@fishjam-cloud/react-native-client 0.19.1 → 0.21.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/components/LivestreamStreamer.d.ts +51 -0
- package/build/components/LivestreamStreamer.d.ts.map +1 -0
- package/build/components/LivestreamStreamer.js +36 -0
- package/build/components/LivestreamStreamer.js.map +1 -0
- package/build/components/{LivestreamView.d.ts → LivestreamViewer.d.ts} +6 -6
- package/build/components/LivestreamViewer.d.ts.map +1 -0
- package/build/components/LivestreamViewer.js +10 -0
- package/build/components/LivestreamViewer.js.map +1 -0
- package/build/consts/index.d.ts +2 -0
- package/build/consts/index.d.ts.map +1 -1
- package/build/consts/index.js +5 -1
- package/build/consts/index.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/useLivestreamStreamer.d.ts +28 -0
- package/build/hooks/useLivestreamStreamer.d.ts.map +1 -0
- package/build/hooks/useLivestreamStreamer.js +30 -0
- package/build/hooks/useLivestreamStreamer.js.map +1 -0
- package/build/hooks/useLivestreamViewer.d.ts +29 -0
- package/build/hooks/useLivestreamViewer.d.ts.map +1 -0
- package/build/hooks/useLivestreamViewer.js +45 -0
- package/build/hooks/useLivestreamViewer.js.map +1 -0
- package/build/hooks/useSandbox.d.ts +7 -0
- package/build/hooks/useSandbox.d.ts.map +1 -1
- package/build/hooks/useSandbox.js +18 -4
- package/build/hooks/useSandbox.js.map +1 -1
- package/build/index.d.ts +10 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -2
- package/build/index.js.map +1 -1
- package/ios/Events.swift +8 -1
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +7 -0
- package/ios/VideoPreviewView.swift +1 -0
- package/package.json +2 -2
- package/build/components/LivestreamView.d.ts.map +0 -1
- package/build/components/LivestreamView.js +0 -10
- package/build/components/LivestreamView.js.map +0 -1
- package/build/hooks/useLivestream.d.ts +0 -6
- package/build/hooks/useLivestream.d.ts.map +0 -1
- package/build/hooks/useLivestream.js +0 -12
- package/build/hooks/useLivestream.js.map +0 -1
|
@@ -298,6 +298,11 @@ class RNFishjamClient(
|
|
|
298
298
|
config: ConnectConfig,
|
|
299
299
|
promise: Promise
|
|
300
300
|
) {
|
|
301
|
+
if (connectPromise != null || peerStatus == PeerStatus.Connected) {
|
|
302
|
+
promise.reject(JoinError("Room already joined or it's connecting. You must call leaveRoom() before calling joinRoom() again."))
|
|
303
|
+
return
|
|
304
|
+
}
|
|
305
|
+
|
|
301
306
|
peerStatus = PeerStatus.Connecting
|
|
302
307
|
connectPromise = promise
|
|
303
308
|
localUserMetadata = mapOf("server" to emptyMap(), "peer" to peerMetadata)
|
|
@@ -316,6 +321,9 @@ class RNFishjamClient(
|
|
|
316
321
|
}
|
|
317
322
|
|
|
318
323
|
fun leaveRoom() {
|
|
324
|
+
connectPromise?.reject(JoinError("leaveRoom called before connected"))
|
|
325
|
+
connectPromise = null
|
|
326
|
+
|
|
319
327
|
if (isScreenShareOn) {
|
|
320
328
|
stopScreenShare()
|
|
321
329
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import { Camera, SenderAudioCodecName, SenderVideoCodecName, VideoParameters, WhipClient } from 'react-native-whip-whep';
|
|
3
|
+
/**
|
|
4
|
+
* Props of the LivestreamView component
|
|
5
|
+
*/
|
|
6
|
+
export type LivestreamStreamerProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Styles of the LivestreamView component
|
|
9
|
+
*/
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
/**
|
|
12
|
+
* If video track should be enabled.
|
|
13
|
+
*/
|
|
14
|
+
videoEnabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If audio track should be enabled.
|
|
17
|
+
*/
|
|
18
|
+
audioEnabled: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Camera to use for the livestream.
|
|
21
|
+
* Use {@link cameras} to get the list of supported cameras.
|
|
22
|
+
*/
|
|
23
|
+
camera?: Camera;
|
|
24
|
+
/**
|
|
25
|
+
* Set video parameters for the camera
|
|
26
|
+
*/
|
|
27
|
+
videoParameters?: VideoParameters;
|
|
28
|
+
/**
|
|
29
|
+
* Set the preferred video codecs for sending the video.
|
|
30
|
+
* Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.
|
|
31
|
+
*/
|
|
32
|
+
preferredVideoCodecs?: SenderVideoCodecName[];
|
|
33
|
+
/**
|
|
34
|
+
* Set the preferred audio codecs for sending the audio.
|
|
35
|
+
* Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.
|
|
36
|
+
*/
|
|
37
|
+
preferredAudioCodecs?: SenderAudioCodecName[];
|
|
38
|
+
/**
|
|
39
|
+
* Reference to the WhipClient instance. Needs to be passed from the {@link useLivestreamStreamer} hook.
|
|
40
|
+
*/
|
|
41
|
+
whipClientRef: React.RefObject<WhipClient | null>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.
|
|
45
|
+
*
|
|
46
|
+
* @category Components
|
|
47
|
+
* @param {object} props
|
|
48
|
+
* @param {object} props.style
|
|
49
|
+
*/
|
|
50
|
+
export declare const LivestreamStreamer: ({ style, whipClientRef, videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }: LivestreamStreamerProps) => import("react").JSX.Element;
|
|
51
|
+
//# sourceMappingURL=LivestreamStreamer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LivestreamStreamer.d.ts","sourceRoot":"","sources":["../../src/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,MAAM,EAEN,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC9C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE9C;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,4HAShC,uBAAuB,gCAgCzB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { cameras, WhipClient, WhipClientView, } from 'react-native-whip-whep';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.
|
|
5
|
+
*
|
|
6
|
+
* @category Components
|
|
7
|
+
* @param {object} props
|
|
8
|
+
* @param {object} props.style
|
|
9
|
+
*/
|
|
10
|
+
export const LivestreamStreamer = ({ style, whipClientRef, videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }) => {
|
|
11
|
+
const whipClient = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
whipClient.current = new WhipClient({
|
|
14
|
+
audioEnabled,
|
|
15
|
+
videoEnabled,
|
|
16
|
+
videoParameters,
|
|
17
|
+
videoDeviceId: camera?.id ?? cameras[0].id,
|
|
18
|
+
}, preferredVideoCodecs, preferredAudioCodecs);
|
|
19
|
+
whipClientRef.current = whipClient.current;
|
|
20
|
+
return () => {
|
|
21
|
+
whipClient.current?.disconnect();
|
|
22
|
+
whipClient.current?.cleanup();
|
|
23
|
+
whipClientRef.current = null;
|
|
24
|
+
};
|
|
25
|
+
}, [
|
|
26
|
+
camera,
|
|
27
|
+
videoParameters,
|
|
28
|
+
videoEnabled,
|
|
29
|
+
audioEnabled,
|
|
30
|
+
preferredVideoCodecs,
|
|
31
|
+
preferredAudioCodecs,
|
|
32
|
+
whipClientRef,
|
|
33
|
+
]);
|
|
34
|
+
return <WhipClientView style={style}/>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=LivestreamStreamer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LivestreamStreamer.js","sourceRoot":"","sources":["../../src/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAEL,OAAO,EAIP,UAAU,EACV,cAAc,GACf,MAAM,wBAAwB,CAAC;AA4ChC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GACI,EAAE,EAAE;IAC5B,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,IAAI,UAAU,CACjC;YACE,YAAY;YACZ,YAAY;YACZ,eAAe;YACf,aAAa,EAAE,MAAM,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;SAC3C,EACD,oBAAoB,EACpB,oBAAoB,CACrB,CAAC;QACF,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAE3C,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;YACjC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAC9B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,eAAe;QACf,YAAY;QACZ,YAAY;QACZ,oBAAoB;QACpB,oBAAoB;QACpB,aAAa;KACd,CAAC,CAAC;IAEH,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAsB,CAAC,EAAG,CAAC;AAC3D,CAAC,CAAC","sourcesContent":["import { CSSProperties, useEffect, useRef } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport {\n Camera,\n cameras,\n SenderAudioCodecName,\n SenderVideoCodecName,\n VideoParameters,\n WhipClient,\n WhipClientView,\n} 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 * If video track should be enabled.\n */\n videoEnabled: boolean;\n /**\n * If audio track should be enabled.\n */\n audioEnabled: boolean;\n /**\n * Camera to use for the livestream.\n * Use {@link cameras} to get the list of supported cameras.\n */\n camera?: Camera;\n /**\n * Set video parameters for the camera\n */\n videoParameters?: VideoParameters;\n /**\n * Set the preferred video codecs for sending the video.\n * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.\n */\n preferredVideoCodecs?: SenderVideoCodecName[];\n /**\n * Set the preferred audio codecs for sending the audio.\n * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.\n */\n preferredAudioCodecs?: SenderAudioCodecName[];\n\n /**\n * Reference to the WhipClient instance. Needs to be passed from the {@link useLivestreamStreamer} hook.\n */\n whipClientRef: React.RefObject<WhipClient | null>;\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 = ({\n style,\n whipClientRef,\n videoEnabled,\n audioEnabled,\n camera,\n videoParameters,\n preferredVideoCodecs,\n preferredAudioCodecs,\n}: LivestreamStreamerProps) => {\n const whipClient = useRef<WhipClient | null>(null);\n\n useEffect(() => {\n whipClient.current = new WhipClient(\n {\n audioEnabled,\n videoEnabled,\n videoParameters,\n videoDeviceId: camera?.id ?? cameras[0].id,\n },\n preferredVideoCodecs,\n preferredAudioCodecs,\n );\n whipClientRef.current = whipClient.current;\n\n return () => {\n whipClient.current?.disconnect();\n whipClient.current?.cleanup();\n whipClientRef.current = null;\n };\n }, [\n camera,\n videoParameters,\n videoEnabled,\n audioEnabled,\n preferredVideoCodecs,\n preferredAudioCodecs,\n whipClientRef,\n ]);\n\n return <WhipClientView style={style as CSSProperties} />;\n};\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import { WhepClientViewRef } from 'react-native-whip-whep';
|
|
4
|
-
export type
|
|
4
|
+
export type LivestreamViewerRef = WhepClientViewRef;
|
|
5
5
|
/**
|
|
6
6
|
* Props of the LivestreamView component
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type LivestreamViewerProps = {
|
|
9
9
|
/**
|
|
10
10
|
* Styles of the LivestreamView component
|
|
11
11
|
*/
|
|
@@ -38,14 +38,14 @@ export type LivestreamViewProps = {
|
|
|
38
38
|
width: number;
|
|
39
39
|
height: number;
|
|
40
40
|
};
|
|
41
|
-
ref?: Ref<
|
|
41
|
+
ref?: Ref<LivestreamViewerRef>;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
* Renders a video player playing the livestream set up with {@link
|
|
44
|
+
* Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.
|
|
45
45
|
*
|
|
46
46
|
* @category Components
|
|
47
47
|
* @param {object} props
|
|
48
48
|
* @param {object} props.style
|
|
49
49
|
*/
|
|
50
|
-
export declare const
|
|
51
|
-
//# sourceMappingURL=
|
|
50
|
+
export declare const LivestreamViewer: ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }: LivestreamViewerProps) => import("react").JSX.Element;
|
|
51
|
+
//# sourceMappingURL=LivestreamViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,gCASvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WhepClientView } from 'react-native-whip-whep';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.
|
|
4
|
+
*
|
|
5
|
+
* @category Components
|
|
6
|
+
* @param {object} props
|
|
7
|
+
* @param {object} props.style
|
|
8
|
+
*/
|
|
9
|
+
export const LivestreamViewer = ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }) => (<WhepClientView ref={ref} style={style} pipEnabled={pipEnabled} autoStartPip={autoStartPip} autoStopPip={autoStopPip} pipSize={pipSize}/>);
|
|
10
|
+
//# sourceMappingURL=LivestreamViewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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 pipEnabled={pipEnabled}\n autoStartPip={autoStartPip}\n autoStopPip={autoStopPip}\n pipSize={pipSize}\n />\n);\n"]}
|
package/build/consts/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const FISHJAM_HTTP_CONNECT_URL = "https://fishjam.io/api/v1/connect";
|
|
2
2
|
export declare const FISHJAM_WS_CONNECT_URL = "wss://fishjam.io/api/v1/connect";
|
|
3
|
+
export declare const FISHJAM_WHIP_URL = "https://fishjam.io/api/v1/live/api/whip";
|
|
4
|
+
export declare const FISHJAM_WHEP_URL = "https://fishjam.io/api/v1/live/api/whep";
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,sCAAoC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,oCAAkC,CAAC;AAItE,eAAO,MAAM,gBAAgB,4CAAiC,CAAC;AAC/D,eAAO,MAAM,gBAAgB,4CAAiC,CAAC"}
|
package/build/consts/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const FISHJAM_URL_BASE = 'fishjam.io/api/v1';
|
|
2
|
+
const FISHJAM_CONNECT_PATH = `${FISHJAM_URL_BASE}/connect`;
|
|
2
3
|
export const FISHJAM_HTTP_CONNECT_URL = `https://${FISHJAM_CONNECT_PATH}`;
|
|
3
4
|
export const FISHJAM_WS_CONNECT_URL = `wss://${FISHJAM_CONNECT_PATH}`;
|
|
5
|
+
const FISHJAM_LIVE_URL = `https://${FISHJAM_URL_BASE}/live`;
|
|
6
|
+
export const FISHJAM_WHIP_URL = `${FISHJAM_LIVE_URL}/api/whip`;
|
|
7
|
+
export const FISHJAM_WHEP_URL = `${FISHJAM_LIVE_URL}/api/whep`;
|
|
4
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAC7C,MAAM,oBAAoB,GAAG,GAAG,gBAAgB,UAAU,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,oBAAoB,EAAE,CAAC;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,oBAAoB,EAAE,CAAC;AAEtE,MAAM,gBAAgB,GAAG,WAAW,gBAAgB,OAAO,CAAC;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,gBAAgB,WAAW,CAAC;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,gBAAgB,WAAW,CAAC","sourcesContent":["const FISHJAM_URL_BASE = 'fishjam.io/api/v1';\nconst FISHJAM_CONNECT_PATH = `${FISHJAM_URL_BASE}/connect`;\n\nexport const FISHJAM_HTTP_CONNECT_URL = `https://${FISHJAM_CONNECT_PATH}`;\nexport const FISHJAM_WS_CONNECT_URL = `wss://${FISHJAM_CONNECT_PATH}`;\n\nconst FISHJAM_LIVE_URL = `https://${FISHJAM_URL_BASE}/live`;\n\nexport const FISHJAM_WHIP_URL = `${FISHJAM_LIVE_URL}/api/whip`;\nexport const FISHJAM_WHEP_URL = `${FISHJAM_LIVE_URL}/api/whep`;\n"]}
|
|
@@ -5,7 +5,14 @@ export type AudioOutputDevice = {
|
|
|
5
5
|
name: string;
|
|
6
6
|
};
|
|
7
7
|
export type OnAudioDeviceEvent = {
|
|
8
|
+
/**
|
|
9
|
+
* Currently selected output audio device.
|
|
10
|
+
* On iOS this property can briefly become null, even if it was previously initialized, when AVAudioSession's .currentRoute is empty.
|
|
11
|
+
*/
|
|
8
12
|
selectedDevice: AudioOutputDevice | null;
|
|
13
|
+
/**
|
|
14
|
+
* [Android only] available audio output devices to be set
|
|
15
|
+
*/
|
|
9
16
|
availableDevices: AudioOutputDevice[];
|
|
10
17
|
};
|
|
11
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;CACvC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB;IAkD5B;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;sCA5CY,qBAAqB;IA8CpC;;;;OAIG;+CArCsB,gBAAgB;IAuCzC;;;OAGG;;EAGN"}
|
|
1
|
+
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,EAAE,CAAC;CACvC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB;IAkD5B;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;sCA5CY,qBAAqB;IA8CpC;;;;OAIG;+CArCsB,gBAAgB;IAuCzC;;;OAGG;;EAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.js","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,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QAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IACvE,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAClD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,KAAK,CACT,0DAA0D;gBACxD,kFAAkF,CACrF,CAAC;QACJ,CAAC;QACD,MAAM,qBAAqB,CAAC,oBAAoB,EAAE,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;WAEG;QACH,yBAAyB;QACzB;;WAEG;QACH,gBAAgB;QAChB;;;WAGG;QACH,uBAAuB;QACvB;;;;WAIG;QACH,sBAAsB;QACtB;;;WAGG;QACH,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Platform } from 'react-native';\n\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type AudioOutputDeviceType =\n | 'bluetooth'\n | 'headset'\n | 'speaker'\n | 'earpiece';\n\nexport type AudioSessionMode = 'voiceChat' | 'videoChat';\n\nexport type AudioOutputDevice = {\n type: AudioOutputDeviceType;\n name: string;\n};\n\nexport type OnAudioDeviceEvent = {\n /**\n * Currently selected output audio device.\n * On iOS this property can briefly become null, even if it was previously initialized, when AVAudioSession's .currentRoute is empty.\n */\n selectedDevice: AudioOutputDevice | null;\n /**\n * [Android only] available audio output devices to be set\n */\n availableDevices: AudioOutputDevice[];\n};\n\n/**\n * This hook manages audio settings.\n * @category Devices\n * @group Hooks\n */\nexport function useAudioSettings() {\n const { selectedDevice: selectedAudioOutputDevice, availableDevices } =\n useFishjamEventState(ReceivableEvents.AudioDeviceUpdate, {\n selectedDevice: null,\n availableDevices: [],\n });\n\n useEffect(() => {\n RNFishjamClientModule.startAudioSwitcher();\n return () => {\n if (Platform.OS === 'android') {\n RNFishjamClientModule.stopAudioSwitcher();\n }\n };\n }, []);\n\n const selectOutputAudioDevice = useCallback(\n async (device: AudioOutputDeviceType) => {\n if (Platform.OS === 'ios') {\n throw Error(\n 'selectOutputAudioDevice function is supported only on Android. ' +\n 'To select an output audio device on iOS use selectAudioSessionMode or showAudioRoutePicker functions',\n );\n }\n await RNFishjamClientModule.setOutputAudioDevice(device);\n },\n [],\n );\n\n const selectAudioSessionMode = useCallback(\n async (audioSessionMode: AudioSessionMode) => {\n if (Platform.OS === 'android') {\n throw Error('selectAudioSessionMode function is supported only on iOS');\n }\n await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);\n },\n [],\n );\n\n const showAudioRoutePicker = useCallback(async () => {\n if (Platform.OS === 'android') {\n throw Error(\n 'showAudioRoutePicker function is supported only on iOS. ' +\n 'To select an output audio device on Android use selectOutputAudioDevice function',\n );\n }\n await RNFishjamClientModule.showAudioRoutePicker();\n }, []);\n\n return {\n /**\n * currently selected output audio device\n */\n selectedAudioOutputDevice,\n /**\n * [Android only] available audio output devices to be set\n */\n availableDevices,\n /**\n * [Android only] selects output audio device.\n * For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.\n */\n selectOutputAudioDevice,\n /**\n * [iOS only] selects audio session mode. For more information refer to Apple's documentation:\n * https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/\n *\n */\n selectAudioSessionMode,\n /**\n * [iOS only] Shows a picker modal that allows user to select output audio device. For more\n * information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview\n */\n showAudioRoutePicker,\n };\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WhipClient } from 'react-native-whip-whep';
|
|
2
|
+
/**
|
|
3
|
+
* @category Livestream
|
|
4
|
+
*/
|
|
5
|
+
export interface useLivestreamStreamerResult {
|
|
6
|
+
/**
|
|
7
|
+
* Callback used to start publishing the selected audio and video media streams.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.
|
|
11
|
+
*/
|
|
12
|
+
connect: (token: string, urlOverride?: string) => Promise<void>;
|
|
13
|
+
/** Callback to stop publishing anything previously published with {@link connect} */
|
|
14
|
+
disconnect: () => Promise<void>;
|
|
15
|
+
/** Utility flag which indicates the current connection status */
|
|
16
|
+
isConnected: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.
|
|
19
|
+
*/
|
|
20
|
+
whipClientRef: React.RefObject<WhipClient | null>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}
|
|
24
|
+
* @category Livestream
|
|
25
|
+
* @group Hooks
|
|
26
|
+
*/
|
|
27
|
+
export declare const useLivestreamStreamer: () => useLivestreamStreamerResult;
|
|
28
|
+
//# sourceMappingURL=useLivestreamStreamer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG5E;;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,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,2BAwBxC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import { useWhipConnectionState } 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 = () => {
|
|
10
|
+
const state = useWhipConnectionState();
|
|
11
|
+
const isConnected = state === 'connected';
|
|
12
|
+
const whipClientRef = useRef(null);
|
|
13
|
+
const connect = useCallback(async (token, urlOverride) => {
|
|
14
|
+
const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;
|
|
15
|
+
await whipClientRef.current?.connect({
|
|
16
|
+
authToken: token,
|
|
17
|
+
serverUrl: resolvedUrl,
|
|
18
|
+
});
|
|
19
|
+
}, []);
|
|
20
|
+
const disconnect = useCallback(async () => {
|
|
21
|
+
await whipClientRef.current?.disconnect();
|
|
22
|
+
}, []);
|
|
23
|
+
return {
|
|
24
|
+
connect,
|
|
25
|
+
disconnect,
|
|
26
|
+
isConnected,
|
|
27
|
+
whipClientRef,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=useLivestreamStreamer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,sBAAsB,EAAc,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAuB7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAgC,EAAE;IACrE,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,CAAC;IAE1C,MAAM,aAAa,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;QACxE,MAAM,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC;QACpD,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;YACnC,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,MAAM,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,OAAO;QACP,UAAU;QACV,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useRef } from 'react';\nimport { useWhipConnectionState, WhipClient } 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: () => Promise<void>;\n /** Utility flag which indicates the current connection status */\n isConnected: boolean;\n /**\n * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.\n */\n whipClientRef: React.RefObject<WhipClient | null>;\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 = (): useLivestreamStreamerResult => {\n const state = useWhipConnectionState();\n const isConnected = state === 'connected';\n\n const whipClientRef = useRef<WhipClient | null>(null);\n\n const connect = useCallback(async (token: string, urlOverride?: string) => {\n const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;\n await whipClientRef.current?.connect({\n authToken: token,\n serverUrl: resolvedUrl,\n });\n }, []);\n\n const disconnect = useCallback(async () => {\n await whipClientRef.current?.disconnect();\n }, []);\n\n return {\n connect,\n disconnect,\n isConnected,\n whipClientRef,\n };\n};\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type ConnectViewerConfig = {
|
|
2
|
+
token: string;
|
|
3
|
+
streamId?: never;
|
|
4
|
+
} | {
|
|
5
|
+
streamId: string;
|
|
6
|
+
token?: never;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @category Livestream
|
|
10
|
+
*/
|
|
11
|
+
export interface useLivestreamViewerResult {
|
|
12
|
+
/**
|
|
13
|
+
* Callback to start receiving a livestream.
|
|
14
|
+
* If the livestream is private, provide `token`.
|
|
15
|
+
* If the livestream is public, provide `streamId`.
|
|
16
|
+
*/
|
|
17
|
+
connect: (config: ConnectViewerConfig, url?: string) => Promise<void>;
|
|
18
|
+
/** Disconnect from a stream previously connected to with {@link connect} */
|
|
19
|
+
disconnect: () => Promise<void>;
|
|
20
|
+
/** Utility flag which indicates the current connection status */
|
|
21
|
+
isConnected: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hook for receiving a published livestream.
|
|
25
|
+
* @category Livestream
|
|
26
|
+
* @group Hooks
|
|
27
|
+
*/
|
|
28
|
+
export declare const useLivestreamViewer: () => useLivestreamViewerResult;
|
|
29
|
+
//# sourceMappingURL=useLivestreamViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivestreamViewer.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAIA,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,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAO,yBAuCtC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { WhepClient, useWhepConnectionState } 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 state = useWhepConnectionState();
|
|
16
|
+
const isConnected = state === 'connected';
|
|
17
|
+
const whepClient = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const createClient = () => {
|
|
20
|
+
whepClient.current = new WhepClient({
|
|
21
|
+
audioEnabled: true,
|
|
22
|
+
videoEnabled: true,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
createClient();
|
|
26
|
+
return () => {
|
|
27
|
+
whepClient.current?.disconnect();
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
const connect = useCallback(async (config, url) => {
|
|
31
|
+
await whepClient.current?.connect({
|
|
32
|
+
serverUrl: url ?? urlFromConfig(config),
|
|
33
|
+
authToken: config.token,
|
|
34
|
+
});
|
|
35
|
+
}, []);
|
|
36
|
+
const disconnect = useCallback(async () => {
|
|
37
|
+
await whepClient.current?.disconnect();
|
|
38
|
+
}, []);
|
|
39
|
+
return {
|
|
40
|
+
connect,
|
|
41
|
+
disconnect,
|
|
42
|
+
isConnected,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useLivestreamViewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivestreamViewer.js","sourceRoot":"","sources":["../../src/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,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;AAkBF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAA8B,EAAE;IACjE,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,CAAC;IAE1C,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,UAAU,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC;gBAClC,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC,CAAC;QACF,YAAY,EAAE,CAAC;QAEf,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,WAAW,CACzB,KAAK,EAAE,MAA2B,EAAE,GAAY,EAAE,EAAE;QAClD,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC;YAChC,SAAS,EAAE,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC;YACvC,SAAS,EAAE,MAAM,CAAC,KAAK;SACxB,CAAC,CAAC;IACL,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,MAAM,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,OAAO;QACP,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { WhepClient, useWhepConnectionState } 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: () => Promise<void>;\n /** Utility flag which indicates the current connection status */\n isConnected: boolean;\n}\n\n/**\n * Hook for receiving a published livestream.\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamViewer = (): useLivestreamViewerResult => {\n const state = useWhepConnectionState();\n const isConnected = state === 'connected';\n\n const whepClient = useRef<WhepClient | null>(null);\n\n useEffect(() => {\n const createClient = () => {\n whepClient.current = new WhepClient({\n audioEnabled: true,\n videoEnabled: true,\n });\n };\n createClient();\n\n return () => {\n whepClient.current?.disconnect();\n };\n }, []);\n\n const connect = useCallback(\n async (config: ConnectViewerConfig, url?: string) => {\n await whepClient.current?.connect({\n serverUrl: url ?? urlFromConfig(config),\n authToken: config.token,\n });\n },\n [],\n );\n\n const disconnect = useCallback(async () => {\n await whepClient.current?.disconnect();\n }, []);\n\n return {\n connect,\n disconnect,\n isConnected,\n };\n};\n"]}
|
|
@@ -9,5 +9,12 @@ export type UseSandboxProps = {
|
|
|
9
9
|
export declare const useSandbox: ({ fishjamId, fishjamUrl }: UseSandboxProps) => {
|
|
10
10
|
getSandboxPeerToken: (roomName: string, peerName: string, roomType?: RoomType) => Promise<string>;
|
|
11
11
|
getSandboxViewerToken: (roomName: string) => Promise<string>;
|
|
12
|
+
getSandboxLivestream: (roomName: string, isPublic?: boolean) => Promise<{
|
|
13
|
+
streamerToken: string;
|
|
14
|
+
room: {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
12
19
|
};
|
|
13
20
|
//# sourceMappingURL=useSandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSandbox.d.ts","sourceRoot":"","sources":["../../src/hooks/useSandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSandbox.d.ts","sourceRoot":"","sources":["../../src/hooks/useSandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAUpC,MAAM,MAAM,eAAe,GACvB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzC;IAAE,SAAS,CAAC,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,eAAO,MAAM,UAAU,GAAI,2BAA2B,eAAe;oCAOrD,MAAM,YACN,MAAM,aACN,QAAQ;sCA6BH,MAAM;qCA4BN,MAAM,aAAY,OAAO;uBAevB,MAAM;cACf;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE;;CAWzC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
1
2
|
import { FISHJAM_HTTP_CONNECT_URL } from '../consts';
|
|
2
3
|
export const useSandbox = ({ fishjamId, fishjamUrl }) => {
|
|
3
4
|
const managerUrl = fishjamUrl
|
|
4
5
|
? `${fishjamUrl}/room-manager`
|
|
5
6
|
: `${FISHJAM_HTTP_CONNECT_URL}/${fishjamId}/room-manager`;
|
|
6
|
-
const getSandboxPeerToken = async (roomName, peerName, roomType = 'conference') => {
|
|
7
|
+
const getSandboxPeerToken = useCallback(async (roomName, peerName, roomType = 'conference') => {
|
|
7
8
|
try {
|
|
8
9
|
const url = new URL(managerUrl);
|
|
9
10
|
url.searchParams.set('roomName', roomName);
|
|
@@ -19,8 +20,8 @@ export const useSandbox = ({ fishjamId, fishjamUrl }) => {
|
|
|
19
20
|
catch (error) {
|
|
20
21
|
throw new Error(`Failed to get peer token for room '${roomName}', peer '${peerName}': ${error instanceof Error ? error.message : String(error)}`);
|
|
21
22
|
}
|
|
22
|
-
};
|
|
23
|
-
const getSandboxViewerToken = async (roomName) => {
|
|
23
|
+
}, [managerUrl]);
|
|
24
|
+
const getSandboxViewerToken = useCallback(async (roomName) => {
|
|
24
25
|
try {
|
|
25
26
|
const url = new URL(`${managerUrl}/${roomName}/livestream-viewer-token`);
|
|
26
27
|
const res = await fetch(url);
|
|
@@ -33,10 +34,23 @@ export const useSandbox = ({ fishjamId, fishjamUrl }) => {
|
|
|
33
34
|
catch (error) {
|
|
34
35
|
throw new Error(`Failed to get viewer token for room '${roomName}': ${error instanceof Error ? error.message : String(error)}`);
|
|
35
36
|
}
|
|
36
|
-
};
|
|
37
|
+
}, [managerUrl]);
|
|
38
|
+
const getSandboxLivestream = useCallback(async (roomName, isPublic = false) => {
|
|
39
|
+
const url = new URL(`${managerUrl}/livestream`);
|
|
40
|
+
url.searchParams.set('roomName', roomName);
|
|
41
|
+
url.searchParams.set('public', isPublic.toString());
|
|
42
|
+
const res = await fetch(url);
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
console.log(await res.json());
|
|
45
|
+
throw new Error(`Failed to retrieve streamer token for '${roomName}' livestream room.`);
|
|
46
|
+
}
|
|
47
|
+
const data = await res.json();
|
|
48
|
+
return data;
|
|
49
|
+
}, [managerUrl]);
|
|
37
50
|
return {
|
|
38
51
|
getSandboxPeerToken,
|
|
39
52
|
getSandboxViewerToken,
|
|
53
|
+
getSandboxLivestream,
|
|
40
54
|
};
|
|
41
55
|
};
|
|
42
56
|
//# sourceMappingURL=useSandbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSandbox.js","sourceRoot":"","sources":["../../src/hooks/useSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAerD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAmB,EAAE,EAAE;IACvE,MAAM,UAAU,GAAG,UAAU;QAC3B,CAAC,CAAC,GAAG,UAAU,eAAe;QAC9B,CAAC,CAAC,GAAG,wBAAwB,IAAI,SAAS,eAAe,CAAC;IAE5D,MAAM,mBAAmB,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"useSandbox.js","sourceRoot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CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,0CAA0C,QAAQ,oBAAoB,CACvE,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,IAGN,CAAC;IACJ,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO;QACL,mBAAmB;QACnB,qBAAqB;QACrB,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback } from 'react';\nimport { FISHJAM_HTTP_CONNECT_URL } from '../consts';\nimport { RoomType } from '../types';\n\ntype BasicInfo = { id: string; name: string };\ntype RoomManagerResponse = {\n peerToken: string;\n url: string;\n room: BasicInfo;\n peer: BasicInfo;\n};\n\nexport type UseSandboxProps =\n | { fishjamId: string; fishjamUrl?: never }\n | { fishjamId?: never; fishjamUrl: string };\n\nexport const useSandbox = ({ fishjamId, fishjamUrl }: UseSandboxProps) => {\n const managerUrl = fishjamUrl\n ? `${fishjamUrl}/room-manager`\n : `${FISHJAM_HTTP_CONNECT_URL}/${fishjamId}/room-manager`;\n\n const getSandboxPeerToken = useCallback(\n async (\n roomName: string,\n peerName: string,\n roomType: RoomType = 'conference',\n ) => {\n try {\n const url = new URL(managerUrl);\n url.searchParams.set('roomName', roomName);\n url.searchParams.set('peerName', peerName);\n url.searchParams.set('roomType', roomType);\n\n const res = await fetch(url.toString());\n\n if (!res.ok) {\n throw new Error(\n `Room '${roomName}' or peer '${peerName}' does not exist or cannot retrieve peer token.`,\n );\n }\n const data: RoomManagerResponse = await res.json();\n return data.peerToken;\n } catch (error) {\n throw new Error(\n `Failed to get peer token for room '${roomName}', peer '${peerName}': ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n },\n [managerUrl],\n );\n\n const getSandboxViewerToken = useCallback(\n async (roomName: string) => {\n try {\n const url = new URL(\n `${managerUrl}/${roomName}/livestream-viewer-token`,\n );\n const res = await fetch(url);\n\n if (!res.ok) {\n throw new Error(\n `Room '${roomName}' does not exist or cannot retrieve viewer token.`,\n );\n }\n\n const data: { token: string } = await res.json();\n\n return data.token;\n } catch (error) {\n throw new Error(\n `Failed to get viewer token for room '${roomName}': ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n },\n [managerUrl],\n );\n\n const getSandboxLivestream = useCallback(\n async (roomName: string, isPublic: boolean = false) => {\n const url = new URL(`${managerUrl}/livestream`);\n url.searchParams.set('roomName', roomName);\n url.searchParams.set('public', isPublic.toString());\n\n const res = await fetch(url);\n if (!res.ok) {\n console.log(await res.json());\n throw new Error(\n `Failed to retrieve streamer token for '${roomName}' livestream room.`,\n );\n }\n\n const data = await res.json();\n return data as {\n streamerToken: string;\n room: { id: string; name: string };\n };\n },\n [managerUrl],\n );\n\n return {\n getSandboxPeerToken,\n getSandboxViewerToken,\n getSandboxLivestream,\n };\n};\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ joinRoom,
|
|
|
8
8
|
leaveRoom, } from './common/client';
|
|
9
9
|
export type { VideoPreviewViewProps } from './components/VideoPreviewView';
|
|
10
10
|
export type { VideoRendererProps } from './components/VideoRendererView';
|
|
11
|
-
export type {
|
|
11
|
+
export type { LivestreamViewerProps, LivestreamViewerRef, } from './components/LivestreamViewer';
|
|
12
12
|
export { VideoPreviewView } from './components/VideoPreviewView';
|
|
13
13
|
export { VideoRendererView } from './components/VideoRendererView';
|
|
14
|
-
export {
|
|
14
|
+
export { LivestreamViewer } from './components/LivestreamViewer';
|
|
15
|
+
export { LivestreamStreamer } from './components/LivestreamStreamer';
|
|
15
16
|
export type { Peer, PeerId, Track, TrackId, TrackType, VadStatus, EncodingReason, TrackBase, AudioTrack, VideoTrack, UsePeersResult, PeerWithTracks, PeerTrackMetadata, DistinguishedTracks, } from './hooks/usePeers';
|
|
16
17
|
export type { AudioOutputDevice, AudioOutputDeviceType, AudioSessionMode, } from './hooks/useAudioSettings';
|
|
17
18
|
export type { CameraId, Camera, CameraConfig, VideoQuality, CameraFacingDirection, CameraConfigBase, } from './hooks/useCamera';
|
|
@@ -19,8 +20,11 @@ export type { ScreenShareOptions, ScreenShareQuality, } from './hooks/useScreenS
|
|
|
19
20
|
export type { ForegroundServiceConfig } from './hooks/useForegroundService';
|
|
20
21
|
export type { JoinRoomConfig, ReconnectionStatus, PeerStatus, } from './hooks/useConnection';
|
|
21
22
|
export type { AppScreenShareData } from './hooks/useAppScreenShare';
|
|
22
|
-
export type {
|
|
23
|
+
export type { useLivestreamViewerResult } from './hooks/useLivestreamViewer';
|
|
24
|
+
export type { useLivestreamStreamerResult } from './hooks/useLivestreamStreamer';
|
|
23
25
|
export type { UseSandboxProps } from './hooks/useSandbox';
|
|
26
|
+
export type { LivestreamStreamerProps } from './components/LivestreamStreamer';
|
|
27
|
+
export type { ConnectViewerConfig } from './hooks/useLivestreamViewer';
|
|
24
28
|
export { useAudioSettings } from './hooks/useAudioSettings';
|
|
25
29
|
export { useBandwidthEstimation } from './hooks/useBandwidthEstimation';
|
|
26
30
|
export { useCamera } from './hooks/useCamera';
|
|
@@ -33,8 +37,10 @@ export { usePeers } from './hooks/usePeers';
|
|
|
33
37
|
export { useForegroundService } from './hooks/useForegroundService';
|
|
34
38
|
export { useConnection } from './hooks/useConnection';
|
|
35
39
|
export { useUpdatePeerMetadata } from './hooks/useUpdatePeerMetadata';
|
|
36
|
-
export {
|
|
40
|
+
export { useLivestreamViewer } from './hooks/useLivestreamViewer';
|
|
41
|
+
export { useLivestreamStreamer } from './hooks/useLivestreamStreamer';
|
|
37
42
|
export { useSandbox } from './hooks/useSandbox';
|
|
43
|
+
export { cameras, VideoParameters, WhipClient, WhepClient, } from 'react-native-whip-whep';
|
|
38
44
|
export { useCameraPermissions, useMicrophonePermissions, } from './hooks/usePermissions';
|
|
39
45
|
export type { FishjamRoomProps } from './components/FishjamRoom';
|
|
40
46
|
export { FishjamRoom } from './components/FishjamRoom';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO;AACL,kBAAkB;AAClB,QAAQ;AACR,kBAAkB;AAClB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAIzB,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO;AACL,kBAAkB;AAClB,QAAQ;AACR,kBAAkB;AAClB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAIzB,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,M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AAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,OAAO,EACP,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -9,7 +9,8 @@ joinRoom,
|
|
|
9
9
|
leaveRoom, } from './common/client';
|
|
10
10
|
export { VideoPreviewView } from './components/VideoPreviewView';
|
|
11
11
|
export { VideoRendererView } from './components/VideoRendererView';
|
|
12
|
-
export {
|
|
12
|
+
export { LivestreamViewer } from './components/LivestreamViewer';
|
|
13
|
+
export { LivestreamStreamer } from './components/LivestreamStreamer';
|
|
13
14
|
// #endregion
|
|
14
15
|
// #region hooks
|
|
15
16
|
export { useAudioSettings } from './hooks/useAudioSettings';
|
|
@@ -24,8 +25,10 @@ export { usePeers } from './hooks/usePeers';
|
|
|
24
25
|
export { useForegroundService } from './hooks/useForegroundService';
|
|
25
26
|
export { useConnection } from './hooks/useConnection';
|
|
26
27
|
export { useUpdatePeerMetadata } from './hooks/useUpdatePeerMetadata';
|
|
27
|
-
export {
|
|
28
|
+
export { useLivestreamViewer } from './hooks/useLivestreamViewer';
|
|
29
|
+
export { useLivestreamStreamer } from './hooks/useLivestreamStreamer';
|
|
28
30
|
export { useSandbox } from './hooks/useSandbox';
|
|
31
|
+
export { cameras, VideoParameters, WhipClient, WhepClient, } from 'react-native-whip-whep';
|
|
29
32
|
// #endregion
|
|
30
33
|
export { useCameraPermissions, useMicrophonePermissions, } from './hooks/usePermissions';
|
|
31
34
|
export { FishjamRoom } from './components/FishjamRoom';
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAYlE,aAAa;AAEb,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO;AACL,kBAAkB;AAClB,QAAQ;AACR,kBAAkB;AAClB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAYlE,aAAa;AAEb,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO;AACL,kBAAkB;AAClB,QAAQ;AACR,kBAAkB;AAClB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,gBA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,CAAC","sourcesContent":["import { initializeWarningListener } from './utils/errorListener';\n\n// #region types\nexport type {\n SimulcastConfig,\n VideoLayout,\n GenericMetadata,\n TrackMetadata,\n Brand,\n RoomType,\n} from './types';\nexport type { ConnectionConfig } from './common/client';\n// #endregion\n\n// #region methods\nexport { updatePeerMetadata } from './common/metadata';\nexport {\n /** @deprecated */\n joinRoom,\n /** @deprecated */\n leaveRoom,\n} from './common/client';\n// #endregion\n\n// #region components\nexport type { VideoPreviewViewProps } from './components/VideoPreviewView';\nexport type { VideoRendererProps } from './components/VideoRendererView';\nexport type {\n LivestreamViewerProps,\n LivestreamViewerRef,\n} from './components/LivestreamViewer';\n\nexport { VideoPreviewView } from './components/VideoPreviewView';\nexport { VideoRendererView } from './components/VideoRendererView';\nexport { LivestreamViewer } from './components/LivestreamViewer';\nexport { LivestreamStreamer } from './components/LivestreamStreamer';\n// #endregion\n\n// #region types for hooks\nexport type {\n Peer,\n PeerId,\n Track,\n TrackId,\n TrackType,\n VadStatus,\n EncodingReason,\n TrackBase,\n AudioTrack,\n VideoTrack,\n UsePeersResult,\n PeerWithTracks,\n PeerTrackMetadata,\n DistinguishedTracks,\n} from './hooks/usePeers';\n\nexport type {\n AudioOutputDevice,\n AudioOutputDeviceType,\n AudioSessionMode,\n} from './hooks/useAudioSettings';\n\nexport type {\n CameraId,\n Camera,\n CameraConfig,\n VideoQuality,\n CameraFacingDirection,\n CameraConfigBase,\n} from './hooks/useCamera';\n\nexport type {\n ScreenShareOptions,\n ScreenShareQuality,\n} from './hooks/useScreenShare';\nexport type { ForegroundServiceConfig } from './hooks/useForegroundService';\nexport type {\n JoinRoomConfig,\n ReconnectionStatus,\n PeerStatus,\n} from './hooks/useConnection';\nexport type { AppScreenShareData } from './hooks/useAppScreenShare';\nexport type { useLivestreamViewerResult } from './hooks/useLivestreamViewer';\nexport type { useLivestreamStreamerResult } from './hooks/useLivestreamStreamer';\nexport type { UseSandboxProps } from './hooks/useSandbox';\nexport type { LivestreamStreamerProps } from './components/LivestreamStreamer';\nexport type { ConnectViewerConfig } from './hooks/useLivestreamViewer';\n// #endregion\n\n// #region hooks\nexport { useAudioSettings } from './hooks/useAudioSettings';\nexport { useBandwidthEstimation } from './hooks/useBandwidthEstimation';\nexport { useCamera } from './hooks/useCamera';\nexport { useMicrophone } from './hooks/useMicrophone';\nexport { useScreenShare } from './hooks/useScreenShare';\nexport { useAppScreenShare } from './hooks/useAppScreenShare';\nexport { useReconnection } from './hooks/useReconnection';\nexport { usePeerStatus } from './hooks/usePeerStatus';\nexport { usePeers } from './hooks/usePeers';\nexport { useForegroundService } from './hooks/useForegroundService';\nexport { useConnection } from './hooks/useConnection';\nexport { useUpdatePeerMetadata } from './hooks/useUpdatePeerMetadata';\nexport { useLivestreamViewer } from './hooks/useLivestreamViewer';\nexport { useLivestreamStreamer } from './hooks/useLivestreamStreamer';\nexport { useSandbox } from './hooks/useSandbox';\nexport {\n cameras,\n VideoParameters,\n WhipClient,\n WhepClient,\n} from 'react-native-whip-whep';\n// #endregion\n\nexport {\n useCameraPermissions,\n useMicrophonePermissions,\n} from './hooks/usePermissions';\n\nexport type { FishjamRoomProps } from './components/FishjamRoom';\nexport { FishjamRoom } from './components/FishjamRoom';\n\ninitializeWarningListener();\n"]}
|
package/ios/Events.swift
CHANGED
|
@@ -93,7 +93,14 @@ class EmitableEvent {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
static func audioDeviceUpdate(currentRoute: AVAudioSessionRouteDescription) -> EmitableEvent {
|
|
96
|
-
|
|
96
|
+
guard let output = currentRoute.outputs.first else {
|
|
97
|
+
return .init(
|
|
98
|
+
event: .AudioDeviceUpdate,
|
|
99
|
+
eventContent: [
|
|
100
|
+
"selectedDevice": nil,
|
|
101
|
+
"availableDevices": [],
|
|
102
|
+
])
|
|
103
|
+
}
|
|
97
104
|
let deviceType = output.portType
|
|
98
105
|
|
|
99
106
|
let deviceTypeString =
|
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '15.1'
|
|
14
14
|
s.swift_version = '5.4'
|
|
15
15
|
s.source = { git: 'https://github.com/fishjam-cloud/mobile-client-sdk/tree/main/packages/react-native-client/ios' }
|
|
16
16
|
s.static_framework = true
|
|
@@ -224,6 +224,11 @@ class RNFishjamClient: FishjamClientListener {
|
|
|
224
224
|
url: String, peerToken: String, peerMetadata: [String: Any], config: ConnectConfig,
|
|
225
225
|
promise: Promise
|
|
226
226
|
) {
|
|
227
|
+
guard connectPromise == nil && peerStatus != .connected else {
|
|
228
|
+
promise.reject("E_MEMBRANE_CONNECT", "Room already joined or it's connecting. You must call leaveRoom() before calling joinRoom() again.")
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
227
232
|
peerStatus = .connecting
|
|
228
233
|
connectPromise = promise
|
|
229
234
|
|
|
@@ -240,6 +245,8 @@ class RNFishjamClient: FishjamClientListener {
|
|
|
240
245
|
}
|
|
241
246
|
|
|
242
247
|
func leaveRoom() {
|
|
248
|
+
connectPromise?.reject("E_MEMBRANE_CONNECT", "leaveRoom called before connected")
|
|
249
|
+
connectPromise = nil
|
|
243
250
|
if isScreenShareOn {
|
|
244
251
|
let screenShareExtensionBundleId =
|
|
245
252
|
Bundle.main.infoDictionary?["ScreenShareExtensionBundleId"] as? String
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/react-native-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "A React Native client for Fishjam",
|
|
5
5
|
"author": "Fishjam Team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"promise-fs": "^2.1.1",
|
|
44
44
|
"protobufjs": "^7.4.0",
|
|
45
|
-
"react-native-whip-whep": "0.
|
|
45
|
+
"react-native-whip-whep": "0.3.1",
|
|
46
46
|
"zod": "^3.25.71"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamView.d.ts","sourceRoot":"","sources":["../../src/components/LivestreamView.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,iBAAiB,GAAG,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;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,iBAAiB,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,8EAQ5B,mBAAmB,gCAUrB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WhepClientView } from 'react-native-whip-whep';
|
|
2
|
-
/**
|
|
3
|
-
* Renders a video player playing the livestream set up with {@link useLivestream} hook.
|
|
4
|
-
*
|
|
5
|
-
* @category Components
|
|
6
|
-
* @param {object} props
|
|
7
|
-
* @param {object} props.style
|
|
8
|
-
*/
|
|
9
|
-
export const LivestreamView = ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }) => (<WhepClientView ref={ref} style={style} orientation={orientation} pipEnabled={pipEnabled} autoStartPip={autoStartPip} autoStopPip={autoStopPip} pipSize={pipSize}/>);
|
|
10
|
-
//# sourceMappingURL=LivestreamView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamView.js","sourceRoot":"","sources":["../../src/components/LivestreamView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AA4C3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,GAAG,GACiB,EAAE,EAAE,CAAC,CACzB,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 LivestreamViewRef = WhepClientViewRef;\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamViewProps = {\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<LivestreamViewRef>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestream} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamView = ({\n style,\n orientation,\n pipEnabled,\n autoStartPip,\n autoStopPip,\n pipSize,\n ref,\n}: LivestreamViewProps) => (\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":"useLivestream.d.ts","sourceRoot":"","sources":["../../src/hooks/useLivestream.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,QAAO,mBAShC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { connectWhepClient, createWhepClient, disconnectWhepClient, } from 'react-native-whip-whep';
|
|
3
|
-
export const useLivestream = () => {
|
|
4
|
-
const connect = useCallback(async (url, token) => {
|
|
5
|
-
createWhepClient(url, {
|
|
6
|
-
authToken: token,
|
|
7
|
-
});
|
|
8
|
-
await connectWhepClient();
|
|
9
|
-
}, []);
|
|
10
|
-
return { connect, disconnect: disconnectWhepClient };
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=useLivestream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivestream.js","sourceRoot":"","sources":["../../src/hooks/useLivestream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAOhC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAwB,EAAE;IACrD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,GAAW,EAAE,KAAa,EAAE,EAAE;QAC/D,gBAAgB,CAAC,GAAG,EAAE;YACpB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import { useCallback } from 'react';\nimport {\n connectWhepClient,\n createWhepClient,\n disconnectWhepClient,\n} from 'react-native-whip-whep';\n\nexport interface UseLivestreamResult {\n connect: (url: string, token: string) => Promise<void>;\n disconnect: () => void;\n}\n\nexport const useLivestream = (): UseLivestreamResult => {\n const connect = useCallback(async (url: string, token: string) => {\n createWhepClient(url, {\n authToken: token,\n });\n await connectWhepClient();\n }, []);\n\n return { connect, disconnect: disconnectWhepClient };\n};\n"]}
|