let g729 be setup for pass through compile like this... MOD_CFLAGS="-DG729_PASSTHROUGH" make installall

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2575 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-09-08 15:43:45 +00:00
parent 597e2becbc
commit 5816256ce3
4 changed files with 50 additions and 25 deletions

View File

@ -446,6 +446,7 @@ SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3) - End period of silence
SWITCH_CODEC_FLAG_SILENCE = (1 << 4) - Silence
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5) - Free codec's pool on destruction
SWITCH_CODEC_FLAG_AAL2 = (1 << 6) - USE AAL2 Bitpacking
SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7) - Passthrough only
</pre>
*/
typedef enum {
@ -455,7 +456,8 @@ typedef enum {
SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3),
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
SWITCH_CODEC_FLAG_AAL2 = (1 << 6)
SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7)
} switch_codec_flag_t;

View File

@ -31,20 +31,27 @@
* mod_g729.c -- G729 Codec Module
*
*/
#include "switch.h"
#include "g729.h"
static const char modname[] = "mod_g729";
#include "switch.h"
#ifndef G729_PASSTHROUGH
#include "g729.h"
struct g729_context {
struct dec_state decoder_object;
struct cod_state encoder_object;
};
#endif
static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
const switch_codec_settings_t *codec_settings)
{
#ifdef G729_PASSTHROUGH
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
return SWITCH_STATUS_SUCCESS;
#else
struct g729_context *context = NULL;
int encoding, decoding;
@ -68,11 +75,14 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
return SWITCH_STATUS_SUCCESS;
}
#endif
}
static switch_status_t switch_g729_destroy(switch_codec_t *codec)
{
#ifndef G729_PASSTHROUGH
codec->private_info = NULL;
#endif
return SWITCH_STATUS_SUCCESS;
}
@ -88,6 +98,10 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
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");
return SWITCH_STATUS_FALSE;
#else
struct g729_context *context = codec->private_info;
int cbret = 0;
@ -117,6 +131,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
}
}
return SWITCH_STATUS_SUCCESS;
#endif
}
static switch_status_t switch_g729_decode(switch_codec_t *codec,
@ -131,6 +146,10 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
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");
return SWITCH_STATUS_FALSE;
#else
struct g729_context *context = codec->private_info;
int divisor = 10;
int plen = 10;
@ -194,6 +213,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
#endif
}
/* Registration */

View File

@ -498,6 +498,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, ch
}
switch_set_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL);
}
implementation->init(codec, flags, codec_settings);
return SWITCH_STATUS_SUCCESS;

View File

@ -1426,7 +1426,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
int32_t idx = -1;
switch_codec_t write_codec = {0};
switch_frame_t write_frame = {0};
uint8_t err = 0, fdata[1024];
uint8_t err = 0, fdata[1024], pass = 0;
char *file = NULL, *key = NULL, *odata, *var;
write_frame.data = fdata;
@ -1630,6 +1630,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
read_codec = switch_core_session_get_read_codec(session);
assert(read_codec != NULL);
if (!(pass = switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
"L16",
read_codec->implementation->samples_per_second,
@ -1650,6 +1651,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
}
}
}
while ((!caller_channel || switch_channel_ready(caller_channel)) &&
check_channel_status(peer_channels, peer_sessions, argc, &idx, file, key) && ((time(NULL) - start) < (time_t)timelimit_sec)) {
@ -1661,7 +1663,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
if (read_frame) {
if (read_frame && !pass) {
if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
break;
}
@ -1718,7 +1720,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (odata) {
free(odata);
}
if (write_codec.implementation) {
if (!pass && write_codec.implementation) {
switch_core_codec_destroy(&write_codec);
}
return status;