Skip to content

Commit 4b5f8ff

Browse files
committed
add max_bitrate field for archive api
1 parent cba368e commit 4b5f8ff

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

opentok/archives.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
# compat
1313
from six.moves import map
1414

15-
dthandler = (
16-
lambda obj: obj.isoformat()
17-
if isinstance(obj, datetime) or isinstance(obj, date)
18-
else None
15+
dthandler = lambda obj: (
16+
obj.isoformat() if isinstance(obj, datetime) or isinstance(obj, date) else None
1917
)
2018

2119

@@ -28,8 +26,9 @@ class OutputModes(Enum):
2826
individual = u("individual")
2927
"""Each stream in the archive is recorded to an individual file."""
3028

29+
3130
class StreamModes(Enum):
32-
""""List of valid settings for the stream_mode parameter of the OpenTok.start_archive()
31+
""" "List of valid settings for the stream_mode parameter of the OpenTok.start_archive()
3332
method."""
3433

3534
auto = u("auto")
@@ -38,6 +37,7 @@ class StreamModes(Enum):
3837
"""Streams are included in the archive based on calls to the OpenTok.add_archive_stream()
3938
and OpenTok.remove_archive_stream() methods."""
4039

40+
4141
class Archive(object):
4242
"""Represents an archive of an OpenTok session.
4343
@@ -68,8 +68,8 @@ class Archive(object):
6868
6969
:ivar streamMode:
7070
Whether streams included in the archive are selected automatically
71-
("auto", the default) or manually ("manual").
72-
71+
("auto", the default) or manually ("manual").
72+
7373
:ivar streams:
7474
A list of streams currently being archived. This is only set for an archive with
7575
the status set to "started" and the stream_Mode set to "manual".
@@ -110,6 +110,8 @@ class Archive(object):
110110
"available"; for other archives, (including archives with the status "uploaded") this property is
111111
set to null. The download URL is obfuscated, and the file is only available from the URL for
112112
10 minutes. To generate a new URL, call the Archive.listArchives() or OpenTok.getArchive() method.
113+
114+
:ivar max_bitrate: The maximum video bitrate for the archive, in bits per second. The minimum value is 100,000 and the maximum is 6,000,000.
113115
"""
114116

115117
def __init__(self, sdk, values):
@@ -136,6 +138,7 @@ def __init__(self, sdk, values):
136138
self.streams = values.get("streams")
137139
self.url = values.get("url")
138140
self.resolution = values.get("resolution")
141+
self.max_bitrate = values.get("maxBitrate")
139142

140143
def stop(self):
141144
"""

opentok/opentok.py

+4
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ def start_archive(
559559
resolution=None,
560560
layout=None,
561561
multi_archive_tag=None,
562+
max_bitrate=None,
562563
):
563564
"""
564565
Starts archiving an OpenTok session.
@@ -617,6 +618,8 @@ def start_archive(
617618
at a time for a given session.
618619
For more information, see simultaneous archives: https://tokbox.com/developer/guides/archiving/#simultaneous-archives.
619620
621+
:param String max_bitrate (Optional): The maximum video bitrate for the archive, in bits per second. The minimum value is 100,000 and the maximum is 6,000,000.
622+
620623
:rtype: The Archive object, which includes properties defining the archive,
621624
including the archive ID.
622625
"""
@@ -643,6 +646,7 @@ def start_archive(
643646
"resolution": resolution,
644647
"streamMode": stream_mode.value,
645648
"multiArchiveTag": multi_archive_tag,
649+
"maxBitrate": max_bitrate,
646650
}
647651

648652
if layout is not None:

tests/test_archive.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_stop_archive(self):
3838
u("hasVideo"): True,
3939
u("outputMode"): OutputModes.composed.value,
4040
u("url"): None,
41+
u("maxBitrate"): 2000000,
4142
},
4243
)
4344
httpretty.register_uri(
@@ -61,7 +62,8 @@ def test_stop_archive(self):
6162
"hasAudio": true,
6263
"hasVideo": false,
6364
"outputMode": "composed",
64-
"url" : null
65+
"url" : null,
66+
"maxBitrate": 2000000
6567
}
6668
"""
6769
)
@@ -98,6 +100,7 @@ def test_stop_archive(self):
98100
expect(archive).to(have_property(u("has_video"), False))
99101
expect(archive).to(have_property(u("output_mode"), OutputModes.composed))
100102
expect(archive).to(have_property(u("url"), None))
103+
expect(archive).to(have_property(u("max_bitrate"), 2000000))
101104

102105
@httpretty.activate
103106
def test_add_archive_stream(self):
@@ -144,6 +147,7 @@ def test_delete_archive(self):
144147
u("hasVideo"): True,
145148
u("outputMode"): OutputModes.composed.value,
146149
u("url"): None,
150+
u("maxBitrate"): 2000000,
147151
},
148152
)
149153
httpretty.register_uri(

tests/test_archive_api.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def test_start_archive(self):
5151
"hasAudio": true,
5252
"hasVideo": true,
5353
"outputMode": "composed",
54-
"url" : null
54+
"url" : null,
55+
"maxBitrate": 2000000
5556
}
5657
"""
5758
)
@@ -95,6 +96,7 @@ def test_start_archive(self):
9596
expect(archive).to(have_property(u("has_audio"), True))
9697
expect(archive).to(have_property(u("has_video"), True))
9798
expect(archive).to(have_property(u("url"), None))
99+
expect(archive).to(have_property(u("max_bitrate"), 2000000))
98100

99101
@httpretty.activate
100102
def test_start_archive_with_name(self):
@@ -468,7 +470,8 @@ def test_start_composed_archive(self):
468470
"hasAudio": true,
469471
"hasVideo": true,
470472
"outputMode": "composed",
471-
"url" : null
473+
"url" : null,
474+
"maxBitrate": 2000000
472475
}
473476
"""
474477
)
@@ -516,6 +519,7 @@ def test_start_composed_archive(self):
516519
expect(archive).to(have_property(u("has_video"), True))
517520
expect(archive).to(have_property(u("output_mode"), OutputModes.composed))
518521
expect(archive).to(have_property(u("url"), None))
522+
expect(archive).to(have_property(u("max_bitrate"), 2000000))
519523

520524
@httpretty.activate
521525
def test_start_archive_with_layout(self):
@@ -1069,9 +1073,7 @@ def test_find_archives_with_offset_and_count(self):
10691073
equal(u("application/json"))
10701074
)
10711075
expect(httpretty.last_request()).to(
1072-
have_property(
1073-
u("querystring"), {u("offset"): [u("2")], u("count"): [u("4")]}
1074-
)
1076+
have_property(u("querystring"), {u("offset"): [u("2")], u("count"): [u("4")]})
10751077
)
10761078
expect(archive_list).to(be_an(ArchiveList))
10771079
expect(archive_list).to(have_property(u("count"), 6))

0 commit comments

Comments
 (0)