Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
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
 
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
 
static int unload_module (void)
 standard module glue
 

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 = ASTERISK_GPL_KEY , .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::@239 data
union ast_trans_pvt::@308 outbuf
unsigned char * uc
Definition translate.h:222
int datalen
actual space used in outbuf
Definition translate.h:218

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 = ASTERISK_GPL_KEY , .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.

79 {
80 .name = "alawtoulaw",
81 .src_codec = {
82 .name = "alaw",
84 .sample_rate = 8000,
85 },
86 .dst_codec = {
87 .name = "ulaw",
89 .sample_rate = 8000,
90 },
91 .format = "ulaw",
92 .framein = alawtoulaw_framein,
93 .sample = alaw_sample,
94 .buffer_samples = BUFFER_SAMPLES,
95 .buf_size = BUFFER_SAMPLES,
96};
@ AST_MEDIA_TYPE_AUDIO
Definition codec.h:32
#define BUFFER_SAMPLES
Definition codec_a_mu.c:38
static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
convert frame data and store into the buffer
Definition codec_a_mu.c:48
static struct ast_frame * alaw_sample(void)
Definition ex_alaw.h:26

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.

98 {
99 .name = "ulawtoalaw",
100 .src_codec = {
101 .name = "ulaw",
102 .type = AST_MEDIA_TYPE_AUDIO,
103 .sample_rate = 8000,
104 },
105 .dst_codec = {
106 .name = "alaw",
107 .type = AST_MEDIA_TYPE_AUDIO,
108 .sample_rate = 8000,
109 },
110 .format = "alaw",
111 .framein = ulawtoalaw_framein,
112 .sample = ulaw_sample,
113 .buffer_samples = BUFFER_SAMPLES,
114 .buf_size = BUFFER_SAMPLES,
115};
static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
convert frame data and store into the buffer
Definition codec_a_mu.c:64
static struct ast_frame * ulaw_sample(void)
Definition ex_ulaw.h:26

Referenced by load_module(), and unload_module().