diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index 62fcac2343..f1fde8d7d6 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -115,6 +115,8 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin */ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name); +SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit); + /*! \brief Retrieve the dialplan interface by it's registered name \param name the name of the dialplan diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index b333cebda9..9ad780f838 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -122,8 +122,8 @@ static void clear_queue(private_t *tech_pvt) static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, switch_codec_t *codec) { const char *iananame = "L16"; - int rate = 8000; - int interval = 20; + uint32_t rate = 8000; + uint32_t interval = 20; switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *channel = switch_core_session_get_channel(session); const switch_codec_implementation_t *read_impl; @@ -132,6 +132,15 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses iananame = codec->implementation->iananame; rate = codec->implementation->samples_per_second; interval = codec->implementation->microseconds_per_packet / 1000; + } else { + const char *var; + + if ((var = switch_channel_get_variable(channel, "loopback_initial_codec"))) { + char *dup = switch_core_session_strdup(session, var); + uint32_t bit; + iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit); + } + } if (switch_core_codec_ready(&tech_pvt->read_codec)) { diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 812afe785b..51f343a70e 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -2075,7 +2075,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme } -char *parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit) +SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit) { char *cur, *next = NULL, *name, *p; @@ -2119,7 +2119,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ uint32_t interval = 0, rate = 0, bit = 0; switch_copy_string(buf, prefs[x], sizeof(buf)); - name = parse_codec_buf(buf, &interval, &rate, &bit); + name = switch_parse_codec_buf(buf, &interval, &rate, &bit); for(j = 0; j < x; j++) { char *jname; @@ -2135,7 +2135,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ } switch_copy_string(jbuf, prefs[j], sizeof(jbuf)); - jname = parse_codec_buf(jbuf, &jinterval, &jrate, &jbit); + jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit); if (jinterval == 0) { jinterval = switch_default_ptime(jname, 0);