run indent on the whole tree and update copyright dates in prep for 1.0.5

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2010-02-06 03:38:24 +00:00
1 parent 7b347417e5
commit 886e1ddb4d
229 files changed
+20252 -20192

No files matched your search

+22 -21
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -250,7 +250,8 @@ static switch_status_t switch_amr_encode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
{
#ifdef AMR_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -272,7 +273,8 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
{
#ifdef AMR_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -319,24 +321,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "AMR");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
96, /* the IANA code number */
"AMR", /* the IANA code name */
"octet-align=0", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
12200, /* bits transferred per second */
20000, /* number of microseconds per frame */
160, /* number of samples per frame */
320, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_amr_init, /* function to initialize a codec handle using this implementation */
switch_amr_encode, /* function to encode raw data into encoded data */
switch_amr_decode, /* function to decode encoded data into raw data */
switch_amr_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
96, /* the IANA code number */
"AMR", /* the IANA code name */
"octet-align=0", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
12200, /* bits transferred per second */
20000, /* number of microseconds per frame */
160, /* number of samples per frame */
320, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_amr_init, /* function to initialize a codec handle using this implementation */
switch_amr_encode, /* function to encode raw data into encoded data */
switch_amr_decode, /* function to decode encoded data into raw data */
switch_amr_destroy); /* deinitalize a codec handle using this implementation */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
+16 -16
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005-2010, Anthony Minessale II <anthmct@yahoo.com>
*
* Version: MPL 1.1
*
@@ -166,7 +166,8 @@ static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_fla
context->enc_mode = globals.default_bitrate;
}
switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0,
context->enc_mode);
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
context->enc_mode = AMRWB_DEFAULT_BITRATE;
@@ -205,11 +206,11 @@ static switch_status_t switch_amrwb_destroy(switch_codec_t *codec)
}
static switch_status_t switch_amrwb_encode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate,
unsigned int *flag)
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
{
#ifdef AMRWB_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -228,11 +229,11 @@ static switch_status_t switch_amrwb_encode(switch_codec_t *codec,
}
static switch_status_t switch_amrwb_decode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
unsigned int *flag)
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
{
#ifdef AMRWB_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -279,10 +280,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amrwb_load)
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "AMR-WB");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", "octet-align=0", 16000, 16000, 23850,
20000, 320, 640, 0, 1, 1,
switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", "octet-align=0", 16000, 16000, 23850,
20000, 320, 640, 0, 1, 1, switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
+51 -55
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -51,16 +51,16 @@ static switch_status_t switch_bv16_init(switch_codec_t *codec, switch_codec_flag
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
}
}
if (encoding) {
context->encoder_object = bv16_encode_init(NULL);
}
if (decoding) {
context->decoder_object = bv16_decode_init(NULL);
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
@@ -68,7 +68,7 @@ static switch_status_t switch_bv16_init(switch_codec_t *codec, switch_codec_flag
static switch_status_t switch_bv16_destroy(switch_codec_t *codec)
{
struct bv16_context *context = codec->private_info;
if (context->encoder_object) {
bv16_encode_free(context->encoder_object);
}
@@ -134,16 +134,16 @@ static switch_status_t switch_bv32_init(switch_codec_t *codec, switch_codec_flag
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
}
}
if (encoding) {
context->encoder_object = bv32_encode_init(NULL);
}
if (decoding) {
context->decoder_object = bv32_decode_init(NULL);
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
@@ -180,7 +180,7 @@ static switch_status_t switch_bv32_encode(switch_codec_t *codec,
}
*encoded_data_len = bv32_encode(context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
return SWITCH_STATUS_SUCCESS;
}
@@ -208,61 +208,57 @@ static switch_status_t switch_bv32_decode(switch_codec_t *codec,
SWITCH_MODULE_LOAD_FUNCTION(mod_bv_load)
{
switch_codec_interface_t *codec_interface;
int mpf, spf, bpf, ebpf, count;
int mpf, spf, bpf, ebpf, count;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "BroadVoice16 (BV16)");
SWITCH_ADD_CODEC(codec_interface, "BroadVoice16 (BV16)");
mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
106, /* the IANA code number */
"BV16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_bv16_init, /* function to initialize a codec handle using this implementation */
switch_bv16_encode, /* function to encode raw data into encoded data */
switch_bv16_decode, /* function to decode encoded data into raw data */
switch_bv16_destroy); /* deinitalize a codec handle using this implementation */
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
106, /* the IANA code number */
"BV16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_bv16_init, /* function to initialize a codec handle using this implementation */
switch_bv16_encode, /* function to encode raw data into encoded data */
switch_bv16_decode, /* function to decode encoded data into raw data */
switch_bv16_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "BroadVoice32 (BV32)");
SWITCH_ADD_CODEC(codec_interface, "BroadVoice32 (BV32)");
mpf = 10000, spf = 160, bpf = 320 , ebpf = 40;
mpf = 10000, spf = 160, bpf = 320, ebpf = 40;
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
127, /* the IANA code number */
"BV32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_bv32_init, /* function to initialize a codec handle using this implementation */
switch_bv32_encode, /* function to encode raw data into encoded data */
switch_bv32_decode, /* function to decode encoded data into raw data */
switch_bv32_destroy); /* deinitalize a codec handle using this implementation */
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
127, /* the IANA code number */
"BV32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_bv32_init, /* function to initialize a codec handle using this implementation */
switch_bv32_encode, /* function to encode raw data into encoded data */
switch_bv32_decode, /* function to decode encoded data into raw data */
switch_bv32_destroy); /* deinitalize a codec handle using this implementation */
}
/* indicate that the module should continue to be loaded */
+67 -71
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -51,43 +51,43 @@ static switch_status_t switch_celt_init(switch_codec_t *codec, switch_codec_flag
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
}
}
context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
celt_mode_info(context->mode_object, CELT_GET_FRAME_SIZE, &context->frame_size);
context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size/codec->implementation->actual_samples_per_second + 4) / 8;
context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size / codec->implementation->actual_samples_per_second + 4) / 8;
/*
if (codec->fmtp_in) {
int x, argc;
char *argv[10];
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
for (x = 0; x < argc; x++) {
char *data = argv[x];
char *arg;
switch_assert(data);
while (*data == ' ') {
data++;
}
if ((arg = strchr(data, '='))) {
*arg++ = '\0';
if (!strcasecmp(data, "bitrate")) {
bit_rate = atoi(arg);
}
}
}
}
codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
*/
if (codec->fmtp_in) {
int x, argc;
char *argv[10];
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
for (x = 0; x < argc; x++) {
char *data = argv[x];
char *arg;
switch_assert(data);
while (*data == ' ') {
data++;
}
if ((arg = strchr(data, '='))) {
*arg++ = '\0';
if (!strcasecmp(data, "bitrate")) {
bit_rate = atoi(arg);
}
}
}
}
codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
*/
if (encoding) {
context->encoder_object = celt_encoder_create(context->mode_object, 1, NULL);
}
if (decoding) {
context->decoder_object = celt_decoder_create(context->mode_object, 1, NULL);
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
@@ -111,8 +111,8 @@ static switch_status_t switch_celt_encode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
*encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *)decoded_data, NULL,
(unsigned char *)encoded_data, context->bytes_per_packet);
*encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, NULL,
(unsigned char *) encoded_data, context->bytes_per_packet);
return SWITCH_STATUS_SUCCESS;
}
@@ -149,52 +149,48 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_celt_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "CELT ultra-low delay");
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
114, /* the IANA code number */
"CELT", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
32000, /* samples transferred per second */
32000, /* actual samples transferred per second */
32000, /* bits transferred per second */
10000, /* number of microseconds per frame */
320, /* number of samples per frame */
640, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_celt_init, /* function to initialize a codec handle using this implementation */
switch_celt_encode, /* function to encode raw data into encoded data */
switch_celt_decode, /* function to decode encoded data into raw data */
switch_celt_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_CODEC(codec_interface, "CELT ultra-low delay");
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
114, /* the IANA code number */
"CELT", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
32000, /* samples transferred per second */
32000, /* actual samples transferred per second */
32000, /* bits transferred per second */
10000, /* number of microseconds per frame */
320, /* number of samples per frame */
640, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_celt_init, /* function to initialize a codec handle using this implementation */
switch_celt_encode, /* function to encode raw data into encoded data */
switch_celt_decode, /* function to decode encoded data into raw data */
switch_celt_destroy); /* deinitalize a codec handle using this implementation */
ms_per_frame = 2000;
samples_per_frame = 96;
bytes_per_frame = 192;
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 */
114, /* the IANA code number */
"CELT", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
48000, /* samples transferred per second */
48000, /* actual samples transferred per second */
48000, /* 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 */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_celt_init, /* function to initialize a codec handle using this implementation */
switch_celt_encode, /* function to encode raw data into encoded data */
switch_celt_decode, /* function to decode encoded data into raw data */
switch_celt_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
114, /* the IANA code number */
"CELT", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
48000, /* samples transferred per second */
48000, /* actual samples transferred per second */
48000, /* 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 */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_celt_init, /* function to initialize a codec handle using this implementation */
switch_celt_encode, /* function to encode raw data into encoded data */
switch_celt_decode, /* function to decode encoded data into raw data */
switch_celt_destroy); /* deinitalize a codec handle using this implementation */
ms_per_frame += 2000;
samples_per_frame += 96;
bytes_per_frame += 192;
+105 -122
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -33,7 +33,7 @@
#include <switch.h>
#include <g711.h>
#include <poll.h>
#include <linux/types.h> /* __u32 */
#include <linux/types.h> /* __u32 */
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
@@ -75,8 +75,8 @@ static uint32_t total_decoders_usage = 0;
#define DAHDI_FORMAT_G729A (1 << 8)
struct dahdi_transcoder_formats {
__u32 srcfmt;
__u32 dstfmt;
__u32 srcfmt;
__u32 dstfmt;
};
struct dahdi_transcoder_info {
@@ -108,15 +108,11 @@ static int32_t switch_dahdi_get_transcoder(struct dahdi_transcoder_formats *fmts
int32_t fdflags;
int32_t fd = open(transcoding_device, O_RDWR);
if (fd < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Failed to open %s transcoder device: %s.\n",
transcoder_name, strerror(errno));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n", transcoder_name, strerror(errno));
return -1;
}
if (ioctl(fd, DAHDI_TC_ALLOCATE, fmts)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Failed to attach to transcoder: %s.\n",
strerror(errno));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to attach to transcoder: %s.\n", strerror(errno));
close(fd);
return -1;
}
@@ -124,15 +120,14 @@ static int32_t switch_dahdi_get_transcoder(struct dahdi_transcoder_formats *fmts
if (fdflags > -1) {
fdflags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, fdflags)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not set non-block mode in %s transcoder FD: %s\n",
transcoder_name, strerror(errno));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not set non-block mode in %s transcoder FD: %s\n",
transcoder_name, strerror(errno));
/* should we abort? this may cause channels to hangup when overruning the device
* see jira dahdi codec issue MODCODEC-8 (Hung Calls and Codec DAHDI G.729A 8.0k decoder error!)
* */
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not get flags from %s transcoder FD: %s\n",
transcoder_name, strerror(errno));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not get flags from %s transcoder FD: %s\n", transcoder_name, strerror(errno));
}
if (fmts->srcfmt & DAHDI_FORMAT_ULAW) {
@@ -154,19 +149,17 @@ static switch_status_t init_encoder(switch_codec_t *codec)
struct dahdi_context *context = codec->private_info;
fmts.srcfmt = DAHDI_FORMAT_ULAW;
fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
context->encoding_fd = switch_dahdi_get_transcoder(&fmts);
if (context->encoding_fd < 0) {
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n",
fmts.srcfmt, fmts.dstfmt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
#endif
return SWITCH_STATUS_FALSE;
}
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n",
fmts.srcfmt, fmts.dstfmt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
#endif
@@ -176,23 +169,21 @@ static switch_status_t init_encoder(switch_codec_t *codec)
static switch_status_t init_decoder(switch_codec_t *codec)
{
struct dahdi_transcoder_formats fmts;
struct dahdi_context *context = codec->private_info;
struct dahdi_transcoder_formats fmts;
struct dahdi_context *context = codec->private_info;
fmts.dstfmt = DAHDI_FORMAT_ULAW;
fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
context->decoding_fd = switch_dahdi_get_transcoder(&fmts);
if (context->decoding_fd < 0) {
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n",
fmts.srcfmt, fmts.dstfmt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
#endif
return SWITCH_STATUS_FALSE;
}
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n",
fmts.srcfmt, fmts.dstfmt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
#endif
return SWITCH_STATUS_SUCCESS;
@@ -228,7 +219,7 @@ static switch_status_t switch_dahdi_init(switch_codec_t *codec, switch_codec_fla
/* ulaw requires 8 times more storage than g729 and 12 times more than G723, right?
* this can be used to calculate the target buffer when encoding and decoding
* */
context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
? 8 : 12;
@@ -238,7 +229,7 @@ static switch_status_t switch_dahdi_init(switch_codec_t *codec, switch_codec_fla
static int wait_for_transcoder(int fd)
{
/* let's wait a bit for the transcoder, if in 20msthe driver does not notify us that its ready to give us something
then just bail out with 0 bytes encoded/decoded as result, I'd expect the card to hold that buffer and return it later */
then just bail out with 0 bytes encoded/decoded as result, I'd expect the card to hold that buffer and return it later */
int res = 0;
struct pollfd readpoll;
memset(&readpoll, 0, sizeof(readpoll));
@@ -246,21 +237,21 @@ static int wait_for_transcoder(int fd)
readpoll.events = POLLIN;
/* my testing shows that it does not take more than 1ms to encode a 160 bytes frame ulaw to g729,
I dont think there is much difference decoding and for g723, waiting 10ms seems more than reasonable */
res = poll(&readpoll, 1, 10);
res = poll(&readpoll, 1, 10);
return res;
}
static switch_status_t switch_dahdi_encode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
{
int32_t res;
short *dbuf_linear;
unsigned char *ebuf_g729;
unsigned char ebuf_ulaw[decoded_data_len/2];
unsigned char ebuf_ulaw[decoded_data_len / 2];
uint32_t i;
struct dahdi_context *context = NULL;
switch_status_t status;
@@ -290,7 +281,8 @@ static switch_status_t switch_dahdi_encode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
if (i != res) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n", i, transcoder_name, res);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n", i,
transcoder_name, res);
return SWITCH_STATUS_FALSE;
}
res = wait_for_transcoder(context->encoding_fd);
@@ -333,7 +325,7 @@ static switch_status_t switch_dahdi_decode(switch_codec_t *codec,
int32_t res;
short *dbuf_linear;
// we only can decode up to half ulaw bytes of whatever their destiny linear buffer is
unsigned char dbuf_ulaw[*decoded_data_len/2];
unsigned char dbuf_ulaw[*decoded_data_len / 2];
unsigned char *ebuf_g729;
uint32_t i;
struct dahdi_context *context;
@@ -360,7 +352,7 @@ static switch_status_t switch_dahdi_decode(switch_codec_t *codec,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Switch DAHDI decode in silence returned %d bytes.\n", *decoded_data_len);
#endif
return SWITCH_STATUS_SUCCESS;
}
}
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Writing %d bytes to decode.\n", encoded_data_len);
#endif
@@ -370,12 +362,12 @@ static switch_status_t switch_dahdi_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
if (encoded_data_len != res) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n", encoded_data_len, transcoder_name, res);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n",
encoded_data_len, transcoder_name, res);
return SWITCH_STATUS_FALSE;
}
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to read from device %d bytes of decoded ulaw data.\n",
sizeof(dbuf_ulaw));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to read from device %d bytes of decoded ulaw data.\n", sizeof(dbuf_ulaw));
#endif
res = wait_for_transcoder(context->decoding_fd);
if (-1 == res) {
@@ -386,7 +378,8 @@ static switch_status_t switch_dahdi_decode(switch_codec_t *codec,
memset(dbuf_linear, 0, codec->implementation->decoded_bytes_per_packet);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output on %s decoder device, returning silence frame of %d bytes.\n", transcoder_name, *decoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output on %s decoder device, returning silence frame of %d bytes.\n", transcoder_name,
*decoded_data_len);
#endif
return SWITCH_STATUS_SUCCESS;
}
@@ -437,10 +430,8 @@ SWITCH_STANDARD_API(dahdi_transcode_usage)
return SWITCH_STATUS_SUCCESS;
}
switch_mutex_lock(transcoder_counter_mutex);
stream->write_function(stream, "Using %d encoders of a total of %d available.\n",
total_encoders_usage, total_encoders);
stream->write_function(stream, "Using %d decoders of a total of %d available.\n",
total_decoders_usage, total_decoders);
stream->write_function(stream, "Using %d encoders of a total of %d available.\n", total_encoders_usage, total_encoders);
stream->write_function(stream, "Using %d decoders of a total of %d available.\n", total_decoders_usage, total_decoders);
switch_mutex_unlock(transcoder_counter_mutex);
return SWITCH_STATUS_SUCCESS;
}
@@ -452,10 +443,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load)
struct stat statbuf;
struct dahdi_transcoder_info info = { 0 };
int32_t fd, res;
int mpf = 20000; /* Algorithmic delay of 15ms with 5ms of look-ahead delay */
int spf = 160;
int bpfd = 320;
int bpfc = 20;
int mpf = 20000; /* Algorithmic delay of 15ms with 5ms of look-ahead delay */
int spf = 160;
int bpfd = 320;
int bpfc = 20;
int fpnp = 20;
total_encoders = 0;
@@ -479,8 +470,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load)
fd = open(transcoding_device, O_RDWR);
if (fd < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n",
transcoder_name, strerror(errno));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n", transcoder_name, strerror(errno));
return SWITCH_STATUS_FALSE;
}
@@ -491,14 +481,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load)
continue;
}
if ((info.dstfmts & DAHDI_FORMAT_ULAW) && (info.srcfmts & (DAHDI_FORMAT_G729A | DAHDI_FORMAT_G723_1))) {
total_decoders += info.numchannels;
total_decoders += info.numchannels;
continue;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Not using transcoder %s, we just support ULAW and G723.1/G729A", info.name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Not using transcoder %s, we just support ULAW and G723.1/G729A", info.name);
}
close(fd);
if (!total_encoders && !total_decoders) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No DAHDI transcoders found.\n");
return SWITCH_STATUS_FALSE;
@@ -510,79 +499,73 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dahdi_codec_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "DAHDI G.729A 8.0k"); /* 8.0kbit */
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
18, /* the IANA code number */
"G729", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_CODEC(codec_interface, "DAHDI G.729A 8.0k"); /* 8.0kbit */
mpf = 30000;
spf = 240;
bpfd = 480;
bpfc = 30;
fpnp = 30;
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
18, /* the IANA code number */
"G729", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
18, /* the IANA code number */
"G729", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_CODEC(codec_interface, "DAHDI G.723.1 5.3k"); /* 5.3kbit */
mpf = 30000; /* Algorithmic delay of 37.5ms with 7.5ms of look-ahead delay */
mpf = 30000;
spf = 240;
bpfd = 480;
bpfc = 30;
fpnp = 30;
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
18, /* the IANA code number */
"G729", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_CODEC(codec_interface, "DAHDI G.723.1 5.3k"); /* 5.3kbit */
mpf = 30000; /* Algorithmic delay of 37.5ms with 7.5ms of look-ahead delay */
spf = 240;
bpfd = 480;
bpfc = 20;
fpnp = 10;
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
4, /* the IANA code number */
"G723", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
4, /* the IANA code number */
"G723", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
mpf, /* number of microseconds per frame */
spf, /* number of samples per frame */
bpfd, /* number of bytes per frame decompressed */
bpfc, /* number of bytes per frame compressed */
1, /* number of channels represented */
fpnp, /* number of frames per network packet */
switch_dahdi_init, /* function to initialize a codec handle using this implementation */
switch_dahdi_encode, /* function to encode raw data into encoded data */
switch_dahdi_decode, /* function to decode encoded data into raw data */
switch_dahdi_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_API(api_interface, "dahdi_transcode", "DAHDI Transcode", dahdi_transcode_usage, NULL);
switch_console_set_complete("add dahdi_transcode");
+4 -5
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -171,8 +171,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
{
switch_codec_interface_t *codec_interface;
int ompf = 30000, ospf = 240, obpf = 480, oebpf = 24, count = 0;
int mpf = ompf , spf = ospf , bpf = obpf , ebpf = oebpf ;
int mpf = ompf, spf = ospf, bpf = obpf, ebpf = oebpf;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "G.723.1 6.3k");
@@ -180,8 +180,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
for (count = 0; count < 4; count++) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
mpf , spf , bpf , ebpf , 1, count,
switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
mpf, spf, bpf, ebpf, 1, count, switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
mpf += ompf;
spf += ospf;
bpf += obpf;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+39 -43
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -46,10 +46,10 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
int decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
int mode = codec->implementation->microseconds_per_packet / 1000;
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
}
}
if (codec->fmtp_in) {
int x, argc;
@@ -70,9 +70,9 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
}
}
}
codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "mode=%d", mode);
if (encoding) {
ilbc_encode_init(&context->encoder_object, mode);
}
@@ -80,7 +80,7 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
if (decoding) {
ilbc_decode_init(&context->decoder_object, mode, 0);
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
@@ -122,7 +122,7 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
*decoded_data_len = (2 *ilbc_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
*decoded_data_len = (2 * ilbc_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
return SWITCH_STATUS_SUCCESS;
}
@@ -137,45 +137,41 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
SWITCH_ADD_CODEC(codec_interface, "iLBC");
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
98, /* the IANA code number */
"iLBC", /* the IANA code name */
"mode=20", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
15200, /* bits transferred per second */
20000, /* number of microseconds per frame */
ILBC_BLOCK_LEN_20MS, /* number of samples per frame */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
98, /* the IANA code number */
"iLBC", /* the IANA code name */
"mode=20", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
15200, /* bits transferred per second */
20000, /* number of microseconds per frame */
ILBC_BLOCK_LEN_20MS, /* number of samples per frame */
ILBC_BLOCK_LEN_20MS * 2, /* number of bytes per frame decompressed */
ILBC_NO_OF_BYTES_20MS, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_ilbc_init, /* function to initialize a codec handle using this implementation */
switch_ilbc_encode, /* function to encode raw data into encoded data */
switch_ilbc_decode, /* function to decode encoded data into raw data */
switch_ilbc_destroy); /* deinitalize a codec handle using this implementation */
ILBC_NO_OF_BYTES_20MS, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_ilbc_init, /* function to initialize a codec handle using this implementation */
switch_ilbc_encode, /* function to encode raw data into encoded data */
switch_ilbc_decode, /* function to decode encoded data into raw data */
switch_ilbc_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
97, /* the IANA code number */
"iLBC", /* the IANA code name */
"mode=30", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
13300, /* bits transferred per second */
30000, /* number of microseconds per frame */
ILBC_BLOCK_LEN_30MS, /* number of samples per frame */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
97, /* the IANA code number */
"iLBC", /* the IANA code name */
"mode=30", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
13300, /* bits transferred per second */
30000, /* number of microseconds per frame */
ILBC_BLOCK_LEN_30MS, /* number of samples per frame */
ILBC_BLOCK_LEN_30MS * 2, /* number of bytes per frame decompressed */
ILBC_NO_OF_BYTES_30MS, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_ilbc_init, /* function to initialize a codec handle using this implementation */
switch_ilbc_encode, /* function to encode raw data into encoded data */
switch_ilbc_decode, /* function to decode encoded data into raw data */
switch_ilbc_destroy); /* deinitalize a codec handle using this implementation */
ILBC_NO_OF_BYTES_30MS, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_ilbc_init, /* function to initialize a codec handle using this implementation */
switch_ilbc_encode, /* function to encode raw data into encoded data */
switch_ilbc_decode, /* function to decode encoded data into raw data */
switch_ilbc_destroy); /* deinitalize a codec handle using this implementation */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
+50 -54
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -56,7 +56,7 @@ static switch_status_t switch_siren_init(switch_codec_t *codec, switch_codec_fla
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE;
}
}
if (codec->fmtp_in) {
int x, argc;
@@ -77,9 +77,9 @@ static switch_status_t switch_siren_init(switch_codec_t *codec, switch_codec_fla
}
}
}
codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
if (encoding) {
g722_1_encode_init(&context->encoder_object, bit_rate, codec->implementation->samples_per_second);
}
@@ -87,7 +87,7 @@ static switch_status_t switch_siren_init(switch_codec_t *codec, switch_codec_fla
if (decoding) {
g722_1_decode_init(&context->decoder_object, bit_rate, codec->implementation->samples_per_second);
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
@@ -99,11 +99,11 @@ static switch_status_t switch_siren_destroy(switch_codec_t *codec)
}
static switch_status_t switch_siren_encode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
{
struct siren_context *context = codec->private_info;
@@ -116,14 +116,14 @@ static switch_status_t switch_siren_encode(switch_codec_t *codec,
}
static switch_status_t switch_siren_decode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
{
struct siren_context *context = codec->private_info;
if (!context) {
return SWITCH_STATUS_FALSE;
}
@@ -148,47 +148,43 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_siren_load)
spf = 320, bpf = 640;
for (count = 3; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
107, /* the IANA code number */
"G7221", /* the IANA code name */
"bitrate=32000", /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_siren_init, /* function to initialize a codec handle using this implementation */
switch_siren_encode, /* function to encode raw data into encoded data */
switch_siren_decode, /* function to decode encoded data into raw data */
switch_siren_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
107, /* the IANA code number */
"G7221", /* the IANA code name */
"bitrate=32000", /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_siren_init, /* function to initialize a codec handle using this implementation */
switch_siren_encode, /* function to encode raw data into encoded data */
switch_siren_decode, /* function to decode encoded data into raw data */
switch_siren_destroy); /* deinitalize a codec handle using this implementation */
}
spf = 640, bpf = 1280;
for (count = 3; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
115, /* the IANA code number */
"G7221", /* the IANA code name */
"bitrate=48000", /* default fmtp to send (can be overridden by the init function) */
32000, /* samples transferred per second */
32000, /* actual samples transferred per second */
48000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_siren_init, /* function to initialize a codec handle using this implementation */
switch_siren_encode, /* function to encode raw data into encoded data */
switch_siren_decode, /* function to decode encoded data into raw data */
switch_siren_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
115, /* the IANA code number */
"G7221", /* the IANA code name */
"bitrate=48000", /* default fmtp to send (can be overridden by the init function) */
32000, /* samples transferred per second */
32000, /* actual samples transferred per second */
48000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_siren_init, /* function to initialize a codec handle using this implementation */
switch_siren_encode, /* function to encode raw data into encoded data */
switch_siren_decode, /* function to decode encoded data into raw data */
switch_siren_destroy); /* deinitalize a codec handle using this implementation */
}
/* indicate that the module should continue to be loaded */
+39 -41
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -94,15 +94,14 @@ static switch_status_t switch_skel_init(switch_codec_t *codec, switch_codec_flag
* SWITCH_STATUS_NOOP, NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.
* SWITCH_STATUS_NOT_INITALIZED, failure to init, you can use this to init on first usage and no in switch_skel_init?
* */
static switch_status_t switch_skel_encode(switch_codec_t *codec,
switch_codec_t *other_codec, /* codec that was used by the other side */
void *decoded_data, /* decoded data that we must encode */
uint32_t decoded_data_len /* decoded data length */,
uint32_t decoded_rate /* rate of the decoded data */,
void *encoded_data, /* here we will store the encoded data */
uint32_t *encoded_data_len, /* here we will set the length of the encoded data */
uint32_t *encoded_rate /* here we will set the rate of the encoded data */,
unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */)
static switch_status_t switch_skel_encode(switch_codec_t *codec, switch_codec_t *other_codec, /* codec that was used by the other side */
void *decoded_data, /* decoded data that we must encode */
uint32_t decoded_data_len /* decoded data length */ ,
uint32_t decoded_rate /* rate of the decoded data */ ,
void *encoded_data, /* here we will store the encoded data */
uint32_t *encoded_data_len, /* here we will set the length of the encoded data */
uint32_t *encoded_rate /* here we will set the rate of the encoded data */ ,
unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */ )
{
struct skel_context *context = codec->private_info;
/* FS core checks the actual samples per second and microseconds per packet to determine the buffer size in the worst case scenario, no need to check
@@ -123,15 +122,15 @@ static switch_status_t switch_skel_encode(switch_codec_t *codec,
* SWITCH_STATUS_NOOP, NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.
* SWITCH_STATUS_NOT_INITALIZED, failure to init, you can use this to init on first usage and no in switch_skel_init?
* */
static switch_status_t switch_skel_decode(switch_codec_t *codec, /* codec session handle */
switch_codec_t *other_codec, /* what is this? */
void *encoded_data, /* data that we must decode into slinear and put it in decoded_data */
uint32_t encoded_data_len, /* length in bytes of the encoded data */
uint32_t encoded_rate, /* at which rate was the data encoded */
void *decoded_data, /* buffer where we must put the decoded data */
uint32_t *decoded_data_len, /* we must set this value to the size of the decoded data */
uint32_t *decoded_rate, /* rate of the decoded data */
unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */)
static switch_status_t switch_skel_decode(switch_codec_t *codec, /* codec session handle */
switch_codec_t *other_codec, /* what is this? */
void *encoded_data, /* data that we must decode into slinear and put it in decoded_data */
uint32_t encoded_data_len, /* length in bytes of the encoded data */
uint32_t encoded_rate, /* at which rate was the data encoded */
void *decoded_data, /* buffer where we must put the decoded data */
uint32_t *decoded_data_len, /* we must set this value to the size of the decoded data */
uint32_t *decoded_rate, /* rate of the decoded data */
unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */ )
{
struct skel_context *context = codec->private_info;
/* FS core checks the actual samples per second and microseconds per packet to determine the buffer size in the worst case scenario, no need to check
@@ -150,7 +149,7 @@ static switch_status_t switch_skel_destroy(switch_codec_t *codec)
* no need to free memory allocated from the pool though, the owner of the pool takes care of that */
struct skel_context *context = codec->private_info;
context->encodes = 0;
context->decodes = 0; /* silly, context was allocated in the pool and therefore will be destroyed soon, exact time is not guaranteed though */
context->decodes = 0; /* silly, context was allocated in the pool and therefore will be destroyed soon, exact time is not guaranteed though */
return SWITCH_STATUS_SUCCESS;
}
@@ -180,32 +179,31 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_codec_load)
/* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface list the core keeps,
* gets a codec id and set the given codec name to it.
* At this point there is an empty shell codec interface registered, but not yet implementations */
SWITCH_ADD_CODEC(codec_interface, "SKEL 8.0k"); /* 8.0kbit */
SWITCH_ADD_CODEC(codec_interface, "SKEL 8.0k"); /* 8.0kbit */
/* Now add as many codec implementations as needed, typically this is done inside a for loop where the packetization size is
* incremented (10ms, 20ms, 30ms etc) as needed */
switch_core_codec_add_implementation(pool,
codec_interface, /* the codec interface we allocated and we want to register with the core */
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
0, /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
"SKEL", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
20000, /* for 20ms (milliseconds) frames, 20,000 microseconds and so on, you can register the same codec with different packetization */
160, /* number of samples per frame, for this dummy implementation is 160, which is the number of samples in 20ms at 8000 samples per second */
320, /* number of bytes per frame decompressed */
320, /* number of bytes per frame compressed, since we dont really compress anything, is the same number as per frame decompressed */
1, /* number of channels represented */
20, /* number of frames per network packet */
switch_skel_init, /* function to initialize a codec session using this implementation */
switch_skel_encode, /* function to encode slinear data into encoded data */
switch_skel_decode, /* function to decode encoded data into slinear data */
switch_skel_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, /* the codec interface we allocated and we want to register with the core */
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
0, /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
"SKEL", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
8000, /* bits transferred per second */
20000, /* for 20ms (milliseconds) frames, 20,000 microseconds and so on, you can register the same codec with different packetization */
160, /* number of samples per frame, for this dummy implementation is 160, which is the number of samples in 20ms at 8000 samples per second */
320, /* number of bytes per frame decompressed */
320, /* number of bytes per frame compressed, since we dont really compress anything, is the same number as per frame decompressed */
1, /* number of channels represented */
20, /* number of frames per network packet */
switch_skel_init, /* function to initialize a codec session using this implementation */
switch_skel_encode, /* function to encode slinear data into encoded data */
switch_skel_decode, /* function to decode encoded data into slinear data */
switch_skel_destroy); /* deinitalize a codec handle using this implementation */
SWITCH_ADD_API(api_interface, "skel_sayhi", "Skel Codec Says Hi", skel_sayhi, NULL);
switch_console_set_complete("add skel_sayhi"); /* For CLI completion */
switch_console_set_complete("add skel_sayhi"); /* For CLI completion */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
+18 -20
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -272,25 +272,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
SWITCH_ADD_CODEC(codec_interface, "Speex");
for (counta = 1; counta <= 3; counta++) {
for (countb = 1; countb > 0; countb--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
ianacode[counta], /* the IANA code number */
"SPEEX", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
rate, /* samples transferred per second */
rate, /* actual samples transferred per second */
bps[counta], /* bits transferred per second */
mpf * countb, /* number of microseconds per frame */
spf * countb, /* number of samples per frame */
bpf * countb, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_speex_init, /* function to initialize a codec handle using this implementation */
switch_speex_encode, /* function to encode raw data into encoded data */
switch_speex_decode, /* function to decode encoded data into raw data */
switch_speex_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
ianacode[counta], /* the IANA code number */
"SPEEX", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
rate, /* samples transferred per second */
rate, /* actual samples transferred per second */
bps[counta], /* bits transferred per second */
mpf * countb, /* number of microseconds per frame */
spf * countb, /* number of samples per frame */
bpf * countb, /* number of bytes per frame decompressed */
0, /* number of bytes per frame compressed */
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_speex_init, /* function to initialize a codec handle using this implementation */
switch_speex_encode, /* function to encode raw data into encoded data */
switch_speex_decode, /* function to decode encoded data into raw data */
switch_speex_destroy); /* deinitalize a codec handle using this implementation */
}
rate = rate * 2;
spf = spf * 2;
+279 -298
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -80,9 +80,11 @@ static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
return SWITCH_STATUS_FALSE;
}
if (context->encoder_object) lpc10_encode_free(context->encoder_object);
if (context->encoder_object)
lpc10_encode_free(context->encoder_object);
context->encoder_object = NULL;
if (context->decoder_object) lpc10_decode_free(context->decoder_object);
if (context->decoder_object)
lpc10_decode_free(context->decoder_object);
context->decoder_object = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -160,7 +162,8 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
unsigned int *flag)
{
struct gsm_context *context = codec->private_info;
@@ -177,7 +180,8 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
unsigned int *flag)
{
struct gsm_context *context = codec->private_info;
@@ -200,9 +204,11 @@ static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
return SWITCH_STATUS_FALSE;
}
if (context->decoder_object) gsm0610_free(context->decoder_object);
if (context->decoder_object)
gsm0610_free(context->decoder_object);
context->decoder_object = NULL;
if (context->encoder_object) gsm0610_free(context->encoder_object);
if (context->encoder_object)
gsm0610_free(context->encoder_object);
context->encoder_object = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -433,9 +439,11 @@ static switch_status_t switch_g722_destroy(switch_codec_t *codec)
return SWITCH_STATUS_FALSE;
}
if (context->decoder_object) g722_decode_free(context->decoder_object);
if (context->decoder_object)
g722_decode_free(context->decoder_object);
context->decoder_object = NULL;
if (context->encoder_object) g722_encode_free(context->encoder_object);
if (context->encoder_object)
g722_encode_free(context->encoder_object);
context->encoder_object = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -456,14 +464,14 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
if (!(encoding || decoding)) {
return SWITCH_STATUS_FALSE;
}
}
if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
packing = G726_PACKING_LEFT;
}
context = g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
@@ -597,9 +605,11 @@ static switch_status_t switch_adpcm_destroy(switch_codec_t *codec)
return SWITCH_STATUS_FALSE;
}
if (context->decoder_object) ima_adpcm_free(context->decoder_object);
if (context->decoder_object)
ima_adpcm_free(context->decoder_object);
context->decoder_object = NULL;
if (context->encoder_object) ima_adpcm_free(context->encoder_object);
if (context->encoder_object)
ima_adpcm_free(context->encoder_object);
context->encoder_object = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -620,260 +630,238 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
SWITCH_ADD_CODEC(codec_interface, "ADPCM (IMA)");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
5, /* the IANA code number */
"DVI4", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
(ebpf * count) + 4, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_adpcm_init, /* function to initialize a codec handle using this implementation */
switch_adpcm_encode, /* function to encode raw data into encoded data */
switch_adpcm_decode, /* function to decode encoded data into raw data */
switch_adpcm_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
5, /* the IANA code number */
"DVI4", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
(ebpf * count) + 4, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_adpcm_init, /* function to initialize a codec handle using this implementation */
switch_adpcm_encode, /* function to encode raw data into encoded data */
switch_adpcm_decode, /* function to decode encoded data into raw data */
switch_adpcm_destroy); /* deinitalize a codec handle using this implementation */
}
mpf = 10000, spf = 160, bpf = 320, ebpf = 160;
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
6, /* the IANA code number */
"DVI4", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
(ebpf * count) + 4, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_adpcm_init, /* function to initialize a codec handle using this implementation */
switch_adpcm_encode, /* function to encode raw data into encoded data */
switch_adpcm_decode, /* function to decode encoded data into raw data */
switch_adpcm_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
6, /* the IANA code number */
"DVI4", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
16000, /* samples transferred per second */
16000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
(ebpf * count) + 4, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_adpcm_init, /* function to initialize a codec handle using this implementation */
switch_adpcm_encode, /* function to encode raw data into encoded data */
switch_adpcm_decode, /* function to decode encoded data into raw data */
switch_adpcm_destroy); /* deinitalize a codec handle using this implementation */
}
/* G726 */
mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
SWITCH_ADD_CODEC(codec_interface, "G.726 16k (AAL2)");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
124, /* the IANA code number */
"AAL2-G726-16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
124, /* the IANA code number */
"AAL2-G726-16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
124, /* the IANA code number */
"G726-16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
124, /* the IANA code number */
"G726-16", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
16000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
/* Increase encoded bytes per frame by 10 */
ebpf = ebpf + 10;
SWITCH_ADD_CODEC(codec_interface, "G.726 24k (AAL2)");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
123, /* the IANA code number */
"AAL2-G726-24", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
24000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
123, /* the IANA code number */
"AAL2-G726-24", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
24000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
123, /* the IANA code number */
"G726-24", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
24000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
123, /* the IANA code number */
"G726-24", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
24000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
/* Increase encoded bytes per frame by 10 */
ebpf = ebpf + 10;
SWITCH_ADD_CODEC(codec_interface, "G.726 32k (AAL2)");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
122, /* the IANA code number */
"AAL2-G726-32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
122, /* the IANA code number */
"AAL2-G726-32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
122, /* the IANA code number */
"G726-32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
122, /* the IANA code number */
"G726-32", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
32000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
/* Increase encoded bytes per frame by 10 */
ebpf = ebpf + 10;
SWITCH_ADD_CODEC(codec_interface, "G.726 40k (AAL2)");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
121, /* the IANA code number */
"AAL2-G726-40", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
40000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
121, /* the IANA code number */
"AAL2-G726-40", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
40000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
121, /* the IANA code number */
"G726-40", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
40000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
121, /* the IANA code number */
"G726-40", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
40000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count * 10, /* number of frames per network packet */
switch_g726_init, /* function to initialize a codec handle using this implementation */
switch_g726_encode, /* function to encode raw data into encoded data */
switch_g726_decode, /* function to decode encoded data into raw data */
switch_g726_destroy); /* deinitalize a codec handle using this implementation */
}
/* G722 */
mpf = 10000, spf = 80, bpf = 320, ebpf = 80;
SWITCH_ADD_CODEC(codec_interface, "G.722");
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
9, /* the IANA code number */
"G722", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
16000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g722_init, /* function to initialize a codec handle using this implementation */
switch_g722_encode, /* function to encode raw data into encoded data */
switch_g722_decode, /* function to decode encoded data into raw data */
switch_g722_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
9, /* the IANA code number */
"G722", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
16000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g722_init, /* function to initialize a codec handle using this implementation */
switch_g722_encode, /* function to encode raw data into encoded data */
switch_g722_decode, /* function to decode encoded data into raw data */
switch_g722_destroy); /* deinitalize a codec handle using this implementation */
}
#ifdef ENABLE_G711
@@ -881,48 +869,44 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
0, /* the IANA code number */
"PCMU", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g711u_init, /* function to initialize a codec handle using this implementation */
switch_g711u_encode, /* function to encode raw data into encoded data */
switch_g711u_decode, /* function to decode encoded data into raw data */
switch_g711u_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
0, /* the IANA code number */
"PCMU", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g711u_init, /* function to initialize a codec handle using this implementation */
switch_g711u_encode, /* function to encode raw data into encoded data */
switch_g711u_decode, /* function to decode encoded data into raw data */
switch_g711u_destroy); /* deinitalize a codec handle using this implementation */
}
SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
8, /* the IANA code number */
"PCMA", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g711a_init, /* function to initialize a codec handle using this implementation */
switch_g711a_encode, /* function to encode raw data into encoded data */
switch_g711a_decode, /* function to decode encoded data into raw data */
switch_g711a_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
8, /* the IANA code number */
"PCMA", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
64000, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
spf * count, /* number of frames per network packet */
switch_g711a_init, /* function to initialize a codec handle using this implementation */
switch_g711a_encode, /* function to encode raw data into encoded data */
switch_g711a_decode, /* function to decode encoded data into raw data */
switch_g711a_destroy); /* deinitalize a codec handle using this implementation */
}
#endif
@@ -930,47 +914,44 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
mpf = 20000, spf = 160, bpf = 320, ebpf = 33;
SWITCH_ADD_CODEC(codec_interface, "GSM");
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
3, /* the IANA code number */
"GSM", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
13200, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count, /* number of frames per network packet */
switch_gsm_init, /* function to initialize a codec handle using this implementation */
switch_gsm_encode, /* function to encode raw data into encoded data */
switch_gsm_decode, /* function to decode encoded data into raw data */
switch_gsm_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
3, /* the IANA code number */
"GSM", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
13200, /* bits transferred per second */
mpf * count, /* number of microseconds per frame */
spf * count, /* number of samples per frame */
bpf * count, /* number of bytes per frame decompressed */
ebpf * count, /* number of bytes per frame compressed */
1, /* number of channels represented */
count, /* number of frames per network packet */
switch_gsm_init, /* function to initialize a codec handle using this implementation */
switch_gsm_encode, /* function to encode raw data into encoded data */
switch_gsm_decode, /* function to decode encoded data into raw data */
switch_gsm_destroy); /* deinitalize a codec handle using this implementation */
}
/* LPC10 */
#if SWITCH_MAX_INTERVAL >= 90
SWITCH_ADD_CODEC(codec_interface, "LPC-10");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
7, /* the IANA code number */
"LPC", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
2400, /* bits transferred per second */
90000, /* number of microseconds per frame */
720, /* number of samples per frame */
1440, /* number of bytes per frame decompressed */
28, /* number of bytes per frame compressed */
1, /* number of channels represented */
4, /* number of frames per network packet */
switch_lpc10_init, /* function to initialize a codec handle using this implementation */
switch_lpc10_encode, /* function to encode raw data into encoded data */
switch_lpc10_decode, /* function to decode encoded data into raw data */
switch_lpc10_destroy); /* deinitalize a codec handle using this implementation */
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
7, /* the IANA code number */
"LPC", /* the IANA code name */
NULL, /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
2400, /* bits transferred per second */
90000, /* number of microseconds per frame */
720, /* number of samples per frame */
1440, /* number of bytes per frame decompressed */
28, /* number of bytes per frame compressed */
1, /* number of channels represented */
4, /* number of frames per network packet */
switch_lpc10_init, /* function to initialize a codec handle using this implementation */
switch_lpc10_encode, /* function to encode raw data into encoded data */
switch_lpc10_decode, /* function to decode encoded data into raw data */
switch_lpc10_destroy); /* deinitalize a codec handle using this implementation */
#endif
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;