33 #include "speex/speex_resampler.h"
37 #include "asterisk/slin.h"
39 #define OUTBUF_SAMPLES 11520
42 static int trans_size;
46 .type = AST_MEDIA_TYPE_AUDIO,
51 .type = AST_MEDIA_TYPE_AUDIO,
56 .type = AST_MEDIA_TYPE_AUDIO,
61 .type = AST_MEDIA_TYPE_AUDIO,
66 .type = AST_MEDIA_TYPE_AUDIO,
71 .type = AST_MEDIA_TYPE_AUDIO,
76 .type = AST_MEDIA_TYPE_AUDIO,
81 .type = AST_MEDIA_TYPE_AUDIO,
86 .type = AST_MEDIA_TYPE_AUDIO,
87 .sample_rate = 192000,
109 speex_resampler_destroy(resamp_pvt);
115 unsigned int out_samples = OUTBUF_SAMPLES - pvt->
samples;
116 unsigned int in_samples;
123 speex_resampler_process_int(resamp_pvt,
127 pvt->outbuf.i16 + pvt->
samples,
131 pvt->
datalen += out_samples * 2;
136 static int unload_module(
void)
141 for (idx = 0; idx < trans_size; idx++) {
144 ast_free(translators);
149 static int load_module(
void)
154 trans_size = ARRAY_LEN(codec_list) * (ARRAY_LEN(codec_list) - 1);
159 for (x = 0; x < ARRAY_LEN(codec_list); x++) {
160 for (y = 0; y < ARRAY_LEN(codec_list); y++) {
164 translators[idx].
newpvt = resamp_new;
165 translators[idx].
destroy = resamp_destroy;
166 translators[idx].
framein = resamp_framein;
169 translators[idx].
buf_size = (OUTBUF_SAMPLES *
sizeof(int16_t));
170 memcpy(&translators[idx].src_codec, &codec_list[x],
sizeof(
struct ast_codec));
171 memcpy(&translators[idx].dst_codec, &codec_list[y],
sizeof(
struct ast_codec));
172 snprintf(translators[idx].
name,
sizeof(translators[idx].name),
"slin %ukhz -> %ukhz",
int datalen
actual space used in outbuf
const char * name
Name for this codec.
Asterisk main include file. File version handling, generic pbx functions.
int(* newpvt)(struct ast_trans_pvt *)
Descriptor of a translator.
Support for translation of data formats. translate.c.
struct ast_frame_subclass subclass
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ast_register_translator(t)
See __ast_register_translator()
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given translator.
int buf_size
size of outbuf, in bytes. Mandatory. The wrapper code will also allocate an AST_FRIENDLY_OFFSET space...
void(* destroy)(struct ast_trans_pvt *pvt)
struct ast_codec dst_codec
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
struct ast_codec src_codec
union ast_frame::@224 data
#define ast_calloc(num, len)
A wrapper for calloc()
Module has failed to load, may be in an inconsistent state.
unsigned int sample_rate
Sample rate (number of samples carried in a second)
Data structure associated with a single frame of data.
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Represents a media codec within Asterisk.
int(* framein)(struct ast_trans_pvt *pvt, struct ast_frame *in)
int buffer_samples
size of outbuf, in samples. Leave it 0 if you want the framein callback deal with the frame...