Sat Nov 1 06:29:05 2008

Asterisk developer's documentation


file.h File Reference

Generic File Format Support. More...

#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include <fcntl.h>

Include dependency graph for file.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_filestream
struct  ast_format
struct  ast_format_lock

Defines

#define AST_DIGIT_ANY   "0123456789#*ABCD"
#define AST_DIGIT_ANYNUM   "0123456789"
#define ast_format_register(f)   __ast_format_register(f, ast_module_info->self)
#define AST_RESERVED_POINTERS   20
#define SEEK_FORCECUR   10

Functions

int __ast_format_register (const struct ast_format *f, struct ast_module *mod)
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_unregister (const char *name)
ast_filestreamast_openstream (struct ast_channel *chan, const char *filename, const char *preflang)
ast_filestreamast_openstream_full (struct ast_channel *chan, const char *filename, const char *preflang, int asis)
ast_filestreamast_openvstream (struct ast_channel *chan, const char *filename, const char *preflang)
int ast_playstream (struct ast_filestream *s)
ast_filestreamast_readfile (const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode)
ast_frameast_readframe (struct ast_filestream *s)
int ast_seekstream (struct ast_filestream *fs, off_t sample_offset, int whence)
int ast_stopstream (struct ast_channel *c)
 Stops a stream.
int ast_stream_and_wait (struct ast_channel *chan, const char *file, const char *language, const char *digits)
int ast_stream_fastforward (struct ast_filestream *fs, off_t ms)
int ast_stream_rewind (struct ast_filestream *fs, off_t ms)
int ast_streamfile (struct ast_channel *c, const char *filename, const char *preflang)
off_t 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_filestreamast_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)


Detailed Description

Generic File Format Support.

Definition in file file.h.


Define Documentation

#define AST_DIGIT_ANY   "0123456789#*ABCD"

Convenient for waiting

Definition at line 40 of file file.h.

Referenced by __login_exec(), ast_ivr_menu_run_internal(), ast_play_and_wait(), ast_readstring_full(), ast_record_review(), bridge_playfile(), builtin_atxfer(), builtin_blindtransfer(), conf_exec(), conf_run(), dictate_exec(), directory_exec(), festival_exec(), get_folder(), ivr_dispatch(), pbx_builtin_background(), play_file(), play_mailbox_owner(), play_message(), play_message_callerid(), play_message_datetime(), play_message_duration(), play_record_review(), retrydial_exec(), say_and_wait(), say_position(), sayunixtime_exec(), try_calling(), vm_intro_gr(), vm_intro_he(), vm_intro_pt(), vm_intro_pt_BR(), and wait_file2().

#define AST_DIGIT_ANYNUM   "0123456789"

Definition at line 41 of file file.h.

Referenced by initreqprep().

#define ast_format_register ( f   )     __ast_format_register(f, ast_module_info->self)

Definition at line 152 of file file.h.

Referenced by load_module().

#define AST_RESERVED_POINTERS   20

Definition at line 413 of file file.h.

#define SEEK_FORCECUR   10

Definition at line 145 of file file.h.

Referenced by __ast_read(), ast_write(), au_seek(), g729_seek(), gsm_seek(), ilbc_seek(), pcm_seek(), slinear_seek(), vox_seek(), and wav_seek().


Function Documentation

int __ast_format_register ( const struct ast_format f,
struct ast_module mod 
)

Register a new file format capability Adds a format to Asterisk's format abilities. returns 0 on success, -1 on failure

Definition at line 68 of file file.c.

References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_verbose(), ast_format::buf_size, ast_format::exts, f, LOG_WARNING, ast_format::module, ast_format::name, option_verbose, and VERBOSE_PREFIX_2.

00069 {
00070    struct ast_format *tmp;
00071 
00072    if (AST_LIST_LOCK(&formats)) {
00073       ast_log(LOG_WARNING, "Unable to lock format list\n");
00074       return -1;
00075    }
00076    AST_LIST_TRAVERSE(&formats, tmp, list) {
00077       if (!strcasecmp(f->name, tmp->name)) {
00078          AST_LIST_UNLOCK(&formats);
00079          ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", f->name);
00080          return -1;
00081       }
00082    }
00083    if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
00084       AST_LIST_UNLOCK(&formats);
00085       return -1;
00086    }
00087    *tmp = *f;
00088    tmp->module = mod;
00089    if (tmp->buf_size) {
00090       /*
00091        * Align buf_size properly, rounding up to the machine-specific
00092        * alignment for pointers.
00093        */
00094       struct _test_align { void *a, *b; } p;
00095       int align = (char *)&p.b - (char *)&p.a;
00096       tmp->buf_size = ((f->buf_size + align - 1)/align)*align;
00097    }
00098    
00099    memset(&tmp->list, 0, sizeof(tmp->list));
00100 
00101    AST_LIST_INSERT_HEAD(&formats, tmp, list);
00102    AST_LIST_UNLOCK(&formats);
00103    if (option_verbose > 1)
00104       ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", f->name, f->exts);
00105 
00106    return 0;
00107 }

int ast_applystream ( struct ast_channel chan,
struct ast_filestream s 
)

Parameters:
chan channel to work
s ast_filestream to apply Returns 0 for success, -1 on failure

Definition at line 764 of file file.c.

References s.

Referenced by ast_streamfile(), handle_getoption(), handle_recordfile(), handle_streamfile(), and speech_streamfile().

00765 {
00766    s->owner = chan;
00767    return 0;
00768 }

int ast_closestream ( struct ast_filestream f  ) 

Parameters:
f filestream to close Close a playback or recording stream Returns 0 on success, -1 on failure

Definition at line 807 of file file.c.

References ast_closestream(), AST_FORMAT_MAX_AUDIO, ast_module_unref(), ast_safe_system(), AST_SCHED_DEL, ast_settimeout(), ast_translator_free_path(), ast_format::close, f, ast_format::format, free, and ast_format::module.

Referenced by __ast_play_and_record(), ast_closestream(), ast_filehelper(), ast_hangup(), ast_moh_files_next(), ast_monitor_start(), ast_monitor_stop(), ast_stopstream(), cli_audio_convert(), cli_audio_convert_deprecated(), dictate_exec(), gen_closestream(), handle_recordfile(), local_ast_moh_stop(), mixmonitor_thread(), moh_files_release(), and rpt().

00808 {
00809    char *cmd = NULL;
00810    size_t size = 0;
00811    /* Stop a running stream if there is one */
00812    if (f->owner) {
00813       if (f->fmt->format < AST_FORMAT_MAX_AUDIO) {
00814          f->owner->stream = NULL;
00815          AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
00816 #ifdef HAVE_DAHDI
00817          ast_settimeout(f->owner, 0, NULL, NULL);
00818 #endif         
00819       } else {
00820          f->owner->vstream = NULL;
00821          AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);
00822       }
00823    }
00824    /* destroy the translator on exit */
00825    if (f->trans)
00826       ast_translator_free_path(f->trans);
00827 
00828    if (f->realfilename && f->filename) {
00829          size = strlen(f->filename) + strlen(f->realfilename) + 15;
00830          cmd = alloca(size);
00831          memset(cmd,0,size);
00832          snprintf(cmd,size,"/bin/mv -f %s %s",f->filename,f->realfilename);
00833          ast_safe_system(cmd);
00834    }
00835 
00836    if (f->filename)
00837       free(f->filename);
00838    if (f->realfilename)
00839       free(f->realfilename);
00840    if (f->fmt->close)
00841       f->fmt->close(f);
00842    fclose(f->f);
00843    if (f->vfs)
00844       ast_closestream(f->vfs);
00845    if (f->orig_chan_name)
00846       free((void *) f->orig_chan_name);
00847    ast_module_unref(f->fmt->module);
00848    free(f);
00849    return 0;
00850 }

int ast_file_init ( void   ) 

Initializes all the various file stuff. Basically just registers the cli stuff Returns 0 all the time

Definition at line 1340 of file file.c.

References ast_cli_register_multiple(), and cli_file.

Referenced by main().

01341 {
01342    ast_cli_register_multiple(cli_file, sizeof(cli_file) / sizeof(struct ast_cli_entry));
01343    return 0;
01344 }

int ast_filecopy ( const char *  oldname,
const char *  newname,
const char *  fmt 
)

Parameters:
oldname name of the file you wish to copy (minus extension)
newname name you wish the file to be copied to (minus extension)
fmt the format of the file Copy a given file in a given format, or if fmt is NULL, then do so for all

Definition at line 880 of file file.c.

References ast_filehelper().

Referenced by copy_plain_file(), and vm_forwardoptions().

00881 {
00882    return ast_filehelper(filename, filename2, fmt, ACTION_COPY);
00883 }

int ast_filedelete ( const char *  filename,
const char *  fmt 
)

Parameters:
filename name of the file you wish to delete (minus the extension)
fmt of the file Delete a given file in a given format, or if fmt is NULL, then do so for all

Definition at line 870 of file file.c.

References ACTION_DELETE, and ast_filehelper().

Referenced by __ast_play_and_record(), ast_monitor_start(), ast_monitor_stop(), cli_audio_convert(), cli_audio_convert_deprecated(), leave_voicemail(), play_mailbox_owner(), play_record_review(), vm_delete(), and vm_forwardoptions().

00871 {
00872    return ast_filehelper(filename, NULL, fmt, ACTION_DELETE);
00873 }

int ast_fileexists ( const char *  filename,
const char *  fmt,
const char *  preflang 
)

Parameters:
filename name of the file you wish to check, minus the extension
fmt the format you wish to check (the extension)
preflang (the preferred language you wisht to find the file in) See if a given file exists in a given format. If fmt is NULL, any format is accepted. Returns -1 if file does not exist, non-zero positive otherwise.

Definition at line 856 of file file.c.

References ast_filestream::buf, and fileexists_core().

Referenced by app_exec(), ast_moh_files_next(), ast_monitor_start(), ast_monitor_stop(), common_exec(), conf_run(), last_message_index(), leave_voicemail(), play_greeting(), play_mailbox_owner(), play_message_callerid(), record_exec(), retrydial_exec(), say_character_str_full(), say_digit_str_full(), say_phonetic_str_full(), vm_intro(), vm_newuser(), vm_options(), and vm_tempgreeting().

00857 {
00858    char *buf;
00859    int buflen;
00860 
00861    if (preflang == NULL)
00862       preflang = "";
00863    buflen = strlen(preflang) + strlen(filename) + 4;  /* room for everything */
00864    buf = alloca(buflen);
00865    if (buf == NULL)
00866       return 0;
00867    return fileexists_core(filename, fmt, preflang, buf, buflen);
00868 }

int ast_filerename ( const char *  oldname,
const char *  newname,
const char *  fmt 
)

Parameters:
oldname the name of the file you wish to act upon (minus the extension)
newname the name you wish to rename the file to (minus the extension)
fmt the format of the file Rename a given file in a given format, or if fmt is NULL, then do so for all Returns -1 on failure

Definition at line 875 of file file.c.

References ACTION_RENAME, and ast_filehelper().

Referenced by __ast_play_and_record(), ast_monitor_stop(), leave_voicemail(), play_record_review(), and rename_file().

00876 {
00877    return ast_filehelper(filename, filename2, fmt, ACTION_RENAME);
00878 }

int ast_format_unregister ( const char *  name  ) 

Parameters:
name the name of the format you wish to unregister Unregisters a format based on the name of the format. Returns 0 on success, -1 on failure to unregister

Definition at line 109 of file file.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_verbose(), free, LOG_WARNING, ast_format::name, option_verbose, and VERBOSE_PREFIX_2.

Referenced by unload_module().

00110 {
00111    struct ast_format *tmp;
00112    int res = -1;
00113 
00114    if (AST_LIST_LOCK(&formats)) {
00115       ast_log(LOG_WARNING, "Unable to lock format list\n");
00116       return -1;
00117    }
00118    AST_LIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) {
00119       if (!strcasecmp(name, tmp->name)) {
00120          AST_LIST_REMOVE_CURRENT(&formats, list);
00121          free(tmp);
00122          res = 0;
00123       }
00124    }
00125    AST_LIST_TRAVERSE_SAFE_END
00126    AST_LIST_UNLOCK(&formats);
00127 
00128    if (!res) {
00129       if (option_verbose > 1)
00130          ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name);
00131    } else
00132       ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name);
00133 
00134    return res;
00135 }

struct ast_filestream* ast_openstream ( struct ast_channel chan,
const char *  filename,
const char *  preflang 
)

Parameters:
chan channel to work with
filename to use
preflang prefered language to use Returns a ast_filestream pointer if it opens the file, NULL on error

Definition at line 571 of file file.c.

References ast_openstream_full().

Referenced by ast_streamfile(), dictate_exec(), handle_getoption(), handle_streamfile(), and speech_streamfile().

00572 {
00573    return ast_openstream_full(chan, filename, preflang, 0);
00574 }

struct ast_filestream* ast_openstream_full ( struct ast_channel chan,
const char *  filename,
const char *  preflang,
int  asis 
)

Parameters:
chan channel to work with
filename to use
preflang prefered language to use
asis if set, don't clear generators Returns a ast_filestream pointer if it opens the file, NULL on error

Definition at line 576 of file file.c.

References ACTION_OPEN, ast_deactivate_generator(), ast_filehelper(), AST_FORMAT_AUDIO_MASK, ast_log(), ast_set_write_format(), ast_stopstream(), ast_filestream::buf, fileexists_core(), LOG_WARNING, ast_channel::oldwriteformat, ast_channel::stream, and ast_channel::writeformat.

Referenced by ast_moh_files_next(), ast_openstream(), and gen_nextfile().

00577 {
00578    /* 
00579     * Use fileexists_core() to find a file in a compatible
00580     * language and format, set up a suitable translator,
00581     * and open the stream.
00582     */
00583    int fmts, res, buflen;
00584    char *buf;
00585 
00586    if (!asis) {
00587       /* do this first, otherwise we detect the wrong writeformat */
00588       ast_stopstream(chan);
00589       if (chan->generator)
00590          ast_deactivate_generator(chan);
00591    }
00592    if (preflang == NULL)
00593       preflang = "";
00594    buflen = strlen(preflang) + strlen(filename) + 4;
00595    buf = alloca(buflen);
00596    if (buf == NULL)
00597       return NULL;
00598    fmts = fileexists_core(filename, NULL, preflang, buf, buflen);
00599    if (fmts > 0)
00600       fmts &= AST_FORMAT_AUDIO_MASK;
00601    if (fmts < 1) {
00602       ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
00603       return NULL;
00604    }
00605    chan->oldwriteformat = chan->writeformat;
00606    /* Set the channel to a format we can work with */
00607    res = ast_set_write_format(chan, fmts);
00608    res = ast_filehelper(buf, chan, NULL, ACTION_OPEN);
00609    if (res >= 0)
00610       return chan->stream;
00611    return NULL;
00612 }

struct ast_filestream* ast_openvstream ( struct ast_channel chan,
const char *  filename,
const char *  preflang 
)

Parameters:
chan channel to work with
filename to use
preflang prefered language to use Returns a ast_filestream pointer if it opens the file, NULL on error

Definition at line 614 of file file.c.

References ACTION_OPEN, ast_filehelper(), AST_FORMAT_MAX_AUDIO, AST_FORMAT_MAX_VIDEO, ast_getformatname(), ast_log(), ast_filestream::buf, fileexists_core(), fmt, format, LOG_WARNING, ast_channel::nativeformats, and ast_channel::vstream.

Referenced by ast_streamfile(), handle_getoption(), and handle_streamfile().

00615 {
00616    /* As above, but for video. But here we don't have translators
00617     * so we must enforce a format.
00618     */
00619    unsigned int format;
00620    char *buf;
00621    int buflen;
00622 
00623    if (preflang == NULL)
00624       preflang = "";
00625    buflen = strlen(preflang) + strlen(filename) + 4;
00626    buf = alloca(buflen);
00627    if (buf == NULL)
00628       return NULL;
00629 
00630    for (format = AST_FORMAT_MAX_AUDIO << 1; format <= AST_FORMAT_MAX_VIDEO; format = format << 1) {
00631       int fd;
00632       const char *fmt;
00633 
00634       if (!(chan->nativeformats & format))
00635          continue;
00636       fmt = ast_getformatname(format);
00637       if ( fileexists_core(filename, fmt, preflang, buf, buflen) < 1)   /* no valid format */
00638          continue;
00639       fd = ast_filehelper(buf, chan, fmt, ACTION_OPEN);
00640       if (fd >= 0)
00641          return chan->vstream;
00642       ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
00643    }
00644    return NULL;
00645 }

int ast_playstream ( struct ast_filestream s  ) 

Parameters:
s filestream to play Returns 0 for success, -1 on failure

Definition at line 770 of file file.c.

References AST_FORMAT_MAX_AUDIO, ast_readaudio_callback(), ast_readvideo_callback(), FSREAD_FAILURE, and s.

Referenced by ast_streamfile(), handle_getoption(), handle_streamfile(), and speech_streamfile().

00771 {
00772    enum fsread_res res;
00773 
00774    if (s->fmt->format < AST_FORMAT_MAX_AUDIO)
00775       res = ast_readaudio_callback(s);
00776    else
00777       res = ast_readvideo_callback(s);
00778 
00779    return (res == FSREAD_FAILURE) ? -1 : 0;
00780 }

struct ast_filestream* ast_readfile ( const char *  filename,
const char *  type,
const char *  comment,
int  flags,
int  check,
mode_t  mode 
)

Parameters:
filename the name of the file to read from
type format of file you wish to read from
comment comment to go with
flags file flags
check (unimplemented, hence negligible)
mode Open mode Open an incoming file stream. flags are flags for the open() command, and if check is non-zero, then it will not read a file if there are any files that start with that name and have an extension Please note, this is a blocking function. Program execution will not return until ast_waitstream completes it's execution. Returns a struct ast_filestream on success, NULL on failure

Definition at line 916 of file file.c.

References ast_free, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), build_filename(), errno, ast_format::exts, exts_compare(), f, ast_filestream::filename, ast_filestream::flags, ast_filestream::fmt, free, get_filestream(), LOG_WARNING, ast_filestream::mode, open_wrapper(), strdup, ast_filestream::trans, and ast_filestream::vfs.

Referenced by __ast_play_and_record(), cli_audio_convert(), and cli_audio_convert_deprecated().

00917 {
00918    FILE *bfile;
00919    struct ast_format *f;
00920    struct ast_filestream *fs = NULL;
00921    char *fn;
00922 
00923    if (AST_LIST_LOCK(&formats)) {
00924       ast_log(LOG_WARNING, "Unable to lock format list\n");
00925       return NULL;
00926    }
00927 
00928    AST_LIST_TRAVERSE(&formats, f, list) {
00929       fs = NULL;
00930       if (!exts_compare(f->exts, type))
00931          continue;
00932 
00933       fn = build_filename(filename, type);
00934       errno = 0;
00935       bfile = fopen(fn, "r");
00936       if (!bfile || (fs = get_filestream(f, bfile)) == NULL ||
00937           open_wrapper(fs) ) {
00938          ast_log(LOG_WARNING, "Unable to open %s\n", fn);
00939          if (fs)
00940             ast_free(fs);
00941          fs = NULL;
00942          if (bfile)
00943             fclose(bfile);
00944          free(fn);
00945          continue;
00946       }
00947       /* found it */
00948       fs->trans = NULL;
00949       fs->fmt = f;
00950       fs->flags = flags;
00951       fs->mode = mode;
00952       fs->filename = strdup(filename);
00953       fs->vfs = NULL;
00954       break;
00955    }
00956 
00957    AST_LIST_UNLOCK(&formats);
00958    if (!fs) 
00959       ast_log(LOG_WARNING, "No such format '%s'\n", type);
00960 
00961    return fs;
00962 }

struct ast_frame* ast_readframe ( struct ast_filestream s  ) 

Parameters:
s ast_filestream to act on Returns a frame or NULL if read failed

Definition at line 647 of file file.c.

References f, and s.

Referenced by __ast_play_and_record(), cli_audio_convert(), cli_audio_convert_deprecated(), dictate_exec(), gen_readframe(), and moh_files_readframe().

00648 {
00649    struct ast_frame *f = NULL;
00650    int whennext = 0; 
00651    if (s && s->fmt)
00652       f = s->fmt->read(s, &whennext);
00653    return f;
00654 }

int ast_seekstream ( struct ast_filestream fs,
off_t  sample_offset,
int  whence 
)

Parameters:
fs ast_filestream to perform seek on
sample_offset numbers of samples to seek
whence SEEK_SET, SEEK_CUR, SEEK_END Returns 0 for success, or -1 for error

Definition at line 782 of file file.c.

References ast_filestream::fmt, and ast_format::seek.

Referenced by __ast_read(), ast_control_streamfile(), ast_stream_fastforward(), ast_stream_rewind(), ast_write(), dictate_exec(), handle_getoption(), handle_recordfile(), and handle_streamfile().

00783 {
00784    return fs->fmt->seek(fs, sample_offset, whence);
00785 }

int ast_stopstream ( struct ast_channel c  ) 

Stops a stream.

Parameters:
c The channel you wish to stop playback on
Stop playback of a stream

Return values:
0 always
Note:
The channel does not need to be locked before calling this function.

Definition at line 137 of file file.c.

References ast_channel_lock, ast_channel_unlock, ast_closestream(), ast_log(), ast_set_write_format(), LOG_WARNING, ast_channel::oldwriteformat, ast_channel::stream, and ast_channel::vstream.

Referenced by ast_adsi_transmit_message_full(), ast_control_streamfile(), ast_openstream_full(), ast_play_and_wait(), ast_readstring_full(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_he(), 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_ge(), 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(), background_detect_exec(), builtin_blindtransfer(), conf_exec(), conf_run(), directory_exec(), handle_getoption(), handle_streamfile(), ices_exec(), ivr_dispatch(), leave_voicemail(), mp3_exec(), NBScat_exec(), parkandannounce_exec(), pbx_builtin_background(), pl_odtworz_plik(), play_file(), play_mailbox_owner(), playback_exec(), queue_exec(), read_exec(), recordthread(), rpt_tele_thread(), s_streamwait3(), say_character_str_full(), say_digit_str_full(), say_phonetic_str_full(), saycharstr(), sayfile(), saynum(), send_morse(), send_tone_telemetry(), send_waveform_to_channel(), speech_background(), vm_authenticate(), vm_execmain(), wait_for_winner(), waitstream_core(), and zapateller_exec().

00138 {
00139    ast_channel_lock(tmp);
00140 
00141    /* Stop a running stream if there is one */
00142    if (tmp->stream) {
00143       ast_closestream(tmp->stream);
00144       tmp->stream = NULL;
00145       if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
00146          ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat);
00147    }
00148    /* Stop the video stream too */
00149    if (tmp->vstream != NULL) {
00150       ast_closestream(tmp->vstream);
00151       tmp->vstream = NULL;
00152    }
00153 
00154    ast_channel_unlock(tmp);
00155 
00156    return 0;
00157 }

int ast_stream_and_wait ( struct ast_channel chan,
const char *  file,
const char *  language,
const char *  digits 
)

Definition at line 1259 of file file.c.

References ast_streamfile(), ast_strlen_zero(), and ast_waitstream().

Referenced by __ast_play_and_record(), app_exec(), ast_record_review(), bridge_playfile(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), directory_exec(), invent_message(), ivr_dispatch(), leave_voicemail(), park_exec(), play_mailbox_owner(), play_message_callerid(), play_record_review(), and wait_file2().

01261 {
01262         int res = 0;
01263         if (!ast_strlen_zero(file)) {
01264                 res =  ast_streamfile(chan, file, language);
01265                 if (!res)
01266                         res = ast_waitstream(chan, digits);
01267         }
01268         return res;
01269 } 

int ast_stream_fastforward ( struct ast_filestream fs,
off_t  ms 
)

Parameters:
fs filestream to act on
ms milliseconds to move Returns 0 for success, or -1 for error

Definition at line 797 of file file.c.

References ast_seekstream(), and DEFAULT_SAMPLES_PER_MS.

Referenced by waitstream_core().

00798 {
00799    return ast_seekstream(fs, ms * DEFAULT_SAMPLES_PER_MS, SEEK_CUR);
00800 }

int ast_stream_rewind ( struct ast_filestream fs,
off_t  ms 
)

Parameters:
fs filestream to act on
ms milliseconds to move Returns 0 for success, or -1 for error

Definition at line 802 of file file.c.

References ast_seekstream(), and DEFAULT_SAMPLES_PER_MS.

Referenced by __ast_play_and_record(), handle_recordfile(), and waitstream_core().

00803 {
00804    return ast_seekstream(fs, -ms * DEFAULT_SAMPLES_PER_MS, SEEK_CUR);
00805 }

int ast_streamfile ( struct ast_channel c,
const char *  filename,
const char *  preflang 
)

Parameters:
c channel to stream the file to
filename the name of the file you wish to stream, minus the extension
preflang the preferred language you wish to have the file streamed to you in Prepares a channel for the streaming of a file. To start the stream, afterward do a ast_waitstream() on the channel Also, it will stop any existing streams on the channel. Returns 0 on success, or -1 on failure.

Definition at line 885 of file file.c.

References ast_applystream(), AST_FLAG_MASQ_NOSTREAM, ast_getformatname(), ast_getformatname_multiple(), ast_log(), ast_openstream(), ast_openvstream(), ast_playstream(), ast_strdup, ast_test_flag, ast_verbose(),