From e8ecf7c887fb43ae2c0977ee820e5217f8199650 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 7 Mar 2013 16:21:37 -0600 Subject: [PATCH] FS-4846 --resolve --- src/include/switch_core.h | 1 + src/switch_core.c | 10 ++++++++++ src/switch_loadable_module.c | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 3383b67bc0..78b3827aa9 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2396,6 +2396,7 @@ SWITCH_DECLARE(void) switch_cache_db_flush_handles(void); SWITCH_DECLARE(const char *) switch_core_banner(void); SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session); SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number); +SWITCH_DECLARE(uint32_t) switch_default_rate(const char *name, uint32_t number); /*! \brief Add user registration diff --git a/src/switch_core.c b/src/switch_core.c index 2ead117121..60e133c730 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1720,6 +1720,16 @@ SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number) return 20; } +SWITCH_DECLARE(uint32_t) switch_default_rate(const char *name, uint32_t number) +{ + + if (!strcasecmp(name, "opus")) { + return 48000; + } + + return 8000; +} + static uint32_t d_30 = 30; static void switch_load_core_config(const char *file) diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 02a9e6792b..c1b37abbd1 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -2165,7 +2165,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ } if (orate == 0) { - orate = 8000; + orate = switch_default_rate(name, 0); } switch_copy_string(jbuf, prefs[j], sizeof(jbuf)); @@ -2176,7 +2176,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ } if (jrate == 0) { - jrate = 8000; + jrate = switch_default_rate(jname, 0); } if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate) { @@ -2188,6 +2188,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ /* If no specific codec interval is requested opt for the default above all else because lots of stuff assumes it */ for (imp = codec_interface->implementations; imp; imp = imp->next) { uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode); + uint32_t default_rate = switch_default_rate(imp->iananame, imp->ianacode); if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { @@ -2196,7 +2197,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ continue; } - if (((!rate && (uint32_t) imp->samples_per_second != 8000) || (rate && (uint32_t) imp->samples_per_second != rate))) { + if (((!rate && (uint32_t) imp->samples_per_second != default_rate) || (rate && (uint32_t) imp->samples_per_second != rate))) { continue; }