adding 12kHz and 24kHz

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16026 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-12-22 21:24:15 +00:00
parent 376c07e8bd
commit 908d8a7280
5 changed files with 68 additions and 5 deletions

View 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;

View 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)

View 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)) {

View 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")) {

View 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;