提交 614177ac authored 作者: Anthony Minessale's avatar Anthony Minessale

update

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5181 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 3db8dd0e
......@@ -92,12 +92,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_
/*!
\brief Parse command from an event
\param session the session to send the message to
\param event the event to send
\param session the session on which to parse the event
\param event the event to parse
\return SWITCH_STATUS_SUCCESS if successful
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event);
/*!
\brief Parse all commands from an event
\param session the session on which to parse the events
\return SWITCH_STATUS_SUCCESS if successful
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session);
/*!
\brief Wait for time to pass for a specified number of milliseconds
\param session the session to wait for.
......
......@@ -690,6 +690,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_core_session_t *other_session;
switch_channel_t *other_channel;
char *ip = NULL, *port = NULL;
if (switch_channel_get_state(channel) >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
tech_pvt->local_sdp_str = NULL;
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
......@@ -710,6 +715,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
break;
case SWITCH_MESSAGE_INDICATE_MEDIA:{
uint32_t count = 0;
if (switch_channel_get_state(channel) >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
tech_pvt->local_sdp_str = NULL;
if (!switch_rtp_ready(tech_pvt->rtp_session)) {
......
......@@ -581,6 +581,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch
return status;
}
SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session)
{
switch_channel_t *channel;
......
......@@ -374,6 +374,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
}
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
{
switch_event_t *event;
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
while (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_fire(&event);
}
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
......@@ -383,6 +400,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
switch_event_t *event;
switch_unicast_conninfo_t *conninfo = NULL;
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
......@@ -467,10 +485,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
}
}
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_channel_event_set_data(switch_core_session_get_channel(session), event);
switch_event_fire(&event);
if (switch_core_session_private_event_count(session)) {
switch_ivr_parse_all_events(session);
}
if (switch_channel_has_dtmf(channel)) {
......@@ -540,10 +556,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
}
}
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_destroy(&event);
}
if (switch_core_session_private_event_count(session)) {
switch_ivr_parse_all_events(session);
}
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
......@@ -606,8 +621,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
while (switch_channel_ready(channel)) {
switch_frame_t *read_frame;
switch_event_t *event;
if (timeout) {
elapsed = (uint32_t) ((switch_time_now() - started) / 1000);
if (elapsed >= timeout) {
......@@ -615,10 +629,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
}
}
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_destroy(&event);
}
if (switch_core_session_private_event_count(session)) {
switch_ivr_parse_all_events(session);
}
if (switch_channel_has_dtmf(channel)) {
char dtmf[128];
......@@ -776,8 +789,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag
switch_core_session_message_t msg = { 0 };
switch_status_t status = SWITCH_STATUS_GENERR;
uint8_t swap = 0;
switch_event_t *event;
msg.message_id = SWITCH_MESSAGE_INDICATE_NOMEDIA;
msg.from = __FILE__;
......@@ -791,27 +803,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)) {
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_core_session_receive_message(session, &msg);
switch_ivr_parse_all_events(session);
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
other_channel = switch_core_session_get_channel(other_session);
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_ivr_parse_all_events(other_session);
switch_core_session_receive_message(other_session, &msg);
switch_channel_clear_state_handler(other_channel, NULL);
}
switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if (other_channel) {
switch_channel_clear_state_handler(channel, NULL);
if (swap) {
......
......@@ -771,7 +771,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
if ((session = switch_core_session_locate(uuid))) {
char *cause = NULL;
char *mypath = strdup(path);
char *mypath;
char *p;
master = session;
......@@ -779,6 +779,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
switch_channel_get_name(channel));
switch_core_session_rwunlock(session);
return SWITCH_STATUS_FALSE;
}
mypath = strdup(path);
if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE);
}
......
......@@ -55,6 +55,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
switch_channel_t *chan_a, *chan_b;
switch_frame_t *read_frame;
switch_core_session_t *session_a, *session_b;
uint32_t loop_count = 0;
session_a = data->session;
if (!(session_b = switch_core_session_locate(data->b_uuid))) {
......@@ -80,6 +81,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
switch_channel_state_t b_state;
switch_status_t status;
switch_event_t *event;
loop_count++;
/* if you really want to make sure it's not ready, test it twice because it might be just a break */
if (!switch_channel_ready(chan_a) && !switch_channel_ready(chan_a)) {
......@@ -96,21 +98,20 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
break;
}
if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
if (loop_count > 10 && switch_core_session_private_event_count(session_a)) {
switch_channel_set_flag(chan_b, CF_SUSPEND);
msg.string_arg = data->b_uuid;
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
msg.from = __FILE__;
switch_core_session_receive_message(session_a, &msg);
switch_ivr_parse_event(session_a, event);
switch_ivr_parse_all_events(session_a);
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
switch_core_session_receive_message(session_a, &msg);
switch_channel_clear_flag(chan_b, CF_SUSPEND);
switch_event_destroy(&event);
}
if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
switch_yield(100000);
switch_yield(1000);
continue;
}
......
......@@ -394,11 +394,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
while (switch_channel_ready(channel)) {
switch_size_t len;
switch_event_t *event;
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_destroy(&event);
if (switch_core_session_private_event_count(session)) {
switch_ivr_parse_all_events(session);
}
if (start && (time(NULL) - start) > limit) {
......@@ -425,6 +423,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
}
if (args->input_callback) {
switch_event_t *event = NULL;
if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
switch_event_destroy(&event);
......@@ -682,12 +682,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
int done = 0;
int do_speed = 1;
int last_speed = -1;
switch_event_t *event;
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
switch_event_destroy(&event);
if (switch_core_session_private_event_count(session)) {
switch_ivr_parse_all_events(session);
}
if (args && (args->input_callback || args->buf || args->buflen)) {
......@@ -711,6 +708,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
}
if (args->input_callback) {
switch_event_t *event;
if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
status = args->input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, args->buf, args->buflen);
switch_event_destroy(&event);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论