Skip to content

Commit bf9267d

Browse files
authored
Add feature: hls manual track subscription (#19)
* Add feature: hls manual track subscription * Remove recording api
1 parent eec1e67 commit bf9267d

11 files changed

Lines changed: 577 additions & 17 deletions

jellyfish/_openapi_client/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
__version__ = "1.0.0"
1616

1717
# import apis into sdk package
18-
from jellyfish._openapi_client.api.default_api import DefaultApi
18+
from jellyfish._openapi_client.api.hls_api import HlsApi
1919
from jellyfish._openapi_client.api.room_api import RoomApi
2020

2121
# import ApiClient
@@ -40,6 +40,9 @@
4040
from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS
4141
from jellyfish._openapi_client.models.component_options import ComponentOptions
4242
from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS
43+
from jellyfish._openapi_client.models.component_options_hlss3 import (
44+
ComponentOptionsHLSS3,
45+
)
4346
from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP
4447
from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP
4548
from jellyfish._openapi_client.models.error import Error
@@ -62,3 +65,5 @@
6265
)
6366
from jellyfish._openapi_client.models.room_details_response import RoomDetailsResponse
6467
from jellyfish._openapi_client.models.rooms_listing_response import RoomsListingResponse
68+
from jellyfish._openapi_client.models.s3_credentials import S3Credentials
69+
from jellyfish._openapi_client.models.subscription_config import SubscriptionConfig
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# flake8: noqa
22

33
# import apis into api package
4-
from jellyfish._openapi_client.api.default_api import DefaultApi
4+
from jellyfish._openapi_client.api.hls_api import HlsApi
55
from jellyfish._openapi_client.api.room_api import RoomApi

jellyfish/_openapi_client/api/default_api.py renamed to jellyfish/_openapi_client/api/hls_api.py

Lines changed: 179 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from typing import Optional
2323

2424
from jellyfish._openapi_client.models.hls_skip import HlsSkip
25+
from jellyfish._openapi_client.models.subscription_config import SubscriptionConfig
2526

2627
from jellyfish._openapi_client.api_client import ApiClient
2728
from jellyfish._openapi_client.api_response import ApiResponse
@@ -31,7 +32,7 @@
3132
)
3233

3334

34-
class DefaultApi(object):
35+
class HlsApi(object):
3536
"""NOTE: This class is auto generated by OpenAPI Generator
3637
Ref: https://openapi-generator.tech
3738
@@ -44,7 +45,7 @@ def __init__(self, api_client=None):
4445
self.api_client = api_client
4546

4647
@validate_arguments
47-
def jellyfish_web_hls_controller_index(
48+
def get_hls_content(
4849
self,
4950
room_id: Annotated[StrictStr, Field(..., description="Room id")],
5051
filename: Annotated[StrictStr, Field(..., description="Name of the file")],
@@ -64,12 +65,12 @@ def jellyfish_web_hls_controller_index(
6465
] = None,
6566
**kwargs
6667
) -> str: # noqa: E501
67-
"""Send file # noqa: E501
68+
"""Retrieve HLS Content # noqa: E501
6869
6970
This method makes a synchronous HTTP request by default. To make an
7071
asynchronous HTTP request, please pass async_req=True
7172
72-
>>> thread = api.jellyfish_web_hls_controller_index(room_id, filename, range, hls_msn, hls_part, hls_skip, async_req=True)
73+
>>> thread = api.get_hls_content(room_id, filename, range, hls_msn, hls_part, hls_skip, async_req=True)
7374
>>> result = thread.get()
7475
7576
:param room_id: Room id (required)
@@ -98,14 +99,14 @@ def jellyfish_web_hls_controller_index(
9899
kwargs["_return_http_data_only"] = True
99100
if "_preload_content" in kwargs:
100101
raise ValueError(
101-
"Error! Please call the jellyfish_web_hls_controller_index_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
102+
"Error! Please call the get_hls_content_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
102103
)
103-
return self.jellyfish_web_hls_controller_index_with_http_info(
104+
return self.get_hls_content_with_http_info(
104105
room_id, filename, range, hls_msn, hls_part, hls_skip, **kwargs
105106
) # noqa: E501
106107

107108
@validate_arguments
108-
def jellyfish_web_hls_controller_index_with_http_info(
109+
def get_hls_content_with_http_info(
109110
self,
110111
room_id: Annotated[StrictStr, Field(..., description="Room id")],
111112
filename: Annotated[StrictStr, Field(..., description="Name of the file")],
@@ -125,12 +126,12 @@ def jellyfish_web_hls_controller_index_with_http_info(
125126
] = None,
126127
**kwargs
127128
) -> ApiResponse: # noqa: E501
128-
"""Send file # noqa: E501
129+
"""Retrieve HLS Content # noqa: E501
129130
130131
This method makes a synchronous HTTP request by default. To make an
131132
asynchronous HTTP request, please pass async_req=True
132133
133-
>>> thread = api.jellyfish_web_hls_controller_index_with_http_info(room_id, filename, range, hls_msn, hls_part, hls_skip, async_req=True)
134+
>>> thread = api.get_hls_content_with_http_info(room_id, filename, range, hls_msn, hls_part, hls_skip, async_req=True)
134135
>>> result = thread.get()
135136
136137
:param room_id: Room id (required)
@@ -197,7 +198,7 @@ def jellyfish_web_hls_controller_index_with_http_info(
197198
if _key not in _all_params:
198199
raise ApiTypeError(
199200
"Got an unexpected keyword argument '%s'"
200-
" to method jellyfish_web_hls_controller_index" % _key
201+
" to method get_hls_content" % _key
201202
)
202203
_params[_key] = _val
203204
del _params["kwargs"]
@@ -264,3 +265,171 @@ def jellyfish_web_hls_controller_index_with_http_info(
264265
collection_formats=_collection_formats,
265266
_request_auth=_params.get("_request_auth"),
266267
)
268+
269+
@validate_arguments
270+
def subscribe_tracks(
271+
self,
272+
room_id: Annotated[StrictStr, Field(..., description="Room ID")],
273+
subscription_config: Annotated[
274+
Optional[SubscriptionConfig], Field(description="Subscribe configuration")
275+
] = None,
276+
**kwargs
277+
) -> None: # noqa: E501
278+
"""Subscribe hls component for tracks # noqa: E501
279+
280+
This method makes a synchronous HTTP request by default. To make an
281+
asynchronous HTTP request, please pass async_req=True
282+
283+
>>> thread = api.subscribe_tracks(room_id, subscription_config, async_req=True)
284+
>>> result = thread.get()
285+
286+
:param room_id: Room ID (required)
287+
:type room_id: str
288+
:param subscription_config: Subscribe configuration
289+
:type subscription_config: SubscriptionConfig
290+
:param async_req: Whether to execute the request asynchronously.
291+
:type async_req: bool, optional
292+
:param _request_timeout: timeout setting for this request. If one
293+
number provided, it will be total request
294+
timeout. It can also be a pair (tuple) of
295+
(connection, read) timeouts.
296+
:return: Returns the result object.
297+
If the method is called asynchronously,
298+
returns the request thread.
299+
:rtype: None
300+
"""
301+
kwargs["_return_http_data_only"] = True
302+
if "_preload_content" in kwargs:
303+
raise ValueError(
304+
"Error! Please call the subscribe_tracks_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
305+
)
306+
return self.subscribe_tracks_with_http_info(
307+
room_id, subscription_config, **kwargs
308+
) # noqa: E501
309+
310+
@validate_arguments
311+
def subscribe_tracks_with_http_info(
312+
self,
313+
room_id: Annotated[StrictStr, Field(..., description="Room ID")],
314+
subscription_config: Annotated[
315+
Optional[SubscriptionConfig], Field(description="Subscribe configuration")
316+
] = None,
317+
**kwargs
318+
) -> ApiResponse: # noqa: E501
319+
"""Subscribe hls component for tracks # noqa: E501
320+
321+
This method makes a synchronous HTTP request by default. To make an
322+
asynchronous HTTP request, please pass async_req=True
323+
324+
>>> thread = api.subscribe_tracks_with_http_info(room_id, subscription_config, async_req=True)
325+
>>> result = thread.get()
326+
327+
:param room_id: Room ID (required)
328+
:type room_id: str
329+
:param subscription_config: Subscribe configuration
330+
:type subscription_config: SubscriptionConfig
331+
:param async_req: Whether to execute the request asynchronously.
332+
:type async_req: bool, optional
333+
:param _preload_content: if False, the ApiResponse.data will
334+
be set to none and raw_data will store the
335+
HTTP response body without reading/decoding.
336+
Default is True.
337+
:type _preload_content: bool, optional
338+
:param _return_http_data_only: response data instead of ApiResponse
339+
object with status code, headers, etc
340+
:type _return_http_data_only: bool, optional
341+
:param _request_timeout: timeout setting for this request. If one
342+
number provided, it will be total request
343+
timeout. It can also be a pair (tuple) of
344+
(connection, read) timeouts.
345+
:param _request_auth: set to override the auth_settings for an a single
346+
request; this effectively ignores the authentication
347+
in the spec for a single request.
348+
:type _request_auth: dict, optional
349+
:type _content_type: string, optional: force content-type for the request
350+
:return: Returns the result object.
351+
If the method is called asynchronously,
352+
returns the request thread.
353+
:rtype: None
354+
"""
355+
356+
_params = locals()
357+
358+
_all_params = ["room_id", "subscription_config"]
359+
_all_params.extend(
360+
[
361+
"async_req",
362+
"_return_http_data_only",
363+
"_preload_content",
364+
"_request_timeout",
365+
"_request_auth",
366+
"_content_type",
367+
"_headers",
368+
]
369+
)
370+
371+
# validate the arguments
372+
for _key, _val in _params["kwargs"].items():
373+
if _key not in _all_params:
374+
raise ApiTypeError(
375+
"Got an unexpected keyword argument '%s'"
376+
" to method subscribe_tracks" % _key
377+
)
378+
_params[_key] = _val
379+
del _params["kwargs"]
380+
381+
_collection_formats = {}
382+
383+
# process the path parameters
384+
_path_params = {}
385+
if _params["room_id"]:
386+
_path_params["room_id"] = _params["room_id"]
387+
388+
# process the query parameters
389+
_query_params = []
390+
# process the header parameters
391+
_header_params = dict(_params.get("_headers", {}))
392+
# process the form parameters
393+
_form_params = []
394+
_files = {}
395+
# process the body parameter
396+
_body_params = None
397+
if _params["subscription_config"] is not None:
398+
_body_params = _params["subscription_config"]
399+
400+
# set the HTTP header `Accept`
401+
_header_params["Accept"] = self.api_client.select_header_accept(
402+
["application/json"]
403+
) # noqa: E501
404+
405+
# set the HTTP header `Content-Type`
406+
_content_types_list = _params.get(
407+
"_content_type",
408+
self.api_client.select_header_content_type(["application/json"]),
409+
)
410+
if _content_types_list:
411+
_header_params["Content-Type"] = _content_types_list
412+
413+
# authentication setting
414+
_auth_settings = ["authorization"] # noqa: E501
415+
416+
_response_types_map = {}
417+
418+
return self.api_client.call_api(
419+
"/hls/{room_id}/subscribe",
420+
"POST",
421+
_path_params,
422+
_query_params,
423+
_header_params,
424+
body=_body_params,
425+
post_params=_form_params,
426+
files=_files,
427+
response_types_map=_response_types_map,
428+
auth_settings=_auth_settings,
429+
async_req=_params.get("async_req"),
430+
_return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501
431+
_preload_content=_params.get("_preload_content", True),
432+
_request_timeout=_params.get("_request_timeout"),
433+
collection_formats=_collection_formats,
434+
_request_auth=_params.get("_request_auth"),
435+
)

jellyfish/_openapi_client/models/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS
2323
from jellyfish._openapi_client.models.component_options import ComponentOptions
2424
from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS
25+
from jellyfish._openapi_client.models.component_options_hlss3 import (
26+
ComponentOptionsHLSS3,
27+
)
2528
from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP
2629
from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP
2730
from jellyfish._openapi_client.models.error import Error
@@ -44,3 +47,5 @@
4447
)
4548
from jellyfish._openapi_client.models.room_details_response import RoomDetailsResponse
4649
from jellyfish._openapi_client.models.rooms_listing_response import RoomsListingResponse
50+
from jellyfish._openapi_client.models.s3_credentials import S3Credentials
51+
from jellyfish._openapi_client.models.subscription_config import SubscriptionConfig

jellyfish/_openapi_client/models/component_metadata_hls.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
from typing import Optional
20-
from pydantic import BaseModel, Field, StrictBool, StrictInt
20+
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator
2121

2222

2323
class ComponentMetadataHLS(BaseModel):
@@ -34,12 +34,30 @@ class ComponentMetadataHLS(BaseModel):
3434
playable: StrictBool = Field(
3535
..., description="Whether the generated HLS playlist is playable"
3636
)
37+
subscribe_mode: StrictStr = Field(
38+
...,
39+
alias="subscribeMode",
40+
description="Whether the HLS component should subscribe to tracks automatically or manually",
41+
)
3742
target_window_duration: Optional[StrictInt] = Field(
3843
...,
3944
alias="targetWindowDuration",
4045
description="Duration of stream available for viewer",
4146
)
42-
__properties = ["lowLatency", "persistent", "playable", "targetWindowDuration"]
47+
__properties = [
48+
"lowLatency",
49+
"persistent",
50+
"playable",
51+
"subscribeMode",
52+
"targetWindowDuration",
53+
]
54+
55+
@validator("subscribe_mode")
56+
def subscribe_mode_validate_enum(cls, value):
57+
"""Validates the enum"""
58+
if value not in ("auto", "manual"):
59+
raise ValueError("must be one of enum values ('auto', 'manual')")
60+
return value
4361

4462
class Config:
4563
"""Pydantic configuration"""
@@ -87,6 +105,7 @@ def from_dict(cls, obj: dict) -> ComponentMetadataHLS:
87105
"low_latency": obj.get("lowLatency"),
88106
"persistent": obj.get("persistent"),
89107
"playable": obj.get("playable"),
108+
"subscribe_mode": obj.get("subscribeMode"),
90109
"target_window_duration": obj.get("targetWindowDuration"),
91110
}
92111
)

0 commit comments

Comments
 (0)