forked from Mirrors/freeswitch
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
This commit is contained in:
parent
93c30a12fd
commit
f41319e655
|
@ -42,6 +42,7 @@
|
|||
#define SWITCH_LOADABLE_MODULE_H
|
||||
|
||||
#include <switch.h>
|
||||
#include <switch_module_interfaces.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
/*!
|
||||
|
@ -305,14 +306,79 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
|
|||
break; \
|
||||
}
|
||||
|
||||
#define SWITCH_ADD_CODEC(codec_int, int_name, implementation) \
|
||||
#define SWITCH_ADD_CODEC(codec_int, int_name) \
|
||||
for (;;) { \
|
||||
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; \
|
||||
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) { \
|
||||
|
|
|
@ -514,7 +514,7 @@ struct switch_codec {
|
|||
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
||||
struct switch_codec_implementation {
|
||||
/*! enumeration defining the type of the codec */
|
||||
const switch_codec_type_t codec_type;
|
||||
switch_codec_type_t codec_type;
|
||||
/*! the IANA code number */
|
||||
switch_payload_t ianacode;
|
||||
/*! the IANA code name */
|
||||
|
@ -542,21 +542,13 @@ struct switch_codec_implementation {
|
|||
/*! 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_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 */
|
||||
switch_status_t (*encode) (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);
|
||||
switch_core_codec_encode_func_t encode;
|
||||
/*! function to decode encoded data into raw data */
|
||||
switch_status_t (*decode) (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);
|
||||
switch_core_codec_decode_func_t decode;
|
||||
/*! 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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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 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 *);
|
||||
#define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data)
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
* mod_amr.c -- GSM-AMR Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load);
|
||||
|
@ -284,28 +285,6 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
|||
}
|
||||
|
||||
/* 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_codec_interface_t *codec_interface;
|
||||
|
@ -331,8 +310,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
|
|||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
* 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 <g7xx/g711.h>
|
||||
|
||||
|
@ -176,233 +177,28 @@ static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
|
|||
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_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 */
|
||||
*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, "g711 alaw", &g711a_8k_10ms_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
|
||||
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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -27,9 +27,10 @@
|
|||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Michael Jerris <mike@jerris.com>
|
||||
*
|
||||
* mod_g722.c -- G722 Codec Module
|
||||
* mod_g722.c -- G.722 Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "g7xx/g722.h"
|
||||
|
||||
|
@ -115,58 +116,21 @@ static switch_status_t switch_g722_destroy(switch_codec_t *codec)
|
|||
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_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 */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
* mod_g723_1.c -- G723.1 Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
#ifndef G723_PASSTHROUGH
|
||||
|
@ -166,36 +167,19 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
|||
#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_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 */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
BASE=../../../..
|
||||
G726_DIR=$(BASE)/libs/codec/g726
|
||||
G726LA=$(G726_DIR)/libg726.la
|
||||
LOCAL_CFLAGS=-I$(G726_DIR)/src
|
||||
LOCAL_LIBADD=$(G726LA)
|
||||
G7XX_DIR=$(BASE)/libs/codec/g7xx
|
||||
G7XXLA=$(G7XX_DIR)/libg7xx.la
|
||||
LOCAL_CFLAGS=-I$(G7XX_DIR)/src/include/
|
||||
LOCAL_LIBADD=$(G7XXLA)
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
$(G726LA): $(G726_DIR) $(G726_DIR)/.update
|
||||
cd $(G726_DIR) && $(MAKE)
|
||||
$(G7XXLA): $(G7XX_DIR) $(G7XX_DIR)/.update
|
||||
cd $(G7XX_DIR) && $(MAKE)
|
||||
$(TOUCH_TARGET)
|
||||
|
|
|
@ -30,72 +30,46 @@
|
|||
*
|
||||
*/
|
||||
#include "switch.h"
|
||||
#include "g72x.h"
|
||||
#include "switch_bitpack.h"
|
||||
#include "g7xx/g726.h"
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_g726_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_g726, mod_g726_load, NULL, NULL);
|
||||
|
||||
typedef int (*encoder_t) (int, int, g726_state *);
|
||||
typedef int (*decoder_t) (int, int, g726_state *);
|
||||
|
||||
typedef struct {
|
||||
g726_state context;
|
||||
switch_byte_t bits_per_frame;
|
||||
encoder_t encoder;
|
||||
decoder_t decoder;
|
||||
switch_bitpack_t pack;
|
||||
switch_bitpack_t unpack;
|
||||
switch_bitpack_mode_t mode;
|
||||
switch_byte_t loops;
|
||||
switch_byte_t bytes;
|
||||
switch_byte_t buf[160];
|
||||
} g726_handle_t;
|
||||
|
||||
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
uint32_t encoding, decoding;
|
||||
g726_handle_t *handle;
|
||||
int packing = G726_PACKING_RIGHT;
|
||||
g726_state_t *context;
|
||||
|
||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
||||
if (!(encoding || decoding) || (!(handle = switch_core_alloc(codec->memory_pool, sizeof(*handle))))) {
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
|
||||
if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
|
||||
packing = G726_PACKING_LEFT;
|
||||
}
|
||||
|
||||
switch (handle->bytes) {
|
||||
case 100:
|
||||
handle->encoder = g726_40_encoder;
|
||||
handle->decoder = g726_40_decoder;
|
||||
handle->loops = 160;
|
||||
switch (codec->implementation->bits_per_second) {
|
||||
case 40000:
|
||||
g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
|
||||
break;
|
||||
case 80:
|
||||
handle->encoder = g726_32_encoder;
|
||||
handle->decoder = g726_32_decoder;
|
||||
handle->loops = 40;
|
||||
case 32000:
|
||||
g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
|
||||
break;
|
||||
case 60:
|
||||
handle->encoder = g726_24_encoder;
|
||||
handle->decoder = g726_24_decoder;
|
||||
handle->loops = 160;
|
||||
case 24000:
|
||||
g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
|
||||
break;
|
||||
case 40:
|
||||
handle->encoder = g726_16_encoder;
|
||||
handle->decoder = g726_16_decoder;
|
||||
handle->loops = 160;
|
||||
case 16000:
|
||||
g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
g726_init_state(&handle->context);
|
||||
codec->private_info = handle;
|
||||
handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->actual_samples_per_second));
|
||||
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
|
||||
? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
|
||||
codec->private_info = context;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -113,38 +87,13 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
|||
uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
g726_state *context = &handle->context;
|
||||
uint32_t len = codec->implementation->bytes_per_frame;
|
||||
g726_state_t *context = codec->private_info;
|
||||
|
||||
if (!context) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (decoded_data_len % len == 0) {
|
||||
uint32_t new_len = 0;
|
||||
int16_t *ddp = decoded_data;
|
||||
switch_byte_t *edp = encoded_data;
|
||||
uint32_t x, loops = decoded_data_len / (sizeof(*ddp));
|
||||
|
||||
switch_bitpack_init(&handle->pack, handle->bits_per_frame, edp, *encoded_data_len, handle->mode);
|
||||
|
||||
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
||||
int edata = handle->encoder(*ddp, AUDIO_ENCODING_LINEAR, context);
|
||||
switch_bitpack_in(&handle->pack, (switch_byte_t) edata);
|
||||
ddp++;
|
||||
}
|
||||
switch_bitpack_done(&handle->pack);
|
||||
new_len = handle->pack.bytes;
|
||||
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
*encoded_data_len = g726_encode(context, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -156,222 +105,90 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
|||
uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
g726_state *context = &handle->context;
|
||||
int16_t *ddp = decoded_data;
|
||||
uint32_t new_len = 0, z = 0, y;
|
||||
g726_state_t *context = codec->private_info;
|
||||
|
||||
switch_byte_t *in = (switch_byte_t *) encoded_data;
|
||||
|
||||
if (!handle || !context) {
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
while (z < encoded_data_len && new_len <= *decoded_data_len) {
|
||||
switch_bitpack_init(&handle->unpack, handle->bits_per_frame, handle->buf, sizeof(handle->buf), handle->mode);
|
||||
for (y = 0; y < handle->loops; y++) {
|
||||
switch_bitpack_out(&handle->unpack, in[z++]);
|
||||
}
|
||||
for (y = 0; y < handle->bytes; y++) {
|
||||
*ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
|
||||
new_len += 2;
|
||||
}
|
||||
switch_bitpack_done(&handle->unpack);
|
||||
}
|
||||
|
||||
if (new_len <= *decoded_data_len) {
|
||||
*decoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
*decoded_data_len = (2 * g726_decode(context, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
|
||||
static switch_codec_implementation_t g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 127,
|
||||
/*.iananame */ "G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 126,
|
||||
/*.iananame */ "G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 125,
|
||||
/*.iananame */ "G726-40",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t aal2_g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 124,
|
||||
/*.iananame */ "AAL2-G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t aal2_g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 123,
|
||||
/*.iananame */ "AAL2-G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t aal2_g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "AAL2-G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t aal2_g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 122,
|
||||
/*.iananame */ "AAL2-G726-40",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_g726_load)
|
||||
{
|
||||
switch_codec_interface_t *codec_interface;
|
||||
int mpf = 10000, spf = 80, bpf = 160, ebpf = 20, count;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 40k (aal2)", &aal2_g726_40k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 32k (aal2)", &aal2_g726_32k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 24k (aal2)", &aal2_g726_24k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 16k (aal2)", &aal2_g726_16k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 40k", &g726_40k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 32k", &g726_32k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 24k", &g726_24k_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 16k", &g726_16k_implementation);
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 16k (AAL2)");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 124, "AAL2-G726-16", NULL, 8000, 8000, 16000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 127, "G726-16", NULL, 8000, 8000, 16000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
/* Increase encoded bytes per frame by 10 */
|
||||
ebpf = ebpf + 10;
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 24k (AAL2)");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 123, "AAL2-G726-24", NULL, 8000, 8000, 24000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 126, "G726-24", NULL, 8000, 8000, 24000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
/* Increase encoded bytes per frame by 10 */
|
||||
ebpf = ebpf + 10;
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 32k (AAL2)");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 2, "AAL2-G726-32", NULL, 8000, 8000, 32000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 2, "G726-32", NULL, 8000, 8000, 32000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
/* Increase encoded bytes per frame by 10 */
|
||||
ebpf = ebpf + 10;
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 40k (AAL2)");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 122, "AAL2-G726-40", NULL, 8000, 8000, 40000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
|
||||
for (count = 12; count > 0; count--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 125, "G726-40", NULL, 8000, 8000, 40000,
|
||||
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
|
||||
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
|
||||
}
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
*
|
||||
* 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"
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load);
|
||||
|
@ -205,102 +206,21 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
|||
#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_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 */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Michael Jerris <mike@jerris.com>
|
||||
*
|
||||
* mod_gsm.c -- gsm Codec Module
|
||||
* mod_gsm.c -- GSM-FR Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include "switch.h"
|
||||
#include "gsm.h"
|
||||
|
||||
|
@ -136,34 +137,20 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
|
|||
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_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 */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* mod_h26x.c -- H26X Signed Linear Codec
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load);
|
||||
|
@ -68,85 +69,29 @@ static switch_status_t switch_h26x_decode(switch_codec_t *codec,
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_h26x_destroy(switch_codec_t *codec)
|
||||
{
|
||||
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_codec_interface_t *codec_interface;
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* mod_ilbc.c -- ilbc Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include "switch.h"
|
||||
#include "iLBC_encode.h"
|
||||
#include "iLBC_decode.h"
|
||||
|
@ -176,123 +177,41 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
|||
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_codec_interface_t *codec_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*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", &ilbc_8k_20ms_nonext_implementation);
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "iLBC");
|
||||
|
||||
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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* mod_l16.c -- Raw Signed Linear Codec
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_l16_load);
|
||||
|
@ -86,345 +87,35 @@ static switch_status_t switch_raw_destroy(switch_codec_t *codec)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_codec_implementation_t raw_32k_60ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 119,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 32000,
|
||||
/*.actual_samples_per_second = */ 32000,
|
||||
/*.bits_per_second = */ 512000,
|
||||
/*.microseconds_per_frame = */ 60000,
|
||||
/*.samples_per_frame = */ 1920,
|
||||
/*.bytes_per_frame = */ 3840,
|
||||
/*.encoded_bytes_per_frame = */ 3840,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy
|
||||
/*.next = */
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_32k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 119,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 32000,
|
||||
/*.actual_samples_per_second = */ 32000,
|
||||
/*.bits_per_second = */ 512000,
|
||||
/*.microseconds_per_frame = */ 30000,
|
||||
/*.samples_per_frame = */ 960,
|
||||
/*.bytes_per_frame = */ 1920,
|
||||
/*.encoded_bytes_per_frame = */ 1920,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_32k_60ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_32k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 119,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 32000,
|
||||
/*.actual_samples_per_second = */ 32000,
|
||||
/*.bits_per_second = */ 512000,
|
||||
/*.microseconds_per_frame = */ 20000,
|
||||
/*.samples_per_frame = */ 640,
|
||||
/*.bytes_per_frame = */ 1280,
|
||||
/*.encoded_bytes_per_frame = */ 1280,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_32k_30ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_32k_10ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 119,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 32000,
|
||||
/*.actual_samples_per_second = */ 32000,
|
||||
/*.bits_per_second = */ 512000,
|
||||
/*.microseconds_per_frame = */ 10000,
|
||||
/*.samples_per_frame = */ 320,
|
||||
/*.bytes_per_frame = */ 640,
|
||||
/*.encoded_bytes_per_frame = */ 640,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_32k_20ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_22k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 118,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 22050,
|
||||
/*.actual_samples_per_second = */ 22050,
|
||||
/*.bits_per_second = */ 352800,
|
||||
/*.microseconds_per_frame = */ 20000,
|
||||
/*.samples_per_frame = */ 441,
|
||||
/*.bytes_per_frame = */ 882,
|
||||
/*.encoded_bytes_per_frame = */ 882,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_32k_10ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_16k_120ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 117,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 16000,
|
||||
/*.actual_samples_per_second */ 16000,
|
||||
/*.bits_per_second */ 256000,
|
||||
/*.microseconds_per_frame */ 120000,
|
||||
/*.samples_per_frame */ 1920,
|
||||
/*.bytes_per_frame */ 3840,
|
||||
/*.encoded_bytes_per_frame */ 3840,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_22k_20ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_16k_60ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 117,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 16000,
|
||||
/*.actual_samples_per_second */ 16000,
|
||||
/*.bits_per_second */ 256000,
|
||||
/*.microseconds_per_frame */ 60000,
|
||||
/*.samples_per_frame */ 960,
|
||||
/*.bytes_per_frame */ 1920,
|
||||
/*.encoded_bytes_per_frame */ 1920,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_16k_120ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_16k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 117,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 16000,
|
||||
/*.actual_samples_per_second */ 16000,
|
||||
/*.bits_per_second */ 256000,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 480,
|
||||
/*.bytes_per_frame */ 960,
|
||||
/*.encoded_bytes_per_frame */ 960,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_16k_60ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_16k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 117,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 16000,
|
||||
/*.actual_samples_per_second = */ 16000,
|
||||
/*.bits_per_second = */ 256000,
|
||||
/*.microseconds_per_frame = */ 20000,
|
||||
/*.samples_per_frame = */ 320,
|
||||
/*.bytes_per_frame = */ 640,
|
||||
/*.encoded_bytes_per_frame = */ 640,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_16k_30ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_16k_10ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 117,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 16000,
|
||||
/*.actual_samples_per_second = */ 16000,
|
||||
/*.bits_per_second = */ 256000,
|
||||
/*.microseconds_per_frame = */ 10000,
|
||||
/*.samples_per_frame = */ 160,
|
||||
/*.bytes_per_frame = */ 320,
|
||||
/*.encoded_bytes_per_frame = */ 320,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_16k_20ms_implementation
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
static switch_codec_implementation_t raw_8k_120ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 10,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 512000,
|
||||
/*.microseconds_per_frame */ 120000,
|
||||
/*.samples_per_frame */ 960,
|
||||
/*.bytes_per_frame */ 1920,
|
||||
/*.encoded_bytes_per_frame */ 1920,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_16k_10ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_8k_60ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 10,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 256000,
|
||||
/*.microseconds_per_frame */ 60000,
|
||||
/*.samples_per_frame */ 480,
|
||||
/*.bytes_per_frame */ 960,
|
||||
/*.encoded_bytes_per_frame */ 960,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_8k_120ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_8k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 10,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.actual_samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 128000,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ 480,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_raw_init,
|
||||
/*.encode */ switch_raw_encode,
|
||||
/*.decode */ switch_raw_decode,
|
||||
/*.destroy */ switch_raw_destroy,
|
||||
/*.next */ &raw_8k_60ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_8k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 10,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 8000,
|
||||
/*.actual_samples_per_second = */ 8000,
|
||||
/*.bits_per_second = */ 128000,
|
||||
/*.microseconds_per_frame = */ 20000,
|
||||
/*.samples_per_frame = */ 160,
|
||||
/*.bytes_per_frame = */ 320,
|
||||
/*.encoded_bytes_per_frame = */ 320,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next */ &raw_8k_30ms_implementation
|
||||
};
|
||||
|
||||
static switch_codec_implementation_t raw_8k_10ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 10,
|
||||
/*.iananame */ "L16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second = */ 8000,
|
||||
/*.actual_samples_per_second = */ 8000,
|
||||
/*.bits_per_second = */ 128000,
|
||||
/*.microseconds_per_frame = */ 10000,
|
||||
/*.samples_per_frame = */ 80,
|
||||
/*.bytes_per_frame = */ 160,
|
||||
/*.encoded_bytes_per_frame = */ 160,
|
||||
/*.number_of_channels = */ 1,
|
||||
/*.pref_frames_per_packet = */ 1,
|
||||
/*.max_frames_per_packet = */ 1,
|
||||
/*.init = */ switch_raw_init,
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next */ &raw_8k_20ms_implementation
|
||||
};
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_l16_load)
|
||||
{
|
||||
switch_codec_interface_t *codec_interface;
|
||||
int mpf = 10000, spf = 80, bpf = 160, ebpf = 160, bps = 128000, rate = 8000, counta, countb;
|
||||
int ianacode[4] = { 0, 10, 117, 119 };
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
SWITCH_ADD_CODEC(codec_interface, "raw signed linear (16 bit)", &raw_8k_10ms_implementation);
|
||||
SWITCH_ADD_CODEC(codec_interface, "RAW Signed Linear (16 bit)");
|
||||
for (counta = 1; counta <= 3; counta++) {
|
||||
for (countb = 12; countb > 0; countb--) {
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "L16", NULL, rate, rate, bps,
|
||||
mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 12,
|
||||
switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
|
||||
}
|
||||
rate = rate * 2;
|
||||
bps = bps * 2;
|
||||
spf = spf * 2;
|
||||
bpf = bpf * 2;
|
||||
ebpf = ebpf * 2;
|
||||
}
|
||||
|
||||
switch_core_codec_add_implementation(pool, codec_interface,
|
||||
SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
|
||||
20000, 441, 882, 882, 1, 1, 1,
|
||||
switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -156,36 +156,17 @@ static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
|
|||
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_codec_interface_t *codec_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
*
|
||||
* mod_speexcodec.c -- Speex Codec Module
|
||||
* mod_speex.c -- Speex Codec Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <speex/speex.h>
|
||||
#include <speex/speex_preprocess.h>
|
||||
|
@ -260,145 +261,30 @@ static switch_status_t switch_speex_destroy(switch_codec_t *codec)
|
|||
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_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 */
|
||||
*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 */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue