提交 139b505f authored 作者: Anthony Minessale's avatar Anthony Minessale

update

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5178 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 7a8c8479
...@@ -272,15 +272,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se ...@@ -272,15 +272,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen); unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen); unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
char *lead_frames = switch_event_get_header(event, "lead-frames"); char *lead_frames = switch_event_get_header(event, "lead-frames");
switch_status_t status = SWITCH_STATUS_SUCCESS;
assert(channel != NULL); assert(channel != NULL);
assert(event != NULL); assert(event != NULL);
if (switch_strlen_zero(cmd)) { if (switch_strlen_zero(cmd)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Command!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Command!\n");
status = SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
goto done;
} }
hlen = (switch_size_t) strlen(cmd); hlen = (switch_size_t) strlen(cmd);
...@@ -291,11 +289,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se ...@@ -291,11 +289,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
if (lead_frames) { if (lead_frames) {
switch_frame_t *read_frame; switch_frame_t *read_frame;
int frame_count = atoi(lead_frames); int frame_count = atoi(lead_frames);
switch_status_t status;
while(frame_count > 0) { while(frame_count > 0) {
status = switch_core_session_read_frame(session, &read_frame, -1, 0); status = switch_core_session_read_frame(session, &read_frame, -1, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
goto done; return status;
} }
if (!switch_test_flag(read_frame, SFF_CNG)) { if (!switch_test_flag(read_frame, SFF_CNG)) {
frame_count--; frame_count--;
...@@ -366,33 +365,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se ...@@ -366,33 +365,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_channel_hangup(channel, cause); switch_channel_hangup(channel, cause);
} else if (cmd_hash == CMD_NOMEDIA) { } else if (cmd_hash == CMD_NOMEDIA) {
char *uuid = switch_event_get_header(event, "nomedia-uuid"); char *uuid = switch_event_get_header(event, "nomedia-uuid");
char *waitfor = switch_event_get_header(event, "wait-for");
if (waitfor) {
switch_core_session_t *w_session;
if ((w_session = switch_core_session_locate(waitfor))) {
switch_channel_t *w_channel = switch_core_session_get_channel(w_session);
int sanity = 0;
while(switch_channel_test_flag(w_channel, CF_WAIT_FOR_ME)) {
switch_yield(1000);
if (++sanity > 10000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Timeout waiting for channel %s\n", switch_channel_get_name(w_channel));
switch_channel_clear_flag(w_channel, CF_WAIT_FOR_ME);
break;
}
}
switch_core_session_rwunlock(w_session);
}
}
switch_ivr_nomedia(uuid, SMF_REBRIDGE); switch_ivr_nomedia(uuid, SMF_REBRIDGE);
} }
done:
switch_channel_clear_flag(channel, CF_EVENT_PARSE); switch_channel_clear_flag(channel, CF_EVENT_PARSE);
switch_channel_clear_flag(channel, CF_WAIT_FOR_ME); return SWITCH_STATUS_SUCCESS;
return status;
} }
...@@ -798,6 +776,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag ...@@ -798,6 +776,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag
switch_core_session_message_t msg = { 0 }; switch_core_session_message_t msg = { 0 };
switch_status_t status = SWITCH_STATUS_GENERR; switch_status_t status = SWITCH_STATUS_GENERR;
uint8_t swap = 0; uint8_t swap = 0;
switch_event_t *event;
msg.message_id = SWITCH_MESSAGE_INDICATE_NOMEDIA; msg.message_id = SWITCH_MESSAGE_INDICATE_NOMEDIA;
msg.from = __FILE__; msg.from = __FILE__;
...@@ -812,12 +791,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag ...@@ -812,12 +791,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag
} }
if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) { if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
while (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_destroy(&event);
}
switch_channel_set_flag(channel, CF_BYPASS_MEDIA); switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg); switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) { (other_session = switch_core_session_locate(other_uuid))) {
other_channel = switch_core_session_get_channel(other_session); other_channel = switch_core_session_get_channel(other_session);
assert(other_channel != NULL); assert(other_channel != NULL);
while (switch_core_session_dequeue_private_event(other_session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(other_session, event);
switch_event_destroy(&event);
}
switch_core_session_receive_message(other_session, &msg); switch_core_session_receive_message(other_session, &msg);
switch_channel_clear_state_handler(other_channel, NULL); switch_channel_clear_state_handler(other_channel, NULL);
......
...@@ -775,10 +775,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi ...@@ -775,10 +775,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
char *p; char *p;
master = session; master = session;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) { if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE); switch_ivr_media(uuid, SMF_REBRIDGE);
} }
...@@ -796,9 +796,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi ...@@ -796,9 +796,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
} }
} }
if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))
&& (other_session = switch_core_session_locate(other_uuid))) { && (other_session = switch_core_session_locate(other_uuid))) {
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
...@@ -807,13 +806,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi ...@@ -807,13 +806,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
if ((flags & SMF_LOOP)) { if ((flags & SMF_LOOP)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
} }
switch_core_session_queue_private_event(other_session, &event); switch_core_session_queue_private_event(other_session, &event);
} }
master = other_session;
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
master = other_session;
other_session = NULL; other_session = NULL;
} }
...@@ -835,17 +833,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi ...@@ -835,17 +833,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
if ((flags & SMF_ECHO_BLEG) && (flags & SMF_ECHO_ALEG)) {
switch_channel_t *channel = switch_core_session_get_channel(master);
char *bto = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
if ((other_session = switch_core_session_locate(bto))) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_channel_set_flag(other_channel, CF_WAIT_FOR_ME);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "wait-for", "%s", bto);
switch_core_session_rwunlock(other_session);
}
}
switch_core_session_queue_private_event(master, &event); switch_core_session_queue_private_event(master, &event);
} }
} }
......
...@@ -96,11 +96,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) ...@@ -96,11 +96,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
break; break;
} }
if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
switch_yield(100000);
continue;
}
if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) { if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_flag(chan_b, CF_SUSPEND); switch_channel_set_flag(chan_b, CF_SUSPEND);
msg.string_arg = data->b_uuid; msg.string_arg = data->b_uuid;
...@@ -114,6 +109,10 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) ...@@ -114,6 +109,10 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
switch_event_destroy(&event); switch_event_destroy(&event);
} }
if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
switch_yield(100000);
continue;
}
/* if 1 channel has DTMF pass it to the other */ /* if 1 channel has DTMF pass it to the other */
if (switch_channel_has_dtmf(chan_a)) { if (switch_channel_has_dtmf(chan_a)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论