From 7e5aed0546a56a2a51d93e3f25b24f7d1a0281e6 Mon Sep 17 00:00:00 2001 From: Konrad Bochnia Date: Tue, 16 Apr 2024 16:00:06 +0200 Subject: [PATCH] Fix HLS change (#84) * Fix breaking HLS change * Fix prettier --- src/containers/Client.tsx | 23 +-- src/containers/Room.tsx | 12 +- src/server-sdk/api.ts | 284 ++++++++++++++++++++++---------- src/server-sdk/base.ts | 2 +- src/server-sdk/common.ts | 2 +- src/server-sdk/configuration.ts | 2 +- src/server-sdk/index.ts | 2 +- 7 files changed, 214 insertions(+), 113 deletions(-) diff --git a/src/containers/Client.tsx b/src/containers/Client.tsx index 6ae2960..53296dd 100644 --- a/src/containers/Client.tsx +++ b/src/containers/Client.tsx @@ -19,7 +19,7 @@ import { DeviceInfo, StreamingSettingsCard } from "./StreamingSettingsCard"; import { checkJSON } from "./StreamingSettingsPanel"; import { atomFamily, atomWithStorage } from "jotai/utils"; import { useSetAtom } from "jotai"; -import { ComponentOptionsHLSSubscribeModeEnum } from "../server-sdk"; +import { ComponentHLS } from "../server-sdk"; type ClientProps = { roomId: string; @@ -30,7 +30,7 @@ type ClientProps = { remove: (roomId: string) => void; setToken: (token: string) => void; removeToken: () => void; - hlsMode?: ComponentOptionsHLSSubscribeModeEnum; + hlsComponent?: ComponentHLS; }; export const createDefaultTrackMetadata = (type: string) => @@ -65,9 +65,9 @@ export const trackMetadataAtomFamily = atomFamily((clientId) => atomWithStorage | null>(`track-metadata-${clientId}`, null), ); -const prepareHlsButtonMessage = (hlsMode?: ComponentOptionsHLSSubscribeModeEnum): string | null => { - if (hlsMode === undefined) return "There is no HLS component in this room"; - if (hlsMode === "auto") return "HLS is in automatic subscription mode"; +const prepareHlsButtonMessage = (hlsComponent?: ComponentHLS): string | null => { + if (hlsComponent === undefined) return "There is no HLS component in this room"; + if (hlsComponent.properties.subscribeMode === "auto") return "HLS is in automatic subscription mode"; else return null; }; @@ -80,7 +80,7 @@ export const Client = ({ remove, removeToken, setToken, - hlsMode, + hlsComponent, }: ClientProps) => { const { state, dispatch } = useStore(); const client = state.rooms[roomId].peers[peerId].client; @@ -98,7 +98,7 @@ export const Client = ({ const api = client.useSelector((snapshot) => snapshot.connectivity.api); const jellyfishClient = client.useSelector((snapshot) => snapshot.connectivity.client); - const { signalingHost, signalingPath, signalingURISchema, hlsApi } = useServerSdk(); + const { signalingHost, signalingPath, signalingURISchema, roomApi } = useServerSdk(); const [showClientState, setShowClientState] = useLocalStorageState(`show-client-state-json-${peerId}`); const [attachClientMetadata, setAttachClientMetadata] = useLocalStorageState(`attach-client-metadata-${peerId}`); const [showMetadataEditor, setShowMetadataEditor] = useLocalStorageState(`show-metadata-editor-${peerId}`); @@ -268,7 +268,7 @@ export const Client = ({ if (!trackId) throw Error("Adding track error!"); }; - const hlsMessage = prepareHlsButtonMessage(hlsMode); + const hlsMessage = prepareHlsButtonMessage(hlsComponent); return (
@@ -427,10 +427,11 @@ export const Client = ({