#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/translate.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 void | __reg_module (void) |
static void | __unreg_module (void) |
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 | |
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 int | parse_config (int reload) |
static int | reload (void) |
standard module stuff | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "A-law 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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, .reload = reload, } |
static struct ast_translator | alawtolin |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_translator | lintoalaw |
Definition in file codec_alaw.c.
#define BUFFER_SAMPLES 8096 |
Definition at line 36 of file codec_alaw.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 184 of file codec_alaw.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 184 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 44 of file codec_alaw.c.
References AST_ALAW, ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00045 { 00046 int i = f->samples; 00047 unsigned char *src = f->data; 00048 int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; 00049 00050 pvt->samples += i; 00051 pvt->datalen += i * 2; /* 2 bytes/sample */ 00052 00053 while (i--) 00054 *dst++ = AST_ALAW(*src++); 00055 00056 return 0; 00057 }
static struct ast_frame* alawtolin_sample | ( | void | ) | [static] |
alawToLin_Sample
Definition at line 76 of file codec_alaw.c.
References AST_FORMAT_ALAW, AST_FRAME_VOICE, f, and ulaw_slin_ex.
00077 { 00078 static struct ast_frame f; 00079 f.frametype = AST_FRAME_VOICE; 00080 f.subclass = AST_FORMAT_ALAW; 00081 f.datalen = sizeof(ulaw_slin_ex); 00082 f.samples = sizeof(ulaw_slin_ex); 00083 f.mallocd = 0; 00084 f.offset = 0; 00085 f.src = __PRETTY_FUNCTION__; 00086 f.data = ulaw_slin_ex; 00087 return &f; 00088 }
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 60 of file codec_alaw.c.
References AST_LIN2A, ast_trans_pvt::datalen, f, ast_trans_pvt::outbuf, and ast_trans_pvt::samples.
00061 { 00062 int i = f->samples; 00063 char *dst = pvt->outbuf + pvt->samples; 00064 int16_t *src = f->data; 00065 00066 pvt->samples += i; 00067 pvt->datalen += i; /* 1 byte/sample */ 00068 00069 while (i--) 00070 *dst++ = AST_LIN2A(*src++); 00071 00072 return 0; 00073 }
static struct ast_frame* lintoalaw_sample | ( | void | ) | [static] |
LinToalaw_Sample.
Definition at line 91 of file codec_alaw.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, f, and slin_ulaw_ex.
00092 { 00093 static struct ast_frame f; 00094 f.frametype = AST_FRAME_VOICE; 00095 f.subclass = AST_FORMAT_SLINEAR; 00096 f.datalen = sizeof(slin_ulaw_ex); 00097 f.samples = sizeof(slin_ulaw_ex) / 2; 00098 f.mallocd = 0; 00099 f.offset = 0; 00100 f.src = __PRETTY_FUNCTION__; 00101 f.data = slin_ulaw_ex; 00102 return &f; 00103 }
static int load_module | ( | void | ) | [static] |
Definition at line 164 of file codec_alaw.c.
References alawtolin, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, ast_unregister_translator(), lintoalaw, and parse_config().
00165 { 00166 int res; 00167 00168 if (parse_config(0)) 00169 return AST_MODULE_LOAD_DECLINE; 00170 res = ast_register_translator(&alawtolin); 00171 if (!res) 00172 res = ast_register_translator(&lintoalaw); 00173 else 00174 ast_unregister_translator(&alawtolin); 00175 if (res) 00176 return AST_MODULE_LOAD_FAILURE; 00177 return AST_MODULE_LOAD_SUCCESS; 00178 }
static int parse_config | ( | int | reload | ) | [static] |
Definition at line 126 of file codec_alaw.c.
References alawtolin, ast_config_load, ast_true(), ast_variable_browse(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEUNCHANGED, ast_translator::useplc, and var.
00127 { 00128 struct ast_variable *var; 00129 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 00130 struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); 00131 if (cfg == NULL) 00132 return 0; 00133 if (cfg == CONFIG_STATUS_FILEUNCHANGED) 00134 return 0; 00135 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 00136 if (!strcasecmp(var->name, "genericplc")) { 00137 alawtolin.useplc = ast_true(var->value) ? 1 : 0; 00138 ast_verb(3, "codec_alaw: %susing generic PLC\n", alawtolin.useplc ? "" : "not "); 00139 } 00140 } 00141 ast_config_destroy(cfg); 00142 return 0; 00143 }
static int reload | ( | void | ) | [static] |
standard module stuff
Definition at line 147 of file codec_alaw.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and parse_config().
00148 { 00149 if (parse_config(1)) 00150 return AST_MODULE_LOAD_DECLINE; 00151 return AST_MODULE_LOAD_SUCCESS; 00152 }
static int unload_module | ( | void | ) | [static] |
Definition at line 154 of file codec_alaw.c.
References alawtolin, ast_unregister_translator(), and lintoalaw.
00155 { 00156 int res; 00157 00158 res = ast_unregister_translator(&lintoalaw); 00159 res |= ast_unregister_translator(&alawtolin); 00160 00161 return res; 00162 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "A-law 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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 184 of file codec_alaw.c.
struct ast_translator alawtolin [static] |
Definition at line 105 of file codec_alaw.c.
Referenced by load_module(), parse_config(), and unload_module().
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 184 of file codec_alaw.c.
struct ast_translator lintoalaw [static] |