@fishjam-cloud/react-native-client 0.5.0 → 0.7.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/README.md +6 -6
- package/android/build.gradle +6 -2
- package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +17 -16
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +64 -49
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +16 -24
- package/build/RNFishjamClientModule.d.ts +44 -11
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js +18 -4
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +3 -8
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +2 -6
- package/build/common/client.js.map +1 -1
- package/build/common/metadata.d.ts +2 -1
- package/build/common/metadata.d.ts.map +1 -1
- package/build/common/metadata.js +2 -1
- package/build/common/metadata.js.map +1 -1
- package/build/components/FishjamRoom/index.d.ts +21 -0
- package/build/components/FishjamRoom/index.d.ts.map +1 -1
- package/build/components/FishjamRoom/index.js +16 -1
- package/build/components/FishjamRoom/index.js.map +1 -1
- package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +1 -1
- package/build/components/FishjamRoom/parsePeersToTracks.js +4 -6
- package/build/components/FishjamRoom/parsePeersToTracks.js.map +1 -1
- package/build/components/VideoPreviewView.d.ts +7 -3
- package/build/components/VideoPreviewView.d.ts.map +1 -1
- package/build/components/VideoPreviewView.js +5 -1
- package/build/components/VideoPreviewView.js.map +1 -1
- package/build/components/VideoRendererView.d.ts +13 -0
- package/build/components/VideoRendererView.d.ts.map +1 -1
- package/build/components/VideoRendererView.js +13 -0
- package/build/components/VideoRendererView.js.map +1 -1
- package/build/debug/stats/useRTCStatistics.d.ts.map +1 -1
- package/build/debug/stats/useRTCStatistics.js +13 -13
- package/build/debug/stats/useRTCStatistics.js.map +1 -1
- package/build/hooks/internal/useFishjamEvent.d.ts +4 -0
- package/build/hooks/internal/useFishjamEvent.d.ts.map +1 -0
- package/build/hooks/internal/useFishjamEvent.js +35 -0
- package/build/hooks/internal/useFishjamEvent.js.map +1 -0
- package/build/hooks/internal/useFishjamEventState.d.ts +3 -0
- package/build/hooks/internal/useFishjamEventState.d.ts.map +1 -0
- package/build/hooks/{useFishjamEventState.js → internal/useFishjamEventState.js} +3 -1
- package/build/hooks/internal/useFishjamEventState.js.map +1 -0
- package/build/hooks/useAppScreenShare.d.ts +9 -0
- package/build/hooks/useAppScreenShare.d.ts.map +1 -1
- package/build/hooks/useAppScreenShare.js +14 -14
- package/build/hooks/useAppScreenShare.js.map +1 -1
- package/build/hooks/useAudioSettings.d.ts +4 -0
- package/build/hooks/useAudioSettings.d.ts.map +1 -1
- package/build/hooks/useAudioSettings.js +8 -11
- package/build/hooks/useAudioSettings.js.map +1 -1
- package/build/hooks/useBandwidthEstimation.d.ts +3 -0
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
- package/build/hooks/useBandwidthEstimation.js +9 -5
- package/build/hooks/useBandwidthEstimation.js.map +1 -1
- package/build/hooks/useCamera.d.ts +11 -33
- package/build/hooks/useCamera.d.ts.map +1 -1
- package/build/hooks/useCamera.js +18 -68
- package/build/hooks/useCamera.js.map +1 -1
- package/build/hooks/useConnection.d.ts +58 -0
- package/build/hooks/useConnection.d.ts.map +1 -0
- package/build/hooks/useConnection.js +39 -0
- package/build/hooks/useConnection.js.map +1 -0
- package/build/hooks/useForegroundService.d.ts +20 -11
- package/build/hooks/useForegroundService.d.ts.map +1 -1
- package/build/hooks/useForegroundService.js +2 -3
- package/build/hooks/useForegroundService.js.map +1 -1
- package/build/hooks/useMicrophone.d.ts.map +1 -1
- package/build/hooks/useMicrophone.js +2 -3
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/usePeerStatus.d.ts +3 -12
- package/build/hooks/usePeerStatus.d.ts.map +1 -1
- package/build/hooks/usePeerStatus.js +5 -10
- package/build/hooks/usePeerStatus.js.map +1 -1
- package/build/hooks/usePeers.d.ts +19 -22
- package/build/hooks/usePeers.d.ts.map +1 -1
- package/build/hooks/usePeers.js +21 -20
- package/build/hooks/usePeers.js.map +1 -1
- package/build/hooks/useReconnection.d.ts +3 -3
- package/build/hooks/useReconnection.d.ts.map +1 -1
- package/build/hooks/useReconnection.js +5 -10
- package/build/hooks/useReconnection.js.map +1 -1
- package/build/hooks/useScreenShare.d.ts +2 -23
- package/build/hooks/useScreenShare.d.ts.map +1 -1
- package/build/hooks/useScreenShare.js +6 -45
- package/build/hooks/useScreenShare.js.map +1 -1
- package/build/hooks/useUpdatePeerMetadata.d.ts +15 -0
- package/build/hooks/useUpdatePeerMetadata.d.ts.map +1 -0
- package/build/hooks/useUpdatePeerMetadata.js +21 -0
- package/build/hooks/useUpdatePeerMetadata.js.map +1 -0
- package/build/index.d.ts +21 -16
- package/build/index.d.ts.map +1 -1
- package/build/index.js +15 -6
- package/build/index.js.map +1 -1
- package/build/types.d.ts +0 -19
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils/errorListener.d.ts.map +1 -1
- package/build/utils/errorListener.js +2 -3
- package/build/utils/errorListener.js.map +1 -1
- package/build/utils/eventPayloadValidator.d.ts +3 -0
- package/build/utils/eventPayloadValidator.d.ts.map +1 -0
- package/build/utils/eventPayloadValidator.js +94 -0
- package/build/utils/eventPayloadValidator.js.map +1 -0
- package/ios/Events.swift +8 -8
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +45 -48
- package/ios/RNFishjamClientModule.swift +13 -14
- package/ios/Utils.swift +0 -20
- package/package.json +21 -13
- package/plugin/build/withFishjamAndroid.js +18 -20
- package/plugin/build/withFishjamIos.js +116 -110
- package/build/common/webRTC.d.ts +0 -14
- package/build/common/webRTC.d.ts.map +0 -1
- package/build/common/webRTC.js +0 -15
- package/build/common/webRTC.js.map +0 -1
- package/build/hooks/useFishjamEvent.d.ts +0 -18
- package/build/hooks/useFishjamEvent.d.ts.map +0 -1
- package/build/hooks/useFishjamEvent.js +0 -27
- package/build/hooks/useFishjamEvent.js.map +0 -1
- package/build/hooks/useFishjamEventState.d.ts +0 -3
- package/build/hooks/useFishjamEventState.d.ts.map +0 -1
- package/build/hooks/useFishjamEventState.js.map +0 -1
- /package/{LICENSE → LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useAppScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useAppScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useAppScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAClC,CAAC;IACC,OAAO,EAAE,KAAK;CACf,CAA2B,CAAC;AAE/B,IAAI,0BAA0B,GAAoB,sBAAsB,EAAE,CAAC;AAU3E,SAAS,oBAAoB;IAC3B,MAAM,kBAAkB,GAAG,oBAAoB,CAC7C,gBAAgB,CAAC,kBAAkB,EACnC,qBAAqB,CAAC,kBAAkB,CACzC,CAAC;IAEF,MAAM,eAAe,GAAG,oBAAoB,CAC1C,gBAAgB,CAAC,qBAAqB,EACtC,0BAA0B,CAC3B,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CACtC,KAAK,EAAE,qBAAkD,EAAE,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG;YACd,GAAG,kBAAkB;YACrB,mBAAmB,EAAE;gBACnB,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,kBAA2B;gBACjC,MAAM,EAAE,CAAC,kBAAkB;aAC5B;SACF,CAAC;QACF,MAAM,qBAAqB,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAC1D,0BAA0B,GAAG,sBAAsB,EAAE,CAAC,CAAC,kCAAkC;IAC3F,CAAC,EACD,CAAC,kBAAkB,CAAC,CACrB,CAAC;IAEF,OAAO;QACL,kBAAkB;QAClB,eAAe;QACf;;;WAGG;QACH,oBAAoB;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B;IACtC,OAAO;QACL,kBAAkB,EAAE,KAAK;QACzB,eAAe,EAAE,sBAAsB,EAAE;QACzC,oBAAoB,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACrC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/C,GAAG,EAAE,oBAAoB;IACzB,OAAO,EAAE,+BAA+B;CACzC,CAAC,CAAC","sourcesContent":["import { useCallback } from 'react';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { SimulcastConfig } from '../types';\nimport { ScreenShareOptions } from './useScreenShare';\nimport { Platform } from 'react-native';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nconst defaultSimulcastConfig = () =>\n ({\n enabled: false,\n }) satisfies SimulcastConfig;\n\nlet screenShareSimulcastConfig: SimulcastConfig = defaultSimulcastConfig();\n\ntype AppScreenShareData = {\n isAppScreenShareOn: boolean;\n simulcastConfig: SimulcastConfig;\n toggleAppScreenShare: (\n screenShareOptions?: Partial<ScreenShareOptions>,\n ) => Promise<void>;\n};\n\nfunction useIosAppScreenShare(): AppScreenShareData {\n const isAppScreenShareOn = useFishjamEventState(\n ReceivableEvents.IsAppScreenShareOn,\n RNFishjamClientModule.isAppScreenShareOn,\n );\n\n const simulcastConfig = useFishjamEventState(\n ReceivableEvents.SimulcastConfigUpdate,\n screenShareSimulcastConfig,\n );\n\n const toggleAppScreenShare = useCallback(\n async (screenShareOptions: Partial<ScreenShareOptions> = {}) => {\n const options = {\n ...screenShareOptions,\n screenShareMetadata: {\n displayName: 'presenting',\n type: 'screenShareVideo' as const,\n active: !isAppScreenShareOn,\n },\n };\n await RNFishjamClientModule.toggleAppScreenShare(options);\n screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings\n },\n [isAppScreenShareOn],\n );\n\n return {\n isAppScreenShareOn,\n simulcastConfig,\n /**\n * Toggles the screen share on/off.\n * Emits warning on ios when user is screensharing full screen.\n */\n toggleAppScreenShare,\n };\n}\n\nfunction useDefaultAppScreenShareAndroid(): AppScreenShareData {\n return {\n isAppScreenShareOn: false,\n simulcastConfig: defaultSimulcastConfig(),\n toggleAppScreenShare: async () => {},\n };\n}\n\n/**\n * This hook can toggle client app screen sharing on/off and provides current screen share state.\n *\n * It works only on iOS.\n *\n * @returns An object with functions to manage app screen share on iOS and null on android.\n * @category Connection\n * @group Hooks\n */\nexport const useAppScreenShare = Platform.select({\n ios: useIosAppScreenShare,\n default: useDefaultAppScreenShareAndroid,\n});\n"]}
|
|
@@ -4,6 +4,10 @@ export type AudioOutputDevice = {
|
|
|
4
4
|
type: AudioOutputDeviceType;
|
|
5
5
|
name: string;
|
|
6
6
|
};
|
|
7
|
+
export type OnAudioDeviceEvent = {
|
|
8
|
+
selectedDevice: AudioOutputDevice | null;
|
|
9
|
+
availableDevices: AudioOutputDevice[];
|
|
10
|
+
};
|
|
7
11
|
/**
|
|
8
12
|
* This hook manages audio settings.
|
|
9
13
|
* @category Devices
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"
|
|
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,20 +1,17 @@
|
|
|
1
|
-
import { useCallback, useEffect
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
|
-
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
4
|
-
import {
|
|
3
|
+
import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
|
|
4
|
+
import { useFishjamEventState } from './internal/useFishjamEventState';
|
|
5
5
|
/**
|
|
6
6
|
* This hook manages audio settings.
|
|
7
7
|
* @category Devices
|
|
8
8
|
* @group Hooks
|
|
9
9
|
*/
|
|
10
10
|
export function useAudioSettings() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
setAvailableDevices(event.availableDevices);
|
|
16
|
-
}, []);
|
|
17
|
-
useFishjamEvent(ReceivableEvents.AudioDeviceUpdate, onAudioDevice);
|
|
11
|
+
const { selectedDevice: selectedAudioOutputDevice, availableDevices } = useFishjamEventState(ReceivableEvents.AudioDeviceUpdate, {
|
|
12
|
+
selectedDevice: null,
|
|
13
|
+
availableDevices: [],
|
|
14
|
+
});
|
|
18
15
|
useEffect(() => {
|
|
19
16
|
RNFishjamClientModule.startAudioSwitcher();
|
|
20
17
|
return () => {
|
|
@@ -22,7 +19,7 @@ export function useAudioSettings() {
|
|
|
22
19
|
RNFishjamClientModule.stopAudioSwitcher();
|
|
23
20
|
}
|
|
24
21
|
};
|
|
25
|
-
}, [
|
|
22
|
+
}, []);
|
|
26
23
|
const selectOutputAudioDevice = useCallback(async (device) => {
|
|
27
24
|
if (Platform.OS === 'ios') {
|
|
28
25
|
throw Error('selectOutputAudioDevice function is supported only on Android. ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioSettings.js","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,
|
|
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,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAoBvE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,cAAc,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,GACnE,oBAAoB,CAAC,gBAAgB,CAAC,iBAAiB,EAAE;QACvD,cAAc,EAAE,IAAI;QACpB,gBAAgB,EAAE,EAAE;KACrB,CAAC,CAAC;IAEL,SAAS,CAAC,GAAG,EAAE;QACb,qBAAqB,CAAC,kBAAkB,EAAE,CAAC;QAC3C,OAAO,GAAG,EAAE;YACV,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;gBAC9B,qBAAqB,CAAC,iBAAiB,EAAE,CAAC;YAC5C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,uBAAuB,GAAG,WAAW,CACzC,KAAK,EAAE,MAA6B,EAAE,EAAE;QACtC,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,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 } 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 selectedDevice: AudioOutputDevice | null;\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,sBAAsB;IAMlC;;OAEG;;EAGN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReceivableEvents } from '../RNFishjamClientModule';
|
|
2
|
+
import { useFishjamEventState } from './internal/useFishjamEventState';
|
|
3
3
|
/**
|
|
4
4
|
* This hook provides current bandwidth estimation
|
|
5
5
|
* estimation - client's available incoming bitrate estimated
|
|
@@ -8,8 +8,12 @@ import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
|
|
|
8
8
|
* @group Hooks
|
|
9
9
|
*/
|
|
10
10
|
export function useBandwidthEstimation() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const estimation = useFishjamEventState(ReceivableEvents.BandwidthEstimation, null);
|
|
12
|
+
return {
|
|
13
|
+
/**
|
|
14
|
+
* Bandwidth estimation, measured in bits per second
|
|
15
|
+
*/
|
|
16
|
+
estimation,
|
|
17
|
+
};
|
|
14
18
|
}
|
|
15
19
|
//# sourceMappingURL=useBandwidthEstimation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,UAAU,GAAG,oBAAoB,CACrC,gBAAgB,CAAC,mBAAmB,EACpC,IAAI,CACL,CAAC;IACF,OAAO;QACL;;WAEG;QACH,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { ReceivableEvents } from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\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 = useFishjamEventState(\n ReceivableEvents.BandwidthEstimation,\n null,\n );\n return {\n /**\n * Bandwidth estimation, measured in bits per second\n */\n estimation,\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Brand, SimulcastConfig } from '../types';
|
|
2
2
|
export type CameraId = Brand<string, 'CameraId'>;
|
|
3
3
|
export type CameraFacingDirection = 'front' | 'back' | 'unspecified';
|
|
4
4
|
export type Camera = {
|
|
@@ -9,6 +9,7 @@ export type Camera = {
|
|
|
9
9
|
export type CurrentCameraChangedType = {
|
|
10
10
|
currentCamera: Camera | null;
|
|
11
11
|
isCameraOn: boolean;
|
|
12
|
+
isCameraInitialized: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type VideoQuality = 'QVGA169' | 'VGA169' | 'QHD169' | 'HD169' | 'FHD169' | 'QVGA43' | 'VGA43' | 'QHD43' | 'HD43' | 'FHD43';
|
|
14
15
|
type CameraConfigBase = {
|
|
@@ -63,15 +64,7 @@ export type CameraConfigInternal = CameraConfigBase & {
|
|
|
63
64
|
* SimulcastConfig of a video track. By default simulcast is disabled.
|
|
64
65
|
*/
|
|
65
66
|
simulcastConfig?: SimulcastConfig;
|
|
66
|
-
|
|
67
|
-
* bandwidth limit of a video track. By default there is no bandwidth limit.
|
|
68
|
-
*/
|
|
69
|
-
maxBandwidth?: TrackBandwidthLimit;
|
|
70
|
-
} & ({
|
|
71
|
-
maxBandwidthInt?: BandwidthLimit;
|
|
72
|
-
} | {
|
|
73
|
-
maxBandwidthMap?: SimulcastBandwidthLimit;
|
|
74
|
-
});
|
|
67
|
+
};
|
|
75
68
|
export declare function updateCameraConfig(config: Readonly<CameraConfig>): CameraConfigInternal;
|
|
76
69
|
/**
|
|
77
70
|
* This hook can toggle camera on/off and provides current camera state.
|
|
@@ -96,7 +89,13 @@ export declare function useCamera(): {
|
|
|
96
89
|
* @returns A promise that resolves to the list of available cameras.
|
|
97
90
|
*/
|
|
98
91
|
cameras: readonly Camera[];
|
|
99
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* A value indicating if camera was already initialized (if `prepareCamera` was called).
|
|
94
|
+
*/
|
|
95
|
+
isInitialized: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Enable/disable current camera
|
|
98
|
+
*/
|
|
100
99
|
toggleCamera: () => Promise<void>;
|
|
101
100
|
/**
|
|
102
101
|
* Prepares camera and starts local video track
|
|
@@ -108,29 +107,8 @@ export declare function useCamera(): {
|
|
|
108
107
|
* Switches to the specified camera.
|
|
109
108
|
* List of available devices can be retrieved from `cameras` variable
|
|
110
109
|
* @returns A promise that resolves when camera is switched.
|
|
111
|
-
*/ switchCamera: (cameraId: CameraId) => Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* @deprecated
|
|
114
|
-
* toggles encoding of a video track on/off
|
|
115
|
-
* @param encoding encoding to toggle
|
|
116
|
-
*/
|
|
117
|
-
toggleVideoTrackEncoding: (encoding: TrackEncoding) => Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
120
|
-
* @param encoding encoding to update
|
|
121
|
-
* @param bandwidth BandwidthLimit to set
|
|
122
|
-
* @deprecated
|
|
123
|
-
*/
|
|
124
|
-
setVideoTrackEncodingBandwidth: (encoding: TrackEncoding, bandwidth: BandwidthLimit) => Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* updates maximum bandwidth for the video track. This value directly translates
|
|
127
|
-
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
128
|
-
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
129
|
-
* their resolution.
|
|
130
|
-
* @param BandwidthLimit to set
|
|
131
|
-
* @deprecated
|
|
132
110
|
*/
|
|
133
|
-
|
|
111
|
+
switchCamera: (cameraId: CameraId) => Promise<void>;
|
|
134
112
|
};
|
|
135
113
|
export {};
|
|
136
114
|
//# sourceMappingURL=useCamera.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMlD,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEjD,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;AAErE,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,qBAAqB,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,OAAO,GACP,MAAM,GACN,OAAO,CAAC;AAEZ,KAAK,gBAAgB,GAAG;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAI5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,kBAAkB,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IACzD;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAgBF,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAC7B,oBAAoB,CAMtB;AAED;;;;GAIG;AACH,wBAAgB,SAAS;IAmDrB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;6BA1DY,QAAQ,CAAC,YAAY,CAAC;IA4DrC;;;;OAIG;6BAxC6C,QAAQ;EA2C3D"}
|
package/build/hooks/useCamera.js
CHANGED
|
@@ -1,47 +1,20 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { ReceivableEvents } from './useFishjamEvent';
|
|
5
|
-
import { useFishjamEventState } from './useFishjamEventState';
|
|
2
|
+
import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
|
|
3
|
+
import { useFishjamEventState } from './internal/useFishjamEventState';
|
|
6
4
|
const defaultSimulcastConfig = () => ({
|
|
7
5
|
enabled: false,
|
|
8
|
-
activeEncodings: [],
|
|
9
6
|
});
|
|
10
|
-
function
|
|
11
|
-
if (Platform.OS === 'android') {
|
|
12
|
-
if (typeof maxBandwidth === 'object') {
|
|
13
|
-
return {
|
|
14
|
-
maxBandwidth: undefined,
|
|
15
|
-
maxBandwidthMap: maxBandwidth,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return {
|
|
20
|
-
maxBandwidth: undefined,
|
|
21
|
-
maxBandwidthInt: maxBandwidth,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return { maxBandwidth };
|
|
26
|
-
}
|
|
27
|
-
function simulcastConfig(simulcastEnabled) {
|
|
28
|
-
// iOS has a limit of 3 hardware encoders
|
|
29
|
-
// 3 simulcast layers + 1 screen share layer = 4, which is too much
|
|
30
|
-
// so we limit simulcast layers to 2
|
|
7
|
+
function getSimulcastConfig(simulcastEnabled) {
|
|
31
8
|
if (simulcastEnabled) {
|
|
32
|
-
return
|
|
33
|
-
ios: { enabled: true, activeEncodings: ['l', 'h'] },
|
|
34
|
-
android: { enabled: true, activeEncodings: ['l', 'm', 'h'] },
|
|
35
|
-
});
|
|
9
|
+
return { enabled: true };
|
|
36
10
|
}
|
|
37
11
|
return undefined;
|
|
38
12
|
}
|
|
39
13
|
export function updateCameraConfig(config) {
|
|
40
14
|
return {
|
|
41
15
|
...config,
|
|
42
|
-
...maxBandwidthConfig({ l: 150, m: 500, h: 1500 }),
|
|
43
16
|
videoTrackMetadata: { active: true, type: 'camera' },
|
|
44
|
-
simulcastConfig:
|
|
17
|
+
simulcastConfig: getSimulcastConfig(config.simulcastEnabled),
|
|
45
18
|
};
|
|
46
19
|
}
|
|
47
20
|
/**
|
|
@@ -51,17 +24,18 @@ export function updateCameraConfig(config) {
|
|
|
51
24
|
*/
|
|
52
25
|
export function useCamera() {
|
|
53
26
|
const simulcastConfig = useFishjamEventState(ReceivableEvents.SimulcastConfigUpdate, defaultSimulcastConfig());
|
|
54
|
-
const { currentCamera: currentCameraState, isCameraOn } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {
|
|
27
|
+
const { currentCamera: currentCameraState, isCameraOn, isCameraInitialized, } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {
|
|
55
28
|
currentCamera: RNFishjamClientModule.currentCamera,
|
|
56
29
|
isCameraOn: RNFishjamClientModule.isCameraOn,
|
|
30
|
+
isCameraInitialized: RNFishjamClientModule.isCameraInitialized,
|
|
57
31
|
});
|
|
58
32
|
// For Android Expo converts null to undefined ¯\_(ツ)_/¯
|
|
59
33
|
const currentCamera = currentCameraState ?? null;
|
|
60
34
|
const cameras = useMemo(() => RNFishjamClientModule.cameras, []);
|
|
61
35
|
const prepareCamera = useCallback(async (config = {}) => {
|
|
62
|
-
const camera = RNFishjamClientModule.cameras.find((
|
|
63
|
-
?
|
|
64
|
-
:
|
|
36
|
+
const camera = RNFishjamClientModule.cameras.find((cam) => config.cameraId
|
|
37
|
+
? cam.id === config.cameraId
|
|
38
|
+
: cam.facingDirection === 'front');
|
|
65
39
|
const updatedConfig = updateCameraConfig({
|
|
66
40
|
...config,
|
|
67
41
|
cameraId: camera?.id,
|
|
@@ -78,15 +52,6 @@ export function useCamera() {
|
|
|
78
52
|
const switchCamera = useCallback(async (cameraId) => {
|
|
79
53
|
await RNFishjamClientModule.switchCamera(cameraId);
|
|
80
54
|
}, []);
|
|
81
|
-
const setVideoTrackBandwidth = useCallback(async (bandwidth) => {
|
|
82
|
-
await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);
|
|
83
|
-
}, []);
|
|
84
|
-
const toggleVideoTrackEncoding = useCallback(async (encoding) => {
|
|
85
|
-
await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);
|
|
86
|
-
}, []);
|
|
87
|
-
const setVideoTrackEncodingBandwidth = useCallback(async (encoding, bandwidth) => {
|
|
88
|
-
await RNFishjamClientModule.setVideoTrackEncodingBandwidth(encoding, bandwidth);
|
|
89
|
-
}, []);
|
|
90
55
|
return {
|
|
91
56
|
/**
|
|
92
57
|
* Informs if user camera is streaming video
|
|
@@ -105,7 +70,13 @@ export function useCamera() {
|
|
|
105
70
|
* @returns A promise that resolves to the list of available cameras.
|
|
106
71
|
*/
|
|
107
72
|
cameras,
|
|
108
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* A value indicating if camera was already initialized (if `prepareCamera` was called).
|
|
75
|
+
*/
|
|
76
|
+
isInitialized: isCameraInitialized,
|
|
77
|
+
/**
|
|
78
|
+
* Enable/disable current camera
|
|
79
|
+
*/
|
|
109
80
|
toggleCamera,
|
|
110
81
|
/**
|
|
111
82
|
* Prepares camera and starts local video track
|
|
@@ -117,29 +88,8 @@ export function useCamera() {
|
|
|
117
88
|
* Switches to the specified camera.
|
|
118
89
|
* List of available devices can be retrieved from `cameras` variable
|
|
119
90
|
* @returns A promise that resolves when camera is switched.
|
|
120
|
-
*/ switchCamera,
|
|
121
|
-
/**
|
|
122
|
-
* @deprecated
|
|
123
|
-
* toggles encoding of a video track on/off
|
|
124
|
-
* @param encoding encoding to toggle
|
|
125
|
-
*/
|
|
126
|
-
toggleVideoTrackEncoding,
|
|
127
|
-
/**
|
|
128
|
-
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
129
|
-
* @param encoding encoding to update
|
|
130
|
-
* @param bandwidth BandwidthLimit to set
|
|
131
|
-
* @deprecated
|
|
132
|
-
*/
|
|
133
|
-
setVideoTrackEncodingBandwidth,
|
|
134
|
-
/**
|
|
135
|
-
* updates maximum bandwidth for the video track. This value directly translates
|
|
136
|
-
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
137
|
-
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
138
|
-
* their resolution.
|
|
139
|
-
* @param BandwidthLimit to set
|
|
140
|
-
* @deprecated
|
|
141
91
|
*/
|
|
142
|
-
|
|
92
|
+
switchCamera,
|
|
143
93
|
};
|
|
144
94
|
}
|
|
145
95
|
//# sourceMappingURL=useCamera.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA4F9D,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,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,eAAe,CACtB,gBAAqC;IAErC,yCAAyC;IACzC,mEAAmE;IACnE,oCAAoC;IACpC,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,QAAQ,CAAC,MAAM,CAAkB;YACtC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE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,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 } 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 } from './useFishjamEvent';\nimport { useFishjamEventState } from './useFishjamEventState';\n\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 CurrentCameraChangedType = {\n currentCamera: Camera | null;\n isCameraOn: boolean;\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 simulcastConfig = useFishjamEventState<SimulcastConfig>(\n ReceivableEvents.SimulcastConfigUpdate,\n defaultSimulcastConfig(), // TODO: Fetch from native\n );\n\n const { currentCamera: currentCameraState, isCameraOn } =\n useFishjamEventState<CurrentCameraChangedType>(\n ReceivableEvents.CurrentCameraChanged,\n {\n currentCamera: RNFishjamClientModule.currentCamera,\n isCameraOn: RNFishjamClientModule.isCameraOn,\n },\n );\n\n // For Android Expo converts null to undefined ¯\\_(ツ)_/¯\n const currentCamera = currentCameraState ?? null;\n\n const cameras = useMemo(() => RNFishjamClientModule.cameras, []);\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 const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n return 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 }, []);\n\n const switchCamera = useCallback(async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\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 await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);\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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aAAa;QACb;;;;WAIG;QACH,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { Brand, SimulcastConfig } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\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 CurrentCameraChangedType = {\n currentCamera: Camera | null;\n isCameraOn: boolean;\n isCameraInitialized: boolean;\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\nconst defaultSimulcastConfig = () =>\n ({\n enabled: false,\n }) satisfies SimulcastConfig;\n\nfunction getSimulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n if (simulcastEnabled) {\n return { enabled: true };\n }\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: getSimulcastConfig(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 simulcastConfig = useFishjamEventState(\n ReceivableEvents.SimulcastConfigUpdate,\n defaultSimulcastConfig(), // TODO: Fetch from native\n );\n\n const {\n currentCamera: currentCameraState,\n isCameraOn,\n isCameraInitialized,\n } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {\n currentCamera: RNFishjamClientModule.currentCamera,\n isCameraOn: RNFishjamClientModule.isCameraOn,\n isCameraInitialized: RNFishjamClientModule.isCameraInitialized,\n });\n\n // For Android Expo converts null to undefined ¯\\_(ツ)_/¯\n const currentCamera = currentCameraState ?? null;\n\n const cameras = useMemo(() => RNFishjamClientModule.cameras, []);\n\n const prepareCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const camera = RNFishjamClientModule.cameras.find((cam) =>\n config.cameraId\n ? cam.id === config.cameraId\n : cam.facingDirection === 'front',\n );\n\n const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n return 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 }, []);\n\n const switchCamera = useCallback(async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\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 * A value indicating if camera was already initialized (if `prepareCamera` was called).\n */\n isInitialized: isCameraInitialized,\n /**\n * Enable/disable current camera\n */\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 */\n switchCamera,\n };\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ConnectionConfig } from '../common/client';
|
|
2
|
+
import { GenericMetadata } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the possible statuses of a peer while reconnecting to room
|
|
5
|
+
*
|
|
6
|
+
* - `idle` - No reconnection in progress. See {@link PeerStatus} for more details
|
|
7
|
+
* - `reconnecting` - Peer is in the process of reconnecting.
|
|
8
|
+
* - `error` - There was an error in the reconnection process.
|
|
9
|
+
*/
|
|
10
|
+
export type ReconnectionStatus = 'idle' | 'reconnecting' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* Represents the possible statuses of a peer connection to a room (websocket state).
|
|
13
|
+
*
|
|
14
|
+
* - `idle` - Peer is not connected, either never connected or successfully disconnected.
|
|
15
|
+
* - `connecting` - Peer is in the process of connecting.
|
|
16
|
+
* - `connected` - Peer has successfully connected.
|
|
17
|
+
* - `error` - There was an error in the connection process.
|
|
18
|
+
*/
|
|
19
|
+
export type PeerStatus = 'connecting' | 'connected' | 'error' | 'idle';
|
|
20
|
+
export type JoinRoomConfig<PeerMetadata extends GenericMetadata = GenericMetadata> = {
|
|
21
|
+
/**
|
|
22
|
+
* Fishjam URL
|
|
23
|
+
*/
|
|
24
|
+
url: string;
|
|
25
|
+
/**
|
|
26
|
+
* Token received from server (or Room Manager)
|
|
27
|
+
*/
|
|
28
|
+
peerToken: string;
|
|
29
|
+
/**
|
|
30
|
+
* String indexed record with metadata, that will be available to all other peers
|
|
31
|
+
*/
|
|
32
|
+
peerMetadata?: PeerMetadata;
|
|
33
|
+
/**
|
|
34
|
+
* Additional connection configuration
|
|
35
|
+
*/
|
|
36
|
+
config?: ConnectionConfig;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Connect/leave room. And get connection status.
|
|
40
|
+
* @group Hooks
|
|
41
|
+
* @category Connection
|
|
42
|
+
*/
|
|
43
|
+
export declare function useConnection(): {
|
|
44
|
+
/**
|
|
45
|
+
* Join room and start streaming camera and microphone
|
|
46
|
+
*
|
|
47
|
+
* See {@link JoinRoomConfig} for parameter list
|
|
48
|
+
*/
|
|
49
|
+
joinRoom: <PeerMetadata extends GenericMetadata = GenericMetadata>({ url, peerToken, peerMetadata, config, }: JoinRoomConfig<PeerMetadata>) => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Leave room and stop streaming
|
|
52
|
+
* @type function
|
|
53
|
+
*/
|
|
54
|
+
leaveRoom: () => void;
|
|
55
|
+
peerStatus: PeerStatus;
|
|
56
|
+
reconnectionStatus: ReconnectionStatus;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=useConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAGjB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAevE,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,eAAe,GAAG,eAAe,IACpD;IACF;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa;IAoBzB;;;;OAIG;eApBI,YAAY,SAAS,eAAe,+DAKxC,cAAc,CAAC,YAAY,CAAC;IAiB/B;;;OAGG;;;;EAKN"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { joinRoom as joinRoomClient, leaveRoom as leaveRoomClient, } from '../common/client';
|
|
3
|
+
import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
|
|
4
|
+
import { useFishjamEventState } from './internal/useFishjamEventState';
|
|
5
|
+
function useConnectionStatus() {
|
|
6
|
+
const peerStatus = useFishjamEventState(ReceivableEvents.PeerStatusChanged, RNFishjamClientModule.peerStatus);
|
|
7
|
+
const reconnectionStatus = useFishjamEventState(ReceivableEvents.ReconnectionStatusChanged, RNFishjamClientModule.reconnectionStatus);
|
|
8
|
+
return { peerStatus, reconnectionStatus };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Connect/leave room. And get connection status.
|
|
12
|
+
* @group Hooks
|
|
13
|
+
* @category Connection
|
|
14
|
+
*/
|
|
15
|
+
export function useConnection() {
|
|
16
|
+
const { peerStatus, reconnectionStatus } = useConnectionStatus();
|
|
17
|
+
const joinRoom = useCallback(async ({ url, peerToken, peerMetadata, config, }) => {
|
|
18
|
+
await joinRoomClient(url, peerToken, peerMetadata, config);
|
|
19
|
+
}, []);
|
|
20
|
+
const leaveRoom = useCallback(() => {
|
|
21
|
+
leaveRoomClient();
|
|
22
|
+
}, []);
|
|
23
|
+
return {
|
|
24
|
+
/**
|
|
25
|
+
* Join room and start streaming camera and microphone
|
|
26
|
+
*
|
|
27
|
+
* See {@link JoinRoomConfig} for parameter list
|
|
28
|
+
*/
|
|
29
|
+
joinRoom,
|
|
30
|
+
/**
|
|
31
|
+
* Leave room and stop streaming
|
|
32
|
+
* @type function
|
|
33
|
+
*/
|
|
34
|
+
leaveRoom,
|
|
35
|
+
peerStatus,
|
|
36
|
+
reconnectionStatus,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=useConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnection.js","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAEL,QAAQ,IAAI,cAAc,EAC1B,SAAS,IAAI,eAAe,GAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAsBvE,SAAS,mBAAmB;IAC1B,MAAM,UAAU,GAAG,oBAAoB,CACrC,gBAAgB,CAAC,iBAAiB,EAClC,qBAAqB,CAAC,UAAU,CACjC,CAAC;IAEF,MAAM,kBAAkB,GAAG,oBAAoB,CAC7C,gBAAgB,CAAC,yBAAyB,EAC1C,qBAAqB,CAAC,kBAAkB,CACzC,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAC5C,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEjE,MAAM,QAAQ,GAAG,WAAW,CAC1B,KAAK,EAA0D,EAC7D,GAAG,EACH,SAAS,EACT,YAAY,EACZ,MAAM,GACuB,EAAE,EAAE;QACjC,MAAM,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,eAAe,EAAE,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;;;WAIG;QACH,QAAQ;QACR;;;WAGG;QACH,SAAS;QACT,UAAU;QACV,kBAAkB;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react';\nimport {\n ConnectionConfig,\n joinRoom as joinRoomClient,\n leaveRoom as leaveRoomClient,\n} from '../common/client';\n\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\nimport { GenericMetadata } from '../types';\n\n/**\n * Represents the possible statuses of a peer while reconnecting to room\n *\n * - `idle` - No reconnection in progress. See {@link PeerStatus} for more details\n * - `reconnecting` - Peer is in the process of reconnecting.\n * - `error` - There was an error in the reconnection process.\n */\nexport type ReconnectionStatus = 'idle' | 'reconnecting' | 'error';\n\n/**\n * Represents the possible statuses of a peer connection to a room (websocket state).\n *\n * - `idle` - Peer is not connected, either never connected or successfully disconnected.\n * - `connecting` - Peer is in the process of connecting.\n * - `connected` - Peer has successfully connected.\n * - `error` - There was an error in the connection process.\n */\nexport type PeerStatus = 'connecting' | 'connected' | 'error' | 'idle';\n\nfunction useConnectionStatus() {\n const peerStatus = useFishjamEventState(\n ReceivableEvents.PeerStatusChanged,\n RNFishjamClientModule.peerStatus,\n );\n\n const reconnectionStatus = useFishjamEventState(\n ReceivableEvents.ReconnectionStatusChanged,\n RNFishjamClientModule.reconnectionStatus,\n );\n\n return { peerStatus, reconnectionStatus };\n}\nexport type JoinRoomConfig<\n PeerMetadata extends GenericMetadata = GenericMetadata,\n> = {\n /**\n * Fishjam URL\n */\n url: string;\n /**\n * Token received from server (or Room Manager)\n */\n peerToken: string;\n /**\n * String indexed record with metadata, that will be available to all other peers\n */\n peerMetadata?: PeerMetadata;\n /**\n * Additional connection configuration\n */\n config?: ConnectionConfig;\n};\n\n/**\n * Connect/leave room. And get connection status.\n * @group Hooks\n * @category Connection\n */\nexport function useConnection() {\n const { peerStatus, reconnectionStatus } = useConnectionStatus();\n\n const joinRoom = useCallback(\n async <PeerMetadata extends GenericMetadata = GenericMetadata>({\n url,\n peerToken,\n peerMetadata,\n config,\n }: JoinRoomConfig<PeerMetadata>) => {\n await joinRoomClient(url, peerToken, peerMetadata, config);\n },\n [],\n );\n\n const leaveRoom = useCallback(() => {\n leaveRoomClient();\n }, []);\n\n return {\n /**\n * Join room and start streaming camera and microphone\n *\n * See {@link JoinRoomConfig} for parameter list\n */\n joinRoom,\n /**\n * Leave room and stop streaming\n * @type function\n */\n leaveRoom,\n peerStatus,\n reconnectionStatus,\n };\n}\n"]}
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A type representing the configuration for foreground service permissions.
|
|
3
|
-
*
|
|
4
|
-
* @param enableCamera Indicates whether the camera is enabled for the foreground service.
|
|
5
|
-
* @param enableMicrophone Indicates whether the microphone is enabled for the foreground service.
|
|
6
|
-
* @param channelId The id of the channel. Must be unique per package.
|
|
7
|
-
* @param channelName The user visible name of the channel.
|
|
8
|
-
* @param notificationTitle The title (first row) of the notification, in a standard notification.
|
|
9
|
-
* @param notificationContent The text (second row) of the notification, in a standard notification.
|
|
10
|
-
*
|
|
11
3
|
*/
|
|
12
4
|
export type ForegroundServiceConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether the camera is enabled for the foreground service.
|
|
7
|
+
*/
|
|
13
8
|
enableCamera?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Indicates whether the microphone is enabled for the foreground service.
|
|
11
|
+
*/
|
|
14
12
|
enableMicrophone?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The id of the channel. Must be unique per package.
|
|
15
|
+
*/
|
|
15
16
|
channelId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The user visible name of the channel.
|
|
19
|
+
*/
|
|
16
20
|
channelName?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The title (first row) of the notification, in a standard notification.
|
|
23
|
+
*/
|
|
17
24
|
notificationTitle?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The text (second row) of the notification, in a standard notification.
|
|
27
|
+
*/
|
|
18
28
|
notificationContent?: string;
|
|
19
29
|
};
|
|
20
30
|
/**
|
|
21
|
-
* useForegroundService
|
|
22
|
-
*
|
|
23
31
|
* A hook for managing a foreground service on Android. Does nothing on other platforms.
|
|
24
32
|
* You can use this hook to keep your app running in the background. You're also required to run a foreground service when screen sharing.
|
|
25
33
|
*
|
|
@@ -30,7 +38,8 @@ export type ForegroundServiceConfig = {
|
|
|
30
38
|
* @param {Object} config.channelName - The user visible name of the channel.
|
|
31
39
|
* @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.
|
|
32
40
|
* @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.
|
|
33
|
-
*
|
|
41
|
+
* @group Hooks
|
|
42
|
+
* @category Connection
|
|
34
43
|
*/
|
|
35
44
|
export declare const useForegroundService: ({ enableCamera, enableMicrophone, channelId, channelName, notificationContent, notificationTitle, }: ForegroundServiceConfig) => void;
|
|
36
45
|
//# sourceMappingURL=useForegroundService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForegroundService.d.ts","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"useForegroundService.d.ts","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AA6DF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,wGAnD9B,uBAAuB,SAsDxB,CAAC"}
|
|
@@ -46,8 +46,6 @@ const useForegroundServiceAndroid = ({ enableCamera, enableMicrophone, channelId
|
|
|
46
46
|
};
|
|
47
47
|
const emptyFunction = () => { };
|
|
48
48
|
/**
|
|
49
|
-
* useForegroundService
|
|
50
|
-
*
|
|
51
49
|
* A hook for managing a foreground service on Android. Does nothing on other platforms.
|
|
52
50
|
* You can use this hook to keep your app running in the background. You're also required to run a foreground service when screen sharing.
|
|
53
51
|
*
|
|
@@ -58,7 +56,8 @@ const emptyFunction = () => { };
|
|
|
58
56
|
* @param {Object} config.channelName - The user visible name of the channel.
|
|
59
57
|
* @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.
|
|
60
58
|
* @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.
|
|
61
|
-
*
|
|
59
|
+
* @group Hooks
|
|
60
|
+
* @category Connection
|
|
62
61
|
*/
|
|
63
62
|
export const useForegroundService = Platform.select({
|
|
64
63
|
android: useForegroundServiceAndroid,
|