fix bridge app to make sure both channels are ready for media when one is only in ringing state
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9449 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
bfafa0bd36
commit
2e46528e52
|
@ -723,7 +723,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
||||||
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
|
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
|
||||||
switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
|
switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
|
||||||
|
|
||||||
if (!(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
|
if (!switch_channel_media_ready(caller_channel) ||
|
||||||
|
!(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
|
||||||
if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS) {
|
if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
|
switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
|
||||||
switch_channel_hangup(peer_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
|
switch_channel_hangup(peer_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
|
||||||
|
|
|
@ -395,6 +395,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_core_session_dequeue_message(peer_session, &message) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_dequeue_message(peer_session, &message) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (switch_test_flag(message, SCSMF_DYNAMIC)) {
|
if (switch_test_flag(message, SCSMF_DYNAMIC)) {
|
||||||
switch_safe_free(message);
|
switch_safe_free(message);
|
||||||
|
@ -402,17 +403,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
||||||
message = NULL;
|
message = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (switch_channel_media_ready(caller_channel)) {
|
||||||
|
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
read_frame = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (read_frame && !pass) {
|
if (read_frame && !pass) {
|
||||||
if (ringback.fh) {
|
if (ringback.fh) {
|
||||||
switch_size_t mlen, olen;
|
switch_size_t mlen, olen;
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
|
|
||||||
if (ringback.asis) {
|
if (ringback.asis) {
|
||||||
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
|
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
|
||||||
} else {
|
} else {
|
||||||
|
@ -443,8 +448,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
if ((ringback.fh || ringback.audio_buffer) && write_frame.codec && write_frame.datalen) {
|
||||||
break;
|
if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_yield(1000);
|
switch_yield(1000);
|
||||||
|
@ -1202,10 +1209,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
||||||
(ringback_data
|
(ringback_data
|
||||||
|| (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)))) {
|
|| (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)))) {
|
||||||
|
|
||||||
switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
switch_status_t tstatus = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
if (switch_channel_media_ready(caller_channel)) {
|
||||||
break;
|
tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
|
||||||
|
if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
read_frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ring_ready && read_frame && !pass) {
|
if (ring_ready && read_frame && !pass) {
|
||||||
|
|
Loading…
Reference in New Issue