mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-01 03:05:50 +00:00
add some stuff to tolerate more buggy switches
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11881 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
39404c4dd3
commit
d458cf3348
@ -173,7 +173,7 @@ typedef enum {
|
|||||||
PFLAG_3PCC_PROXY,
|
PFLAG_3PCC_PROXY,
|
||||||
PFLAG_CALLID_AS_UUID,
|
PFLAG_CALLID_AS_UUID,
|
||||||
PFLAG_UUID_AS_CALLID,
|
PFLAG_UUID_AS_CALLID,
|
||||||
|
PFLAG_SCROOGE,
|
||||||
PFLAG_MAX
|
PFLAG_MAX
|
||||||
} PFLAGS;
|
} PFLAGS;
|
||||||
|
|
||||||
|
@ -1561,7 +1561,11 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||||||
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
|
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
|
||||||
if (!strcasecmp(val, "greedy")) {
|
if (!strcasecmp(val, "greedy")) {
|
||||||
sofia_set_pflag(profile, PFLAG_GREEDY);
|
sofia_set_pflag(profile, PFLAG_GREEDY);
|
||||||
|
} else if (!strcasecmp(val, "scrooge")) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_GREEDY);
|
||||||
|
sofia_set_pflag(profile, PFLAG_SCROOGE);
|
||||||
} else {
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_SCROOGE);
|
||||||
sofia_clear_pflag(profile, PFLAG_GREEDY);
|
sofia_clear_pflag(profile, PFLAG_GREEDY);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(var, "disable-transcoding")) {
|
} else if (!strcasecmp(var, "disable-transcoding")) {
|
||||||
@ -2072,6 +2076,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||||||
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
|
} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
|
||||||
if (!strcasecmp(val, "greedy")) {
|
if (!strcasecmp(val, "greedy")) {
|
||||||
sofia_set_pflag(profile, PFLAG_GREEDY);
|
sofia_set_pflag(profile, PFLAG_GREEDY);
|
||||||
|
} else if (!strcasecmp(val, "scrooge")) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_GREEDY);
|
||||||
|
sofia_set_pflag(profile, PFLAG_SCROOGE);
|
||||||
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_SCROOGE);
|
||||||
|
sofia_clear_pflag(profile, PFLAG_GREEDY);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(var, "disable-transcoding")) {
|
} else if (!strcasecmp(var, "disable-transcoding")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
|
@ -2271,14 +2271,21 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||||||
const char *val;
|
const char *val;
|
||||||
const char *crypto = NULL;
|
const char *crypto = NULL;
|
||||||
int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0, got_udptl = 0;
|
int got_crypto = 0, got_audio = 0, got_avp = 0, got_savp = 0, got_udptl = 0;
|
||||||
|
int scrooge = 0;
|
||||||
|
|
||||||
switch_assert(tech_pvt != NULL);
|
switch_assert(tech_pvt != NULL);
|
||||||
|
|
||||||
greedy = !!sofia_test_pflag(tech_pvt->profile, PFLAG_GREEDY);
|
greedy = !!sofia_test_pflag(tech_pvt->profile, PFLAG_GREEDY);
|
||||||
|
scrooge = !!sofia_test_pflag(tech_pvt->profile, PFLAG_SCROOGE);
|
||||||
if (!greedy) {
|
|
||||||
if ((val = switch_channel_get_variable(channel, "sip_codec_negotiation")) && !strcasecmp(val, "greedy")) {
|
if (!greedy || !scrooge) {
|
||||||
greedy = 1;
|
if ((val = switch_channel_get_variable(channel, "sip_codec_negotiation"))) {
|
||||||
|
if (!strcasecmp(val, "greedy")) {
|
||||||
|
greedy = 1;
|
||||||
|
} else if (!strcasecmp(val, "scrooge")) {
|
||||||
|
scrooge = 1;
|
||||||
|
greedy = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2330,6 +2337,10 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||||||
sofia_glue_toggle_hold(tech_pvt, sendonly);
|
sofia_glue_toggle_hold(tech_pvt, sendonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dptime) {
|
||||||
|
dptime = 20;
|
||||||
|
}
|
||||||
|
|
||||||
for (m = sdp->sdp_media; m; m = m->m_next) {
|
for (m = sdp->sdp_media; m; m = m->m_next) {
|
||||||
sdp_connection_t *connection;
|
sdp_connection_t *connection;
|
||||||
|
|
||||||
@ -2533,8 +2544,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u]/[%s:%d:%u]\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d]/[%s:%d:%u:%d]\n",
|
||||||
rm_encoding, map->rm_pt, (int) map->rm_rate, imp->iananame, imp->ianacode, codec_rate);
|
rm_encoding, map->rm_pt, (int) map->rm_rate, ptime,
|
||||||
|
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000);
|
||||||
if (map->rm_pt < 96) {
|
if (map->rm_pt < 96) {
|
||||||
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
@ -2542,12 +2554,18 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
if ((ptime && ptime * 1000 != imp->microseconds_per_packet) ||
|
if (scrooge) {
|
||||||
map->rm_rate != codec_rate) {
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||||
near_rate = map->rm_rate;
|
"Bah HUMBUG! Sticking with %s@%uh@%ui\n",
|
||||||
near_match = imp;
|
imp->iananame, imp->samples_per_second, imp->microseconds_per_packet / 1000);
|
||||||
match = 0;
|
} else {
|
||||||
continue;
|
if ((ptime && ptime * 1000 != imp->microseconds_per_packet) ||
|
||||||
|
map->rm_rate != codec_rate) {
|
||||||
|
near_rate = map->rm_rate;
|
||||||
|
near_match = imp;
|
||||||
|
match = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mimp = imp;
|
mimp = imp;
|
||||||
break;
|
break;
|
||||||
@ -2561,18 +2579,18 @@ 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_rate ? near_rate : near_match->samples_per_second, ptime);
|
switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%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);
|
||||||
|
|
||||||
if (num) {
|
if (num) {
|
||||||
mimp = search[0];
|
mimp = search[0];
|
||||||
} else {
|
} else {
|
||||||
mimp = near_match;
|
mimp = near_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!maxptime || mimp->microseconds_per_packet / 1000 <= maxptime) {
|
if (!maxptime || mimp->microseconds_per_packet / 1000 <= maxptime) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
|
||||||
mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
|
mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
|
||||||
@ -2581,6 +2599,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
|||||||
mimp = NULL;
|
mimp = NULL;
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match && greedy) {
|
if (!match && greedy) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user