codec_speex.c File Reference

Translate between signed linear and Speex (Open Codec). More...

#include "asterisk.h"
#include <speex/speex.h>
#include "asterisk/translate.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/utils.h"
#include "asterisk/slin.h"
#include "ex_speex.h"

Include dependency graph for codec_speex.c:

Go to the source code of this file.

Data Structures

struct  speex_coder_pvt

Defines

#define BUFFER_SAMPLES   8000
#define SPEEX_SAMPLES   160
#define TYPE_HIGH   0x0
#define TYPE_LOW   0x1
#define TYPE_MASK   0x3
#define TYPE_SILENCE   0x2

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int lin16tospeexwb_new (struct ast_trans_pvt *pvt)
static int lin32tospeexuwb_new (struct ast_trans_pvt *pvt)
static void lintospeex_destroy (struct ast_trans_pvt *arg)
static int lintospeex_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 store input frame in work buffer
static struct ast_framelintospeex_frameout (struct ast_trans_pvt *pvt)
 convert work buffer and produce output frame
static int lintospeex_new (struct ast_trans_pvt *pvt)
static int load_module (void)
static int parse_config (int reload)
static int reload (void)
static int speex_decoder_construct (struct ast_trans_pvt *pvt, const SpeexMode *profile)
static int speex_encoder_construct (struct ast_trans_pvt *pvt, const SpeexMode *profile, int sampling_rate)
static void speextolin_destroy (struct ast_trans_pvt *arg)
static int speextolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 convert and store into outbuf
static int speextolin_new (struct ast_trans_pvt *pvt)
static int speexuwbtolin32_new (struct ast_trans_pvt *pvt)
static int speexwbtolin16_new (struct ast_trans_pvt *pvt)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Speex Coder/Decoder" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, }
static int abr = 0
static struct ast_module_infoast_module_info = &__mod_info
static int complexity = 2
static int dtx = 0
static int enhancement = 0
static struct ast_translator lin16tospeexwb
static struct ast_translator lin32tospeexuwb
static struct ast_translator lintospeex
static int pp_agc = 0
static float pp_agc_level = 8000
static int pp_denoise = 0
static int pp_dereverb = 0
static float pp_dereverb_decay = 0.4
static float pp_dereverb_level = 0.3
static int pp_vad = 0
static int preproc = 0
static int quality = 3
static struct ast_translator speextolin
static struct ast_translator speexuwbtolin32
static struct ast_translator speexwbtolin16
static int vad = 0
static int vbr = 0
static float vbr_quality = 4


Detailed Description

Translate between signed linear and Speex (Open Codec).

Note:
This work was motivated by Jeremy McNamara hacked to be configurable by anthm and bkw 9/28/2004
The Speex library - http://www.speex.org

Definition in file codec_speex.c.


Define Documentation

#define BUFFER_SAMPLES   8000

Definition at line 82 of file codec_speex.c.

#define SPEEX_SAMPLES   160

Definition at line 83 of file codec_speex.c.

Referenced by speex16_sample(), and speex_sample().

#define TYPE_HIGH   0x0

Definition at line 78 of file codec_speex.c.

Referenced by g723_len().

#define TYPE_LOW   0x1

Definition at line 79 of file codec_speex.c.

Referenced by g723_len().

#define TYPE_MASK   0x3

Definition at line 80 of file codec_speex.c.

Referenced by g723_len().

#define TYPE_SILENCE   0x2

Definition at line 77 of file codec_speex.c.

Referenced by g723_len().


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 632 of file codec_speex.c.

static void __unreg_module ( void   )  [static]

Definition at line 632 of file codec_speex.c.

static int lin16tospeexwb_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 148 of file codec_speex.c.

References speex_encoder_construct().

00149 {
00150    return speex_encoder_construct(pvt, &speex_wb_mode, 16000);
00151 }

static int lin32tospeexuwb_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 153 of file codec_speex.c.

References speex_encoder_construct().

00154 {
00155    return speex_encoder_construct(pvt, &speex_uwb_mode, 32000);
00156 }

static void lintospeex_destroy ( struct ast_trans_pvt arg  )  [static]

Definition at line 341 of file codec_speex.c.

References speex_coder_pvt::bits, ast_trans_pvt::pvt, and speex_coder_pvt::speex.

00342 {
00343    struct speex_coder_pvt *pvt = arg->pvt;
00344 #ifdef _SPEEX_TYPES_H
00345    if (preproc)
00346       speex_preprocess_state_destroy(pvt->pp);
00347 #endif
00348    speex_encoder_destroy(pvt->speex);
00349    speex_bits_destroy(&pvt->bits);
00350 }

static int lintospeex_framein ( struct ast_trans_pvt pvt,
struct ast_frame f 
) [static]

store input frame in work buffer

Definition at line 246 of file codec_speex.c.

References speex_coder_pvt::buf, ast_frame::data, ast_frame::datalen, ast_frame::ptr, ast_trans_pvt::pvt, ast_frame::samples, ast_trans_pvt::samples, and tmp().

00247 {
00248    struct speex_coder_pvt *tmp = pvt->pvt;
00249 
00250    /* XXX We should look at how old the rest of our stream is, and if it
00251       is too old, then we should overwrite it entirely, otherwise we can
00252       get artifacts of earlier talk that do not belong */
00253    memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen);
00254    pvt->samples += f->samples;
00255    return 0;
00256 }

static struct ast_frame* lintospeex_frameout ( struct ast_trans_pvt pvt  )  [static, read]

convert work buffer and produce output frame

Definition at line 259 of file codec_speex.c.

References AST_FRAME_CNG, ast_frisolate(), ast_trans_frameout(), speex_coder_pvt::bits, speex_coder_pvt::buf, ast_translator::buf_size, ast_trans_pvt::c, speex_coder_pvt::framesize, ast_frame::frametype, ast_translator::name, NULL, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, ast_trans_pvt::samples, speex_coder_pvt::silent_state, speex_coder_pvt::speex, ast_trans_pvt::t, and tmp().

00260 {
00261    struct speex_coder_pvt *tmp = pvt->pvt;
00262    int is_speech=1;
00263    int datalen = 0;  /* output bytes */
00264    int samples = 0;  /* output samples */
00265 
00266    /* We can't work on anything less than a frame in size */
00267    if (pvt->samples < tmp->framesize)
00268       return NULL;
00269    speex_bits_reset(&tmp->bits);
00270    while (pvt->samples >= tmp->framesize) {
00271 #ifdef _SPEEX_TYPES_H
00272       /* Preprocess audio */
00273       if (preproc)
00274          is_speech = speex_preprocess(tmp->pp, tmp->buf + samples, NULL);
00275       /* Encode a frame of data */
00276       if (is_speech) {
00277          /* If DTX enabled speex_encode returns 0 during silence */
00278          is_speech = speex_encode_int(tmp->speex, tmp->buf + samples, &tmp->bits) || !dtx;
00279       } else {
00280          /* 5 zeros interpreted by Speex as silence (submode 0) */
00281          speex_bits_pack(&tmp->bits, 0, 5);
00282       }
00283 #else
00284       {
00285          float fbuf[1024];
00286          int x;
00287          /* Convert to floating point */
00288          for (x = 0; x < tmp->framesize; x++)
00289             fbuf[x] = tmp->buf[samples + x];
00290          /* Encode a frame of data */
00291          is_speech = speex_encode(tmp->speex, fbuf, &tmp->bits) || !dtx;
00292       }
00293 #endif
00294       samples += tmp->framesize;
00295       pvt->samples -= tmp->framesize;
00296    }
00297 
00298    /* Move the data at the end of the buffer to the front */
00299    if (pvt->samples)
00300       memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2);
00301 
00302    /* Use AST_FRAME_CNG to signify the start of any silence period */
00303    if (is_speech) {
00304       tmp->silent_state = 0;
00305    } else {
00306       if (tmp->silent_state) {
00307          return NULL;
00308       } else {
00309          struct ast_frame frm = {
00310             .frametype = AST_FRAME_CNG,
00311             .src = pvt->t->name,
00312          };
00313 
00314          /*
00315           * XXX I don't think the AST_FRAME_CNG code has ever
00316           * really worked for speex.  There doesn't seem to be
00317           * any consumers of the frame type.  Everyone that
00318           * references the type seems to pass the frame on.
00319           */
00320          tmp->silent_state = 1;
00321 
00322          /* XXX what now ? format etc... */
00323          return ast_frisolate(&frm);
00324       }
00325    }
00326 
00327    /* Terminate bit stream */
00328    speex_bits_pack(&tmp->bits, 15, 5);
00329    datalen = speex_bits_write(&tmp->bits, pvt->outbuf.c, pvt->t->buf_size);
00330    return ast_trans_frameout(pvt, datalen, samples);
00331 }

static int lintospeex_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 143 of file codec_speex.c.

References speex_encoder_construct().

00144 {
00145    return speex_encoder_construct(pvt, &speex_nb_mode, 8000);
00146 }

static int load_module ( void   )  [static]

Definition at line 605 of file codec_speex.c.

References AST_MODULE_LOAD_DECLINE, ast_register_translator, parse_config(), and unload_module.

00606 {
00607    int res = 0;
00608 
00609    if (parse_config(0))
00610       return AST_MODULE_LOAD_DECLINE;
00611 
00612    res |= ast_register_translator(&speextolin);
00613    res |= ast_register_translator(&lintospeex);
00614    res |= ast_register_translator(&speexwbtolin16);
00615    res |= ast_register_translator(&lin16tospeexwb);
00616    res |= ast_register_translator(&speexuwbtolin32);
00617    res |= ast_register_translator(&lin32tospeexuwb);
00618 
00619    if (res) {
00620       unload_module();
00621       return res;
00622    }
00623 
00624    return res;
00625 }

static int parse_config ( int  reload  )  [static]

Definition at line 488 of file codec_speex.c.

References abs, ast_config_destroy(), ast_config_load, ast_log, ast_true(), ast_variable_browse(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, LOG_ERROR, ast_variable::name, ast_variable::next, ast_variable::value, and var.

00489 {
00490    struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
00491    struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
00492    struct ast_variable *var;
00493    int res;
00494    float res_f;
00495 
00496    if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
00497       return 0;
00498 
00499    for (var = ast_variable_browse(cfg, "speex"); var; var = var->next) {
00500       if (!strcasecmp(var->name, "quality")) {
00501          res = abs(atoi(var->value));
00502          if (res > -1 && res < 11) {
00503             ast_verb(3, "CODEC SPEEX: Setting Quality to %d\n",res);
00504             quality = res;
00505          } else 
00506             ast_log(LOG_ERROR,"Error Quality must be 0-10\n");
00507       } else if (!strcasecmp(var->name, "complexity")) {
00508          res = abs(atoi(var->value));
00509          if (res > -1 && res < 11) {
00510             ast_verb(3, "CODEC SPEEX: Setting Complexity to %d\n",res);
00511             complexity = res;
00512          } else 
00513             ast_log(LOG_ERROR,"Error! Complexity must be 0-10\n");
00514       } else if (!strcasecmp(var->name, "vbr_quality")) {
00515          if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0 && res_f <= 10) {
00516             ast_verb(3, "CODEC SPEEX: Setting VBR Quality to %f\n",res_f);
00517             vbr_quality = res_f;
00518          } else
00519             ast_log(LOG_ERROR,"Error! VBR Quality must be 0-10\n");
00520       } else if (!strcasecmp(var->name, "abr_quality")) {
00521          ast_log(LOG_ERROR,"Error! ABR Quality setting obsolete, set ABR to desired bitrate\n");
00522       } else if (!strcasecmp(var->name, "enhancement")) {
00523          enhancement = ast_true(var->value) ? 1 : 0;
00524          ast_verb(3, "CODEC SPEEX: Perceptual Enhancement Mode. [%s]\n",enhancement ? "on" : "off");
00525       } else if (!strcasecmp(var->name, "vbr")) {
00526          vbr = ast_true(var->value) ? 1 : 0;
00527          ast_verb(3, "CODEC SPEEX: VBR Mode. [%s]\n",vbr ? "on" : "off");
00528       } else if (!strcasecmp(var->name, "abr")) {
00529          res = abs(atoi(var->value));
00530          if (res >= 0) {
00531                if (res > 0)
00532                ast_verb(3, "CODEC SPEEX: Setting ABR target bitrate to %d\n",res);
00533                else
00534                ast_verb(3, "CODEC SPEEX: Disabling ABR\n");
00535             abr = res;
00536          } else 
00537             ast_log(LOG_ERROR,"Error! ABR target bitrate must be >= 0\n");
00538       } else if (!strcasecmp(var->name, "vad")) {
00539          vad = ast_true(var->value) ? 1 : 0;
00540          ast_verb(3, "CODEC SPEEX: VAD Mode. [%s]\n",vad ? "on" : "off");
00541       } else if (!strcasecmp(var->name, "dtx")) {
00542          dtx = ast_true(var->value) ? 1 : 0;
00543          ast_verb(3, "CODEC SPEEX: DTX Mode. [%s]\n",dtx ? "on" : "off");
00544       } else if (!strcasecmp(var->name, "preprocess")) {
00545          preproc = ast_true(var->value) ? 1 : 0;
00546          ast_verb(3, "CODEC SPEEX: Preprocessing. [%s]\n",preproc ? "on" : "off");
00547       } else if (!strcasecmp(var->name, "pp_vad")) {
00548          pp_vad = ast_true(var->value) ? 1 : 0;
00549          ast_verb(3, "CODEC SPEEX: Preprocessor VAD. [%s]\n",pp_vad ? "on" : "off");
00550       } else if (!strcasecmp(var->name, "pp_agc")) {
00551          pp_agc = ast_true(var->value) ? 1 : 0;
00552          ast_verb(3, "CODEC SPEEX: Preprocessor AGC. [%s]\n",pp_agc ? "on" : "off");
00553       } else if (!strcasecmp(var->name, "pp_agc_level")) {
00554          if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
00555             ast_verb(3, "CODEC SPEEX: Setting preprocessor AGC Level to %f\n",res_f);
00556             pp_agc_level = res_f;
00557          } else
00558             ast_log(LOG_ERROR,"Error! Preprocessor AGC Level must be >= 0\n");
00559       } else if (!strcasecmp(var->name, "pp_denoise")) {
00560          pp_denoise = ast_true(var->value) ? 1 : 0;
00561          ast_verb(3, "CODEC SPEEX: Preprocessor Denoise. [%s]\n",pp_denoise ? "on" : "off");
00562       } else if (!strcasecmp(var->name, "pp_dereverb")) {
00563          pp_dereverb = ast_true(var->value) ? 1 : 0;
00564          ast_verb(3, "CODEC SPEEX: Preprocessor Dereverb. [%s]\n",pp_dereverb ? "on" : "off");
00565       } else if (!strcasecmp(var->name, "pp_dereverb_decay")) {
00566          if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
00567             ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Decay to %f\n",res_f);
00568             pp_dereverb_decay = res_f;
00569          } else
00570             ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Decay must be >= 0\n");
00571       } else if (!strcasecmp(var->name, "pp_dereverb_level")) {
00572          if (sscanf(var->value, "%30f", &res_f) == 1 && res_f >= 0) {
00573             ast_verb(3, "CODEC SPEEX: Setting preprocessor Dereverb Level to %f\n",res_f);
00574             pp_dereverb_level = res_f;
00575          } else
00576             ast_log(LOG_ERROR,"Error! Preprocessor Dereverb Level must be >= 0\n");
00577       }
00578    }
00579    ast_config_destroy(cfg);
00580    return 0;
00581 }

static int reload ( void   )  [static]

Definition at line 583 of file codec_speex.c.

References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and parse_config().

00584 {
00585    if (parse_config(1))
00586       return AST_MODULE_LOAD_DECLINE;
00587    return AST_MODULE_LOAD_SUCCESS;
00588 }

static int speex_decoder_construct ( struct ast_trans_pvt pvt,
const SpeexMode *  profile 
) [static]

Definition at line 158 of file codec_speex.c.

References speex_coder_pvt::bits, speex_coder_pvt::framesize, ast_trans_pvt::pvt, speex_coder_pvt::speex, and tmp().

Referenced by speextolin_new(), speexuwbtolin32_new(), and speexwbtolin16_new().

00159 {
00160    struct speex_coder_pvt *tmp = pvt->pvt;
00161    
00162    if (!(tmp->speex = speex_decoder_init(profile)))
00163       return -1;
00164 
00165    speex_bits_init(&tmp->bits);
00166    speex_decoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
00167    if (enhancement)
00168       speex_decoder_ctl(tmp->speex, SPEEX_SET_ENH, &enhancement);
00169 
00170    return 0;
00171 }

static int speex_encoder_construct ( struct ast_trans_pvt pvt,
const SpeexMode *  profile,
int  sampling_rate 
) [static]

Definition at line 102 of file codec_speex.c.

References speex_coder_pvt::bits, speex_coder_pvt::framesize, ast_trans_pvt::pvt, speex_coder_pvt::silent_state, speex_coder_pvt::speex, and tmp().

Referenced by lin16tospeexwb_new(), lin32tospeexuwb_new(), and lintospeex_new().

00103 {
00104    struct speex_coder_pvt *tmp = pvt->pvt;
00105 
00106    if (!(tmp->speex = speex_encoder_init(profile)))
00107       return -1;
00108 
00109    speex_bits_init(&tmp->bits);
00110    speex_bits_reset(&tmp->bits);
00111    speex_encoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
00112    speex_encoder_ctl(tmp->speex, SPEEX_SET_COMPLEXITY, &complexity);
00113 #ifdef _SPEEX_TYPES_H
00114    if (preproc) {
00115       tmp->pp = speex_preprocess_state_init(tmp->framesize, sampling_rate);
00116       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_VAD, &pp_vad);
00117       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC, &pp_agc);
00118       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &pp_agc_level);
00119       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DENOISE, &pp_denoise);
00120       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB, &pp_dereverb);
00121       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &pp_dereverb_decay);
00122       speex_preprocess_ctl(tmp->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &pp_dereverb_level);
00123    }
00124 #endif
00125    if (!abr && !vbr) {
00126       speex_encoder_ctl(tmp->speex, SPEEX_SET_QUALITY, &quality);
00127       if (vad)
00128          speex_encoder_ctl(tmp->speex, SPEEX_SET_VAD, &vad);
00129    }
00130    if (vbr) {
00131       speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR, &vbr);
00132       speex_encoder_ctl(tmp->speex, SPEEX_SET_VBR_QUALITY, &vbr_quality);
00133    }
00134    if (abr)
00135       speex_encoder_ctl(tmp->speex, SPEEX_SET_ABR, &abr);
00136    if (dtx)
00137       speex_encoder_ctl(tmp->speex, SPEEX_SET_DTX, &dtx); 
00138    tmp->silent_state = 0;
00139 
00140    return 0;
00141 }

static void speextolin_destroy ( struct ast_trans_pvt arg  )  [static]

Definition at line 333 of file codec_speex.c.

References speex_coder_pvt::bits, ast_trans_pvt::pvt, and speex_coder_pvt::speex.

00334 {
00335    struct speex_coder_pvt *pvt = arg->pvt;
00336 
00337    speex_decoder_destroy(pvt->speex);
00338    speex_bits_destroy(&pvt->bits);
00339 }

static int speextolin_framein ( struct ast_trans_pvt pvt,
struct ast_frame f 
) [static]

convert and store into outbuf

Definition at line 189 of file codec_speex.c.

References ast_log, speex_coder_pvt::bits, BUFFER_SAMPLES, ast_frame::data, ast_trans_pvt::datalen, ast_frame::datalen, speex_coder_pvt::framesize, ast_trans_pvt::i16, LOG_WARNING, NULL, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_trans_pvt::samples, speex_coder_pvt::speex, spx_int16_t, and tmp().

00190 {
00191    struct speex_coder_pvt *tmp = pvt->pvt;
00192 
00193    /* Assuming there's space left, decode into the current buffer at
00194       the tail location.  Read in as many frames as there are */
00195    int x;
00196    int res;
00197    int16_t *dst = pvt->outbuf.i16;
00198    /* XXX fout is a temporary buffer, may have different types */
00199 #ifdef _SPEEX_TYPES_H
00200    spx_int16_t fout[1024];
00201 #else
00202    float fout[1024];
00203 #endif
00204 
00205    if (f->datalen == 0) {  /* Native PLC interpolation */
00206       if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
00207          ast_log(LOG_WARNING, "Out of buffer space\n");
00208          return -1;
00209       }
00210 #ifdef _SPEEX_TYPES_H
00211       speex_decode_int(tmp->speex, NULL, dst + pvt->samples);
00212 #else
00213       speex_decode(tmp->speex, NULL, fout);
00214       for (x=0;x<tmp->framesize;x++) {
00215          dst[pvt->samples + x] = (int16_t)fout[x];
00216       }
00217 #endif
00218       pvt->samples += tmp->framesize;
00219       pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
00220       return 0;
00221    }
00222 
00223    /* Read in bits */
00224    speex_bits_read_from(&tmp->bits, f->data.ptr, f->datalen);
00225    for (;;) {
00226 #ifdef _SPEEX_TYPES_H
00227       res = speex_decode_int(tmp->speex, &tmp->bits, fout);
00228 #else
00229       res = speex_decode(tmp->speex, &tmp->bits, fout);
00230 #endif
00231       if (res < 0)
00232          break;
00233       if (pvt->samples + tmp->framesize > BUFFER_SAMPLES) {
00234          ast_log(LOG_WARNING, "Out of buffer space\n");
00235          return -1;
00236       }
00237       for (x = 0 ; x < tmp->framesize; x++)
00238          dst[pvt->samples + x] = (int16_t)fout[x];
00239       pvt->samples += tmp->framesize;
00240       pvt->datalen += 2 * tmp->framesize; /* 2 bytes/sample */
00241    }
00242    return 0;
00243 }

static int speextolin_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 173 of file codec_speex.c.

References speex_decoder_construct().

00174 {
00175    return speex_decoder_construct(pvt, &speex_nb_mode);
00176 }

static int speexuwbtolin32_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 183 of file codec_speex.c.

References speex_decoder_construct().

00184 {
00185    return speex_decoder_construct(pvt, &speex_uwb_mode);
00186 }

static int speexwbtolin16_new ( struct ast_trans_pvt pvt  )  [static]

Definition at line 178 of file codec_speex.c.

References speex_decoder_construct().

00179 {
00180    return speex_decoder_construct(pvt, &speex_wb_mode);
00181 }

static int unload_module ( void   )  [static]

Definition at line 590 of file codec_speex.c.

References ast_unregister_translator().

00591 {
00592    int res = 0;
00593 
00594    res |= ast_unregister_translator(&speextolin);
00595    res |= ast_unregister_translator(&lintospeex);
00596    res |= ast_unregister_translator(&speexwbtolin16);
00597    res |= ast_unregister_translator(&lin16tospeexwb);
00598    res |= ast_unregister_translator(&speexuwbtolin32);
00599    res |= ast_unregister_translator(&lin32tospeexuwb);
00600 
00601 
00602    return res;
00603 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Speex Coder/Decoder" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, } [static]

Definition at line 632 of file codec_speex.c.

int abr = 0 [static]

Definition at line 65 of file codec_speex.c.

Definition at line 632 of file codec_speex.c.

int complexity = 2 [static]

Definition at line 60 of file codec_speex.c.

int dtx = 0 [static]

Definition at line 66 of file codec_speex.c.

int enhancement = 0 [static]

Definition at line 61 of file codec_speex.c.

struct ast_translator lin16tospeexwb [static]

Definition at line 421 of file codec_speex.c.

Definition at line 466 of file codec_speex.c.

struct ast_translator lintospeex [static]

Definition at line 375 of file codec_speex.c.

int pp_agc = 0 [static]

Definition at line 70 of file codec_speex.c.

float pp_agc_level = 8000 [static]

Definition at line 71 of file codec_speex.c.

int pp_denoise = 0 [static]

Definition at line 72 of file codec_speex.c.

int pp_dereverb = 0 [static]

Definition at line 73 of file codec_speex.c.

float pp_dereverb_decay = 0.4 [static]

Definition at line 74 of file codec_speex.c.

float pp_dereverb_level = 0.3 [static]

Definition at line 75 of file codec_speex.c.

int pp_vad = 0 [static]

Definition at line 69 of file codec_speex.c.

int preproc = 0 [static]

Definition at line 68 of file codec_speex.c.

int quality = 3 [static]

Definition at line 59 of file codec_speex.c.

Referenced by ast_rtp_instance_set_stats_vars(), handle_request_bye(), and sip_hangup().

struct ast_translator speextolin [static]

Definition at line 352 of file codec_speex.c.

Definition at line 444 of file codec_speex.c.

struct ast_translator speexwbtolin16 [static]

Definition at line 398 of file codec_speex.c.

int vad = 0 [static]

Definition at line 62 of file codec_speex.c.

int vbr = 0 [static]

Definition at line 63 of file codec_speex.c.

float vbr_quality = 4 [static]

Definition at line 64 of file codec_speex.c.


Generated on Thu Apr 16 06:30:16 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6