git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7972 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-03-27 20:36:03 +00:00
parent da72bfb9f6
commit ecece5885f
6 changed files with 25 additions and 13 deletions

View File

@ -4140,6 +4140,12 @@ SWITCH_STANDARD_APP(conference_function)
conf_xml_cfg_t xml_cfg = { 0 }; conf_xml_cfg_t xml_cfg = { 0 };
switch_event_t *params = NULL; 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)) { if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n"); 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)) if (!switch_channel_test_flag(channel, CF_OUTBOUND))
switch_set_flag(conference, CFLAG_ANSWERED); 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.orig_read_codec = read_codec;
member.native_rate = read_codec->implementation->samples_per_second; member.native_rate = read_codec->implementation->samples_per_second;
member.pool = switch_core_session_get_pool(session); member.pool = switch_core_session_get_pool(session);

View File

@ -1043,7 +1043,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
} else { } else {
if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) { if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION); switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);

View File

@ -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) { for (map = m->m_rtpmaps; map; map = map->rm_next) {
int32_t i; int32_t i;
uint32_t near_rate = 0;
const switch_codec_implementation_t *mimp = NULL, *near_match = NULL; const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
const char *rm_encoding; 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; match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
} }
if (match && (map->rm_rate == codec_rate)) { if (match) {
if (ptime && ptime * 1000 != imp->microseconds_per_frame) { if ((ptime && ptime * 1000 != imp->microseconds_per_frame) || map->rm_rate != codec_rate) {
near_rate = map->rm_rate;
near_match = imp; near_match = imp;
match = 0; match = 0;
continue; continue;
@ -2036,8 +2038,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
char *prefs[1]; char *prefs[1];
char tmp[80]; char tmp[80];
int num; 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; prefs[0] = tmp;
num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1); 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 { } else {
mimp = near_match; mimp = near_match;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ums\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
mimp->iananame, mimp->microseconds_per_frame / 1000); mimp->iananame, mimp->microseconds_per_frame / 1000, mimp->samples_per_second);
match = 1; match = 1;
} }

View File

@ -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); switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30]; char tmp[30];
switch_assert(codec->implementation);
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event); switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame); 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); switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30]; char tmp[30];
switch_assert(codec->implementation);
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event); switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame);

View File

@ -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)) { } 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", 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)); 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 = if ((expanded =

View File

@ -1245,7 +1245,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
for (x = 0; x < preflen; x++) { for (x = 0; x < preflen; x++) {
char *cur, *last = NULL, *next = NULL, *name, *p, buf[256]; 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)); switch_copy_string(buf, prefs[x], sizeof(buf));
last = name = next = cur = buf; last = name = next = cur = buf;