spring cleaning

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4795 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-03-29 22:31:56 +00:00
parent a021945cef
commit 3a54126261
143 changed files with 22413 additions and 31567 deletions

View File

@@ -30,7 +30,7 @@
*
* mod_amr.c -- GSM-AMR Codec Module
*
*/
*/
#include "switch.h"
static const char modname[] = "mod_amr";
@@ -114,14 +114,14 @@ static struct {
#endif
static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
#ifdef AMR_PASSTHROUGH
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
return SWITCH_STATUS_SUCCESS;
#else
struct amr_context *context = NULL;
@@ -139,10 +139,10 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
if (codec->fmtp_in) {
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
for(x = 0; x < argc; x++) {
for (x = 0; x < argc; x++) {
char *data = argv[x];
char *arg;
while(*data && *data == ' ') {
while (*data && *data == ' ') {
data++;
}
if ((arg = strchr(data, '='))) {
@@ -171,16 +171,16 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
} else if (!strcasecmp(data, "mode-change-period")) {
context->change_period = atoi(arg);
} else if (!strcasecmp(data, "ptime")) {
context->ptime = (switch_byte_t)atoi(arg);
context->ptime = (switch_byte_t) atoi(arg);
} else if (!strcasecmp(data, "channels")) {
context->channels = (switch_byte_t)atoi(arg);
context->channels = (switch_byte_t) atoi(arg);
} else if (!strcasecmp(data, "maxptime")) {
context->max_ptime = (switch_byte_t)atoi(arg);
context->max_ptime = (switch_byte_t) atoi(arg);
} else if (!strcasecmp(data, "mode-set")) {
int y, m_argc;
char *m_argv[7];
m_argc = switch_separate_string(arg, ',', m_argv, (sizeof(m_argv) / sizeof(m_argv[0])));
for(y = 0; y < m_argc; y++) {
for (y = 0; y < m_argc; y++) {
context->enc_modes |= (1 << atoi(m_argv[y]));
}
}
@@ -192,7 +192,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
if (context->enc_modes) {
for (i = 7; i > -1; i++) {
if (context->enc_modes & (1 << i)) {
context->enc_mode = (switch_byte_t)i;
context->enc_mode = (switch_byte_t) i;
break;
}
}
@@ -201,10 +201,11 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
if (!context->enc_mode) {
context->enc_mode = globals.default_bitrate;
}
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
context->enc_mode = AMR_DEFAULT_BITRATE;
context->encoder_state = NULL;
context->decoder_state = NULL;
@@ -224,7 +225,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
#endif
}
static switch_status_t switch_amr_destroy(switch_codec_t *codec)
static switch_status_t switch_amr_destroy(switch_codec_t *codec)
{
#ifndef AMR_PASSTHROUGH
struct amr_context *context = codec->private_info;
@@ -240,45 +241,39 @@ static switch_status_t switch_amr_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS;
}
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)
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)
{
#ifdef AMR_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
return SWITCH_STATUS_FALSE;
#else
struct amr_context *context = codec->private_info;
if (!context) {
return SWITCH_STATUS_FALSE;
}
*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (switch_byte_t *) encoded_data, 0);
*encoded_data_len =
Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data,
(switch_byte_t *) encoded_data, 0);
return SWITCH_STATUS_SUCCESS;
#endif
}
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)
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)
{
#ifdef AMR_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -290,51 +285,51 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
Decoder_Interface_Decode(context->decoder_state, (unsigned char *)encoded_data, (int16_t *)decoded_data, 0);
Decoder_Interface_Decode(context->decoder_state, (unsigned char *) encoded_data, (int16_t *) decoded_data, 0);
*decoded_data_len = codec->implementation->bytes_per_frame;
return SWITCH_STATUS_SUCCESS;
#endif
}
/* Registration */
/* Registration */
static const switch_codec_implementation_t amr_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 96,
/*.iananame */ "AMR",
static const switch_codec_implementation_t amr_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 96,
/*.iananame */ "AMR",
/*.fmtp */ "octet-align=0",
/*.samples_per_second */ 8000,
/*.bits_per_second */ 0,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 0,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_amr_init,
/*.encode */ switch_amr_encode,
/*.decode */ switch_amr_decode,
/*.destroy */ switch_amr_destroy,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_amr_init,
/*.encode */ switch_amr_encode,
/*.decode */ switch_amr_decode,
/*.destroy */ switch_amr_destroy,
};
static const switch_codec_interface_t amr_codec_interface = {
/*.interface_name */ "GSM-AMR",
/*.implementations */ &amr_implementation,
static const switch_codec_interface_t amr_codec_interface = {
/*.interface_name */ "GSM-AMR",
/*.implementations */ &amr_implementation,
};
static switch_loadable_module_interface_t amr_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &amr_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t amr_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &amr_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
#ifndef AMR_PASSTHROUGH
char *cf = "amr.conf";
@@ -349,17 +344,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "default-bitrate")) {
globals.default_bitrate = (switch_byte_t)atoi(val);
globals.default_bitrate = (switch_byte_t) atoi(val);
}
}
}
}
#endif
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &amr_module_interface;
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -37,7 +37,7 @@ static const char modname[] = "mod_g711";
static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
int encoding, decoding;
@@ -53,12 +53,12 @@ static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_fla
static switch_status_t switch_g711u_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)
{
short *dbuf;
unsigned char *ebuf;
@@ -77,12 +77,12 @@ static switch_status_t switch_g711u_encode(switch_codec_t *codec,
}
static switch_status_t switch_g711u_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)
{
short *dbuf;
unsigned char *ebuf;
@@ -112,7 +112,7 @@ static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
int encoding, decoding;
@@ -128,12 +128,12 @@ static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_fla
static switch_status_t switch_g711a_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)
{
short *dbuf;
unsigned char *ebuf;
@@ -152,12 +152,12 @@ static switch_status_t switch_g711a_encode(switch_codec_t *codec,
}
static switch_status_t switch_g711a_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)
{
short *dbuf;
unsigned char *ebuf;
@@ -226,7 +226,7 @@ static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next*/ &g711u_8k_120ms_implementation
/*.next */ &g711u_8k_120ms_implementation
};
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
@@ -247,7 +247,7 @@ static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next*/ &g711u_8k_60ms_implementation
/*.next */ &g711u_8k_60ms_implementation
};
static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
@@ -268,7 +268,7 @@ static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next*/ &g711u_8k_30ms_implementation
/*.next */ &g711u_8k_30ms_implementation
};
static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
@@ -289,7 +289,7 @@ static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next*/ &g711u_8k_20ms_implementation
/*.next */ &g711u_8k_20ms_implementation
};
@@ -332,7 +332,7 @@ static const switch_codec_implementation_t g711a_8k_60ms_implementation = {
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next*/ &g711a_8k_120ms_implementation
/*.next */ &g711a_8k_120ms_implementation
};
static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
@@ -353,7 +353,7 @@ static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next*/ &g711a_8k_60ms_implementation
/*.next */ &g711a_8k_60ms_implementation
};
static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
@@ -374,7 +374,7 @@ static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next*/ &g711a_8k_30ms_implementation
/*.next */ &g711a_8k_30ms_implementation
};
static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
@@ -395,7 +395,7 @@ static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next*/ &g711a_8k_20ms_implementation
/*.next */ &g711a_8k_20ms_implementation
};
@@ -421,7 +421,8 @@ static switch_loadable_module_interface_t g711_module_interface = {
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &g711_module_interface;

View File

@@ -41,7 +41,7 @@ struct g722_context {
};
static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
int encoding, decoding;
struct g722_context *context = NULL;
@@ -50,18 +50,18 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
return SWITCH_STATUS_FALSE;
} else {
if (encoding) {
if(codec->implementation->samples_per_second == 16000){
if (codec->implementation->samples_per_second == 16000) {
g722_encode_init(&context->encoder_object, 64000, G722_PACKED);
} else {
g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000);
}
}
if (decoding) {
if(codec->implementation->samples_per_second == 16000){
if (codec->implementation->samples_per_second == 16000) {
g722_decode_init(&context->decoder_object, 64000, G722_PACKED);
} else {
g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000);
@@ -70,44 +70,47 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
}
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_g722_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 g722_context *context = codec->private_info;
if (!context) {
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_FALSE;
}
*encoded_data_len = g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
*encoded_data_len =
g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_g722_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 g722_context *context = codec->private_info;
if (!context) {
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_FALSE;
}
*decoded_data_len = (2 * g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
*decoded_data_len =
(2 *
g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
return SWITCH_STATUS_SUCCESS;
}
@@ -175,7 +178,8 @@ static switch_loadable_module_interface_t g722_module_interface = {
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &g722_module_interface;

View File

@@ -30,7 +30,7 @@
*
* mod_g723.c -- G723.1 Codec Module
*
*/
*/
#include "switch.h"
#ifndef G723_PASSTHROUGH
@@ -61,11 +61,11 @@ struct g723_context {
#endif
static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
#ifdef G723_PASSTHROUGH
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_FALSE;
#else
struct g723_context *context = NULL;
int encoding, decoding;
@@ -79,10 +79,10 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
if (encoding) {
Init_Coder(&context->encoder_object);
if( UseVx ) {
if (UseVx) {
Init_Vad(&context->encoder_object);
Init_Cod_Cng(&context->encoder_object);
}
}
}
if (decoding) {
@@ -98,7 +98,7 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
}
static switch_status_t switch_g723_destroy(switch_codec_t *codec)
static switch_status_t switch_g723_destroy(switch_codec_t *codec)
{
#ifndef G723_PASSTHROUGH
codec->private_info = NULL;
@@ -106,17 +106,13 @@ static switch_status_t switch_g723_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_g723_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)
static switch_status_t switch_g723_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)
{
#ifdef G723_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -131,28 +127,24 @@ static switch_status_t switch_g723_encode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
for(x = 0; x < Frame; x++) {
for (x = 0; x < Frame; x++) {
context->cod_float_buf[x] = decoded_slin_buf[x];
}
Coder(&context->encoder_object, (FLOAT *)context->cod_float_buf, ebuf);
Coder(&context->encoder_object, (FLOAT *) context->cod_float_buf, ebuf);
*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
return SWITCH_STATUS_SUCCESS;
#endif
}
static switch_status_t switch_g723_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)
static switch_status_t switch_g723_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)
{
#ifdef G723_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -165,10 +157,10 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
if (!context) {
return SWITCH_STATUS_FALSE;
}
Decod(&context->decoder_object, (FLOAT *) context->dec_float_buf, (char *) decoded_data, 0);
for (x=0;x<Frame;x++) {
for (x = 0; x < Frame; x++) {
to_slin_buf[x] = context->dec_float_buf[x];
}
*decoded_data_len = codec->implementation->bytes_per_frame;
@@ -177,49 +169,49 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
#endif
}
/* Registration */
/* Registration */
static const switch_codec_implementation_t g723_1_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 4,
/*.iananame */ "G723",
static const switch_codec_implementation_t g723_1_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 4,
/*.iananame */ "G723",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 6300,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 24,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 4,
/*.init */ switch_g723_init,
/*.encode */ switch_g723_encode,
/*.decode */ switch_g723_decode,
/*.destroy */ switch_g723_destroy,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 6300,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 24,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 4,
/*.init */ switch_g723_init,
/*.encode */ switch_g723_encode,
/*.decode */ switch_g723_decode,
/*.destroy */ switch_g723_destroy,
};
static const switch_codec_interface_t g723_1_codec_interface = {
/*.interface_name */ "g723.1 6.3k",
/*.implementations */ &g723_1_implementation,
static const switch_codec_interface_t g723_1_codec_interface = {
/*.interface_name */ "g723.1 6.3k",
/*.implementations */ &g723_1_implementation,
};
static switch_loadable_module_interface_t g723_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &g723_1_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t g723_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &g723_1_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &g723_module_interface;
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -28,15 +28,15 @@
*
* mod_g726.c -- G726 Codec Module
*
*/
*/
#include "switch.h"
#include "g72x.h"
#include "switch_bitpack.h"
static const char modname[] = "mod_g726";
typedef int (*encoder_t)(int, int, g726_state *);
typedef int (*decoder_t)(int, int, g726_state *);
typedef int (*encoder_t) (int, int, g726_state *);
typedef int (*decoder_t) (int, int, g726_state *);
typedef struct {
@@ -53,7 +53,7 @@ typedef struct {
} g726_handle_t;
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
uint32_t encoding, decoding;
g726_handle_t *handle;
@@ -65,8 +65,8 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
return SWITCH_STATUS_FALSE;
} else {
handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
switch(handle->bytes) {
switch (handle->bytes) {
case 100:
handle->encoder = g726_40_encoder;
handle->decoder = g726_40_decoder;
@@ -88,22 +88,24 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
handle->loops = 160;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n",
codec->implementation->encoded_bytes_per_frame);
return SWITCH_STATUS_FALSE;
break;
}
g726_init_state(&handle->context);
codec->private_info = handle;
handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
handle->bits_per_frame =
(switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
return SWITCH_STATUS_SUCCESS;
}
}
static switch_status_t switch_g726_destroy(switch_codec_t *codec)
static switch_status_t switch_g726_destroy(switch_codec_t *codec)
{
codec->private_info = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -111,17 +113,13 @@ static switch_status_t switch_g726_destroy(switch_codec_t *codec)
static switch_status_t switch_g726_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)
static switch_status_t switch_g726_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)
{
g726_handle_t *handle = codec->private_info;
@@ -153,7 +151,8 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
if (new_len <= *encoded_data_len) {
*encoded_data_len = new_len;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
*encoded_data_len);
return SWITCH_STATUS_FALSE;
}
}
@@ -163,17 +162,13 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
static switch_status_t switch_g726_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)
static switch_status_t switch_g726_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)
{
g726_handle_t *handle = codec->private_info;
@@ -192,13 +187,13 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
for (y = 0; y < handle->loops; y++) {
switch_bitpack_out(&handle->unpack, in[z++]);
}
for(y = 0; y < handle->bytes; y++) {
for (y = 0; y < handle->bytes; y++) {
*ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
new_len += 2;
new_len += 2;
}
switch_bitpack_done(&handle->unpack);
}
if (new_len <= *decoded_data_len) {
*decoded_data_len = new_len;
} else {
@@ -213,239 +208,239 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
/* Registration */
/* Registration */
static const switch_codec_implementation_t g726_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 127,
/*.iananame */ "G726-16",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 40,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t g726_24k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 126,
/*.iananame */ "G726-24",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 60,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t g726_32k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 2,
/*.iananame */ "G726-32",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t g726_40k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 125,
/*.iananame */ "G726-40",
static const switch_codec_implementation_t g726_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 127,
/*.iananame */ "G726-16",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 100,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
/*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 40,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 124,
/*.iananame */ "AAL2-G726-16",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 40,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_24k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 123,
/*.iananame */ "AAL2-G726-24",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 60,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_32k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 2,
/*.iananame */ "AAL2-G726-32",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_40k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 122,
/*.iananame */ "AAL2-G726-40",
static const switch_codec_implementation_t g726_24k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 126,
/*.iananame */ "G726-24",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 100,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
/*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 60,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
const switch_codec_interface_t g726_16k_codec_interface = {
/*.interface_name */ "G.726 16k",
/*.implementations */ &g726_16k_implementation,
static const switch_codec_implementation_t g726_32k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 2,
/*.iananame */ "G726-32",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
const switch_codec_interface_t g726_24k_codec_interface = {
/*.interface_name */ "G.726 24k",
/*.implementations */ &g726_24k_implementation,
static const switch_codec_implementation_t g726_40k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 125,
/*.iananame */ "G726-40",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 100,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 124,
/*.iananame */ "AAL2-G726-16",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 16000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 40,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_24k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 123,
/*.iananame */ "AAL2-G726-24",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 24000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 60,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_32k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 2,
/*.iananame */ "AAL2-G726-32",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
static const switch_codec_implementation_t aal2_g726_40k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 122,
/*.iananame */ "AAL2-G726-40",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 40000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 100,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g726_init,
/*.encode */ switch_g726_encode,
/*.decode */ switch_g726_decode,
/*.destroy */ switch_g726_destroy,
};
const switch_codec_interface_t g726_16k_codec_interface = {
/*.interface_name */ "G.726 16k",
/*.implementations */ &g726_16k_implementation,
};
const switch_codec_interface_t g726_24k_codec_interface = {
/*.interface_name */ "G.726 24k",
/*.implementations */ &g726_24k_implementation,
/*.next */ &g726_16k_codec_interface
};
const switch_codec_interface_t g726_32k_codec_interface = {
/*.interface_name */ "G.726 32k",
/*.implementations */ &g726_32k_implementation,
const switch_codec_interface_t g726_32k_codec_interface = {
/*.interface_name */ "G.726 32k",
/*.implementations */ &g726_32k_implementation,
/*.next */ &g726_24k_codec_interface
};
const switch_codec_interface_t g726_40k_codec_interface = {
/*.interface_name */ "G.726 40k",
/*.implementations */ &g726_40k_implementation,
const switch_codec_interface_t g726_40k_codec_interface = {
/*.interface_name */ "G.726 40k",
/*.implementations */ &g726_40k_implementation,
/*.next */ &g726_32k_codec_interface
};
const switch_codec_interface_t aal2_g726_16k_codec_interface = {
/*.interface_name */ "G.726 16k (aal2)",
/*.implementations */ &aal2_g726_16k_implementation,
const switch_codec_interface_t aal2_g726_16k_codec_interface = {
/*.interface_name */ "G.726 16k (aal2)",
/*.implementations */ &aal2_g726_16k_implementation,
/*.next */ &g726_40k_codec_interface
};
const switch_codec_interface_t aal2_g726_24k_codec_interface = {
/*.interface_name */ "G.726 24k (aal2)",
/*.implementations */ &aal2_g726_24k_implementation,
const switch_codec_interface_t aal2_g726_24k_codec_interface = {
/*.interface_name */ "G.726 24k (aal2)",
/*.implementations */ &aal2_g726_24k_implementation,
/*.next */ &aal2_g726_16k_codec_interface
};
const switch_codec_interface_t aal2_g726_32k_codec_interface = {
/*.interface_name */ "G.726 32k (aal2)",
/*.implementations */ &aal2_g726_32k_implementation,
const switch_codec_interface_t aal2_g726_32k_codec_interface = {
/*.interface_name */ "G.726 32k (aal2)",
/*.implementations */ &aal2_g726_32k_implementation,
/*.next */ &aal2_g726_24k_codec_interface
};
const switch_codec_interface_t aal2_g726_40k_codec_interface = {
/*.interface_name */ "G.726 40k (aal2)",
/*.implementations */ &aal2_g726_40k_implementation,
const switch_codec_interface_t aal2_g726_40k_codec_interface = {
/*.interface_name */ "G.726 40k (aal2)",
/*.implementations */ &aal2_g726_40k_implementation,
/*.next */ &aal2_g726_32k_codec_interface
};
static switch_loadable_module_interface_t g726_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &aal2_g726_40k_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t g726_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &aal2_g726_40k_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &g726_module_interface;
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -30,7 +30,7 @@
*
* mod_g729.c -- G729 Codec Module
*
*/
*/
static const char modname[] = "mod_g729";
@@ -46,15 +46,15 @@ struct g729_context {
#endif
static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
#ifdef G729_PASSTHROUGH
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
return SWITCH_STATUS_SUCCESS;
#else
#else
struct g729_context *context = NULL;
int encoding, decoding;
@@ -64,9 +64,9 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
return SWITCH_STATUS_FALSE;
} else {
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
if (codec->fmtp_in) {
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
}
if (encoding) {
g729_init_coder(&context->encoder_object, 0);
@@ -84,7 +84,7 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
#endif
}
static switch_status_t switch_g729_destroy(switch_codec_t *codec)
static switch_status_t switch_g729_destroy(switch_codec_t *codec)
{
#ifndef G729_PASSTHROUGH
codec->private_info = NULL;
@@ -92,17 +92,13 @@ static switch_status_t switch_g729_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_g729_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)
static switch_status_t switch_g729_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)
{
#ifdef G729_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -117,7 +113,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
if (decoded_data_len % 160 == 0) {
uint32_t new_len = 0;
INT16 * ddp = decoded_data;
INT16 *ddp = decoded_data;
char *edp = encoded_data;
int x;
int loops = (int) decoded_data_len / 160;
@@ -132,7 +128,8 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
if (new_len <= *encoded_data_len) {
*encoded_data_len = new_len;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
*encoded_data_len);
return SWITCH_STATUS_FALSE;
}
}
@@ -140,17 +137,13 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
#endif
}
static switch_status_t switch_g729_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)
static switch_status_t switch_g729_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)
{
#ifdef G729_PASSTHROUGH
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
@@ -189,7 +182,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
uint32_t new_len = 0;
test = (uint8_t *) encoded_data;
if (*test == 0 && *(test+1) == 0) {
if (*test == 0 && *(test + 1) == 0) {
*decoded_data_len = (encoded_data_len / divisor) * 160;
memset(decoded_data, 0, *decoded_data_len);
return SWITCH_STATUS_SUCCESS;
@@ -213,55 +206,56 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
encoded_data_len);
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
#endif
}
/* Registration */
/* Registration */
static const switch_codec_implementation_t g729_10ms_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
static const switch_codec_implementation_t g729_10ms_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80,
/*.bytes_per_frame */ 160,
/*.encoded_bytes_per_frame */ 10,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80,
/*.bytes_per_frame */ 160,
/*.encoded_bytes_per_frame */ 10,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
};
static const switch_codec_implementation_t g729_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
static const switch_codec_implementation_t g729_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 20,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 20,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
&g729_10ms_8k_implementation
};
@@ -271,22 +265,22 @@ static const switch_codec_interface_t g729_codec_interface = {
/*.next */ NULL
};
static switch_loadable_module_interface_t g729_module_interface = {
static switch_loadable_module_interface_t g729_module_interface = {
/*.module_name */ "g729",
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &g729_codec_interface,
/*.application_interface */ NULL
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &g729_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &g729_module_interface;
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -28,7 +28,7 @@
*
* mod_codec_gsm.c -- gsm Codec Module
*
*/
*/
#include "switch.h"
#include "gsm.h"
static const char modname[] = "mod_gsm";
@@ -37,7 +37,7 @@ struct gsm_context {
gsm decoder;
};
static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
struct gsm_context *context;
int encoding, decoding;
@@ -55,7 +55,7 @@ static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
{
struct gsm_context *context = codec->private_info;
int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
@@ -68,8 +68,8 @@ static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS;
}
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_data_len, 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;
if (!context) {
@@ -77,8 +77,8 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
}
if (decoded_data_len % 320 == 0) {
uint32_t new_len = 0;
gsm_signal * ddp = decoded_data;
gsm_byte * edp = encoded_data;
gsm_signal *ddp = decoded_data;
gsm_byte *edp = encoded_data;
int x;
int loops = (int) decoded_data_len / 320;
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
@@ -90,15 +90,16 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
if (new_len <= *encoded_data_len) {
*encoded_data_len = new_len;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
*encoded_data_len);
return SWITCH_STATUS_FALSE;
}
}
return SWITCH_STATUS_SUCCESS;
}
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_data_len, 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;
if (!context) {
@@ -107,8 +108,8 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
if (encoded_data_len % 33 == 0) {
int loops = (int) encoded_data_len / 33;
gsm_byte * edp = encoded_data;
gsm_signal * ddp = decoded_data;
gsm_byte *edp = encoded_data;
gsm_signal *ddp = decoded_data;
int x;
uint32_t new_len = 0;
@@ -121,57 +122,59 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
if (new_len <= *decoded_data_len) {
*decoded_data_len = new_len;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len, *decoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len,
*decoded_data_len);
return SWITCH_STATUS_FALSE;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n", encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n",
encoded_data_len);
}
return SWITCH_STATUS_SUCCESS;
}
/* Registration */
static const switch_codec_implementation_t gsm_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 3,
/*.iananame */ "GSM",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 13200,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 33,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_gsm_init,
/*.encode */ switch_gsm_encode,
/*.decode */ switch_gsm_decode,
/*.destroy */ switch_gsm_destroy,
/* Registration */
static const switch_codec_implementation_t gsm_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 3,
/*.iananame */ "GSM",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 13200,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 33,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_gsm_init,
/*.encode */ switch_gsm_encode,
/*.decode */ switch_gsm_decode,
/*.destroy */ switch_gsm_destroy,
};
static const switch_codec_interface_t gsm_codec_interface = {
/*.interface_name */ "gsm",
/*.implementations */ &gsm_8k_implementation,
static const switch_codec_interface_t gsm_codec_interface = {
/*.interface_name */ "gsm",
/*.implementations */ &gsm_8k_implementation,
};
static switch_loadable_module_interface_t gsm_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &gsm_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t gsm_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &gsm_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &gsm_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &gsm_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:

View File

@@ -28,7 +28,7 @@
*
* mod_ilbc.c -- ilbc Codec Module
*
*/
*/
#include "switch.h"
#include "iLBC_encode.h"
#include "iLBC_decode.h"
@@ -45,11 +45,11 @@ struct ilbc_context {
};
static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
struct ilbc_context *context;
int encoding, decoding;
uint8_t ms = (uint8_t)(codec->implementation->microseconds_per_frame / 1000);
uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_frame / 1000);
if (ms != 20 && ms != 30) {
@@ -82,13 +82,13 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
}
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->implementation->fmtp);
codec->private_info = context;
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
{
codec->private_info = NULL;
return SWITCH_STATUS_SUCCESS;
@@ -96,14 +96,12 @@ static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
static switch_status_t switch_ilbc_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 ilbc_context *context = codec->private_info;
@@ -120,7 +118,7 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
float buf[240];
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
for (y = 0; y < context->dbytes / sizeof(short); y++) {
buf[y] = ddp[y];
}
iLBC_encode(edp, buf, &context->encoder);
@@ -131,7 +129,8 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
if (new_len <= *encoded_data_len) {
*encoded_data_len = new_len;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
*encoded_data_len);
return SWITCH_STATUS_FALSE;
}
}
@@ -139,14 +138,12 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
}
static switch_status_t switch_ilbc_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 ilbc_context *context = codec->private_info;
@@ -165,8 +162,8 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
iLBC_decode(buf, edp, &context->decoder, 1);
for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
ddp[y] = (short)buf[y];
for (y = 0; y < context->dbytes / sizeof(short); y++) {
ddp[y] = (short) buf[y];
}
ddp += context->dbytes / sizeof(short);
edp += context->bytes;
@@ -179,160 +176,161 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
encoded_data_len);
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}
/* Registration */
/* Registration */
static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_8k_30ms_implementation
static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_8k_30ms_implementation
};
static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC102",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_102_8k_30ms_implementation
static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC102",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_102_8k_30ms_implementation
};
static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC20ms",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC20ms",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
static const switch_codec_interface_t ilbc_20ms_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_8k_20ms_nonext_implementation
static const switch_codec_interface_t ilbc_20ms_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_8k_20ms_nonext_implementation
};
static const switch_codec_interface_t ilbc_102_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_102_8k_20ms_implementation,
/*.next*/ &ilbc_20ms_codec_interface
static const switch_codec_interface_t ilbc_102_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_102_8k_20ms_implementation,
/*.next */ &ilbc_20ms_codec_interface
};
static const switch_codec_interface_t ilbc_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_8k_20ms_implementation,
/*.next*/ &ilbc_102_codec_interface
static const switch_codec_interface_t ilbc_codec_interface = {
/*.interface_name */ "ilbc",
/*.implementations */ &ilbc_8k_20ms_implementation,
/*.next */ &ilbc_102_codec_interface
};
static switch_loadable_module_interface_t ilbc_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &ilbc_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t ilbc_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &ilbc_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &ilbc_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &ilbc_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -35,7 +35,7 @@ static const char modname[] = "mod_l16";
static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
int encoding, decoding;
@@ -50,15 +50,16 @@ static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_
}
static switch_status_t switch_raw_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)
{
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
if (codec && other_codec
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
memcpy(encoded_data, decoded_data, decoded_data_len);
*encoded_data_len = decoded_data_len;
return SWITCH_STATUS_RESAMPLE;
@@ -67,14 +68,15 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
}
static switch_status_t switch_raw_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)
{
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
if (codec && other_codec
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
memcpy(decoded_data, encoded_data, encoded_data_len);
*decoded_data_len = encoded_data_len;
return SWITCH_STATUS_RESAMPLE;
@@ -107,7 +109,7 @@ static const switch_codec_implementation_t raw_32k_60ms_implementation = {
/*.encode = */ switch_raw_encode,
/*.decode = */ switch_raw_decode,
/*.destroy = */ switch_raw_destroy
/*.next = */
/*.next = */
};
static const switch_codec_implementation_t raw_32k_30ms_implementation = {
@@ -298,6 +300,7 @@ static const switch_codec_implementation_t raw_16k_10ms_implementation = {
/*.destroy = */ switch_raw_destroy,
/*.next = */ &raw_16k_20ms_implementation
};
///////////////////////////////
@@ -426,7 +429,8 @@ static switch_loadable_module_interface_t raw_module_interface = {
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &raw_module_interface;

View File

@@ -28,16 +28,16 @@
*
* mod_lpc10.c -- LPC10 Codec Module
*
*/
*/
#include "switch.h"
#include "lpc10.h"
enum {
SamplesPerFrame = 180,
BitsPerFrame = 54,
BytesPerFrame = (BitsPerFrame+7)/8,
BitsPerSecond = 2400
BitsPerFrame = 54,
BytesPerFrame = (BitsPerFrame + 7) / 8,
BitsPerSecond = 2400
};
#define SampleValueScale 32768.0
@@ -52,7 +52,7 @@ struct lpc10_context {
};
static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
uint32_t encoding, decoding;
struct lpc10_context *context = NULL;
@@ -78,44 +78,40 @@ static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_fla
}
}
static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
{
codec->private_info = NULL;
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_lpc10_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)
static switch_status_t switch_lpc10_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)
{
struct lpc10_context *context = codec->private_info;
uint8_t i;
int32_t bits[BitsPerFrame];
real speech[SamplesPerFrame];
const short *sampleBuffer = (const short *)decoded_data;
unsigned char *buffer = (unsigned char *)encoded_data;
const short *sampleBuffer = (const short *) decoded_data;
unsigned char *buffer = (unsigned char *) encoded_data;
if (!context) {
return SWITCH_STATUS_FALSE;
}
for (i = 0; i < SamplesPerFrame; i++)
speech[i] = (real)(sampleBuffer[i]/SampleValueScale);
speech[i] = (real) (sampleBuffer[i] / SampleValueScale);
lpc10_encode(speech, bits, &context->encoder_object);
memset(encoded_data, 0, BytesPerFrame);
for (i = 0; i < BitsPerFrame; i++) {
if (bits[i])
buffer[i>>3] |= 1 << (i&7);
buffer[i >> 3] |= 1 << (i & 7);
}
*encoded_data_len = BytesPerFrame;
@@ -123,91 +119,87 @@ static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_lpc10_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)
static switch_status_t switch_lpc10_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)
{
struct lpc10_context *context = codec->private_info;
int i;
INT32 bits[BitsPerFrame];
real speech[SamplesPerFrame];
short *sampleBuffer = (short *)decoded_data;
const unsigned char *buffer = (const unsigned char *)encoded_data;
short *sampleBuffer = (short *) decoded_data;
const unsigned char *buffer = (const unsigned char *) encoded_data;
if (!context) {
return SWITCH_STATUS_FALSE;
}
for (i = 0; i < BitsPerFrame; i++)
bits[i] = (buffer[i>>3]&(1<<(i&7))) != 0;
bits[i] = (buffer[i >> 3] & (1 << (i & 7))) != 0;
lpc10_decode(bits, speech, &context->decoder_object);
for (i = 0; i < SamplesPerFrame; i++) {
real sample = (real)(speech[i]*SampleValueScale);
real sample = (real) (speech[i] * SampleValueScale);
if (sample < MinSampleValue)
sample = MinSampleValue;
else if (sample > MaxSampleValue)
sample = MaxSampleValue;
sampleBuffer[i] = (short)sample;
sampleBuffer[i] = (short) sample;
}
*decoded_data_len = SamplesPerFrame*2;
*decoded_data_len = SamplesPerFrame * 2;
return SWITCH_STATUS_SUCCESS;
}
/* Registration */
/* Registration */
static const switch_codec_implementation_t lpc10_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 7,
/*.iananame */ "LPC",
static const switch_codec_implementation_t lpc10_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 7,
/*.iananame */ "LPC",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.bits_per_second */ 240,
/*.microseconds_per_frame */ 22500,
/*.samples_per_frame */ 180,
/*.bytes_per_frame */ 360,
/*.encoded_bytes_per_frame */ 7,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_lpc10_init,
/*.encode */ switch_lpc10_encode,
/*.decode */ switch_lpc10_decode,
/*.destroy */ switch_lpc10_destroy,
/*.bits_per_second */ 240,
/*.microseconds_per_frame */ 22500,
/*.samples_per_frame */ 180,
/*.bytes_per_frame */ 360,
/*.encoded_bytes_per_frame */ 7,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_lpc10_init,
/*.encode */ switch_lpc10_encode,
/*.decode */ switch_lpc10_decode,
/*.destroy */ switch_lpc10_destroy,
};
const switch_codec_interface_t lpc10_codec_interface = {
/*.interface_name */ "LPC-10 2.4kbps",
/*.implementations */ &lpc10_implementation,
const switch_codec_interface_t lpc10_codec_interface = {
/*.interface_name */ "LPC-10 2.4kbps",
/*.implementations */ &lpc10_implementation,
};
static switch_loadable_module_interface_t lpc10_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &lpc10_codec_interface,
/*.application_interface */ NULL
static switch_loadable_module_interface_t lpc10_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ NULL,
/*.timer_interface */ NULL,
/*.dialplan_interface */ NULL,
/*.codec_interface */ &lpc10_codec_interface,
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &lpc10_module_interface;
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -73,7 +73,7 @@ struct speex_context {
};
static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
const switch_codec_settings_t *codec_settings)
{
struct speex_context *context = NULL;
int encoding, decoding;
@@ -158,12 +158,12 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
}
static switch_status_t switch_speex_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 speex_context *context = codec->private_info;
short *buf;
@@ -211,12 +211,12 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
}
static switch_status_t switch_speex_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 speex_context *context = codec->private_info;
short *buf;
@@ -343,7 +343,8 @@ static switch_loadable_module_interface_t speex_module_interface = {
/*.application_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
char *filename)
{
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &speex_module_interface;