#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 | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Raw G.726 (16/24/32/40kbps) data") | |
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_format | f [] |
static int | frame_size [4] |
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(), h263_read(), h264_read(), ogg_vorbis_read(), pcm_read(), pcm_seek(), slinear_read(), and vox_read().
#define FRAME_TIME 10 |
#define RATE_16 3 |
#define RATE_24 2 |
#define RATE_32 1 |
#define RATE_40 0 |
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Raw G.726 (16/24/32/40kbps) data" | ||||
) |
static int g726_16_open | ( | struct ast_filestream * | s | ) | [static] |
static int g726_16_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
static int g726_24_open | ( | struct ast_filestream * | s | ) | [static] |
static int g726_24_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
static int g726_32_open | ( | struct ast_filestream * | s | ) | [static] |
static int g726_32_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
static int g726_40_open | ( | struct ast_filestream * | s | ) | [static] |
static int g726_40_rewrite | ( | struct ast_filestream * | s, | |
const char * | comment | |||
) | [static] |
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().
00078 { 00079 struct g726_desc *s = (struct g726_desc *)tmp->_private; 00080 s->rate = rate; 00081 if (option_debug) 00082 ast_log(LOG_DEBUG, "Created filestream G.726-%dk.\n", 00083 40 - s->rate * 8); 00084 return 0; 00085 }
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] |
static off_t g726_tell | ( | struct ast_filestream * | fs | ) | [static] |
static int g726_trunc | ( | struct ast_filestream * | fs | ) | [static] |
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_format f[] [static] |
Definition at line 193 of file format_g726.c.
Referenced by __adsi_transmit_messages(), __ast_play_and_record(), __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_channel_spy_free(), ast_el_read_history(), ast_feature_request_and_dial(), ast_filehelper(), ast_frame_header_new(), ast_generic_bridge(), ast_jb_destroy(), ast_masq_autoanswer_login(), ast_masq_hold_call(), ast_masq_park_call(), ast_queue_frame(), ast_read_image(), ast_readfile(), ast_readframe(), 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(), builtin_atxfer(), 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(), copy_data_from_queue(), dictate_exec(), disa_exec(), do_autoanswer_thread(), do_holding_thread(), do_parking_thread(), do_waiting(), echo_exec(), features_read(), find_cache(), fn_wrapper(), frame_cache_cleanup(), gen_generate(), gen_readframe(), get_bit_raw(), gtalk_rtp_read(), handle_invite_replaces(), handle_recordfile(), iax2_bridge(), iax2_trunk_queue(), iax_park_thread(), ices_exec(), isAnsweringMachine(), jb_get_and_deliver(), lintoadpcm_frameout(), main(), measurenoise(), mgcp_read(), mgcp_rtp_read(), misdn_bridge(), misdn_lib_nt_debug_init(), mixmonitor_thread(), 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_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.