fix codec
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@113 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
05ee76b30a
commit
0ad907ea46
|
@ -11,3 +11,4 @@ mod_g711codec
|
||||||
mod_rawaudio
|
mod_rawaudio
|
||||||
mod_iaxchan
|
mod_iaxchan
|
||||||
#mod_opalchan
|
#mod_opalchan
|
||||||
|
mod_codec_g729
|
||||||
|
|
|
@ -79,22 +79,15 @@ static switch_status switch_g729_encode(switch_codec *codec,
|
||||||
unsigned int *flag)
|
unsigned int *flag)
|
||||||
{
|
{
|
||||||
struct g729_context *context = codec->private;
|
struct g729_context *context = codec->private;
|
||||||
short *dbuf;
|
|
||||||
unsigned char *ebuf;
|
|
||||||
int cbret = 0;
|
int cbret = 0;
|
||||||
|
|
||||||
if (!context)
|
if (!context) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
dbuf = decoded_data;
|
g729_coder(&context->encoder_object, (short *) decoded_data, encoded_data, &cbret);
|
||||||
ebuf = encoded_data;
|
|
||||||
|
|
||||||
if (decoded_data_len < (size_t)codec->implementation->samples_per_frame*2 || *encoded_data_len < (size_t)codec->implementation->encoded_bytes_per_frame)
|
*encoded_data_len = 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);
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -112,20 +105,15 @@ static switch_status switch_g729_decode(switch_codec *codec,
|
||||||
short *dbuf;
|
short *dbuf;
|
||||||
unsigned char *ebuf;
|
unsigned char *ebuf;
|
||||||
|
|
||||||
if (!context)
|
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)
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
|
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
|
||||||
memset(dbuf, 0, codec->implementation->bytes_per_frame);
|
memset(dbuf, 0, codec->implementation->bytes_per_frame);
|
||||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||||
} else {
|
} 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;
|
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,12 @@ char *arg = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg = strchr(cmd, ' ')) {
|
if ((arg = strchr(cmd, ' '))) {
|
||||||
*arg++ = '\0';
|
*arg++ = '\0';
|
||||||
}
|
}
|
||||||
if ((api = loadable_module_get_api_interface(cmd))) {
|
if ((api = loadable_module_get_api_interface(cmd))) {
|
||||||
char retbuf[512] = "";
|
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);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue