From d89c21fda421aebf1dbff67170c139cf56dd6ad2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 19 Jan 2007 01:36:20 +0000 Subject: [PATCH] a few twiax for early media (part 1) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3992 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_iax/mod_iax.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_iax/mod_iax.c b/src/mod/endpoints/mod_iax/mod_iax.c index 8fb436d2a0..c1f78a424d 100644 --- a/src/mod/endpoints/mod_iax/mod_iax.c +++ b/src/mod/endpoints/mod_iax/mod_iax.c @@ -1033,8 +1033,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void) case IAX_EVENT_TIMEOUT: break; case IAX_EVENT_ACCEPT: - if (tech_pvt) { - tech_media(tech_pvt, iaxevent); + if (channel && !switch_channel_test_flag(channel, CF_ANSWERED)) { + if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) { + switch_channel_set_flag(channel, CF_EARLY_MEDIA); + } else { + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + } } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call accepted.\n"); break; @@ -1047,17 +1051,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void) case IAX_EVENT_ANSWER: // the other side answered our call if (channel) { - tech_media(tech_pvt, iaxevent); - - if (switch_channel_test_flag(channel, CF_ANSWERED)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel)); + if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) { + if (switch_channel_test_flag(channel, CF_ANSWERED)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel)); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel)); + switch_channel_mark_answered(channel); + } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel)); - switch_channel_mark_answered(channel); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } - - } + } break; case IAX_EVENT_CONNECT: // incoming call detected