-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from opentok/add-broadcast-and-dial-options
Add broadcast and dial options
- Loading branch information
Showing
9 changed files
with
151 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 3.6.1 | ||
current_version = 3.7.0 | ||
commit = True | ||
tag = False | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,7 +386,8 @@ Your application server can disconnect a client from an OpenTok session by calli | |
Working with SIP Interconnect | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
You can connect your SIP platform to an OpenTok session, the audio from your end of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media Router mixes audio from other streams in the session and sends the mixed audio to your SIP endpoint. | ||
You can connect your SIP platform to an OpenTok session, the audio from your end of the SIP call is added to the OpenTok session as an audio-only stream. | ||
The OpenTok Media Router mixes audio from other streams in the session and sends the mixed audio to your SIP endpoint. | ||
|
||
.. code:: python | ||
|
@@ -397,8 +398,7 @@ You can connect your SIP platform to an OpenTok session, the audio from your end | |
# call the method with the required parameters | ||
sip_call = opentok.dial(session_id, token, sip_uri) | ||
# the method also support aditional options to establish the sip call | ||
# the method also supports aditional options to establish the sip call | ||
options = { | ||
'from': '[email protected]', | ||
'headers': { | ||
|
@@ -408,7 +408,10 @@ You can connect your SIP platform to an OpenTok session, the audio from your end | |
'username': 'username', | ||
'password': 'password' | ||
}, | ||
'secure': True | ||
'secure': True, | ||
'video': True, | ||
'observeForceMute': True, | ||
'streams': ['stream-id-1', 'stream-id-2'] | ||
} | ||
# call the method with aditional options | ||
|
@@ -438,8 +441,9 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser | |
'stylesheet': 'the layout stylesheet (only used with type == custom)' | ||
}, | ||
'maxDuration': 5400, | ||
'hasAudio': True | ||
'hasVideo': True | ||
'hasAudio': True, | ||
'hasVideo': True, | ||
'maxBitrate': 2000000, | ||
'outputs': { | ||
'hls': {}, | ||
'rtmp': [{ | ||
|
@@ -466,6 +470,8 @@ You can specify the following broadcast resolutions: | |
* "1920x1080" (FHD landscape) | ||
* "1080x1920" (FHD portrait) | ||
|
||
You can specify a maximum bitrate between 100000 and 6000000. | ||
|
||
.. code:: python | ||
session_id = 'SESSIONID' | ||
|
@@ -476,6 +482,7 @@ You can specify the following broadcast resolutions: | |
'stylesheet': 'the layout stylesheet (only used with type == custom)' | ||
}, | ||
'maxDuration': 5400, | ||
'maxBitrate': 2000000, | ||
'outputs': { | ||
'hls': {}, | ||
'rtmp': [{ | ||
|
@@ -508,8 +515,9 @@ to ``False`` as required. These fields are ``True`` by default. | |
'stylesheet': 'the layout stylesheet (only used with type == custom)' | ||
}, | ||
'maxDuration': 5400, | ||
'hasAudio': True | ||
'hasVideo': False | ||
'hasAudio': True, | ||
'hasVideo': False, | ||
'maxBitrate': 2000000, | ||
'outputs': { | ||
'hls': {}, | ||
'rtmp': [{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
from .websocket_audio_connection import WebSocketAudioConnection | ||
from .exceptions import ( | ||
ArchiveStreamModeError, | ||
BroadcastOptionsError, | ||
BroadcastHLSOptionsError, | ||
BroadcastStreamModeError, | ||
OpenTokException, | ||
|
@@ -1170,7 +1171,7 @@ def set_archive_layout( | |
else: | ||
raise RequestError("OpenTok server error.", response.status_code) | ||
|
||
def dial(self, session_id, token, sip_uri, options=[]): | ||
def dial(self, session_id, token, sip_uri, options={}): | ||
""" | ||
Use this method to connect a SIP platform to an OpenTok session. The audio from the end | ||
of the SIP call is added to the OpenTok session as an audio-only stream. The OpenTok Media | ||
|
@@ -1213,27 +1214,30 @@ def dial(self, session_id, token, sip_uri, options=[]): | |
in the OpenTok stream that is sent to the OpenTok session. The SIP client will receive a single | ||
composed video of the published streams in the OpenTok session. | ||
This is an example of what the payload POST data body could look like: | ||
List 'streams': An array of stream IDs for streams to include in the SIP call. | ||
If you do not set this property, all streams in the session are included in the call. | ||
This is an example of what the payload POST data dictionary could look like: | ||
{ | ||
"sessionId": "Your OpenTok session ID", | ||
"token": "Your valid OpenTok token", | ||
"sip": { | ||
"uri": "sip:[email protected];transport=tls", | ||
"from": "[email protected]", | ||
"headers": { | ||
"headerKey": "headerValue" | ||
}, | ||
"uri": "sip:[email protected];transport=tls", | ||
"from": "[email protected]", | ||
"headers": { | ||
"headerKey": "headerValue" | ||
}, | ||
"auth": { | ||
"username": "username", | ||
"password": "password" | ||
}, | ||
"secure": true|false, | ||
"observeForceMute": true|false, | ||
"video": true|false | ||
} | ||
"secure": True, | ||
"video": True, | ||
"observeForceMute": True, | ||
"streams": ["stream-id-1", "stream-id-2"] | ||
} | ||
} | ||
:rtype: A SipCall object, which contains data of the SIP call: id, connectionId and streamId. | ||
This is what the response body should look like after returning with a status code of 200: | ||
|
@@ -1246,29 +1250,9 @@ def dial(self, session_id, token, sip_uri, options=[]): | |
Note: Your response will have a different: id, connectionId and streamId | ||
""" | ||
payload = {"sessionId": session_id, "token": token, "sip": {"uri": sip_uri}} | ||
observeForceMute = False | ||
video = False | ||
|
||
if "from" in options: | ||
payload["sip"]["from"] = options["from"] | ||
|
||
if "headers" in options: | ||
payload["sip"]["headers"] = options["headers"] | ||
|
||
if "auth" in options: | ||
payload["sip"]["auth"] = options["auth"] | ||
|
||
if "secure" in options: | ||
payload["sip"]["secure"] = options["secure"] | ||
|
||
if "observeForceMute" in options: | ||
observeForceMute = True | ||
payload["sip"]["observeForceMute"] = options["observeForceMute"] | ||
|
||
if "video" in options: | ||
video = True | ||
payload["sip"]["video"] = options["video"] | ||
payload = {"sessionId": session_id, "token": token, "sip": {"uri": sip_uri}} | ||
payload.update(options) | ||
|
||
endpoint = self.endpoints.dial_url() | ||
|
||
|
@@ -1367,11 +1351,11 @@ def start_broadcast( | |
:param String session_id: The session ID of the OpenTok session you want to broadcast | ||
:param Boolean optional hasAudio: Whether the stream is broadcast with audio. | ||
:param Dictionary options, with the following properties: | ||
:param Boolean optional hasVideo: Whether the stream is broadcast with video. | ||
:param Boolean optional hasAudio: Whether the stream is broadcast with audio. | ||
:param Dictionary options, with the following properties: | ||
:param Boolean optional hasVideo: Whether the stream is broadcast with video. | ||
Dictionary 'layout' optional: Specify this to assign the initial layout type for the | ||
broadcast. | ||
|
@@ -1392,6 +1376,9 @@ def start_broadcast( | |
set the maximum duration to a value from 60 (60 seconds) to 36000 (10 hours). The | ||
default maximum duration is 4 hours (14,400 seconds) | ||
Integer 'maxBitrate' optional: The maximum bitrate (bits per second) used by the broadcast. | ||
Value must be between 100_000 and 6_000_000. | ||
Dictionary 'outputs': This object defines the types of broadcast streams you want to | ||
start (both HLS and RTMP). You can include HLS, RTMP, or both as broadcast streams. | ||
If you include RTMP streaming, you can specify up to five target RTMP streams. For | ||
|
@@ -1448,6 +1435,16 @@ def start_broadcast( | |
'HLS options "lowLatency" and "dvr" cannot both be set to "True".' | ||
) | ||
|
||
if "maxBitrate" in options: | ||
if ( | ||
type(options["maxBitrate"]) != int | ||
or options["maxBitrate"] < 100000 | ||
or options["maxBitrate"] > 6000000 | ||
): | ||
raise BroadcastOptionsError( | ||
"maxBitrate must be an integer between 100000 and 6000000." | ||
) | ||
|
||
payload = {"sessionId": session_id, "streamMode": stream_mode.value} | ||
|
||
payload.update(options) | ||
|
@@ -1578,7 +1575,9 @@ def add_broadcast_stream( | |
"Your broadcast is configured with a streamMode that does not support stream manipulation." | ||
) | ||
elif response.status_code == 409: | ||
raise BroadcastError("The broadcast has already started for the session.") | ||
raise BroadcastError( | ||
"The broadcast has already started for the session." | ||
) | ||
else: | ||
raise RequestError("An unexpected error occurred.", response.status_code) | ||
|
||
|
@@ -1621,7 +1620,9 @@ def remove_broadcast_stream( | |
"Your broadcast is configured with a streamMode that does not support stream manipulation." | ||
) | ||
elif response.status_code == 409: | ||
raise BroadcastError("The broadcast has already started for the session.") | ||
raise BroadcastError( | ||
"The broadcast has already started for the session." | ||
) | ||
else: | ||
raise RequestError("OpenTok server error.", response.status_code) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# see: http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers | ||
__version__ = "3.6.1" | ||
__version__ = "3.7.0" | ||
|
Oops, something went wrong.