Skip to content

Commit 2218083

Browse files
authored
Merge pull request #207 from opentok/add-multiple-archives-and-broadcasts
enabled multiArchive and multiBroadcast options for start_archive and…
2 parents 290fdef + bd60d1a commit 2218083

File tree

3 files changed

+98
-4
lines changed

3 files changed

+98
-4
lines changed

README.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ Warning: This value cannot be set for Individual output mode, an error will be t
160160
# Store this archive_id in the database
161161
archive_id = archive.id
162162
163+
You can enable multiple simultaneous archives by specifying a unique value for the ``multi_archive_tag``
164+
parameter in the ``start_archive`` method.
165+
166+
.. code:: python
167+
168+
archive = opentok.start_archive(session_id, name=u'Important Presentation', multi_archive_tag='MyArchiveTag')
169+
163170
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
164171
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
165172

@@ -403,6 +410,36 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser
403410
404411
broadcast = opentok.start_broadcast(session_id, options)
405412
413+
To enable multiple simultaneous broadcasts on the same session, specify a unique value for the
414+
``multiBroadcastTag`` parameter in ``options`` when calling the ``opentok.start_broadcast`` method.
415+
416+
.. code:: python
417+
418+
session_id = 'SESSIONID'
419+
options = {
420+
'multiBroadcastTag': 'unique_broadcast_tag'
421+
'layout': {
422+
'type': 'custom',
423+
'stylesheet': 'the layout stylesheet (only used with type == custom)'
424+
},
425+
'maxDuration': 5400,
426+
'outputs': {
427+
'hls': {},
428+
'rtmp': [{
429+
'id': 'foo',
430+
'serverUrl': 'rtmp://myfooserver/myfooapp',
431+
'streamName': 'myfoostream'
432+
}, {
433+
'id': 'bar',
434+
'serverUrl': 'rtmp://mybarserver/mybarapp',
435+
'streamName': 'mybarstream'
436+
}]
437+
},
438+
'resolution': '640x480'
439+
}
440+
441+
broadcast = opentok.start_broadcast(session_id, options)
442+
406443
You can stop a started Broadcast using the ``opentok.stop_broadcast(broadcast_id)`` method.
407444

408445
.. code:: python

opentok/broadcast.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,53 @@ class Broadcast(object):
77
"""
88
Represents a live streaming broadcast.
99
10+
:ivar id:
11+
The broadcast ID.
12+
13+
:ivar session_id:
14+
The session ID of the OpenTok session associated with this broadcast.
15+
16+
:ivar project_id:
17+
Your OpenTok API key.
18+
19+
:ivar created_at:
20+
The time at which the broadcast was created, in milliseconds since the UNIX epoch.
21+
22+
:ivar updated_at:
23+
The time at which the broadcast was last updated, in milliseconds since the UNIX epoch.
24+
25+
:ivar resolution:
26+
The resolution of the broadcast (either "640x480", "1280x720", "1920x1080", "480x640", "720x1280", or "1920x1080").
27+
28+
:ivar status:
29+
The status of the broadcast.
30+
31+
:ivar broadcastUrls:
32+
An object containing details about the HLS and RTMP broadcasts.
33+
34+
If you specified an HLS endpoint, the object includes an hls property, which is set to the URL for the HLS broadcast.
35+
Note this HLS broadcast URL points to an index file, an .M3U8-formatted playlist that contains a list of URLs
36+
to .ts media segment files (MPEG-2 transport stream files).
37+
While the URLs of both the playlist index file and media segment files are provided as soon as the HTTP response
38+
is returned, these URLs should not be accessed until 15 - 20 seconds later,
39+
after the initiation of the HLS broadcast, due to the delay between the HLS broadcast and the live streams
40+
in the OpenTok session.
41+
See https://developer.apple.com/library/ios/technotes/tn2288/_index.html for more information about the playlist index
42+
file and media segment files for HLS.
43+
44+
If you specified RTMP stream endpoints, the object includes an rtmp property.
45+
This is an array of objects that include information on each of the RTMP streams.
46+
Each of these objects has the following properties: id (the ID you assigned to the RTMP stream),
47+
serverUrl (the server URL), streamName (the stream name), and status property (which is set to "connecting").
48+
You can call the OpenTok REST method to check for status updates for the broadcast:
49+
https://tokbox.com/developer/rest/#get_info_broadcast
50+
1051
:ivar streamMode:
1152
Whether streams included in the broadcast are selected automatically
1253
("auto", the default) or manually ("manual").
13-
54+
1455
:ivar streams:
15-
A list of streams currently being broadcast. This is only set for a broadcast with
56+
A list of streams currently being broadcasted. This is only set for a broadcast with
1657
the status set to "started" and the stream_Mode set to "manual".
1758
"""
1859

opentok/opentok.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ def start_archive(
484484
output_mode=OutputModes.composed,
485485
stream_mode=StreamModes.auto,
486486
resolution=None,
487-
layout=None
487+
layout=None,
488+
multi_archive_tag=None
488489
):
489490
"""
490491
Starts archiving an OpenTok session.
@@ -535,6 +536,14 @@ def start_archive(
535536
StreamModes.manual to explicitly select streams to include in the the archive, using the
536537
OpenTok.add_archive_stream() and OpenTok.remove_archive_stream() methods.
537538
539+
:param String multi_archive_tag (Optional): Set this to support recording multiple archives for the same
540+
session simultaneously. Set this to a unique string for each simultaneous archive of an ongoing session.
541+
You must also set this option when manually starting an archive that is automatically archived.
542+
Note that the multiArchiveTag value is not included in the response for the methods to list archives and
543+
retrieve archive information. If you do not specify a unique multi_archive_tag, you can only record one archive
544+
at a time for a given session.
545+
For more information, see simultaneous archives: https://tokbox.com/developer/guides/archiving/#simultaneous-archives.
546+
538547
:rtype: The Archive object, which includes properties defining the archive,
539548
including the archive ID.
540549
"""
@@ -559,7 +568,8 @@ def start_archive(
559568
"hasVideo": has_video,
560569
"outputMode": output_mode.value,
561570
"resolution": resolution,
562-
"streamMode": stream_mode.value
571+
"streamMode": stream_mode.value,
572+
"multiArchiveTag": multi_archive_tag
563573
}
564574

565575
if layout is not None:
@@ -1314,6 +1324,12 @@ def start_broadcast(self, session_id, options, stream_mode=BroadcastStreamModes.
13141324
String 'resolution' optional: The resolution of the broadcast, either "640x480"
13151325
(SD, the default) or "1280x720" (HD)
13161326
1327+
String 'multiBroadcastTag' optional: Set this to support multiple broadcasts for the same session simultaneously.
1328+
Set this to a unique string for each simultaneous broadcast of an ongoing session.
1329+
Note that the multiBroadcastTag value is not included in the response for the methods to list live streaming
1330+
broadcasts and get information about a live streaming broadcast.
1331+
For more information, see https://tokbox.com/developer/guides/broadcast/live-streaming#simultaneous-broadcasts.
1332+
13171333
:param BroadcastStreamModes stream_mode (Optional): Determines the broadcast stream handling mode.
13181334
Set this to BroadcastStreamModes.auto (the default) to have streams added automatically. Set this to
13191335
BroadcastStreamModes.manual to explicitly select streams to include in the the broadcast, using the

0 commit comments

Comments
 (0)