]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add loopback_initial_codec variable to specifiy the codec of a one legeded loopback...
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Apr 2012 17:16:53 +0000 (12:16 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Apr 2012 17:16:53 +0000 (12:16 -0500)
src/include/switch_loadable_module.h
src/mod/endpoints/mod_loopback/mod_loopback.c
src/switch_loadable_module.c

index 62fcac23430aa6fd716dbcd1baee1982f29ffa82..f1fde8d7d6f4ddfdf130cc2c2f0b7bc221345f62 100644 (file)
@@ -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
index b333cebda95e84d6290162a71ccedc3e456d064a..9ad780f8380fcd8c02584b67081b083c840df0c9 100644 (file)
@@ -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)) {
index 812afe785b1712ccadf9e5676f519d7dfc01463d..51f343a70e18fb8dc04900470f0be505d7c0b3ea 100644 (file)
@@ -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);