42#define RECORDING_BUCKETS 127
45#define RECORDING_COMMENT NULL
48#define RECORDING_CHECK 0
82 if (!strcmp(
state,
"recording")) {
83 type =
"RecordingStarted";
84 }
else if (!strcmp(
state,
"done") || !strcasecmp(
state,
"canceled")) {
85 type =
"RecordingFinished";
86 }
else if (!strcmp(
state,
"failed")) {
87 type =
"RecordingFailed";
175 if (strcasecmp(
str,
"none") == 0) {
179 if (strcasecmp(
str,
"any") == 0) {
183 if (strcasecmp(
str,
"#") == 0) {
187 if (strcasecmp(
str,
"*") == 0) {
202 if (strcasecmp(
str,
"fail") == 0) {
206 if (strcasecmp(
str,
"overwrite") == 0) {
210 if (strcasecmp(
str,
"append") == 0) {
232 if (!failure_cause) {
317 acceptdtmf =
"#*0123456789abcd";
322 acceptdtmf[1] =
'\0';
382 options->max_silence_seconds < 0 ||
383 options->max_duration_seconds < 0) {
388 ast_debug(3,
"%s: Sending record(%s.%s) command\n",
428 ast_log(
LOG_WARNING,
"Recording file '%s' already exists and ifExists option is failure.\n",
445 "Recording %s already in progress\n",
464 return recording->
state;
483 if (recording ==
NULL) {
552 if (recording->
muted == desired_mute_state) {
557 recording->
muted = desired_mute_state;
619 "Unhandled operation during recording: %u\n",
625 return cb(recording) ?
659 .
requires =
"res_stasis",
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_unlink_flags(container, obj, flags)
Remove an object from a container.
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
Convenient Signal Processing routines.
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
struct stasis_message * ast_channel_blob_create_from_cache(const char *uniqueid, struct stasis_message_type *type, struct ast_json *blob)
Create a ast_channel_blob message, pulling channel state from the cache.
int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Record a file based on input from a channel This function will play "auth-thankyou" upon successful r...
@ AST_RECORD_IF_EXISTS_FAIL
@ AST_RECORD_IF_EXISTS_APPEND
@ AST_RECORD_IF_EXISTS_OVERWRITE
@ AST_RECORD_IF_EXISTS_ERROR
@ AST_CONTROL_RECORD_CANCEL
@ AST_CONTROL_RECORD_STOP
@ AST_CONTROL_RECORD_MUTE
@ AST_CONTROL_RECORD_SUSPEND
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_RECORDING_DIR
struct stasis_app_recording_options * stasis_app_recording_options_create(const char *name, const char *format)
Allocate a recording options object.
static void recording_cleanup(void *data)
static int recording_unpause(struct stasis_app_recording *recording)
static int recording_pause(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_noop(struct stasis_app_recording *recording)
struct ast_json * stasis_app_recording_to_json(const struct stasis_app_recording *recording)
Construct a JSON model of a recording.
static void recording_options_dtor(void *obj)
static void recording_dtor(void *obj)
static int recording_disregard(struct stasis_app_recording *recording)
enum stasis_app_recording_state stasis_app_recording_get_state(struct stasis_app_recording *recording)
Gets the current state of a recording operation.
static int recording_hash(const void *obj, int flags)
static int recording_mute(struct stasis_app_recording *recording)
static int recording_unmute(struct stasis_app_recording *recording)
static int record_file(struct stasis_app_control *control, struct ast_channel *chan, void *data)
STASIS_MESSAGE_TYPE_DEFN(stasis_app_recording_snapshot_type,.to_json=recording_to_json,)
struct stasis_app_recording * stasis_app_recording_find_by_name(const char *name)
Finds the recording object with the given name.
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.
int(* recording_operation_cb)(struct stasis_app_recording *recording)
#define RECORDING_BUCKETS
recording_operation_cb operations[STASIS_APP_RECORDING_STATE_MAX][STASIS_APP_RECORDING_OPER_MAX]
static struct stasis_app_control_rule rule_recording
static enum stasis_app_control_channel_result check_rule_recording(const struct stasis_app_control *control)
struct stasis_app_recording * stasis_app_control_record(struct stasis_app_control *control, struct stasis_app_recording_options *options)
Record media from a channel.
static struct ao2_container * recordings
static int recording_cmp(void *obj, void *arg, int flags)
enum ast_record_if_exists stasis_app_recording_if_exists_parse(const char *str)
Parse a string into the if_exists enum.
static int toggle_recording_mute(struct stasis_app_recording *recording, int desired_mute_state)
char stasis_app_recording_termination_parse(const char *str)
Parse a string into the recording termination enum.
static int load_module(void)
static void recording_fail(struct stasis_app_control *control, struct stasis_app_recording *recording, const char *cause)
static int recording_stop(struct stasis_app_recording *recording)
static void recording_set_state(struct stasis_app_recording *recording, enum stasis_app_recording_state state, const char *cause)
static int unload_module(void)
const char * stasis_app_recording_get_name(struct stasis_app_recording *recording)
Gets the unique name of a recording object.
static const char * state_to_string(enum stasis_app_recording_state state)
static int recording_cancel(struct stasis_app_recording *recording)
static void recording_publish(struct stasis_app_recording *recording, const char *cause)
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
const char * stasis_app_control_get_channel_id(const struct stasis_app_control *control)
Returns the uniqueid of the channel associated with this control.
int stasis_app_control_queue_control(struct stasis_app_control *control, enum ast_control_frame_type frame_type)
Queue a control frame without payload.
void stasis_app_control_publish(struct stasis_app_control *control, struct stasis_message *message)
Publish a message to the control's channel's topic.
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
void stasis_app_control_unregister_add_rule(struct stasis_app_control *control, struct stasis_app_control_rule *rule)
UnRegister an add channel to bridge rule.
void stasis_app_control_register_add_rule(struct stasis_app_control *control, struct stasis_app_control_rule *rule)
Registers an add channel to bridge rule.
stasis_app_control_channel_result
Result codes used when adding/removing channels to/from bridges.
@ STASIS_APP_CHANNEL_RECORDING
Backend API for implementing components of res_stasis.
int stasis_app_send_command_async(struct stasis_app_control *control, stasis_app_command_cb command, void *data, command_data_destructor_fn data_destructor)
Asynchronous version of stasis_app_send_command().
Stasis Application Recording API. See StasisApplication API" for detailed documentation.
struct stasis_message_type * stasis_app_recording_snapshot_type(void)
Message type for recording updates. The data is an ast_channel_blob.
#define STASIS_APP_RECORDING_TERMINATE_NONE
#define STASIS_APP_RECORDING_TERMINATE_ANY
stasis_app_recording_oper_results
Possible results from a recording operation.
@ STASIS_APP_RECORDING_OPER_NOT_RECORDING
@ STASIS_APP_RECORDING_OPER_FAILED
@ STASIS_APP_RECORDING_OPER_OK
stasis_app_recording_state
@ STASIS_APP_RECORDING_STATE_CANCELED
@ STASIS_APP_RECORDING_STATE_FAILED
@ STASIS_APP_RECORDING_STATE_COMPLETE
@ STASIS_APP_RECORDING_STATE_RECORDING
@ STASIS_APP_RECORDING_STATE_PAUSED
@ STASIS_APP_RECORDING_STATE_QUEUED
@ STASIS_APP_RECORDING_STATE_MAX
#define STASIS_APP_RECORDING_TERMINATE_INVALID
stasis_app_recording_media_operation
@ STASIS_APP_RECORDING_PAUSE
@ STASIS_APP_RECORDING_UNPAUSE
@ STASIS_APP_RECORDING_UNMUTE
@ STASIS_APP_RECORDING_STOP
@ STASIS_APP_RECORDING_OPER_MAX
@ STASIS_APP_RECORDING_MUTE
@ STASIS_APP_RECORDING_CANCEL
#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_free_memory(x)
free all memory - to be called before destroying the object
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Blob of data associated with a channel.
Main Channel structure associated with a channel.
Abstract JSON element (object, array, string, int, ...).
Rule to check to see if an operation is allowed.
enum stasis_app_control_channel_result(* check_rule)(const struct stasis_app_control *control)
Checks to see if an operation is allowed on the control.
enum ast_record_if_exists if_exists
const ast_string_field target
const ast_string_field name
const ast_string_field format
struct stasis_app_recording::@480 duration
struct stasis_app_recording_options * options
enum stasis_app_recording_state state
struct stasis_app_control * control
Structure containing callbacks for Stasis message sanitization.
#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.