format_g726.c File Reference

Headerless G.726 (16/24/32/40kbps) data format for Asterisk. More...

#include "asterisk.h"
#include "asterisk/mod_format.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
#include "asterisk/format_cache.h"

Include dependency graph for format_g726.c:

Go to the source code of this file.

Data Structures

struct  g726_desc

Defines

#define BUF_SIZE   (5*FRAME_TIME)
#define FRAME_TIME   10
#define RATE_16   3
#define RATE_24   2
#define RATE_32   1
#define RATE_40   0

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int g726_16_open (struct ast_filestream *s)
static int g726_16_rewrite (struct ast_filestream *s, const char *comment)
static int g726_24_open (struct ast_filestream *s)
static int g726_24_rewrite (struct ast_filestream *s, const char *comment)
static int g726_32_open (struct ast_filestream *s)
static int g726_32_rewrite (struct ast_filestream *s, const char *comment)
static int g726_40_open (struct ast_filestream *s)
static int g726_40_rewrite (struct ast_filestream *s, const char *comment)
static int g726_open (struct ast_filestream *tmp, int rate)
static struct ast_frameg726_read (struct ast_filestream *s, int *whennext)
static int g726_seek (struct ast_filestream *fs, off_t sample_offset, int whence)
static off_t g726_tell (struct ast_filestream *fs)
static int g726_trunc (struct ast_filestream *fs)
static int g726_write (struct ast_filestream *s, struct ast_frame *f)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw G.726 (16/24/32/40kbps) data" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_format_def f []
static int frame_size [4]


Detailed Description

Headerless G.726 (16/24/32/40kbps) data format for Asterisk.

File name extensions:

Definition in file format_g726.c.


Define Documentation

#define BUF_SIZE   (5*FRAME_TIME)

Definition at line 52 of file format_g726.c.

#define FRAME_TIME   10

Definition at line 50 of file format_g726.c.

Referenced by g726_read().

#define RATE_16   3

Definition at line 47 of file format_g726.c.

Referenced by g726_16_open(), and g726_16_rewrite().

#define RATE_24   2

Definition at line 46 of file format_g726.c.

Referenced by g726_24_open(), and g726_24_rewrite().

#define RATE_32   1

Definition at line 45 of file format_g726.c.

Referenced by g726_32_open(), and g726_32_rewrite().

#define RATE_40   0

Definition at line 44 of file format_g726.c.

Referenced by g726_40_open(), and g726_40_rewrite().


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 256 of file format_g726.c.

static void __unreg_module ( void   )  [static]

Definition at line 256 of file format_g726.c.

static int g726_16_open ( struct ast_filestream s  )  [static]

Definition at line 91 of file format_g726.c.

References g726_open(), and RATE_16.

00092 {
00093    return g726_open(s, RATE_16);
00094 }

static int g726_16_rewrite ( struct ast_filestream s,
const char *  comment 
) [static]

Definition at line 111 of file format_g726.c.

References g726_open(), and RATE_16.

00112 {
00113    return g726_open(s, RATE_16);
00114 }

static int g726_24_open ( struct ast_filestream s  )  [static]

Definition at line 86 of file format_g726.c.

References g726_open(), and RATE_24.

00087 {
00088    return g726_open(s, RATE_24);
00089 }

static int g726_24_rewrite ( struct ast_filestream s,
const char *  comment 
) [static]

Definition at line 106 of file format_g726.c.

References g726_open(), and RATE_24.

00107 {
00108    return g726_open(s, RATE_24);
00109 }

static int g726_32_open ( struct ast_filestream s  )  [static]

Definition at line 81 of file format_g726.c.

References g726_open(), and RATE_32.

00082 {
00083    return g726_open(s, RATE_32);
00084 }

static int g726_32_rewrite ( struct ast_filestream s,
const char *  comment 
) [static]

Definition at line 101 of file format_g726.c.

References g726_open(), and RATE_32.

00102 {
00103    return g726_open(s, RATE_32);
00104 }

static int g726_40_open ( struct ast_filestream s  )  [static]

Definition at line 76 of file format_g726.c.

References g726_open(), and RATE_40.

00077 {
00078    return g726_open(s, RATE_40);
00079 }

static int g726_40_rewrite ( struct ast_filestream s,
const char *  comment 
) [static]

Definition at line 96 of file format_g726.c.

References g726_open(), and RATE_40.

00097 {
00098    return g726_open(s, RATE_40);
00099 }

static int g726_open ( struct ast_filestream tmp,
int  rate 
) [static]

Definition at line 68 of file format_g726.c.

References ast_filestream::_private, ast_debug, and g726_desc::rate.

Referenced by g726_16_open(), g726_16_rewrite(), g726_24_open(), g726_24_rewrite(), g726_32_open(), g726_32_rewrite(), g726_40_open(), and g726_40_rewrite().

00069 {
00070    struct g726_desc *s = (struct g726_desc *)tmp->_private;
00071    s->rate = rate;
00072    ast_debug(1, "Created filestream G.726-%dk.\n", 40 - s->rate * 8);
00073    return 0;
00074 }

static struct ast_frame* g726_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 120 of file format_g726.c.

References ast_filestream::_private, AST_FRAME_SET_BUFFER, AST_FRIENDLY_OFFSET, ast_log, ast_filestream::buf, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_filestream::fr, FRAME_TIME, LOG_WARNING, NULL, ast_frame::ptr, g726_desc::rate, and ast_frame::samples.

00121 {
00122    int res;
00123    struct g726_desc *fs = (struct g726_desc *)s->_private;
00124 
00125    /* Send a frame from the file to the appropriate channel */
00126    AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
00127    s->fr.samples = 8 * FRAME_TIME;
00128    if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
00129       if (res)
00130          ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
00131       return NULL;
00132    }
00133    *whennext = s->fr.samples;
00134    return &s->fr;
00135 }

static int g726_seek ( struct ast_filestream fs,
off_t  sample_offset,
int  whence 
) [static]

Definition at line 155 of file format_g726.c.

00156 {
00157    return -1;
00158 }

static off_t g726_tell ( struct ast_filestream fs  )  [static]

Definition at line 165 of file format_g726.c.

00166 {
00167    return -1;
00168 }

static int g726_trunc ( struct ast_filestream fs  )  [static]

Definition at line 160 of file format_g726.c.

00161 {
00162    return -1;
00163 }

static int g726_write ( struct ast_filestream s,
struct ast_frame f 
) [static]

Definition at line 137 of file format_g726.c.

References ast_filestream::_private, ast_log, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, LOG_WARNING, ast_frame::ptr, and g726_desc::rate.

00138 {
00139    int res;
00140    struct g726_desc *fs = (struct g726_desc *)s->_private;
00141 
00142    if (f->datalen % frame_size[fs->rate]) {
00143       ast_log(LOG_WARNING, "Invalid data length %d, should be multiple of %d\n", 
00144                   f->datalen, frame_size[fs->rate]);
00145       return -1;
00146    }
00147    if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
00148       ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", 
00149             res, frame_size[fs->rate], strerror(errno));
00150          return -1;
00151    }
00152    return 0;
00153 }

static int load_module ( void   )  [static]

Definition at line 226 of file format_g726.c.

References ast_format_def_register, ast_format_g726, ast_log, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_format_def::desc_size, ast_format_def::format, LOG_WARNING, and name.

00227 {
00228    int i;
00229 
00230    for (i = 0; f[i].desc_size ; i++) {
00231       f[i].format = ast_format_g726;
00232       if (ast_format_def_register(&f[i])) {  /* errors are fatal */
00233          ast_log(LOG_WARNING, "Failed to register format %s.\n", f[i].name);
00234          return AST_MODULE_LOAD_FAILURE;
00235       }
00236    }
00237    return AST_MODULE_LOAD_SUCCESS;
00238 }

static int unload_module ( void   )  [static]

Definition at line 240 of file format_g726.c.

References ast_format_def_unregister(), ast_log, ast_format_def::desc_size, LOG_WARNING, and name.

00241 {
00242    int i;
00243 
00244    for (i = 0; f[i].desc_size ; i++) {
00245       if (ast_format_def_unregister(f[i].name))
00246          ast_log(LOG_WARNING, "Failed to unregister format %s.\n", f[i].name);
00247    }
00248    return(0);
00249 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw G.726 (16/24/32/40kbps) data" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND } [static]

Definition at line 256 of file format_g726.c.

Definition at line 256 of file format_g726.c.

struct ast_format_def f[] [static]

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 170 of file format_g726.c.

Referenced by __adsi_transmit_messages(), __analog_handle_event(), __analog_ss_thread(), __ast_play_and_record(), __ast_queue_frame(), __attempt_transmit(), action_atxfer(), alloc_profile(), analog_exception(), analog_handle_dtmf(), app_exec(), ast_autoservice_stop(), ast_config_text_file_save2(), ast_format_str_reduce(), ast_frame_header_new(), ast_get_format_for_file_ext(), ast_jb_destroy(), ast_read_image(), ast_readfile(), ast_rtcp_read(), ast_rtp_read(), ast_rtp_write(), ast_send_image(), ast_slinfactory_destroy(), ast_trans_frameout(), ast_ulaw_init(), ast_writefile(), async_agi_read_frame(), auth_exec(), autoservice_run(), bsynz_(), cache_cmp(), chan_pjsip_read(), channel_spy(), close_logger(), compile_script(), conf_flush(), conf_run(), config_text_file_load(), create_video_frame(), cubic_coef(), decode_(), dictate_exec(), disa_exec(), do_waiting(), dyptrk_(), echo_exec(), eivr_comm(), encode_(), execif_exec(), filehelper(), filestream_destructor(), fn_wrapper(), frame_cache_cleanup(), function_realtime_store(), gen_generate(), gen_readframe(), generate_computational_cost(), generic_fax_exec(), get_bit_raw(), h261_encap(), h263_encap(), h263p_encap(), h264_encap(), handle_cli_core_show_file_formats(), handle_cli_file_convert(), handle_recordfile(), handle_request_info(), http_post_callback(), ices_exec(), interpolate_product_single(), invert_(), isAnsweringMachine(), ivfilt_(), jack_exec(), jb_empty_and_reset_adaptive(), jb_framedata_destroy(), jb_get_and_deliver(), key_history(), lintoadpcm_frameout(), load_config(), load_file(), load_pktccops_config(), localized_config_text_file_save(), lpfilt_(), lua_read_extensions_file(), main(), mbl_write(), measurenoise(), mgcp_read(), mgcp_rtp_read(), misdn_lib_nt_debug_init(), moh_files_generator(), moh_files_readframe(), mp3_exec(), mpeg4_encap(), multicast_rtp_write(), my_handle_dtmf(), NBScat_exec(), onset_(), ooh323_rtp_read(), op_func(), oss_read(), parse(), parse_file(), pitsyn_(), process_ast_dsp(), process_description_file(), process_dtmf_cisco(), process_dtmf_rfc2833(), rcchk_(), readdirqueue(), receive_dtmf_digits(), receive_message(), record_exec(), recordthread(), reload_followme(), reload_logger(), remove_from_queue(), run_agi(), rxqcheck(), safe_append(), scan_service(), send_string(), send_waveform_to_channel(), sendurl_exec(), session_destroy(), show_history(), sinc(), sip_rtp_read(), skinny_rtp_read(), sms_handleincoming_proto2(), sms_hexdump(), spandsp_fax_gw_t30_gen(), spandsp_fax_read(), speech_background(), spy_generate(), stasis_app_exec(), strip_quotes(), synths_(), t38_tx_packet_handler(), testclient_exec(), testserver_exec(), try_load_key(), txqcheck(), udptlread(), unistim_rtp_read(), unload_module(), ustmtext(), voicin_(), vparms_(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), waitstream_control(), write_history(), and writefile().

int frame_size[4] [static]

Definition at line 54 of file format_g726.c.

Referenced by after_bridge_move_channel(), and ast_websocket_read().


Generated on Thu Apr 16 06:31:05 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6