codec_g722.c - translate between signed linear and ITU G.722-64kbps More...
#include "asterisk.h"
#include "asterisk/linkedlists.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "g722/g722.h"
#include "asterisk/slin.h"
#include "ex_g722.h"
Go to the source code of this file.
Data Structures | |
struct | g722_decoder_pvt |
struct | g722_encoder_pvt |
Defines | |
#define | BUF_SHIFT 5 |
#define | BUFFER_SAMPLES 8096 |
Functions | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,"ITU G.722-64kbps G722 Transcoder",.load=load_module,.unload=unload_module,.reload=reload,) | |
static int | g722tolin16_new (struct ast_trans_pvt *pvt) |
static int | g722tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
static int | g722tolin_new (struct ast_trans_pvt *pvt) |
init a new instance of g722_encoder_pvt. | |
static int | lin16tog722_new (struct ast_trans_pvt *pvt) |
static int | lintog722_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) |
static int | lintog722_new (struct ast_trans_pvt *pvt) |
init a new instance of g722_encoder_pvt. | |
static int | load_module (void) |
static int | reload (void) |
static int | unload_module (void) |
Variables | |
static struct ast_translator | g722tolin |
static struct ast_translator | g722tolin16 |
static struct ast_translator | lin16tog722 |
static struct ast_translator | lintog722 |
codec_g722.c - translate between signed linear and ITU G.722-64kbps
Definition in file codec_g722.c.
#define BUF_SHIFT 5 |
Definition at line 51 of file codec_g722.c.
#define BUFFER_SAMPLES 8096 |
Definition at line 50 of file codec_g722.c.
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_DEFAULT | , | |||
"ITU G.722-64kbps G722 Transcoder" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | reload = reload | |||
) |
static int g722tolin16_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
Definition at line 96 of file codec_g722.c.
References g722_decoder_pvt::g722, and ast_trans_pvt::pvt.
00097 { 00098 struct g722_decoder_pvt *tmp = pvt->pvt; 00099 00100 g722_decode_init(&tmp->g722, 64000, 0); 00101 00102 return 0; 00103 }
static int g722tolin_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 105 of file codec_g722.c.
References ast_frame::data, ast_trans_pvt::datalen, g722_decoder_pvt::g722, ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_trans_pvt::samples, and ast_frame::samples.
00106 { 00107 struct g722_decoder_pvt *tmp = pvt->pvt; 00108 int out_samples; 00109 int in_samples; 00110 00111 /* g722_decode expects the samples to be in the invalid samples / 2 format */ 00112 in_samples = f->samples / 2; 00113 00114 out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples * sizeof(int16_t)], 00115 (uint8_t *) f->data.ptr, in_samples); 00116 00117 pvt->samples += out_samples; 00118 00119 pvt->datalen += (out_samples * sizeof(int16_t)); 00120 00121 return 0; 00122 }
static int g722tolin_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 87 of file codec_g722.c.
References g722_decoder_pvt::g722, and ast_trans_pvt::pvt.
00088 { 00089 struct g722_decoder_pvt *tmp = pvt->pvt; 00090 00091 g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 00092 00093 return 0; 00094 }
static int lin16tog722_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
Definition at line 77 of file codec_g722.c.
References g722_encoder_pvt::g722, and ast_trans_pvt::pvt.
00078 { 00079 struct g722_encoder_pvt *tmp = pvt->pvt; 00080 00081 g722_encode_init(&tmp->g722, 64000, 0); 00082 00083 return 0; 00084 }
static int lintog722_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 124 of file codec_g722.c.
References ast_frame::data, ast_trans_pvt::datalen, g722_encoder_pvt::g722, ast_trans_pvt::outbuf, ast_frame::ptr, ast_trans_pvt::pvt, ast_trans_pvt::samples, ast_frame::samples, and ast_trans_pvt::ui8.
00125 { 00126 struct g722_encoder_pvt *tmp = pvt->pvt; 00127 int outlen; 00128 00129 outlen = g722_encode(&tmp->g722, (&pvt->outbuf.ui8[pvt->datalen]), 00130 (int16_t *) f->data.ptr, f->samples); 00131 00132 pvt->samples += outlen * 2; 00133 00134 pvt->datalen += outlen; 00135 00136 return 0; 00137 }
static int lintog722_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 68 of file codec_g722.c.
References g722_encoder_pvt::g722, and ast_trans_pvt::pvt.
00069 { 00070 struct g722_encoder_pvt *tmp = pvt->pvt; 00071 00072 g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 00073 00074 return 0; 00075 }
static int load_module | ( | void | ) | [static] |
Definition at line 204 of file codec_g722.c.
References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, and unload_module.
00205 { 00206 int res = 0; 00207 00208 res |= ast_register_translator(&g722tolin); 00209 res |= ast_register_translator(&lintog722); 00210 res |= ast_register_translator(&g722tolin16); 00211 res |= ast_register_translator(&lin16tog722); 00212 00213 if (res) { 00214 unload_module(); 00215 return AST_MODULE_LOAD_FAILURE; 00216 } 00217 00218 return AST_MODULE_LOAD_SUCCESS; 00219 }
static int reload | ( | void | ) | [static] |
Definition at line 187 of file codec_g722.c.
References AST_MODULE_LOAD_SUCCESS.
00188 { 00189 return AST_MODULE_LOAD_SUCCESS; 00190 }
static int unload_module | ( | void | ) | [static] |
Definition at line 192 of file codec_g722.c.
References ast_unregister_translator().
00193 { 00194 int res = 0; 00195 00196 res |= ast_unregister_translator(&g722tolin); 00197 res |= ast_unregister_translator(&lintog722); 00198 res |= ast_unregister_translator(&g722tolin16); 00199 res |= ast_unregister_translator(&lin16tog722); 00200 00201 return res; 00202 }
struct ast_translator g722tolin [static] |
Definition at line 139 of file codec_g722.c.
struct ast_translator g722tolin16 [static] |
Definition at line 163 of file codec_g722.c.
struct ast_translator lin16tog722 [static] |
Definition at line 175 of file codec_g722.c.
struct ast_translator lintog722 [static] |
Definition at line 151 of file codec_g722.c.