Wed Apr 6 11:30:03 2011

Asterisk developer's documentation


codec_g722.c File Reference

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 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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .reload = reload, }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_translator g722tolin
static struct ast_translator g722tolin16
static struct ast_translator lin16tog722
static struct ast_translator lintog722


Detailed Description

codec_g722.c - translate between signed linear and ITU G.722-64kbps

Author:
Matthew Fredrickson <creslin@digium.com>

Russell Bryant <russell@digium.com>

Definition in file codec_g722.c.


Define Documentation

#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.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 221 of file codec_g722.c.

static void __unreg_module ( void   )  [static]

Definition at line 221 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.

00093 {
00094    struct g722_decoder_pvt *tmp = pvt->pvt;
00095 
00096    g722_decode_init(&tmp->g722, 64000, 0);
00097 
00098    return 0;
00099 }

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_trans_pvt::datalen, f, g722_decoder_pvt::g722, ast_trans_pvt::i16, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, and ast_trans_pvt::samples.

00102 {
00103    struct g722_decoder_pvt *tmp = pvt->pvt;
00104    int out_samples;
00105    int in_samples;
00106 
00107    /* g722_decode expects the samples to be in the invalid samples / 2 format */
00108    in_samples = f->samples / 2;
00109 
00110    out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples * sizeof(int16_t)], 
00111       (uint8_t *) f->data.ptr, in_samples);
00112 
00113    pvt->samples += out_samples;
00114 
00115    pvt->datalen += (out_samples * sizeof(int16_t));
00116 
00117    return 0;
00118 }

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.

00084 {
00085    struct g722_decoder_pvt *tmp = pvt->pvt;
00086 
00087    g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000);
00088 
00089    return 0;
00090 }

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.

00074 {
00075    struct g722_encoder_pvt *tmp = pvt->pvt;
00076 
00077    g722_encode_init(&tmp->g722, 64000, 0);
00078 
00079    return 0;
00080 }

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_trans_pvt::datalen, f, g722_encoder_pvt::g722, ast_trans_pvt::outbuf, ast_trans_pvt::pvt, ast_trans_pvt::samples, and ast_trans_pvt::ui8.

00121 {
00122    struct g722_encoder_pvt *tmp = pvt->pvt;
00123    int outlen;
00124 
00125    outlen = g722_encode(&tmp->g722, (&pvt->outbuf.ui8[pvt->datalen]), 
00126       (int16_t *) f->data.ptr, f->samples);
00127 
00128    pvt->samples += outlen * 2;
00129 
00130    pvt->datalen += outlen;
00131 
00132    return 0;
00133 }

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.

00065 {
00066    struct g722_encoder_pvt *tmp = pvt->pvt;
00067 
00068    g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000);
00069 
00070    return 0;
00071 }

static int load_module ( void   )  [static]

Definition at line 200 of file codec_g722.c.

References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_translator, g722tolin, g722tolin16, lin16tog722, lintog722, and unload_module.

00201 {
00202    int res = 0;
00203 
00204    res |= ast_register_translator(&g722tolin);
00205    res |= ast_register_translator(&lintog722);
00206    res |= ast_register_translator(&g722tolin16);
00207    res |= ast_register_translator(&lin16tog722);
00208 
00209    if (res) {
00210       unload_module();
00211       return AST_MODULE_LOAD_FAILURE;
00212    }  
00213 
00214    return AST_MODULE_LOAD_SUCCESS;
00215 }

static int reload ( void   )  [static]

Definition at line 183 of file codec_g722.c.

References AST_MODULE_LOAD_SUCCESS.

00184 {
00185    return AST_MODULE_LOAD_SUCCESS;
00186 }

static int unload_module ( void   )  [static]

Definition at line 188 of file codec_g722.c.

References ast_unregister_translator(), g722tolin, g722tolin16, lin16tog722, and lintog722.

00189 {
00190    int res = 0;
00191 
00192    res |= ast_unregister_translator(&g722tolin);
00193    res |= ast_unregister_translator(&lintog722);
00194    res |= ast_unregister_translator(&g722tolin16);
00195    res |= ast_unregister_translator(&lin16tog722);
00196 
00197    return res;
00198 }


Variable Documentation

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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .reload = reload, } [static]

Definition at line 221 of file codec_g722.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 221 of file codec_g722.c.

struct ast_translator g722tolin [static]

Definition at line 135 of file codec_g722.c.

Referenced by load_module(), and unload_module().

struct ast_translator g722tolin16 [static]

Definition at line 159 of file codec_g722.c.

Referenced by load_module(), and unload_module().

struct ast_translator lin16tog722 [static]

Definition at line 171 of file codec_g722.c.

Referenced by load_module(), and unload_module().

struct ast_translator lintog722 [static]

Definition at line 147 of file codec_g722.c.

Referenced by load_module(), and unload_module().


Generated on Wed Apr 6 11:30:03 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7