@fishjam-cloud/react-native-client 0.2.2 → 0.2.4
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/README.md +9 -397
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +2 -1
- package/android/src/main/java/io/fishjam/reactnative/Errors.kt +3 -2
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +86 -73
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +20 -19
- package/build/RNFishjamClientModule.d.ts +10 -8
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js +2 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +8 -5
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +9 -6
- package/build/common/client.js.map +1 -1
- package/build/common/metadata.d.ts +4 -3
- package/build/common/metadata.d.ts.map +1 -1
- package/build/common/metadata.js +5 -4
- package/build/common/metadata.js.map +1 -1
- package/build/common/webRTC.d.ts +2 -0
- package/build/common/webRTC.d.ts.map +1 -1
- package/build/common/webRTC.js +2 -0
- package/build/common/webRTC.js.map +1 -1
- package/build/components/VideoPreviewView.d.ts +6 -3
- package/build/components/VideoPreviewView.d.ts.map +1 -1
- package/build/components/VideoPreviewView.js +5 -0
- package/build/components/VideoPreviewView.js.map +1 -1
- package/build/components/VideoRendererView.d.ts +5 -3
- package/build/components/VideoRendererView.d.ts.map +1 -1
- package/build/components/VideoRendererView.js +4 -0
- package/build/components/VideoRendererView.js.map +1 -1
- package/build/hooks/useAudioSettings.d.ts +15 -0
- package/build/hooks/useAudioSettings.d.ts.map +1 -1
- package/build/hooks/useAudioSettings.js +15 -13
- package/build/hooks/useAudioSettings.js.map +1 -1
- package/build/hooks/useBandwidthEstimation.d.ts +2 -0
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
- package/build/hooks/useBandwidthEstimation.js +2 -0
- package/build/hooks/useBandwidthEstimation.js.map +1 -1
- package/build/hooks/useCamera.d.ts +62 -1
- package/build/hooks/useCamera.d.ts.map +1 -1
- package/build/hooks/useCamera.js +46 -38
- package/build/hooks/useCamera.js.map +1 -1
- package/build/hooks/useFishjamEvent.d.ts +2 -1
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +4 -5
- package/build/hooks/useFishjamEvent.js.map +1 -1
- package/build/hooks/useMicrophone.d.ts +4 -0
- package/build/hooks/useMicrophone.d.ts.map +1 -1
- package/build/hooks/useMicrophone.js +8 -4
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/useParticipants.d.ts +2 -0
- package/build/hooks/useParticipants.d.ts.map +1 -1
- package/build/hooks/useParticipants.js +2 -0
- package/build/hooks/useParticipants.js.map +1 -1
- package/build/hooks/useReconnection.d.ts +6 -0
- package/build/hooks/useReconnection.d.ts.map +1 -1
- package/build/hooks/useReconnection.js +6 -0
- package/build/hooks/useReconnection.js.map +1 -1
- package/build/hooks/useScreenShare.d.ts +57 -0
- package/build/hooks/useScreenShare.d.ts.map +1 -0
- package/build/hooks/useScreenShare.js +85 -0
- package/build/hooks/useScreenShare.js.map +1 -0
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/stats/useRTCStatistics.d.ts +1 -0
- package/build/stats/useRTCStatistics.d.ts.map +1 -1
- package/build/stats/useRTCStatistics.js +1 -0
- package/build/stats/useRTCStatistics.js.map +1 -1
- package/build/types.d.ts +6 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/errorListener.d.ts +2 -0
- package/build/utils/errorListener.d.ts.map +1 -0
- package/build/utils/errorListener.js +16 -0
- package/build/utils/errorListener.js.map +1 -0
- package/build/utils/foregroundService.d.ts +2 -0
- package/build/utils/foregroundService.d.ts.map +1 -1
- package/build/utils/foregroundService.js +2 -0
- package/build/utils/foregroundService.js.map +1 -1
- package/ios/Events.swift +2 -1
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +76 -62
- package/ios/RNFishjamClientModule.swift +18 -17
- package/package.json +13 -10
- package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +50 -0
- package/plugin/broadcastExtensionFiles/FishjamScreenBroadcastExtension.entitlements +10 -0
- package/plugin/broadcastExtensionFiles/Info.plist +27 -0
- package/plugin/build/types.d.ts +5 -5
- package/plugin/build/withFishjamAndroid.js +2 -2
- package/plugin/build/withFishjamIos.js +4 -4
- package/build/hooks/useScreencast.d.ts +0 -38
- package/build/hooks/useScreencast.d.ts.map +0 -1
- package/build/hooks/useScreencast.js +0 -77
- package/build/hooks/useScreencast.js.map +0 -1
package/build/common/webRTC.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export type LoggingSeverity = 'verbose' | 'info' | 'warning' | 'error' | 'none';
|
|
|
8
8
|
*
|
|
9
9
|
* @param trackId id of a track which encoding you want to select
|
|
10
10
|
* @param encoding encoding to select
|
|
11
|
+
* @category Debugging
|
|
11
12
|
*/
|
|
12
13
|
export declare function setTargetTrackEncoding(trackId: string, encoding: TrackEncoding): Promise<void>;
|
|
13
14
|
/**
|
|
14
15
|
* Function that changes level of debugging logs in WebRTC.
|
|
15
16
|
* @param severity to use when displaying logs
|
|
16
17
|
* @returns a promise that is resolved when debug severity is changed
|
|
18
|
+
* @category Debugging
|
|
17
19
|
*/
|
|
18
20
|
export declare function changeWebRTCLoggingSeverity(severity: LoggingSeverity): Promise<void>;
|
|
19
21
|
//# sourceMappingURL=webRTC.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webRTC.d.ts","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"webRTC.d.ts","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,iBAGxB;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
package/build/common/webRTC.js
CHANGED
|
@@ -7,6 +7,7 @@ import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
|
7
7
|
*
|
|
8
8
|
* @param trackId id of a track which encoding you want to select
|
|
9
9
|
* @param encoding encoding to select
|
|
10
|
+
* @category Debugging
|
|
10
11
|
*/
|
|
11
12
|
export async function setTargetTrackEncoding(trackId, encoding) {
|
|
12
13
|
await RNFishjamClientModule.setTargetTrackEncoding(trackId, encoding);
|
|
@@ -15,6 +16,7 @@ export async function setTargetTrackEncoding(trackId, encoding) {
|
|
|
15
16
|
* Function that changes level of debugging logs in WebRTC.
|
|
16
17
|
* @param severity to use when displaying logs
|
|
17
18
|
* @returns a promise that is resolved when debug severity is changed
|
|
19
|
+
* @category Debugging
|
|
18
20
|
*/
|
|
19
21
|
export function changeWebRTCLoggingSeverity(severity) {
|
|
20
22
|
return RNFishjamClientModule.changeWebRTCLoggingSeverity(severity);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webRTC.js","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAI7D
|
|
1
|
+
{"version":3,"file":"webRTC.js","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAI7D;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAe,EACf,QAAuB;IAEvB,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACxE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAyB;IAEzB,OAAO,qBAAqB,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { TrackEncoding } from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nexport type LoggingSeverity = 'verbose' | 'info' | 'warning' | 'error' | 'none';\n\n/**\n * sets track encoding that server should send to the client library.\n * The encoding will be sent whenever it is available. If chooses encoding is\n * temporarily unavailable, some other encoding will be sent until choose encoding\n * becomes active again.\n *\n * @param trackId id of a track which encoding you want to select\n * @param encoding encoding to select\n * @category Debugging\n */\nexport async function setTargetTrackEncoding(\n trackId: string,\n encoding: TrackEncoding,\n) {\n await RNFishjamClientModule.setTargetTrackEncoding(trackId, encoding);\n}\n\n/**\n * Function that changes level of debugging logs in WebRTC.\n * @param severity to use when displaying logs\n * @returns a promise that is resolved when debug severity is changed\n * @category Debugging\n */\nexport function changeWebRTCLoggingSeverity(\n severity: LoggingSeverity,\n): Promise<void> {\n return RNFishjamClientModule.changeWebRTCLoggingSeverity(severity);\n}\n"]}
|
|
@@ -4,9 +4,7 @@ import { VideoLayout } from '../types';
|
|
|
4
4
|
import { CameraId } from '../hooks/useCamera';
|
|
5
5
|
export type VideoPreviewViewProps = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* with video and it may cut some parts of the video. `FIT` scales the video so the whole
|
|
9
|
-
* video is visible, but it may leave some empty space in the view.
|
|
7
|
+
* Video layout inside of the component
|
|
10
8
|
* @default `FILL`
|
|
11
9
|
*/
|
|
12
10
|
videoLayout?: VideoLayout;
|
|
@@ -17,5 +15,10 @@ export type VideoPreviewViewProps = {
|
|
|
17
15
|
*/
|
|
18
16
|
cameraId?: CameraId;
|
|
19
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Render camera preview.
|
|
20
|
+
* Allows to display camera preview beofre streaming is started
|
|
21
|
+
* @category Components
|
|
22
|
+
*/
|
|
20
23
|
export declare const VideoPreviewView: React.ForwardRefExoticComponent<VideoPreviewViewProps & React.RefAttributes<React.ComponentType<VideoPreviewViewProps>>>;
|
|
21
24
|
//# sourceMappingURL=VideoPreviewView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPreviewView.d.ts","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG;IAClC
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.d.ts","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0HAM3B,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
const NativeView = requireNativeViewManager('VideoPreviewViewModule');
|
|
4
|
+
/**
|
|
5
|
+
* Render camera preview.
|
|
6
|
+
* Allows to display camera preview beofre streaming is started
|
|
7
|
+
* @category Components
|
|
8
|
+
*/
|
|
4
9
|
export const VideoPreviewView = React.forwardRef((props, ref) => (
|
|
5
10
|
// @ts-expect-error ref prop needs to be updated
|
|
6
11
|
<NativeView {...props} captureDeviceId={props.cameraId} ref={ref}/>));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAG9C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACrE,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport { CameraId } from '../hooks/useCamera';\n\nexport type VideoPreviewViewProps = {\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n style?: ViewStyle;\n /**\n * Id of the camera used for preview. Get available cameras with `cameras` property.\n * @default the first front camera\n */\n cameraId?: CameraId;\n};\n\nconst NativeView: React.ComponentType<VideoPreviewViewProps> =\n requireNativeViewManager('VideoPreviewViewModule');\n\n/**\n * Render camera preview.\n * Allows to display camera preview beofre streaming is started\n * @category Components\n */\nexport const VideoPreviewView = React.forwardRef<\n React.ComponentType<VideoPreviewViewProps>,\n VideoPreviewViewProps\n>((props, ref) => (\n // @ts-expect-error ref prop needs to be updated\n <NativeView {...props} captureDeviceId={props.cameraId} ref={ref} />\n));\n"]}
|
|
@@ -7,13 +7,15 @@ export type VideoRendererProps = {
|
|
|
7
7
|
*/
|
|
8
8
|
trackId: string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* with video and it may cut some parts of the video. `FIT` scales the video so the whole
|
|
12
|
-
* video is visible, but it may leave some empty space in the view.
|
|
10
|
+
* Video layout inside of the component
|
|
13
11
|
* @default `FILL`
|
|
14
12
|
*/
|
|
15
13
|
videoLayout?: VideoLayout;
|
|
16
14
|
style?: ViewStyle;
|
|
17
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Render video track received from {@link useParticipants} hook
|
|
18
|
+
* @category Components
|
|
19
|
+
*/
|
|
18
20
|
export declare const VideoRendererView: React.ForwardRefExoticComponent<VideoRendererProps & React.RefAttributes<React.ComponentType<VideoRendererProps>>>;
|
|
19
21
|
//# sourceMappingURL=VideoRendererView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoRendererView.d.ts","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB
|
|
1
|
+
{"version":3,"file":"VideoRendererView.d.ts","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oHAM5B,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
const NativeView = requireNativeViewManager('VideoRendererViewModule');
|
|
4
|
+
/**
|
|
5
|
+
* Render video track received from {@link useParticipants} hook
|
|
6
|
+
* @category Components
|
|
7
|
+
*/
|
|
4
8
|
export const VideoRendererView = React.forwardRef((props, ref) => (
|
|
5
9
|
// @ts-expect-error ref prop needs to be updated
|
|
6
10
|
<NativeView {...props} ref={ref}/>));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoRendererView.js","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoRendererView.js","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAG/C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACpC,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\n\nexport type VideoRendererProps = {\n /**\n * id of the video track which you want to render.\n */\n trackId: string;\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n style?: ViewStyle;\n};\n\nconst NativeView: React.ComponentType<VideoRendererProps> =\n requireNativeViewManager('VideoRendererViewModule');\n\n/**\n * Render video track received from {@link useParticipants} hook\n * @category Components\n */\nexport const VideoRendererView = React.forwardRef<\n React.ComponentType<VideoRendererProps>,\n VideoRendererProps\n>((props, ref) => (\n // @ts-expect-error ref prop needs to be updated\n <NativeView {...props} ref={ref} />\n));\n"]}
|
|
@@ -6,6 +6,8 @@ export type AudioOutputDevice = {
|
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* This hook manages audio settings.
|
|
9
|
+
* @category Devices
|
|
10
|
+
* @group Hooks
|
|
9
11
|
*/
|
|
10
12
|
export declare function useAudioSettings(): {
|
|
11
13
|
/**
|
|
@@ -16,8 +18,21 @@ export declare function useAudioSettings(): {
|
|
|
16
18
|
* [Android only] available audio output devices to be set
|
|
17
19
|
*/
|
|
18
20
|
availableDevices: AudioOutputDevice[];
|
|
21
|
+
/**
|
|
22
|
+
* [Android only] selects output audio device.
|
|
23
|
+
* For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.
|
|
24
|
+
*/
|
|
19
25
|
selectOutputAudioDevice: (device: AudioOutputDeviceType) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* [iOS only] selects audio session mode. For more information refer to Apple's documentation:
|
|
28
|
+
* https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
20
31
|
selectAudioSessionMode: (audioSessionMode: AudioSessionMode) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* [iOS only] Shows a picker modal that allows user to select output audio device. For more
|
|
34
|
+
* information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview
|
|
35
|
+
*/
|
|
21
36
|
showAudioRoutePicker: () => Promise<void>;
|
|
22
37
|
};
|
|
23
38
|
//# sourceMappingURL=useAudioSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAMA,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;AAOF
|
|
1
|
+
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAMA,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;AAOF;;;;GAIG;AACH,wBAAgB,gBAAgB;IAyD5B;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;sCA5CY,qBAAqB;IA8CpC;;;;OAIG;+CArCsB,gBAAgB;IAuCzC;;;OAGG;;EAGN"}
|
|
@@ -4,6 +4,8 @@ import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
|
4
4
|
import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
|
|
5
5
|
/**
|
|
6
6
|
* This hook manages audio settings.
|
|
7
|
+
* @category Devices
|
|
8
|
+
* @group Hooks
|
|
7
9
|
*/
|
|
8
10
|
export function useAudioSettings() {
|
|
9
11
|
const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] = useState(null);
|
|
@@ -21,10 +23,6 @@ export function useAudioSettings() {
|
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
}, [onAudioDevice]);
|
|
24
|
-
/**
|
|
25
|
-
* [Android only] selects output audio device.
|
|
26
|
-
* For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.
|
|
27
|
-
*/
|
|
28
26
|
const selectOutputAudioDevice = useCallback(async (device) => {
|
|
29
27
|
if (Platform.OS === 'ios') {
|
|
30
28
|
throw Error('selectOutputAudioDevice function is supported only on Android. ' +
|
|
@@ -32,21 +30,12 @@ export function useAudioSettings() {
|
|
|
32
30
|
}
|
|
33
31
|
await RNFishjamClientModule.setOutputAudioDevice(device);
|
|
34
32
|
}, []);
|
|
35
|
-
/**
|
|
36
|
-
* [iOS only] selects audio session mode. For more information refer to Apple's documentation:
|
|
37
|
-
* https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
33
|
const selectAudioSessionMode = useCallback(async (audioSessionMode) => {
|
|
41
34
|
if (Platform.OS === 'android') {
|
|
42
35
|
throw Error('selectAudioSessionMode function is supported only on iOS');
|
|
43
36
|
}
|
|
44
37
|
await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);
|
|
45
38
|
}, []);
|
|
46
|
-
/**
|
|
47
|
-
* [iOS only] Shows a picker modal that allows user to select output audio device. For more
|
|
48
|
-
* information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview
|
|
49
|
-
*/
|
|
50
39
|
const showAudioRoutePicker = useCallback(async () => {
|
|
51
40
|
if (Platform.OS === 'android') {
|
|
52
41
|
throw Error('showAudioRoutePicker function is supported only on iOS. ' +
|
|
@@ -63,8 +52,21 @@ export function useAudioSettings() {
|
|
|
63
52
|
* [Android only] available audio output devices to be set
|
|
64
53
|
*/
|
|
65
54
|
availableDevices,
|
|
55
|
+
/**
|
|
56
|
+
* [Android only] selects output audio device.
|
|
57
|
+
* For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.
|
|
58
|
+
*/
|
|
66
59
|
selectOutputAudioDevice,
|
|
60
|
+
/**
|
|
61
|
+
* [iOS only] selects audio session mode. For more information refer to Apple's documentation:
|
|
62
|
+
* https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
67
65
|
selectAudioSessionMode,
|
|
66
|
+
/**
|
|
67
|
+
* [iOS only] Shows a picker modal that allows user to select output audio device. For more
|
|
68
|
+
* information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview
|
|
69
|
+
*/
|
|
68
70
|
showAudioRoutePicker,
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.js","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,eAA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CAAC;YAC1B,MAAM,KAAK,CACT,iEAAiE;gBAC/D,sGAAsG,CACzG,CAAC;QACJ,CAAC;QACD,MAAM,qBAAqB,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,sBAAsB,GAAG,WAAW,CACxC,KAAK,EAAE,gBAAkC,EAAE,EAAE;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, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\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\ntype OnAudioDeviceEvent = {\n selectedDevice: AudioOutputDevice;\n availableDevices: AudioOutputDevice[];\n};\n\n/**\n * This hook manages audio settings.\n * @category Devices\n * @group Hooks\n */\nexport function useAudioSettings() {\n const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] =\n useState<AudioOutputDevice | null>(null);\n const [availableDevices, setAvailableDevices] = useState<AudioOutputDevice[]>(\n [],\n );\n\n const onAudioDevice = useCallback((event: OnAudioDeviceEvent) => {\n setSelectedAudioOutputDevice(event.selectedDevice);\n setAvailableDevices(event.availableDevices);\n }, []);\n\n useFishjamEvent(ReceivableEvents.AudioDeviceUpdate, onAudioDevice);\n\n useEffect(() => {\n RNFishjamClientModule.startAudioSwitcher();\n return () => {\n if (Platform.OS === 'android') {\n RNFishjamClientModule.stopAudioSwitcher();\n }\n };\n }, [onAudioDevice]);\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"]}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* This hook provides current bandwidth estimation
|
|
3
3
|
* estimation - client's available incoming bitrate estimated
|
|
4
4
|
* by the server. It's measured in bits per second.
|
|
5
|
+
* @category Debugging
|
|
6
|
+
* @group Hooks
|
|
5
7
|
*/
|
|
6
8
|
export declare function useBandwidthEstimation(): {
|
|
7
9
|
estimation: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,sBAAsB;;EAMrC"}
|
|
@@ -4,6 +4,8 @@ import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
|
|
|
4
4
|
* This hook provides current bandwidth estimation
|
|
5
5
|
* estimation - client's available incoming bitrate estimated
|
|
6
6
|
* by the server. It's measured in bits per second.
|
|
7
|
+
* @category Debugging
|
|
8
|
+
* @group Hooks
|
|
7
9
|
*/
|
|
8
10
|
export function useBandwidthEstimation() {
|
|
9
11
|
const [estimation, setEstimation] = useState(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAElE,eAAe,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;IAErE,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import { useState } from 'react';\n\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\n/**\n * This hook provides current bandwidth estimation\n * estimation - client's available incoming bitrate estimated\n * by the server. It's measured in bits per second.\n * @category Debugging\n * @group Hooks\n */\nexport function useBandwidthEstimation() {\n const [estimation, setEstimation] = useState<number | null>(null);\n\n useFishjamEvent(ReceivableEvents.BandwidthEstimation, setEstimation);\n\n return { estimation };\n}\n"]}
|
|
@@ -15,6 +15,23 @@ type CameraConfigBase = {
|
|
|
15
15
|
* @default `VGA_169`
|
|
16
16
|
*/
|
|
17
17
|
quality?: VideoQuality;
|
|
18
|
+
/**
|
|
19
|
+
* whether to flip the dimensions of the video, that is whether to film in vertical orientation.
|
|
20
|
+
* This basically switches width with height and is only used to select closes capture format.
|
|
21
|
+
*
|
|
22
|
+
* To record horizontal video your phone orientation must be in landscape and your app must support this orientation.
|
|
23
|
+
*
|
|
24
|
+
* Platform specific capture formats:
|
|
25
|
+
* @see iOS: https://developer.apple.com/documentation/avfoundation/avcapturedevice/format
|
|
26
|
+
* @see Android: https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50
|
|
27
|
+
*
|
|
28
|
+
* WebRTC device orientation handling:
|
|
29
|
+
* @see iOS: https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285
|
|
30
|
+
* @see Android: https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347
|
|
31
|
+
*
|
|
32
|
+
* @default `true`
|
|
33
|
+
*/
|
|
34
|
+
flipDimensions?: boolean;
|
|
18
35
|
/**
|
|
19
36
|
* whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method
|
|
20
37
|
* @default `true`
|
|
@@ -54,17 +71,61 @@ export type CameraConfigInternal = CameraConfigBase & {
|
|
|
54
71
|
export declare function updateCameraConfig(config: Readonly<CameraConfig>): CameraConfigInternal;
|
|
55
72
|
/**
|
|
56
73
|
* This hook can toggle camera on/off and provides current camera state.
|
|
74
|
+
* @category Devices
|
|
75
|
+
* @group Hooks
|
|
57
76
|
*/
|
|
58
77
|
export declare function useCamera(): {
|
|
78
|
+
/**
|
|
79
|
+
* Informs if user camera is streaming video
|
|
80
|
+
*/
|
|
59
81
|
isCameraOn: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Which camera is now used for streaming (or will be used as default when camera will be enabled)
|
|
84
|
+
*/
|
|
60
85
|
currentCamera: Camera | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Simulcast configuration
|
|
88
|
+
*/
|
|
61
89
|
simulcastConfig: SimulcastConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Property that lists cameras available on device.
|
|
92
|
+
* @returns A promise that resolves to the list of available cameras.
|
|
93
|
+
*/
|
|
62
94
|
cameras: readonly Camera[];
|
|
95
|
+
/** Enable/disable current camera */
|
|
63
96
|
toggleCamera: () => Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Prepares camera and starts local video track
|
|
99
|
+
* @param config configuration of the camera capture
|
|
100
|
+
* @returns A promise that resolves when camera is started.
|
|
101
|
+
*/
|
|
64
102
|
prepareCamera: (config?: Readonly<CameraConfig>) => Promise<void>;
|
|
65
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Switches to the specified camera.
|
|
105
|
+
* List of available devices can be retrieved from `cameras` variable
|
|
106
|
+
* @returns A promise that resolves when camera is switched.
|
|
107
|
+
*/ switchCamera: (cameraId: CameraId) => Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated
|
|
110
|
+
* toggles encoding of a video track on/off
|
|
111
|
+
* @param encoding encoding to toggle
|
|
112
|
+
*/
|
|
66
113
|
toggleVideoTrackEncoding: (encoding: TrackEncoding) => Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
116
|
+
* @param encoding encoding to update
|
|
117
|
+
* @param bandwidth BandwidthLimit to set
|
|
118
|
+
* @deprecated
|
|
119
|
+
*/
|
|
67
120
|
setVideoTrackEncodingBandwidth: (encoding: TrackEncoding, bandwidth: BandwidthLimit) => Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* updates maximum bandwidth for the video track. This value directly translates
|
|
123
|
+
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
124
|
+
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
125
|
+
* their resolution.
|
|
126
|
+
* @param BandwidthLimit to set
|
|
127
|
+
* @deprecated
|
|
128
|
+
*/
|
|
68
129
|
setVideoTrackBandwidth: (bandwidth: BandwidthLimit) => Promise<void>;
|
|
69
130
|
};
|
|
70
131
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,KAAK,EACL,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB,MAAM,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pC;IAAE,eAAe,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAChD,CAAC;AAuCJ,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAC7B,oBAAoB,CAOtB;AAED;;;;GAIG;AACH,wBAAgB,SAAS;IAsFrB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAGH,oCAAoC;;IAEpC;;;;OAIG;6BArFY,QAAQ,CAAC,YAAY,CAAC;IAuFrC;;;;OAIG,0BAhEc,QAAQ;IAkEzB;;;;OAIG;yCAvDc,aAAa;IAyD9B;;;;;OAKG;+CArDc,aAAa,aAAa,cAAc;IAuDzD;;;;;;;OAOG;wCA9Ee,cAAc;EAiFnC"}
|
package/build/hooks/useCamera.js
CHANGED
|
@@ -25,7 +25,7 @@ function maxBandwidthConfig(maxBandwidth) {
|
|
|
25
25
|
}
|
|
26
26
|
function simulcastConfig(simulcastEnabled) {
|
|
27
27
|
// iOS has a limit of 3 hardware encoders
|
|
28
|
-
// 3 simulcast layers + 1
|
|
28
|
+
// 3 simulcast layers + 1 screen share layer = 4, which is too much
|
|
29
29
|
// so we limit simulcast layers to 2
|
|
30
30
|
if (simulcastEnabled) {
|
|
31
31
|
return Platform.select({
|
|
@@ -45,6 +45,8 @@ export function updateCameraConfig(config) {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* This hook can toggle camera on/off and provides current camera state.
|
|
48
|
+
* @category Devices
|
|
49
|
+
* @group Hooks
|
|
48
50
|
*/
|
|
49
51
|
export function useCamera() {
|
|
50
52
|
const [isCameraOn, setIsCameraOn] = useState(RNFishjamClientModule.isCameraOn);
|
|
@@ -52,18 +54,9 @@ export function useCamera() {
|
|
|
52
54
|
const [simulcastConfig, setSimulcastConfig] = useState(defaultSimulcastConfig());
|
|
53
55
|
useFishjamEvent(ReceivableEvents.SimulcastConfigUpdate, setSimulcastConfig);
|
|
54
56
|
useFishjamEvent(ReceivableEvents.IsCameraOn, setIsCameraOn);
|
|
55
|
-
/**
|
|
56
|
-
* Property that lists cameras available on device.
|
|
57
|
-
* @returns A promise that resolves to the list of available cameras.
|
|
58
|
-
*/
|
|
59
57
|
const cameras = useMemo(() => {
|
|
60
58
|
return RNFishjamClientModule.cameras;
|
|
61
59
|
}, []);
|
|
62
|
-
/**
|
|
63
|
-
* Prepares camera and starts local camera capture.
|
|
64
|
-
* @param config configuration of the camera capture
|
|
65
|
-
* @returns A promise that resolves when camera is started.
|
|
66
|
-
*/
|
|
67
60
|
const prepareCamera = useCallback(async (config = {}) => {
|
|
68
61
|
const camera = RNFishjamClientModule.cameras.find((camera) => config.cameraId
|
|
69
62
|
? camera.id === config.cameraId
|
|
@@ -75,9 +68,6 @@ export function useCamera() {
|
|
|
75
68
|
});
|
|
76
69
|
await RNFishjamClientModule.startCamera(updatedConfig);
|
|
77
70
|
}, []);
|
|
78
|
-
/**
|
|
79
|
-
* Toggles camera on/off
|
|
80
|
-
*/
|
|
81
71
|
const toggleCamera = useCallback(async () => {
|
|
82
72
|
const state = await RNFishjamClientModule.toggleCamera();
|
|
83
73
|
await RNFishjamClientModule.updateVideoTrackMetadata({
|
|
@@ -86,54 +76,72 @@ export function useCamera() {
|
|
|
86
76
|
});
|
|
87
77
|
setIsCameraOn(state);
|
|
88
78
|
}, []);
|
|
89
|
-
/**
|
|
90
|
-
* Switches to the specified camera.
|
|
91
|
-
* List of available devices can be retrieved from `cameras` variable
|
|
92
|
-
* @returns A promise that resolves when camera is switched.
|
|
93
|
-
*/
|
|
94
79
|
const switchCamera = useCallback(async (cameraId) => {
|
|
95
80
|
await RNFishjamClientModule.switchCamera(cameraId);
|
|
96
81
|
setCurrentCamera(cameras.find((camera) => camera.id === cameraId));
|
|
97
82
|
}, [cameras]);
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated
|
|
100
|
-
* updates maximum bandwidth for the video track. This value directly translates
|
|
101
|
-
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
102
|
-
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
103
|
-
* their resolution.
|
|
104
|
-
* @param BandwidthLimit to set
|
|
105
|
-
*/
|
|
106
83
|
const setVideoTrackBandwidth = useCallback(async (bandwidth) => {
|
|
107
84
|
await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);
|
|
108
85
|
}, []);
|
|
109
|
-
/**
|
|
110
|
-
* @deprecated
|
|
111
|
-
* toggles encoding of a video track on/off
|
|
112
|
-
* @param encoding encoding to toggle
|
|
113
|
-
*/
|
|
114
86
|
const toggleVideoTrackEncoding = useCallback(async (encoding) => {
|
|
115
87
|
const videoSimulcastConfig = await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);
|
|
116
88
|
setSimulcastConfig(videoSimulcastConfig);
|
|
117
89
|
}, []);
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated
|
|
120
|
-
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
121
|
-
* @param encoding encoding to update
|
|
122
|
-
* @param bandwidth BandwidthLimit to set
|
|
123
|
-
*/
|
|
124
90
|
const setVideoTrackEncodingBandwidth = useCallback(async (encoding, bandwidth) => {
|
|
125
91
|
await RNFishjamClientModule.setVideoTrackEncodingBandwidth(encoding, bandwidth);
|
|
126
92
|
}, []);
|
|
127
93
|
return {
|
|
94
|
+
/**
|
|
95
|
+
* Informs if user camera is streaming video
|
|
96
|
+
*/
|
|
128
97
|
isCameraOn,
|
|
98
|
+
/**
|
|
99
|
+
* Which camera is now used for streaming (or will be used as default when camera will be enabled)
|
|
100
|
+
*/
|
|
129
101
|
currentCamera,
|
|
102
|
+
/**
|
|
103
|
+
* Simulcast configuration
|
|
104
|
+
*/
|
|
130
105
|
simulcastConfig,
|
|
106
|
+
/**
|
|
107
|
+
* Property that lists cameras available on device.
|
|
108
|
+
* @returns A promise that resolves to the list of available cameras.
|
|
109
|
+
*/
|
|
131
110
|
cameras,
|
|
111
|
+
/** Enable/disable current camera */
|
|
132
112
|
toggleCamera,
|
|
113
|
+
/**
|
|
114
|
+
* Prepares camera and starts local video track
|
|
115
|
+
* @param config configuration of the camera capture
|
|
116
|
+
* @returns A promise that resolves when camera is started.
|
|
117
|
+
*/
|
|
133
118
|
prepareCamera,
|
|
134
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Switches to the specified camera.
|
|
121
|
+
* List of available devices can be retrieved from `cameras` variable
|
|
122
|
+
* @returns A promise that resolves when camera is switched.
|
|
123
|
+
*/ switchCamera,
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated
|
|
126
|
+
* toggles encoding of a video track on/off
|
|
127
|
+
* @param encoding encoding to toggle
|
|
128
|
+
*/
|
|
135
129
|
toggleVideoTrackEncoding,
|
|
130
|
+
/**
|
|
131
|
+
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
132
|
+
* @param encoding encoding to update
|
|
133
|
+
* @param bandwidth BandwidthLimit to set
|
|
134
|
+
* @deprecated
|
|
135
|
+
*/
|
|
136
136
|
setVideoTrackEncodingBandwidth,
|
|
137
|
+
/**
|
|
138
|
+
* updates maximum bandwidth for the video track. This value directly translates
|
|
139
|
+
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
140
|
+
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
141
|
+
* their resolution.
|
|
142
|
+
* @param BandwidthLimit to set
|
|
143
|
+
* @deprecated
|
|
144
|
+
*/
|
|
137
145
|
setVideoTrackBandwidth,
|
|
138
146
|
};
|
|
139
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM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;QAEP,YAAY;QACZ,aAAa;QACb,YAAY;QAEZ,wBAAwB;QACxB,8BAA8B;QAC9B,sBAAsB;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n BandwidthLimit,\n Brand,\n SimulcastBandwidthLimit,\n SimulcastConfig,\n TrackBandwidthLimit,\n TrackEncoding,\n} from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\ntype SimulcastConfigUpdateEvent = SimulcastConfig;\nexport type CameraId = Brand<string, 'CameraId'>;\n\nexport type CameraFacingDirection = 'front' | 'back' | 'unspecified';\n\nexport type Camera = {\n id: CameraId;\n name: string;\n facingDirection: CameraFacingDirection;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\ntype CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method\n * @default `true`\n */\n cameraEnabled?: boolean;\n /**\n * id of the camera to start capture with. Get available cameras with `cameras`.\n * You can switch the cameras later with `switchCamera` functions.\n * @default the first front camera\n */\n cameraId?: CameraId;\n};\n\nexport type CameraConfig = CameraConfigBase & {\n /**\n * whether video track uses simulcast. By default simulcast is disabled.\n */\n simulcastEnabled?: boolean;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n};\n\nexport type CameraConfigInternal = CameraConfigBase & {\n videoTrackMetadata?: { active: boolean; type: 'camera' };\n /**\n * SimulcastConfig of a video track. By default simulcast is disabled.\n */\n simulcastConfig?: SimulcastConfig;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n maxBandwidth?: TrackBandwidthLimit;\n} & (\n | { maxBandwidthInt?: BandwidthLimit }\n | { maxBandwidthMap?: SimulcastBandwidthLimit }\n );\n\nconst defaultSimulcastConfig = () => ({\n enabled: false,\n activeEncodings: [],\n});\n\nfunction maxBandwidthConfig(maxBandwidth: TrackBandwidthLimit | undefined) {\n if (Platform.OS === 'android') {\n if (typeof maxBandwidth === 'object') {\n return {\n maxBandwidth: undefined,\n maxBandwidthMap: maxBandwidth,\n };\n } else {\n return {\n maxBandwidth: undefined,\n maxBandwidthInt: maxBandwidth,\n };\n }\n }\n return { maxBandwidth };\n}\n\nfunction simulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n // iOS has a limit of 3 hardware encoders\n // 3 simulcast layers + 1 screencast layer = 4, which is too much\n // so we limit simulcast layers to 2\n if (simulcastEnabled) {\n return Platform.select<SimulcastConfig>({\n ios: { enabled: true, activeEncodings: ['l', 'h'] },\n android: { enabled: true, activeEncodings: ['l', 'm', 'h'] },\n });\n }\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n ...maxBandwidthConfig({ l: 150, m: 500, h: 1500 }),\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: simulcastConfig(config.simulcastEnabled),\n };\n}\n\n/**\n * This hook can toggle camera on/off and provides current camera state.\n */\nexport function useCamera() {\n const [isCameraOn, setIsCameraOn] = useState<boolean>(\n RNFishjamClientModule.isCameraOn,\n );\n\n const [currentCamera, setCurrentCamera] = useState<Camera | undefined>(\n undefined,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n defaultSimulcastConfig(),\n );\n\n useFishjamEvent<SimulcastConfigUpdateEvent>(\n ReceivableEvents.SimulcastConfigUpdate,\n setSimulcastConfig,\n );\n\n useFishjamEvent(ReceivableEvents.IsCameraOn, setIsCameraOn);\n\n /**\n * Property that lists cameras available on device.\n * @returns A promise that resolves to the list of available cameras.\n */\n const cameras = useMemo(() => {\n return RNFishjamClientModule.cameras;\n }, []);\n\n /**\n * Prepares camera and starts local camera capture.\n * @param config configuration of the camera capture\n * @returns A promise that resolves when camera is started.\n */\n const prepareCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const camera = RNFishjamClientModule.cameras.find((camera) =>\n config.cameraId\n ? camera.id === config.cameraId\n : camera.facingDirection === 'front',\n );\n\n setCurrentCamera(camera);\n const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n await RNFishjamClientModule.startCamera(updatedConfig);\n },\n [],\n );\n\n /**\n * Toggles camera on/off\n */\n const toggleCamera = useCallback(async () => {\n const state = await RNFishjamClientModule.toggleCamera();\n await RNFishjamClientModule.updateVideoTrackMetadata({\n active: state,\n type: 'camera',\n });\n setIsCameraOn(state);\n }, []);\n\n /**\n * Switches to the specified camera.\n * List of available devices can be retrieved from `cameras` variable\n * @returns A promise that resolves when camera is switched.\n */\n const switchCamera = useCallback(\n async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\n setCurrentCamera(cameras.find((camera) => camera.id === cameraId));\n },\n [cameras],\n );\n\n /**\n * @deprecated\n * updates maximum bandwidth for the video track. This value directly translates\n * to quality of the stream and the amount of RTP packets being sent. In case simulcast\n * is enabled bandwidth is split between all of the variant streams proportionally to\n * their resolution.\n * @param BandwidthLimit to set\n */\n const setVideoTrackBandwidth = useCallback(\n async (bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);\n },\n [],\n );\n\n /**\n * @deprecated\n * toggles encoding of a video track on/off\n * @param encoding encoding to toggle\n */\n const toggleVideoTrackEncoding = useCallback(\n async (encoding: TrackEncoding) => {\n const videoSimulcastConfig =\n await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);\n setSimulcastConfig(videoSimulcastConfig);\n },\n [],\n );\n\n /**\n * @deprecated\n * updates maximum bandwidth for the given simulcast encoding of the video track\n * @param encoding encoding to update\n * @param bandwidth BandwidthLimit to set\n */\n const setVideoTrackEncodingBandwidth = useCallback(\n async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackEncodingBandwidth(\n encoding,\n bandwidth,\n );\n },\n [],\n );\n\n return {\n isCameraOn,\n currentCamera,\n simulcastConfig,\n cameras,\n\n toggleCamera,\n prepareCamera,\n switchCamera,\n\n toggleVideoTrackEncoding,\n setVideoTrackEncodingBandwidth,\n setVideoTrackBandwidth,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAwFtE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,EAAE,KAAK;IACd,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,YAA6C;IACvE,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO;gBACL,YAAY,EAAE,SAAS;gBACvB,eAAe,EAAE,YAAY;aAC9B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,YAAY,EAAE,SAAS;gBACvB,eAAe,EAAE,YAAY;aAC9B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,YAAY,E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V,CAAC;IAEF,MAAM,sBAAsB,GAAG,WAAW,CACxC,KAAK,EAAE,SAAyB,EAAE,EAAE;QAClC,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,wBAAwB,GAAG,WAAW,CAC1C,KAAK,EAAE,QAAuB,EAAE,EAAE;QAChC,MAAM,oBAAoB,GACxB,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACjE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAC3C,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,8BAA8B,GAAG,WAAW,CAChD,KAAK,EAAE,QAAuB,EAAE,SAAyB,EAAE,EAAE;QAC3D,MAAM,qBAAqB,CAAC,8BAA8B,CACxD,QAAQ,EACR,SAAS,CACV,CAAC;IACJ,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO;QACL;;WAEG;QACH,UAAU;QACV;;WAEG;QACH,aAAa;QACb;;WAEG;QACH,eAAe;QACf;;;WAGG;QACH,OAAO;QAEP,oCAAoC;QACpC,YAAY;QACZ;;;;WAIG;QACH,aAAa;QACb;;;;WAIG,CAAC,YAAY;QAEhB;;;;WAIG;QACH,wBAAwB;QACxB;;;;;WAKG;QACH,8BAA8B;QAC9B;;;;;;;WAOG;QACH,sBAAsB;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n BandwidthLimit,\n Brand,\n SimulcastBandwidthLimit,\n SimulcastConfig,\n TrackBandwidthLimit,\n TrackEncoding,\n} from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\ntype SimulcastConfigUpdateEvent = SimulcastConfig;\nexport type CameraId = Brand<string, 'CameraId'>;\n\nexport type CameraFacingDirection = 'front' | 'back' | 'unspecified';\n\nexport type Camera = {\n id: CameraId;\n name: string;\n facingDirection: CameraFacingDirection;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\ntype CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether to flip the dimensions of the video, that is whether to film in vertical orientation.\n * This basically switches width with height and is only used to select closes capture format.\n *\n * To record horizontal video your phone orientation must be in landscape and your app must support this orientation.\n *\n * Platform specific capture formats:\n * @see iOS: https://developer.apple.com/documentation/avfoundation/avcapturedevice/format\n * @see Android: https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50\n *\n * WebRTC device orientation handling:\n * @see iOS: https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285\n * @see Android: https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347\n *\n * @default `true`\n */\n flipDimensions?: boolean;\n /**\n * whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method\n * @default `true`\n */\n cameraEnabled?: boolean;\n /**\n * id of the camera to start capture with. Get available cameras with `cameras`.\n * You can switch the cameras later with `switchCamera` functions.\n * @default the first front camera\n */\n cameraId?: CameraId;\n};\n\nexport type CameraConfig = CameraConfigBase & {\n /**\n * whether video track uses simulcast. By default simulcast is disabled.\n */\n simulcastEnabled?: boolean;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n};\n\nexport type CameraConfigInternal = CameraConfigBase & {\n videoTrackMetadata?: { active: boolean; type: 'camera' };\n /**\n * SimulcastConfig of a video track. By default simulcast is disabled.\n */\n simulcastConfig?: SimulcastConfig;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n maxBandwidth?: TrackBandwidthLimit;\n} & (\n | { maxBandwidthInt?: BandwidthLimit }\n | { maxBandwidthMap?: SimulcastBandwidthLimit }\n );\n\nconst defaultSimulcastConfig = () => ({\n enabled: false,\n activeEncodings: [],\n});\n\nfunction maxBandwidthConfig(maxBandwidth: TrackBandwidthLimit | undefined) {\n if (Platform.OS === 'android') {\n if (typeof maxBandwidth === 'object') {\n return {\n maxBandwidth: undefined,\n maxBandwidthMap: maxBandwidth,\n };\n } else {\n return {\n maxBandwidth: undefined,\n maxBandwidthInt: maxBandwidth,\n };\n }\n }\n return { maxBandwidth };\n}\n\nfunction simulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n // iOS has a limit of 3 hardware encoders\n // 3 simulcast layers + 1 screen share layer = 4, which is too much\n // so we limit simulcast layers to 2\n if (simulcastEnabled) {\n return Platform.select<SimulcastConfig>({\n ios: { enabled: true, activeEncodings: ['l', 'h'] },\n android: { enabled: true, activeEncodings: ['l', 'm', 'h'] },\n });\n }\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n ...maxBandwidthConfig({ l: 150, m: 500, h: 1500 }),\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: simulcastConfig(config.simulcastEnabled),\n };\n}\n\n/**\n * This hook can toggle camera on/off and provides current camera state.\n * @category Devices\n * @group Hooks\n */\nexport function useCamera() {\n const [isCameraOn, setIsCameraOn] = useState<boolean>(\n RNFishjamClientModule.isCameraOn,\n );\n\n const [currentCamera, setCurrentCamera] = useState<Camera | undefined>(\n undefined,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n defaultSimulcastConfig(),\n );\n\n useFishjamEvent<SimulcastConfigUpdateEvent>(\n ReceivableEvents.SimulcastConfigUpdate,\n setSimulcastConfig,\n );\n\n useFishjamEvent(ReceivableEvents.IsCameraOn, setIsCameraOn);\n\n const cameras = useMemo(() => {\n return RNFishjamClientModule.cameras;\n }, []);\n\n const prepareCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const camera = RNFishjamClientModule.cameras.find((camera) =>\n config.cameraId\n ? camera.id === config.cameraId\n : camera.facingDirection === 'front',\n );\n\n setCurrentCamera(camera);\n const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n await RNFishjamClientModule.startCamera(updatedConfig);\n },\n [],\n );\n\n const toggleCamera = useCallback(async () => {\n const state = await RNFishjamClientModule.toggleCamera();\n await RNFishjamClientModule.updateVideoTrackMetadata({\n active: state,\n type: 'camera',\n });\n setIsCameraOn(state);\n }, []);\n\n const switchCamera = useCallback(\n async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\n setCurrentCamera(cameras.find((camera) => camera.id === cameraId));\n },\n [cameras],\n );\n\n const setVideoTrackBandwidth = useCallback(\n async (bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);\n },\n [],\n );\n\n const toggleVideoTrackEncoding = useCallback(\n async (encoding: TrackEncoding) => {\n const videoSimulcastConfig =\n await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);\n setSimulcastConfig(videoSimulcastConfig);\n },\n [],\n );\n\n const setVideoTrackEncodingBandwidth = useCallback(\n async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackEncodingBandwidth(\n encoding,\n bandwidth,\n );\n },\n [],\n );\n\n return {\n /**\n * Informs if user camera is streaming video\n */\n isCameraOn,\n /**\n * Which camera is now used for streaming (or will be used as default when camera will be enabled)\n */\n currentCamera,\n /**\n * Simulcast configuration\n */\n simulcastConfig,\n /**\n * Property that lists cameras available on device.\n * @returns A promise that resolves to the list of available cameras.\n */\n cameras,\n\n /** Enable/disable current camera */\n toggleCamera,\n /**\n * Prepares camera and starts local video track\n * @param config configuration of the camera capture\n * @returns A promise that resolves when camera is started.\n */\n prepareCamera,\n /**\n * Switches to the specified camera.\n * List of available devices can be retrieved from `cameras` variable\n * @returns A promise that resolves when camera is switched.\n */ switchCamera,\n\n /**\n * @deprecated\n * toggles encoding of a video track on/off\n * @param encoding encoding to toggle\n */\n toggleVideoTrackEncoding,\n /**\n * updates maximum bandwidth for the given simulcast encoding of the video track\n * @param encoding encoding to update\n * @param bandwidth BandwidthLimit to set\n * @deprecated\n */\n setVideoTrackEncodingBandwidth,\n /**\n * updates maximum bandwidth for the video track. This value directly translates\n * to quality of the stream and the amount of RTP packets being sent. In case simulcast\n * is enabled bandwidth is split between all of the variant streams proportionally to\n * their resolution.\n * @param BandwidthLimit to set\n * @deprecated\n */\n setVideoTrackBandwidth,\n };\n}\n"]}
|