]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix codec regression from yesterday
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 30 Sep 2010 20:15:33 +0000 (15:15 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 30 Sep 2010 20:15:58 +0000 (15:15 -0500)
src/include/switch_utils.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_loadable_module.c

index 6cf7212bfe807c2ba8cd2b1835acc70d324a7381..e5d70c43cc379914337a28ff8419ca902df71f2f 100644 (file)
@@ -177,6 +177,23 @@ static inline switch_bool_t switch_is_digit_string(const char *s)
        return SWITCH_TRUE;
 }
 
+
+static inline uint32_t switch_known_bitrate(switch_payload_t payload)
+{
+       switch(payload) {
+       case 0: /* PCMU */ return 64000;
+       case 3: /* GSM */ return 13200;
+       case 4: /* G723 */ return 6300;
+       case 7: /* LPC */ return 2400;
+       case 8: /* PCMA */ return 64000;
+       case 9: /* G722 */ return 64000;
+       case 18: /* G729 */ return 8000;
+       default: break;
+       }
+
+       return 0;
+}
+
 SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len);
 
 
index f1d2dcf1bcbe725a53ac115d5fa41aca873efe5b..e4933c63c16736083e804eb250d062ba069f5d3f 100644 (file)
@@ -4148,8 +4148,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                        for (map = m->m_rtpmaps; map; map = map->rm_next) {
                                int32_t i;
                                uint32_t near_rate = 0;
-                               uint32_t near_bit_rate = 0;
-                               switch_codec_interface_t *codec_interface;
                                const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
                                const char *rm_encoding;
                                uint32_t map_bit_rate = 0;
@@ -4197,22 +4195,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                        ptime = switch_default_ptime(rm_encoding, map->rm_pt);
                                }
 
-                               /* This will try to use codec specific fmtp parser */
-                               if (map->rm_fmtp && (codec_interface = switch_loadable_module_get_codec_interface(rm_encoding)) != 0) {
-                                       switch_codec_fmtp_t codec_fmtp;
-                                       memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
-                                       codec_fmtp.actual_samples_per_second = map->rm_rate;
-                                       if (codec_interface->parse_fmtp && codec_interface->parse_fmtp(map->rm_fmtp, &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) {
-                                                       ptime = (codec_fmtp.microseconds_per_packet / 1000);
-                                               }
-                                       }
-                                       UNPROTECT_INTERFACE(codec_interface);
-                               }
-
+                               map_bit_rate = switch_known_bitrate(map->rm_pt);
 
                                if (!codec_ms) {
                                        codec_ms = ptime;
@@ -4235,19 +4218,19 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                                match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
                                        }
 
+                                       if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate) {
+                                               /* nevermind */
+                                               match = 0;
+                                       }
+                                       
                                        if (match) {
                                                if (scrooge) {
                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
                                                                                          "Bah HUMBUG! Sticking with %s@%uh@%ui\n",
                                                                                          imp->iananame, imp->samples_per_second, imp->microseconds_per_packet / 1000);
                                                } else {
-                                                       if ((codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate || (map_bit_rate && map_bit_rate != bit_rate) ) {
+                                                       if ((codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
                                                                near_rate = map->rm_rate;
-                                                               if (map_bit_rate) {
-                                                                       near_bit_rate = map_bit_rate;
-                                                               } else {
-                                                                       near_bit_rate = bit_rate;
-                                                               }
                                                                near_match = imp;
                                                                match = 0;
                                                                continue;
@@ -4260,7 +4243,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                        }
                                }
 
-                               if (!match && near_match && !map->rm_next) {
+                               if (!match && near_match) {
                                        const switch_codec_implementation_t *search[1];
                                        char *prefs[1];
                                        char tmp[80];
index 5466c189835801169dc6299a5518d12029e5931a..7e08f714728d227a6fb67048afcc44cecd211f09 100644 (file)
@@ -183,8 +183,9 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
                                if (load_interface) {
                                        for (impl = ptr->implementations; impl; impl = impl->next) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                                                                 "Adding Codec '%s' (%s) %dhz %dms %dbps\n",
-                                                                                 impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000, impl->bits_per_second);
+                                                                                 "Adding Codec %s %d %s %dhz %dms %dbps\n",
+                                                                                 impl->iananame, impl->ianacode,
+                                                                                 ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000, impl->bits_per_second);
                                                if (!switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {
                                                        switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) ptr);
                                                }
@@ -515,8 +516,9 @@ static switch_status_t switch_loadable_module_unprocess(switch_loadable_module_t
                                if (load_interface) {
                                        for (impl = ptr->implementations; impl; impl = impl->next) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                                                                 "Deleting Codec '%s' (%s) %dhz %dms\n",
-                                                                                 impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
+                                                                                 "Deleting Codec %s %d %s %dhz %dms\n",
+                                                                                 impl->iananame, impl->ianacode,
+                                                                                 ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
                                                switch_core_session_hupall_matching_var("read_codec", impl->iananame, SWITCH_CAUSE_MANAGER_REQUEST);
                                                switch_core_session_hupall_matching_var("write_codec", impl->iananame, SWITCH_CAUSE_MANAGER_REQUEST);
                                                if (switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {