]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6632 Trying to actually use opus in stereo broke pretending to use it in stereo
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 25 Jun 2014 16:18:51 +0000 (21:18 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 25 Jun 2014 16:19:07 +0000 (21:19 +0500)
src/switch_core_media.c

index 7bc5562f03248f4fccf4af634fada9decca58781..cd0774eb832a3d74cbf3c9150f78a6326ff2d7b6 100644 (file)
@@ -3382,6 +3382,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                const char *rm_encoding;
                                uint32_t map_bit_rate = 0;
                                switch_codec_fmtp_t codec_fmtp = { 0 };
+                               int map_channels = map->rm_params ? atoi(map->rm_params) : 1;
 
                                if (!(rm_encoding = map->rm_encoding)) {
                                        rm_encoding = "";
@@ -3453,14 +3454,18 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                                if (codec_fmtp.actual_samples_per_second) {
                                                        fmtp_remote_codec_rate = codec_fmtp.actual_samples_per_second;
                                                }
+                                               if (codec_fmtp.stereo) {
+                                                       map_channels = 2;
+                                               } else if (!strcasecmp(map->rm_encoding, "opus")) {
+                                                       map_channels = 1;
+                                               }
                                        }
                                }
-                               
+
                                for (i = 0; i < smh->mparams->num_codecs && i < total_codecs; i++) {
                                        const switch_codec_implementation_t *imp = codec_array[i];
                                        uint32_t bit_rate = imp->bits_per_second;
                                        uint32_t codec_rate = imp->samples_per_second;
-                                       int map_channels = map->rm_params ? atoi(map->rm_params) : 1;
 
                                        if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
                                                continue;
@@ -3558,8 +3563,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                        near_match = near_matches[j].imp;
                                        near_map = near_matches[j].map;                                 
                                        
-                                       switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second,
-                                                                       codec_ms);
+                                       switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui%dc", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second,
+                                                                       codec_ms, near_match->number_of_channels);
                                        
                                        prefs[0] = tmp;
                                        num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
@@ -3571,8 +3576,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                        }
                                
                                        if (!maxptime || timp->microseconds_per_packet / 1000 <= maxptime) {
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
-                                                                                 timp->iananame, timp->microseconds_per_packet / 1000, timp->actual_samples_per_second);
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh@%dc\n",
+                                                                                 timp->iananame, timp->microseconds_per_packet / 1000, timp->actual_samples_per_second, timp->number_of_channels);
                                                match = 1;
 
                                                matches[m_idx].codec_idx = near_matches[j].codec_idx;