37 #undef SWITCH_MOD_DECLARE_DATA
38 #define SWITCH_MOD_DECLARE_DATA __declspec(dllexport)
46 int encoding, decoding;
51 if (!(encoding || decoding)) {
61 uint32_t decoded_data_len,
62 uint32_t decoded_rate,
void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
68 memcpy(encoded_data, decoded_data, decoded_data_len);
69 *encoded_data_len = decoded_data_len;
78 uint32_t encoded_data_len,
79 uint32_t encoded_rate,
void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
84 memcpy(decoded_data, encoded_data, encoded_data_len);
85 *decoded_data_len = encoded_data_len;
106 uint32_t decoded_data_len,
107 uint32_t decoded_rate,
void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
116 uint32_t encoded_data_len,
117 uint32_t encoded_rate,
void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
131 int encoding, decoding;
136 if (!(encoding || decoding)) {
146 uint32_t decoded_data_len,
147 uint32_t decoded_rate,
void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
157 for (i = 0; i < decoded_data_len /
sizeof(short); i++) {
161 *encoded_data_len = i;
169 uint32_t encoded_data_len,
170 uint32_t encoded_rate,
void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
184 for (i = 0; i < encoded_data_len; i++) {
188 *decoded_data_len = i * 2;
202 int encoding, decoding;
207 if (!(encoding || decoding)) {
217 uint32_t decoded_data_len,
218 uint32_t decoded_rate,
void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
228 for (i = 0; i < decoded_data_len /
sizeof(short); i++) {
232 *encoded_data_len = i;
240 uint32_t encoded_data_len,
241 uint32_t encoded_rate,
void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
255 for (i = 0; i < encoded_data_len; i++) {
259 *decoded_data_len = i * 2;
274 int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
277 for (count = 12; count > 0; count--) {
296 if (count > 4)
continue;
326 ebpf * count * 6 * 2,
336 for (count = 12; count > 0; count--) {
360 int mpf = 10000, spf = 80, bpf = 160, ebpf = 160, bps = 128000, rate = 8000, counta = 1, countb = 12;
361 int samples_per_frame, bytes_per_frame, ms_per_frame, x;
426 for (counta = 1; counta <= 3; counta++) {
432 for (; countb > 0; countb--) {
435 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, spf * countb,
440 mpf * countb, spf * countb, bpf * countb * 2, ebpf * countb, 2, spf * countb,
450 samples_per_frame = 240;
451 bytes_per_frame = 480;
452 ms_per_frame = 20000;
454 for (x = 0; x < 5; x++) {
491 samples_per_frame += 240;
492 bytes_per_frame += 480;
493 ms_per_frame += 20000;
497 samples_per_frame = 480;
498 bytes_per_frame = 960;
499 ms_per_frame = 20000;
501 for (x = 0; x < 3; x++) {
538 samples_per_frame += 480;
539 bytes_per_frame += 960;
540 ms_per_frame += 20000;
546 samples_per_frame = 96;
547 bytes_per_frame = 192;
550 for (x = 0; x < 5; x++) {
587 samples_per_frame += 96;
588 bytes_per_frame += 192;
589 ms_per_frame += 2000;
594 samples_per_frame = 16;
595 bytes_per_frame = 32;
598 for (x = 0; x < 4; x++) {
635 samples_per_frame += 16;
636 bytes_per_frame += 32;
637 ms_per_frame += 2000;
641 samples_per_frame = 32;
642 bytes_per_frame = 64;
645 for (x = 0; x < 4; x++) {
682 samples_per_frame += 32;
683 bytes_per_frame += 64;
684 ms_per_frame += 2000;
689 samples_per_frame = 64;
690 bytes_per_frame = 128;
693 for (x = 0; x < 4; x++) {
730 samples_per_frame += 64;
731 bytes_per_frame += 128;
732 ms_per_frame += 2000;
736 samples_per_frame = 960;
737 bytes_per_frame = 1920;
738 ms_per_frame = 20000;
740 for (x = 0; x < 3; x++) {
777 samples_per_frame += 480;
778 bytes_per_frame += 960;
779 ms_per_frame += 10000;
782 samples_per_frame = 441;
783 bytes_per_frame = 882;
784 ms_per_frame = 10000;
786 for (x = 0; x < 3; x++) {
823 samples_per_frame += 441;
824 bytes_per_frame += 882;
825 ms_per_frame += 10000;
SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
static switch_status_t switch_raw_destroy(switch_codec_t *codec)
SWITCH_MODULE_DEFINITION(CORE_PCM_MODULE, core_pcm_load, core_pcm_shutdown, NULL)
static switch_status_t switch_g711a_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)
static switch_status_t switch_proxy_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)
static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
static switch_status_t switch_g711a_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)
static __inline__ uint8_t linear_to_alaw(int linear)
Encode a linear sample to A-law.
uint32_t decoded_bytes_per_packet
switch_memory_pool_t * pool
static void switch_core_codec_add_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface, const switch_codec_type_t codec_type, switch_payload_t ianacode, const char *iananame, char *fmtp, uint32_t samples_per_second, uint32_t actual_samples_per_second, int bits_per_second, int microseconds_per_packet, uint32_t samples_per_packet, uint32_t decoded_bytes_per_packet, uint32_t encoded_bytes_per_packet, uint8_t number_of_channels, int codec_frames_per_packet, switch_core_codec_init_func_t init, switch_core_codec_encode_func_t encode, switch_core_codec_decode_func_t decode, switch_core_codec_destroy_func_t destroy)
static switch_status_t switch_proxy_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
static switch_status_t switch_raw_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)
uint32_t switch_codec_flag_t
static switch_status_t switch_g711u_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)
const switch_codec_implementation_t * implementation
uint32_t actual_samples_per_second
SWITCH_MODULE_SHUTDOWN_FUNCTION(core_pcm_shutdown)
static switch_status_t switch_raw_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)
Top level module interface to implement a series of codec implementations.
static __inline__ int16_t alaw_to_linear(uint8_t alaw)
Decode an A-law sample to a linear value.
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
Decode an u-law sample to a linear value.
static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
static __inline__ uint8_t linear_to_ulaw(int linear)
Encode a linear sample to u-law.
static switch_status_t switch_proxy_destroy(switch_codec_t *codec)
#define SWITCH_ADD_CODEC(codec_int, int_name)
static switch_status_t switch_g711a_destroy(switch_codec_t *codec)
static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
switch_status_t
Common return values.
switch_loadable_module_interface_t * switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name)
static void mod_g711_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
struct apr_pool_t switch_memory_pool_t
static switch_status_t switch_proxy_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)
static switch_status_t switch_g711u_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)
The abstraction of a loadable module.