42 #ifdef HAVE_GSM_HEADER
44 #elif defined(HAVE_GSM_GSM_HEADER)
48 #include "../formats/msgsm.h"
50 #define BUFFER_SAMPLES 8000
51 #define GSM_SAMPLES 160
52 #define GSM_FRAME_LEN 33
53 #define MSGSM_FRAME_LEN 65
56 #include "asterisk/slin.h"
61 int16_t buf[BUFFER_SAMPLES];
68 return (tmp->gsm = gsm_create()) ? 0 : -1;
76 int16_t *dst = pvt->outbuf.i16;
78 int flen = (f->
datalen % MSGSM_FRAME_LEN == 0) ?
79 MSGSM_FRAME_LEN : GSM_FRAME_LEN;
81 for (x=0; x < f->
datalen; x += flen) {
82 unsigned char data[2 * GSM_FRAME_LEN];
85 if (flen == MSGSM_FRAME_LEN) {
92 conv65(f->
data.ptr + x, data);
95 src = f->
data.ptr + x;
98 if (pvt->
samples + len > BUFFER_SAMPLES) {
99 ast_log(LOG_WARNING,
"Out of buffer space\n");
102 if (gsm_decode(tmp->gsm, src, dst + pvt->
samples)) {
103 ast_log(LOG_WARNING,
"Invalid GSM data (1)\n");
107 pvt->
datalen += 2 * GSM_SAMPLES;
108 if (flen == MSGSM_FRAME_LEN) {
109 if (gsm_decode(tmp->gsm, data + GSM_FRAME_LEN, dst + pvt->
samples)) {
110 ast_log(LOG_WARNING,
"Invalid GSM data (2)\n");
114 pvt->
datalen += 2 * GSM_SAMPLES;
129 ast_log(LOG_WARNING,
"Out of buffer space\n");
145 while (pvt->
samples >= GSM_SAMPLES) {
149 gsm_encode(tmp->gsm, tmp->buf + samples, (gsm_byte *) pvt->outbuf.
c);
150 samples += GSM_SAMPLES;
166 memmove(tmp->buf, tmp->buf + samples, pvt->
samples * 2);
176 gsm_destroy(tmp->gsm);
183 .type = AST_MEDIA_TYPE_AUDIO,
188 .type = AST_MEDIA_TYPE_AUDIO,
194 .destroy = gsm_destroy_stuff,
195 .sample = gsm_sample,
196 .buffer_samples = BUFFER_SAMPLES,
197 .buf_size = BUFFER_SAMPLES * 2,
205 .type = AST_MEDIA_TYPE_AUDIO,
210 .type = AST_MEDIA_TYPE_AUDIO,
217 .destroy = gsm_destroy_stuff,
218 .sample = slin8_sample,
220 .buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
223 static int unload_module(
void)
233 static int load_module(
void)
249 .support_level = AST_MODULE_SUPPORT_CORE,
251 .unload = unload_module,
struct ast_frame * ast_trans_frameout(struct ast_trans_pvt *pvt, int datalen, int samples)
generic frameout function
int datalen
actual space used in outbuf
Asterisk main include file. File version handling, generic pbx functions.
Descriptor of a translator.
Support for translation of data formats. translate.c.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
static struct ast_frame * lintogsm_frameout(struct ast_trans_pvt *pvt)
encode and produce a frame
static int gsmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
decode and store in outbuf.
Configuration File Parser.
#define ast_register_translator(t)
See __ast_register_translator()
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given translator.
A set of macros to manage forward-linked lists.
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
union ast_frame::@224 data
Module has failed to load, may be in an inconsistent state.
Data structure associated with a single frame of data.
static int lintogsm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
store samples into working buffer for later decode
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.