#include "asterisk.h"
#include "asterisk/linkedlists.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "g722/g722.h"
#include "slin_g722_ex.h"
#include "g722_slin_ex.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 | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
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 struct ast_frame * | g722tolin_sample (void) |
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 struct ast_frame * | lintog722_sample (void) |
static int | load_module (void) |
static int | parse_config (int reload) |
static int | reload (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "ITU G.722-64kbps G722 Transcoder" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, .reload = reload, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_translator | g722tolin |
static struct ast_translator | lintog722 |
Russell Bryant <russell@digium.com>
Definition in file codec_g722.c.
#define BUF_SHIFT 5 |
Definition at line 48 of file codec_g722.c.
#define BUFFER_SAMPLES 8096 |
Definition at line 47 of file codec_g722.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 227 of file codec_g722.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 227 of file codec_g722.c.
static int g722tolin_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 84 of file codec_g722.c.
References ast_trans_pvt::datalen, f, g722_decoder_pvt::g722, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, and ast_trans_pvt::samples.
00085 { 00086 struct g722_decoder_pvt *tmp = pvt->pvt; 00087 int out_samples; 00088 int in_samples; 00089 00090 /* g722_decode expects the samples to be in the invalid samples / 2 format */ 00091 in_samples = f->samples / 2; 00092 00093 out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], (uint8_t *) f->data, in_samples); 00094 00095 pvt->samples += out_samples; 00096 00097 pvt->datalen += (out_samples * sizeof(int16_t)); 00098 00099 return 0; 00100 }
static int g722tolin_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 75 of file codec_g722.c.
References g722_decoder_pvt::g722, and ast_trans_pvt::pvt.
00076 { 00077 struct g722_decoder_pvt *tmp = pvt->pvt; 00078 00079 g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 00080 00081 return 0; 00082 }
static struct ast_frame* g722tolin_sample | ( | void | ) | [static] |
Definition at line 117 of file codec_g722.c.
References AST_FORMAT_G722, AST_FRAME_VOICE, f, g722_slin_ex, and ast_frame::samples.
00118 { 00119 static struct ast_frame f = { 00120 .frametype = AST_FRAME_VOICE, 00121 .subclass = AST_FORMAT_G722, 00122 .datalen = sizeof(g722_slin_ex), 00123 .samples = sizeof(g722_slin_ex) * 2, 00124 .src = __PRETTY_FUNCTION__, 00125 .data = g722_slin_ex, 00126 }; 00127 00128 return &f; 00129 }
static int lintog722_framein | ( | struct ast_trans_pvt * | pvt, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 102 of file codec_g722.c.
References ast_trans_pvt::datalen, f, g722_encoder_pvt::g722, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, and ast_trans_pvt::samples.
00103 { 00104 struct g722_encoder_pvt *tmp = pvt->pvt; 00105 int outlen; 00106 00107 outlen = g722_encode(&tmp->g722, (uint8_t *) (&pvt->outbuf[pvt->datalen]), (int16_t *) f->data, f->samples); 00108 00109 00110 pvt->samples += outlen * 2; 00111 00112 pvt->datalen += outlen; 00113 00114 return 0; 00115 }
static int lintog722_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 65 of file codec_g722.c.
References g722_encoder_pvt::g722, and ast_trans_pvt::pvt.
00066 { 00067 struct g722_encoder_pvt *tmp = pvt->pvt; 00068 00069 g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 00070 00071 return 0; 00072 }
static struct ast_frame* lintog722_sample | ( | void | ) | [static] |
Definition at line 131 of file codec_g722.c.
References ARRAY_LEN, AST_FORMAT_SLINEAR, AST_FRAME_VOICE, f, ast_frame::samples, and slin_g722_ex.
00132 { 00133 static struct ast_frame f = { 00134 .frametype = AST_FRAME_VOICE, 00135 .subclass = AST_FORMAT_SLINEAR, 00136 .datalen = sizeof(slin_g722_ex), 00137 .samples = ARRAY_LEN(slin_g722_ex), 00138 .src = __PRETTY_FUNCTION__, 00139 .data = slin_g722_ex, 00140 }; 00141 00142 return &f; 00143 }
static int load_module | ( | void | ) | [static] |
Definition at line 205 of file codec_g722.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, g722tolin, lintog722, parse_config(), and unload_module().
00206 { 00207 int res = 0; 00208 00209 if (parse_config(0)) 00210 return AST_MODULE_LOAD_DECLINE; 00211 00212 res |= ast_register_translator(&g722tolin); 00213 res |= ast_register_translator(&lintog722); 00214 00215 if (res) { 00216 unload_module(); 00217 return AST_MODULE_LOAD_FAILURE; 00218 } 00219 00220 return AST_MODULE_LOAD_SUCCESS; 00221 }
static int parse_config | ( | int | reload | ) | [static] |
Definition at line 170 of file codec_g722.c.
References ast_config_load(), ast_true(), ast_variable_browse(), ast_verbose(), g722tolin, option_verbose, ast_translator::useplc, var, and VERBOSE_PREFIX_3.
Referenced by load_module(), and reload().
00171 { 00172 struct ast_variable *var; 00173 struct ast_config *cfg = ast_config_load("codecs.conf"); 00174 00175 if (!cfg) 00176 return 0; 00177 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 00178 if (!strcasecmp(var->name, "genericplc")) { 00179 g722tolin.useplc = ast_true(var->value) ? 1 : 0; 00180 if (option_verbose > 2) 00181 ast_verbose(VERBOSE_PREFIX_3 "codec_g722: %susing generic PLC\n", g722tolin.useplc ? "" : "not "); 00182 } 00183 } 00184 ast_config_destroy(cfg); 00185 return 0; 00186 }
static int reload | ( | void | ) | [static] |
Definition at line 188 of file codec_g722.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and parse_config().
00189 { 00190 if (parse_config(1)) 00191 return AST_MODULE_LOAD_DECLINE; 00192 return AST_MODULE_LOAD_SUCCESS; 00193 }
static int unload_module | ( | void | ) | [static] |
Definition at line 195 of file codec_g722.c.
References ast_unregister_translator(), g722tolin, and lintog722.
00196 { 00197 int res = 0; 00198 00199 res |= ast_unregister_translator(&g722tolin); 00200 res |= ast_unregister_translator(&lintog722); 00201 00202 return res; 00203 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "ITU G.722-64kbps G722 Transcoder" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 227 of file codec_g722.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 227 of file codec_g722.c.
struct ast_translator g722tolin [static] |
Definition at line 145 of file codec_g722.c.
Referenced by load_module(), parse_config(), and unload_module().
struct ast_translator lintog722 [static] |