fix codec

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@113 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2005-12-10 22:37:21 +00:00
parent 05ee76b30a
commit 0ad907ea46
3 changed files with 10 additions and 21 deletions

View File

@ -11,3 +11,4 @@ mod_g711codec
mod_rawaudio
mod_iaxchan
#mod_opalchan
mod_codec_g729

View File

@ -79,22 +79,15 @@ static switch_status switch_g729_encode(switch_codec *codec,
unsigned int *flag)
{
struct g729_context *context = codec->private;
short *dbuf;
unsigned char *ebuf;
int cbret = 0;
if (!context)
if (!context) {
return SWITCH_STATUS_FALSE;
}
dbuf = decoded_data;
ebuf = encoded_data;
g729_coder(&context->encoder_object, (short *) decoded_data, encoded_data, &cbret);
if (decoded_data_len < (size_t)codec->implementation->samples_per_frame*2 || *encoded_data_len < (size_t)codec->implementation->encoded_bytes_per_frame)
return SWITCH_STATUS_FALSE;
g729_coder(&context->encoder_object, (short *) dbuf, ebuf, &cbret);
*encoded_data_len = (codec->implementation->encoded_bytes_per_frame / 2);
*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
return SWITCH_STATUS_SUCCESS;
}
@ -112,20 +105,15 @@ static switch_status switch_g729_decode(switch_codec *codec,
short *dbuf;
unsigned char *ebuf;
if (!context)
return SWITCH_STATUS_FALSE;
dbuf = decoded_data;
ebuf = encoded_data;
if ((encoded_data_len * 2) < (size_t)codec->implementation->encoded_bytes_per_frame)
if (!context) {
return SWITCH_STATUS_FALSE;
}
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
memset(dbuf, 0, codec->implementation->bytes_per_frame);
*decoded_data_len = codec->implementation->bytes_per_frame;
} else {
g729_decoder(&context->decoder_object, decoded_data, (void *) encoded_data, (int)encoded_data_len);
g729_decoder(&context->decoder_object, decoded_data, encoded_data, encoded_data_len);
*decoded_data_len = codec->implementation->bytes_per_frame;
}

View File

@ -56,12 +56,12 @@ char *arg = NULL;
return 1;
}
if (arg = strchr(cmd, ' ')) {
if ((arg = strchr(cmd, ' '))) {
*arg++ = '\0';
}
if ((api = loadable_module_get_api_interface(cmd))) {
char retbuf[512] = "";
switch_status status = api->function(arg, retbuf, sizeof(retbuf));
api->function(arg, retbuf, sizeof(retbuf));
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
return 1;
}