Wed Jan 8 2020 09:49:46

Asterisk developer's documentation


codec_speex.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19 
20 /*! \file
21  *
22  * \brief Translate between signed linear and Speex (Open Codec)
23  *
24  * \note This work was motivated by Jeremy McNamara
25  * hacked to be configurable by anthm and bkw 9/28/2004
26  *
27  * \ingroup codecs
28  *
29  * \extref The Speex library - http://www.speex.org
30  *
31  */
32 
33 /*** MODULEINFO
34  <depend>speex</depend>
35  <depend>speex_preprocess</depend>
36  <use>speexdsp</use>
37  <support_level>core</support_level>
38  ***/
39 
40 #include "asterisk.h"
41 
42 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
43 
44 #include <speex/speex.h>
45 
46 /* We require a post 1.1.8 version of Speex to enable preprocessing
47  and better type handling */
48 #ifdef _SPEEX_TYPES_H
49 #include <speex/speex_preprocess.h>
50 #endif
51 
52 #include "asterisk/translate.h"
53 #include "asterisk/module.h"
54 #include "asterisk/config.h"
55 #include "asterisk/utils.h"
56 
57 /* codec variables */
58 static int quality = 3;
59 static int complexity = 2;
60 static int enhancement = 0;
61 static int vad = 0;
62 static int vbr = 0;
63 static float vbr_quality = 4;
64 static int abr = 0;
65 static int dtx = 0; /* set to 1 to enable silence detection */
66 
67 static int preproc = 0;
68 static int pp_vad = 0;
69 static int pp_agc = 0;
70 static float pp_agc_level = 8000; /* XXX what is this 8000 ? */
71 static int pp_denoise = 0;
72 static int pp_dereverb = 0;
73 static float pp_dereverb_decay = 0.4;
74 static float pp_dereverb_level = 0.3;
75 
76 #define TYPE_SILENCE 0x2
77 #define TYPE_HIGH 0x0
78 #define TYPE_LOW 0x1
79 #define TYPE_MASK 0x3
80 
81 #define BUFFER_SAMPLES 8000
82 #define SPEEX_SAMPLES 160
83 
84 /* Sample frame data */
85 #include "asterisk/slin.h"
86 #include "ex_speex.h"
87 
89  void *speex;
90  SpeexBits bits;
91  int framesize;
93 #ifdef _SPEEX_TYPES_H
94  SpeexPreprocessState *pp;
95  spx_int16_t buf[BUFFER_SAMPLES];
96 #else
97  int16_t buf[BUFFER_SAMPLES]; /* input, waiting to be compressed */
98 #endif
99 };
100 
101 static int speex_encoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile, int sampling_rate)
102 {
103  struct speex_coder_pvt *tmp = pvt->pvt;
104 
105  if (!(tmp->speex = speex_encoder_init(profile)))
106  return -1;
107 
108  speex_bits_init(&tmp->bits);
109  speex_bits_reset(&tmp->bits);
110  speex_encoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
111  speex_encoder_ctl(tmp->speex, SPEEX_SET_COMPLEXITY, &complexity);
112 #ifdef _SPEEX_TYPES_H
113  if (preproc) {
114  tmp->pp = speex_preprocess_state_init(tmp->framesize, sampling_rate);
115  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_VAD, &pp_vad);
116  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC, &pp_agc);
117  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &pp_agc_level);
118  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DENOISE, &pp_denoise);
119  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB, &pp_dereverb);
120  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &pp_dereverb_decay);
121  speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &pp_dereverb_level);
122  }
123 #endif
124  if (!abr && !vbr) {
125  speex_encoder_ctl(tmp->speex, SPEEX_SET_QUALITY, &quality);
126  if (vad)
127  speex_encoder_ctl(tmp->speex, SPEEX_SET_VAD, &vad);
128  }
129  if (vbr) {
130  speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR, &vbr);
131  speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR_QUALITY, &vbr_quality);
132  }
133  if (abr)
134  speex_encoder_ctl(tmp->speex, SPEEX_SET_ABR, &abr);
135  if (dtx)
136  speex_encoder_ctl(tmp->speex, SPEEX_SET_DTX, &dtx);
137  tmp->silent_state = 0;
138 
139  return 0;
140 }
141 
142 static int lintospeex_new(struct ast_trans_pvt *pvt)
143 {
144  return speex_encoder_construct(pvt, &speex_nb_mode, 8000);
145 }
146 
147 static int lin16tospeexwb_new(struct ast_trans_pvt *pvt)
148 {
149  return speex_encoder_construct(pvt, &speex_wb_mode, 16000);
150 }
151 
152 static int speex_decoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile)
153 {
154  struct speex_coder_pvt *tmp = pvt->pvt;
155 
156  if (!(tmp->speex = speex_decoder_init(profile)))
157  return -1;
158 
159  speex_bits_init(&tmp->bits);
160  speex_decoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
161  if (enhancement)
162  speex_decoder_ctl(tmp->speex, SPEEX_SET_ENH, &enhancement);
163 
164  return 0;
165 }
166 
167 static int speextolin_new(struct ast_trans_pvt *pvt)
168 {
169  return speex_decoder_construct(pvt, &speex_nb_mode);
170 }
171 
172 static int speexwbtolin16_new(struct ast_trans_pvt *pvt)
173 {
174  return speex_decoder_construct(pvt, &speex_wb_mode);
175 }
176 
177 /*! \brief convert and store into outbuf */
178 static int speextolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
179 {
180  struct speex_coder_pvt *tmp = pvt->pvt;
181 
182  /* Assuming there's space left, decode into the current buffer at
183  the tail location. Read in as many frames as there are */
184  int x;
185  int res;
186  int16_t *dst = pvt->outbuf.i16;
187  /* XXX fout is a temporary buffer, may have different types */
188 #ifdef _SPEEX_TYPES_H
189  spx_int16_t fout[1024];
190 #else
191  float fout[1024];
192 #endif
193 
194  if (f->datalen == 0) { /* Native PLC interpolation */
195  if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
196  ast_log(LOG_WARNING, "Out of buffer space\n");
197  return -1;
198  }
199 #ifdef _SPEEX_TYPES_H
200  speex_decode_int(tmp->speex, NULL, dst + pvt->samples);
201 #else
202  speex_decode(tmp->speex, NULL, fout);
203  for (x=0;x<tmp->framesize;x++) {
204  dst[pvt->samples + x] = (int16_t)fout[x];
205  }
206 #endif
207  pvt->samples += tmp->framesize;
208  pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
209  return 0;
210  }
211 
212  /* Read in bits */
213  speex_bits_read_from(&tmp->bits, f->data.ptr, f->datalen);
214  for (;;) {
215 #ifdef _SPEEX_TYPES_H
216  res = speex_decode_int(tmp->speex, &tmp->bits, fout);
217 #else
218  res = speex_decode(tmp->speex, &tmp->bits, fout);
219 #endif
220  if (res < 0)
221  break;
222  if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
223  ast_log(LOG_WARNING, "Out of buffer space\n");
224  return -1;
225  }
226  for (x = 0 ; x < tmp->framesize; x++)
227  dst[pvt->samples + x] = (int16_t)fout[x];
228  pvt->samples += tmp->framesize;
229  pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
230  }
231  return 0;
232 }
233 
234 /*! \brief store input frame in work buffer */
235 static int lintospeex_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
236 {
237  struct speex_coder_pvt *tmp = pvt->pvt;
238 
239  /* XXX We should look at how old the rest of our stream is, and if it
240  is too old, then we should overwrite it entirely, otherwise we can
241  get artifacts of earlier talk that do not belong */
242  memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen);
243  pvt->samples += f->samples;
244  return 0;
245 }
246 
247 /*! \brief convert work buffer and produce output frame */
248 static struct ast_frame *lintospeex_frameout(struct ast_trans_pvt *pvt)
249 {
250  struct speex_coder_pvt *tmp = pvt->pvt;
251  int is_speech=1;
252  int datalen = 0; /* output bytes */
253  int samples = 0; /* output samples */
254 
255  /* We can't work on anything less than a frame in size */
256  if (pvt->samples < tmp->framesize)
257  return NULL;
258  speex_bits_reset(&tmp->bits);
259  while (pvt->samples >= tmp->framesize) {
260 #ifdef _SPEEX_TYPES_H
261  /* Preprocess audio */
262  if (preproc)
263  is_speech = speex_preprocess(tmp->pp, tmp->buf + samples, NULL);
264  /* Encode a frame of data */
265  if (is_speech) {
266  /* If DTX enabled speex_encode returns 0 during silence */
267  is_speech = speex_encode_int(tmp->speex, tmp->buf + samples, &tmp->bits) || !dtx;
268  } else {
269  /* 5 zeros interpreted by Speex as silence (submode 0) */
270  speex_bits_pack(&tmp->bits, 0, 5);
271  }
272 #else
273  {
274  float fbuf[1024];
275  int x;
276  /* Convert to floating point */
277  for (x = 0; x < tmp->framesize; x++)
278  fbuf[x] = tmp->buf[samples + x];
279  /* Encode a frame of data */
280  is_speech = speex_encode(tmp->speex, fbuf, &tmp->bits) || !dtx;
281  }
282 #endif
283  samples += tmp->framesize;
284  pvt->samples -= tmp->framesize;
285  }
286 
287  /* Move the data at the end of the buffer to the front */
288  if (pvt->samples)
289  memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2);
290 
291  /* Use AST_FRAME_CNG to signify the start of any silence period */
292  if (is_speech) {
293  tmp->silent_state = 0;
294  } else {
295  if (tmp->silent_state) {
296  return NULL;
297  } else {
298  tmp->silent_state = 1;
299  speex_bits_reset(&tmp->bits);
300  memset(&pvt->f, 0, sizeof(pvt->f));
301  pvt->f.frametype = AST_FRAME_CNG;
302  pvt->f.samples = samples;
303  /* XXX what now ? format etc... */
304  }
305  }
306 
307  /* Terminate bit stream */
308  speex_bits_pack(&tmp->bits, 15, 5);
309  datalen = speex_bits_write(&tmp->bits, pvt->outbuf.c, pvt->t->buf_size);
310  return ast_trans_frameout(pvt, datalen, samples);
311 }
312 
313 static void speextolin_destroy(struct ast_trans_pvt *arg)
314 {
315  struct speex_coder_pvt *pvt = arg->pvt;
316 
317  speex_decoder_destroy(pvt->speex);
318  speex_bits_destroy(&pvt->bits);
319 }
320 
321 static void lintospeex_destroy(struct ast_trans_pvt *arg)
322 {
323  struct speex_coder_pvt *pvt = arg->pvt;
324 #ifdef _SPEEX_TYPES_H
325  if (preproc)
326  speex_preprocess_state_destroy(pvt->pp);
327 #endif
328  speex_encoder_destroy(pvt->speex);
329  speex_bits_destroy(&pvt->bits);
330 }
331 
332 static struct ast_translator speextolin = {
333  .name = "speextolin",
334  .srcfmt = AST_FORMAT_SPEEX,
335  .dstfmt = AST_FORMAT_SLINEAR,
336  .newpvt = speextolin_new,
337  .framein = speextolin_framein,
338  .destroy = speextolin_destroy,
339  .sample = speex_sample,
340  .desc_size = sizeof(struct speex_coder_pvt),
341  .buffer_samples = BUFFER_SAMPLES,
342  .buf_size = BUFFER_SAMPLES * 2,
343  .native_plc = 1,
344 };
345 
346 static struct ast_translator lintospeex = {
347  .name = "lintospeex",
348  .srcfmt = AST_FORMAT_SLINEAR,
349  .dstfmt = AST_FORMAT_SPEEX,
350  .newpvt = lintospeex_new,
351  .framein = lintospeex_framein,
352  .frameout = lintospeex_frameout,
353  .destroy = lintospeex_destroy,
354  .sample = slin8_sample,
355  .desc_size = sizeof(struct speex_coder_pvt),
356  .buffer_samples = BUFFER_SAMPLES,
357  .buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */
358 };
359 
361  .name = "speexwbtolin16",
362  .srcfmt = AST_FORMAT_SPEEX16,
363  .dstfmt = AST_FORMAT_SLINEAR16,
364  .newpvt = speexwbtolin16_new,
365  .framein = speextolin_framein,
366  .destroy = speextolin_destroy,
367  .sample = speex16_sample,
368  .desc_size = sizeof(struct speex_coder_pvt),
369  .buffer_samples = BUFFER_SAMPLES,
370  .buf_size = BUFFER_SAMPLES * 2,
371  .native_plc = 1,
372 };
373 
375  .name = "lin16tospeexwb",
376  .srcfmt = AST_FORMAT_SLINEAR16,
377  .dstfmt = AST_FORMAT_SPEEX16,
378  .newpvt = lin16tospeexwb_new,
379  .framein = lintospeex_framein,
380  .frameout = lintospeex_frameout,
381  .destroy = lintospeex_destroy,
382  .sample = slin16_sample,
383  .desc_size = sizeof(struct speex_coder_pvt),
384  .buffer_samples = BUFFER_SAMPLES,
385  .buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */
386 };
387 
388 static int parse_config(int reload)
389 {
390  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
391  struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
392  struct ast_variable *var;
393  int res;
394  float res_f;
395 
397  return 0;
398 
399  for (var = ast_variable_browse(cfg, "speex"); var; var = var->next) {
400  if (!strcasecmp(var->name, "quality")) {
401  res = abs(atoi(var->value));
402  if (res > -1 && res < 11) {
403  ast_verb(3, "CODEC SPEEX: Setting Quality to %d\n",res);
404  quality = res;
405  } else
406  ast_log(LOG_ERROR,"Error Quality must be 0-10\n");
407  } else if (!strcasecmp(var->name, "complexity")) {
408  res = abs(atoi(var->value));
409  if (res > -1 && res < 11) {
410  ast_verb(3, "CODEC SPEEX: Setting Complexity to %d\n",res);
411  complexity = res;
412  } else
413  ast_log(LOG_ERROR,"Error! Complexity must be 0-10\n");
414  } else if (!strcasecmp(var->name, "vbr_quality")) {
415  if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0 && res_f <= 10) {
416  ast_verb(3, "CODEC SPEEX: Setting VBR Quality to %f\n",res_f);
417  vbr_quality = res_f;
418  } else
419  ast_log(LOG_ERROR,"Error! VBR Quality must be 0-10\n");
420  } else if (!strcasecmp(var->name, "abr_quality")) {
421  ast_log(LOG_ERROR,"Error! ABR Quality setting obsolete, set ABR to desired bitrate\n");
422  } else if (!strcasecmp(var->name, "enhancement")) {
423  enhancement = ast_true(var->value) ? 1 : 0;
424  ast_verb(3, "CODEC SPEEX: Perceptual Enhancement Mode. [%s]\n",enhancement ? "on" : "off");
425  } else if (!strcasecmp(var->name, "vbr")) {
426  vbr = ast_true(var->value) ? 1 : 0;
427  ast_verb(3, "CODEC SPEEX: VBR Mode. [%s]\n",vbr ? "on" : "off");
428  } else if (!strcasecmp(var->name, "abr")) {
429  res = abs(atoi(var->value));
430  if (res >= 0) {
431  if (res > 0)
432  ast_verb(3, "CODEC SPEEX: Setting ABR target bitrate to %d\n",res);
433  else
434  ast_verb(3, "CODEC SPEEX: Disabling ABR\n");
435  abr = res;
436  } else
437  ast_log(LOG_ERROR,"Error! ABR target bitrate must be >= 0\n");
438  } else if (!strcasecmp(var->name, "vad")) {
439  vad = ast_true(var->value) ? 1 : 0;
440  ast_verb(3, "CODEC SPEEX: VAD Mode. [%s]\n",vad ? "on" : "off");
441  } else if (!strcasecmp(var->name, "dtx")) {
442  dtx = ast_true(var->value) ? 1 : 0;
443  ast_verb(3, "CODEC SPEEX: DTX Mode. [%s]\n",dtx ? "on" : "off");
444  } else if (!strcasecmp(var->name, "preprocess")) {
445  preproc = ast_true(var->value) ? 1 : 0;
446  ast_verb(3, "CODEC SPEEX: Preprocessing. [%s]\n",preproc ? "on" : "off");
447  } else if (!strcasecmp(var->name, "pp_vad")) {
448  pp_vad = ast_true(var->value) ? 1 : 0;
449  ast_verb(3, "CODEC SPEEX: Preprocessor VAD. [%s]\n",pp_vad ? "on" : "off");
450  } else if (!strcasecmp(var->name, "pp_agc")) {
451  pp_agc = ast_true(var->value) ? 1 : 0;
452  ast_verb(3, "CODEC SPEEX: Preprocessor AGC. [%s]\n",pp_agc ? "on" : "off");
453  } else if (!strcasecmp(var->name, "pp_agc_level")) {
454  if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
455  ast_verb(3, "CODEC SPEEX: Setting preprocessor AGC Level to %f\n",res_f);
456  pp_agc_level = res_f;
457  } else
458  ast_log(LOG_ERROR,"Error! Preprocessor AGC Level must be >= 0\n");
459  } else if (!strcasecmp(var->name, "pp_denoise")) {
460  pp_denoise = ast_true(var->value) ? 1 : 0;
461  ast_verb(3, "CODEC SPEEX: Preprocessor Denoise. [%s]\n",pp_denoise ? "on" : "off");
462  } else if (!strcasecmp(var->name, "pp_dereverb")) {
463  pp_dereverb = ast_true(var->value) ? 1 : 0;
464  ast_verb(3, "CODEC SPEEX: Preprocessor Dereverb. [%s]\n",pp_dereverb ? "on" : "off");
465  } else if (!strcasecmp(var->name, "pp_dereverb_decay")) {
466  if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
467  ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Decay to %f\n",res_f);
468  pp_dereverb_decay = res_f;
469  } else
470  ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Decay must be >= 0\n");
471  } else if (!strcasecmp(var->name, "pp_dereverb_level")) {
472  if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
473  ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Level to %f\n",res_f);
474  pp_dereverb_level = res_f;
475  } else
476  ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Level must be >= 0\n");
477  }
478  }
479  ast_config_destroy(cfg);
480  return 0;
481 }
482 
483 static int reload(void)
484 {
485  if (parse_config(1))
488 }
489 
490 static int unload_module(void)
491 {
492  int res = 0;
493 
494  res |= ast_unregister_translator(&speextolin);
495  res |= ast_unregister_translator(&lintospeex);
496  res |= ast_unregister_translator(&speexwbtolin16);
497  res |= ast_unregister_translator(&lin16tospeexwb);
498 
499  return res;
500 }
501 
502 static int load_module(void)
503 {
504  int res = 0;
505 
506  if (parse_config(0))
508 
509  res |= ast_register_translator(&speextolin);
510  res |= ast_register_translator(&lintospeex);
511  res |= ast_register_translator(&speexwbtolin16);
512  res |= ast_register_translator(&lin16tospeexwb);
513 
514  return res;
515 }
516 
518  .load = load_module,
519  .unload = unload_module,
520  .reload = reload,
521  );
static int speexwbtolin16_new(struct ast_trans_pvt *pvt)
Definition: codec_speex.c:172
struct ast_frame * ast_trans_frameout(struct ast_trans_pvt *pvt, int datalen, int samples)
generic frameout function
Definition: translate.c:235
int datalen
actual space used in outbuf
Definition: translate.h:140
static float pp_dereverb_decay
Definition: codec_speex.c:73
static void lintospeex_destroy(struct ast_trans_pvt *arg)
Definition: codec_speex.c:321
Asterisk main include file. File version handling, generic pbx functions.
union ast_trans_pvt::@213 outbuf
static int quality
Definition: codec_speex.c:58
Descriptor of a translator.
Definition: translate.h:71
static int preproc
Definition: codec_speex.c:67
SpeexBits bits
Definition: codec_speex.c:90
static struct ast_translator lin16tospeexwb
Definition: codec_speex.c:374
Support for translation of data formats. translate.c.
void * ptr
Definition: frame.h:160
struct ast_frame f
Definition: translate.h:137
#define LOG_WARNING
Definition: logger.h:144
static int speex_decoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile)
Definition: codec_speex.c:152
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
static int lin16tospeexwb_new(struct ast_trans_pvt *pvt)
Definition: codec_speex.c:147
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
#define var
Definition: ast_expr2f.c:606
static struct ast_frame * lintospeex_frameout(struct ast_trans_pvt *pvt)
convert work buffer and produce output frame
Definition: codec_speex.c:248
Configuration File Parser.
const char name[80]
Definition: translate.h:72
static int lintospeex_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
store input frame in work buffer
Definition: codec_speex.c:235
int16_t buf[BUFFER_SAMPLES]
Definition: codec_speex.c:97
static int load_module(void)
Definition: codec_speex.c:502
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:374
static void speextolin_destroy(struct ast_trans_pvt *arg)
Definition: codec_speex.c:313
static struct ast_frame * slin8_sample(void)
Definition: slin.h:61
void * pvt
Definition: translate.h:141
static int parse_config(int reload)
Definition: codec_speex.c:388
#define ast_verb(level,...)
Definition: logger.h:243
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
static int reload(void)
Definition: codec_speex.c:483
static int complexity
Definition: codec_speex.c:59
int16_t * i16
Definition: translate.h:145
static struct ast_frame * slin16_sample(void)
Definition: slin.h:77
Utility functions.
#define CONFIG_STATUS_FILEMISSING
Definition: config.h:50
const char * value
Definition: config.h:79
static float pp_dereverb_level
Definition: codec_speex.c:74
static int speextolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
convert and store into outbuf
Definition: codec_speex.c:178
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
#define AST_FORMAT_SPEEX
Definition: frame.h:260
int datalen
Definition: frame.h:148
#define ast_register_translator(t)
See __ast_register_translator()
Definition: translate.h:170
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given tranlator.
Definition: translate.c:942
const char * name
Definition: config.h:77
static int vbr
Definition: codec_speex.c:62
static int pp_vad
Definition: codec_speex.c:68
static int speextolin_new(struct ast_trans_pvt *pvt)
Definition: codec_speex.c:167
int buf_size
size of outbuf, in bytes. Mandatory. The wrapper code will also allocate an AST_FRIENDLY_OFFSET space...
Definition: translate.h:105
#define AST_FORMAT_SLINEAR16
Definition: frame.h:272
static struct ast_frame * speex_sample(void)
Definition: ex_speex.h:17
static int pp_dereverb
Definition: codec_speex.c:72
static int unload_module(void)
Definition: codec_speex.c:490
static struct ast_translator lintospeex
Definition: codec_speex.c:346
#define LOG_ERROR
Definition: logger.h:155
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is &quot;true&quot;. This function checks to see whether a string passed to it is an indication of an &quot;true&quot; value. It checks to see if the string is &quot;yes&quot;, &quot;true&quot;, &quot;y&quot;, &quot;t&quot;, &quot;on&quot; or &quot;1&quot;.
Definition: utils.c:1533
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:135
static struct ast_translator speexwbtolin16
Definition: codec_speex.c:360
static int speex_encoder_construct(struct ast_trans_pvt *pvt, const SpeexMode *profile, int sampling_rate)
Definition: codec_speex.c:101
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static struct ast_format f[]
Definition: format_g726.c:181
Random Data.
static int vad
Definition: codec_speex.c:61
static struct ast_frame * speex16_sample(void)
Definition: ex_speex.h:48
static int dtx
Definition: codec_speex.c:65
static int pp_denoise
Definition: codec_speex.c:71
static int lintospeex_new(struct ast_trans_pvt *pvt)
Definition: codec_speex.c:142
Structure used to handle boolean flags.
Definition: utils.h:200
#define AST_FORMAT_SLINEAR
Definition: frame.h:254
#define BUFFER_SAMPLES
Definition: codec_speex.c:81
static int enhancement
Definition: codec_speex.c:60
Data structure associated with a single frame of data.
Definition: frame.h:142
static float vbr_quality
Definition: codec_speex.c:63
struct ast_translator * t
Definition: translate.h:136
enum ast_frame_type frametype
Definition: frame.h:144
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
static float pp_agc_level
Definition: codec_speex.c:70
static struct ast_translator speextolin
Definition: codec_speex.c:332
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
union ast_frame::@172 data
static int abr
Definition: codec_speex.c:64
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180
int samples
Definition: frame.h:150
#define CONFIG_STATUS_FILEUNCHANGED
Definition: config.h:51
static int pp_agc
Definition: codec_speex.c:69
#define AST_FORMAT_SPEEX16
Definition: frame.h:301