提交 f41319e6 authored 作者: Brian West's avatar Brian West

Massive codec update. I have also switched G726 to use Steve Underwoods code as…

Massive codec update.  I have also switched G726 to use Steve Underwoods code as it passes all the tests. G726 tested in AAL2 mode with Sipura and G726-32 tested with Snom which does proper bitpacking.  Be sure to "make current" before you continue.

/b



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7452 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 93c30a12
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#define SWITCH_LOADABLE_MODULE_H #define SWITCH_LOADABLE_MODULE_H
#include <switch.h> #include <switch.h>
#include <switch_module_interfaces.h>
SWITCH_BEGIN_EXTERN_C SWITCH_BEGIN_EXTERN_C
/*! /*!
...@@ -305,14 +306,79 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void); ...@@ -305,14 +306,79 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
break; \ break; \
} }
#define SWITCH_ADD_CODEC(codec_int, int_name, implementation) \ #define SWITCH_ADD_CODEC(codec_int, int_name) \
for (;;) { \ for (;;) { \
codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \ codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
codec_int->implementations = implementation; \
codec_int->interface_name = int_name; \ codec_int->interface_name = int_name; \
break; \ break; \
} }
static inline void switch_core_codec_add_implementation(switch_memory_pool_t *pool,
switch_codec_interface_t *codec_interface,
/*! enumeration defining the type of the codec */
const switch_codec_type_t codec_type,
/*! the IANA code number */
switch_payload_t ianacode,
/*! the IANA code name */
char *iananame,
/*! default fmtp to send (can be overridden by the init function) */
char *fmtp,
/*! samples transferred per second */
uint32_t samples_per_second,
/*! actual samples transferred per second for those who are not moron g722 RFC writers*/
uint32_t actual_samples_per_second,
/*! bits transferred per second */
int bits_per_second,
/*! number of microseconds that denote one frame */
int microseconds_per_frame,
/*! number of samples that denote one frame */
uint32_t samples_per_frame,
/*! number of bytes that denote one frame decompressed */
uint32_t bytes_per_frame,
/*! number of bytes that denote one frame compressed */
uint32_t encoded_bytes_per_frame,
/*! number of channels represented */
uint8_t number_of_channels,
/*! number of frames to send in one netowrk packet */
int pref_frames_per_packet,
/*! max number of frames to send in one network packet */
int max_frames_per_packet,
/*! function to initialize a codec handle using this implementation */
switch_core_codec_init_func_t init,
/*! function to encode raw data into encoded data */
switch_core_codec_encode_func_t encode,
/*! function to decode encoded data into raw data */
switch_core_codec_decode_func_t decode,
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy)
{
switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
impl->codec_type = codec_type;
impl->ianacode = ianacode;
impl->iananame = iananame;
impl->fmtp = fmtp;
impl->samples_per_second = samples_per_second;
impl->actual_samples_per_second = actual_samples_per_second;
impl->bits_per_second = bits_per_second;
impl->microseconds_per_frame = microseconds_per_frame;
impl->samples_per_frame = samples_per_frame;
impl->bytes_per_frame = bytes_per_frame;
impl->encoded_bytes_per_frame = encoded_bytes_per_frame;
impl->number_of_channels = number_of_channels;
impl->pref_frames_per_packet = pref_frames_per_packet;
impl->max_frames_per_packet = max_frames_per_packet;
impl->init = init;
impl->encode = encode;
impl->decode = decode;
impl->destroy = destroy;
impl->next = codec_interface->implementations;
codec_interface->implementations = impl;
}
///\} ///\}
#define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut) void init(void) { \ #define SWITCH_DECLARE_STATIC_MODULE(init, load, run, shut) void init(void) { \
......
...@@ -514,7 +514,7 @@ struct switch_codec { ...@@ -514,7 +514,7 @@ struct switch_codec {
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */ /*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
struct switch_codec_implementation { struct switch_codec_implementation {
/*! enumeration defining the type of the codec */ /*! enumeration defining the type of the codec */
const switch_codec_type_t codec_type; switch_codec_type_t codec_type;
/*! the IANA code number */ /*! the IANA code number */
switch_payload_t ianacode; switch_payload_t ianacode;
/*! the IANA code name */ /*! the IANA code name */
...@@ -542,21 +542,13 @@ struct switch_codec_implementation { ...@@ -542,21 +542,13 @@ struct switch_codec_implementation {
/*! max number of frames to send in one network packet */ /*! max number of frames to send in one network packet */
int max_frames_per_packet; int max_frames_per_packet;
/*! function to initialize a codec handle using this implementation */ /*! function to initialize a codec handle using this implementation */
switch_status_t (*init) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings); switch_core_codec_init_func_t init;
/*! function to encode raw data into encoded data */ /*! function to encode raw data into encoded data */
switch_status_t (*encode) (switch_codec_t *codec, switch_core_codec_encode_func_t encode;
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag);
/*! function to decode encoded data into raw data */ /*! function to decode encoded data into raw data */
switch_status_t (*decode) (switch_codec_t *codec, switch_core_codec_decode_func_t decode;
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag);
/*! deinitalize a codec handle using this implementation */ /*! deinitalize a codec handle using this implementation */
switch_status_t (*destroy) (switch_codec_t *); switch_core_codec_destroy_func_t destroy;
struct switch_codec_implementation *next; struct switch_codec_implementation *next;
}; };
......
...@@ -1123,6 +1123,34 @@ typedef struct switch_core_port_allocator switch_core_port_allocator_t; ...@@ -1123,6 +1123,34 @@ typedef struct switch_core_port_allocator switch_core_port_allocator_t;
typedef struct switch_media_bug switch_media_bug_t; typedef struct switch_media_bug switch_media_bug_t;
typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t); typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
typedef switch_status_t (*switch_core_codec_encode_func_t) (switch_codec_t *codec,
switch_codec_t *other_codec,
void *decoded_data,
uint32_t decoded_data_len,
uint32_t decoded_rate,
void *encoded_data,
uint32_t * encoded_data_len,
uint32_t * encoded_rate,
unsigned int *flag);
typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *codec,
switch_codec_t *other_codec,
void *encoded_data,
uint32_t encoded_data_len,
uint32_t encoded_rate,
void *decoded_data,
uint32_t * decoded_data_len,
uint32_t * decoded_rate,
unsigned int *flag);
typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
typedef void (*switch_application_function_t) (switch_core_session_t *, const char *); typedef void (*switch_application_function_t) (switch_core_session_t *, const char *);
#define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data) #define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data)
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
* mod_amr.c -- GSM-AMR Codec Module * mod_amr.c -- GSM-AMR Codec Module
* *
*/ */
#include "switch.h" #include "switch.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load); SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load);
...@@ -284,28 +285,6 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec, ...@@ -284,28 +285,6 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
} }
/* Registration */ /* Registration */
static switch_codec_implementation_t amr_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 96,
/*.iananame */ "AMR",
/*.fmtp */ "octet-align=0",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 0,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_amr_init,
/*.encode */ switch_amr_encode,
/*.decode */ switch_amr_decode,
/*.destroy */ switch_amr_destroy,
};
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load) SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
...@@ -331,8 +310,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load) ...@@ -331,8 +310,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "GSM-AMR", &amr_implementation);
SWITCH_ADD_CODEC(codec_interface, "GSM-AMR");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200,
20000, 160, 320, 0, 1, 1, 1,
switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* *
* *
* mod_g711.c -- G711 Ulaw/Alaw Codec Module * mod_g711.c -- G.711 Ulaw/Alaw Codec Module
* *
*/ */
#include <switch.h> #include <switch.h>
#include <g7xx/g711.h> #include <g7xx/g711.h>
...@@ -176,233 +177,28 @@ static switch_status_t switch_g711a_destroy(switch_codec_t *codec) ...@@ -176,233 +177,28 @@ static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t g711u_8k_120ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 960,
/*.bytes_per_frame */ 1920,
/*.encoded_bytes_per_frame */ 960,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711u_init,
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy
};
static switch_codec_implementation_t g711u_8k_60ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 480,
/*.bytes_per_frame */ 960,
/*.encoded_bytes_per_frame */ 480,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711u_init,
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next */ &g711u_8k_120ms_implementation
};
static switch_codec_implementation_t g711u_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 240,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711u_init,
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next */ &g711u_8k_60ms_implementation
};
static switch_codec_implementation_t g711u_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 160,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711u_init,
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next */ &g711u_8k_30ms_implementation
};
static switch_codec_implementation_t g711u_8k_10ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80,
/*.bytes_per_frame */ 160,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711u_init,
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
/*.next */ &g711u_8k_20ms_implementation
};
static switch_codec_implementation_t g711a_8k_120ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 120000,
/*.samples_per_frame */ 960,
/*.bytes_per_frame */ 1920,
/*.encoded_bytes_per_frame */ 960,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711a_init,
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy
};
static switch_codec_implementation_t g711a_8k_60ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 60000,
/*.samples_per_frame */ 480,
/*.bytes_per_frame */ 960,
/*.encoded_bytes_per_frame */ 480,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711a_init,
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next */ &g711a_8k_120ms_implementation
};
static switch_codec_implementation_t g711a_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 240,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711a_init,
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next */ &g711a_8k_60ms_implementation
};
static switch_codec_implementation_t g711a_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 160,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711a_init,
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next */ &g711a_8k_30ms_implementation
};
static switch_codec_implementation_t g711a_8k_10ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80,
/*.bytes_per_frame */ 160,
/*.encoded_bytes_per_frame */ 80,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g711a_init,
/*.encode */ switch_g711a_encode,
/*.decode */ switch_g711a_decode,
/*.destroy */ switch_g711a_destroy,
/*.next */ &g711a_8k_20ms_implementation
};
SWITCH_MODULE_LOAD_FUNCTION(mod_g711_load) SWITCH_MODULE_LOAD_FUNCTION(mod_g711_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "g711 ulaw", &g711u_8k_10ms_implementation); SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
SWITCH_ADD_CODEC(codec_interface, "g711 alaw", &g711a_8k_10ms_implementation); for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* Michael Jerris <mike@jerris.com> * Michael Jerris <mike@jerris.com>
* *
* mod_g722.c -- G722 Codec Module * mod_g722.c -- G.722 Codec Module
* *
*/ */
#include <switch.h> #include <switch.h>
#include "g7xx/g722.h" #include "g7xx/g722.h"
...@@ -115,58 +116,21 @@ static switch_status_t switch_g722_destroy(switch_codec_t *codec) ...@@ -115,58 +116,21 @@ static switch_status_t switch_g722_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t g722_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 109,
/*.iananame */ "G722_8",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 160,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g722_init,
/*.encode */ switch_g722_encode,
/*.decode */ switch_g722_decode,
/*.destroy */ switch_g722_destroy
};
static switch_codec_implementation_t g722_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 9,
/*.iananame */ "G722",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 640,
/*.encoded_bytes_per_frame */ 160,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g722_init,
/*.encode */ switch_g722_encode,
/*.decode */ switch_g722_decode,
/*.destroy */ switch_g722_destroy,
/*.next */
};
SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load) SWITCH_MODULE_LOAD_FUNCTION(mod_g722_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 10000, spf = 80, bpf = 320, ebpf = 80, count;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "G722", &g722_16k_implementation);
SWITCH_ADD_CODEC(codec_interface, "G722_8", &g722_8k_implementation); SWITCH_ADD_CODEC(codec_interface, "G.722");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 9, "G722", NULL, 8000, 16000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
* mod_g723_1.c -- G723.1 Codec Module * mod_g723_1.c -- G723.1 Codec Module
* *
*/ */
#include "switch.h" #include "switch.h"
#ifndef G723_PASSTHROUGH #ifndef G723_PASSTHROUGH
...@@ -166,36 +167,19 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec, ...@@ -166,36 +167,19 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
#endif #endif
} }
/* Registration */
static switch_codec_implementation_t g723_1_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 4,
/*.iananame */ "G723",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 6300,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 24,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 4,
/*.init */ switch_g723_init,
/*.encode */ switch_g723_encode,
/*.decode */ switch_g723_decode,
/*.destroy */ switch_g723_destroy,
};
SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load) SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 30000, spf = 240, bpf = 480, ebpf = 24, count;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "g723.1 6.3k", &g723_1_implementation); SWITCH_ADD_CODEC(codec_interface, "G.723.1 6.3k");
for (count = 1; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 4,
switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
BASE=../../../.. BASE=../../../..
G726_DIR=$(BASE)/libs/codec/g726 G7XX_DIR=$(BASE)/libs/codec/g7xx
G726LA=$(G726_DIR)/libg726.la G7XXLA=$(G7XX_DIR)/libg7xx.la
LOCAL_CFLAGS=-I$(G726_DIR)/src LOCAL_CFLAGS=-I$(G7XX_DIR)/src/include/
LOCAL_LIBADD=$(G726LA) LOCAL_LIBADD=$(G7XXLA)
include $(BASE)/build/modmake.rules include $(BASE)/build/modmake.rules
$(G726LA): $(G726_DIR) $(G726_DIR)/.update $(G7XXLA): $(G7XX_DIR) $(G7XX_DIR)/.update
cd $(G726_DIR) && $(MAKE) cd $(G7XX_DIR) && $(MAKE)
$(TOUCH_TARGET) $(TOUCH_TARGET)
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
* *
* The g729 codec itself is not distributed with this module. * The g729 codec itself is not distributed with this module.
* *
* mod_g729.c -- G729 Codec Module * mod_g729.c -- G.729 Codec Module
* *
*/ */
#include "switch.h" #include "switch.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load); SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load);
...@@ -205,102 +206,21 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec, ...@@ -205,102 +206,21 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
#endif #endif
} }
/* Registration */
static switch_codec_implementation_t g729_40ms_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 128000,
/*.microseconds_per_frame */ 40000,
/*.samples_per_frame */ 320,
/*.bytes_per_frame */ 640,
/*.encoded_bytes_per_frame */ 40,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
};
static switch_codec_implementation_t g729_30ms_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 96000,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 30,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
/*.next */ &g729_40ms_8k_implementation
};
static switch_codec_implementation_t g729_10ms_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 32000,
/*.microseconds_per_frame */ 10000,
/*.samples_per_frame */ 80,
/*.bytes_per_frame */ 160,
/*.encoded_bytes_per_frame */ 10,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
/*.next */ &g729_30ms_8k_implementation
};
static switch_codec_implementation_t g729_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 64000,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 20,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_g729_init,
/*.encode */ switch_g729_encode,
/*.decode */ switch_g729_decode,
/*.destroy */ switch_g729_destroy,
/*.next */ &g729_10ms_8k_implementation
};
SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load) SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 10000, spf = 80, bpf = 160, ebpf = 10, count;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "g729", &g729_8k_implementation);
SWITCH_ADD_CODEC(codec_interface, "G.729");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 18, "G729", NULL, 8000, 8000, 8000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
switch_g729_init, switch_g729_encode, switch_g729_decode, switch_g729_destroy);
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* Michael Jerris <mike@jerris.com> * Michael Jerris <mike@jerris.com>
* *
* mod_gsm.c -- gsm Codec Module * mod_gsm.c -- GSM-FR Codec Module
* *
*/ */
#include "switch.h" #include "switch.h"
#include "gsm.h" #include "gsm.h"
...@@ -136,34 +137,20 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t * ...@@ -136,34 +137,20 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t gsm_8k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 3,
/*.iananame */ "GSM",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 13200,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 33,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_gsm_init,
/*.encode */ switch_gsm_encode,
/*.decode */ switch_gsm_decode,
/*.destroy */ switch_gsm_destroy,
};
SWITCH_MODULE_LOAD_FUNCTION(mod_gsm_load) SWITCH_MODULE_LOAD_FUNCTION(mod_gsm_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 20000, spf = 160, bpf = 320, ebpf = 33, count;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "gsm", &gsm_8k_implementation); SWITCH_ADD_CODEC(codec_interface, "GSM-FR");
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 3, "GSM", NULL, 8000, 8000, 13200,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 6,
switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* mod_h26x.c -- H26X Signed Linear Codec * mod_h26x.c -- H26X Signed Linear Codec
* *
*/ */
#include <switch.h> #include <switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load); SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load);
...@@ -68,85 +69,29 @@ static switch_status_t switch_h26x_decode(switch_codec_t *codec, ...@@ -68,85 +69,29 @@ static switch_status_t switch_h26x_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
static switch_status_t switch_h26x_destroy(switch_codec_t *codec) static switch_status_t switch_h26x_destroy(switch_codec_t *codec)
{ {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_codec_implementation_t h264_90000_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
/*.ianacode */ 99,
/*.iananame */ "H264",
/*.fmtp */ NULL,
/*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0,
/*.bytes_per_frame = */ 0,
/*.encoded_bytes_per_frame = */ 0,
/*.number_of_channels = */ 1,
/*.pref_frames_per_packet = */ 1,
/*.max_frames_per_packet = */ 1,
/*.init = */ switch_h26x_init,
/*.encode = */ switch_h26x_encode,
/*.decode = */ switch_h26x_decode,
/*.destroy = */ switch_h26x_destroy
/*.next = */
};
static switch_codec_implementation_t h263_90000_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
/*.ianacode */ 34,
/*.iananame */ "H263",
/*.fmtp */ NULL,
/*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0,
/*.bytes_per_frame = */ 0,
/*.encoded_bytes_per_frame = */ 0,
/*.number_of_channels = */ 1,
/*.pref_frames_per_packet = */ 1,
/*.max_frames_per_packet = */ 1,
/*.init = */ switch_h26x_init,
/*.encode = */ switch_h26x_encode,
/*.decode = */ switch_h26x_decode,
/*.destroy = */ switch_h26x_destroy,
/*.next = */&h264_90000_implementation
};
static switch_codec_implementation_t h261_90000_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_VIDEO,
/*.ianacode */ 31,
/*.iananame */ "H261",
/*.fmtp */ NULL,
/*.samples_per_second = */ 90000,
/*.actual_samples_per_second = */ 90000,
/*.bits_per_second = */ 0,
/*.microseconds_per_frame = */ 0,
/*.samples_per_frame = */ 0,
/*.bytes_per_frame = */ 0,
/*.encoded_bytes_per_frame = */ 0,
/*.number_of_channels = */ 1,
/*.pref_frames_per_packet = */ 1,
/*.max_frames_per_packet = */ 1,
/*.init = */ switch_h26x_init,
/*.encode = */ switch_h26x_encode,
/*.decode = */ switch_h26x_decode,
/*.destroy = */ switch_h26x_destroy,
/*.next = */&h263_90000_implementation
};
SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load) SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "h26x video (passthru)", &h261_90000_implementation); SWITCH_ADD_CODEC(codec_interface, "H.26x Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1,
switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 34, "H263", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1,
switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 31, "H261", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1,
switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* mod_ilbc.c -- ilbc Codec Module * mod_ilbc.c -- ilbc Codec Module
* *
*/ */
#include "switch.h" #include "switch.h"
#include "iLBC_encode.h" #include "iLBC_encode.h"
#include "iLBC_decode.h" #include "iLBC_decode.h"
...@@ -176,123 +177,41 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec, ...@@ -176,123 +177,41 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t ilbc_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
static switch_codec_implementation_t ilbc_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_8k_30ms_implementation
};
static switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC",
/*.fmtp */ "mode=30",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
/*.microseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
static switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC102",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy,
/*.next */ &ilbc_102_8k_30ms_implementation
};
static switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC20ms",
/*.fmtp */ "mode=20",
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
/*.microseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_ilbc_init,
/*.encode */ switch_ilbc_encode,
/*.decode */ switch_ilbc_decode,
/*.destroy */ switch_ilbc_destroy
};
SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load) SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_8k_20ms_implementation);
SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_102_8k_20ms_implementation); SWITCH_ADD_CODEC(codec_interface, "iLBC");
SWITCH_ADD_CODEC(codec_interface, "ilbc", &ilbc_8k_20ms_nonext_implementation);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 97, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC102", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC20ms", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
/* 30ms variants */
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 98, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
...@@ -156,36 +156,17 @@ static switch_status_t switch_lpc10_decode(switch_codec_t *codec, ...@@ -156,36 +156,17 @@ static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t lpc10_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 7,
/*.iananame */ "LPC",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 240,
/*.microseconds_per_frame */ 22500,
/*.samples_per_frame */ 180,
/*.bytes_per_frame */ 360,
/*.encoded_bytes_per_frame */ 7,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_lpc10_init,
/*.encode */ switch_lpc10_encode,
/*.decode */ switch_lpc10_decode,
/*.destroy */ switch_lpc10_destroy,
};
SWITCH_MODULE_LOAD_FUNCTION(mod_lpc10_load) SWITCH_MODULE_LOAD_FUNCTION(mod_lpc10_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "LPC-10 2.4kbps", &lpc10_implementation); SWITCH_ADD_CODEC(codec_interface, "LPC-10 2.4kbps");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
22500, 180, 360, 7, 1, 1, 1,
switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* *
* *
* mod_speexcodec.c -- Speex Codec Module * mod_speex.c -- Speex Codec Module
* *
*/ */
#include <switch.h> #include <switch.h>
#include <speex/speex.h> #include <speex/speex.h>
#include <speex/speex_preprocess.h> #include <speex/speex_preprocess.h>
...@@ -260,145 +261,30 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec) ...@@ -260,145 +261,30 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* Registration */
static switch_codec_implementation_t speex_32k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 32000,
/*.actual_samples_per_second */ 32000,
/*.bits_per_second */ 44000,
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 640,
/*.bytes_per_frame */ 1280,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy
};
static switch_codec_implementation_t speex_16k_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 99,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 16000,
/*.actual_samples_per_second */ 16000,
/*.bits_per_second */ 42200,
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 320,
/*.bytes_per_frame */ 640,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy,
/*.next */ &speex_32k_implementation
};
static switch_codec_implementation_t speex_8k_60ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24600,
/*.nanoseconds_per_frame */ 60000,
/*.samples_per_frame */ 480,
/*.bytes_per_frame */ 960,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy,
/*.next */ &speex_16k_implementation
};
static switch_codec_implementation_t speex_8k_40ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24600,
/*.nanoseconds_per_frame */ 40000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 640,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy,
/*.next */ &speex_8k_60ms_implementation
};
static switch_codec_implementation_t speex_8k_30ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24600,
/*.nanoseconds_per_frame */ 30000,
/*.samples_per_frame */ 240,
/*.bytes_per_frame */ 480,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy,
/*.next */ &speex_8k_40ms_implementation
};
static switch_codec_implementation_t speex_8k_20ms_implementation = {
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.fmtp */ NULL,
/*.samples_per_second */ 8000,
/*.actual_samples_per_second */ 8000,
/*.bits_per_second */ 24600,
/*.nanoseconds_per_frame */ 20000,
/*.samples_per_frame */ 160,
/*.bytes_per_frame */ 320,
/*.encoded_bytes_per_frame */ 0,
/*.number_of_channels */ 1,
/*.pref_frames_per_packet */ 1,
/*.max_frames_per_packet */ 1,
/*.init */ switch_speex_init,
/*.encode */ switch_speex_encode,
/*.decode */ switch_speex_decode,
/*.destroy */ switch_speex_destroy,
/*.next */ &speex_8k_30ms_implementation
};
SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load) SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
{ {
switch_codec_interface_t *codec_interface; switch_codec_interface_t *codec_interface;
int mpf = 10000, spf = 80, bpf = 160, ebpf = 0, rate = 8000, counta, countb;
int ianacode[4] = { 0, 98, 99, 103};
int bps[4] = { 0, 24600, 42200, 44000 };
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CODEC(codec_interface, "speex", &speex_8k_20ms_implementation); SWITCH_ADD_CODEC(codec_interface, "Speex");
for (counta = 1; counta <= 3; counta++) {
for (countb = 6; countb > 0; countb--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "speex", NULL, rate, rate, bps[counta],
mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 6,
switch_speex_init, switch_speex_encode, switch_speex_decode, switch_speex_destroy);
}
rate = rate * 2;
spf = spf * 2;
bpf = bpf * 2;
ebpf = ebpf * 2;
}
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论