#include "asterisk.h"
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <spandsp/bit_operations.h>
#include <spandsp/g711.h>
#include "asterisk/lock.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/translate.h"
#include "asterisk/channel.h"
#include "asterisk/alaw.h"
#include "asterisk/utils.h"
#include "slin_ulaw_ex.h"
#include "ulaw_slin_ex.h"
Include dependency graph for codec_alaw.c:
Go to the source code of this file.
Defines | |
#define | BUFFER_SAMPLES 8096 |
Functions | |
static int | alawtolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
decode frame into lin and fill output buffer. | |
static struct ast_frame * | alawtolin_sample (void) |
alawToLin_Sample | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,"A-law Coder/Decoder",.load=load_module,.unload=unload_module,.reload=reload,) | |
static int | lintoalaw_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
convert and store input samples in output buffer | |
static struct ast_frame * | lintoalaw_sample (void) |
LinToalaw_Sample. | |
static int | load_module (void) |
static void | parse_config (void) |
static int | reload (void) |
standard module stuff | |
static int | unload_module (void) |
Variables | |
static struct ast_translator | alawtolin |
static struct ast_translator | lintoalaw |
Definition in file codec_alaw.c.
#define BUFFER_SAMPLES 8096 |
Definition at line 54 of file codec_alaw.c.
static int alawtolin_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
decode frame into lin and fill output buffer.
Definition at line 62 of file codec_alaw.c.
References ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00063 { 00064 int i = f->samples; 00065 unsigned char *src = f->data; 00066 int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; 00067 00068 pvt->samples += i; 00069 pvt->datalen += i * 2; /* 2 bytes/sample */ 00070 00071 while (i--) 00072 *dst++ = alaw_to_linear(*src++); 00073 00074 return 0; 00075 }
static struct ast_frame* alawtolin_sample | ( | void | ) | [static] |
alawToLin_Sample
Definition at line 94 of file codec_alaw.c.
References AST_FORMAT_ALAW, AST_FRAME_VOICE, f, and ulaw_slin_ex.
00095 { 00096 static struct ast_frame f; 00097 f.frametype = AST_FRAME_VOICE; 00098 f.subclass = AST_FORMAT_ALAW; 00099 f.datalen = sizeof(ulaw_slin_ex); 00100 f.samples = sizeof(ulaw_slin_ex); 00101 f.mallocd = 0; 00102 f.offset = 0; 00103 f.src = __PRETTY_FUNCTION__; 00104 f.data = ulaw_slin_ex; 00105 return &f; 00106 }
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_DEFAULT | , | |||
"A-law Coder/Decoder" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | reload = reload | |||
) |
static int lintoalaw_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
convert and store input samples in output buffer
Definition at line 78 of file codec_alaw.c.
References ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00079 { 00080 int i = f->samples; 00081 char *dst = pvt->outbuf + pvt->samples; 00082 int16_t *src = f->data; 00083 00084 pvt->samples += i; 00085 pvt->datalen += i; /* 1 byte/sample */ 00086 00087 while (i--) 00088 *dst++ = linear_to_alaw(*src++); 00089 00090 return 0; 00091 }
static struct ast_frame* lintoalaw_sample | ( | void | ) | [static] |
LinToalaw_Sample.
Definition at line 109 of file codec_alaw.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, f, and slin_ulaw_ex.
00110 { 00111 static struct ast_frame f; 00112 f.frametype = AST_FRAME_VOICE; 00113 f.subclass = AST_FORMAT_SLINEAR; 00114 f.datalen = sizeof(slin_ulaw_ex); 00115 f.samples = sizeof(slin_ulaw_ex) / 2; 00116 f.mallocd = 0; 00117 f.offset = 0; 00118 f.src = __PRETTY_FUNCTION__; 00119 f.data = slin_ulaw_ex; 00120 return &f; 00121 }
static int load_module | ( | void | ) | [static] |
Definition at line 178 of file codec_alaw.c.
References alawtolin, ast_register_translator, ast_unregister_translator(), lintoalaw, and parse_config().
00179 { 00180 int res; 00181 00182 parse_config(); 00183 res = ast_register_translator(&alawtolin); 00184 if (!res) 00185 res = ast_register_translator(&lintoalaw); 00186 else 00187 ast_unregister_translator(&alawtolin); 00188 00189 return res; 00190 }
static void parse_config | ( | void | ) | [static] |
Definition at line 144 of file codec_alaw.c.
References alawtolin, ast_config_load(), ast_true(), ast_variable_browse(), ast_verbose(), option_verbose, ast_translator::useplc, var, and VERBOSE_PREFIX_3.
00145 { 00146 struct ast_variable *var; 00147 struct ast_config *cfg = ast_config_load("codecs.conf"); 00148 if (!cfg) 00149 return; 00150 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 00151 if (!strcasecmp(var->name, "genericplc")) { 00152 alawtolin.useplc = ast_true(var->value) ? 1 : 0; 00153 if (option_verbose > 2) 00154 ast_verbose(VERBOSE_PREFIX_3 "codec_alaw: %susing generic PLC\n", alawtolin.useplc ? "" : "not "); 00155 } 00156 } 00157 ast_config_destroy(cfg); 00158 }
static int reload | ( | void | ) | [static] |
standard module stuff
Definition at line 162 of file codec_alaw.c.
References parse_config().
00163 { 00164 parse_config(); 00165 return 0; 00166 }
static int unload_module | ( | void | ) | [static] |
Definition at line 168 of file codec_alaw.c.
References alawtolin, ast_unregister_translator(), and lintoalaw.
00169 { 00170 int res; 00171 00172 res = ast_unregister_translator(&lintoalaw); 00173 res |= ast_unregister_translator(&alawtolin); 00174 00175 return res; 00176 }
struct ast_translator alawtolin [static] |
Definition at line 123 of file codec_alaw.c.
Referenced by load_module(), parse_config(), and unload_module().
struct ast_translator lintoalaw [static] |