Skip to content

Commit c6f2588

Browse files
authored
Merge pull request #220 from opentok/dev
Add append to user agent function, add audio/video only broadcasts
2 parents f4cb1fe + 09595b2 commit c6f2588

File tree

7 files changed

+511
-172
lines changed

7 files changed

+511
-172
lines changed

README.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser
421421
'stylesheet': 'the layout stylesheet (only used with type == custom)'
422422
},
423423
'maxDuration': 5400,
424+
'hasAudio': True
425+
'hasVideo': True
424426
'outputs': {
425427
'hls': {},
426428
'rtmp': [{
@@ -477,6 +479,37 @@ You can specify the following broadcast resolutions:
477479
To enable multiple simultaneous broadcasts on the same session, specify a unique value for the
478480
``multiBroadcastTag`` parameter in ``options`` when calling the ``opentok.start_broadcast`` method.
479481

482+
You can broadcast only audio, or only video, for a stream by setting ``hasAudio`` or ``hasVideo``
483+
to ``False`` as required. These fields are ``True`` by default.
484+
485+
.. code:: python
486+
487+
session_id = 'SESSIONID'
488+
options = {
489+
'layout': {
490+
'type': 'custom',
491+
'stylesheet': 'the layout stylesheet (only used with type == custom)'
492+
},
493+
'maxDuration': 5400,
494+
'hasAudio': True
495+
'hasVideo': False
496+
'outputs': {
497+
'hls': {},
498+
'rtmp': [{
499+
'id': 'foo',
500+
'serverUrl': 'rtmp://myfooserver/myfooapp',
501+
'streamName': 'myfoostream'
502+
}, {
503+
'id': 'bar',
504+
'serverUrl': 'rtmp://mybarserver/mybarapp',
505+
'streamName': 'mybarstream'
506+
}]
507+
},
508+
'resolution': '640x480'
509+
}
510+
511+
broadcast = opentok.start_broadcast(session_id, options)
512+
480513
You can stop a started Broadcast using the ``opentok.stop_broadcast(broadcast_id)`` method.
481514

482515
.. code:: python
@@ -640,6 +673,15 @@ to all clients connected to session or to a specific connection:
640673
# To a specific connection
641674
opentok.play_dtmf(session_id, connection_id, digits)
642675
676+
Appending to the User Agent
677+
-------
678+
679+
You can append a string to the user agent that is sent with requests:
680+
681+
.. code:: python
682+
683+
opentok.append_to_user_agent('my-appended-string')
684+
643685
Samples
644686
-------
645687

opentok/broadcast.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class Broadcast(object):
2828
:ivar status:
2929
The status of the broadcast.
3030
31+
:ivar hasAudio:
32+
Whether the broadcast has audio.
33+
34+
:ivar hasVideo:
35+
Whether the broadcast has video.
36+
3137
:ivar broadcastUrls:
3238
An object containing details about the HLS and RTMP broadcasts.
3339
@@ -63,6 +69,8 @@ def __init__(self, kwargs):
6369
self.projectId = kwargs.get("projectId")
6470
self.createdAt = kwargs.get("createdAt")
6571
self.updatedAt = kwargs.get("updatedAt")
72+
self.hasAudio = kwargs.get("hasAudio")
73+
self.hasVideo = kwargs.get("hasVideo")
6674
self.resolution = kwargs.get("resolution")
6775
self.status = kwargs.get("status")
6876
self.broadcastUrls = kwargs.get("broadcastUrls")
@@ -71,7 +79,7 @@ def __init__(self, kwargs):
7179

7280
def json(self):
7381
"""
74-
Returns a JSON representation of the broadcast
82+
Returns a JSON representation of the broadcast.
7583
"""
7684
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
7785

0 commit comments

Comments
 (0)