forked from Mirrors/freeswitch
Fix iLBC when using ep_codec_string
This commit is contained in:
parent
9462f53c90
commit
85c22d10e2
@ -163,7 +163,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
|
|||||||
"mode=30", /* default fmtp to send (can be overridden by the init function) */
|
"mode=30", /* default fmtp to send (can be overridden by the init function) */
|
||||||
8000, /* samples transferred per second */
|
8000, /* samples transferred per second */
|
||||||
8000, /* actual samples transferred per second */
|
8000, /* actual samples transferred per second */
|
||||||
13300, /* bits transferred per second */
|
13330, /* bits transferred per second */
|
||||||
30000, /* number of microseconds per frame */
|
30000, /* number of microseconds per frame */
|
||||||
ILBC_BLOCK_LEN_30MS, /* number of samples per frame */
|
ILBC_BLOCK_LEN_30MS, /* number of samples per frame */
|
||||||
ILBC_BLOCK_LEN_30MS * 2, /* number of bytes per frame decompressed */
|
ILBC_BLOCK_LEN_30MS * 2, /* number of bytes per frame decompressed */
|
||||||
|
@ -3550,13 +3550,53 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
if (ptime > 0) {
|
int codec_ms = ptime;
|
||||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate,
|
uint32_t map_bit_rate = 0;
|
||||||
ptime);
|
char ptstr[20] = "";
|
||||||
} else {
|
char ratestr[20] = "";
|
||||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh", imp->iananame, (unsigned int) map->rm_rate);
|
char bitstr[20] = "";
|
||||||
|
switch_codec_fmtp_t codec_fmtp = { 0 };
|
||||||
|
|
||||||
|
if (!codec_ms) {
|
||||||
|
codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt);
|
||||||
}
|
}
|
||||||
already_did[imp->ianacode] = 1;
|
|
||||||
|
map_bit_rate = switch_known_bitrate(map->rm_pt);
|
||||||
|
|
||||||
|
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
|
||||||
|
ptime = codec_ms = 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(map->rm_fmtp)) {
|
||||||
|
if (!strcasecmp(map->rm_encoding, "ilbc")) {
|
||||||
|
ptime = codec_ms = 30;
|
||||||
|
map_bit_rate = 13330;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
if (codec_fmtp.bits_per_second) {
|
||||||
|
map_bit_rate = codec_fmtp.bits_per_second;
|
||||||
|
}
|
||||||
|
if (codec_fmtp.microseconds_per_packet) {
|
||||||
|
codec_ms = (codec_fmtp.microseconds_per_packet / 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map->rm_rate) {
|
||||||
|
switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codec_ms) {
|
||||||
|
switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_bit_rate) {
|
||||||
|
switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4378,6 +4418,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
|||||||
if (zstr(map->rm_fmtp)) {
|
if (zstr(map->rm_fmtp)) {
|
||||||
if (!strcasecmp(map->rm_encoding, "ilbc")) {
|
if (!strcasecmp(map->rm_encoding, "ilbc")) {
|
||||||
ptime = codec_ms = 30;
|
ptime = codec_ms = 30;
|
||||||
|
map_bit_rate = 13330;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
|
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
|
||||||
@ -4390,8 +4431,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
|
for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
|
||||||
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
|
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
|
||||||
uint32_t bit_rate = imp->bits_per_second;
|
uint32_t bit_rate = imp->bits_per_second;
|
||||||
@ -4401,7 +4440,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n",
|
||||||
rm_encoding, map->rm_pt, (int) map->rm_rate, ptime, map_bit_rate,
|
rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms, map_bit_rate,
|
||||||
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate);
|
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate);
|
||||||
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
|
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
|
||||||
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user