#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"
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 | |
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 |
Definition at line 59 of file format_g726.c.
#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_log(), LOG_DEBUG, option_debug, ast_filestream::private, 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] |
Definition at line 131 of file format_g726.c.
References AST_FORMAT_G726, AST_FRAME_SET_BUFFER, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), LOG_WARNING, g726_desc::rate, and s.
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_FORMAT_G726, AST_FRAME_VOICE, ast_log(), f, LOG_WARNING, g726_desc::rate, and s.
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(), f, 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(), f, 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_format_register(), __ast_play_and_record(), __ast_read(), __ast_request_and_dial(), __ast_smoother_feed(), __attempt_transmit(), __auto_congest(), __oh323_update_info(), __send_command(), __zt_exception(), action_zapdialoffhook(), adpcmtolin_framein(), adpcmtolin_sample(), agent_ack_sleep(), agent_read(), agent_write(), alawtolin_framein(), alawtolin_sample(), alawtoulaw_framein(), alawtoulaw_sample(), alloc_profile(), alsa_call(), alsa_read(), alsa_write(), app_exec(), ast_bridge_call(), ast_channel_free(), ast_channel_spy_free(), ast_channel_whisper_feed(), ast_closestream(), ast_codec_get_samples(), ast_dsp_silence(), ast_el_read_history(), ast_feature_request_and_dial(), ast_filehelper(), ast_frame_adjust_volume(), ast_frame_dump(), ast_frame_header_new(), ast_frdup(), ast_generic_bridge(), ast_jb_destroy(), ast_jb_put(), ast_masq_park_call(), ast_queue_control(), ast_queue_control_data(), ast_queue_frame(), ast_queue_hangup(), ast_read_generator_actions(), ast_read_image(), ast_readfile(), ast_readframe(), ast_recvtext(), ast_rtcp_read(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_write(), ast_safe_sleep_conditional(), ast_send_image(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_tonepair(), ast_trans_frameout(), ast_translate(), ast_udptl_bridge(), ast_udptl_write(), ast_ulaw_init(), ast_waitfordigit_full(), ast_write(), ast_writefile(), ast_writestream(), async_wait(), auth_exec(), autoservice_run(), builtin_atxfer(), calc_cost(), calc_timestamp(), channel_spy(), check_goto_on_transfer(), cli_audio_convert(), cli_audio_convert_deprecated(), close_logger(), compile_script(), conf_exec(), conf_flush(), conf_queue_dtmf(), conf_run(), config_text_file_load(), config_text_file_save(), console_answer(), console_answer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_sendtext(), console_sendtext_deprecated(), copy_data_from_queue(), decode_frame(), decrypt_frame(), demodulador(), dictate_exec(), disa_exec(), do_parking_thread(), do_waiting(), echo_exec(), fakesrc_sample(), features_read(), features_write(), find_cache(), fn_wrapper(), frame_cache_cleanup(), framein(), free_numbers(), g722tolin_framein(), g722tolin_sample(), g723_write(), g726_write(), g726aal2tolin_framein(), g726tog726aal2_framein(), g726tolin_framein(), g726tolin_sample(), g729_write(), gen_generate(), gen_readframe(), gsm_write(), gsmtolin_framein(), gsmtolin_sample(), gtalk_handle_dtmf(), gtalk_rtp_read(), h263_write(), h264_write(), handle_invite_replaces(), handle_keypad_button_message(), handle_recordfile(), handle_request(), handle_request_info(), iax2_bridge(), iax2_queue_frame(), iax2_send(), iax2_trunk_queue(), iax2_write(), iax_frame_wrap(), iax_park_thread(), iax_showframe(), ices_exec(), ilbc_write(), ilbctolin_framein(), ilbctolin_sample(), init_profile(), isAnsweringMachine(), jb_get_and_deliver(), linear_generator(), lintoadpcm_framein(), lintoadpcm_frameout(), lintoadpcm_sample(), lintoalaw_framein(), lintoalaw_sample(), lintog722_framein(), lintog722_sample(), lintog726_framein(), lintog726_sample(), lintog726aal2_framein(), lintogsm_framein(), lintogsm_sample(), lintoilbc_framein(), lintoilbc_sample(), lintolpc10_framein(), lintolpc10_sample(), lintospeex_framein(), lintospeex_sample(), lintoulaw_framein(), lintoulaw_sample(), load_module(), local_digit_begin(), local_digit_end(), local_hangup(), local_indicate(), local_queue_frame(), local_sendhtml(), local_sendtext(), local_write(), lpc10tolin_framein(), lpc10tolin_sample(), main(), measurenoise(), mgcp_queue_control(), mgcp_queue_frame(), mgcp_read(), mgcp_rtp_read(), misdn_bridge(), misdn_lib_nt_debug_init(), mixmonitor_thread(), moh_files_generator(), moh_files_readframe(), monitor_main(), mp3_exec(), NBScat_exec(), network_thread(), ogg_vorbis_write(), oh323_rtp_read(), oh323_simulate_dtmf_end(), oss_call(), oss_read(), oss_write(), parse(), parse_request(), pcm_write(), process_ast_dsp(), process_cisco_dtmf(), process_rfc2833(), process_rfc3389(), profile_set_param(), queue_frame_to_spies(), readdirqueue(), receive_digit(), receive_dtmf_digits(), receive_message(), record_exec(), recordthread(), reload_followme(), reload_logger(), remove_from_queue(), rpt(), rpt_exec(), rtpread(), run_agi(), safe_append(), scan_service(), send_packet(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), show_file_formats(), show_file_formats_deprecated(), sip_rtp_read(), skinny_rtp_read(), slinear_write(), sms_exec(), sms_generate(), sms_nextoutgoing(), socket_process(), speech_background(), speextolin_framein(), speextolin_sample(), spy_generate(), ss_thread(), strip_quotes(), testclient_exec(), testserver_exec(), transmit_trunk(), try_load_key(), udptlread(), ulawtoalaw_framein(), ulawtoalaw_sample(), ulawtolin_framein(), ulawtolin_sample(), unload_module(), update_packet(), vnak_retransmit(), vox_write(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), wav_write(), writefile(), zap_framein(), zap_queue_frame(), zt_bridge(), zt_exception(), zt_handle_dtmfup(), zt_handle_event(), and zt_read().
int frame_size[4] [static] |
Definition at line 63 of file format_g726.c.