mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-20 02:04:13 +00:00
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@107 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
0ce22f5ac7
commit
d79ff1c66e
5 files changed
+89
-25
No files matched your search
@@ -35,14 +35,12 @@
|
||||
static const char modname[] = "mod_codec_g729";
|
||||
|
||||
struct g729_context {
|
||||
struct dec_state *decoder_object;
|
||||
struct cod_state *encoder_object;
|
||||
struct dec_state decoder_object;
|
||||
struct cod_state encoder_object;
|
||||
};
|
||||
|
||||
static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
struct dec_state *decoder_object = NULL;
|
||||
struct cod_state *encoder_object = NULL;
|
||||
struct g729_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -52,20 +50,14 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
if ((encoding) && (!(encoder_object = switch_core_alloc(codec->memory_pool, sizeof(*encoder_object))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
memset(context, 0, sizeof(*context));
|
||||
if (encoding) {
|
||||
g729_init_coder(&context->encoder_object, 0);
|
||||
}
|
||||
if ((decoding) && (!(decoder_object = switch_core_alloc(codec->memory_pool, sizeof(*decoder_object))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
if (decoding) {
|
||||
g729_init_decoder(&context->decoder_object);
|
||||
}
|
||||
if (encoder_object) {
|
||||
g729_init_coder(encoder_object, 0);
|
||||
}
|
||||
if (decoder_object) {
|
||||
g729_init_decoder(decoder_object);
|
||||
}
|
||||
context->decoder_object = decoder_object;
|
||||
context->encoder_object = encoder_object;
|
||||
|
||||
codec->private = context;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -88,7 +80,6 @@ static switch_status switch_g729_encode(switch_codec *codec,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct g729_context *context = codec->private;
|
||||
struct cod_state *encoder_object = context->encoder_object;
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
int cbret = 0;
|
||||
@@ -102,7 +93,7 @@ static switch_status switch_g729_encode(switch_codec *codec,
|
||||
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(encoder_object, (short *) dbuf, ebuf, &cbret);
|
||||
g729_coder(&context->encoder_object, (short *) dbuf, ebuf, &cbret);
|
||||
|
||||
*encoded_data_len = (codec->implementation->encoded_bytes_per_frame / 2);
|
||||
|
||||
@@ -119,7 +110,6 @@ static switch_status switch_g729_decode(switch_codec *codec,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct g729_context *context = codec->private;
|
||||
struct dec_state *decoder_object = context->decoder_object;
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
|
||||
@@ -136,7 +126,7 @@ static switch_status switch_g729_decode(switch_codec *codec,
|
||||
memset(dbuf, 0, codec->implementation->bytes_per_frame);
|
||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||
} else {
|
||||
g729_decoder(decoder_object, decoded_data, (void *) encoded_data, (int)encoded_data_len);
|
||||
g729_decoder(&context->decoder_object, decoded_data, (void *) encoded_data, (int)encoded_data_len);
|
||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="mod_codec_g729"
|
||||
ProjectGUID="{B1FE4613-3F4B-4DAF-9714-2472BF8F56AE}"
|
||||
ProjectGUID="{1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0}"
|
||||
RootNamespace="mod_codec_g729"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user