#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include <fcntl.h>
Go to the source code of this file.
Defines | |
#define | AST_DIGIT_ANY "0123456789#*ABCD" |
#define | AST_DIGIT_ANYNUM "0123456789" |
#define | AST_RESERVED_POINTERS 20 |
#define | SEEK_FORCECUR 10 |
Functions | |
int | ast_applystream (struct ast_channel *chan, struct ast_filestream *s) |
int | ast_closestream (struct ast_filestream *f) |
int | ast_file_init (void) |
int | ast_filecopy (const char *oldname, const char *newname, const char *fmt) |
int | ast_filedelete (const char *filename, const char *fmt) |
int | ast_fileexists (const char *filename, const char *fmt, const char *preflang) |
int | ast_filerename (const char *oldname, const char *newname, const char *fmt) |
int | ast_format_register (const char *name, const char *exts, int format, struct ast_filestream *(*open)(FILE *f), struct ast_filestream *(*rewrite)(FILE *f, const char *comment), int(*write)(struct ast_filestream *, struct ast_frame *), int(*seek)(struct ast_filestream *, long offset, int whence), int(*trunc)(struct ast_filestream *), long(*tell)(struct ast_filestream *), struct ast_frame *(*read)(struct ast_filestream *, int *timetonext), void(*close)(struct ast_filestream *), char *(*getcomment)(struct ast_filestream *)) |
int | ast_format_unregister (const char *name) |
ast_filestream * | ast_openstream (struct ast_channel *chan, const char *filename, const char *preflang) |
ast_filestream * | ast_openstream_full (struct ast_channel *chan, const char *filename, const char *preflang, int asis) |
ast_filestream * | ast_openvstream (struct ast_channel *chan, const char *filename, const char *preflang) |
int | ast_playstream (struct ast_filestream *s) |
ast_filestream * | ast_readfile (const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode) |
ast_frame * | ast_readframe (struct ast_filestream *s) |
int | ast_seekstream (struct ast_filestream *fs, long sample_offset, int whence) |
int | ast_stopstream (struct ast_channel *c) |
int | ast_stream_fastforward (struct ast_filestream *fs, long ms) |
int | ast_stream_rewind (struct ast_filestream *fs, long ms) |
int | ast_streamfile (struct ast_channel *c, const char *filename, const char *preflang) |
long | ast_tellstream (struct ast_filestream *fs) |
int | ast_truncstream (struct ast_filestream *fs) |
int | ast_waitstream (struct ast_channel *c, const char *breakon) |
int | ast_waitstream_exten (struct ast_channel *c, const char *context) |
int | ast_waitstream_fr (struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms) |
int | ast_waitstream_full (struct ast_channel *c, const char *breakon, int audiofd, int monfd) |
ast_filestream * | ast_writefile (const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode) |
int | ast_writestream (struct ast_filestream *fs, struct ast_frame *f) |
Definition in file file.h.
|
|
Definition at line 42 of file file.h. Referenced by initreqprep(). |
|
|
|
Definition at line 44 of file file.h. Referenced by ast_read(), ast_write(), and pcm_seek(). |
|
Definition at line 641 of file file.c. References ast_filestream::owner, and s. Referenced by ast_streamfile(), handle_getoption(), handle_recordfile(), and handle_streamfile().
|
|
Definition at line 686 of file file.c. References ast_safe_system(), ast_sched_del(), ast_settimeout(), ast_translator_free_path(), ast_format::close, ast_filestream::filename, ast_filestream::fmt, ast_format::format, free, ast_filestream::owner, ast_filestream::realfilename, ast_channel::sched, ast_channel::stream, ast_channel::streamid, ast_filestream::trans, ast_channel::vstream, and ast_channel::vstreamid. Referenced by ast_app_getvoice(), ast_hangup(), ast_moh_files_next(), ast_monitor_start(), ast_monitor_stop(), ast_play_and_prepend(), ast_play_and_record(), ast_stopstream(), dictate_exec(), gen_closestream(), handle_recordfile(), local_ast_moh_stop(), mixmonitor_thread(), record_exec(), and recordthread(). 00687 { 00688 char *cmd = NULL; 00689 size_t size = 0; 00690 /* Stop a running stream if there is one */ 00691 if (f->owner) { 00692 if (f->fmt->format < AST_FORMAT_MAX_AUDIO) { 00693 f->owner->stream = NULL; 00694 if (f->owner->streamid > -1) 00695 ast_sched_del(f->owner->sched, f->owner->streamid); 00696 f->owner->streamid = -1; 00697 #ifdef ZAPTEL_OPTIMIZATIONS 00698 ast_settimeout(f->owner, 0, NULL, NULL); 00699 #endif 00700 } else { 00701 f->owner->vstream = NULL; 00702 if (f->owner->vstreamid > -1) 00703 ast_sched_del(f->owner->sched, f->owner->vstreamid); 00704 f->owner->vstreamid = -1; 00705 } 00706 } 00707 /* destroy the translator on exit */ 00708 if (f->trans) { 00709 ast_translator_free_path(f->trans); 00710 f->trans = NULL; 00711 } 00712 00713 if (f->realfilename && f->filename) { 00714 size = strlen(f->filename) + strlen(f->realfilename) + 15; 00715 cmd = alloca(size); 00716 memset(cmd,0,size); 00717 snprintf(cmd,size,"/bin/mv -f %s %s",f->filename,f->realfilename); 00718 ast_safe_system(cmd); 00719 } 00720 00721 if (f->filename) { 00722 free(f->filename); 00723 f->filename = NULL; 00724 } 00725 if (f->realfilename) { 00726 free(f->realfilename); 00727 f->realfilename = NULL; 00728 } 00729 f->fmt->close(f); 00730 return 0; 00731 }
|
|
Initializes all the various file stuff. Basically just registers the cli stuff Returns 0 all the time Definition at line 1283 of file file.c. References ast_cli_register(), and show_file. Referenced by main(). 01284 { 01285 ast_cli_register(&show_file); 01286 return 0; 01287 }
|
|
Definition at line 792 of file file.c. References ACTION_COPY, ast_filehelper(), and fmt. Referenced by copy_file(). 00793 { 00794 return ast_filehelper(filename, filename2, fmt, ACTION_COPY); 00795 }
|
|
Definition at line 782 of file file.c. References ACTION_DELETE, ast_filehelper(), and fmt. Referenced by ast_monitor_start(), ast_monitor_stop(), ast_play_and_prepend(), conf_run(), dial_exec_full(), and vm_delete(). 00783 { 00784 return ast_filehelper(filename, NULL, fmt, ACTION_DELETE); 00785 }
|
|
Definition at line 734 of file file.c. References ACTION_EXISTS, ast_filehelper(), ast_strlen_zero(), fmt, and strsep(). Referenced by app_exec(), ast_moh_files_next(), ast_monitor_start(), ast_monitor_stop(), ast_openstream_full(), ast_openvstream(), chanspy_exec(), conf_run(), dial_exec_full(), invent_message(), last_message_index(), leave_voicemail(), play_mailbox_owner(), play_message_callerid(), record_exec(), and vm_tempgreeting(). 00735 { 00736 char filename2[256]; 00737 char tmp[256]; 00738 char *postfix; 00739 char *prefix; 00740 char *c; 00741 char lang2[MAX_LANGUAGE]; 00742 int res = -1; 00743 if (!ast_strlen_zero(preflang)) { 00744 /* Insert the language between the last two parts of the path */ 00745 ast_copy_string(tmp, filename, sizeof(tmp)); 00746 c = strrchr(tmp, '/'); 00747 if (c) { 00748 *c = '\0'; 00749 postfix = c+1; 00750 prefix = tmp; 00751 snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, preflang, postfix); 00752 } else { 00753 postfix = tmp; 00754 prefix=""; 00755 snprintf(filename2, sizeof(filename2), "%s/%s", preflang, postfix); 00756 } 00757 res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS); 00758 if (res < 1) { 00759 char *stringp=NULL; 00760 ast_copy_string(lang2, preflang, sizeof(lang2)); 00761 stringp=lang2; 00762 strsep(&stringp, "_"); 00763 /* If language is a specific locality of a language (like es_MX), strip the locality and try again */ 00764 if (strcmp(lang2, preflang)) { 00765 if (ast_strlen_zero(prefix)) { 00766 snprintf(filename2, sizeof(filename2), "%s/%s", lang2, postfix); 00767 } else { 00768 snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, lang2, postfix); 00769 } 00770 res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS); 00771 } 00772 } 00773 } 00774 00775 /* Fallback to no language (usually winds up being American English) */ 00776 if (res < 1) { 00777 res = ast_filehelper(filename, NULL, fmt, ACTION_EXISTS); 00778 } 00779 return res; 00780 }
|
|
Definition at line 787 of file file.c. References ACTION_RENAME, ast_filehelper(), and fmt. Referenced by ast_monitor_stop(), ast_play_and_prepend(), and rename_file(). 00788 { 00789 return ast_filehelper(filename, filename2, fmt, ACTION_RENAME); 00790 }
|
|
Register a new file format capability Adds a format to asterisk's format abilities. Fill in the fields, and it will work. For examples, look at some of the various format code. returns 0 on success, -1 on failure Referenced by load_module(). |
|
Definition at line 156 of file file.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), formats, free, LOG_WARNING, ast_format::name, name, ast_format::next, option_verbose, and VERBOSE_PREFIX_2. Referenced by unload_module(). 00157 { 00158 struct ast_format *tmp, *tmpl = NULL; 00159 if (ast_mutex_lock(&formatlock)) { 00160 ast_log(LOG_WARNING, "Unable to lock format list\n"); 00161 return -1; 00162 } 00163 tmp = formats; 00164 while(tmp) { 00165 if (!strcasecmp(name, tmp->name)) { 00166 if (tmpl) 00167 tmpl->next = tmp->next; 00168 else 00169 formats = tmp->next; 00170 free(tmp); 00171 ast_mutex_unlock(&formatlock); 00172 if (option_verbose > 1) 00173 ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name); 00174 return 0; 00175 } 00176 tmpl = tmp; 00177 tmp = tmp->next; 00178 } 00179 ast_mutex_unlock(&formatlock); 00180 ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name); 00181 return -1; 00182 }
|
|
Definition at line 462 of file file.c. References ast_openstream_full(). Referenced by ast_streamfile(), dictate_exec(), handle_getoption(), and handle_streamfile(). 00463 { 00464 return ast_openstream_full(chan, filename, preflang, 0); 00465 }
|
|
Definition at line 467 of file file.c. References ACTION_OPEN, ast_deactivate_generator(), ast_fileexists(), ast_filehelper(), ast_log(), ast_set_write_format(), ast_stopstream(), ast_strlen_zero(), ast_channel::generator, LOG_WARNING, ast_channel::oldwriteformat, ast_channel::stream, and ast_channel::writeformat. Referenced by ast_moh_files_next(), ast_openstream(), and gen_nextfile(). 00468 { 00469 /* This is a fairly complex routine. Essentially we should do 00470 the following: 00471 00472 1) Find which file handlers produce our type of format. 00473 2) Look for a filename which it can handle. 00474 3) If we find one, then great. 00475 4) If not, see what files are there 00476 5) See what we can actually support 00477 6) Choose the one with the least costly translator path and 00478 set it up. 00479 00480 */ 00481 int fmts = -1; 00482 char filename2[256]=""; 00483 char filename3[256]; 00484 char *endpart; 00485 int res; 00486 00487 if (!asis) { 00488 /* do this first, otherwise we detect the wrong writeformat */ 00489 ast_stopstream(chan); 00490 if (chan->generator) 00491 ast_deactivate_generator(chan); 00492 } 00493 if (!ast_strlen_zero(preflang)) { 00494 ast_copy_string(filename3, filename, sizeof(filename3)); 00495 endpart = strrchr(filename3, '/'); 00496 if (endpart) { 00497 *endpart = '\0'; 00498 endpart++; 00499 snprintf(filename2, sizeof(filename2), "%s/%s/%s", filename3, preflang, endpart); 00500 } else 00501 snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename); 00502 fmts = ast_fileexists(filename2, NULL, NULL); 00503 } 00504 if (fmts < 1) { 00505 ast_copy_string(filename2, filename, sizeof(filename2)); 00506 fmts = ast_fileexists(filename2, NULL, NULL); 00507 } 00508 if (fmts < 1) { 00509 ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename); 00510 return NULL; 00511 } 00512 chan->oldwriteformat = chan->writeformat; 00513 /* Set the channel to a format we can work with */ 00514 res = ast_set_write_format(chan, fmts); 00515 00516 res = ast_filehelper(filename2, (char *)chan, NULL, ACTION_OPEN); 00517 if (res >= 0) 00518 return chan->stream; 00519 return NULL; 00520 }
|
|
Definition at line 522 of file file.c. References ACTION_OPEN, ast_fileexists(), ast_filehelper(), ast_log(), ast_strlen_zero(), fmt, and LOG_WARNING. Referenced by ast_streamfile(), and handle_streamfile(). 00523 { 00524 /* This is a fairly complex routine. Essentially we should do 00525 the following: 00526 00527 1) Find which file handlers produce our type of format. 00528 2) Look for a filename which it can handle. 00529 3) If we find one, then great. 00530 4) If not, see what files are there 00531 5) See what we can actually support 00532 6) Choose the one with the least costly translator path and 00533 set it up. 00534 00535 */ 00536 int fd = -1; 00537 int fmts = -1; 00538 char filename2[256]; 00539 char lang2[MAX_LANGUAGE]; 00540 /* XXX H.263 only XXX */ 00541 char *fmt = "h263"; 00542 if (!ast_strlen_zero(preflang)) { 00543 snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename); 00544 fmts = ast_fileexists(filename2, fmt, NULL); 00545 if (fmts < 1) { 00546 ast_copy_string(lang2, preflang, sizeof(lang2)); 00547 snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename); 00548 fmts = ast_fileexists(filename2, fmt, NULL); 00549 } 00550 } 00551 if (fmts < 1) { 00552 ast_copy_string(filename2, filename, sizeof(filename2)); 00553 fmts = ast_fileexists(filename2, fmt, NULL); 00554 } 00555 if (fmts < 1) { 00556 return NULL; 00557 } 00558 fd = ast_filehelper(filename2, (char *)chan, fmt, ACTION_OPEN); 00559 if (fd >= 0) 00560 return chan->vstream; 00561 ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename); 00562 return NULL; 00563 }
|
|
Definition at line 647 of file file.c. References ast_readaudio_callback(), ast_readvideo_callback(), ast_filestream::fmt, ast_format::format, and s. Referenced by ast_streamfile(), handle_getoption(), and handle_streamfile(). 00648 { 00649 if (s->fmt->format < AST_FORMAT_MAX_AUDIO) 00650 ast_readaudio_callback(s); 00651 else 00652 ast_readvideo_callback(s); 00653 return 0; 00654 }
|
|
Definition at line 825 of file file.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), build_filename(), ast_format::exts, exts_compare(), ast_filestream::filename, ast_filestream::flags, ast_filestream::fmt, free, LOG_WARNING, ast_filestream::mode, ast_format::next, ast_format::open, strdup, ast_filestream::trans, type, and ast_filestream::vfs. Referenced by ast_play_and_prepend(). 00826 { 00827 FILE *bfile; 00828 struct ast_format *f; 00829 struct ast_filestream *fs = NULL; 00830 char *fn; 00831 00832 if (ast_mutex_lock(&formatlock)) { 00833 ast_log(LOG_WARNING, "Unable to lock format list\n"); 00834 return NULL; 00835 } 00836 00837 for (f = formats; f && !fs; f = f->next) { 00838 if (!exts_compare(f->exts, type)) 00839 continue; 00840 00841 fn = build_filename(filename, type); 00842 bfile = fopen(fn, "r"); 00843 if (bfile) { 00844 errno = 0; 00845 00846 if (!(fs = f->open(bfile))) { 00847 ast_log(LOG_WARNING, "Unable to open %s\n", fn); 00848 fclose(bfile); 00849 free(fn); 00850 continue; 00851 } 00852 00853 fs->trans = NULL; 00854 fs->fmt = f; 00855 fs->flags = flags; 00856 fs->mode = mode; 00857 fs->filename = strdup(filename); 00858 fs->vfs = NULL; 00859 } else if (errno != EEXIST) 00860 ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno)); 00861 free(fn); 00862 } 00863 00864 ast_mutex_unlock(&formatlock); 00865 if (!fs) 00866 ast_log(LOG_WARNING, "No such format '%s'\n", type); 00867 00868 return fs; 00869 }
|
|
Definition at line 565 of file file.c. References ast_filestream::fmt, ast_format::read, and s. Referenced by ast_play_and_prepend(), dictate_exec(), gen_readframe(), and moh_files_readframe(). 00566 { 00567 struct ast_frame *f = NULL; 00568 int whennext = 0; 00569 if (s && s->fmt) 00570 f = s->fmt->read(s, &whennext); 00571 return f; 00572 }
|
|
Definition at line 656 of file file.c. References ast_filestream::fmt, and ast_format::seek. Referenced by ast_control_streamfile(), ast_moh_files_next(), ast_read(), ast_stream_fastforward(), ast_stream_rewind(), ast_write(), dictate_exec(), handle_getoption(), handle_recordfile(), handle_streamfile(), and mixmonitor_thread().
|
|
|
Definition at line 671 of file file.c. References ast_seekstream(). Referenced by ast_waitstream_fr(). 00672 { 00673 /* I think this is right, 8000 samples per second, 1000 ms a second so 8 00674 * samples per ms */ 00675 long samples = ms * 8; 00676 return ast_seekstream(fs, samples, SEEK_CUR); 00677 }
|
|
Definition at line 679 of file file.c. References ast_seekstream(). Referenced by ast_play_and_prepend(), ast_play_and_record(), ast_waitstream_fr(), handle_recordfile(), and record_exec(). 00680 { 00681 long samples = ms * 8; 00682 samples = samples * -1; 00683 return ast_seekstream(fs, samples, SEEK_CUR); 00684 }
|
|
Definition at line 797 of file file.c. References ast_applystream(), ast_getformatname(), ast_log(), ast_openstream(), ast_openvstream(), ast_playstream(), ast_verbose(), LOG_DEBUG, LOG_WARNING, ast_channel::nativeformats, option_verbose, and VERBOSE_PREFIX_3. Referenced by __login_exec(), agent_call(), ast_app_getdata(), ast_app_getdata_full(), ast_app_getvoice(), ast_control_streamfile(), ast_play_and_prepend(), ast_play_and_record(), ast_play_and_wait(), ast_record_review(), ast_say_character_str_full(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_nl(), ast_say_date_with_format_gr(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_gr(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_tw(), ast_say_digit_str_full(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_cz(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_he(), ast_say_number_full_it(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_tw(), ast_say_phonetic_str_full(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_nl(), ast_say_time_tw(), auth_exec(), background_detect_exec(), background_file(), bridge_playfile(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), chanspy_exec(), check_availability(), check_beep(), conf_exec(), conf_run(), dial_exec_full(), directory_exec(), do_directory(), forward_message(), gr_say_number_female(), handle_recordfile(), invent_message(), ivr_dispatch(), leave_voicemail(), page_exec(), park_exec(), parkandannounce_exec(), pbx_builtin_background(), pl_odtworz_plik(), play_and_wait(), play_file(), play_mailbox_owner(), play_message_callerid(), play_record_review(), playback_exec(), privacy_exec(), record_exec(), retrydial_exec(), rpt_tele_thread(), sayfile(), ss_thread(), vm_authenticate(), wait_file(), and wait_file2(). 00798 { 00799 struct ast_filestream *fs; 00800 struct ast_filestream *vfs; 00801 00802 fs = ast_openstream(chan, filename, preflang); 00803 vfs = ast_openvstream(chan, filename, preflang); 00804 if (vfs) 00805 ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); 00806 if (fs){ 00807 if (ast_applystream(chan, fs)) 00808 return -1; 00809 if (vfs && ast_applystream(chan, vfs)) 00810 return -1; 00811 if (ast_playstream(fs)) 00812 return -1; 00813 if (vfs && ast_playstream(vfs)) 00814 return -1; 00815 #if 1 00816 if (option_verbose > 2) 00817 ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (language '%s')\n", filename, preflang ? preflang : "default"); 00818 #endif 00819 return 0; 00820 } 00821 ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname(chan->nativeformats), strerror(errno)); 00822 return -1; 00823 }
|
|
Definition at line 666 of file file.c. References ast_filestream::fmt, and ast_format::tell. Referenced by ast_control_streamfile(), handle_getoption(), handle_recordfile(), and handle_streamfile().
|
|
Definition at line 661 of file file.c. References ast_filestream::fmt, and ast_format::trunc. Referenced by ast_play_and_prepend(), ast_play_and_record(), handle_recordfile(), and record_exec().
|
|
Definition at line 986 of file file.c. References ast_channel::_softhangup, AST_CONTROL_ANSWER, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, AST_CONTROL_VIDUPDATE, AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree(), ast_log(), ast_read(), ast_sched_runq(), ast_sched_wait(), ast_stopstream(), ast_waitfor(), ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_channel::sched, ast_channel::stream, ast_frame::subclass, and ast_channel::timingfunc. Referenced by __login_exec(), agent_call(), ast_app_getvoice(), ast_play_and_prepend(), ast_play_and_record(), ast_play_and_wait(), ast_readstring(), ast_record_review(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_nl(), ast_say_date_with_format_gr(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_gr(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_tw(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_cz(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_he(), ast_say_number_full_it(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_tw(), ast_say_time_de(), ast_say_time_en(), ast_say_time_gr(), ast_say_time_nl(), ast_say_time_tw(), auth_exec(), background_file(), bridge_playfile(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), chanspy_exec(), check_availability(), check_beep(), conf_exec(), conf_run(), dial_exec_full(), directory_exec(), gr_say_number_female(), handle_recordfile(), invent_message(), ivr_dispatch(), leave_voicemail(), page_exec(), park_exec(), parkandannounce_exec(), pbx_builtin_background(), pl_odtworz_plik(), play_and_wait(), play_file(), play_mailbox_owner(), play_message_callerid(), play_record_review(), playback_exec(), privacy_exec(), record_exec(), retrydial_exec(), rpt_tele_thread(), saycharstr(), sayfile(), saynum(), send_morse(), send_tone_telemetry(), ss_thread(), vm_authenticate(), wait_file(), and wait_file2(). 00987 { 00988 /* XXX Maybe I should just front-end ast_waitstream_full ? XXX */ 00989 int res; 00990 struct ast_frame *fr; 00991 if (!breakon) breakon = ""; 00992 while(c->stream) { 00993 res = ast_sched_wait(c->sched); 00994 if ((res < 0) && !c->timingfunc) { 00995 ast_stopstream(c); 00996 break; 00997 } 00998 if (res < 0) 00999 res = 1000; 01000 res = ast_waitfor(c, res); 01001 if (res < 0) { 01002 ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno)); 01003 return res; 01004 } else if (res > 0) { 01005 fr = ast_read(c); 01006 if (!fr) { 01007 #if 0 01008 ast_log(LOG_DEBUG, "Got hung up\n"); 01009 #endif 01010 return -1; 01011 } 01012 01013 switch(fr->frametype) { 01014 case AST_FRAME_DTMF: 01015 res = fr->subclass; 01016 if (strchr(breakon, res)) { 01017 ast_frfree(fr); 01018 return res; 01019 } 01020 break; 01021 case AST_FRAME_CONTROL: 01022 switch(fr->subclass) { 01023 case AST_CONTROL_HANGUP: 01024 ast_frfree(fr); 01025 return -1; 01026 case AST_CONTROL_RINGING: 01027 case AST_CONTROL_ANSWER: 01028 case AST_CONTROL_VIDUPDATE: 01029 /* Unimportant */ 01030 break; 01031 default: 01032 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass); 01033 } 01034 } 01035 /* Ignore */ 01036 ast_frfree(fr); 01037 } 01038 ast_sched_runq(c->sched); 01039 } 01040 return (c->_softhangup ? -1 : 0); 01041 }
|
|
Definition at line 1183 of file file.c. References ast_channel::_softhangup, AST_CONTROL_ANSWER, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, ast_exists_extension(), AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree(), ast_log(), ast_read(), ast_sched_runq(), ast_sched_wait(), ast_stopstream(), ast_waitfor(), ast_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_channel::sched, ast_channel::stream, ast_frame::subclass, and ast_channel::timingfunc. Referenced by pbx_builtin_background(). 01184 { 01185 /* Waitstream, with return in the case of a valid 1 digit extension */ 01186 /* in the current or specified context being pressed */ 01187 /* XXX Maybe I should just front-end ast_waitstream_full ? XXX */ 01188 int res; 01189 struct ast_frame *fr; 01190 char exten[AST_MAX_EXTENSION]; 01191 01192 if (!context) context = c->context; 01193 while(c->stream) { 01194 res = ast_sched_wait(c->sched); 01195 if ((res < 0) && !c->timingfunc) { 01196 ast_stopstream(c); 01197 break; 01198 } 01199 if (res < 0) 01200 res = 1000; 01201 res = ast_waitfor(c, res); 01202 if (res < 0) { 01203 ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno)); 01204 return res; 01205 } else if (res > 0) { 01206 fr = ast_read(c); 01207 if (!fr) { 01208 #if 0 01209 ast_log(LOG_DEBUG, "Got hung up\n"); 01210 #endif 01211 return -1; 01212 } 01213 01214 switch(fr->frametype) { 01215 case AST_FRAME_DTMF: 01216 res = fr->subclass; 01217 snprintf(exten, sizeof(exten), "%c", res); 01218 if (ast_exists_extension(c, context, exten, 1, c->cid.cid_num)) { 01219 ast_frfree(fr); 01220 return res; 01221 } 01222 break; 01223 case AST_FRAME_CONTROL: 01224 switch(fr->subclass) { 01225 case AST_CONTROL_HANGUP: 01226 ast_frfree(fr); 01227 return -1; 01228 case AST_CONTROL_RINGING: 01229 case AST_CONTROL_ANSWER: 01230 /* Unimportant */ 01231 break; 01232 default: 01233 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass); 01234 } 01235 } 01236 /* Ignore */ 01237 ast_frfree(fr); 01238 } 01239 ast_sched_runq(c->sched); 01240 } 01241 return (c->_softhangup ? -1 : 0); 01242 }
|
|
Definition at line 1043 of file file.c. References ast_channel::_softhangup, AST_CONTROL_ANSWER, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree(), ast_log(), ast_read(), ast_sched_runq(), ast_sched_wait(), ast_stopstream(), ast_stream_fastforward(), ast_stream_rewind(), ast_waitfor(), ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_channel::sched, ast_channel::stream, ast_frame::subclass, and ast_channel::timingfunc. Referenced by ast_control_streamfile(). 01044 { 01045 int res; 01046 struct ast_frame *fr; 01047 01048 if (!breakon) 01049 breakon = ""; 01050 if (!forward) 01051 forward = ""; 01052 if (!rewind) 01053 rewind = ""; 01054 01055 while(c->stream) { 01056 res = ast_sched_wait(c->sched); 01057 if ((res < 0) && !c->timingfunc) { 01058 ast_stopstream(c); 01059 break; 01060 } 01061 if (res < 0) 01062 res = 1000; 01063 res = ast_waitfor(c, res); 01064 if (res < 0) { 01065 ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno)); 01066 return res; 01067 } else 01068 if (res > 0) { 01069 fr = ast_read(c); 01070 if (!fr) { 01071 #if 0 01072 ast_log(LOG_DEBUG, "Got hung up\n"); 01073 #endif 01074 return -1; 01075 } 01076 01077 switch(fr->frametype) { 01078 case AST_FRAME_DTMF: 01079 res = fr->subclass; 01080 if (strchr(forward,res)) { 01081 ast_stream_fastforward(c->stream, ms); 01082 } else if (strchr(rewind,res)) { 01083 ast_stream_rewind(c->stream, ms); 01084 } else if (strchr(breakon, res)) { 01085 ast_frfree(fr); 01086 return res; 01087 } 01088 break; 01089 case AST_FRAME_CONTROL: 01090 switch(fr->subclass) { 01091 case AST_CONTROL_HANGUP: 01092 ast_frfree(fr); 01093 return -1; 01094 case AST_CONTROL_RINGING: 01095 case AST_CONTROL_ANSWER: 01096 /* Unimportant */ 01097 break; 01098 default: 01099 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass); 01100 } 01101 } 01102 /* Ignore */ 01103 ast_frfree(fr); 01104 } else 01105 ast_sched_runq(c->sched); 01106 01107 01108 } 01109 return (c->_softhangup ? -1 : 0); 01110 }
|
|
Definition at line 1112 of file file.c. References ast_channel::_softhangup, AST_CONTROL_ANSWER, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree(), ast_log(), ast_read(), ast_sched_runq(), ast_sched_wait(), ast_stopstream(), ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_channel::sched, ast_channel::stream, ast_frame::subclass, and ast_channel::timingfunc. Referenced by ast_readstring_full(), ast_say_character_str_full(), ast_say_digit_str_full(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_cz(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_he(), ast_say_number_full_it(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_tw(), ast_say_phonetic_str_full(), handle_getoption(), handle_streamfile(), and pl_odtworz_plik(). 01113 { 01114 int res; 01115 int ms; 01116 int outfd; 01117 struct ast_frame *fr; 01118 struct ast_channel *rchan; 01119 01120 if (!breakon) 01121 breakon = ""; 01122 01123 while(c->stream) { 01124 ms = ast_sched_wait(c->sched); 01125 if ((ms < 0) && !c->timingfunc) { 01126 ast_stopstream(c); 01127 break; 01128 } 01129 if (ms < 0) 01130 ms = 1000; 01131 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); 01132 if (!rchan && (outfd < 0) && (ms)) { 01133 /* Continue */ 01134 if (errno == EINTR) 01135 continue; 01136 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); 01137 return -1; 01138 } else if (outfd > -1) { 01139 /* The FD we were watching has something waiting */ 01140 return 1; 01141 } else if (rchan) { 01142 fr = ast_read(c); 01143 if (!fr) { 01144 #if 0 01145 ast_log(LOG_DEBUG, "Got hung up\n"); 01146 #endif 01147 return -1; 01148 } 01149 01150 switch(fr->frametype) { 01151 case AST_FRAME_DTMF: 01152 res = fr->subclass; 01153 if (strchr(breakon, res)) { 01154 ast_frfree(fr); 01155 return res; 01156 } 01157 break; 01158 case AST_FRAME_CONTROL: 01159 switch(fr->subclass) { 01160 case AST_CONTROL_HANGUP: 01161 ast_frfree(fr); 01162 return -1; 01163 case AST_CONTROL_RINGING: 01164 case AST_CONTROL_ANSWER: 01165 /* Unimportant */ 01166 break; 01167 default: 01168 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass); 01169 } 01170 case AST_FRAME_VOICE: 01171 /* Write audio if appropriate */ 01172 if (audiofd > -1) 01173 write(audiofd, fr->data, fr->datalen); 01174 } 01175 /* Ignore */ 01176 ast_frfree(fr); 01177 } 01178 ast_sched_runq(c->sched); 01179 } 01180 return (c->_softhangup ? -1 : 0); 01181 }
|
|
Definition at line 871 of file file.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strdupa, build_filename(), ast_format::exts, exts_compare(), ast_filestream::filename, ast_filestream::flags, ast_filestream::fmt, free, LOG_WARNING, ast_filestream::mode, ast_format::next, option_cache_record_files, ast_filestream::realfilename, record_cache_dir, ast_format::rewrite, ast_format::seek, strdup, ast_filestream::trans, type, and ast_filestream::vfs. Referenced by ast_app_getvoice(), ast_monitor_start(), ast_play_and_prepend(), ast_play_and_record(), ast_writestream(), dictate_exec(), handle_recordfile(), mixmonitor_thread(), record_exec(), and recordthread(). 00872 { 00873 int fd, myflags = 0; 00874 /* compiler claims this variable can be used before initialization... */ 00875 FILE *bfile = NULL; 00876 struct ast_format *f; 00877 struct ast_filestream *fs = NULL; 00878 char *fn, *orig_fn = NULL; 00879 char *buf = NULL; 00880 size_t size = 0; 00881 00882 if (ast_mutex_lock(&formatlock)) { 00883 ast_log(LOG_WARNING, "Unable to lock format list\n"); 00884 return NULL; 00885 } 00886 00887 /* set the O_TRUNC flag if and only if there is no O_APPEND specified */ 00888 if (flags & O_APPEND) { 00889 /* We really can't use O_APPEND as it will break WAV header updates */ 00890 flags &= ~O_APPEND; 00891 } else { 00892 myflags = O_TRUNC; 00893 } 00894 00895 myflags |= O_WRONLY | O_CREAT; 00896 00897 for (f = formats; f && !fs; f = f->next) { 00898 if (!exts_compare(f->exts, type)) 00899 continue; 00900 00901 fn = build_filename(filename, type); 00902 fd = open(fn, flags | myflags, mode); 00903 if (fd > -1) { 00904 /* fdopen() the resulting file stream */ 00905 bfile = fdopen(fd, ((flags | myflags) & O_RDWR) ? "w+" : "w"); 00906 if (!bfile) { 00907 ast_log(LOG_WARNING, "Whoa, fdopen failed: %s!\n", strerror(errno)); 00908 close(fd); 00909 fd = -1; 00910 } 00911 } 00912 00913 if (option_cache_record_files && (fd > -1)) { 00914 char *c; 00915 00916 fclose(bfile); 00917 /* 00918 We touch orig_fn just as a place-holder so other things (like vmail) see the file is there. 00919 What we are really doing is writing to record_cache_dir until we are done then we will mv the file into place. 00920 */ 00921 orig_fn = ast_strdupa(fn); 00922 for (c = fn; *c; c++) 00923 if (*c == '/') 00924 *c = '_'; 00925 00926 size = strlen(fn) + strlen(record_cache_dir) + 2; 00927 buf = alloca(size); 00928 strcpy(buf, record_cache_dir); 00929 strcat(buf, "/"); 00930 strcat(buf, fn); 00931 free(fn); 00932 fn = buf; 00933 fd = open(fn, flags | myflags, mode); 00934 if (fd > -1) { 00935 /* fdopen() the resulting file stream */ 00936 bfile = fdopen(fd, ((flags | myflags) & O_RDWR) ? "w+" : "w"); 00937 if (!bfile) { 00938 ast_log(LOG_WARNING, "Whoa, fdopen failed: %s!\n", strerror(errno)); 00939 close(fd); 00940 fd = -1; 00941 } 00942 } 00943 } 00944 if (fd > -1) { 00945 errno = 0; 00946 if ((fs = f->rewrite(bfile, comment))) { 00947 fs->trans = NULL; 00948 fs->fmt = f; 00949 fs->flags = flags; 00950 fs->mode = mode; 00951 if (orig_fn) { 00952 fs->realfilename = strdup(orig_fn); 00953 fs->filename = strdup(fn); 00954 } else { 00955 fs->realfilename = NULL; 00956 fs->filename = strdup(filename); 00957 } 00958 fs->vfs = NULL; 00959 /* If truncated, we'll be at the beginning; if not truncated, then append */ 00960 f->seek(fs, 0, SEEK_END); 00961 } else { 00962 ast_log(LOG_WARNING, "Unable to rewrite %s\n", fn); 00963 close(fd); 00964 if (orig_fn) { 00965 unlink(fn); 00966 unlink(orig_fn); 00967 } 00968 } 00969 } else if (errno != EEXIST) { 00970 ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno)); 00971 if (orig_fn) 00972 unlink(orig_fn); 00973 } 00974 /* if buf != NULL then fn is already free and pointing to it */ 00975 if (!buf) 00976 free(fn); 00977 } 00978 00979 ast_mutex_unlock(&formatlock); 00980 if (!fs) 00981 ast_log(LOG_WARNING, "No such format '%s'\n", type); 00982 00983 return fs; 00984 }
|
|
Definition at line 197 of file file.c. References ast_getformatname(), ast_log(), ast_translate(), ast_translator_build_path(), ast_translator_free_path(), ast_writefile(), ast_filestream::filename, ast_filestream::flags, ast_filestream::fmt, ast_format::format, ast_frame::frametype, ast_filestream::lastwriteformat, LOG_DEBUG, LOG_WARNING, ast_filestream::mode, ast_format::name, ast_frame::subclass, ast_filestream::trans, type, ast_filestream::vfs, and ast_format::write. Referenced by ast_app_getvoice(), ast_play_and_prepend(), ast_play_and_record(), ast_read(), ast_write(), dictate_exec(), handle_recordfile(), mixmonitor_thread(), record_exec(), and recordthread(). 00198 { 00199 struct ast_frame *trf; 00200 int res = -1; 00201 int alt=0; 00202 if (f->frametype == AST_FRAME_VIDEO) { 00203 if (fs->fmt->format < AST_FORMAT_MAX_AUDIO) { 00204 /* This is the audio portion. Call the video one... */ 00205 if (!fs->vfs && fs->filename) { 00206 /* XXX Support other video formats XXX */ 00207 const char *type = "h263"; 00208 fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode); 00209 ast_log(LOG_DEBUG, "Opened video output file\n"); 00210 } 00211 if (fs->vfs) 00212 return ast_writestream(fs->vfs, f); 00213 /* Ignore */ 00214 return 0; 00215 } else { 00216 /* Might / might not have mark set */ 00217 alt = 1; 00218 } 00219 } else if (f->frametype != AST_FRAME_VOICE) { 00220 ast_log(LOG_WARNING, "Tried to write non-voice frame\n"); 00221 return -1; 00222 } 00223 if (((fs->fmt->format | alt) & f->subclass) == f->subclass) { 00224 res = fs->fmt->write(fs, f); 00225 if (res < 0) 00226 ast_log(LOG_WARNING, "Natural write failed\n"); 00227 if (res > 0) 00228 ast_log(LOG_WARNING, "Huh??\n"); 00229 return res; 00230 } else { 00231 /* XXX If they try to send us a type of frame that isn't the normal frame, and isn't 00232 the one we've setup a translator for, we do the "wrong thing" XXX */ 00233 if (fs->trans && (f->subclass != fs->lastwriteformat)) { 00234 ast_translator_free_path(fs->trans); 00235 fs->trans = NULL; 00236 } 00237 if (!fs->trans) 00238 fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass); 00239 if (!fs->trans) 00240 ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n", fs->fmt->name, ast_getformatname(f->subclass)); 00241 else { 00242 fs->lastwriteformat = f->subclass; 00243 res = 0; 00244 /* Get the translated frame but don't consume the original in case they're using it on another stream */ 00245 trf = ast_translate(fs->trans, f, 0); 00246 if (trf) { 00247 res = fs->fmt->write(fs, trf); 00248 if (res) 00249 ast_log(LOG_WARNING, "Translated frame write failed\n"); 00250 } else 00251 res = 0; 00252 } 00253 return res; 00254 } 00255 }
|