#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/ulaw.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 | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,"mu-Law Coder/Decoder",.load=load_module,.unload=unload_module,.reload=reload,) | |
static int | lintoulaw_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
convert and store samples in outbuf | |
static struct ast_frame * | lintoulaw_sample (void) |
LinToulaw_Sample. | |
static int | load_module (void) |
static void | parse_config (void) |
static int | reload (void) |
static int | ulawtolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
convert and store samples in outbuf | |
static struct ast_frame * | ulawtolin_sample (void) |
ulawToLin_Sample | |
static int | unload_module (void) |
Variables | |
static struct ast_translator | lintoulaw |
The complete translator for LinToulaw. | |
static struct ast_translator | ulawtolin |
The complete translator for ulawToLin. |
Definition in file codec_ulaw.c.
#define BUFFER_SAMPLES 8096 |
Definition at line 47 of file codec_ulaw.c.
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_DEFAULT | , | |||
"mu-Law Coder/Decoder" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | reload = reload | |||
) |
static int lintoulaw_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
convert and store samples in outbuf
Definition at line 72 of file codec_ulaw.c.
References AST_LIN2MU, ast_frame::data, ast_trans_pvt::datalen, ast_trans_pvt::outbuf, ast_trans_pvt::samples, and ast_frame::samples.
00073 { 00074 int i = f->samples; 00075 char *dst = pvt->outbuf + pvt->samples; 00076 int16_t *src = f->data; 00077 00078 pvt->samples += i; 00079 pvt->datalen += i; /* 1 byte/sample */ 00080 00081 while (i--) 00082 *dst++ = AST_LIN2MU(*src++); 00083 00084 return 0; 00085 }
static struct ast_frame* lintoulaw_sample | ( | void | ) | [static, read] |
LinToulaw_Sample.
Definition at line 106 of file codec_ulaw.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_frame::mallocd, ast_frame::offset, ast_frame::samples, slin_ulaw_ex, ast_frame::src, and ast_frame::subclass.
00107 { 00108 static struct ast_frame f; 00109 f.frametype = AST_FRAME_VOICE; 00110 f.subclass = AST_FORMAT_SLINEAR; 00111 f.datalen = sizeof(slin_ulaw_ex); 00112 /* Assume 8000 Hz */ 00113 f.samples = sizeof(slin_ulaw_ex) / 2; 00114 f.mallocd = 0; 00115 f.offset = 0; 00116 f.src = __PRETTY_FUNCTION__; 00117 f.data = slin_ulaw_ex; 00118 return &f; 00119 }
static int load_module | ( | void | ) | [static] |
Definition at line 183 of file codec_ulaw.c.
References ast_register_translator, ast_unregister_translator(), and parse_config().
00184 { 00185 int res; 00186 00187 parse_config(); 00188 res = ast_register_translator(&ulawtolin); 00189 if (!res) 00190 res = ast_register_translator(&lintoulaw); 00191 else 00192 ast_unregister_translator(&ulawtolin); 00193 00194 return res; 00195 }
static void parse_config | ( | void | ) | [static] |
Definition at line 150 of file codec_ulaw.c.
References ast_config_destroy(), ast_config_load(), ast_true(), ast_variable_browse(), ast_verbose(), ast_variable::name, ast_variable::next, option_verbose, ast_translator::useplc, ast_variable::value, var, and VERBOSE_PREFIX_3.
00151 { 00152 struct ast_variable *var; 00153 struct ast_config *cfg = ast_config_load("codecs.conf"); 00154 if (!cfg) 00155 return; 00156 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 00157 if (!strcasecmp(var->name, "genericplc")) { 00158 ulawtolin.useplc = ast_true(var->value) ? 1 : 0; 00159 if (option_verbose > 2) 00160 ast_verbose(VERBOSE_PREFIX_3 "codec_ulaw: %susing generic PLC\n", ulawtolin.useplc ? "" : "not "); 00161 } 00162 } 00163 ast_config_destroy(cfg); 00164 }
static int reload | ( | void | ) | [static] |
Definition at line 166 of file codec_ulaw.c.
References parse_config().
00167 { 00168 parse_config(); 00169 00170 return 0; 00171 }
static int ulawtolin_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
convert and store samples in outbuf
Definition at line 55 of file codec_ulaw.c.
References AST_MULAW, ast_frame::data, ast_trans_pvt::datalen, ast_trans_pvt::outbuf, ast_trans_pvt::samples, and ast_frame::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 /* convert and copy in outbuf */ 00065 while (i--) 00066 *dst++ = AST_MULAW(*src++); 00067 00068 return 0; 00069 }
static struct ast_frame* ulawtolin_sample | ( | void | ) | [static, read] |
ulawToLin_Sample
*
Definition at line 88 of file codec_ulaw.c.
References AST_FORMAT_ULAW, AST_FRAME_VOICE, ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_frame::mallocd, ast_frame::offset, ast_frame::samples, ast_frame::src, ast_frame::subclass, and ulaw_slin_ex.
00089 { 00090 static struct ast_frame f; 00091 f.frametype = AST_FRAME_VOICE; 00092 f.subclass = AST_FORMAT_ULAW; 00093 f.datalen = sizeof(ulaw_slin_ex); 00094 f.samples = sizeof(ulaw_slin_ex); 00095 f.mallocd = 0; 00096 f.offset = 0; 00097 f.src = __PRETTY_FUNCTION__; 00098 f.data = ulaw_slin_ex; 00099 return &f; 00100 }
static int unload_module | ( | void | ) | [static] |
Definition at line 173 of file codec_ulaw.c.
References ast_unregister_translator().
00174 { 00175 int res; 00176 00177 res = ast_unregister_translator(&lintoulaw); 00178 res |= ast_unregister_translator(&ulawtolin); 00179 00180 return res; 00181 }
struct ast_translator lintoulaw [static] |
struct ast_translator ulawtolin [static] |