Skip to content

Commit 3fe1c8c

Browse files
committed
Merge branch 'dev' into add_mute_feature
2 parents 1788254 + 814b319 commit 3fe1c8c

12 files changed

+575
-27
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.0b1
2+
current_version = 3.2.0
33
commit = True
44
tag = False
55

opentok/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .opentok import OpenTok, Client, Roles, MediaModes, ArchiveModes
22
from .session import Session
3-
from .archives import Archive, ArchiveList, OutputModes
3+
from .archives import Archive, ArchiveList, OutputModes, StreamModes
44
from .exceptions import (
55
OpenTokException,
66
AuthError,
@@ -13,4 +13,4 @@
1313
from .stream import Stream
1414
from .streamlist import StreamList
1515
from .sip_call import SipCall
16-
from .broadcast import Broadcast
16+
from .broadcast import Broadcast, BroadcastStreamModes

opentok/archives.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class OutputModes(Enum):
2626
individual = u("individual")
2727
"""Each stream in the archive is recorded to an individual file."""
2828

29+
class StreamModes(Enum):
30+
""""List of valid settings for the stream_mode parameter of the OpenTok.start_archive()
31+
method."""
32+
33+
auto = u("auto")
34+
"""Streams are automatically added to the archive."""
35+
manual = u("manual")
36+
"""Streams are included in the archive based on calls to the OpenTok.add_archive_stream()
37+
and OpenTok.remove_archive_stream() methods."""
2938

3039
class Archive(object):
3140
"""Represents an archive of an OpenTok session.
@@ -34,7 +43,7 @@ class Archive(object):
3443
The time at which the archive was created, in milliseconds since the UNIX epoch.
3544
3645
:ivar duration:
37-
The duration of the archive, in milliseconds.
46+
The duration of the archive, in seconds.
3847
3948
:ivar has_audio:
4049
Boolean value set to true when the archive contains an audio track,
@@ -55,6 +64,14 @@ class Archive(object):
5564
Whether all streams in the archive are recorded to a single file
5665
(OutputModes.composed) or to individual files (OutputModes.individual).
5766
67+
:ivar streamMode:
68+
Whether streams included in the archive are selected automatically
69+
("auto", the default) or manually ("manual").
70+
71+
:ivar streams:
72+
A list of streams currently being archived. This is only set for an archive with
73+
the status set to "started" and the stream_Mode set to "manual".
74+
5875
:ivar partner_id:
5976
The API key associated with the archive.
6077
@@ -113,6 +130,8 @@ def __init__(self, sdk, values):
113130
self.has_audio = values.get("hasAudio")
114131
self.has_video = values.get("hasVideo")
115132
self.output_mode = OutputModes[values.get("outputMode", "composed")]
133+
self.stream_mode = values.get("streamMode", StreamModes.auto)
134+
self.streams = values.get("streams")
116135
self.url = values.get("url")
117136
self.resolution = values.get("resolution")
118137

opentok/broadcast.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import json
2+
from enum import Enum
3+
from six import iteritems, u
24

35

46
class Broadcast(object):
57
"""
6-
Represents a live streaming broadcast
8+
Represents a live streaming broadcast.
9+
10+
:ivar streamMode:
11+
Whether streams included in the broadcast are selected automatically
12+
("auto", the default) or manually ("manual").
13+
14+
:ivar streams:
15+
A list of streams currently being broadcast. This is only set for a broadcast with
16+
the status set to "started" and the stream_Mode set to "manual".
717
"""
818

919
def __init__(self, kwargs):
@@ -15,9 +25,21 @@ def __init__(self, kwargs):
1525
self.resolution = kwargs.get("resolution")
1626
self.status = kwargs.get("status")
1727
self.broadcastUrls = kwargs.get("broadcastUrls")
28+
self.stream_mode = kwargs.get("streamMode", BroadcastStreamModes.auto)
29+
self.streams = kwargs.get("streams")
1830

1931
def json(self):
2032
"""
2133
Returns a JSON representation of the broadcast
2234
"""
2335
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
36+
37+
class BroadcastStreamModes(Enum):
38+
""""List of valid settings for the stream_mode parameter of the OpenTok.start_broadcast()
39+
method."""
40+
41+
auto = u("auto")
42+
"""Streams are automatically added to the broadcast."""
43+
manual = u("manual")
44+
"""Streams are included in the broadcast based on calls to the OpenTok.add_broadcast_stream()
45+
and OpenTok.remove_broadcast_stream() methods."""

opentok/endpoints.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,26 @@ def get_dtmf_specific_url(self, session_id, connection_id):
166166
+ "/connection/"
167167
+ connection_id
168168
+ "/play-dtmf"
169-
)
169+
)
170+
171+
def get_archive_stream(self, archive_id=None):
172+
""" this method returns urls for working with streamModes in archives """
173+
url = (
174+
self.api_url
175+
+ "/v2/project/"
176+
+ self.api_key
177+
+ "archive/"
178+
+ archive_id
179+
+ "/streams"
180+
)
181+
182+
def get_broadcast_stream(self, broadcast_id=None):
183+
""" this method returns urls for working with streamModes in broadcasts """
184+
url = (
185+
self.api_url
186+
+ "/v2/partner/"
187+
+ self.api_key
188+
+ "broadcast/"
189+
+ broadcast_id
190+
+ "/streams"
191+
)

opentok/exceptions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,18 @@ class DTMFError(OpenTokException):
9393
"""
9494
Indicates that one of the properties digits, session_id or connection_id is invalid
9595
"""
96+
97+
class ArchiveStreamModeError(OpenTokException):
98+
"""
99+
Indicates that the archive is configured with a streamMode that does not support stream manipulation.
100+
"""
101+
102+
pass
103+
104+
105+
class BroadcastStreamModeError(OpenTokException):
106+
"""
107+
Indicates that the broadcast is configured with a streamMode that does not support stream manipulation.
108+
"""
109+
96110
pass

0 commit comments

Comments
 (0)