Skip to content

Commit 4773b83

Browse files
authored
Merge pull request #213 from opentok/dev
3.3.0 Release
2 parents 290fdef + da560b7 commit 4773b83

17 files changed

+857
-55
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.2.0
2+
current_version = 3.3.0
33
commit = True
44
tag = False
55

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release v3.3.0
2+
3+
- Support for Experience Composer (Render) API
4+
- Support for multiple archives and broadcasts in the `start_archive` and `start_broadcast` methods
5+
- Support for low latency and DVR modes
6+
- Documented more methods in README
7+
- Updated some out-of-date dependencies
8+
19
# Release v3.2.0
210

311
## Added

README.rst

Lines changed: 129 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,35 @@ streams in the session to individual files (instead of a single composed file) b
146146
# Store this archive_id in the database
147147
archive_id = archive.id
148148
149+
To add an individual stream to an archive, use the
150+
``opentok.add_archive_stream(archive_id, stream_id, has_audio, has_video)`` method:
151+
152+
.. code:: python
153+
154+
opentok.add_archive_stream(archive.id, stream_id, has_audio=True, has_video=True)
155+
156+
To remove a stream from an archive, use the ``opentok.remove_archive_stream()`` method:
157+
158+
.. code:: python
159+
160+
opentok.remove_archive_stream(archive.id, stream_id)
161+
149162
Composed archives (output_mode=OutputModes.composed) have an optional ``resolution`` parameter.
150-
If no value is supplied the opentok platform will use the default resolution "640x480".
151-
You can set this to "1280x720" by setting the
163+
If no value is supplied, the archive will use the default resolution, "640x480".
164+
You can set this to another resolution by setting the
152165
``resolution`` parameter of the ``opentok.start_archive()`` method.
153166

154-
Warning: This value cannot be set for Individual output mode, an error will be thrown.
167+
You can specify the following archive resolutions:
168+
169+
* "640x480" (SD landscape, default resolution)
170+
* "480x640" (SD portrait)
171+
* "1280x720" (HD landscape)
172+
* "720x1280" (HD portrait)
173+
* "1920x1080" (FHD landscape)
174+
* "1080x1920" (FHD portrait)
175+
176+
Setting the ``resolution`` parameter while setting the ``output_mode`` parameter to
177+
``OutputModes.individual`` results in an error.
155178

156179
.. code:: python
157180
@@ -160,8 +183,15 @@ Warning: This value cannot be set for Individual output mode, an error will be t
160183
# Store this archive_id in the database
161184
archive_id = archive.id
162185
163-
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
164-
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
186+
You can enable multiple simultaneous archives by specifying a unique value for the ``multi_archive_tag``
187+
parameter in the ``start_archive`` method.
188+
189+
.. code:: python
190+
191+
archive = opentok.start_archive(session_id, name=u'Important Presentation', multi_archive_tag='MyArchiveTag')
192+
193+
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``method.
194+
You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
165195

166196
.. code:: python
167197
@@ -195,7 +225,7 @@ filter by session ID. This method returns an instance of the ``ArchiveList`` cla
195225

196226
.. code:: python
197227
198-
archive_list = opentok.list_archive()
228+
archive_list = opentok.list_archives()
199229
200230
# Get a specific Archive from the list
201231
archive = archive_list.items[i]
@@ -371,7 +401,8 @@ Working with Broadcasts
371401

372402
OpenTok broadcast lets you share live OpenTok sessions with many viewers.
373403

374-
You can use the ``opentok.start_broadcast()`` method to start a live streaming for an OpenTok session. This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.
404+
You can use the ``opentok.start_broadcast()`` method to start a live stream for an OpenTok session.
405+
This broadcasts the session to HLS (HTTP live streaming) or to RTMP streams.
375406

376407
To successfully start broadcasting a session, at least one client must be connected to the session.
377408

@@ -403,6 +434,45 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser
403434
404435
broadcast = opentok.start_broadcast(session_id, options)
405436
437+
You can specify the following broadcast resolutions:
438+
439+
* "640x480" (SD landscape, default resolution)
440+
* "480x640" (SD portrait)
441+
* "1280x720" (HD landscape)
442+
* "720x1280" (HD portrait)
443+
* "1920x1080" (FHD landscape)
444+
* "1080x1920" (FHD portrait)
445+
446+
.. code:: python
447+
448+
session_id = 'SESSIONID'
449+
options = {
450+
'multiBroadcastTag': 'unique_broadcast_tag'
451+
'layout': {
452+
'type': 'custom',
453+
'stylesheet': 'the layout stylesheet (only used with type == custom)'
454+
},
455+
'maxDuration': 5400,
456+
'outputs': {
457+
'hls': {},
458+
'rtmp': [{
459+
'id': 'foo',
460+
'serverUrl': 'rtmp://myfooserver/myfooapp',
461+
'streamName': 'myfoostream'
462+
}, {
463+
'id': 'bar',
464+
'serverUrl': 'rtmp://mybarserver/mybarapp',
465+
'streamName': 'mybarstream'
466+
}]
467+
},
468+
'resolution': '640x480'
469+
}
470+
471+
broadcast = opentok.start_broadcast(session_id, options)
472+
473+
To enable multiple simultaneous broadcasts on the same session, specify a unique value for the
474+
``multiBroadcastTag`` parameter in ``options`` when calling the ``opentok.start_broadcast`` method.
475+
406476
You can stop a started Broadcast using the ``opentok.stop_broadcast(broadcast_id)`` method.
407477

408478
.. code:: python
@@ -465,6 +535,16 @@ You can dynamically change the layout type of a live streaming broadcast.
465535
'stream.instructor {position: absolute; width: 100%; height:50%;}'
466536
)
467537
538+
You can add streams to a broadcast using the ``opentok.add_broadcast_stream()`` method:
539+
540+
.. code:: python
541+
opentok.add_broadcast_stream(broadcast_id, stream_id)
542+
543+
Conversely, streams can be removed from a broadcast with the ``opentok.remove_broadcast_stream()`` method.
544+
545+
.. code:: python
546+
opentok.remove_broadcast_stream(broadcast_id, stream_id)
547+
468548
For more information about OpenTok live streaming broadcasts, see the
469549
`Broadcast developer guide <https://tokbox.com/developer/guides/broadcast/>`_.
470550

@@ -483,6 +563,46 @@ And then proceed to change the value with
483563

484564
``opentok.timeout = value``
485565

566+
Muting streams
567+
--------------
568+
569+
You can mute all streams in a session using the ``opentok.mute_all()`` method:
570+
571+
.. code:: python
572+
opentok.mute_all(session_id)
573+
574+
# You can also specify streams to exclude (e.g. main presenter)
575+
excluded_stream_ids = ['1234', '5678']
576+
opentok.mute_all(session_id, excluded_stream_ids)
577+
578+
In addition to existing streams, any streams that are published after the call to
579+
this method are published with audio muted. You can remove the mute state of a session
580+
by calling the ``opentok.disableForceMute()`` method:
581+
582+
.. code:: python
583+
opentok.disable_force_mute(session_id)
584+
585+
After calling the ``opentok.disableForceMute()`` method, new streams that are published
586+
to the session will not be muted.
587+
588+
You can mute a single stream using the ``opentok.mute_stream()`` method:
589+
590+
.. code:: python
591+
opentok.mute_stream(session_id, stream_id)
592+
593+
DTMF
594+
------
595+
596+
You can send dual-tone multi-frequency (DTMF) digits to SIP endpoints. You can play DTMF tones
597+
to all clients connected to session or to a specific connection:
598+
599+
.. code:: python
600+
digits = '12345'
601+
opentok.play_dtmf(session_id, digits)
602+
603+
# To a specific connection
604+
opentok.play_dtmf(session_id, connection_id, digits)
605+
486606
Samples
487607
-------
488608

@@ -495,7 +615,7 @@ repository and follow the Walkthroughs:
495615
Documentation
496616
-------------
497617

498-
Reference documentation is available at http://www.tokbox.com/opentok/libraries/server/python/reference/index.html.
618+
Reference documentation is available at https://tokbox.com/developer/sdks/python/reference/.
499619

500620
Requirements
501621
------------
@@ -532,7 +652,7 @@ The Client.create_session() method now includes a media_mode parameter, instead
532652
This version of the SDK includes significant improvements such as top level entity naming, where the Opentok class is now `Client`. We also implemented a standardised logging module, improved naming conventions and JWT generation to make developer experience more rewarding.
533653

534654
For details, see the reference documentation at
535-
http://www.tokbox.com/opentok/libraries/server/python/reference/index.html.
655+
https://tokbox.com/developer/sdks/python/reference/.
536656

537657
Development and Contributing
538658
----------------------------

opentok/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
from .streamlist import StreamList
1515
from .sip_call import SipCall
1616
from .broadcast import Broadcast, BroadcastStreamModes
17+
from .render import Render, RenderList

opentok/archives.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytz
55
from enum import Enum
66

7+
from .exceptions import ArchiveError
8+
79
if PY3:
810
from datetime import timezone
911

opentok/broadcast.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,59 @@
11
import json
22
from enum import Enum
3-
from six import iteritems, u
3+
from six import u
44

55

66
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/endpoints.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,11 @@ def get_broadcast_stream(self, broadcast_id=None):
200200
)
201201

202202
return url
203+
204+
def get_render_url(self, render_id: str = None):
205+
"Returns URLs for working with the Render API."""
206+
url = self.api_url + "/v2/project/" + self.api_key + "/render"
207+
if render_id:
208+
url += "/" + render_id
209+
210+
return url

opentok/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,11 @@ class BroadcastStreamModeError(OpenTokException):
108108
"""
109109

110110
pass
111+
112+
113+
class BroadcastHLSOptionsError(OpenTokException):
114+
"""
115+
Indicates that HLS options have been set incorrectly.
116+
117+
dvr and lowLatency modes cannot both be set to true in a broadcast.
118+
"""

0 commit comments

Comments
 (0)