ARI: Add the ability to play multiple media URIs in a single operation

Many ARI applications will want to play multiple media files in a row to
a resource. The most common use case is when building long-ish IVR prompts
made up of multiple, smaller sound files. Today, that requires building a
small state machine, listening for each PlaybackFinished event, and triggering
the next sound file to play. While not especially challenging, it is tedious
work. Since requiring developers to write tedious code to do normal activities
stinks, this patch adds the ability to play back a list of media files to a
resource.

Each of the 'play' operations on supported resources (channels and bridges)
now accepts a comma delineated list of media URIs to play. A single Playback
resource is created as a handle to the entire list. The operation of playing
a list is identical to playing a single media URI, save that a new event,
PlaybackContinuing, is raised instead of a PlaybackFinished for each non-final
media URI. When the entire list is finished being played, a PlaybackFinished
event is raised.

In order to help inform applications where they are in the list playback, the
Playback resource now includes a new, optional attribute, 'next_media_uri',
that contains the next URI in the list to be played.

It's important to note the following:
 - If an offset is provided to the 'play' operations, it only applies to the
   first media URI, as it would be weird to skip n seconds forward in every
   media resource.
 - Operations that control the position of the media only affect the current
   media being played. For example, once a media resource in the list
   completes, a 'reverse' operation on a subsequent media resource will not
   start a previously completed media resource at the appropiate offset.
 - This patch does not add any new operations to control the list. Hopefully,
   user feedback and/or future patches would add that if people want it.

ASTERISK-26022 #close

Change-Id: Ie1ea5356573447b8f51f2e7964915ea01792f16f
This commit is contained in:
Matt Jordan
2016-04-18 18:17:08 -05:00
committed by Joshua Colp
parent 040522100b
commit 03d88b5656
15 changed files with 643 additions and 126 deletions

View File

@@ -328,10 +328,10 @@
},
{
"name": "media",
"description": "Media's URI to play.",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": false,
"allowMultiple": true,
"dataType": "string"
},
{
@@ -344,7 +344,7 @@
},
{
"name": "offsetms",
"description": "Number of media to skip before playing.",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,
@@ -420,10 +420,10 @@
},
{
"name": "media",
"description": "Media's URI to play.",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": false,
"allowMultiple": true,
"dataType": "string"
},
{
@@ -436,7 +436,7 @@
},
{
"name": "offsetms",
"description": "Number of media to skip before playing.",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,

View File

@@ -973,10 +973,10 @@
},
{
"name": "media",
"description": "Media's URI to play.",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": false,
"allowMultiple": true,
"dataType": "string"
},
{
@@ -989,7 +989,7 @@
},
{
"name": "offsetms",
"description": "Number of media to skip before playing.",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,
@@ -1055,10 +1055,10 @@
},
{
"name": "media",
"description": "Media's URI to play.",
"description": "Media URIs to play.",
"paramType": "query",
"required": true,
"allowMultiple": false,
"allowMultiple": true,
"dataType": "string"
},
{
@@ -1071,7 +1071,7 @@
},
{
"name": "offsetms",
"description": "Number of media to skip before playing.",
"description": "Number of milliseconds to skip before playing. Only applies to the first URI if multiple media URIs are specified.",
"paramType": "query",
"required": false,
"allowMultiple": false,

View File

@@ -146,6 +146,7 @@
"subTypes": [
"DeviceStateChanged",
"PlaybackStarted",
"PlaybackContinuing",
"PlaybackFinished",
"RecordingStarted",
"RecordingFinished",
@@ -270,6 +271,17 @@
}
}
},
"PlaybackContinuing": {
"id": "PlaybackContinuing",
"description": "Event showing the continuation of a media playback operation from one media URI to the next in the list.",
"properties": {
"playback": {
"type": "Playback",
"description": "Playback control object",
"required": true
}
}
},
"PlaybackFinished": {
"id": "PlaybackFinished",
"description": "Event showing the completion of a media playback operation.",

View File

@@ -124,9 +124,14 @@
},
"media_uri": {
"type": "string",
"description": "URI for the media to play back.",
"description": "The URI for the media currently being played back.",
"required": true
},
"next_media_uri": {
"type": "string",
"description": "If a list of URIs is being played, the next media URI to be played back.",
"required": false
},
"target_uri": {
"type": "string",
"description": "URI for the channel or bridge to play the media on",
@@ -145,7 +150,8 @@
"values": [
"queued",
"playing",
"complete"
"continuing",
"done"
]
}
}