This patch implements the REST API's for POST /channels/{channelId}/play

and GET /playback/{playbackId}.

This allows an external application to initiate playback of a sound on a
channel while the channel is in the Stasis application.

/play commands are issued asynchronously, and return immediately with
the URL of the associated /playback resource. Playback commands queue up,
playing in succession. The /playback resource shows the state of a
playback operation as enqueued, playing or complete. (Although the
operation will only be in the 'complete' state for a very short time,
since it is almost immediately freed up).

(closes issue ASTERISK-21283)
(closes issue ASTERISK-21586)
Review: https://reviewboard.asterisk.org/r/2531/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389587 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-05-23 20:11:35 +00:00
parent 3464e0919a
commit 10ba6bf8a8
20 changed files with 906 additions and 97 deletions

View File

@@ -56,7 +56,8 @@ struct stasis_app_control *control_create(struct ast_channel *channel)
return NULL;
}
control->command_queue = ao2_container_alloc_list(0, 0, NULL, NULL);
control->command_queue = ao2_container_alloc_list(
AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL);
control->channel = channel;
@@ -75,10 +76,8 @@ static struct stasis_app_command *exec_command(
return NULL;
}
ao2_lock(control);
ao2_ref(command, +1);
/* command_queue is a thread safe list; no lock needed */
ao2_link(control->command_queue, command);
ao2_unlock(control);
ao2_ref(command, +1);
return command;
@@ -182,8 +181,6 @@ int control_dispatch_all(struct stasis_app_control *control,
struct ao2_iterator i;
void *obj;
SCOPED_AO2LOCK(lock, control);
ast_assert(control->channel == chan);
i = ao2_iterator_init(control->command_queue, AO2_ITERATOR_UNLINK);