Headerless G.726 (16/24/32/40kbps) data format for Asterisk. More...
#include "asterisk.h"
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/sched.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
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_frame * | g726_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_FIRST | AST_MODFLAG_BUILDSUM, .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 = "6989f2ec67f8497e38c12890500c525b" , .load = load_module, .unload = unload_module, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_format | f [] |
static int | frame_size [4] |
Headerless G.726 (16/24/32/40kbps) data format for Asterisk.
File name extensions:
Definition in file format_g726.c.
#define BUF_SIZE (5*FRAME_TIME) |
Definition at line 61 of file format_g726.c.
Referenced by g729_read(), g729_seek(), g729_tell(), gen_prios(), h263_read(), h264_read(), ogg_vorbis_read(), pcm_read(), pcm_seek(), slinear_read(), and vox_read().
#define FRAME_TIME 10 |
Definition at line 59 of file format_g726.c.
Referenced by g726_read().
#define RATE_16 3 |
Definition at line 56 of file format_g726.c.
Referenced by g726_16_open(), and g726_16_rewrite().
#define RATE_24 2 |
Definition at line 55 of file format_g726.c.
Referenced by g726_24_open(), and g726_24_rewrite().
#define RATE_32 1 |
Definition at line 54 of file format_g726.c.
Referenced by g726_32_open(), and g726_32_rewrite().
#define RATE_40 0 |
Definition at line 53 of file format_g726.c.
Referenced by g726_40_open(), and g726_40_rewrite().
static void __reg_module | ( | void | ) | [static] |
Definition at line 280 of file format_g726.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 280 of file format_g726.c.
static int g726_16_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 102 of file format_g726.c.
References g726_open(), and RATE_16.
static int g726_16_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
Definition at line 122 of file format_g726.c.
References g726_open(), and RATE_16.
static int g726_24_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 97 of file format_g726.c.
References g726_open(), and RATE_24.
static int g726_24_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
Definition at line 117 of file format_g726.c.
References g726_open(), and RATE_24.
static int g726_32_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 92 of file format_g726.c.
References g726_open(), and RATE_32.
static int g726_32_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
Definition at line 112 of file format_g726.c.
References g726_open(), and RATE_32.
static int g726_40_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 87 of file format_g726.c.
References g726_open(), and RATE_40.
static int g726_40_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
Definition at line 107 of file format_g726.c.
References g726_open(), and RATE_40.
static int g726_open | ( | struct ast_filestream * | tmp, | |
int | rate | |||
) | [static] |
Definition at line 77 of file format_g726.c.
References ast_filestream::_private, ast_log(), LOG_DEBUG, option_debug, g726_desc::rate, and s.
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().
static struct ast_frame* g726_read | ( | struct ast_filestream * | s, | |
int * | whennext | |||
) | [static, read] |
Definition at line 131 of file format_g726.c.
References ast_filestream::_private, AST_FORMAT_G726, AST_FRAME_SET_BUFFER, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_filestream::buf, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_filestream::fr, FRAME_TIME, ast_frame::frametype, LOG_WARNING, ast_frame::mallocd, g726_desc::rate, ast_frame::samples, and ast_frame::subclass.
00132 { 00133 int res; 00134 struct g726_desc *fs = (struct g726_desc *)s->_private; 00135 00136 /* Send a frame from the file to the appropriate channel */ 00137 s->fr.frametype = AST_FRAME_VOICE; 00138 s->fr.subclass = AST_FORMAT_G726; 00139 s->fr.mallocd = 0; 00140 AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]); 00141 s->fr.samples = 8 * FRAME_TIME; 00142 if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { 00143 if (res) 00144 ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); 00145 return NULL; 00146 } 00147 *whennext = s->fr.samples; 00148 return &s->fr; 00149 }
static int g726_seek | ( | struct ast_filestream * | fs, | |
off_t | sample_offset, | |||
int | whence | |||
) | [static] |
Definition at line 178 of file format_g726.c.
static off_t g726_tell | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 188 of file format_g726.c.
static int g726_trunc | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 183 of file format_g726.c.
static int g726_write | ( | struct ast_filestream * | s, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 151 of file format_g726.c.
References ast_filestream::_private, AST_FORMAT_G726, AST_FRAME_VOICE, ast_log(), ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_frame::frametype, LOG_WARNING, g726_desc::rate, and ast_frame::subclass.
00152 { 00153 int res; 00154 struct g726_desc *fs = (struct g726_desc *)s->_private; 00155 00156 if (f->frametype != AST_FRAME_VOICE) { 00157 ast_log(LOG_WARNING, "Asked to write non-voice frame!\n"); 00158 return -1; 00159 } 00160 if (f->subclass != AST_FORMAT_G726) { 00161 ast_log(LOG_WARNING, "Asked to write non-G726 frame (%d)!\n", 00162 f->subclass); 00163 return -1; 00164 } 00165 if (f->datalen % frame_size[fs->rate]) { 00166 ast_log(LOG_WARNING, "Invalid data length %d, should be multiple of %d\n", 00167 f->datalen, frame_size[fs->rate]); 00168 return -1; 00169 } 00170 if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) { 00171 ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", 00172 res, frame_size[fs->rate], strerror(errno)); 00173 return -1; 00174 } 00175 return 0; 00176 }
static int load_module | ( | void | ) | [static] |
Definition at line 253 of file format_g726.c.
References ast_format_register, ast_log(), ast_format::format, LOG_WARNING, and name.
00254 { 00255 int i; 00256 00257 for (i = 0; f[i].format ; i++) { 00258 if (ast_format_register(&f[i])) { /* errors are fatal */ 00259 ast_log(LOG_WARNING, "Failed to register format %s.\n", f[i].name); 00260 return -1; 00261 } 00262 } 00263 return 0; 00264 }
static int unload_module | ( | void | ) | [static] |
Definition at line 266 of file format_g726.c.
References ast_format_unregister(), ast_log(), ast_format::format, LOG_WARNING, and name.
00267 { 00268 int i; 00269 00270 for (i = 0; f[i].format ; i++) { 00271 if (ast_format_unregister(f[i].name)) 00272 ast_log(LOG_WARNING, "Failed to unregister format %s.\n", f[i].name); 00273 } 00274 return(0); 00275 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_FIRST | AST_MODFLAG_BUILDSUM, .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 = "6989f2ec67f8497e38c12890500c525b" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 280 of file format_g726.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 280 of file format_g726.c.
struct ast_format f[] [static] |
Definition at line 193 of file format_g726.c.
Referenced by __adsi_transmit_messages(), __ast_play_and_record(), __ast_queue_frame(), __ast_read(), __ast_request_and_dial(), __attempt_transmit(), agent_ack_sleep(), agent_read(), alloc_profile(), app_exec(), ast_autoservice_stop(), ast_bridge_call(), ast_channel_free(), ast_el_read_history(), ast_filehelper(), ast_format_str_reduce(), ast_frame_header_new(), ast_generic_bridge(), ast_jb_destroy(), ast_read_image(), ast_readfile(), ast_recvtext(), ast_rtcp_read(), ast_rtp_read(), ast_rtp_write(), ast_safe_sleep_conditional(), ast_send_image(), ast_slinfactory_destroy(), ast_tonepair(), ast_trans_frameout(), ast_udptl_bridge(), ast_ulaw_init(), ast_waitfordigit_full(), ast_write(), ast_writefile(), async_wait(), auth_exec(), autoservice_run(), calc_cost(), channel_spy(), check_goto_on_transfer(), cli_audio_convert(), cli_audio_convert_deprecated(), close_logger(), compile_script(), conf_exec(), conf_flush(), conf_run(), config_text_file_load(), config_text_file_save(), dictate_exec(), disa_exec(), do_parking_thread(), do_waiting(), echo_exec(), feature_request_and_dial(), features_read(), filestream_destructor(), find_cache(), fn_wrapper(), frame_cache_cleanup(), gen_generate(), gen_readframe(), get_bit_raw(), gtalk_rtp_read(), handle_recordfile(), iax2_bridge(), iax2_trunk_queue(), iax_park_thread(), ices_exec(), isAnsweringMachine(), jb_empty_and_reset_adaptive(), jb_get_and_deliver(), lintoadpcm_frameout(), main(), masq_park_call(), measurenoise(), mgcp_read(), mgcp_rtp_read(), misdn_bridge(), misdn_lib_nt_debug_init(), moh_files_generator(), moh_files_readframe(), mp3_exec(), NBScat_exec(), network_thread(), oh323_rtp_read(), oss_read(), parse(), parse_request(), process_ast_dsp(), process_cisco_dtmf(), process_rfc2833(), process_rfc3389(), readdirqueue(), receive_dtmf_digits(), record_exec(), recordthread(), reload_followme(), reload_logger(), remove_from_queue(), rtpread(), run_agi(), safe_append(), scan_service(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), show_file_formats(), show_file_formats_deprecated(), sip_new(), sip_rtp_read(), skinny_rtp_read(), sms_exec(), sms_nextoutgoing(), speech_background(), spy_generate(), strip_quotes(), testclient_exec(), testserver_exec(), try_load_key(), udptlread(), unload_module(), vnak_retransmit(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and writefile().
int frame_size[4] [static] |
Definition at line 63 of file format_g726.c.