[Core] RFC 3264 says once we assign a payload number to a dynamic codec, we are stuck with it.

8.3.1 Modifying Address, Port or Transport

   The port number for a stream MAY be changed.  To do this, the offerer
   creates a new media description, with the port number in the m line
   different from the corresponding stream in the previous SDP.  If only
   the port number is to be changed, the rest of the media stream
   description SHOULD remain unchanged.  The offerer MUST be prepared to
   receive media on both the old and new ports as soon as the offer is
   sent.  The offerer SHOULD NOT cease listening for media on the old
   port until the answer is received and media arrives on the new port.
   Doing so could result in loss of media during the transition.

Co-authored-by: Anthony Minessale <anthm@signalwire.com>
This commit is contained in:
Michael Jerris 2021-12-17 13:55:11 -07:00 committed by Andrey Volk
parent 862a19e103
commit 6c87ed4915
1 changed files with 26 additions and 6 deletions

View File

@ -9907,7 +9907,8 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
int this_ptime = (imp->microseconds_per_packet / 1000);
payload_map_t *pmap;
if (!strcasecmp(imp->iananame, "ilbc") || !strcasecmp(imp->iananame, "isac") ) {
this_ptime = 20;
}
@ -9932,7 +9933,18 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
continue;
}
switch_mutex_lock(smh->sdp_mutex);
for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
if (pmap->negotiated && !strcasecmp(imp->iananame, pmap->iananame)) {
smh->ianacodes[i] = pmap->pt;
break;
}
}
switch_mutex_unlock(smh->sdp_mutex);
already_did[smh->ianacodes[i]] = 1;
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), " %d", smh->ianacodes[i]);
}
@ -11114,13 +11126,21 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
continue;
}
if (smh->ianacodes[i] < 128) {
if (already_did[smh->ianacodes[i]]) {
continue;
}
already_did[smh->ianacodes[i]] = 1;
if (smh->ianacodes[i] >= 128 || already_did[smh->ianacodes[i]]) {
continue;
}
switch_mutex_lock(smh->sdp_mutex);
for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
if (pmap->negotiated && !strcasecmp(imp->iananame, pmap->iananame)) {
smh->ianacodes[i] = pmap->pt;
break;
}
}
switch_mutex_unlock(smh->sdp_mutex);
already_did[smh->ianacodes[i]] = 1;
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->ianacodes[i]);
if (!ptime) {