Skip to content

Commit c70fc90

Browse files
Merge pull request #68 from apivideo/feat/live-restreaming
Feat/live restreaming
2 parents dd05fa2 + 4a219e1 commit c70fc90

37 files changed

+590
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4-
## [1.3.0] - 2023-06-19
4+
## [1.3.0] - 2023-06-28
5+
- Introducing live streams restream feature
56
- Introducing new analytics endpoints
67

78
## [1.2.8] - 2022-09-13

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ Method | HTTP request | Description
268268
- [RawStatisticsListPlayerSessionEventsResponse](https://github.com/apivideo/api.video-python-client/blob/main/docs/RawStatisticsListPlayerSessionEventsResponse.md)
269269
- [RawStatisticsListSessionsResponse](https://github.com/apivideo/api.video-python-client/blob/main/docs/RawStatisticsListSessionsResponse.md)
270270
- [RefreshTokenPayload](https://github.com/apivideo/api.video-python-client/blob/main/docs/RefreshTokenPayload.md)
271+
- [RestreamsRequestObject](https://github.com/apivideo/api.video-python-client/blob/main/docs/RestreamsRequestObject.md)
272+
- [RestreamsResponseObject](https://github.com/apivideo/api.video-python-client/blob/main/docs/RestreamsResponseObject.md)
271273
- [TokenCreationPayload](https://github.com/apivideo/api.video-python-client/blob/main/docs/TokenCreationPayload.md)
272274
- [TokenListResponse](https://github.com/apivideo/api.video-python-client/blob/main/docs/TokenListResponse.md)
273275
- [UploadToken](https://github.com/apivideo/api.video-python-client/blob/main/docs/UploadToken.md)

apivideo/model/live_stream.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
def lazy_import():
2929
from apivideo.model.live_stream_assets import LiveStreamAssets
30+
from apivideo.model.restreams_response_object import RestreamsResponseObject
3031
globals()['LiveStreamAssets'] = LiveStreamAssets
32+
globals()['RestreamsResponseObject'] = RestreamsResponseObject
3133

3234

3335
class LiveStream(ModelNormal):
@@ -77,6 +79,7 @@ def openapi_types():
7779
lazy_import()
7880
return {
7981
'live_stream_id': (str,), # noqa: E501
82+
'restreams': ([RestreamsResponseObject],), # noqa: E501
8083
'name': (str,), # noqa: E501
8184
'stream_key': (str,), # noqa: E501
8285
'record': (bool,), # noqa: E501
@@ -95,6 +98,7 @@ def discriminator():
9598

9699
attribute_map = {
97100
'live_stream_id': 'liveStreamId', # noqa: E501
101+
'restreams': 'restreams', # noqa: E501
98102
'name': 'name', # noqa: E501
99103
'stream_key': 'streamKey', # noqa: E501
100104
'record': 'record', # noqa: E501
@@ -118,11 +122,12 @@ def discriminator():
118122
])
119123

120124
@convert_js_args_to_python_args
121-
def __init__(self, live_stream_id, *args, **kwargs): # noqa: E501
125+
def __init__(self, live_stream_id, restreams, *args, **kwargs): # noqa: E501
122126
"""LiveStream - a model defined in OpenAPI
123127
124128
Args:
125129
live_stream_id (str): The unique identifier for the live stream. Live stream IDs begin with \"li.\"
130+
restreams ([RestreamsResponseObject]): Returns the list of RTMP restream destinations.
126131
127132
Keyword Args:
128133
_check_type (bool): if True, values for parameters in openapi_types
@@ -190,6 +195,7 @@ def __init__(self, live_stream_id, *args, **kwargs): # noqa: E501
190195
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
191196

192197
self.live_stream_id = live_stream_id
198+
self.restreams = restreams
193199
for var_name, var_value in kwargs.items():
194200
if var_name not in self.attribute_map and \
195201
self._configuration is not None and \

apivideo/model/live_stream_creation_payload.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
validate_get_composed_info,
2626
)
2727

28+
def lazy_import():
29+
from apivideo.model.restreams_request_object import RestreamsRequestObject
30+
globals()['RestreamsRequestObject'] = RestreamsRequestObject
31+
2832

2933
class LiveStreamCreationPayload(ModelNormal):
3034
"""NOTE: This class is auto generated by OpenAPI Generator.
@@ -54,6 +58,9 @@ class LiveStreamCreationPayload(ModelNormal):
5458
}
5559

5660
validations = {
61+
('restreams',): {
62+
'max_items': 5,
63+
},
5764
}
5865

5966
additional_properties_type = None
@@ -70,11 +77,13 @@ def openapi_types():
7077
openapi_types (dict): The key is attribute name
7178
and the value is attribute type.
7279
"""
80+
lazy_import()
7381
return {
7482
'name': (str,), # noqa: E501
7583
'record': (bool,), # noqa: E501
7684
'public': (bool,), # noqa: E501
7785
'player_id': (str,), # noqa: E501
86+
'restreams': ([RestreamsRequestObject],), # noqa: E501
7887
}
7988

8089
@cached_property
@@ -87,6 +96,7 @@ def discriminator():
8796
'record': 'record', # noqa: E501
8897
'public': 'public', # noqa: E501
8998
'player_id': 'playerId', # noqa: E501
99+
'restreams': 'restreams', # noqa: E501
90100
}
91101

92102
_composed_schemas = {}
@@ -141,6 +151,7 @@ def __init__(self, name, *args, **kwargs): # noqa: E501
141151
record (bool): Whether you are recording or not. True for record, false for not record.. [optional] if omitted the server will use the default value of False # noqa: E501
142152
public (bool): Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Learn more about the Private Video feature [here](https://docs.api.video/docs/private-videos).. [optional] # noqa: E501
143153
player_id (str): The unique identifier for the player.. [optional] # noqa: E501
154+
restreams ([RestreamsRequestObject]): Use this parameter to add, edit, or remove RTMP services where you want to restream a live stream. The list can only contain up to 5 destinations.. [optional] # noqa: E501
144155
"""
145156

146157
_check_type = kwargs.pop('_check_type', True)

apivideo/model/live_stream_update_payload.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
validate_get_composed_info,
2626
)
2727

28+
def lazy_import():
29+
from apivideo.model.restreams_request_object import RestreamsRequestObject
30+
globals()['RestreamsRequestObject'] = RestreamsRequestObject
31+
2832

2933
class LiveStreamUpdatePayload(ModelNormal):
3034
"""NOTE: This class is auto generated by OpenAPI Generator.
@@ -54,6 +58,9 @@ class LiveStreamUpdatePayload(ModelNormal):
5458
}
5559

5660
validations = {
61+
('restreams',): {
62+
'max_items': 5,
63+
},
5764
}
5865

5966
additional_properties_type = None
@@ -70,11 +77,13 @@ def openapi_types():
7077
openapi_types (dict): The key is attribute name
7178
and the value is attribute type.
7279
"""
80+
lazy_import()
7381
return {
7482
'name': (str,), # noqa: E501
7583
'public': (bool,), # noqa: E501
7684
'record': (bool,), # noqa: E501
7785
'player_id': (str,), # noqa: E501
86+
'restreams': ([RestreamsRequestObject],), # noqa: E501
7887
}
7988

8089
@cached_property
@@ -87,6 +96,7 @@ def discriminator():
8796
'public': 'public', # noqa: E501
8897
'record': 'record', # noqa: E501
8998
'player_id': 'playerId', # noqa: E501
99+
'restreams': 'restreams', # noqa: E501
90100
}
91101

92102
_composed_schemas = {}
@@ -139,6 +149,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
139149
public (bool): Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Learn more about the Private Video feature [here](https://docs.api.video/docs/private-videos).. [optional] # noqa: E501
140150
record (bool): Use this to indicate whether you want the recording on or off. On is true, off is false.. [optional] # noqa: E501
141151
player_id (str): The unique ID for the player associated with a live stream that you want to update.. [optional] # noqa: E501
152+
restreams ([RestreamsRequestObject]): Use this parameter to add, edit, or remove RTMP services where you want to restream a live stream. The list can only contain up to 5 destinations. This operation updates all restream destinations in the same request. If you do not want to modify an existing restream destination, you need to include it in your request, otherwise it is removed.. [optional] # noqa: E501
142153
"""
143154

144155
_check_type = kwargs.pop('_check_type', True)
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
"""
2+
api.video
3+
4+
api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes. # noqa: E501
5+
6+
Contact: ecosystem@api.video
7+
"""
8+
9+
10+
import re # noqa: F401
11+
import sys # noqa: F401
12+
13+
from apivideo.model_utils import ( # noqa: F401
14+
ApiTypeError,
15+
ModelComposed,
16+
ModelNormal,
17+
ModelSimple,
18+
cached_property,
19+
change_keys_js_to_python,
20+
convert_js_args_to_python_args,
21+
date,
22+
datetime,
23+
file_type,
24+
none_type,
25+
validate_get_composed_info,
26+
)
27+
28+
29+
class RestreamsRequestObject(ModelNormal):
30+
"""NOTE: This class is auto generated by OpenAPI Generator.
31+
Ref: https://openapi-generator.tech
32+
33+
Do not edit the class manually.
34+
35+
Attributes:
36+
allowed_values (dict): The key is the tuple path to the attribute
37+
and the for var_name this is (var_name,). The value is a dict
38+
with a capitalized key describing the allowed value and an allowed
39+
value. These dicts store the allowed enum values.
40+
attribute_map (dict): The key is attribute name
41+
and the value is json key in definition.
42+
discriminator_value_class_map (dict): A dict to go from the discriminator
43+
variable value to the discriminator class name.
44+
validations (dict): The key is the tuple path to the attribute
45+
and the for var_name this is (var_name,). The value is a dict
46+
that stores validations for max_length, min_length, max_items,
47+
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
48+
inclusive_minimum, and regex.
49+
additional_properties_type (tuple): A tuple of classes accepted
50+
as additional properties values.
51+
"""
52+
53+
allowed_values = {
54+
}
55+
56+
validations = {
57+
}
58+
59+
additional_properties_type = None
60+
61+
_nullable = False
62+
63+
@cached_property
64+
def openapi_types():
65+
"""
66+
This must be a method because a model may have properties that are
67+
of type self, this must run after the class is loaded
68+
69+
Returns
70+
openapi_types (dict): The key is attribute name
71+
and the value is attribute type.
72+
"""
73+
return {
74+
'name': (str,), # noqa: E501
75+
'server_url': (str,), # noqa: E501
76+
'stream_key': (str,), # noqa: E501
77+
}
78+
79+
@cached_property
80+
def discriminator():
81+
return None
82+
83+
84+
attribute_map = {
85+
'name': 'name', # noqa: E501
86+
'server_url': 'serverUrl', # noqa: E501
87+
'stream_key': 'streamKey', # noqa: E501
88+
}
89+
90+
_composed_schemas = {}
91+
92+
required_properties = set([
93+
'_data_store',
94+
'_check_type',
95+
'_spec_property_naming',
96+
'_path_to_item',
97+
'_configuration',
98+
'_visited_composed_classes',
99+
])
100+
101+
@convert_js_args_to_python_args
102+
def __init__(self, name, server_url, stream_key, *args, **kwargs): # noqa: E501
103+
"""RestreamsRequestObject - a model defined in OpenAPI
104+
105+
Args:
106+
name (str): Use this parameter to define a name for the restream destination.
107+
server_url (str): Use this parameter to set the RTMP URL of the restream destination.
108+
stream_key (str): Use this parameter to provide the unique key of the live stream that you want to restream.
109+
110+
Keyword Args:
111+
_check_type (bool): if True, values for parameters in openapi_types
112+
will be type checked and a TypeError will be
113+
raised if the wrong type is input.
114+
Defaults to True
115+
_path_to_item (tuple/list): This is a list of keys or values to
116+
drill down to the model in received_data
117+
when deserializing a response
118+
_spec_property_naming (bool): True if the variable names in the input data
119+
are serialized names, as specified in the OpenAPI document.
120+
False if the variable names in the input data
121+
are pythonic names, e.g. snake case (default)
122+
_configuration (Configuration): the instance to use when
123+
deserializing a file_type parameter.
124+
If passed, type conversion is attempted
125+
If omitted no type conversion is done.
126+
_visited_composed_classes (tuple): This stores a tuple of
127+
classes that we have traveled through so that
128+
if we see that class again we will not use its
129+
discriminator again.
130+
When traveling through a discriminator, the
131+
composed schema that is
132+
is traveled through is added to this set.
133+
For example if Animal has a discriminator
134+
petType and we pass in "Dog", and the class Dog
135+
allOf includes Animal, we move through Animal
136+
once using the discriminator, and pick Dog.
137+
Then in Dog, we will make an instance of the
138+
Animal class but this time we won't travel
139+
through its discriminator because we passed in
140+
_visited_composed_classes = (Animal,)
141+
"""
142+
143+
_check_type = kwargs.pop('_check_type', True)
144+
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
145+
_path_to_item = kwargs.pop('_path_to_item', ())
146+
_configuration = kwargs.pop('_configuration', None)
147+
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
148+
149+
if args:
150+
raise ApiTypeError(
151+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
152+
args,
153+
self.__class__.__name__,
154+
),
155+
path_to_item=_path_to_item,
156+
valid_classes=(self.__class__,),
157+
)
158+
159+
self._data_store = {}
160+
self._check_type = _check_type
161+
self._spec_property_naming = _spec_property_naming
162+
self._path_to_item = _path_to_item
163+
self._configuration = _configuration
164+
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
165+
166+
self.name = name
167+
self.server_url = server_url
168+
self.stream_key = stream_key
169+
for var_name, var_value in kwargs.items():
170+
if var_name not in self.attribute_map and \
171+
self._configuration is not None and \
172+
self._configuration.discard_unknown_keys and \
173+
self.additional_properties_type is None:
174+
# discard variable.
175+
continue
176+
setattr(self, var_name, var_value)

0 commit comments

Comments
 (0)