]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
let g729 be setup for pass through compile like this... MOD_CFLAGS="-DG729_PASSTHROUG...
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 8 Sep 2006 15:43:45 +0000 (15:43 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 8 Sep 2006 15:43:45 +0000 (15:43 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2575 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/mod/codecs/mod_g729/mod_g729.c
src/switch_core.c
src/switch_ivr.c

index 6019e1166c5deca79d12a63230cd7567584ca562..44e3146c1ebfc5f41c1bf48c82c92e7924b9c7ae 100644 (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;
 
 
index 0880df76f7815273d200a36d8c5024b37151a8ac..5ebaa35a0befca6763c571d0f0f3c98cf8a32736 100644 (file)
  * 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 */ 
index 6eb433fc9741d11e9075af857af9d1e8305d4e53..1208ba665b0a3ddfb202f6650d6fe60410f3c175 100644 (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;
index d062adbb3ab88dfbff5b614825a99bb9bf00be44..e0084a6a5e17a42038bc702be672b96e569bd8d5 100644 (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,24 +1630,26 @@ 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 (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 @@ 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;