#include "asterisk.h"
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.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"
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 47 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 55 of file codec_alaw.c.
References AST_ALAW, ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00056 { 00057 int i = f->samples; 00058 unsigned char *src = f->data; 00059 int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; 00060 00061 pvt->samples += i; 00062 pvt->datalen += i * 2; /* 2 bytes/sample */ 00063 00064 while (i--) 00065 *dst++ = AST_ALAW(*src++); 00066 00067 return 0; 00068 }
static struct ast_frame* alawtolin_sample | ( | void | ) | [static] |
alawToLin_Sample
Definition at line 87 of file codec_alaw.c.
References AST_FORMAT_ALAW, AST_FRAME_VOICE, f, and ulaw_slin_ex.
00088 { 00089 static struct ast_frame f; 00090 f.frametype = AST_FRAME_VOICE; 00091 f.subclass = AST_FORMAT_ALAW; 00092 f.datalen = sizeof(ulaw_slin_ex); 00093 f.samples = sizeof(ulaw_slin_ex); 00094 f.mallocd = 0; 00095 f.offset = 0; 00096 f.src = __PRETTY_FUNCTION__; 00097 f.data = ulaw_slin_ex; 00098 return &f; 00099 }
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 71 of file codec_alaw.c.
References AST_LIN2A, ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00072 { 00073 int i = f->samples; 00074 char *dst = pvt->outbuf + pvt->samples; 00075 int16_t *src = f->data; 00076 00077 pvt->samples += i; 00078 pvt->datalen += i; /* 1 byte/sample */ 00079 00080 while (i--) 00081 *dst++ = AST_LIN2A(*src++); 00082 00083 return 0; 00084 }
static struct ast_frame* lintoalaw_sample | ( | void | ) | [static] |
LinToalaw_Sample.
Definition at line 102 of file codec_alaw.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, f, and slin_ulaw_ex.
00103 { 00104 static struct ast_frame f; 00105 f.frametype = AST_FRAME_VOICE; 00106 f.subclass = AST_FORMAT_SLINEAR; 00107 f.datalen = sizeof(slin_ulaw_ex); 00108 f.samples = sizeof(slin_ulaw_ex) / 2; 00109 f.mallocd = 0; 00110 f.offset = 0; 00111 f.src = __PRETTY_FUNCTION__; 00112 f.data = slin_ulaw_ex; 00113 return &f; 00114 }
static int load_module | ( | void | ) | [static] |
Definition at line 171 of file codec_alaw.c.
References alawtolin, ast_register_translator, ast_unregister_translator(), lintoalaw, and parse_config().
00172 { 00173 int res; 00174 00175 parse_config(); 00176 res = ast_register_translator(&alawtolin); 00177 if (!res) 00178 res = ast_register_translator(&lintoalaw); 00179 else 00180 ast_unregister_translator(&alawtolin); 00181 00182 return res; 00183 }
static void parse_config | ( | void | ) | [static] |
Definition at line 137 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.
00138 { 00139 struct ast_variable *var; 00140 struct ast_config *cfg = ast_config_load("codecs.conf"); 00141 if (!cfg) 00142 return; 00143 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 00144 if (!strcasecmp(var->name, "genericplc")) { 00145 alawtolin.useplc = ast_true(var->value) ? 1 : 0; 00146 if (option_verbose > 2) 00147 ast_verbose(VERBOSE_PREFIX_3 "codec_alaw: %susing generic PLC\n", alawtolin.useplc ? "" : "not "); 00148 } 00149 } 00150 ast_config_destroy(cfg); 00151 }
static int reload | ( | void | ) | [static] |
standard module stuff
Definition at line 155 of file codec_alaw.c.
References parse_config().
00156 { 00157 parse_config(); 00158 return 0; 00159 }
static int unload_module | ( | void | ) | [static] |
Definition at line 161 of file codec_alaw.c.
References alawtolin, ast_unregister_translator(), and lintoalaw.
00162 { 00163 int res; 00164 00165 res = ast_unregister_translator(&lintoalaw); 00166 res |= ast_unregister_translator(&alawtolin); 00167 00168 return res; 00169 }
struct ast_translator alawtolin [static] |
Definition at line 116 of file codec_alaw.c.
Referenced by load_module(), parse_config(), and unload_module().
struct ast_translator lintoalaw [static] |