Asterisk - The Open Source Telephony Project
18.5.0
|
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 searchs 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 184 of file stored.c.
References ast_file_read_dir, stasis_app_stored_recording::file, match_recording_data::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 156 of file stored.c.
References ast_asprintf, match_recording_data::file, match_recording_data::file_with_ext, and is_recording().
Referenced by find_recording().
|
static |
Definition at line 249 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, stasis_app_stored_recording::file_with_ext, stasis_app_stored_recording::format, is_recording(), stasis_app_stored_recording::name, recording_alloc(), and recordings.
Referenced by stasis_app_stored_recording_find_all().
|
static |
Definition at line 135 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 200 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 |
< Deprecated name
< Deprecated name
< Deprecated name
< Deprecated name
< Deprecated name
< Deprecated name
Definition at line 219 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] | fail | 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, 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 389 of file stored.c.
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 439 of file stored.c.
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 290 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 whyENOMEM
- out of memeoryEACCES
- file permissions (or recording is outside the config dir)Definition at line 310 of file stored.c.
References ao2_cleanup, ast_begins_with(), ast_config_AST_RECORDING_DIR, ast_free, ast_log, ast_std_free(), ast_string_field_build, ast_string_field_set, errno, stasis_app_stored_recording::file, stasis_app_stored_recording::file_with_ext, find_recording(), LOG_WARNING, 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(), and play_on_channel().
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 446 of file stored.c.
References ast_json_pack(), stasis_app_stored_recording::file_with_ext, 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().