Skip to content

Commit 3b54c49

Browse files
authored
Merge pull request #210 from opentok/add-hls-options-and-docs
Add hls options and docs, fixing security vulnerability
2 parents 43b00d0 + 4ef92c1 commit 3b54c49

File tree

10 files changed

+328
-51
lines changed

10 files changed

+328
-51
lines changed

README.rst

Lines changed: 94 additions & 11 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
@@ -167,8 +190,8 @@ parameter in the ``start_archive`` method.
167190
168191
archive = opentok.start_archive(session_id, name=u'Important Presentation', multi_archive_tag='MyArchiveTag')
169192
170-
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
171-
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
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.
172195

173196
.. code:: python
174197
@@ -202,7 +225,7 @@ filter by session ID. This method returns an instance of the ``ArchiveList`` cla
202225

203226
.. code:: python
204227
205-
archive_list = opentok.list_archive()
228+
archive_list = opentok.list_archives()
206229
207230
# Get a specific Archive from the list
208231
archive = archive_list.items[i]
@@ -378,7 +401,8 @@ Working with Broadcasts
378401

379402
OpenTok broadcast lets you share live OpenTok sessions with many viewers.
380403

381-
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.
382406

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

@@ -410,8 +434,14 @@ The live streaming broadcast can target one HLS endpoint and up to five RTMP ser
410434
411435
broadcast = opentok.start_broadcast(session_id, options)
412436
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.
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)
415445

416446
.. code:: python
417447
@@ -439,6 +469,9 @@ To enable multiple simultaneous broadcasts on the same session, specify a unique
439469
}
440470
441471
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.
442475

443476
You can stop a started Broadcast using the ``opentok.stop_broadcast(broadcast_id)`` method.
444477

@@ -502,6 +535,16 @@ You can dynamically change the layout type of a live streaming broadcast.
502535
'stream.instructor {position: absolute; width: 100%; height:50%;}'
503536
)
504537
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+
505548
For more information about OpenTok live streaming broadcasts, see the
506549
`Broadcast developer guide <https://tokbox.com/developer/guides/broadcast/>`_.
507550

@@ -520,6 +563,46 @@ And then proceed to change the value with
520563

521564
``opentok.timeout = value``
522565

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+
523606
Samples
524607
-------
525608

@@ -532,7 +615,7 @@ repository and follow the Walkthroughs:
532615
Documentation
533616
-------------
534617

535-
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/.
536619

537620
Requirements
538621
------------
@@ -569,7 +652,7 @@ The Client.create_session() method now includes a media_mode parameter, instead
569652
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.
570653

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

574657
Development and Contributing
575658
----------------------------

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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):

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)