mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 12:52:33 +00:00
ari: Add events for playback and recording.
While there were events defined for playback and recording these were not actually sent. This change implements the to_json handlers which produces them. (closes issue ASTERISK-22710) Reported by: Jonathan Rose Review: https://reviewboard.asterisk.org/r/3026/ ........ Merged revisions 403119 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -57,8 +57,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
#define SOUND_URI_SCHEME "sound:"
|
||||
#define RECORDING_URI_SCHEME "recording:"
|
||||
|
||||
STASIS_MESSAGE_TYPE_DEFN(stasis_app_playback_snapshot_type);
|
||||
|
||||
/*! Container of all current playbacks */
|
||||
static struct ao2_container *playbacks;
|
||||
|
||||
@@ -87,6 +85,32 @@ struct stasis_app_playback {
|
||||
enum stasis_app_playback_state state;
|
||||
};
|
||||
|
||||
static struct ast_json *playback_to_json(struct stasis_message *message,
|
||||
const struct stasis_message_sanitizer *sanitize)
|
||||
{
|
||||
struct ast_channel_blob *channel_blob = stasis_message_data(message);
|
||||
struct ast_json *blob = channel_blob->blob;
|
||||
const char *state =
|
||||
ast_json_string_get(ast_json_object_get(blob, "state"));
|
||||
const char *type;
|
||||
|
||||
if (!strcmp(state, "playing")) {
|
||||
type = "PlaybackStarted";
|
||||
} else if (!strcmp(state, "done")) {
|
||||
type = "PlaybackFinished";
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ast_json_pack("{s: s, s: O}",
|
||||
"type", type,
|
||||
"playback", blob);
|
||||
}
|
||||
|
||||
STASIS_MESSAGE_TYPE_DEFN(stasis_app_playback_snapshot_type,
|
||||
.to_json = playback_to_json,
|
||||
);
|
||||
|
||||
static void playback_dtor(void *obj)
|
||||
{
|
||||
struct stasis_app_playback *playback = obj;
|
||||
|
Reference in New Issue
Block a user