Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
res_stasis recording support. More...
#include "asterisk.h"
#include "asterisk/dsp.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
#include "asterisk/stasis_app_impl.h"
#include "asterisk/stasis_app_recording.h"
#include "asterisk/stasis_channels.h"
Go to the source code of this file.
Data Structures | |
struct | stasis_app_recording |
Macros | |
#define | RECORDING_BUCKETS 127 |
#define | RECORDING_CHECK 0 |
#define | RECORDING_COMMENT NULL |
Typedefs | |
typedef int(* | recording_operation_cb) (struct stasis_app_recording *recording) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static enum stasis_app_control_channel_result | check_rule_recording (const struct stasis_app_control *control) |
static int | load_module (void) |
static int | record_file (struct stasis_app_control *control, struct ast_channel *chan, void *data) |
static int | recording_cancel (struct stasis_app_recording *recording) |
static void | recording_cleanup (void *data) |
static int | recording_cmp (void *obj, void *arg, int flags) |
static int | recording_disregard (struct stasis_app_recording *recording) |
static void | recording_dtor (void *obj) |
static void | recording_fail (struct stasis_app_control *control, struct stasis_app_recording *recording, const char *cause) |
static int | recording_hash (const void *obj, int flags) |
static int | recording_mute (struct stasis_app_recording *recording) |
static int | recording_noop (struct stasis_app_recording *recording) |
static void | recording_options_dtor (void *obj) |
static int | recording_pause (struct stasis_app_recording *recording) |
static void | recording_publish (struct stasis_app_recording *recording, const char *cause) |
static void | recording_set_state (struct stasis_app_recording *recording, enum stasis_app_recording_state state, const char *cause) |
static int | recording_stop (struct stasis_app_recording *recording) |
static struct ast_json * | recording_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize) |
static int | recording_unmute (struct stasis_app_recording *recording) |
static int | recording_unpause (struct stasis_app_recording *recording) |
struct stasis_app_recording * | stasis_app_control_record (struct stasis_app_control *control, struct stasis_app_recording_options *options) |
Record media from a channel. More... | |
struct stasis_app_recording * | stasis_app_recording_find_by_name (const char *name) |
Finds the recording object with the given name. More... | |
const char * | stasis_app_recording_get_name (struct stasis_app_recording *recording) |
Gets the unique name of a recording object. More... | |
enum stasis_app_recording_state | stasis_app_recording_get_state (struct stasis_app_recording *recording) |
Gets the current state of a recording operation. More... | |
enum ast_record_if_exists | stasis_app_recording_if_exists_parse (const char *str) |
Parse a string into the if_exists enum. More... | |
enum stasis_app_recording_oper_results | stasis_app_recording_operation (struct stasis_app_recording *recording, enum stasis_app_recording_media_operation operation) |
Controls the media for a given recording operation. More... | |
struct stasis_app_recording_options * | stasis_app_recording_options_create (const char *name, const char *format) |
Allocate a recording options object. More... | |
char | stasis_app_recording_termination_parse (const char *str) |
Parse a string into the recording termination enum. More... | |
struct ast_json * | stasis_app_recording_to_json (const struct stasis_app_recording *recording) |
Construct a JSON model of a recording. More... | |
STASIS_MESSAGE_TYPE_DEFN (stasis_app_recording_snapshot_type,.to_json=recording_to_json,) | |
static const char * | state_to_string (enum stasis_app_recording_state state) |
static int | toggle_recording_mute (struct stasis_app_recording *recording, int desired_mute_state) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Stasis application recording support" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis", .load_pri = AST_MODPRI_APP_DEPEND } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
recording_operation_cb | operations [STASIS_APP_RECORDING_STATE_MAX][STASIS_APP_RECORDING_OPER_MAX] |
static struct ao2_container * | recordings |
static struct stasis_app_control_rule | rule_recording |
res_stasis recording support.
Definition in file res_stasis_recording.c.
#define RECORDING_BUCKETS 127 |
Number of hash buckets for recording container. Keep it prime!
Definition at line 42 of file res_stasis_recording.c.
#define RECORDING_CHECK 0 |
Recording check is unimplemented. le sigh
Definition at line 48 of file res_stasis_recording.c.
#define RECORDING_COMMENT NULL |
Comment is ignored by most formats, so we will ignore it, too.
Definition at line 45 of file res_stasis_recording.c.
typedef int(* recording_operation_cb) (struct stasis_app_recording *recording) |
Definition at line 506 of file res_stasis_recording.c.
|
static |
Definition at line 661 of file res_stasis_recording.c.
|
static |
Definition at line 661 of file res_stasis_recording.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 661 of file res_stasis_recording.c.
|
static |
Definition at line 261 of file res_stasis_recording.c.
References STASIS_APP_CHANNEL_RECORDING.
|
static |
Definition at line 629 of file res_stasis_recording.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, NULL, RECORDING_BUCKETS, recording_cmp(), recording_hash(), recordings, stasis_app_recording_snapshot_type(), STASIS_MESSAGE_TYPE_CLEANUP, and STASIS_MESSAGE_TYPE_INIT.
|
static |
Definition at line 296 of file res_stasis_recording.c.
References stasis_app_recording::absolute_name, ast_alloca, ast_assert, ast_auto_answer(), ast_channel_uniqueid(), ast_debug, ast_log, ast_play_and_record_full(), stasis_app_recording_options::beep, stasis_app_recording::control, stasis_app_recording::duration, stasis_app_recording::energy_only, stasis_app_recording_options::format, stasis_app_recording_options::if_exists, LOG_ERROR, stasis_app_recording_options::max_duration_seconds, stasis_app_recording_options::max_silence_seconds, NULL, stasis_app_recording::options, recording_fail(), recording_set_state(), rule_recording, stasis_app_control_unregister_add_rule(), stasis_app_get_bridge(), STASIS_APP_RECORDING_STATE_COMPLETE, STASIS_APP_RECORDING_STATE_RECORDING, STASIS_APP_RECORDING_TERMINATE_ANY, STASIS_APP_RECORDING_TERMINATE_INVALID, STASIS_APP_RECORDING_TERMINATE_NONE, stasis_app_recording_options::terminate_on, and stasis_app_recording::total.
Referenced by stasis_app_control_record().
|
static |
Definition at line 519 of file res_stasis_recording.c.
References stasis_app_recording::absolute_name, AST_CONTROL_RECORD_CANCEL, ast_filedelete(), stasis_app_recording::control, NULL, stasis_app_control_queue_control(), STASIS_APP_RECORDING_STATE_CANCELED, and stasis_app_recording::state.
|
static |
Definition at line 287 of file res_stasis_recording.c.
References ao2_ref, ao2_unlink_flags, OBJ_NODATA, OBJ_POINTER, OBJ_UNLINK, and recordings.
Referenced by stasis_app_control_record().
|
static |
Definition at line 109 of file res_stasis_recording.c.
References CMP_MATCH, CMP_STOP, stasis_app_recording_options::name, OBJ_KEY, and stasis_app_recording::options.
Referenced by load_module().
|
static |
Definition at line 513 of file res_stasis_recording.c.
References STASIS_APP_RECORDING_STATE_CANCELED, and stasis_app_recording::state.
|
static |
Definition at line 361 of file res_stasis_recording.c.
References stasis_app_recording::absolute_name, ao2_cleanup, ast_free, stasis_app_recording::control, and stasis_app_recording::options.
Referenced by stasis_app_control_record().
|
static |
Definition at line 277 of file res_stasis_recording.c.
References recording_set_state(), rule_recording, stasis_app_control_unregister_add_rule(), and STASIS_APP_RECORDING_STATE_FAILED.
Referenced by record_file().
|
static |
Definition at line 102 of file res_stasis_recording.c.
References ast_str_hash(), stasis_app_recording_options::name, OBJ_KEY, and stasis_app_recording::options.
Referenced by load_module().
|
static |
Definition at line 563 of file res_stasis_recording.c.
References toggle_recording_mute().
|
static |
Definition at line 508 of file res_stasis_recording.c.
|
static |
Definition at line 144 of file res_stasis_recording.c.
References ast_string_field_free_memory, and options.
Referenced by stasis_app_recording_options_create().
|
static |
Definition at line 536 of file res_stasis_recording.c.
References AST_CONTROL_RECORD_SUSPEND, stasis_app_recording::control, stasis_app_control_queue_control(), STASIS_APP_RECORDING_STATE_PAUSED, and stasis_app_recording::state.
|
static |
Definition at line 217 of file res_stasis_recording.c.
References ao2_cleanup, ast_assert, ast_channel_blob_create_from_cache(), ast_json_object_set(), ast_json_string_create(), ast_json_unref(), ast_strlen_zero(), stasis_app_recording::control, NULL, RAII_VAR, stasis_app_control_get_channel_id(), stasis_app_control_publish(), stasis_app_recording_snapshot_type(), and stasis_app_recording_to_json().
Referenced by recording_set_state().
|
static |
Definition at line 252 of file res_stasis_recording.c.
References lock, recording_publish(), SCOPED_AO2LOCK, state, and stasis_app_recording::state.
Referenced by record_file(), and recording_fail().
|
static |
Definition at line 529 of file res_stasis_recording.c.
References AST_CONTROL_RECORD_STOP, stasis_app_recording::control, stasis_app_control_queue_control(), STASIS_APP_RECORDING_STATE_COMPLETE, and stasis_app_recording::state.
|
static |
Definition at line 73 of file res_stasis_recording.c.
References ast_json_object_get(), ast_json_pack(), ast_json_string_get(), ast_json_timeval(), ast_channel_blob::blob, NULL, stasis_message_data(), stasis_message_timestamp(), and type.
|
static |
Definition at line 568 of file res_stasis_recording.c.
References toggle_recording_mute().
|
static |
Definition at line 543 of file res_stasis_recording.c.
References AST_CONTROL_RECORD_SUSPEND, stasis_app_recording::control, stasis_app_control_queue_control(), STASIS_APP_RECORDING_STATE_RECORDING, and stasis_app_recording::state.
struct stasis_app_recording * stasis_app_control_record | ( | struct stasis_app_control * | control, |
struct stasis_app_recording_options * | options | ||
) |
Record media from a channel.
A reference to the options object may be kept, so it MUST NOT be modified after calling this function.
On error, errno
is set to indicate the failure reason.
EINVAL:
Invalid input.EEXIST:
A recording with that name is in session.ENOMEM:
Out of memory.control | Control for res_stasis . |
options | Recording options. |
NULL | on error. |
Definition at line 370 of file res_stasis_recording.c.
References stasis_app_recording::absolute_name, ao2_alloc, ao2_bump, ao2_cleanup, ao2_find, ao2_link, ao2_ref, ast_asprintf, ast_config_AST_RECORDING_DIR, ast_debug, ast_fileexists(), ast_log, AST_RECORD_IF_EXISTS_FAIL, ast_safe_mkdir(), ast_strlen_zero(), stasis_app_recording::control, stasis_app_recording::duration, stasis_app_recording::energy_only, errno, stasis_app_recording_options::if_exists, lock, LOG_WARNING, stasis_app_recording_options::name, NULL, OBJ_KEY, OBJ_NOLOCK, stasis_app_recording::options, options, RAII_VAR, record_file(), recording_cleanup(), recording_dtor(), recordings, rule_recording, SCOPED_AO2LOCK, stasis_app_control_get_channel_id(), stasis_app_control_register_add_rule(), STASIS_APP_RECORDING_STATE_QUEUED, stasis_app_send_command_async(), stasis_app_recording::state, and stasis_app_recording::total.
Referenced by ast_ari_bridges_record(), and ast_ari_channels_record().
struct stasis_app_recording * stasis_app_recording_find_by_name | ( | const char * | name | ) |
Finds the recording object with the given name.
name | Name of the recording object to find. |
NULL | if name not found. |
Definition at line 473 of file res_stasis_recording.c.
References ao2_find, name, OBJ_KEY, and recordings.
Referenced by ast_ari_recordings_get_live(), and control_recording().
const char * stasis_app_recording_get_name | ( | struct stasis_app_recording * | recording | ) |
Gets the unique name of a recording object.
recording | Recording control object. |
NULL | if recording ic NULL |
Definition at line 467 of file res_stasis_recording.c.
References stasis_app_recording_options::name, and stasis_app_recording::options.
enum stasis_app_recording_state stasis_app_recording_get_state | ( | struct stasis_app_recording * | recording | ) |
Gets the current state of a recording operation.
recording | Recording control object. |
Definition at line 461 of file res_stasis_recording.c.
References stasis_app_recording::state.
enum ast_record_if_exists stasis_app_recording_if_exists_parse | ( | const char * | str | ) |
Parse a string into the if_exists enum.
str | String to parse. |
Definition at line 194 of file res_stasis_recording.c.
References AST_RECORD_IF_EXISTS_APPEND, AST_RECORD_IF_EXISTS_ERROR, AST_RECORD_IF_EXISTS_FAIL, AST_RECORD_IF_EXISTS_OVERWRITE, ast_strlen_zero(), and str.
Referenced by ast_ari_bridges_record(), and ast_ari_channels_record().
enum stasis_app_recording_oper_results stasis_app_recording_operation | ( | struct stasis_app_recording * | recording, |
enum stasis_app_recording_media_operation | operation | ||
) |
Controls the media for a given recording operation.
recording | Recording control object. |
operation | Media control operation. |
STASIS_APP_RECORDING_OPER_OK | on success. |
Definition at line 590 of file res_stasis_recording.c.
References ast_log, lock, LOG_ERROR, LOG_WARNING, operations, SCOPED_AO2LOCK, STASIS_APP_RECORDING_OPER_FAILED, STASIS_APP_RECORDING_OPER_MAX, STASIS_APP_RECORDING_OPER_NOT_RECORDING, STASIS_APP_RECORDING_OPER_OK, STASIS_APP_RECORDING_STATE_MAX, STASIS_APP_RECORDING_STATE_RECORDING, and stasis_app_recording::state.
Referenced by control_recording().
struct stasis_app_recording_options * stasis_app_recording_options_create | ( | const char * | name, |
const char * | format | ||
) |
Allocate a recording options object.
Clean up with ao2_cleanup().
name | Name of the recording. |
format | Format to record in. |
NULL | on error. |
Definition at line 151 of file res_stasis_recording.c.
References ao2_alloc, ao2_cleanup, ao2_ref, ast_string_field_init, ast_string_field_set, stasis_app_recording_options::format, name, NULL, options, RAII_VAR, and recording_options_dtor().
Referenced by ast_ari_bridges_record(), and ast_ari_channels_record().
char stasis_app_recording_termination_parse | ( | const char * | str | ) |
Parse a string into the recording termination enum.
str | String to parse. |
STASIS_APP_RECORDING_TERMINATE_NONE | to not terminate on DTMF. |
STASIS_APP_RECORDING_TERMINATE_ANY | to terminate on any DTMF. |
STASIS_APP_RECORDING_TERMINATE_INVALID | if input was invalid. |
Definition at line 169 of file res_stasis_recording.c.
References ast_strlen_zero(), STASIS_APP_RECORDING_TERMINATE_ANY, STASIS_APP_RECORDING_TERMINATE_INVALID, STASIS_APP_RECORDING_TERMINATE_NONE, and str.
Referenced by ast_ari_bridges_record(), and ast_ari_channels_record().
struct ast_json * stasis_app_recording_to_json | ( | const struct stasis_app_recording * | recording | ) |
Construct a JSON model of a recording.
recording | Recording to conver. |
NULL | on error. |
Definition at line 478 of file res_stasis_recording.c.
References ast_json_integer_create(), ast_json_object_set(), ast_json_pack(), ast_json_ref(), ast_json_unref(), stasis_app_recording::duration, stasis_app_recording::energy_only, stasis_app_recording_options::format, stasis_app_recording_options::name, NULL, stasis_app_recording::options, RAII_VAR, stasis_app_recording::state, state_to_string(), stasis_app_recording_options::target, and stasis_app_recording::total.
Referenced by ast_ari_bridges_record(), ast_ari_channels_record(), ast_ari_recordings_get_live(), and recording_publish().
STASIS_MESSAGE_TYPE_DEFN | ( | stasis_app_recording_snapshot_type | , |
. | to_json = recording_to_json |
||
) |
|
static |
Definition at line 122 of file res_stasis_recording.c.
References STASIS_APP_RECORDING_STATE_CANCELED, STASIS_APP_RECORDING_STATE_COMPLETE, STASIS_APP_RECORDING_STATE_FAILED, STASIS_APP_RECORDING_STATE_MAX, STASIS_APP_RECORDING_STATE_PAUSED, STASIS_APP_RECORDING_STATE_QUEUED, and STASIS_APP_RECORDING_STATE_RECORDING.
Referenced by stasis_app_recording_to_json().
|
static |
Definition at line 550 of file res_stasis_recording.c.
References AST_CONTROL_RECORD_MUTE, stasis_app_recording::control, stasis_app_recording::muted, and stasis_app_control_queue_control().
Referenced by recording_mute(), and recording_unmute().
|
static |
Definition at line 647 of file res_stasis_recording.c.
References ao2_cleanup, NULL, recordings, stasis_app_recording_snapshot_type(), and STASIS_MESSAGE_TYPE_CLEANUP.
|
static |
Definition at line 661 of file res_stasis_recording.c.
|
static |
Definition at line 661 of file res_stasis_recording.c.
Definition at line 573 of file res_stasis_recording.c.
Referenced by stasis_app_recording_operation().
|
static |
Container of all current recordings
Definition at line 51 of file res_stasis_recording.c.
Referenced by load_module(), recording_cleanup(), stasis_app_control_record(), stasis_app_recording_find_by_name(), and unload_module().
|
static |
Definition at line 273 of file res_stasis_recording.c.
Referenced by record_file(), recording_fail(), and stasis_app_control_record().