]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding 12kHz and 24kHz
authorBrian West <brian@freeswitch.org>
Tue, 22 Dec 2009 21:24:15 +0000 (21:24 +0000)
committerBrian West <brian@freeswitch.org>
Tue, 22 Dec 2009 21:24:15 +0000 (21:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16026 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_loadable_module.h
src/include/switch_utils.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/formats/mod_local_stream/mod_local_stream.c
src/switch_pcm.c

index f43fdb54d6be43fb7aedbe3192ed3d93ef49a83f..c1dac88909928c51efe0a0bfc9d2d2e74daa9d08 100644 (file)
@@ -339,10 +339,14 @@ static inline int switch_check_interval(uint32_t rate, uint32_t ptime)
                ptime_div = 2;
                break;
        case 32000:
+       case 24000:
        case 16000:
                max_ms = 60;
                ptime_div = 2;
                break;
+       case 12000:
+               max_ms = 100;
+               ptime_div = 2;
        case 8000:
                max_ms = 120;
                ptime_div = 2;
index c72c6d8321c0d4cbd843c14427e8f7a7dee5b910..e5790e5fc41a91b3e2dfd6381ed3129deb4ee721 100644 (file)
@@ -92,7 +92,7 @@ static inline switch_bool_t switch_is_moh(const char *s)
 #define switch_arraylen(_a) (sizeof(_a) / sizeof(_a[0]))
 #define switch_split(_data, _delim, _array) switch_separate_string(_data, _delim, _array, switch_arraylen(_array))
 
-#define switch_is_valid_rate(_tmp) (_tmp == 8000 || _tmp == 16000 || _tmp == 32000 || _tmp == 11025 || _tmp == 22050 || _tmp == 44100 || _tmp == 48000)
+#define switch_is_valid_rate(_tmp) (_tmp == 8000 || _tmp == 12000 || _tmp == 16000 || _tmp == 24000 || _tmp == 32000 || _tmp == 11025 || _tmp == 22050 || _tmp == 44100 || _tmp == 48000)
 
 
 static inline int switch_string_has_escaped_data(const char *in)
index f038c2bec6e6183fee1732243b42bac7f99b6615..6588ada658df9e7f75ed62e1391648211dc9e780 100644 (file)
@@ -5761,7 +5761,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
 
                if (!strcasecmp(var, "rate") && !zstr(val)) {
                        uint32_t tmp = atoi(val);
-                       if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
+                       if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {
                                rate = tmp;
                        }
                } else if (!strcasecmp(var, "domain") && !zstr(val)) {
index 0ee8258066c66c8d67bb080c1fcb03813c87baa4..226ba8b15b49623064056c3e6d3af80651233f53 100644 (file)
@@ -546,7 +546,7 @@ static void launch_threads(void)
 
                        if (!strcasecmp(var, "rate")) {
                                int tmp = atoi(val);
-                               if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
+                               if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) {
                                        source->rate = tmp;
                                }
                        } else if (!strcasecmp(var, "shuffle")) {
index 77f016d4abe6e3993b6b98d884d1e93ee840e40b..6aae839247e200f7141971180e948f941ff72d9a 100644 (file)
@@ -388,6 +388,67 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
                bpf = bpf * 2;
                ebpf = ebpf * 2;
        }
+
+       samples_per_frame = 240;
+       bytes_per_frame = 480;
+       ms_per_frame = 20000;
+
+       for (x = 0; x < 5; x++) {
+               switch_core_codec_add_implementation(pool, codec_interface,
+                                                                                        SWITCH_CODEC_TYPE_AUDIO,       /* enumeration defining the type of the codec */
+                                                                                        10,                                            /* the IANA code number */
+                                                                                        "L16",                                         /* the IANA code name */
+                                                                                        NULL,                                          /* default fmtp to send (can be overridden by the init function) */
+                                                                                        12000,                                         /* samples transferred per second */
+                                                                                        12000,                                         /* actual samples transferred per second */
+                                                                                        192000,                                        /* bits transferred per second */
+                                                                                        ms_per_frame,                          /* number of microseconds per frame */
+                                                                                        samples_per_frame,                     /* number of samples per frame */
+                                                                                        bytes_per_frame,                       /* number of bytes per frame decompressed */
+                                                                                        bytes_per_frame,                       /* number of bytes per frame compressed */
+                                                                                        1,                                                     /* number of channels represented */
+                                                                                        1,                                                     /* number of frames per network packet */
+                                                                                        switch_raw_init,                       /* function to initialize a codec handle using this implementation */
+                                                                                        switch_raw_encode,                     /* function to encode raw data into encoded data */
+                                                                                        switch_raw_decode,                     /* function to decode encoded data into raw data */
+                                                                                        switch_raw_destroy);           /* deinitalize a codec handle using this implementation */
+               
+               samples_per_frame += 240;
+               bytes_per_frame += 480;
+               ms_per_frame += 20000;
+               
+       }
+
+       samples_per_frame = 480;
+       bytes_per_frame = 960;
+       ms_per_frame = 20000;
+
+       for (x = 0; x < 3; x++) {
+               switch_core_codec_add_implementation(pool, codec_interface,
+                                                                                        SWITCH_CODEC_TYPE_AUDIO,       /* enumeration defining the type of the codec */
+                                                                                        10,                                            /* the IANA code number */
+                                                                                        "L16",                                         /* the IANA code name */
+                                                                                        NULL,                                          /* default fmtp to send (can be overridden by the init function) */
+                                                                                        24000,                                         /* samples transferred per second */
+                                                                                        24000,                                         /* actual samples transferred per second */
+                                                                                        384000,                                        /* bits transferred per second */
+                                                                                        ms_per_frame,                          /* number of microseconds per frame */
+                                                                                        samples_per_frame,                     /* number of samples per frame */
+                                                                                        bytes_per_frame,                       /* number of bytes per frame decompressed */
+                                                                                        bytes_per_frame,                       /* number of bytes per frame compressed */
+                                                                                        1,                                                     /* number of channels represented */
+                                                                                        1,                                                     /* number of frames per network packet */
+                                                                                        switch_raw_init,                       /* function to initialize a codec handle using this implementation */
+                                                                                        switch_raw_encode,                     /* function to encode raw data into encoded data */
+                                                                                        switch_raw_decode,                     /* function to decode encoded data into raw data */
+                                                                                        switch_raw_destroy);           /* deinitalize a codec handle using this implementation */
+               
+               samples_per_frame += 480;
+               bytes_per_frame += 960;
+               ms_per_frame += 20000;
+               
+       }
+
        /* these formats below are for file playing. */
 
        samples_per_frame = 96;
@@ -451,8 +512,6 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
                
        }
 
-
-
        samples_per_frame = 32;
        bytes_per_frame = 64;
        ms_per_frame = 2000;