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 | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| 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 | 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 , .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 = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, .reload = reload, } |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| 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 47 of file codec_g722.c.
| #define BUFFER_SAMPLES 8096 |
Definition at line 46 of file codec_g722.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 247 of file codec_g722.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 247 of file codec_g722.c.
| static int g722tolin16_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
Definition at line 92 of file codec_g722.c.
References g722_decoder_pvt::g722, and ast_trans_pvt::pvt.
{
struct g722_decoder_pvt *tmp = pvt->pvt;
g722_decode_init(&tmp->g722, 64000, 0);
return 0;
}
| static int g722tolin_framein | ( | struct ast_trans_pvt * | pvt, | |
| struct ast_frame * | f | |||
| ) | [static] |
Definition at line 101 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.
{
struct g722_decoder_pvt *tmp = pvt->pvt;
int out_samples;
int in_samples;
/* g722_decode expects the samples to be in the invalid samples / 2 format */
in_samples = f->samples / 2;
out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples * sizeof(int16_t)],
(uint8_t *) f->data.ptr, in_samples);
pvt->samples += out_samples;
pvt->datalen += (out_samples * sizeof(int16_t));
return 0;
}
| static int g722tolin_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 83 of file codec_g722.c.
References g722_decoder_pvt::g722, and ast_trans_pvt::pvt.
{
struct g722_decoder_pvt *tmp = pvt->pvt;
g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000);
return 0;
}
| static int lin16tog722_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
Definition at line 73 of file codec_g722.c.
References g722_encoder_pvt::g722, and ast_trans_pvt::pvt.
{
struct g722_encoder_pvt *tmp = pvt->pvt;
g722_encode_init(&tmp->g722, 64000, 0);
return 0;
}
| static int lintog722_framein | ( | struct ast_trans_pvt * | pvt, | |
| struct ast_frame * | f | |||
| ) | [static] |
Definition at line 120 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.
| static int lintog722_new | ( | struct ast_trans_pvt * | pvt | ) | [static] |
init a new instance of g722_encoder_pvt.
Definition at line 64 of file codec_g722.c.
References g722_encoder_pvt::g722, and ast_trans_pvt::pvt.
{
struct g722_encoder_pvt *tmp = pvt->pvt;
g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000);
return 0;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 223 of file codec_g722.c.
References ast_register_translator, parse_config(), and unload_module().
{
int res = 0;
if (parse_config(0))
return AST_MODULE_LOAD_DECLINE;
res |= ast_register_translator(&g722tolin);
res |= ast_register_translator(&lintog722);
res |= ast_register_translator(&g722tolin16);
res |= ast_register_translator(&lin16tog722);
if (res) {
unload_module();
return AST_MODULE_LOAD_FAILURE;
}
return AST_MODULE_LOAD_SUCCESS;
}
| static int parse_config | ( | int | reload | ) | [static] |
Definition at line 185 of file codec_g722.c.
References ast_config_destroy(), ast_config_load, ast_true(), ast_variable_browse(), ast_verb, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_translator::useplc, and ast_variable::value.
Referenced by load_module(), and reload().
{
struct ast_variable *var;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
return 0;
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
g722tolin.useplc = ast_true(var->value) ? 1 : 0;
ast_verb(3, "codec_g722: %susing generic PLC\n",
g722tolin.useplc ? "" : "not ");
}
}
ast_config_destroy(cfg);
return 0;
}
| static int reload | ( | void | ) | [static] |
Definition at line 204 of file codec_g722.c.
References parse_config().
{
if (parse_config(1))
return AST_MODULE_LOAD_DECLINE;
return AST_MODULE_LOAD_SUCCESS;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 211 of file codec_g722.c.
References ast_unregister_translator().
Referenced by load_module().
{
int res = 0;
res |= ast_unregister_translator(&g722tolin);
res |= ast_unregister_translator(&lintog722);
res |= ast_unregister_translator(&g722tolin16);
res |= ast_unregister_translator(&lin16tog722);
return res;
}
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 247 of file codec_g722.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 247 of file codec_g722.c.
struct ast_translator g722tolin [static] |
Definition at line 135 of file codec_g722.c.
struct ast_translator g722tolin16 [static] |
Definition at line 160 of file codec_g722.c.
struct ast_translator lin16tog722 [static] |
Definition at line 173 of file codec_g722.c.
struct ast_translator lintog722 [static] |
Definition at line 148 of file codec_g722.c.
1.7.1