Asterisk - The Open Source Telephony Project GIT-master-0bf3178
Macros | Functions | Variables
codec_a_mu.c File Reference

codec_a_mu.c - translate between alaw and ulaw directly More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/alaw.h"
#include "asterisk/ulaw.h"
#include "asterisk/utils.h"
#include "ex_ulaw.h"
#include "ex_alaw.h"
Include dependency graph for codec_a_mu.c:

Go to the source code of this file.

Macros

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

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int alawtoulaw_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 convert frame data and store into the buffer More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int ulawtoalaw_framein (struct ast_trans_pvt *pvt, struct ast_frame *f)
 convert frame data and store into the buffer More...
 
static int unload_module (void)
 standard module glue More...
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "A-law and Mulaw direct 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, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static unsigned char a2mu [256]
 
static struct ast_translator alawtoulaw
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static unsigned char mu2a [256]
 
static struct ast_translator ulawtoalaw
 

Detailed Description

codec_a_mu.c - translate between alaw and ulaw directly

Definition in file codec_a_mu.c.

Macro Definition Documentation

◆ BUFFER_SAMPLES

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

Definition at line 38 of file codec_a_mu.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 150 of file codec_a_mu.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 150 of file codec_a_mu.c.

◆ alawtoulaw_framein()

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

convert frame data and store into the buffer

Definition at line 48 of file codec_a_mu.c.

49{
50 int x = f->samples;
51 unsigned char *src = f->data.ptr;
52 unsigned char *dst = pvt->outbuf.uc + pvt->samples;
53
54 pvt->samples += x;
55 pvt->datalen += x;
56
57 while (x--)
58 *dst++ = a2mu[*src++];
59
60 return 0;
61}
static unsigned char a2mu[256]
Definition: codec_a_mu.c:41
union ast_frame::@226 data
unsigned char * uc
Definition: translate.h:222
int datalen
actual space used in outbuf
Definition: translate.h:218
union ast_trans_pvt::@287 outbuf

References a2mu, ast_frame::data, ast_trans_pvt::datalen, ast_trans_pvt::outbuf, ast_frame::ptr, ast_frame::samples, ast_trans_pvt::samples, and ast_trans_pvt::uc.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 150 of file codec_a_mu.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 129 of file codec_a_mu.c.

130{
131 int res;
132 int x;
133
134 for (x=0;x<256;x++) {
135 mu2a[x] = AST_LIN2A(AST_MULAW(x));
136 a2mu[x] = AST_LIN2MU(AST_ALAW(x));
137 }
138
141
142 if (res) {
145 }
146
148}
#define AST_LIN2A(a)
Definition: alaw.h:50
#define AST_ALAW(a)
Definition: alaw.h:84
static struct ast_translator ulawtoalaw
Definition: codec_a_mu.c:98
static unsigned char mu2a[256]
Definition: codec_a_mu.c:40
static struct ast_translator alawtoulaw
Definition: codec_a_mu.c:79
static int unload_module(void)
standard module glue
Definition: codec_a_mu.c:119
@ 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
#define AST_MULAW(a)
Definition: ulaw.h:85
#define AST_LIN2MU(a)
Definition: ulaw.h:49

References a2mu, alawtoulaw, AST_ALAW, AST_LIN2A, AST_LIN2MU, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MULAW, ast_register_translator, mu2a, ulawtoalaw, and unload_module().

◆ ulawtoalaw_framein()

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

convert frame data and store into the buffer

Definition at line 64 of file codec_a_mu.c.

65{
66 int x = f->samples;
67 unsigned char *src = f->data.ptr;
68 unsigned char *dst = pvt->outbuf.uc + pvt->samples;
69
70 pvt->samples += x;
71 pvt->datalen += x;
72
73 while (x--)
74 *dst++ = mu2a[*src++];
75
76 return 0;
77}

References ast_frame::data, ast_trans_pvt::datalen, mu2a, ast_trans_pvt::outbuf, ast_frame::ptr, ast_frame::samples, ast_trans_pvt::samples, and ast_trans_pvt::uc.

◆ unload_module()

static int unload_module ( void  )
static

standard module glue

Definition at line 119 of file codec_a_mu.c.

120{
121 int res;
122
125
126 return res;
127}
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given translator.
Definition: translate.c:1350

References alawtoulaw, ast_unregister_translator(), and ulawtoalaw.

Referenced by load_module().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "A-law and Mulaw direct 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, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 150 of file codec_a_mu.c.

◆ a2mu

unsigned char a2mu[256]
static

Definition at line 41 of file codec_a_mu.c.

Referenced by alawtoulaw_framein(), and load_module().

◆ alawtoulaw

struct ast_translator alawtoulaw
static

Definition at line 79 of file codec_a_mu.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 150 of file codec_a_mu.c.

◆ mu2a

unsigned char mu2a[256]
static

Definition at line 40 of file codec_a_mu.c.

Referenced by load_module(), and ulawtoalaw_framein().

◆ ulawtoalaw

struct ast_translator ulawtoalaw
static

Definition at line 98 of file codec_a_mu.c.

Referenced by load_module(), and unload_module().