52#define PLAYBACK_BUCKETS 127
55#define PLAYBACK_DEFAULT_SKIPMS 3000
57#define SOUND_URI_SCHEME "sound:"
58#define RECORDING_URI_SCHEME "recording:"
59#define NUMBER_URI_SCHEME "number:"
60#define DIGITS_URI_SCHEME "digits:"
61#define CHARACTERS_URI_SCHEME "characters:"
62#define TONE_URI_SCHEME "tone:"
104 if (!strcmp(
state,
"playing")) {
105 type =
"PlaybackStarted";
106 }
else if (!strcmp(
state,
"continuing")) {
107 type =
"PlaybackContinuing";
108 }
else if (!strcmp(
state,
"done")) {
109 type =
"PlaybackFinished";
110 }
else if (!strcmp(
state,
"failed")) {
111 type =
"PlaybackFinished";
179 const char *
id = flags &
OBJ_KEY ? obj : playback->
id;
187 const char *rhs_id = flags &
OBJ_KEY ? arg : rhs->
id;
189 if (strcmp(lhs->
id, rhs_id) == 0) {
245 const char *uniqueid)
252 uniqueid, playback->
media);
278 uniqueid, playback->
media);
281 uniqueid, playback->
media);
304 const char *fwd =
NULL;
305 const char *rev =
NULL;
307 const char *pause =
NULL;
308 const char *restart =
NULL;
340 const char *relname =
345 ast_log(
LOG_ERROR,
"Attempted to play recording '%s' on channel '%s' but recording does not exist",
359 ast_log(
LOG_ERROR,
"Attempted to play number '%s' on channel '%s' but number is invalid",
376 ast_log(
LOG_ERROR,
"Attempted to play URI '%s' on channel '%s' but scheme is unsupported\n",
408 const char *playback_id)
471 const char *target_id)
474 switch (target_type) {
490 size_t media_count,
const char *
language,
const char *target_id,
506 for (i = 0; i < media_count; i++) {
510 ast_log(
LOG_ERROR,
"Attempted to play media on channel '%s' but no media URI was provided.\n",
522 ast_debug(3,
"%s: Sending play(%s) command\n",
526 strcpy(media_uri,
media[i]);
577 if (playback ==
NULL) {
584 "media_uri", playback->
media,
585 "target_uri", playback->
target,
591 "media_uri", playback->
media,
593 "target_uri", playback->
target,
750 "Unhandled operation during playback: %u\n",
756 return cb(playback) ?
790 .
requires =
"res_stasis,res_stasis_recording"
Asterisk main include file. File version handling, generic pbx functions.
#define ast_malloc(len)
A wrapper for malloc()
#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.
#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.
#define ast_bridge_unlock(bridge)
Unlock the bridge.
#define ast_bridge_lock(bridge)
Lock the bridge.
int ast_bridge_channel_queue_playfile_sync(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
Synchronously queue a bridge action play file frame onto the bridge channel.
struct ast_bridge_channel * bridge_find_channel(struct ast_bridge *bridge, struct ast_channel *chan)
static char language[MAX_LANGUAGE]
static int hangup(void *data)
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
ast_channel_state
ast_channel states
Generic File Format Support. Should be included by clients of the file handling routines....
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.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_control_tone(struct ast_channel *chan, const char *tone)
Controls playback of a tone.
int ast_control_streamfile_lang(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, const char *lang, long *offsetms)
Version of ast_control_streamfile() which allows the language of the media file to be specified.
@ AST_CONTROL_STREAM_RESTART
@ AST_CONTROL_STREAM_SUSPEND
@ AST_CONTROL_STREAM_REVERSE
@ AST_CONTROL_STREAM_STOP
@ AST_CONTROL_STREAM_FORWARD
Support for logging to various files, console and syslog Configuration in file logger....
#define ast_debug(level,...)
Log a DEBUG message.
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_ref(struct ast_json *value)
Increase refcount on value.
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.
struct stasis_app_playback * stasis_app_playback_find_by_id(const char *id)
Finds the playback object with the given id.
static struct ast_json * playback_to_json(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
STASIS_MESSAGE_TYPE_DEFN(stasis_app_playback_snapshot_type,.to_json=playback_to_json,)
static struct ao2_container * playbacks
#define NUMBER_URI_SCHEME
static int playback_forward(struct stasis_app_playback *playback)
static int playback_first_update(struct stasis_app_playback *playback, const char *uniqueid)
int(* playback_operation_cb)(struct stasis_app_playback *playback)
static int playback_restart(struct stasis_app_playback *playback)
static int playback_unpause(struct stasis_app_playback *playback)
static int playback_cmp(void *obj, void *arg, int flags)
static int playback_hash(const void *obj, int flags)
static void play_on_channel(struct stasis_app_playback *playback, struct ast_channel *chan)
#define PLAYBACK_DEFAULT_SKIPMS
#define RECORDING_URI_SCHEME
struct stasis_app_playback * stasis_app_control_play_uri(struct stasis_app_control *control, const char **media, size_t media_count, const char *language, const char *target_id, enum stasis_app_playback_target_type target_type, int skipms, long offsetms, const char *id)
Play a file to the control's channel.
static struct stasis_app_playback * playback_create(struct stasis_app_control *control, const char *id)
static int playback_cancel(struct stasis_app_playback *playback)
struct ast_json * stasis_app_playback_to_json(const struct stasis_app_playback *playback)
Convert a playback to its JSON representation.
static int play_uri(struct stasis_app_control *control, struct ast_channel *chan, void *data)
static void set_target_uri(struct stasis_app_playback *playback, enum stasis_app_playback_target_type target_type, const char *target_id)
static void playback_final_update(struct stasis_app_playback *playback, long playedms, int res, int hangup, const char *uniqueid)
const char * stasis_app_playback_get_id(struct stasis_app_playback *control)
Gets the unique id of a playback object.
static void remove_from_playbacks(void *data)
RAII_VAR function to remove a playback from the global list when leaving scope.
static int playback_pause(struct stasis_app_playback *playback)
static int playback_noop(struct stasis_app_playback *playback)
static const char * state_to_string(enum stasis_app_playback_state state)
#define CHARACTERS_URI_SCHEME
#define DIGITS_URI_SCHEME
static int load_module(void)
static void playback_dtor(void *obj)
enum stasis_playback_oper_results stasis_app_playback_operation(struct stasis_app_playback *playback, enum stasis_app_playback_media_operation operation)
Controls the media for a given playback operation.
static int unload_module(void)
enum stasis_app_playback_state stasis_app_playback_get_state(struct stasis_app_playback *control)
Gets the current state of a playback operation.
static int playback_reverse(struct stasis_app_playback *playback)
static void playback_publish(struct stasis_app_playback *playback)
static int playback_stop(struct stasis_app_playback *playback)
static void play_on_channel_in_bridge(struct ast_bridge_channel *bridge_channel, const char *playback_id)
Special case code to play while a channel is in a bridge.
playback_operation_cb operations[STASIS_PLAYBACK_STATE_MAX][STASIS_PLAYBACK_MEDIA_OP_MAX]
A sparse array detailing how commands should be handled in the various playback states....
Say numbers and dates (maybe words one day too)
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
function to pronounce character and phonetic strings
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
says digits of a string
#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.
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 Playback API. See StasisApplication API" for detailed documentation.
stasis_app_playback_target_type
@ STASIS_PLAYBACK_TARGET_BRIDGE
@ STASIS_PLAYBACK_TARGET_CHANNEL
stasis_playback_oper_results
@ STASIS_PLAYBACK_OPER_NOT_PLAYING
@ STASIS_PLAYBACK_OPER_FAILED
@ STASIS_PLAYBACK_OPER_OK
stasis_app_playback_state
@ STASIS_PLAYBACK_STATE_STOPPED
@ STASIS_PLAYBACK_STATE_MAX
@ STASIS_PLAYBACK_STATE_FAILED
@ STASIS_PLAYBACK_STATE_COMPLETE
@ STASIS_PLAYBACK_STATE_CONTINUING
@ STASIS_PLAYBACK_STATE_PAUSED
@ STASIS_PLAYBACK_STATE_PLAYING
@ STASIS_PLAYBACK_STATE_CANCELED
@ STASIS_PLAYBACK_STATE_QUEUED
struct stasis_message_type * stasis_app_playback_snapshot_type(void)
Message type for playback updates. The data is an ast_channel_blob.
stasis_app_playback_media_operation
@ STASIS_PLAYBACK_RESTART
@ STASIS_PLAYBACK_FORWARD
@ STASIS_PLAYBACK_MEDIA_OP_MAX
@ STASIS_PLAYBACK_REVERSE
@ STASIS_PLAYBACK_UNPAUSE
Stasis Application Recording API. See StasisApplication API" for detailed documentation.
const char * stasis_app_stored_recording_get_file(struct stasis_app_stored_recording *recording)
Returns the filename for this recording, for use with streamfile.
struct stasis_app_stored_recording * stasis_app_stored_recording_find_by_name(const char *name)
Creates a stored recording object, with the given name.
#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 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)
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Structure that contains information regarding a channel in a bridge.
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_channel * chan
Structure that contains information about a bridge.
Blob of data associated with a channel.
Main Channel structure associated with a channel.
Abstract JSON element (object, array, string, int, ...).
const ast_string_field language
const ast_string_field media
const ast_string_field id
enum stasis_app_playback_state state
struct stasis_app_playback::@479 medias
const ast_string_field target
unsigned int controllable
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.
Universally unique identifier support.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.