[Freeswitch-svn] [commit] r2575 - in freeswitch/trunk/src: . include mod/codecs/mod_g729
Freeswitch SVN
anthm at freeswitch.org
Fri Sep 8 11:43:45 EDT 2006
Author: anthm
Date: Fri Sep 8 11:43:45 2006
New Revision: 2575
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
Log:
let g729 be setup for pass through compile like this... MOD_CFLAGS="-DG729_PASSTHROUGH" make installall
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Fri Sep 8 11:43:45 2006
@@ -446,6 +446,7 @@
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 @@
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;
Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c Fri Sep 8 11:43:45 2006
@@ -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 @@
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 @@
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 @@
}
}
return SWITCH_STATUS_SUCCESS;
+#endif
}
static switch_status_t switch_g729_decode(switch_codec_t *codec,
@@ -131,6 +146,10 @@
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 @@
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
+#endif
}
/* Registration */
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Fri Sep 8 11:43:45 2006
@@ -498,6 +498,7 @@
}
switch_set_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL);
}
+
implementation->init(codec, flags, codec_settings);
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Fri Sep 8 11:43:45 2006
@@ -1426,7 +1426,7 @@
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,24 +1630,26 @@
read_codec = switch_core_session_get_read_codec(session);
assert(read_codec != NULL);
- if (switch_core_codec_init(&write_codec,
- "L16",
- read_codec->implementation->samples_per_second,
- read_codec->implementation->microseconds_per_frame / 1000,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL,
- pool) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- read_codec->implementation->samples_per_second,
- read_codec->implementation->microseconds_per_frame / 1000);
- write_frame.codec = &write_codec;
- write_frame.datalen = read_codec->implementation->bytes_per_frame;
- write_frame.samples = write_frame.datalen / 2;
- memset(write_frame.data, 255, write_frame.datalen);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!");
- switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
+ 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,
+ read_codec->implementation->microseconds_per_frame / 1000,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL,
+ pool) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
+ write_frame.codec = &write_codec;
+ write_frame.datalen = read_codec->implementation->bytes_per_frame;
+ write_frame.samples = write_frame.datalen / 2;
+ memset(write_frame.data, 255, write_frame.datalen);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!");
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
+ }
}
}
@@ -1661,7 +1663,7 @@
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 @@
if (odata) {
free(odata);
}
- if (write_codec.implementation) {
+ if (!pass && write_codec.implementation) {
switch_core_codec_destroy(&write_codec);
}
return status;
More information about the Freeswitch-svn
mailing list