[Freeswitch-svn] [commit] r5181 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia
Author: anthm Date: Mon May 14 19:50:38 2007 New Revision: 5181 Modified: freeswitch/trunk/src/include/switch_ivr.h freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/switch_core_session.c freeswitch/trunk/src/switch_ivr.c freeswitch/trunk/src/switch_ivr_async.c freeswitch/trunk/src/switch_ivr_bridge.c freeswitch/trunk/src/switch_ivr_play_say.c Log: update Modified: freeswitch/trunk/src/include/switch_ivr.h ============================================================================== --- freeswitch/trunk/src/include/switch_ivr.h (original) +++ freeswitch/trunk/src/include/switch_ivr.h Mon May 14 19:50:38 2007 @@ -92,13 +92,20 @@ /*! \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. \param ms the number of milliseconds Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon May 14 19:50:38 2007 @@ -690,6 +690,11 @@ 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 @@ 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)) { Modified: freeswitch/trunk/src/switch_core_session.c ============================================================================== --- freeswitch/trunk/src/switch_core_session.c (original) +++ freeswitch/trunk/src/switch_core_session.c Mon May 14 19:50:38 2007 @@ -581,6 +581,7 @@ return status; } + SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session) { switch_channel_t *channel; Modified: freeswitch/trunk/src/switch_ivr.c ============================================================================== --- freeswitch/trunk/src/switch_ivr.c (original) +++ freeswitch/trunk/src/switch_ivr.c Mon May 14 19:50:38 2007 @@ -374,6 +374,23 @@ } +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_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 @@ } } - 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 @@ } } - 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 @@ 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 @@ } } - 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_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 @@ } 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) { Modified: freeswitch/trunk/src/switch_ivr_async.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_async.c (original) +++ freeswitch/trunk/src/switch_ivr_async.c Mon May 14 19:50:38 2007 @@ -771,7 +771,7 @@ if ((session = switch_core_session_locate(uuid))) { char *cause = NULL; - char *mypath = strdup(path); + char *mypath; char *p; master = session; @@ -779,6 +779,16 @@ 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); } Modified: freeswitch/trunk/src/switch_ivr_bridge.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_bridge.c (original) +++ freeswitch/trunk/src/switch_ivr_bridge.c Mon May 14 19:50:38 2007 @@ -55,6 +55,7 @@ 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 @@ 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 @@ 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; } Modified: freeswitch/trunk/src/switch_ivr_play_say.c ============================================================================== --- freeswitch/trunk/src/switch_ivr_play_say.c (original) +++ freeswitch/trunk/src/switch_ivr_play_say.c Mon May 14 19:50:38 2007 @@ -394,11 +394,9 @@ 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 @@ } 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 @@ 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 @@ } 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);
participants (1)
-
Freeswitch SVN