Asterisk - The Open Source Telephony Project
21.4.1
|
Generic File Format Support. More...
#include "asterisk.h"
#include <dirent.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <math.h>
#include "asterisk/_private.h"
#include "asterisk/paths.h"
#include "asterisk/mod_format.h"
#include "asterisk/cli.h"
#include "asterisk/channel.h"
#include "asterisk/sched.h"
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/pbx.h"
#include "asterisk/linkedlists.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "asterisk/test.h"
#include "asterisk/stasis.h"
#include "asterisk/json.h"
#include "asterisk/stasis_system.h"
#include "asterisk/media_cache.h"
Go to the source code of this file.
Data Structures | |
struct | formats |
Macros | |
#define | exts_compare(list, type) (type_in_list((list), (type), strcmp)) |
#define | FORMAT "%-10s %-10s %-20s\n" |
#define | FORMAT2 "%-10s %-10s %-20s\n" |
Functions | |
static int | __ast_file_read_dirs (const char *path, ast_file_on_file on_file, void *obj, int max_depth) |
int | __ast_format_def_register (const struct ast_format_def *f, struct ast_module *mod) |
Register a new file format capability. Adds a format to Asterisk's format abilities. More... | |
int | ast_applystream (struct ast_channel *chan, struct ast_filestream *s) |
Applies a open stream to a channel. More... | |
int | ast_closestream (struct ast_filestream *f) |
Closes a stream. More... | |
int | ast_file_fdtemp (const char *path, char **filename, const char *template_name) |
Create a temporary file located at path. More... | |
int | ast_file_init (void) |
FILE * | ast_file_mkftemp (char *template_name, mode_t mode) |
same as mkstemp, but return a FILE More... | |
int | ast_file_read_dirs (const char *dir_name, ast_file_on_file on_file, void *obj, int max_depth) |
Recursively iterate through files and directories up to max_depth. More... | |
int | ast_filecopy (const char *filename, const char *filename2, const char *fmt) |
Copies a file. More... | |
int | ast_filedelete (const char *filename, const char *fmt) |
Deletes a file. More... | |
int | ast_fileexists (const char *filename, const char *fmt, const char *preflang) |
Checks for the existence of a given file. More... | |
int | ast_filerename (const char *filename, const char *filename2, const char *fmt) |
Renames a file. More... | |
int | ast_format_def_unregister (const char *name) |
Unregisters a file format. More... | |
char * | ast_format_str_reduce (char *fmts) |
static int | ast_fsread_audio (const void *data) |
static int | ast_fsread_video (const void *data) |
int | ast_get_extension_for_mime_type (const char *mime_type, char *buffer, size_t capacity) |
Get a suitable filename extension for the given MIME type. More... | |
struct ast_format * | ast_get_format_for_file_ext (const char *file_ext) |
Get the ast_format associated with the given file extension. More... | |
struct ast_filestream * | ast_openstream (struct ast_channel *chan, const char *filename, const char *preflang) |
Opens stream for use in seeking, playing. More... | |
struct ast_filestream * | ast_openstream_full (struct ast_channel *chan, const char *filename, const char *preflang, int asis) |
Opens stream for use in seeking, playing. More... | |
struct ast_filestream * | ast_openvstream (struct ast_channel *chan, const char *filename, const char *preflang) |
Opens stream for use in seeking, playing. More... | |
int | ast_playstream (struct ast_filestream *s) |
Play a open stream on a channel. More... | |
int | ast_ratestream (struct ast_filestream *fs) |
Return the sample rate of the stream's format. More... | |
static enum fsread_res | ast_readaudio_callback (struct ast_filestream *s) |
struct ast_filestream * | ast_readfile (const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode) |
Starts reading from a file. More... | |
struct ast_frame * | ast_readframe (struct ast_filestream *s) |
Read a frame from a filestream. More... | |
static enum fsread_res | ast_readvideo_callback (struct ast_filestream *s) |
int | ast_seekstream (struct ast_filestream *fs, off_t sample_offset, int whence) |
Seeks into stream. More... | |
int | ast_stopstream (struct ast_channel *tmp) |
Stops a stream. More... | |
int | ast_stream_and_wait (struct ast_channel *chan, const char *file, const char *digits) |
stream file until digit If the file name is non-empty, try to play it. More... | |
int | ast_stream_fastforward (struct ast_filestream *fs, off_t ms) |
Fast forward stream ms. More... | |
int | ast_stream_rewind (struct ast_filestream *fs, off_t ms) |
Rewind stream ms. More... | |
int | ast_streamfile (struct ast_channel *chan, const char *filename, const char *preflang) |
Streams a file. More... | |
off_t | ast_tellstream (struct ast_filestream *fs) |
Tell where we are in a stream. More... | |
int | ast_truncstream (struct ast_filestream *fs) |
Trunc stream at current location. More... | |
int | ast_waitstream (struct ast_channel *c, const char *breakon) |
Waits for a stream to stop or digit to be pressed. More... | |
int | ast_waitstream_exten (struct ast_channel *c, const char *context) |
Waits for a stream to stop or digit matching a valid one digit exten to be pressed. More... | |
int | ast_waitstream_fr (struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int ms) |
Same as waitstream but allows stream to be forwarded or rewound. More... | |
int | ast_waitstream_fr_w_cb (struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int ms, ast_waitstream_fr_cb cb) |
Same as waitstream_fr but allows a callback to be alerted when a user fastforwards or rewinds the file. More... | |
int | ast_waitstream_full (struct ast_channel *c, const char *breakon, int audiofd, int cmdfd) |
struct ast_filestream * | ast_writefile (const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode) |
Starts writing a file. More... | |
int | ast_writestream (struct ast_filestream *fs, struct ast_frame *f) |
Writes a frame to a stream. More... | |
static char * | build_filename (const char *filename, const char *ext) |
construct a filename. Absolute pathnames are preserved, relative names are prefixed by the sounds/ directory. The wav49 suffix is replaced by 'WAV'. Returns a malloc'ed string to be freed by the caller. | |
static int | copy (const char *infile, const char *outfile) |
static void | file_shutdown (void) |
static int | fileexists_core (const char *filename, const char *fmt, const char *preflang, char *buf, int buflen, struct ast_format_cap *result_cap) |
helper routine to locate a file with a given format and language preference. More... | |
static int | fileexists_test (const char *filename, const char *fmt, const char *lang, char *buf, int buflen, struct ast_format_cap *result_cap) |
test if a file exists for a given format. More... | |
static int | filehelper (const char *filename, const void *arg2, const char *fmt, const enum file_action action) |
static void | filestream_close (struct ast_filestream *f) |
static void | filestream_destructor (void *arg) |
static int | fn_wrapper (struct ast_filestream *s, const char *comment, enum wrap_fn mode) |
static struct ast_filestream * | get_filestream (struct ast_format_def *fmt, FILE *bfile) |
static char * | handle_cli_core_show_file_formats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | is_absolute_path (const char *filename) |
static int | is_remote_path (const char *filename) |
static struct ast_json * | json_array_from_list (const char *list, const char *sep) |
static int | open_wrapper (struct ast_filestream *s) |
static int | publish_format_update (const struct ast_format_def *f, struct stasis_message_type *type) |
static struct ast_frame * | read_frame (struct ast_filestream *s, int *whennext) |
static int | rewrite_wrapper (struct ast_filestream *s, const char *comment) |
static int | sanitize_waitstream_return (int return_value) |
STASIS_MESSAGE_TYPE_DEFN (ast_format_register_type) | |
STASIS_MESSAGE_TYPE_DEFN (ast_format_unregister_type) | |
static int | type_in_list (const char *list, const char *type, int(*cmp)(const char *s1, const char *s2)) |
static void | waitstream_control (struct ast_channel *c, enum ast_waitstream_fr_cb_values type, ast_waitstream_fr_cb cb, int skip_ms) |
static int | waitstream_core (struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int skip_ms, int audiofd, int cmdfd, const char *context, ast_waitstream_fr_cb cb) |
the core of all waitstream() functions | |
Variables | |
int | ast_language_is_prefix = 1 |
The following variable controls the layout of localized sound files. If 0, use the historical layout with prefix just before the filename (i.e. digits/en/1.gsm , digits/it/1.gsm or default to digits/1.gsm), if 1 put the prefix at the beginning of the filename (i.e. en/digits/1.gsm, it/digits/1.gsm or default to digits/1.gsm). The latter permits a language to be entirely in one directory. More... | |
static struct ast_cli_entry | cli_file [] |
static struct formats | formats = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static ast_mutex_t | read_dirs_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
Lock to hold when iterating over directories. More... | |
Generic File Format Support.
Definition in file file.c.
int __ast_format_def_register | ( | const struct ast_format_def * | f, |
struct ast_module * | mod | ||
) |
Register a new file format capability. Adds a format to Asterisk's format abilities.
0 | on success |
-1 | on failure |
Definition at line 124 of file file.c.
References ast_calloc, ast_format_register_type(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_format_def::buf_size, ast_format_def::exts, ast_format_def::list, and ast_format_def::name.
int ast_applystream | ( | struct ast_channel * | chan, |
struct ast_filestream * | s | ||
) |
Applies a open stream to a channel.
chan | channel to work |
s | ast_filestream to apply |
0 | on success. |
-1 | on failure. |
Definition at line 1057 of file file.c.
Referenced by ast_streamfile(), handle_getoption(), and speech_streamfile().
int ast_closestream | ( | struct ast_filestream * | f | ) |
Closes a stream.
f | filestream to close Close a playback or recording stream |
0 | on success. |
-1 | on failure. |
Definition at line 1111 of file file.c.
References ao2_ref.
Referenced by __ast_play_and_record(), ast_hangup(), ast_readfile(), ast_stopstream(), ast_writefile(), and handle_cli_file_convert().
int ast_file_fdtemp | ( | const char * | path, |
char ** | filename, | ||
const char * | template_name | ||
) |
Create a temporary file located at path.
path | The directory path to create the file in |
filename | Function allocates memory and stores full filename (including path) here |
template_name | mkstemp template to use. Must end with XXXXXX. |
-1 | on failure |
Definition at line 202 of file file.c.
References ast_asprintf, and ast_mkdir().
int ast_file_init | ( | void | ) |
Provided by file.c
Definition at line 2051 of file file.c.
References ast_cli_register_multiple, ast_format_register_type(), ast_format_unregister_type(), ast_register_cleanup(), and STASIS_MESSAGE_TYPE_INIT.
FILE* ast_file_mkftemp | ( | char * | template_name, |
mode_t | mode | ||
) |
same as mkstemp, but return a FILE
template_name | The template for the unique file name to generate. Modified in place to return the file name. |
mode | The mode for file permissions |
Definition at line 187 of file file.c.
References ast_format_def::close.
int ast_file_read_dirs | ( | const char * | dir_name, |
ast_file_on_file | on_file, | ||
void * | obj, | ||
int | max_depth | ||
) |
Recursively iterate through files and directories up to max_depth.
dir_name | the name of the directory to search |
on_file | callback called on each file |
obj | user data object |
max_depth | re-curse into sub-directories up to a given maximum (-1 = infinite) |
-1 | on failure |
errno | on failure |
0 | otherwise |
Definition at line 1274 of file file.c.
References read_dirs_lock.
Referenced by ast_media_index_update_for_file(), and crypto_load().
int ast_filecopy | ( | const char * | oldname, |
const char * | newname, | ||
const char * | fmt | ||
) |
Copies a file.
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 1151 of file file.c.
Referenced by copy_plain_file(), and vm_forwardoptions().
int ast_filedelete | ( | const char * | filename, |
const char * | fmt | ||
) |
Deletes a file.
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 1141 of file file.c.
Referenced by __ast_play_and_record(), async_delete_name_rec_task(), conf_free(), confbridge_exec(), dial_exec_full(), handle_cli_file_convert(), leave_voicemail(), setup_privacy_args(), and vm_delete().
int ast_fileexists | ( | const char * | filename, |
const char * | fmt, | ||
const char * | preflang | ||
) |
Checks for the existence of a given file.
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. |
0 | The file does not exist |
1 | The file does exist. |
Definition at line 1129 of file file.c.
References ast_alloca, ast_filestream::buf, and fileexists_core().
Referenced by ast_get_character_str(), ast_get_digit_str(), ast_get_phonetic_str(), dial_exec_full(), forward_message(), get_folder(), leave_voicemail(), setup_privacy_args(), stasis_app_control_record(), and vm_tempgreeting().
int ast_filerename | ( | const char * | oldname, |
const char * | newname, | ||
const char * | fmt | ||
) |
Renames a file.
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 |
-1 | on failure |
Definition at line 1146 of file file.c.
Referenced by __ast_play_and_record(), forward_message(), leave_voicemail(), rename_file(), and vm_forwardoptions().
int ast_format_def_unregister | ( | const char * | name | ) |
Unregisters a file format.
name | the name of the format you wish to unregister Unregisters a format based on the name of the format. |
0 | on success |
-1 | on failure to unregister |
Definition at line 162 of file file.c.
References ast_format_unregister_type(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_format_def::name.
char* ast_format_str_reduce | ( | char * | fmts | ) |
Remove duplicate formats from a format string.
fmts | a format string, this string will be modified |
NULL | error |
Definition at line 1894 of file file.c.
References AST_MAX_FORMATS, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strdupa, and ast_format_def::exts.
int ast_get_extension_for_mime_type | ( | const char * | mime_type, |
char * | buffer, | ||
size_t | capacity | ||
) |
Get a suitable filename extension for the given MIME type.
mime_type | The MIME type for which to find extensions |
buffer | A pointer to a buffer to receive the extension |
capacity | The size of 'buffer' in bytes |
1 | if an extension was found for the provided MIME type |
0 | if the MIME type was not found |
Definition at line 2019 of file file.c.
References ast_format_def::exts, lock, ast_format_def::mime_types, and SCOPED_RDLOCK.
struct ast_format* ast_get_format_for_file_ext | ( | const char * | file_ext | ) |
Get the ast_format associated with the given file extension.
file_ext | The file extension for which to find the format |
NULL | if not found |
Definition at line 2006 of file file.c.
References ast_format_def::exts, ast_format_def::format, lock, and SCOPED_RDLOCK.
Referenced by ast_ari_bridges_record(), ast_ari_channels_record(), ast_ari_recordings_get_stored_file(), and process_media_file().
struct ast_filestream* ast_openstream | ( | struct ast_channel * | chan, |
const char * | filename, | ||
const char * | preflang | ||
) |
Opens stream for use in seeking, playing.
chan | channel to work with |
filename | to use |
preflang | prefered language to use |
NULL | on error. |
Definition at line 790 of file file.c.
References ast_openstream_full().
Referenced by ast_streamfile(), handle_getoption(), and speech_streamfile().
struct ast_filestream* ast_openstream_full | ( | struct ast_channel * | chan, |
const char * | filename, | ||
const char * | preflang, | ||
int | asis | ||
) |
Opens stream for use in seeking, playing.
chan | channel to work with |
filename | to use |
preflang | prefered language to use |
asis | if set, don't clear generators |
a | ast_filestream pointer if it opens the file. |
NULL | on error. |
Definition at line 795 of file file.c.
References ao2_ref, ast_alloca, ast_deactivate_generator(), ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_has_type(), ast_set_write_format_from_cap(), ast_stopstream(), and fileexists_core().
Referenced by ast_openstream().
struct ast_filestream* ast_openvstream | ( | struct ast_channel * | chan, |
const char * | filename, | ||
const char * | preflang | ||
) |
Opens stream for use in seeking, playing.
chan | channel to work with |
filename | to use |
preflang | prefered language to use |
NULL | on error. |
Definition at line 848 of file file.c.
References ao2_bump, ao2_ref, ast_alloca, ast_format_cap_alloc, ast_format_cap_count(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_format(), ast_format_cap_has_type(), ast_format_cap_iscompatible(), ast_format_get_name(), ast_format_get_type(), and fileexists_core().
Referenced by ast_streamfile(), and handle_getoption().
int ast_playstream | ( | struct ast_filestream * | s | ) |
Play a open stream on a channel.
s | filestream to play |
0 | on success. |
-1 | on failure. |
Definition at line 1063 of file file.c.
References ast_format_get_type(), ast_filestream::fmt, and ast_format_def::format.
Referenced by ast_streamfile(), handle_getoption(), and speech_streamfile().
int ast_ratestream | ( | struct ast_filestream * | fs | ) |
Return the sample rate of the stream's format.
fs | fs to act on |
Definition at line 1090 of file file.c.
References ast_format_get_sample_rate(), ast_filestream::fmt, and ast_format_def::format.
struct ast_filestream* ast_readfile | ( | const char * | filename, |
const char * | type, | ||
const char * | comment, | ||
int | flags, | ||
int | check, | ||
mode_t | mode | ||
) |
Starts reading from a file.
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. |
NULL | on failure. |
Definition at line 1371 of file file.c.
References ast_closestream(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strdup, build_filename(), ast_format_def::exts, ast_filestream::fmt, ast_filestream::trans, and ast_filestream::vfs.
Referenced by __ast_play_and_record(), and handle_cli_file_convert().
struct ast_frame* ast_readframe | ( | struct ast_filestream * | s | ) |
Read a frame from a filestream.
s | ast_filestream to act on |
NULL | if read failed. |
Definition at line 936 of file file.c.
Referenced by __ast_play_and_record(), and handle_cli_file_convert().
int ast_seekstream | ( | struct ast_filestream * | fs, |
off_t | sample_offset, | ||
int | whence | ||
) |
Seeks into stream.
fs | ast_filestream to perform seek on |
sample_offset | numbers of samples to seek |
whence | SEEK_SET, SEEK_CUR, SEEK_END |
0 | on success. |
-1 | on failure. |
Definition at line 1075 of file file.c.
References ast_filestream::fmt, and ast_format_def::seek.
Referenced by ast_stream_fastforward(), ast_stream_rewind(), ast_streamfile(), and handle_getoption().
int ast_stopstream | ( | struct ast_channel * | c | ) |
Stops a stream.
c | The channel you wish to stop playback on |
Stop playback of a stream
0 | always |
Definition at line 222 of file file.c.
References ast_closestream(), ast_format_get_name(), and ast_set_write_format().
Referenced by ast_openstream_full(), ast_play_and_wait(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), 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_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_vi(), ast_say_number_full_zh(), ast_stream_and_wait(), conf_exec(), dial_exec_full(), grab_transfer(), handle_getoption(), leave_voicemail(), play_file(), queue_exec(), speech_background(), and waitstream_core().
int ast_stream_and_wait | ( | struct ast_channel * | chan, |
const char * | file, | ||
const char * | digits | ||
) |
stream file until digit If the file name is non-empty, try to play it.
0 | if success. |
-1 | if error. |
digit | if interrupted by a digit. |
Definition at line 1878 of file file.c.
References ast_stopstream(), ast_streamfile(), and ast_waitstream().
Referenced by __ast_play_and_record(), agent_login_exec(), announce_user_count(), ast_bridge_channel_playfile(), ast_pickup_call(), ast_record_review(), confbridge_exec(), forward_message(), grab_transfer(), join_conference_bridge(), leave_voicemail(), play_file(), play_prompt_to_user(), stream_failsound(), and vm_forwardoptions().
int ast_stream_fastforward | ( | struct ast_filestream * | fs, |
off_t | ms | ||
) |
Fast forward stream ms.
fs | filestream to act on |
ms | milliseconds to move |
0 | on success. |
-1 | on failure. |
Definition at line 1095 of file file.c.
References ast_seekstream().
int ast_stream_rewind | ( | struct ast_filestream * | fs, |
off_t | ms | ||
) |
Rewind stream ms.
fs | filestream to act on |
ms | milliseconds to move |
0 | on success. |
-1 | on failure. |
Definition at line 1100 of file file.c.
References ast_debug, ast_seekstream(), and ast_tellstream().
Referenced by __ast_play_and_record().
int ast_streamfile | ( | struct ast_channel * | c, |
const char * | filename, | ||
const char * | preflang | ||
) |
Streams a file.
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. |
0 | on success. |
-1 | on failure. |
Definition at line 1293 of file file.c.
References ast_applystream(), ast_debug, AST_FLAG_MASQ_NOSTREAM, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_format_get_name(), ast_openstream(), ast_openvstream(), ast_playstream(), ast_seekstream(), ast_strdup, ast_test_suite_event_notify, ast_filestream::fmt, ast_format_def::format, and ast_filestream::vfs.
Referenced by ast_app_getdata_full(), ast_app_getdata_terminator(), ast_play_and_wait(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_th(), 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_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_gr(), ast_say_datetime_he(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), 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_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_vi(), ast_say_number_full_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_hu(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_zh(), ast_stream_and_wait(), conf_exec(), dial_exec_full(), forward_message(), gr_say_number_female(), leave_voicemail(), and setup_privacy_args().
off_t ast_tellstream | ( | struct ast_filestream * | fs | ) |
Tell where we are in a stream.
fs | fs to act on |
Definition at line 1085 of file file.c.
References ast_filestream::fmt, and ast_format_def::tell.
Referenced by __ast_play_and_record(), ast_stream_rewind(), handle_getoption(), and waitstream_core().
int ast_truncstream | ( | struct ast_filestream * | fs | ) |
Trunc stream at current location.
fs | filestream to act on |
0 | on success. |
-1 | on failure. |
Definition at line 1080 of file file.c.
References ast_filestream::fmt, and ast_format_def::trunc.
Referenced by __ast_play_and_record().
int ast_waitstream | ( | struct ast_channel * | c, |
const char * | breakon | ||
) |
Waits for a stream to stop or digit to be pressed.
c | channel to waitstream on |
breakon | string of DTMF digits to break upon Begins playback of a stream... Wait for a stream to stop or for any one of a given digit to arrive, |
0 | if the stream finishes |
character | if it was interrupted by the channel. |
-1 | on error |
Definition at line 1840 of file file.c.
References waitstream_core().
Referenced by ast_play_and_wait(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_th(), 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_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_gr(), ast_say_datetime_he(), ast_say_datetime_nl(), ast_say_datetime_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), 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_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_vi(), ast_say_number_full_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_he(), ast_say_time_hu(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_zh(), ast_stream_and_wait(), conf_exec(), gr_say_number_female(), leave_voicemail(), and setup_privacy_args().
int ast_waitstream_exten | ( | struct ast_channel * | c, |
const char * | context | ||
) |
Waits for a stream to stop or digit matching a valid one digit exten to be pressed.
c | channel to waitstream on |
context | string of context to match digits to break upon Begins playback of a stream... Wait for a stream to stop or for any one of a valid extension digit to arrive, |
0 | if the stream finishes. |
character | if it was interrupted. |
-1 | on error. |
Definition at line 1859 of file file.c.
References waitstream_core().
int ast_waitstream_fr | ( | struct ast_channel * | c, |
const char * | breakon, | ||
const char * | forward, | ||
const char * | rewind, | ||
int | ms | ||
) |
Same as waitstream but allows stream to be forwarded or rewound.
c | channel to waitstream on |
breakon | string of DTMF digits to break upon |
forward | DTMF digit to fast forward upon |
rewind | DTMF digit to rewind upon |
ms | How many miliseconds to skip forward/back Begins playback of a stream... Wait for a stream to stop or for any one of a given digit to arrive, |
0 | if the stream finishes. |
character | if it was interrupted, |
-1 | on error. |
Definition at line 1809 of file file.c.
References waitstream_core().
int ast_waitstream_fr_w_cb | ( | struct ast_channel * | c, |
const char * | breakon, | ||
const char * | forward, | ||
const char * | rewind, | ||
int | ms, | ||
ast_waitstream_fr_cb | cb | ||
) |
Same as waitstream_fr but allows a callback to be alerted when a user fastforwards or rewinds the file.
c | channel to waitstream on |
breakon | string of DTMF digits to break upon |
forward | DTMF digit to fast forward upon |
rewind | DTMF digit to rewind upon |
ms | How many milliseconds to skip forward/back |
cb | to call when rewind or fastforward occurs. Begins playback of a stream... Wait for a stream to stop or for any one of a given digit to arrive, |
0 | if the stream finishes. |
character | if it was interrupted, |
-1 | on error. |
Definition at line 1798 of file file.c.
References waitstream_core().
int ast_waitstream_full | ( | struct ast_channel * | c, |
const char * | breakon, | ||
int | audiofd, | ||
int | monfd | ||
) |
Same as waitstream, but with audio output to fd and monitored fd checking.
1 | if monfd is ready for reading |
Definition at line 1849 of file file.c.
References waitstream_core().
Referenced by ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), 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_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_vi(), ast_say_number_full_zh(), and handle_getoption().
struct ast_filestream* ast_writefile | ( | const char * | filename, |
const char * | type, | ||
const char * | comment, | ||
int | flags, | ||
int | check, | ||
mode_t | mode | ||
) |
Starts writing a file.
filename | the name of the file to write to |
type | format of file you wish to write out to |
comment | comment to go with |
flags | output file flags |
check | (unimplemented, hence negligible) |
mode | Open mode Create an outgoing file stream. oflags are flags for the open() command, and if check is non-zero, then it will not write 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. |
NULL | on failure. |
Definition at line 1423 of file file.c.
References ast_closestream(), ast_malloc, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strdup, ast_filestream::buf, build_filename(), ast_format_def::exts, ast_filestream::fmt, ast_format_def::seek, ast_filestream::trans, and ast_filestream::vfs.
Referenced by __ast_play_and_record(), ast_writestream(), and handle_cli_file_convert().
int ast_writestream | ( | struct ast_filestream * | fs, |
struct ast_frame * | f | ||
) |
Writes a frame to a stream.
fs | filestream to write to |
f | frame to write to the filestream Send a frame to a filestream – note: does NOT free the frame, call ast_frfree manually |
0 | on success. |
-1 | on failure. |
Definition at line 244 of file file.c.
References ao2_replace, ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), ast_format_get_type(), AST_FRAME_VIDEO, AST_FRAME_VOICE, AST_LIST_NEXT, ast_translate(), ast_translator_build_path(), ast_translator_free_path(), ast_writefile(), ast_filestream::fmt, ast_format_def::format, ast_frame_subclass::format, ast_frame::frametype, ast_format_def::name, ast_frame::subclass, ast_filestream::trans, ast_filestream::vfs, and ast_format_def::write.
Referenced by __ast_play_and_record(), and handle_cli_file_convert().
|
static |
helper routine to locate a file with a given format and language preference.
filename | Name of the file. |
fmt | Format to look for the file in. OPTIONAL |
preflang | The perfered language |
buf | Returns the matching filename |
buflen | Size of the buf |
result_cap | OPTIONAL format capabilities result structure returns what formats the file was found in. |
1 | true. file exists and result format is set |
0 | false. file does not exist. |
Definition at line 741 of file file.c.
References ast_strdupa, and fileexists_test().
Referenced by ast_fileexists(), ast_openstream_full(), and ast_openvstream().
|
static |
test if a file exists for a given format.
1 | true and result_cap represents format capabilities file exists in. |
0 | false |
Definition at line 691 of file file.c.
References ast_language_is_prefix, and ast_media_cache_retrieve().
Referenced by fileexists_core().
int ast_language_is_prefix = 1 |
The following variable controls the layout of localized sound files. If 0, use the historical layout with prefix just before the filename (i.e. digits/en/1.gsm , digits/it/1.gsm or default to digits/1.gsm), if 1 put the prefix at the beginning of the filename (i.e. en/digits/1.gsm, it/digits/1.gsm or default to digits/1.gsm). The latter permits a language to be entirely in one directory.
This is settable in asterisk.conf.
Definition at line 67 of file file.c.
Referenced by fileexists_test(), handle_show_settings(), and main().
|
static |
|
static |
Lock to hold when iterating over directories.
Currently, 'readdir' is not required to be thread-safe. In most modern implementations it should be safe to make concurrent calls into 'readdir' that specify different directory streams (glibc would be one of these). However, since it is potentially unsafe for some implementations we'll use our own locking in order to achieve synchronization for those.
Definition at line 1271 of file file.c.
Referenced by ast_file_read_dirs().