diff options
author | Joshua Colp <jcolp@digium.com> | 2013-11-23 12:52:54 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-11-23 12:52:54 +0000 |
commit | 14a74529344ef5229f100c81bc969f34e27112b3 (patch) | |
tree | 42d11fb48fe467f013a14a0b8ae05c77cc21de8d /res/res_stasis_playback.c | |
parent | eda712686268daaaf02754fbb0903cf4f973da87 (diff) |
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
Diffstat (limited to 'res/res_stasis_playback.c')
-rw-r--r-- | res/res_stasis_playback.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c index f112e8b25..f78ccf0ba 100644 --- a/res/res_stasis_playback.c +++ b/res/res_stasis_playback.c @@ -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; |