@fishjam-cloud/react-native-client 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +8 -0
- package/build/RNFishjamClientModule.d.ts +1 -2
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/components/FishjamRoom/index.d.ts +6 -6
- package/build/components/FishjamRoom/index.d.ts.map +1 -1
- package/build/components/FishjamRoom/index.js +8 -10
- package/build/components/FishjamRoom/index.js.map +1 -1
- package/build/hooks/internal/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/internal/useFishjamEvent.js +3 -0
- package/build/hooks/internal/useFishjamEvent.js.map +1 -1
- package/build/hooks/useAudioSettings.d.ts +7 -0
- package/build/hooks/useAudioSettings.d.ts.map +1 -1
- package/build/hooks/useAudioSettings.js.map +1 -1
- package/build/hooks/useConnection.d.ts +20 -16
- package/build/hooks/useConnection.d.ts.map +1 -1
- package/build/hooks/useConnection.js +10 -11
- package/build/hooks/useConnection.js.map +1 -1
- package/build/hooks/useSandbox.d.ts +3 -3
- package/build/hooks/useSandbox.d.ts.map +1 -1
- package/build/hooks/useSandbox.js +10 -12
- package/build/hooks/useSandbox.js.map +1 -1
- package/build/index.d.ts +2 -17
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -10
- package/build/index.js.map +1 -1
- package/build/livestream/components/LivestreamStreamer.d.ts +51 -0
- package/build/livestream/components/LivestreamStreamer.d.ts.map +1 -0
- package/build/livestream/components/LivestreamStreamer.js +36 -0
- package/build/livestream/components/LivestreamStreamer.js.map +1 -0
- package/build/livestream/components/LivestreamViewer.d.ts.map +1 -0
- package/build/{components → livestream/components}/LivestreamViewer.js +1 -1
- package/build/livestream/components/LivestreamViewer.js.map +1 -0
- package/build/{hooks → livestream/hooks}/useLivestreamStreamer.d.ts +9 -5
- package/build/livestream/hooks/useLivestreamStreamer.d.ts.map +1 -0
- package/build/livestream/hooks/useLivestreamStreamer.js +30 -0
- package/build/livestream/hooks/useLivestreamStreamer.js.map +1 -0
- package/build/{hooks → livestream/hooks}/useLivestreamViewer.d.ts +3 -1
- package/build/livestream/hooks/useLivestreamViewer.d.ts.map +1 -0
- package/build/livestream/hooks/useLivestreamViewer.js +45 -0
- package/build/livestream/hooks/useLivestreamViewer.js.map +1 -0
- package/build/livestream/index.d.ts +11 -0
- package/build/livestream/index.d.ts.map +1 -0
- package/build/livestream/index.js +6 -0
- package/build/livestream/index.js.map +1 -0
- package/build/utils/config.d.ts +6 -0
- package/build/utils/config.d.ts.map +1 -0
- package/build/utils/config.js +10 -0
- package/build/utils/config.js.map +1 -0
- package/build/utils/getFishjamUrl.d.ts +2 -0
- package/build/utils/getFishjamUrl.d.ts.map +1 -0
- package/build/utils/getFishjamUrl.js +10 -0
- package/build/utils/getFishjamUrl.js.map +1 -0
- package/ios/Events.swift +8 -1
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +9 -4
- package/ios/VideoPreviewView.swift +1 -0
- package/livestream/package.json +4 -0
- package/package.json +3 -2
- package/build/common/client.d.ts +0 -25
- package/build/common/client.d.ts.map +0 -1
- package/build/common/client.js +0 -14
- package/build/common/client.js.map +0 -1
- package/build/components/LivestreamStreamer.d.ts +0 -19
- package/build/components/LivestreamStreamer.d.ts.map +0 -1
- package/build/components/LivestreamStreamer.js +0 -10
- package/build/components/LivestreamStreamer.js.map +0 -1
- package/build/components/LivestreamViewer.d.ts.map +0 -1
- package/build/components/LivestreamViewer.js.map +0 -1
- package/build/hooks/useLivestreamStreamer.d.ts.map +0 -1
- package/build/hooks/useLivestreamStreamer.js +0 -31
- package/build/hooks/useLivestreamStreamer.js.map +0 -1
- package/build/hooks/useLivestreamViewer.d.ts.map +0 -1
- package/build/hooks/useLivestreamViewer.js +0 -31
- package/build/hooks/useLivestreamViewer.js.map +0 -1
- /package/build/{components → livestream/components}/LivestreamViewer.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamStreamer.js","sourceRoot":"","sources":["../../src/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAYxD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAA2B,EAAE,EAAE,CAAC,CACxE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAsB,CAAC,EAAG,CAClD,CAAC","sourcesContent":["import { CSSProperties } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { WhipClientView } from 'react-native-whip-whep';\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamStreamerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamStreamer = ({ style }: LivestreamStreamerProps) => (\n <WhipClientView style={style as CSSProperties} />\n);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamViewer.d.ts","sourceRoot":"","sources":["../../src/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAkB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,8EAQ9B,qBAAqB,gCAUvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamViewer.js","sourceRoot":"","sources":["../../src/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AA4C3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,GAAG,GACmB,EAAE,EAAE,CAAC,CAC3B,CAAC,cAAc,CACb,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,KAAsB,CAAC,CAC9B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,CAAC,EACjB,CACH,CAAC","sourcesContent":["import { CSSProperties, Ref } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { WhepClientView, WhepClientViewRef } from 'react-native-whip-whep';\n\nexport type LivestreamViewerRef = WhepClientViewRef;\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamViewerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Used to override the orientation of the video (from metadata).\n * Defaults to \"portrait\".\n */\n orientation?: 'landscape' | 'portrait';\n /**\n * A variable deciding whether the Picture-in-Picture is enabled.\n * Defaults to true.\n */\n pipEnabled?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be started automatically after the app is backgrounded.\n * Defaults to false.\n */\n autoStartPip?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be stopped automatically on iOS after the app is foregrounded.\n * Always enabled on Android as PiP is not supported in foreground.\n * Defaults to false.\n */\n autoStopPip?: boolean;\n /**\n * A variable deciding the size of the Picture-in-Picture mode.\n */\n pipSize?: {\n width: number;\n height: number;\n };\n\n ref?: Ref<LivestreamViewerRef>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamViewer = ({\n style,\n orientation,\n pipEnabled,\n autoStartPip,\n autoStopPip,\n pipSize,\n ref,\n}: LivestreamViewerProps) => (\n <WhepClientView\n ref={ref}\n style={style as CSSProperties}\n orientation={orientation}\n pipEnabled={pipEnabled}\n autoStartPip={autoStartPip}\n autoStopPip={autoStopPip}\n pipSize={pipSize}\n />\n);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,MAAM,EACP,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,qFAAqF;IACrF,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,aAEnC;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG,2BA+BH,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useCallback, useRef } from 'react';
|
|
2
|
-
import { connectWhipClient, createWhipClient, disconnectWhipClient, cameras, } from 'react-native-whip-whep';
|
|
3
|
-
import { FISHJAM_WHIP_URL } from '../consts';
|
|
4
|
-
/**
|
|
5
|
-
* Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}
|
|
6
|
-
* @category Livestream
|
|
7
|
-
* @group Hooks
|
|
8
|
-
*/
|
|
9
|
-
export const useLivestreamStreamer = ({ camera, }) => {
|
|
10
|
-
const isWhipClientCreatedRef = useRef(false);
|
|
11
|
-
const connect = useCallback(async (token, urlOverride) => {
|
|
12
|
-
if (isWhipClientCreatedRef.current) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;
|
|
16
|
-
createWhipClient(resolvedUrl, {
|
|
17
|
-
authToken: token,
|
|
18
|
-
}, camera?.id ?? cameras[0].id);
|
|
19
|
-
isWhipClientCreatedRef.current = true;
|
|
20
|
-
await connectWhipClient();
|
|
21
|
-
}, [camera]);
|
|
22
|
-
const disconnect = useCallback(() => {
|
|
23
|
-
// TODO: Remove when FCE-1786 fixed
|
|
24
|
-
if (isWhipClientCreatedRef.current) {
|
|
25
|
-
disconnectWhipClient();
|
|
26
|
-
isWhipClientCreatedRef.current = false;
|
|
27
|
-
}
|
|
28
|
-
}, []);
|
|
29
|
-
return { connect, disconnect };
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=useLivestreamStreamer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamStreamer.js","sourceRoot":"","sources":["../../src/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,OAAO,GAER,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAiB7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,MAAM,GAGP,EAA+B,EAAE;IAChC,MAAM,sBAAsB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,OAAO,GAAG,WAAW,CACzB,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;QAC5C,IAAI,sBAAsB,CAAC,OAAO,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,MAAM,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC;QACpD,gBAAgB,CACd,WAAW,EACX;YACE,SAAS,EAAE,KAAK;SACjB,EACD,MAAM,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAC5B,CAAC;QACF,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;QACtC,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,mCAAmC;QACnC,IAAI,sBAAsB,CAAC,OAAO,EAAE,CAAC;YACnC,oBAAoB,EAAE,CAAC;YACvB,sBAAsB,CAAC,OAAO,GAAG,KAAK,CAAC;QACzC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { useCallback, useRef } from 'react';\nimport {\n connectWhipClient,\n createWhipClient,\n disconnectWhipClient,\n cameras,\n Camera,\n} from 'react-native-whip-whep';\nimport { FISHJAM_WHIP_URL } from '../consts';\n\n/**\n * @category Livestream\n */\nexport interface useLivestreamStreamerResult {\n /**\n * Callback used to start publishing the selected audio and video media streams.\n *\n * @remarks\n * Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.\n */\n connect: (token: string, urlOverride?: string) => Promise<void>;\n /** Callback to stop publishing anything previously published with {@link connect} */\n disconnect: () => void;\n}\n\n/**\n * Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamStreamer = ({\n camera,\n}: {\n camera?: Camera;\n}): useLivestreamStreamerResult => {\n const isWhipClientCreatedRef = useRef(false);\n\n const connect = useCallback(\n async (token: string, urlOverride?: string) => {\n if (isWhipClientCreatedRef.current) {\n return;\n }\n const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;\n createWhipClient(\n resolvedUrl,\n {\n authToken: token,\n },\n camera?.id ?? cameras[0].id,\n );\n isWhipClientCreatedRef.current = true;\n await connectWhipClient();\n },\n [camera],\n );\n\n const disconnect = useCallback(() => {\n // TODO: Remove when FCE-1786 fixed\n if (isWhipClientCreatedRef.current) {\n disconnectWhipClient();\n isWhipClientCreatedRef.current = false;\n }\n }, []);\n\n return { connect, disconnect };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamViewer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,mBAAmB,GAC3B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACnC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAOxC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,4EAA4E;IAC5E,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAO,yBAsBtC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useCallback, useRef } from 'react';
|
|
2
|
-
import { connectWhepClient, createWhepClient, disconnectWhepClient, } from 'react-native-whip-whep';
|
|
3
|
-
import { FISHJAM_WHEP_URL } from '../consts';
|
|
4
|
-
const urlFromConfig = (config) => {
|
|
5
|
-
if (config.streamId)
|
|
6
|
-
return `${FISHJAM_WHEP_URL}/${config.streamId}`;
|
|
7
|
-
return FISHJAM_WHEP_URL;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Hook for receiving a published livestream.
|
|
11
|
-
* @category Livestream
|
|
12
|
-
* @group Hooks
|
|
13
|
-
*/
|
|
14
|
-
export const useLivestreamViewer = () => {
|
|
15
|
-
const isWhepClientCreatedRef = useRef(false);
|
|
16
|
-
const connect = useCallback(async (config, url) => {
|
|
17
|
-
createWhepClient(url ?? urlFromConfig(config), {
|
|
18
|
-
authToken: config.token,
|
|
19
|
-
});
|
|
20
|
-
isWhepClientCreatedRef.current = true;
|
|
21
|
-
await connectWhepClient();
|
|
22
|
-
}, []);
|
|
23
|
-
const disconnect = useCallback(() => {
|
|
24
|
-
// TODO: Remove when FCE-1786 fixed
|
|
25
|
-
if (isWhepClientCreatedRef.current) {
|
|
26
|
-
disconnectWhepClient();
|
|
27
|
-
}
|
|
28
|
-
}, []);
|
|
29
|
-
return { connect, disconnect };
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=useLivestreamViewer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestreamViewer.js","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM7C,MAAM,aAAa,GAAG,CAAC,MAA2B,EAAE,EAAE;IACpD,IAAI,MAAM,CAAC,QAAQ;QAAE,OAAO,GAAG,gBAAgB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;IACrE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAgBF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAA8B,EAAE;IACjE,MAAM,sBAAsB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,OAAO,GAAG,WAAW,CACzB,KAAK,EAAE,MAA2B,EAAE,GAAY,EAAE,EAAE;QAClD,gBAAgB,CAAC,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YAC7C,SAAS,EAAE,MAAM,CAAC,KAAK;SACxB,CAAC,CAAC;QACH,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;QACtC,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,mCAAmC;QACnC,IAAI,sBAAsB,CAAC,OAAO,EAAE,CAAC;YACnC,oBAAoB,EAAE,CAAC;QACzB,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { useCallback, useRef } from 'react';\nimport {\n connectWhepClient,\n createWhepClient,\n disconnectWhepClient,\n} from 'react-native-whip-whep';\nimport { FISHJAM_WHEP_URL } from '../consts';\n\nexport type ConnectViewerConfig =\n | { token: string; streamId?: never }\n | { streamId: string; token?: never };\n\nconst urlFromConfig = (config: ConnectViewerConfig) => {\n if (config.streamId) return `${FISHJAM_WHEP_URL}/${config.streamId}`;\n return FISHJAM_WHEP_URL;\n};\n\n/**\n * @category Livestream\n */\nexport interface useLivestreamViewerResult {\n /**\n * Callback to start receiving a livestream.\n * If the livestream is private, provide `token`.\n * If the livestream is public, provide `streamId`.\n */\n connect: (config: ConnectViewerConfig, url?: string) => Promise<void>;\n /** Disconnect from a stream previously connected to with {@link connect} */\n disconnect: () => void;\n}\n\n/**\n * Hook for receiving a published livestream.\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamViewer = (): useLivestreamViewerResult => {\n const isWhepClientCreatedRef = useRef(false);\n\n const connect = useCallback(\n async (config: ConnectViewerConfig, url?: string) => {\n createWhepClient(url ?? urlFromConfig(config), {\n authToken: config.token,\n });\n isWhepClientCreatedRef.current = true;\n await connectWhepClient();\n },\n [],\n );\n\n const disconnect = useCallback(() => {\n // TODO: Remove when FCE-1786 fixed\n if (isWhepClientCreatedRef.current) {\n disconnectWhepClient();\n }\n }, []);\n\n return { connect, disconnect };\n};\n"]}
|
|
File without changes
|