59 return recording->
file;
98 const char *file_portion;
105 last_slash = strrchr(relative_dir,
'/');
108 file_portion = last_slash + 1;
114 *relative_dir =
'\0';
121 real_dir = realpath(absolute_dir,
NULL);
128 return (*dir && *
file) ? 0 : -1;
139 const char *
ext = strrchr(filename,
'.');
148 ast_debug(5,
"Recording %s: unrecognized format %s\n",
155 return ext - filename - 1;
166 || strncmp(data->
file, filename, num)) {
192 .length = strlen(
file),
193 .file_with_ext =
NULL
229 const char *right_key = obj_right;
234 right_key = object_right->
name;
237 cmp = strcmp(object_left->
name, right_key);
244 cmp = strncmp(object_left->
name, right_key, strlen(right_key));
259 char *dot, *filepath;
266 if (
ast_asprintf(&filepath,
"%s/%s", dir_name, filename) < 0) {
282 dot = strrchr(recording->
file,
'.');
284 recording->
format = dot + 1;
327 struct stat file_stat;
363 prefix_len = strlen(real_basedir);
373 if (!file_with_ext) {
377 recording->format = strrchr(recording->file_with_ext,
'.');
378 if (!recording->format) {
381 ++(recording->format);
383 res = stat(file_with_ext, &file_stat);
388 if (!S_ISREG(file_stat.st_mode)) {
408 format = strrchr(dst_file,
'.');
414 last_slash = strrchr(dst_file,
'/');
423 tmp_path, 0777) != 0) {
438 ast_verb(4,
"Copying recording %s to %s (format %s)\n", src_recording->
file,
439 full_path, src_recording->
format);
463 "name", recording->
name,
464 "format", recording->
format);
Asterisk main include file. File version handling, generic pbx functions.
void ast_std_free(void *ptr)
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE
Replace objects with duplicate keys in container.
#define ast_file_read_dir(dir_name, on_file, obj)
Iterate over each file in a given directory.
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.
struct ast_format * ast_get_format_for_file_ext(const char *file_ext)
Get the ast_format associated with the given file extension.
int ast_filecopy(const char *oldname, const char *newname, const char *fmt)
Copies a file.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_RECORDING_DIR
static struct stasis_rest_handlers recordings
REST handler for /api-docs/recordings.json.
Stasis Application Recording API. See StasisApplication API" for detailed documentation.
static void stored_recording_dtor(void *obj)
const char * stasis_app_stored_recording_get_filename(struct stasis_app_stored_recording *recording)
Returns the full filename, with extension, for this recording.
const char * stasis_app_stored_recording_get_file(struct stasis_app_stored_recording *recording)
Returns the filename for this recording, for use with streamfile.
static int is_recording(const char *filename)
static int recording_sort(const void *obj_left, const void *obj_right, int flags)
struct ao2_container * stasis_app_stored_recording_find_all(void)
Find all stored recordings on disk.
static int handle_scan_file(const char *dir_name, const char *filename, void *obj)
struct ast_json * stasis_app_stored_recording_to_json(struct stasis_app_stored_recording *recording)
Convert stored recording info to JSON.
struct stasis_app_stored_recording * stasis_app_stored_recording_find_by_name(const char *name)
Creates a stored recording object, with the given name.
static struct stasis_app_stored_recording * recording_alloc(void)
Allocate a recording object.
static char * find_recording(const char *dir_name, const char *file)
Finds a recording in the given directory.
int stasis_app_stored_recording_delete(struct stasis_app_stored_recording *recording)
Delete a recording from disk.
const char * stasis_app_stored_recording_get_extension(struct stasis_app_stored_recording *recording)
Returns the extension for this recording.
static int split_path(const char *path, char **dir, char **file)
Split a path into directory and file, resolving canonical directory.
static int handle_find_recording(const char *dir_name, const char *filename, void *obj)
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.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Abstract JSON element (object, array, string, int, ...).
const ast_string_field file_with_ext
const ast_string_field file
const ast_string_field name
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_safe_mkdir(const char *base_path, const char *path, int mode)
Recursively create directory path, but only if it resolves within the given base_path.