Asterisk - The Open Source Telephony Project GIT-master-a358458
Macros | Functions | Variables
codec_ulaw.c File Reference

codec_ulaw.c - translate between signed linear and ulaw More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/translate.h"
#include "asterisk/ulaw.h"
#include "asterisk/utils.h"
#include "asterisk/slin.h"
#include "ex_ulaw.h"
Include dependency graph for codec_ulaw.c:

Go to the source code of this file.

Macros

#define BUFFER_SAMPLES   8096 /* size for the translation buffers */
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int lintoulaw_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 convert and store samples in outbuf More...
 
static int load_module (void)
 
static int ulawtolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 convert and store samples in outbuf More...
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "mu-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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_translator lintoulaw
 The complete translator for LinToulaw. More...
 
static struct ast_translator ulawtolin
 The complete translator for ulawToLin. More...
 

Detailed Description

codec_ulaw.c - translate between signed linear and ulaw

Definition in file codec_ulaw.c.

Macro Definition Documentation

◆ BUFFER_SAMPLES

#define BUFFER_SAMPLES   8096 /* size for the translation buffers */

Definition at line 38 of file codec_ulaw.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 152 of file codec_ulaw.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 152 of file codec_ulaw.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 152 of file codec_ulaw.c.

◆ lintoulaw_framein()

static int lintoulaw_framein ( struct ast_trans_pvt pvt,
struct ast_frame f 
)
static

convert and store samples in outbuf

Definition at line 62 of file codec_ulaw.c.

63{
64 int i = f->samples;
65 char *dst = pvt->outbuf.c + pvt->samples;
66 int16_t *src = f->data.ptr;
67
68 pvt->samples += i;
69 pvt->datalen += i; /* 1 byte/sample */
70
71 while (i--)
72 *dst++ = AST_LIN2MU(*src++);
73
74 return 0;
75}
short int16_t
Definition: db.h:59
union ast_frame::@226 data
int datalen
actual space used in outbuf
Definition: translate.h:218
union ast_trans_pvt::@287 outbuf
#define AST_LIN2MU(a)
Definition: ulaw.h:49

References AST_LIN2MU, ast_trans_pvt::c, ast_frame::data, ast_trans_pvt::datalen, ast_trans_pvt::outbuf, ast_frame::ptr, ast_frame::samples, and ast_trans_pvt::samples.

◆ load_module()

static int load_module ( void  )
static

Definition at line 133 of file codec_ulaw.c.

134{
135 int res;
136
139
140 if (res) {
143 }
144
146}
static struct ast_translator lintoulaw
The complete translator for LinToulaw.
Definition: codec_ulaw.c:104
static struct ast_translator ulawtolin
The complete translator for ulawToLin.
Definition: codec_ulaw.c:81
static int unload_module(void)
Definition: codec_ulaw.c:123
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_register_translator(t)
See __ast_register_translator()
Definition: translate.h:258

References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, lintoulaw, ulawtolin, and unload_module().

◆ ulawtolin_framein()

static int ulawtolin_framein ( struct ast_trans_pvt pvt,
struct ast_frame f 
)
static

convert and store samples in outbuf

Definition at line 45 of file codec_ulaw.c.

46{
47 int i = f->samples;
48 unsigned char *src = f->data.ptr;
49 int16_t *dst = pvt->outbuf.i16 + pvt->samples;
50
51 pvt->samples += i;
52 pvt->datalen += i * 2; /* 2 bytes/sample */
53
54 /* convert and copy in outbuf */
55 while (i--)
56 *dst++ = AST_MULAW(*src++);
57
58 return 0;
59}
int16_t * i16
Definition: translate.h:223
#define AST_MULAW(a)
Definition: ulaw.h:85

References AST_MULAW, ast_frame::data, ast_trans_pvt::datalen, ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_frame::ptr, ast_frame::samples, and ast_trans_pvt::samples.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 123 of file codec_ulaw.c.

124{
125 int res;
126
129
130 return res;
131}
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given translator.
Definition: translate.c:1350

References ast_unregister_translator(), lintoulaw, and ulawtolin.

Referenced by load_module().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "mu-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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
static

Definition at line 152 of file codec_ulaw.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 152 of file codec_ulaw.c.

◆ lintoulaw

struct ast_translator lintoulaw
static

The complete translator for LinToulaw.

Definition at line 104 of file codec_ulaw.c.

Referenced by load_module(), and unload_module().

◆ ulawtolin

struct ast_translator ulawtolin
static

The complete translator for ulawToLin.

Definition at line 81 of file codec_ulaw.c.

Referenced by load_module(), and unload_module().