Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Stored file operations for Stasis. More...
#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/paths.h"
#include "asterisk/stasis_app_recording.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | match_recording_data |
struct | stasis_app_stored_recording |
Functions | |
static char * | find_recording (const char *dir_name, const char *file) |
Finds a recording in the given directory. More... | |
static int | handle_find_recording (const char *dir_name, const char *filename, void *obj) |
static int | handle_scan_file (const char *dir_name, const char *filename, void *obj) |
static int | is_recording (const char *filename) |
static struct stasis_app_stored_recording * | recording_alloc (void) |
Allocate a recording object. More... | |
static int | recording_sort (const void *obj_left, const void *obj_right, int flags) |
static int | split_path (const char *path, char **dir, char **file) |
Split a path into directory and file, resolving canonical directory. More... | |
int | stasis_app_stored_recording_copy (struct stasis_app_stored_recording *src_recording, const char *dst, struct stasis_app_stored_recording **dst_recording) |
Copy a recording. More... | |
int | stasis_app_stored_recording_delete (struct stasis_app_stored_recording *recording) |
Delete a recording from disk. More... | |
struct ao2_container * | stasis_app_stored_recording_find_all (void) |
Find all stored recordings on disk. More... | |
struct stasis_app_stored_recording * | stasis_app_stored_recording_find_by_name (const char *name) |
Creates a stored recording object, with the given name. More... | |
const char * | stasis_app_stored_recording_get_extension (struct stasis_app_stored_recording *recording) |
Returns the extension for this recording. More... | |
const char * | stasis_app_stored_recording_get_file (struct stasis_app_stored_recording *recording) |
Returns the filename for this recording, for use with streamfile. More... | |
const char * | stasis_app_stored_recording_get_filename (struct stasis_app_stored_recording *recording) |
Returns the full filename, with extension, for this recording. More... | |
struct ast_json * | stasis_app_stored_recording_to_json (struct stasis_app_stored_recording *recording) |
Convert stored recording info to JSON. More... | |
static void | stored_recording_dtor (void *obj) |
Stored file operations for Stasis.
Definition in file stored.c.
|
static |
Finds a recording in the given directory.
This function searches for a file with the given file name, with a registered format that matches its extension.
dir_name | Directory to search (absolute path). |
file | File name, without extension. |
NULL | if recording is not found. |
Definition at line 188 of file stored.c.
References ast_file_read_dir, match_recording_data::file, make_ari_stubs::file, match_recording_data::file_with_ext, handle_find_recording(), and NULL.
Referenced by stasis_app_stored_recording_find_by_name().
|
static |
Definition at line 158 of file stored.c.
References ast_asprintf, match_recording_data::file, match_recording_data::file_with_ext, is_recording(), and match_recording_data::length.
Referenced by find_recording().
|
static |
Definition at line 255 of file stored.c.
References ao2_link, ao2_ref, ast_asprintf, ast_config_AST_RECORDING_DIR, ast_free, ast_string_field_set, stasis_app_stored_recording::file, make_ari_stubs::file, stasis_app_stored_recording::file_with_ext, stasis_app_stored_recording::format, is_recording(), name, recording_alloc(), and recordings.
Referenced by stasis_app_stored_recording_find_all().
|
static |
Definition at line 137 of file stored.c.
References ast_debug, ast_get_format_for_file_ext(), and ext.
Referenced by handle_find_recording(), and handle_scan_file().
|
static |
Allocate a recording object.
Definition at line 205 of file stored.c.
References ao2_alloc, ao2_cleanup, ao2_ref, ast_string_field_init, NULL, RAII_VAR, and stored_recording_dtor().
Referenced by handle_scan_file(), and stasis_app_stored_recording_find_by_name().
|
static |
Definition at line 225 of file stored.c.
References ast_assert, stasis_app_stored_recording::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.
Referenced by stasis_app_stored_recording_find_all().
|
static |
Split a path into directory and file, resolving canonical directory.
The path is resolved relative to the recording directory. Both dir and file are allocated strings, which you must ast_free().
path | Path to split. | |
[out] | dir | Output parameter for directory portion. |
[out] | file | Output parameter for the file portion. |
Definition at line 92 of file stored.c.
References ast_asprintf, ast_config_AST_RECORDING_DIR, ast_free, ast_std_free(), ast_strdup, make_ari_stubs::file, NULL, and RAII_VAR.
Referenced by stasis_app_stored_recording_find_by_name().
int stasis_app_stored_recording_copy | ( | struct stasis_app_stored_recording * | src_recording, |
const char * | dst, | ||
struct stasis_app_stored_recording ** | dst_recording | ||
) |
Copy a recording.
src_recording | The recording to copy |
dst | The destination of the recording to make |
dst_recording | If successful, the stored recording created as a result of the copy |
0 | on success |
Non-zero | on error |
Definition at line 398 of file stored.c.
References ast_asprintf, ast_config_AST_RECORDING_DIR, ast_filecopy(), ast_free, ast_safe_mkdir(), ast_strdupa, ast_verb, stasis_app_stored_recording::file, stasis_app_stored_recording::format, NULL, RAII_VAR, and stasis_app_stored_recording_find_by_name().
Referenced by ast_ari_recordings_copy_stored().
int stasis_app_stored_recording_delete | ( | struct stasis_app_stored_recording * | recording | ) |
Delete a recording from disk.
recording | Recording to delete. |
Definition at line 448 of file stored.c.
References stasis_app_stored_recording::file_with_ext.
Referenced by ast_ari_recordings_delete_stored().
struct ao2_container * stasis_app_stored_recording_find_all | ( | void | ) |
Find all stored recordings on disk.
NULL | on error. |
Definition at line 297 of file stored.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_container_alloc_rbtree, ao2_ref, ast_config_AST_RECORDING_DIR, ast_file_read_dirs(), handle_scan_file(), NULL, recording_sort(), and recordings.
Referenced by ast_ari_recordings_list_stored().
struct stasis_app_stored_recording * stasis_app_stored_recording_find_by_name | ( | const char * | name | ) |
Creates a stored recording object, with the given name.
name | Name of the recording. |
NULL | if recording is not found. errno is set to indicate why
|
Definition at line 318 of file stored.c.
References ao2_cleanup, ao2_ref, ast_begins_with(), ast_config_AST_RECORDING_DIR, ast_free, ast_log, ast_std_free(), ast_string_field_build, ast_string_field_set, errno, make_ari_stubs::file, stasis_app_stored_recording::file_with_ext, find_recording(), LOG_WARNING, name, NULL, RAII_VAR, recording_alloc(), and split_path().
Referenced by ast_ari_recordings_copy_stored(), ast_ari_recordings_delete_stored(), ast_ari_recordings_get_stored(), ast_ari_recordings_get_stored_file(), play_on_channel(), and stasis_app_stored_recording_copy().
const char * stasis_app_stored_recording_get_extension | ( | struct stasis_app_stored_recording * | recording | ) |
Returns the extension for this recording.
recording | Recording to query. |
NULL | on error |
Definition at line 71 of file stored.c.
References stasis_app_stored_recording::format, and NULL.
Referenced by ast_ari_recordings_get_stored_file().
const char * stasis_app_stored_recording_get_file | ( | struct stasis_app_stored_recording * | recording | ) |
Returns the filename for this recording, for use with streamfile.
The returned string will be valid until the recording object is freed.
recording | Recording to query. |
NULL | on error. |
Definition at line 53 of file stored.c.
References stasis_app_stored_recording::file, and NULL.
Referenced by play_on_channel().
const char * stasis_app_stored_recording_get_filename | ( | struct stasis_app_stored_recording * | recording | ) |
Returns the full filename, with extension, for this recording.
recording | Recording to query. |
NULL | on error |
Definition at line 62 of file stored.c.
References stasis_app_stored_recording::file_with_ext, and NULL.
Referenced by ast_ari_recordings_get_stored_file().
struct ast_json * stasis_app_stored_recording_to_json | ( | struct stasis_app_stored_recording * | recording | ) |
Convert stored recording info to JSON.
recording | Recording to convert. |
NULL | on error. |
Definition at line 455 of file stored.c.
References ast_json_pack(), stasis_app_stored_recording::format, stasis_app_stored_recording::name, and NULL.
Referenced by ast_ari_recordings_copy_stored(), ast_ari_recordings_get_stored(), and ast_ari_recordings_list_stored().
|
static |
Definition at line 46 of file stored.c.
References ast_string_field_free_memory.
Referenced by recording_alloc().