]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make exception for g722
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 24 Oct 2013 00:04:23 +0000 (05:04 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 24 Oct 2013 00:04:23 +0000 (05:04 +0500)
src/switch_core_codec.c
src/switch_loadable_module.c

index bd3b521a9800e991fceea1d88fc4e39945e9f3e3..db0db33cd5bfa5509c17b26441c0aa565c8d6df5 100644 (file)
@@ -655,7 +655,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec
        /* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
        if (!ms) {
                for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
-                       if ((!rate || rate == iptr->samples_per_second) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) &&
+                       uint32_t crate = !strcasecmp(codec_name, "g722") ? iptr->samples_per_second : iptr->actual_samples_per_second;
+                       if ((!rate || rate == crate) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) &&
                                (20 == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {
                                implementation = iptr;
                                goto found;
@@ -665,7 +666,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec
 
        /* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
        for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
-               if ((!rate || rate == iptr->samples_per_second) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) &&
+               uint32_t crate = !strcasecmp(codec_name, "g722") ? iptr->samples_per_second : iptr->actual_samples_per_second;
+               if ((!rate || rate == crate) && (!bitrate || bitrate == (uint32_t)iptr->bits_per_second) &&
                        (!ms || ms == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {
                        implementation = iptr;
                        break;
index b4d26c2942e03e2e133d4ca522b17c453e12151e..df1e351bba30a11a7dc1d79bf83bde42d7de33d6 100644 (file)
@@ -2310,13 +2310,14 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
                                uint32_t default_rate = switch_default_rate(imp->iananame, imp->ianacode);
                                
                                if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
-                                       
+                                       uint32_t crate = !strcasecmp(imp->iananame, "g722") ? imp->samples_per_second : imp->actual_samples_per_second;
+
                                        if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != default_ptime) ||
                                                (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) {
                                                continue;
                                        }
 
-                                       if (((!rate && (uint32_t) imp->actual_samples_per_second != default_rate) || (rate && (uint32_t) imp->actual_samples_per_second != rate))) {
+                                       if (((!rate && crate != default_rate) || (rate && (uint32_t) imp->actual_samples_per_second != rate))) {
                                                continue;
                                        }
 
@@ -2335,12 +2336,13 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
                        /* Either looking for a specific interval or there was no interval specified and there wasn't one at the default ptime available */
                        for (imp = codec_interface->implementations; imp; imp = imp->next) {
                                if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
+                                       uint32_t crate = !strcasecmp(imp->iananame, "g722") ? imp->samples_per_second : imp->actual_samples_per_second;
 
                                        if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
                                                continue;
                                        }
 
-                                       if (rate && (uint32_t) imp->actual_samples_per_second != rate) {
+                                       if (rate && (uint32_t) crate != rate) {
                                                continue;
                                        }