]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] RFC 3264 says once we assign a payload number to a dynamic codec, we are stuck...
authorMichael Jerris <mike@jerris.com>
Fri, 17 Dec 2021 20:55:11 +0000 (13:55 -0700)
committerAndrey Volk <andywolk@gmail.com>
Fri, 17 Dec 2021 20:56:43 +0000 (23:56 +0300)
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>
src/switch_core_media.c

index 0b337082b831fe50ef59be08cf8c3787dc7b6f64..1b7f392761b059341895f60c46dcf09d21f3a645 100644 (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) {