提交 d642c2c1 authored 作者: Anthony Minessale's avatar Anthony Minessale

add loopback_initial_codec variable to specifiy the codec of a one legeded loopback channel

上级 f73804ac
...@@ -115,6 +115,8 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin ...@@ -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(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 \brief Retrieve the dialplan interface by it's registered name
\param name the name of the dialplan \param name the name of the dialplan
......
...@@ -122,8 +122,8 @@ static void clear_queue(private_t *tech_pvt) ...@@ -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) static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *session, switch_codec_t *codec)
{ {
const char *iananame = "L16"; const char *iananame = "L16";
int rate = 8000; uint32_t rate = 8000;
int interval = 20; uint32_t interval = 20;
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
const switch_codec_implementation_t *read_impl; 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 ...@@ -132,6 +132,15 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
iananame = codec->implementation->iananame; iananame = codec->implementation->iananame;
rate = codec->implementation->samples_per_second; rate = codec->implementation->samples_per_second;
interval = codec->implementation->microseconds_per_packet / 1000; 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)) { if (switch_core_codec_ready(&tech_pvt->read_codec)) {
......
...@@ -2075,7 +2075,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme ...@@ -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; char *cur, *next = NULL, *name, *p;
...@@ -2119,7 +2119,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ ...@@ -2119,7 +2119,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
uint32_t interval = 0, rate = 0, bit = 0; uint32_t interval = 0, rate = 0, bit = 0;
switch_copy_string(buf, prefs[x], sizeof(buf)); 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++) { for(j = 0; j < x; j++) {
char *jname; char *jname;
...@@ -2135,7 +2135,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ ...@@ -2135,7 +2135,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
} }
switch_copy_string(jbuf, prefs[j], sizeof(jbuf)); 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) { if (jinterval == 0) {
jinterval = switch_default_ptime(jname, 0); jinterval = switch_default_ptime(jname, 0);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论