]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9654 additional changes
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 16 Jan 2017 20:10:39 +0000 (14:10 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 16 Jan 2017 20:10:39 +0000 (14:10 -0600)
src/switch_core_media.c

index 0c787e6aa50c9a9e3d9c230d5280379419e819aa..f2457b200a5df5f1558e73f5344b6d194f949fc8 100644 (file)
@@ -799,7 +799,6 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
        int exists = 0;
        switch_media_handle_t *smh;
        switch_rtp_engine_t *engine;
-       int local_pt = 0;
 
        switch_assert(session);
 
@@ -831,7 +830,6 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
                                if (!zstr(fmtp) && !zstr(pmap->rm_fmtp)) {
                                        if (strcmp(pmap->rm_fmtp, fmtp)) {
                                                exists = 0;
-                                               local_pt = pmap->pt;
                                                continue;
                                        }
                                }
@@ -850,7 +848,6 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
                                if (type != SWITCH_MEDIA_TYPE_TEXT && !zstr(fmtp) && !zstr(pmap->rm_fmtp)) {
                                        if (strcmp(pmap->rm_fmtp, fmtp)) {
                                                exists = 0;
-                                               local_pt = pmap->pt;
                                                continue;
                                        }
                                }
@@ -894,8 +891,10 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
                pmap->modname = switch_core_strdup(session->pool, modname);
        }
 
-       if (!zstr(fmtp) && (zstr(pmap->rm_fmtp) || strcmp(pmap->rm_fmtp, fmtp))) {
-               pmap->rm_fmtp = switch_core_strdup(session->pool, fmtp);
+       if (!zstr(fmtp)) {
+               if (sdp_type == SDP_TYPE_REQUEST || !exists) {
+                       pmap->rm_fmtp = switch_core_strdup(session->pool, fmtp);
+               }
        }
 
        pmap->allocated = 1;
@@ -904,7 +903,7 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
 
 
        if (sdp_type == SDP_TYPE_REQUEST || !exists) {
-               pmap->pt = (switch_payload_t)  (local_pt ? local_pt : pt);
+               pmap->pt = (switch_payload_t) pt;
        }
 
        if (negotiated) {
@@ -4121,7 +4120,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
        const char *tmp;
        int m_idx = 0, skip_rtcp = 0, skip_video_rtcp = 0, got_rtcp_mux = 0, got_video_rtcp_mux = 0;
        int nm_idx = 0;
-       int vmatch_pt = 0;
+       int vmatch_pt = 1, consider_video_fmtp = 1;
        int rtcp_auto_audio = 0, rtcp_auto_video = 0;
        int got_audio_rtcp = 0, got_video_rtcp = 0;
        switch_port_t audio_port = 0, video_port = 0;
@@ -5272,6 +5271,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                        const char *rm_encoding;
                        const switch_codec_implementation_t *mimp = NULL;
                        int i;
+                       const char *inherit_video_fmtp = NULL;
 
                        vmatch = 0;
                        nm_idx = 0;
@@ -5438,23 +5438,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                                vmatch = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
                                        }
 
-                                       if (sdp_type == SDP_TYPE_RESPONSE && vmatch && map->rm_fmtp) {
-                                               int fmatch = 0;
-                                               int fcount = 0;
-                                               payload_map_t *pmap;
-                                               
-                                               for (pmap = v_engine->payload_map; pmap && pmap->allocated; pmap = pmap->next) {
-                                                       if (pmap->rm_fmtp) {
-                                                               fcount++;
-                                                               if ((fmatch = !strcasecmp(pmap->rm_fmtp, map->rm_fmtp))) {
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-
-                                               if (fcount && !fmatch) {
-                                                       vmatch = 0;
-                                               }
+                                       if (sdp_type == SDP_TYPE_RESPONSE && vmatch && map->rm_fmtp && consider_video_fmtp) {
+                                               vmatch = !strcasecmp(smh->fmtps[i], map->rm_fmtp);
                                        }
 
                                        if (vmatch && vmatch_pt) {
@@ -5464,6 +5449,10 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                                        int opt = atoi(other_pt);
                                                        if (map->rm_pt != opt) {
                                                                vmatch = 0;
+                                                       } else {
+                                                               if (switch_channel_var_true(channel, "inherit_video_fmtp")) {
+                                                                       inherit_video_fmtp = switch_channel_get_variable_partner(channel, "rtp_video_fmtp");
+                                                               }
                                                        }
                                                }
                                        }
@@ -5482,7 +5471,14 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                }
                        }
 
+                       if (consider_video_fmtp && !m_idx) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No matches with FTMP, fallback to ignoring FMTP\n");
+                               consider_video_fmtp = 0;
+                               goto compare;
+                       }
+
                        if (vmatch_pt && !m_idx) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No matches with inherit_codec, fallback to ignoring PT\n");
                                vmatch_pt = 0;
                                goto compare;
                        }
@@ -5537,7 +5533,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
 
                                        pmap->remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address);
                                        pmap->remote_sdp_port = (switch_port_t) m->m_port;
-                                       pmap->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
+                                       pmap->rm_fmtp = switch_core_session_strdup(session, (char *) inherit_video_fmtp ? inherit_video_fmtp : map->rm_fmtp);
                                        smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp;                                    
                                                
 #if 0
@@ -9417,7 +9413,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
 
                                                smh->ianacodes[i] = orig_pt;
                                                                                                
-                                               if (orig_fmtp) {
+                                               if (!zstr(orig_fmtp)) {
                                                        smh->fmtps[i] = switch_core_session_strdup(session, orig_fmtp);
                                                }
                                        } else {