From ecece5885f6a5605ac6aeebd372ae3e0b8adbe9c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 27 Mar 2008 20:36:03 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7972 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_conference/mod_conference.c | 10 +++++++--- src/mod/endpoints/mod_sofia/mod_sofia.c | 1 - src/mod/endpoints/mod_sofia/sofia_glue.c | 16 +++++++++------- src/switch_core_codec.c | 4 ++++ src/switch_core_state_machine.c | 5 ++++- src/switch_loadable_module.c | 2 +- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 1a3cdf478d..80a8e5ef3c 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -4140,6 +4140,12 @@ SWITCH_STANDARD_APP(conference_function) conf_xml_cfg_t xml_cfg = { 0 }; switch_event_t *params = NULL; + /* Save the original read codec. */ + if (!(read_codec = switch_core_session_get_read_codec(session))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Channel has no media!\n"); + return; + } + if (switch_strlen_zero(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n"); @@ -4376,9 +4382,7 @@ SWITCH_STANDARD_APP(conference_function) if (!switch_channel_test_flag(channel, CF_OUTBOUND)) switch_set_flag(conference, CFLAG_ANSWERED); } - - /* Save the original read codec. */ - read_codec = switch_core_session_get_read_codec(session); + member.orig_read_codec = read_codec; member.native_rate = read_codec->implementation->samples_per_second; member.pool = switch_core_session_get_pool(session); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 14639f1026..43ce3fa965 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1043,7 +1043,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } else { if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) { switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION); - if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index ded7bfcaaa..dfd38d8200 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1961,6 +1961,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * for (map = m->m_rtpmaps; map; map = map->rm_next) { int32_t i; + uint32_t near_rate = 0; const switch_codec_implementation_t *mimp = NULL, *near_match = NULL; const char *rm_encoding; @@ -2018,8 +2019,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1; } - if (match && (map->rm_rate == codec_rate)) { - if (ptime && ptime * 1000 != imp->microseconds_per_frame) { + if (match) { + if ((ptime && ptime * 1000 != imp->microseconds_per_frame) || map->rm_rate != codec_rate) { + near_rate = map->rm_rate; near_match = imp; match = 0; continue; @@ -2036,8 +2038,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * char *prefs[1]; char tmp[80]; int num; - - switch_snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_match->samples_per_second, ptime); + + switch_snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, ptime); prefs[0] = tmp; num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1); @@ -2047,9 +2049,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } else { mimp = near_match; } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ums\n", - mimp->iananame, mimp->microseconds_per_frame / 1000); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n", + mimp->iananame, mimp->microseconds_per_frame / 1000, mimp->samples_per_second); match = 1; } diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 1b97958e60..01f3fb3e0e 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -41,6 +41,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s switch_channel_t *channel = switch_core_session_get_channel(session); char tmp[30]; + switch_assert(codec->implementation); + if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(session->channel, event); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame); @@ -75,6 +77,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_ switch_channel_t *channel = switch_core_session_get_channel(session); char tmp[30]; + switch_assert(codec->implementation); + if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(session->channel, event); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame); diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index dbf6accc3e..ad5fb7d28f 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -160,7 +160,10 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) } else if (!switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) && !switch_channel_media_ready(session->channel)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media! pre_answering channel %s\n", extension->current_application->application_name, switch_channel_get_name(session->channel)); - switch_channel_pre_answer(session->channel); + if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Well, that didn't work very well did it? ...\n"); + return; + } } if ((expanded = diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 699537b512..3c750d547d 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -1245,7 +1245,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ for (x = 0; x < preflen; x++) { char *cur, *last = NULL, *next = NULL, *name, *p, buf[256]; - uint32_t interval = 0, rate = 0; + uint32_t interval = 0, rate = 8000; switch_copy_string(buf, prefs[x], sizeof(buf)); last = name = next = cur = buf;