From c9ef20e7da2bcb86531b00b747f86de29a668bb8 Mon Sep 17 00:00:00 2001 From: Karol Konkol Date: Thu, 14 Dec 2023 19:02:35 +0100 Subject: [PATCH] Update hls_subscribe function --- jellyfish/_openapi_client/__init__.py | 6 +- jellyfish/_openapi_client/api/hls_api.py | 19 +++--- .../_openapi_client/api/recording_api.py | 1 + jellyfish/_openapi_client/models/__init__.py | 6 +- jellyfish/_openapi_client/models/component.py | 38 +++++++++-- .../_openapi_client/models/component_file.py | 65 ++++++++++++++++++ .../_openapi_client/models/component_hls.py | 20 +++--- .../models/component_options.py | 34 ++++++++-- .../models/component_options_file.py | 68 +++++++++++++++++++ ...ata_hls.py => component_properties_hls.py} | 16 ++--- .../_openapi_client/models/component_rtsp.py | 10 +-- .../models/subscription_config.py | 9 +-- jellyfish/_room_api.py | 13 +++- protos | 2 +- tests/test_room_api.py | 4 +- 15 files changed, 256 insertions(+), 55 deletions(-) create mode 100644 jellyfish/_openapi_client/models/component_file.py create mode 100644 jellyfish/_openapi_client/models/component_options_file.py rename jellyfish/_openapi_client/models/{component_metadata_hls.py => component_properties_hls.py} (86%) diff --git a/jellyfish/_openapi_client/__init__.py b/jellyfish/_openapi_client/__init__.py index 34855c8..185bd96 100644 --- a/jellyfish/_openapi_client/__init__.py +++ b/jellyfish/_openapi_client/__init__.py @@ -37,14 +37,18 @@ from jellyfish._openapi_client.models.component_details_response import ( ComponentDetailsResponse, ) +from jellyfish._openapi_client.models.component_file import ComponentFile from jellyfish._openapi_client.models.component_hls import ComponentHLS -from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS from jellyfish._openapi_client.models.component_options import ComponentOptions +from jellyfish._openapi_client.models.component_options_file import ComponentOptionsFile from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS from jellyfish._openapi_client.models.component_options_hlss3 import ( ComponentOptionsHLSS3, ) from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP +from jellyfish._openapi_client.models.component_properties_hls import ( + ComponentPropertiesHLS, +) from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP from jellyfish._openapi_client.models.error import Error from jellyfish._openapi_client.models.hls_skip import HlsSkip diff --git a/jellyfish/_openapi_client/api/hls_api.py b/jellyfish/_openapi_client/api/hls_api.py index db66759..71c3aa6 100644 --- a/jellyfish/_openapi_client/api/hls_api.py +++ b/jellyfish/_openapi_client/api/hls_api.py @@ -244,6 +244,7 @@ def get_hls_content_with_http_info( _response_types_map = { "200": "str", + "400": "Error", "404": "Error", } @@ -267,7 +268,7 @@ def get_hls_content_with_http_info( ) @validate_arguments - def subscribe_tracks( + def subscribe_hls_to( self, room_id: Annotated[StrictStr, Field(..., description="Room ID")], subscription_config: Annotated[ @@ -275,12 +276,12 @@ def subscribe_tracks( ] = None, **kwargs ) -> None: # noqa: E501 - """Subscribe hls component for tracks # noqa: E501 + """Subscribe the HLS component to the tracks of peers or components # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.subscribe_tracks(room_id, subscription_config, async_req=True) + >>> thread = api.subscribe_hls_to(room_id, subscription_config, async_req=True) >>> result = thread.get() :param room_id: Room ID (required) @@ -301,14 +302,14 @@ def subscribe_tracks( kwargs["_return_http_data_only"] = True if "_preload_content" in kwargs: raise ValueError( - "Error! Please call the subscribe_tracks_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" + "Error! Please call the subscribe_hls_to_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" ) - return self.subscribe_tracks_with_http_info( + return self.subscribe_hls_to_with_http_info( room_id, subscription_config, **kwargs ) # noqa: E501 @validate_arguments - def subscribe_tracks_with_http_info( + def subscribe_hls_to_with_http_info( self, room_id: Annotated[StrictStr, Field(..., description="Room ID")], subscription_config: Annotated[ @@ -316,12 +317,12 @@ def subscribe_tracks_with_http_info( ] = None, **kwargs ) -> ApiResponse: # noqa: E501 - """Subscribe hls component for tracks # noqa: E501 + """Subscribe the HLS component to the tracks of peers or components # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.subscribe_tracks_with_http_info(room_id, subscription_config, async_req=True) + >>> thread = api.subscribe_hls_to_with_http_info(room_id, subscription_config, async_req=True) >>> result = thread.get() :param room_id: Room ID (required) @@ -373,7 +374,7 @@ def subscribe_tracks_with_http_info( if _key not in _all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" - " to method subscribe_tracks" % _key + " to method subscribe_hls_to" % _key ) _params[_key] = _val del _params["kwargs"] diff --git a/jellyfish/_openapi_client/api/recording_api.py b/jellyfish/_openapi_client/api/recording_api.py index bfa91a9..9efb801 100644 --- a/jellyfish/_openapi_client/api/recording_api.py +++ b/jellyfish/_openapi_client/api/recording_api.py @@ -327,6 +327,7 @@ def get_recording_content_with_http_info( _response_types_map = { "200": "str", + "400": "Error", "404": "Error", } diff --git a/jellyfish/_openapi_client/models/__init__.py b/jellyfish/_openapi_client/models/__init__.py index dc1acea..c117746 100644 --- a/jellyfish/_openapi_client/models/__init__.py +++ b/jellyfish/_openapi_client/models/__init__.py @@ -18,14 +18,18 @@ from jellyfish._openapi_client.models.component_details_response import ( ComponentDetailsResponse, ) +from jellyfish._openapi_client.models.component_file import ComponentFile from jellyfish._openapi_client.models.component_hls import ComponentHLS -from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS from jellyfish._openapi_client.models.component_options import ComponentOptions +from jellyfish._openapi_client.models.component_options_file import ComponentOptionsFile from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS from jellyfish._openapi_client.models.component_options_hlss3 import ( ComponentOptionsHLSS3, ) from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP +from jellyfish._openapi_client.models.component_properties_hls import ( + ComponentPropertiesHLS, +) from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP from jellyfish._openapi_client.models.error import Error from jellyfish._openapi_client.models.hls_skip import HlsSkip diff --git a/jellyfish/_openapi_client/models/component.py b/jellyfish/_openapi_client/models/component.py index 72413b0..56a4194 100644 --- a/jellyfish/_openapi_client/models/component.py +++ b/jellyfish/_openapi_client/models/component.py @@ -18,12 +18,13 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from jellyfish._openapi_client.models.component_file import ComponentFile from jellyfish._openapi_client.models.component_hls import ComponentHLS from jellyfish._openapi_client.models.component_rtsp import ComponentRTSP from typing import Union, Any, List, TYPE_CHECKING from pydantic import StrictStr, Field -COMPONENT_ONE_OF_SCHEMAS = ["ComponentHLS", "ComponentRTSP"] +COMPONENT_ONE_OF_SCHEMAS = ["ComponentFile", "ComponentHLS", "ComponentRTSP"] class Component(BaseModel): @@ -35,8 +36,10 @@ class Component(BaseModel): oneof_schema_1_validator: Optional[ComponentHLS] = None # data type: ComponentRTSP oneof_schema_2_validator: Optional[ComponentRTSP] = None + # data type: ComponentFile + oneof_schema_3_validator: Optional[ComponentFile] = None if TYPE_CHECKING: - actual_instance: Union[ComponentHLS, ComponentRTSP] + actual_instance: Union[ComponentFile, ComponentHLS, ComponentRTSP] else: actual_instance: Any one_of_schemas: List[str] = Field(COMPONENT_ONE_OF_SCHEMAS, const=True) @@ -79,16 +82,23 @@ def actual_instance_must_validate_oneof(cls, v): ) else: match += 1 + # validate data type: ComponentFile + if not isinstance(v, ComponentFile): + error_messages.append( + f"Error! Input type `{type(v)}` is not `ComponentFile`" + ) + else: + match += 1 if match > 1: # more than 1 match raise ValueError( - "Multiple matches found when setting `actual_instance` in Component with oneOf schemas: ComponentHLS, ComponentRTSP. Details: " + "Multiple matches found when setting `actual_instance` in Component with oneOf schemas: ComponentFile, ComponentHLS, ComponentRTSP. Details: " + ", ".join(error_messages) ) elif match == 0: # no match raise ValueError( - "No match found when setting `actual_instance` in Component with oneOf schemas: ComponentHLS, ComponentRTSP. Details: " + "No match found when setting `actual_instance` in Component with oneOf schemas: ComponentFile, ComponentHLS, ComponentRTSP. Details: " + ", ".join(error_messages) ) else: @@ -112,6 +122,11 @@ def from_json(cls, json_str: str) -> Component: "Failed to lookup data type from the field `type` in the input." ) + # check if data type is `ComponentFile` + if _data_type == "ComponentFile": + instance.actual_instance = ComponentFile.from_json(json_str) + return instance + # check if data type is `ComponentHLS` if _data_type == "ComponentHLS": instance.actual_instance = ComponentHLS.from_json(json_str) @@ -122,6 +137,11 @@ def from_json(cls, json_str: str) -> Component: instance.actual_instance = ComponentRTSP.from_json(json_str) return instance + # check if data type is `ComponentFile` + if _data_type == "file": + instance.actual_instance = ComponentFile.from_json(json_str) + return instance + # check if data type is `ComponentHLS` if _data_type == "hls": instance.actual_instance = ComponentHLS.from_json(json_str) @@ -144,17 +164,23 @@ def from_json(cls, json_str: str) -> Component: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into ComponentFile + try: + instance.actual_instance = ComponentFile.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) if match > 1: # more than 1 match raise ValueError( - "Multiple matches found when deserializing the JSON string into Component with oneOf schemas: ComponentHLS, ComponentRTSP. Details: " + "Multiple matches found when deserializing the JSON string into Component with oneOf schemas: ComponentFile, ComponentHLS, ComponentRTSP. Details: " + ", ".join(error_messages) ) elif match == 0: # no match raise ValueError( - "No match found when deserializing the JSON string into Component with oneOf schemas: ComponentHLS, ComponentRTSP. Details: " + "No match found when deserializing the JSON string into Component with oneOf schemas: ComponentFile, ComponentHLS, ComponentRTSP. Details: " + ", ".join(error_messages) ) else: diff --git a/jellyfish/_openapi_client/models/component_file.py b/jellyfish/_openapi_client/models/component_file.py new file mode 100644 index 0000000..95cb349 --- /dev/null +++ b/jellyfish/_openapi_client/models/component_file.py @@ -0,0 +1,65 @@ +# coding: utf-8 + +""" + Python API wrapper for Jellyfish Media Server + + The version of the OpenAPI document: 0.2.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from pydantic import BaseModel, Field, StrictStr + + +class ComponentFile(BaseModel): + """ + Describes the File component + """ + + id: StrictStr = Field(..., description="Assigned component ID") + type: StrictStr = Field(..., description="Component type") + __properties = ["id", "type"] + + class Config: + """Pydantic configuration""" + + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ComponentFile: + """Create an instance of ComponentFile from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ComponentFile: + """Create an instance of ComponentFile from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ComponentFile.parse_obj(obj) + + _obj = ComponentFile.parse_obj({"id": obj.get("id"), "type": obj.get("type")}) + return _obj diff --git a/jellyfish/_openapi_client/models/component_hls.py b/jellyfish/_openapi_client/models/component_hls.py index acedabe..5637d20 100644 --- a/jellyfish/_openapi_client/models/component_hls.py +++ b/jellyfish/_openapi_client/models/component_hls.py @@ -17,18 +17,20 @@ from pydantic import BaseModel, Field, StrictStr -from jellyfish._openapi_client.models.component_metadata_hls import ComponentMetadataHLS +from jellyfish._openapi_client.models.component_properties_hls import ( + ComponentPropertiesHLS, +) class ComponentHLS(BaseModel): """ - Describes HLS component + Describes the HLS component """ id: StrictStr = Field(..., description="Assigned component ID") - metadata: ComponentMetadataHLS = Field(...) + properties: ComponentPropertiesHLS = Field(...) type: StrictStr = Field(..., description="Component type") - __properties = ["id", "metadata", "type"] + __properties = ["id", "properties", "type"] class Config: """Pydantic configuration""" @@ -52,9 +54,9 @@ def from_json(cls, json_str: str) -> ComponentHLS: def to_dict(self): """Returns the dictionary representation of the model using alias""" _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of metadata - if self.metadata: - _dict["metadata"] = self.metadata.to_dict() + # override the default output from pydantic by calling `to_dict()` of properties + if self.properties: + _dict["properties"] = self.properties.to_dict() return _dict @classmethod @@ -69,8 +71,8 @@ def from_dict(cls, obj: dict) -> ComponentHLS: _obj = ComponentHLS.parse_obj( { "id": obj.get("id"), - "metadata": ComponentMetadataHLS.from_dict(obj.get("metadata")) - if obj.get("metadata") is not None + "properties": ComponentPropertiesHLS.from_dict(obj.get("properties")) + if obj.get("properties") is not None else None, "type": obj.get("type"), } diff --git a/jellyfish/_openapi_client/models/component_options.py b/jellyfish/_openapi_client/models/component_options.py index 26e3dda..15fda16 100644 --- a/jellyfish/_openapi_client/models/component_options.py +++ b/jellyfish/_openapi_client/models/component_options.py @@ -18,12 +18,17 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from jellyfish._openapi_client.models.component_options_file import ComponentOptionsFile from jellyfish._openapi_client.models.component_options_hls import ComponentOptionsHLS from jellyfish._openapi_client.models.component_options_rtsp import ComponentOptionsRTSP from typing import Union, Any, List, TYPE_CHECKING from pydantic import StrictStr, Field -COMPONENTOPTIONS_ONE_OF_SCHEMAS = ["ComponentOptionsHLS", "ComponentOptionsRTSP"] +COMPONENTOPTIONS_ONE_OF_SCHEMAS = [ + "ComponentOptionsFile", + "ComponentOptionsHLS", + "ComponentOptionsRTSP", +] class ComponentOptions(BaseModel): @@ -35,8 +40,12 @@ class ComponentOptions(BaseModel): oneof_schema_1_validator: Optional[ComponentOptionsHLS] = None # data type: ComponentOptionsRTSP oneof_schema_2_validator: Optional[ComponentOptionsRTSP] = None + # data type: ComponentOptionsFile + oneof_schema_3_validator: Optional[ComponentOptionsFile] = None if TYPE_CHECKING: - actual_instance: Union[ComponentOptionsHLS, ComponentOptionsRTSP] + actual_instance: Union[ + ComponentOptionsFile, ComponentOptionsHLS, ComponentOptionsRTSP + ] else: actual_instance: Any one_of_schemas: List[str] = Field(COMPONENTOPTIONS_ONE_OF_SCHEMAS, const=True) @@ -77,16 +86,23 @@ def actual_instance_must_validate_oneof(cls, v): ) else: match += 1 + # validate data type: ComponentOptionsFile + if not isinstance(v, ComponentOptionsFile): + error_messages.append( + f"Error! Input type `{type(v)}` is not `ComponentOptionsFile`" + ) + else: + match += 1 if match > 1: # more than 1 match raise ValueError( - "Multiple matches found when setting `actual_instance` in ComponentOptions with oneOf schemas: ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + "Multiple matches found when setting `actual_instance` in ComponentOptions with oneOf schemas: ComponentOptionsFile, ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + ", ".join(error_messages) ) elif match == 0: # no match raise ValueError( - "No match found when setting `actual_instance` in ComponentOptions with oneOf schemas: ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + "No match found when setting `actual_instance` in ComponentOptions with oneOf schemas: ComponentOptionsFile, ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + ", ".join(error_messages) ) else: @@ -115,17 +131,23 @@ def from_json(cls, json_str: str) -> ComponentOptions: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into ComponentOptionsFile + try: + instance.actual_instance = ComponentOptionsFile.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) if match > 1: # more than 1 match raise ValueError( - "Multiple matches found when deserializing the JSON string into ComponentOptions with oneOf schemas: ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + "Multiple matches found when deserializing the JSON string into ComponentOptions with oneOf schemas: ComponentOptionsFile, ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + ", ".join(error_messages) ) elif match == 0: # no match raise ValueError( - "No match found when deserializing the JSON string into ComponentOptions with oneOf schemas: ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + "No match found when deserializing the JSON string into ComponentOptions with oneOf schemas: ComponentOptionsFile, ComponentOptionsHLS, ComponentOptionsRTSP. Details: " + ", ".join(error_messages) ) else: diff --git a/jellyfish/_openapi_client/models/component_options_file.py b/jellyfish/_openapi_client/models/component_options_file.py new file mode 100644 index 0000000..0147893 --- /dev/null +++ b/jellyfish/_openapi_client/models/component_options_file.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + Python API wrapper for Jellyfish Media Server + + The version of the OpenAPI document: 0.2.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from pydantic import BaseModel, Field, StrictStr + + +class ComponentOptionsFile(BaseModel): + """ + Options specific to the File component + """ + + file_path: StrictStr = Field( + ..., + alias="filePath", + description="Path to track file. Must be either OPUS encapsulated in Ogg or raw h264", + ) + __properties = ["filePath"] + + class Config: + """Pydantic configuration""" + + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ComponentOptionsFile: + """Create an instance of ComponentOptionsFile from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, exclude={}, exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ComponentOptionsFile: + """Create an instance of ComponentOptionsFile from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ComponentOptionsFile.parse_obj(obj) + + _obj = ComponentOptionsFile.parse_obj({"file_path": obj.get("filePath")}) + return _obj diff --git a/jellyfish/_openapi_client/models/component_metadata_hls.py b/jellyfish/_openapi_client/models/component_properties_hls.py similarity index 86% rename from jellyfish/_openapi_client/models/component_metadata_hls.py rename to jellyfish/_openapi_client/models/component_properties_hls.py index 68f0936..5e064dc 100644 --- a/jellyfish/_openapi_client/models/component_metadata_hls.py +++ b/jellyfish/_openapi_client/models/component_properties_hls.py @@ -20,9 +20,9 @@ from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator -class ComponentMetadataHLS(BaseModel): +class ComponentPropertiesHLS(BaseModel): """ - Metadata specific to the HLS component + Properties specific to the HLS component """ low_latency: StrictBool = Field( @@ -74,8 +74,8 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ComponentMetadataHLS: - """Create an instance of ComponentMetadataHLS from a JSON string""" + def from_json(cls, json_str: str) -> ComponentPropertiesHLS: + """Create an instance of ComponentPropertiesHLS from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self): @@ -92,15 +92,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ComponentMetadataHLS: - """Create an instance of ComponentMetadataHLS from a dict""" + def from_dict(cls, obj: dict) -> ComponentPropertiesHLS: + """Create an instance of ComponentPropertiesHLS from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ComponentMetadataHLS.parse_obj(obj) + return ComponentPropertiesHLS.parse_obj(obj) - _obj = ComponentMetadataHLS.parse_obj( + _obj = ComponentPropertiesHLS.parse_obj( { "low_latency": obj.get("lowLatency"), "persistent": obj.get("persistent"), diff --git a/jellyfish/_openapi_client/models/component_rtsp.py b/jellyfish/_openapi_client/models/component_rtsp.py index dc6797c..352dee6 100644 --- a/jellyfish/_openapi_client/models/component_rtsp.py +++ b/jellyfish/_openapi_client/models/component_rtsp.py @@ -22,15 +22,15 @@ class ComponentRTSP(BaseModel): """ - Describes RTSP component + Describes the RTSP component """ id: StrictStr = Field(..., description="Assigned component ID") - metadata: Dict[str, Any] = Field( - ..., description="Metadata specific to the RTSP component" + properties: Dict[str, Any] = Field( + ..., description="Properties specific to the RTSP component" ) type: StrictStr = Field(..., description="Component type") - __properties = ["id", "metadata", "type"] + __properties = ["id", "properties", "type"] class Config: """Pydantic configuration""" @@ -68,7 +68,7 @@ def from_dict(cls, obj: dict) -> ComponentRTSP: _obj = ComponentRTSP.parse_obj( { "id": obj.get("id"), - "metadata": obj.get("metadata"), + "properties": obj.get("properties"), "type": obj.get("type"), } ) diff --git a/jellyfish/_openapi_client/models/subscription_config.py b/jellyfish/_openapi_client/models/subscription_config.py index 8c2fe76..b345dcb 100644 --- a/jellyfish/_openapi_client/models/subscription_config.py +++ b/jellyfish/_openapi_client/models/subscription_config.py @@ -25,10 +25,11 @@ class SubscriptionConfig(BaseModel): Subscription config """ - tracks: Optional[conlist(StrictStr)] = Field( - None, description="List of tracks that hls endpoint will subscribe for" + origins: Optional[conlist(StrictStr)] = Field( + None, + description="List of peers and components ids whose tracks the HLS endpoint will subscribe to", ) - __properties = ["tracks"] + __properties = ["origins"] class Config: """Pydantic configuration""" @@ -63,5 +64,5 @@ def from_dict(cls, obj: dict) -> SubscriptionConfig: if not isinstance(obj, dict): return SubscriptionConfig.parse_obj(obj) - _obj = SubscriptionConfig.parse_obj({"tracks": obj.get("tracks")}) + _obj = SubscriptionConfig.parse_obj({"origins": obj.get("origins")}) return _obj diff --git a/jellyfish/_room_api.py b/jellyfish/_room_api.py index 81691bd..c773329 100644 --- a/jellyfish/_room_api.py +++ b/jellyfish/_room_api.py @@ -128,7 +128,14 @@ def delete_component(self, room_id: str, component_id: str) -> None: return self._room_api.delete_component(room_id, component_id) - def hls_subscribe(self, room_id: str, tracks: list): - """subscribes hls component for tracks""" + def hls_subscribe(self, room_id: str, origins: list): + """ + In order to subscribe to HLS peers/components, + the HLS component should be initialized with the subscribe_mode set to manual. + This mode proves beneficial when you do not wish to record or stream + all the available streams within a room via HLS. + It allows for selective addition instead you can manually select specific streams. + For instance, you could opt to record only the stream of an event's host + """ - return self._hls_api.subscribe_tracks(room_id, {"tracks": tracks}) + return self._hls_api.subscribe_hls_to(room_id, {"origins": origins}) diff --git a/protos b/protos index a6f6971..3781848 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit a6f69712da283d13ae8b6e828694b48fce92a9e5 +Subproject commit 3781848239f67a88866f861fa798a8c18384e666 diff --git a/tests/test_room_api.py b/tests/test_room_api.py index 14142d0..c5efa32 100644 --- a/tests/test_room_api.py +++ b/tests/test_room_api.py @@ -179,13 +179,13 @@ def test_valid_subscription(self, room_api: RoomApi): _ = room_api.add_component( room.id, options=ComponentOptionsHLS(subscribe_mode="manual") ) - assert room_api.hls_subscribe(room.id, ["track-id"]) is None + assert room_api.hls_subscribe(room.id, ["peer-id"]) is None def test_invalid_subscription(self, room_api: RoomApi): _, room = room_api.create_room(video_codec=CODEC_H264) _ = room_api.add_component(room.id, options=HLS_OPTIONS) with pytest.raises(BadRequestException): - room_api.hls_subscribe(room.id, ["track-id"]) + room_api.hls_subscribe(room.id, ["component-id"]) class TestAddPeer: