Skip to content

Commit e942db6

Browse files
committed
add maxBitrate and hlsStatus to Broadcast API
1 parent e502713 commit e942db6

File tree

5 files changed

+154
-166
lines changed

5 files changed

+154
-166
lines changed

README.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,9 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser
438438
'stylesheet': 'the layout stylesheet (only used with type == custom)'
439439
},
440440
'maxDuration': 5400,
441-
'hasAudio': True
442-
'hasVideo': True
441+
'hasAudio': True,
442+
'hasVideo': True,
443+
'maxBitrate': 2000000,
443444
'outputs': {
444445
'hls': {},
445446
'rtmp': [{
@@ -466,6 +467,8 @@ You can specify the following broadcast resolutions:
466467
* "1920x1080" (FHD landscape)
467468
* "1080x1920" (FHD portrait)
468469

470+
You can specify a maximum bitrate between 100000 and 6000000.
471+
469472
.. code:: python
470473
471474
session_id = 'SESSIONID'
@@ -476,6 +479,7 @@ You can specify the following broadcast resolutions:
476479
'stylesheet': 'the layout stylesheet (only used with type == custom)'
477480
},
478481
'maxDuration': 5400,
482+
'maxBitrate': 2000000,
479483
'outputs': {
480484
'hls': {},
481485
'rtmp': [{
@@ -508,8 +512,9 @@ to ``False`` as required. These fields are ``True`` by default.
508512
'stylesheet': 'the layout stylesheet (only used with type == custom)'
509513
},
510514
'maxDuration': 5400,
511-
'hasAudio': True
512-
'hasVideo': False
515+
'hasAudio': True,
516+
'hasVideo': False,
517+
'maxBitrate': 2000000,
513518
'outputs': {
514519
'hls': {},
515520
'rtmp': [{

opentok/broadcast.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Broadcast(object):
2424
2525
:ivar resolution:
2626
The resolution of the broadcast (either "640x480", "1280x720", "1920x1080", "480x640", "720x1280", or "1920x1080").
27-
27+
2828
:ivar status:
2929
The status of the broadcast.
3030
@@ -34,29 +34,36 @@ class Broadcast(object):
3434
:ivar hasVideo:
3535
Whether the broadcast has video.
3636
37+
:ivar 'maxBitrate' optional:
38+
The maximum bitrate (bits per second) used by the broadcast.
39+
3740
:ivar broadcastUrls:
3841
An object containing details about the HLS and RTMP broadcasts.
39-
40-
If you specified an HLS endpoint, the object includes an hls property, which is set to the URL for the HLS broadcast.
41-
Note this HLS broadcast URL points to an index file, an .M3U8-formatted playlist that contains a list of URLs
42+
43+
If you specified an HLS endpoint, the object includes an hls property, which is set to the URL for the HLS broadcast.
44+
Note this HLS broadcast URL points to an index file, an .M3U8-formatted playlist that contains a list of URLs
4245
to .ts media segment files (MPEG-2 transport stream files).
4346
While the URLs of both the playlist index file and media segment files are provided as soon as the HTTP response
44-
is returned, these URLs should not be accessed until 15 - 20 seconds later,
45-
after the initiation of the HLS broadcast, due to the delay between the HLS broadcast and the live streams
46-
in the OpenTok session.
47-
See https://developer.apple.com/library/ios/technotes/tn2288/_index.html for more information about the playlist index
47+
is returned, these URLs should not be accessed until 15 - 20 seconds later,
48+
after the initiation of the HLS broadcast, due to the delay between the HLS broadcast and the live streams
49+
in the OpenTok session.
50+
See https://developer.apple.com/library/ios/technotes/tn2288/_index.html for more information about the playlist index
4851
file and media segment files for HLS.
4952
50-
If you specified RTMP stream endpoints, the object includes an rtmp property.
51-
This is an array of objects that include information on each of the RTMP streams.
52-
Each of these objects has the following properties: id (the ID you assigned to the RTMP stream),
53-
serverUrl (the server URL), streamName (the stream name), and status property (which is set to "connecting").
54-
You can call the OpenTok REST method to check for status updates for the broadcast:
53+
If you specified an HLS endpoint, the object will also include an "hlsStatus" property with
54+
information about the HLS broadcast. This will have one of the following values:
55+
["connecting", "ready", "live", "ended", "error"].
56+
57+
If you specified RTMP stream endpoints, the object includes an rtmp property.
58+
This is an array of objects that include information on each of the RTMP streams.
59+
Each of these objects has the following properties: id (the ID you assigned to the RTMP stream),
60+
serverUrl (the server URL), streamName (the stream name), and status property (which is set to "connecting").
61+
You can call the OpenTok REST method to check for status updates for the broadcast:
5562
https://tokbox.com/developer/rest/#get_info_broadcast
5663
5764
:ivar streamMode:
5865
Whether streams included in the broadcast are selected automatically
59-
("auto", the default) or manually ("manual").
66+
("auto", the default) or manually ("manual").
6067
6168
:ivar streams:
6269
A list of streams currently being broadcasted. This is only set for a broadcast with
@@ -71,6 +78,8 @@ def __init__(self, kwargs):
7178
self.updatedAt = kwargs.get("updatedAt")
7279
self.hasAudio = kwargs.get("hasAudio")
7380
self.hasVideo = kwargs.get("hasVideo")
81+
self.maxBitrate = kwargs.get("maxBitrate")
82+
self.maxDuration = kwargs.get("maxDuration")
7483
self.resolution = kwargs.get("resolution")
7584
self.status = kwargs.get("status")
7685
self.broadcastUrls = kwargs.get("broadcastUrls")
@@ -83,8 +92,9 @@ def json(self):
8392
"""
8493
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
8594

95+
8696
class BroadcastStreamModes(Enum):
87-
""""List of valid settings for the stream_mode parameter of the OpenTok.start_broadcast()
97+
""" "List of valid settings for the stream_mode parameter of the OpenTok.start_broadcast()
8898
method."""
8999

90100
auto = u("auto")

opentok/exceptions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ class BroadcastError(OpenTokException):
8989

9090
pass
9191

92+
9293
class DTMFError(OpenTokException):
9394
"""
9495
Indicates that one of the properties digits, session_id or connection_id is invalid
9596
"""
9697

98+
9799
class ArchiveStreamModeError(OpenTokException):
98100
"""
99101
Indicates that the archive is configured with a streamMode that does not support stream manipulation.
@@ -110,12 +112,18 @@ class BroadcastStreamModeError(OpenTokException):
110112

111113
class BroadcastHLSOptionsError(OpenTokException):
112114
"""
113-
Indicates that HLS options have been set incorrectly.
114-
115+
Indicates that HLS options have been set incorrectly.
116+
115117
dvr and lowLatency modes cannot both be set to true in a broadcast.
116118
"""
117119

118120

121+
class BroadcastOptionsError(OpenTokException):
122+
"""
123+
Indicates that broadcast options have been set incorrectly.
124+
"""
125+
126+
119127
class InvalidWebSocketOptionsError(OpenTokException):
120128
"""
121129
Indicates that the WebSocket options selected are invalid.

0 commit comments

Comments
 (0)