@fishjam-cloud/react-native-client 0.4.1 → 0.5.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.
Files changed (87) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +99 -14
  3. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +63 -92
  4. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +12 -23
  5. package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +6 -2
  6. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +41 -3
  7. package/android/src/main/java/io/fishjam/reactnative/extensions/CaptureDevice.kt +17 -0
  8. package/android/src/main/java/io/fishjam/reactnative/foregroundService/FishjamForegroundService.kt +10 -4
  9. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +41 -70
  10. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceState.kt +46 -0
  11. package/android/src/main/java/io/fishjam/reactnative/managers/ListenerManager.kt +22 -0
  12. package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +2 -15
  13. package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +1 -11
  14. package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +1 -15
  15. package/build/RNFishjamClientModule.d.ts +6 -7
  16. package/build/RNFishjamClientModule.d.ts.map +1 -1
  17. package/build/RNFishjamClientModule.js.map +1 -1
  18. package/build/common/client.d.ts +2 -1
  19. package/build/common/client.d.ts.map +1 -1
  20. package/build/common/client.js.map +1 -1
  21. package/build/common/webRTC.d.ts +2 -1
  22. package/build/common/webRTC.d.ts.map +1 -1
  23. package/build/common/webRTC.js.map +1 -1
  24. package/build/components/FishjamRoom/GridTrackItem.d.ts +11 -0
  25. package/build/components/FishjamRoom/GridTrackItem.d.ts.map +1 -0
  26. package/build/components/FishjamRoom/GridTrackItem.js +56 -0
  27. package/build/components/FishjamRoom/GridTrackItem.js.map +1 -0
  28. package/build/components/FishjamRoom/VideosGrid.d.ts +3 -0
  29. package/build/components/FishjamRoom/VideosGrid.d.ts.map +1 -0
  30. package/build/components/FishjamRoom/VideosGrid.js +20 -0
  31. package/build/components/FishjamRoom/VideosGrid.js.map +1 -0
  32. package/build/components/FishjamRoom/index.d.ts +6 -0
  33. package/build/components/FishjamRoom/index.d.ts.map +1 -0
  34. package/build/components/FishjamRoom/index.js +29 -0
  35. package/build/components/FishjamRoom/index.js.map +1 -0
  36. package/build/components/FishjamRoom/parsePeersToTracks.d.ts +4 -0
  37. package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +1 -0
  38. package/build/components/FishjamRoom/parsePeersToTracks.js +36 -0
  39. package/build/components/FishjamRoom/parsePeersToTracks.js.map +1 -0
  40. package/build/components/VideoRendererView.d.ts +6 -1
  41. package/build/components/VideoRendererView.d.ts.map +1 -1
  42. package/build/components/VideoRendererView.js.map +1 -1
  43. package/build/hooks/useAppScreenShare.js +1 -1
  44. package/build/hooks/useAppScreenShare.js.map +1 -1
  45. package/build/hooks/useCamera.d.ts +6 -2
  46. package/build/hooks/useCamera.d.ts.map +1 -1
  47. package/build/hooks/useCamera.js +14 -17
  48. package/build/hooks/useCamera.js.map +1 -1
  49. package/build/hooks/useFishjamEvent.d.ts +1 -1
  50. package/build/hooks/useFishjamEvent.js +1 -1
  51. package/build/hooks/useFishjamEvent.js.map +1 -1
  52. package/build/hooks/useFishjamEventState.d.ts +3 -0
  53. package/build/hooks/useFishjamEventState.d.ts.map +1 -0
  54. package/build/hooks/useFishjamEventState.js +16 -0
  55. package/build/hooks/useFishjamEventState.js.map +1 -0
  56. package/build/hooks/useForegroundService.d.ts +12 -20
  57. package/build/hooks/useForegroundService.d.ts.map +1 -1
  58. package/build/hooks/useForegroundService.js +14 -4
  59. package/build/hooks/useForegroundService.js.map +1 -1
  60. package/build/hooks/useMicrophone.d.ts.map +1 -1
  61. package/build/hooks/useMicrophone.js +5 -10
  62. package/build/hooks/useMicrophone.js.map +1 -1
  63. package/build/hooks/usePeers.d.ts +50 -11
  64. package/build/hooks/usePeers.d.ts.map +1 -1
  65. package/build/hooks/usePeers.js +41 -6
  66. package/build/hooks/usePeers.js.map +1 -1
  67. package/build/hooks/useScreenShare.d.ts.map +1 -1
  68. package/build/hooks/useScreenShare.js +5 -6
  69. package/build/hooks/useScreenShare.js.map +1 -1
  70. package/build/index.d.ts +3 -2
  71. package/build/index.d.ts.map +1 -1
  72. package/build/index.js +1 -0
  73. package/build/index.js.map +1 -1
  74. package/build/types.d.ts +1 -1
  75. package/build/types.d.ts.map +1 -1
  76. package/build/types.js.map +1 -1
  77. package/build/utils/errorListener.js +2 -2
  78. package/build/utils/errorListener.js.map +1 -1
  79. package/ios/Events.swift +97 -19
  80. package/ios/RNFishjamClient.podspec +1 -1
  81. package/ios/RNFishjamClient.swift +74 -109
  82. package/ios/RNFishjamClientModule.swift +6 -6
  83. package/ios/VideoPreviewView.swift +13 -13
  84. package/ios/VideoRendererView.swift +28 -25
  85. package/ios/VideoRendererViewModule.swift +8 -4
  86. package/ios/extensions/AVCaptureDevice.swift +20 -0
  87. package/package.json +8 -10
@@ -0,0 +1,6 @@
1
+ export type FishjamRoomProps = {
2
+ fishjamUrl: string;
3
+ peerToken: string;
4
+ };
5
+ export declare const FishjamRoom: ({ fishjamUrl, peerToken }: FishjamRoomProps) => import("react").JSX.Element;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,WAAW,8BAA+B,gBAAgB,gCA0BtE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { useEffect } from 'react';
2
+ import { joinRoom, leaveRoom } from '../../common/client';
3
+ import { useCamera } from '../../hooks/useCamera';
4
+ import { VideosGrid } from './VideosGrid';
5
+ import { SafeAreaView } from 'react-native';
6
+ export const FishjamRoom = ({ fishjamUrl, peerToken }) => {
7
+ const { prepareCamera } = useCamera();
8
+ useEffect(() => {
9
+ const join = async () => {
10
+ await prepareCamera({
11
+ simulcastEnabled: false,
12
+ quality: 'HD169',
13
+ cameraEnabled: true,
14
+ });
15
+ await joinRoom(fishjamUrl, peerToken, {
16
+ peer: {},
17
+ server: {},
18
+ });
19
+ };
20
+ join();
21
+ return () => {
22
+ leaveRoom();
23
+ };
24
+ }, [fishjamUrl, peerToken, prepareCamera]);
25
+ return (<SafeAreaView>
26
+ <VideosGrid />
27
+ </SafeAreaView>);
28
+ };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO5C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,EAAoB,EAAE,EAAE;IACzE,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,CAAC;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;YACtB,MAAM,aAAa,CAAC;gBAClB,gBAAgB,EAAE,KAAK;gBACvB,OAAO,EAAE,OAAO;gBAChB,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC;YACH,MAAM,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE;gBACpC,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;QACL,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;QACP,OAAO,GAAG,EAAE;YACV,SAAS,EAAE,CAAC;QACd,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE3C,OAAO,CACL,CAAC,YAAY,CACX;MAAA,CAAC,UAAU,CAAC,AAAD,EACb;IAAA,EAAE,YAAY,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { joinRoom, leaveRoom } from '../../common/client';\nimport { useCamera } from '../../hooks/useCamera';\nimport { VideosGrid } from './VideosGrid';\nimport { SafeAreaView } from 'react-native';\n\nexport type FishjamRoomProps = {\n fishjamUrl: string;\n peerToken: string;\n};\n\nexport const FishjamRoom = ({ fishjamUrl, peerToken }: FishjamRoomProps) => {\n const { prepareCamera } = useCamera();\n\n useEffect(() => {\n const join = async () => {\n await prepareCamera({\n simulcastEnabled: false,\n quality: 'HD169',\n cameraEnabled: true,\n });\n await joinRoom(fishjamUrl, peerToken, {\n peer: {},\n server: {},\n });\n };\n join();\n return () => {\n leaveRoom();\n };\n }, [fishjamUrl, peerToken, prepareCamera]);\n\n return (\n <SafeAreaView>\n <VideosGrid />\n </SafeAreaView>\n );\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import { PeerWithTracks } from '../../hooks/usePeers';
2
+ import { GridTrack } from './GridTrackItem';
3
+ export declare const parsePeersToTracks: (localPeer: PeerWithTracks | null, remotePeers: PeerWithTracks[]) => GridTrack[];
4
+ //# sourceMappingURL=parsePeersToTracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsePeersToTracks.d.ts","sourceRoot":"","sources":["../../../src/components/FishjamRoom/parsePeersToTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAqC5C,eAAO,MAAM,kBAAkB,cAClB,cAAc,GAAG,IAAI,eACnB,cAAc,EAAE,KAC5B,SAAS,EAKX,CAAC"}
@@ -0,0 +1,36 @@
1
+ const createGridTracksFromPeer = (peer) => {
2
+ const tracks = [];
3
+ if (peer.cameraTrack && peer.cameraTrack.isActive) {
4
+ tracks.push({
5
+ track: peer.cameraTrack,
6
+ peerId: peer.id,
7
+ isLocal: peer.isLocal,
8
+ isVadActive: peer.microphoneTrack?.vadStatus === 'speech',
9
+ });
10
+ }
11
+ if (peer.screenShareVideoTrack && peer.screenShareVideoTrack.isActive) {
12
+ tracks.push({
13
+ track: peer.screenShareVideoTrack,
14
+ peerId: peer.id,
15
+ isLocal: peer.isLocal,
16
+ isVadActive: peer.screenShareAudioTrack?.vadStatus === 'speech',
17
+ });
18
+ }
19
+ if (tracks.length === 0) {
20
+ tracks.push({
21
+ track: null,
22
+ peerId: peer.id,
23
+ isLocal: peer.isLocal,
24
+ isVadActive: peer.microphoneTrack?.vadStatus === 'speech' ||
25
+ peer.screenShareAudioTrack?.vadStatus === 'speech',
26
+ });
27
+ }
28
+ return tracks;
29
+ };
30
+ export const parsePeersToTracks = (localPeer, remotePeers) => {
31
+ return [
32
+ ...(localPeer ? createGridTracksFromPeer(localPeer) : []),
33
+ ...remotePeers.flatMap(createGridTracksFromPeer),
34
+ ];
35
+ };
36
+ //# sourceMappingURL=parsePeersToTracks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsePeersToTracks.js","sourceRoot":"","sources":["../../../src/components/FishjamRoom/parsePeersToTracks.ts"],"names":[],"mappings":"AAGA,MAAM,wBAAwB,GAAG,CAAC,IAAoB,EAAe,EAAE;IACrE,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CA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ks/usePeers';\nimport { GridTrack } from './GridTrackItem';\n\nconst createGridTracksFromPeer = (peer: PeerWithTracks): GridTrack[] => {\n const tracks: GridTrack[] = [];\n\n if (peer.cameraTrack && peer.cameraTrack.isActive) {\n tracks.push({\n track: peer.cameraTrack,\n peerId: peer.id,\n isLocal: peer.isLocal,\n isVadActive: peer.microphoneTrack?.vadStatus === 'speech',\n });\n }\n\n if (peer.screenShareVideoTrack && peer.screenShareVideoTrack.isActive) {\n tracks.push({\n track: peer.screenShareVideoTrack,\n peerId: peer.id,\n isLocal: peer.isLocal,\n isVadActive: peer.screenShareAudioTrack?.vadStatus === 'speech',\n });\n }\n\n if (tracks.length === 0) {\n tracks.push({\n track: null,\n peerId: peer.id,\n isLocal: peer.isLocal,\n isVadActive:\n peer.microphoneTrack?.vadStatus === 'speech' ||\n peer.screenShareAudioTrack?.vadStatus === 'speech',\n });\n }\n\n return tracks;\n};\n\nexport const parsePeersToTracks = (\n localPeer: PeerWithTracks | null,\n remotePeers: PeerWithTracks[],\n): GridTrack[] => {\n return [\n ...(localPeer ? createGridTracksFromPeer(localPeer) : []),\n ...remotePeers.flatMap(createGridTracksFromPeer),\n ];\n};\n"]}
@@ -1,16 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import { ViewStyle } from 'react-native';
3
3
  import { VideoLayout } from '../types';
4
+ import type { TrackId } from '../hooks/usePeers';
4
5
  export type VideoRendererProps = {
5
6
  /**
6
7
  * id of the video track which you want to render.
7
8
  */
8
- trackId: string;
9
+ trackId: TrackId;
9
10
  /**
10
11
  * Video layout inside of the component
11
12
  * @default `FILL`
12
13
  */
13
14
  videoLayout?: VideoLayout;
15
+ /**
16
+ * Whether the video should be rendered if it's off screen or hidden.
17
+ */
18
+ skipRenderOutsideVisibleArea?: boolean;
14
19
  style?: ViewStyle;
15
20
  };
16
21
  /**
@@ -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;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oHAM5B,CAAC"}
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;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oHAM5B,CAAC"}
@@ -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;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 usePeers} 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"]}
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;AAuB/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';\nimport type { TrackId } from '../hooks/usePeers';\n\nexport type VideoRendererProps = {\n /**\n * id of the video track which you want to render.\n */\n trackId: TrackId;\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n /**\n * Whether the video should be rendered if it's off screen or hidden.\n */\n skipRenderOutsideVisibleArea?: boolean;\n style?: ViewStyle;\n};\n\nconst NativeView: React.ComponentType<VideoRendererProps> =\n requireNativeViewManager('VideoRendererViewModule');\n\n/**\n * Render video track received from {@link usePeers} 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"]}
@@ -22,7 +22,7 @@ function useIosAppScreenShare() {
22
22
  ...screenShareOptions,
23
23
  screenShareMetadata: {
24
24
  displayName: 'presenting',
25
- type: 'screensharing',
25
+ type: 'screenShareVideo',
26
26
  active: !isAppScreenShareOn,
27
27
  },
28
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useAppScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useAppScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,EAAE,KAAK;IACd,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,IAAI,0BAA0B,GAAoB,sBAAsB,EAAE,CAAC;AAU3E;;;;;GAKG;AACH,SAAS,oBAAoB;IAC3B,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAC1D,qBAAqB,CAAC,kBAAkB,CACzC,CAAC;IAEF,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CACpD,0BAA0B,CAC3B,CAAC;IAEF,eAAe,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;IAE5E,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,eAAwB;gBAC9B,MAAM,EAAE,CAAC,kBAAkB;aAC5B;SACF,CAAC;QACF,MAAM,qBAAqB,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAC1D,0BAA0B,GAAG,sBAAsB,EAAE,CAAC,CAAC,kCAAkC;QACzF,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IACjD,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,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, useState } from 'react';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { SimulcastConfig } from '../types';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\nimport { ScreenShareOptions } from './useScreenShare';\nimport { Platform } from 'react-native';\n\nconst defaultSimulcastConfig = () => ({\n enabled: false,\n activeEncodings: [],\n});\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\n/**\n * This hook can toggle client app screen sharing on/off and provides current screen share state. It works only on iOS.\n * @returns An object with functions to manage app screen share on iOS and null on android.\n * @category Screenshare\n * @group Hooks\n */\nfunction useIosAppScreenShare(): AppScreenShareData {\n const [isAppScreenShareOn, setIsAppScreenShareOn] = useState(\n RNFishjamClientModule.isAppScreenShareOn,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n screenShareSimulcastConfig,\n );\n\n useFishjamEvent(ReceivableEvents.IsAppScreenShareOn, setIsAppScreenShareOn);\n\n const toggleAppScreenShare = useCallback(\n async (screenShareOptions: Partial<ScreenShareOptions> = {}) => {\n const options = {\n ...screenShareOptions,\n screenShareMetadata: {\n displayName: 'presenting',\n type: 'screensharing' as const,\n active: !isAppScreenShareOn,\n },\n };\n await RNFishjamClientModule.toggleAppScreenShare(options);\n screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings\n setSimulcastConfig(screenShareSimulcastConfig);\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\nexport const useAppScreenShare = Platform.select({\n ios: useIosAppScreenShare,\n default: useDefaultAppScreenShareAndroid,\n});\n"]}
1
+ {"version":3,"file":"useAppScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useAppScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE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,EAAE,KAAK;QACzB,eAAe,EAAE,sBAAsB,EAAE;QACzC,oBAAoB,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,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, useState } from 'react';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { SimulcastConfig } from '../types';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\nimport { ScreenShareOptions } from './useScreenShare';\nimport { Platform } from 'react-native';\n\nconst defaultSimulcastConfig = () => ({\n enabled: false,\n activeEncodings: [],\n});\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\n/**\n * This hook can toggle client app screen sharing on/off and provides current screen share state. It works only on iOS.\n * @returns An object with functions to manage app screen share on iOS and null on android.\n * @category Screenshare\n * @group Hooks\n */\nfunction useIosAppScreenShare(): AppScreenShareData {\n const [isAppScreenShareOn, setIsAppScreenShareOn] = useState(\n RNFishjamClientModule.isAppScreenShareOn,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n screenShareSimulcastConfig,\n );\n\n useFishjamEvent(ReceivableEvents.IsAppScreenShareOn, setIsAppScreenShareOn);\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 setSimulcastConfig(screenShareSimulcastConfig);\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\nexport const useAppScreenShare = Platform.select({\n ios: useIosAppScreenShare,\n default: useDefaultAppScreenShareAndroid,\n});\n"]}
@@ -6,6 +6,10 @@ export type Camera = {
6
6
  name: string;
7
7
  facingDirection: CameraFacingDirection;
8
8
  };
9
+ export type CurrentCameraChangedType = {
10
+ currentCamera: Camera | null;
11
+ isCameraOn: boolean;
12
+ };
9
13
  export type VideoQuality = 'QVGA169' | 'VGA169' | 'QHD169' | 'HD169' | 'FHD169' | 'QVGA43' | 'VGA43' | 'QHD43' | 'HD43' | 'FHD43';
10
14
  type CameraConfigBase = {
11
15
  /**
@@ -82,7 +86,7 @@ export declare function useCamera(): {
82
86
  /**
83
87
  * Which camera is now used for streaming (or will be used as default when camera will be enabled)
84
88
  */
85
- currentCamera: Camera | undefined;
89
+ currentCamera: Camera | null;
86
90
  /**
87
91
  * Simulcast configuration
88
92
  */
@@ -99,7 +103,7 @@ export declare function useCamera(): {
99
103
  * @param config configuration of the camera capture
100
104
  * @returns A promise that resolves when camera is started.
101
105
  */
102
- prepareCamera: (config?: Readonly<CameraConfig>) => Promise<void>;
106
+ prepareCamera: (config?: Readonly<CameraConfig>) => Promise<boolean>;
103
107
  /**
104
108
  * Switches to the specified camera.
105
109
  * List of available devices can be retrieved from `cameras` variable
@@ -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,m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,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;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,GAAG,CACE;IAAE,eAAe,CAAC,EAAE,cAAc,CAAA;CAAE,GACpC;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;IA0ErB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAGH,oCAAoC;;IAEpC;;;;OAIG;6BA7EY,QAAQ,CAAC,YAAY,CAAC;IA+ErC;;;;OAIG,0BA3D6C,QAAQ;IA6DxD;;;;OAIG;yCArDc,aAAa;IAuD9B;;;;;OAKG;+CArDc,aAAa,aAAa,cAAc;IAuDzD;;;;;;;OAOG;wCA5Ee,cAAc;EA+EnC"}
@@ -1,7 +1,8 @@
1
- import { useCallback, useMemo, useState } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import RNFishjamClientModule from '../RNFishjamClientModule';
4
- import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
4
+ import { ReceivableEvents } from './useFishjamEvent';
5
+ import { useFishjamEventState } from './useFishjamEventState';
5
6
  const defaultSimulcastConfig = () => ({
6
7
  enabled: false,
7
8
  activeEncodings: [],
@@ -49,24 +50,23 @@ export function updateCameraConfig(config) {
49
50
  * @group Hooks
50
51
  */
51
52
  export function useCamera() {
52
- const [isCameraOn, setIsCameraOn] = useState(RNFishjamClientModule.isCameraOn);
53
- const [currentCamera, setCurrentCamera] = useState(undefined);
54
- const [simulcastConfig, setSimulcastConfig] = useState(defaultSimulcastConfig());
55
- useFishjamEvent(ReceivableEvents.SimulcastConfigUpdate, setSimulcastConfig);
56
- useFishjamEvent(ReceivableEvents.IsCameraOn, setIsCameraOn);
57
- const cameras = useMemo(() => {
58
- return RNFishjamClientModule.cameras;
59
- }, []);
53
+ const simulcastConfig = useFishjamEventState(ReceivableEvents.SimulcastConfigUpdate, defaultSimulcastConfig());
54
+ const { currentCamera: currentCameraState, isCameraOn } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {
55
+ currentCamera: RNFishjamClientModule.currentCamera,
56
+ isCameraOn: RNFishjamClientModule.isCameraOn,
57
+ });
58
+ // For Android Expo converts null to undefined ¯\_()_/¯
59
+ const currentCamera = currentCameraState ?? null;
60
+ const cameras = useMemo(() => RNFishjamClientModule.cameras, []);
60
61
  const prepareCamera = useCallback(async (config = {}) => {
61
62
  const camera = RNFishjamClientModule.cameras.find((camera) => config.cameraId
62
63
  ? camera.id === config.cameraId
63
64
  : camera.facingDirection === 'front');
64
- setCurrentCamera(camera);
65
65
  const updatedConfig = updateCameraConfig({
66
66
  ...config,
67
67
  cameraId: camera?.id,
68
68
  });
69
- await RNFishjamClientModule.startCamera(updatedConfig);
69
+ return RNFishjamClientModule.startCamera(updatedConfig);
70
70
  }, []);
71
71
  const toggleCamera = useCallback(async () => {
72
72
  const state = await RNFishjamClientModule.toggleCamera();
@@ -74,18 +74,15 @@ export function useCamera() {
74
74
  active: state,
75
75
  type: 'camera',
76
76
  });
77
- setIsCameraOn(state);
78
77
  }, []);
79
78
  const switchCamera = useCallback(async (cameraId) => {
80
79
  await RNFishjamClientModule.switchCamera(cameraId);
81
- setCurrentCamera(cameras.find((camera) => camera.id === cameraId));
82
- }, [cameras]);
80
+ }, []);
83
81
  const setVideoTrackBandwidth = useCallback(async (bandwidth) => {
84
82
  await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);
85
83
  }, []);
86
84
  const toggleVideoTrackEncoding = useCallback(async (encoding) => {
87
- const videoSimulcastConfig = await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);
88
- setSimulcastConfig(videoSimulcastConfig);
85
+ await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);
89
86
  }, []);
90
87
  const setVideoTrackEncodingBandwidth = useCallback(async (encoding, bandwidth) => {
91
88
  await RNFishjamClientModule.setVideoTrackEncodingBandwidth(encoding, bandwidth);
@@ -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,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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AAE,KAAK,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC,EACD,CAAC,OAAO,CAAC,CACV,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"]}
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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,QAAQ,CAAC,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,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,qBAAqB,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IACjE,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 } 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\n */\n setVideoTrackBandwidth,\n };\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  export declare const ReceivableEvents: {
2
- readonly IsCameraOn: "IsCameraOn";
3
2
  readonly IsMicrophoneOn: "IsMicrophoneOn";
4
3
  readonly IsScreenShareOn: "IsScreenShareOn";
5
4
  readonly IsAppScreenShareOn: "IsAppScreenShareOn";
@@ -13,6 +12,7 @@ export declare const ReceivableEvents: {
13
12
  readonly Reconnected: "Reconnected";
14
13
  readonly Warning: "Warning";
15
14
  readonly PeerStatusChanged: "PeerStatusChanged";
15
+ readonly CurrentCameraChanged: "CurrentCameraChanged";
16
16
  };
17
17
  export declare function useFishjamEvent<T>(eventName: keyof typeof ReceivableEvents, callback: (event: T) => void): void;
18
18
  //# sourceMappingURL=useFishjamEvent.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { nativeModuleEventEmitter } from '../RNFishjamClientModule';
3
3
  export const ReceivableEvents = {
4
- IsCameraOn: 'IsCameraOn',
5
4
  IsMicrophoneOn: 'IsMicrophoneOn',
6
5
  IsScreenShareOn: 'IsScreenShareOn',
7
6
  IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS
@@ -15,6 +14,7 @@ export const ReceivableEvents = {
15
14
  Reconnected: 'Reconnected',
16
15
  Warning: 'Warning',
17
16
  PeerStatusChanged: 'PeerStatusChanged',
17
+ CurrentCameraChanged: 'CurrentCameraChanged',
18
18
  };
19
19
  export function useFishjamEvent(eventName, callback) {
20
20
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"useFishjamEvent.js","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB,EAAE,eAAe;IACzD,qBAAqB,EAAE,uBAAuB;IAC9C,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;IAC1C,+BAA+B,EAAE,iCAAiC;IAClE,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,iBAAiB,EAAE,mBAAmB;CAC9B,CAAC;AAEX,MAAM,UAAU,eAAe,CAC7B,SAAwC,EACxC,QAA4B;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAExD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;IACtC,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { nativeModuleEventEmitter } from '../RNFishjamClientModule';\n\nexport const ReceivableEvents = {\n IsCameraOn: 'IsCameraOn',\n IsMicrophoneOn: 'IsMicrophoneOn',\n IsScreenShareOn: 'IsScreenShareOn',\n IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS\n SimulcastConfigUpdate: 'SimulcastConfigUpdate',\n PeersUpdate: 'PeersUpdate',\n AudioDeviceUpdate: 'AudioDeviceUpdate',\n SendMediaEvent: 'SendMediaEvent',\n BandwidthEstimation: 'BandwidthEstimation',\n ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',\n ReconnectionStarted: 'ReconnectionStarted',\n Reconnected: 'Reconnected',\n Warning: 'Warning',\n PeerStatusChanged: 'PeerStatusChanged',\n} as const;\n\nexport function useFishjamEvent<T>(\n eventName: keyof typeof ReceivableEvents,\n callback: (event: T) => void,\n) {\n useEffect(() => {\n const eventListener = nativeModuleEventEmitter.addListener<\n Record<keyof typeof ReceivableEvents, T>\n >(eventName, (event) => {\n callback(event[eventName]);\n });\n return () => eventListener.remove();\n }, [callback, eventName]);\n}\n"]}
1
+ {"version":3,"file":"useFishjamEvent.js","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB,EAAE,eAAe;IACzD,qBAAqB,EAAE,uBAAuB;IAC9C,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;IAC1C,+BAA+B,EAAE,iCAAiC;IAClE,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AAEX,MAAM,UAAU,eAAe,CAC7B,SAAwC,EACxC,QAA4B;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAExD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;IACtC,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { nativeModuleEventEmitter } from '../RNFishjamClientModule';\n\nexport const ReceivableEvents = {\n IsMicrophoneOn: 'IsMicrophoneOn',\n IsScreenShareOn: 'IsScreenShareOn',\n IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS\n SimulcastConfigUpdate: 'SimulcastConfigUpdate',\n PeersUpdate: 'PeersUpdate',\n AudioDeviceUpdate: 'AudioDeviceUpdate',\n SendMediaEvent: 'SendMediaEvent',\n BandwidthEstimation: 'BandwidthEstimation',\n ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',\n ReconnectionStarted: 'ReconnectionStarted',\n Reconnected: 'Reconnected',\n Warning: 'Warning',\n PeerStatusChanged: 'PeerStatusChanged',\n CurrentCameraChanged: 'CurrentCameraChanged',\n} as const;\n\nexport function useFishjamEvent<T>(\n eventName: keyof typeof ReceivableEvents,\n callback: (event: T) => void,\n) {\n useEffect(() => {\n const eventListener = nativeModuleEventEmitter.addListener<\n Record<keyof typeof ReceivableEvents, T>\n >(eventName, (event) => {\n callback(event[eventName]);\n });\n return () => eventListener.remove();\n }, [callback, eventName]);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { ReceivableEvents } from './useFishjamEvent';
2
+ export declare function useFishjamEventState<EventType, StateType = EventType>(eventName: keyof typeof ReceivableEvents, defaultValue: StateType, transform?: StateType extends EventType ? undefined : (eventValue: EventType) => StateType): StateType;
3
+ //# sourceMappingURL=useFishjamEventState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFishjamEventState.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamEventState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAEtE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EACnE,SAAS,EAAE,MAAM,OAAO,gBAAgB,EACxC,YAAY,EAAE,SAAS,EACvB,SAAS,CAAC,EAAE,SAAS,SAAS,SAAS,GACnC,SAAS,GACT,CAAC,UAAU,EAAE,SAAS,KAAK,SAAS,aAkBzC"}
@@ -0,0 +1,16 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { useFishjamEvent } from './useFishjamEvent';
3
+ export function useFishjamEventState(eventName, defaultValue, transform) {
4
+ const [value, setValue] = useState(defaultValue);
5
+ const onEvent = useCallback((newValue) => {
6
+ if (transform) {
7
+ setValue(transform(newValue));
8
+ }
9
+ else {
10
+ setValue(newValue);
11
+ }
12
+ }, [transform]);
13
+ useFishjamEvent(eventName, onEvent);
14
+ return value;
15
+ }
16
+ //# sourceMappingURL=useFishjamEventState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFishjamEventState.js","sourceRoot":"","sources":["../../src/hooks/useFishjamEventState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,UAAU,oBAAoB,CAClC,SAAwC,EACxC,YAAuB,EACvB,SAEwC;IAExC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAY,YAAY,CAAC,CAAC;IAE5D,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,QAAmB,EAAE,EAAE;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,QAAgC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\nexport function useFishjamEventState<EventType, StateType = EventType>(\n eventName: keyof typeof ReceivableEvents,\n defaultValue: StateType,\n transform?: StateType extends EventType\n ? undefined\n : (eventValue: EventType) => StateType,\n) {\n const [value, setValue] = useState<StateType>(defaultValue);\n\n const onEvent = useCallback(\n (newValue: EventType) => {\n if (transform) {\n setValue(transform(newValue));\n } else {\n setValue(newValue as unknown as StateType);\n }\n },\n [transform],\n );\n\n useFishjamEvent(eventName, onEvent);\n\n return value;\n}\n"]}
@@ -1,30 +1,22 @@
1
- export type ForegroundServicePermissionsConfigInternal = {
2
- enableCamera?: boolean;
3
- enableMicrophone?: boolean;
4
- enableScreenSharing?: boolean;
5
- };
6
1
  /**
7
- * A type representing the options required for configuring the foreground service notifcation.
2
+ * A type representing the configuration for foreground service permissions.
8
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.
9
6
  * @param channelId The id of the channel. Must be unique per package.
10
7
  * @param channelName The user visible name of the channel.
11
8
  * @param notificationTitle The title (first row) of the notification, in a standard notification.
12
9
  * @param notificationContent The text (second row) of the notification, in a standard notification.
13
- */
14
- export type ForegroundServiceNotificationConfig = {
15
- channelId: string;
16
- channelName: string;
17
- notificationTitle: string;
18
- notificationContent: string;
19
- };
20
- /**
21
- * A type representing the configuration for foreground service permissions.
22
- *
23
- * @param enableCamera Indicates whether the camera is enabled for the foreground service.
24
- * @param enableMicrophone Indicates whether the microphone is enabled for the foreground service.
25
10
  *
26
11
  */
27
- export type ForegroundServicePermissionsConfig = Pick<ForegroundServicePermissionsConfigInternal, 'enableCamera' | 'enableMicrophone'>;
12
+ export type ForegroundServiceConfig = {
13
+ enableCamera?: boolean;
14
+ enableMicrophone?: boolean;
15
+ channelId?: string;
16
+ channelName?: string;
17
+ notificationTitle?: string;
18
+ notificationContent?: string;
19
+ };
28
20
  /**
29
21
  * useForegroundService
30
22
  *
@@ -40,5 +32,5 @@ export type ForegroundServicePermissionsConfig = Pick<ForegroundServicePermissio
40
32
  * @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.
41
33
  *
42
34
  */
43
- export declare const useForegroundService: ({ enableCamera, enableMicrophone, ...restOptions }: ForegroundServiceNotificationConfig & ForegroundServicePermissionsConfig) => void;
35
+ export declare const useForegroundService: ({ enableCamera, enableMicrophone, channelId, channelName, notificationContent, notificationTitle, }: ForegroundServiceConfig) => void;
44
36
  //# sourceMappingURL=useForegroundService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useForegroundService.d.ts","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,0CAA0C,GAAG;IACvD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AACF;;;;;;GAMG;AACH,MAAM,MAAM,kCAAkC,GAAG,IAAI,CACnD,0CAA0C,EAC1C,cAAc,GAAG,kBAAkB,CACpC,CAAC;AAiDF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,uDA3C9B,mCAAmC,GACpC,kCAAkC,SA6ClC,CAAC"}
1
+ {"version":3,"file":"useForegroundService.d.ts","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AA6DF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,wGApD9B,uBAAuB,SAuDxB,CAAC"}
@@ -12,7 +12,7 @@ const requestNotificationsPermission = async () => {
12
12
  console.warn(err);
13
13
  }
14
14
  };
15
- const useForegroundServiceAndroid = ({ enableCamera, enableMicrophone, ...restOptions }) => {
15
+ const useForegroundServiceAndroid = ({ enableCamera, enableMicrophone, channelId, channelName, notificationContent, notificationTitle, }) => {
16
16
  const [isConfigured, setIsConfigured] = useState(false);
17
17
  useEffect(() => {
18
18
  if (!isConfigured) {
@@ -21,17 +21,27 @@ const useForegroundServiceAndroid = ({ enableCamera, enableMicrophone, ...restOp
21
21
  RNFishjamClientModule.startForegroundService({
22
22
  enableCamera,
23
23
  enableMicrophone,
24
+ channelId,
25
+ channelName,
26
+ notificationContent,
27
+ notificationTitle,
24
28
  });
25
- }, [enableCamera, enableMicrophone, isConfigured]);
29
+ }, [
30
+ channelId,
31
+ channelName,
32
+ enableCamera,
33
+ enableMicrophone,
34
+ isConfigured,
35
+ notificationContent,
36
+ notificationTitle,
37
+ ]);
26
38
  useEffect(() => {
27
39
  const runConfiguration = async () => {
28
40
  await requestNotificationsPermission();
29
- RNFishjamClientModule.configureForegroundService(restOptions);
30
41
  setIsConfigured(true);
31
42
  };
32
43
  runConfiguration();
33
44
  return () => RNFishjamClientModule.stopForegroundService();
34
- // eslint-disable-next-line react-hooks/exhaustive-deps
35
45
  }, []);
36
46
  };
37
47
  const emptyFunction = () => { };
@@ -1 +1 @@
1
- {"version":3,"file":"useForegroundService.js","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAkC5D,MAAM,8BAA8B,GAAG,KAAK,IAAI,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAC7C,kBAAkB,CAAC,WAAW,CAAC,kBAAkB,CAClD,CAAC;QACF,IAAI,MAAM,KAAK,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CACV,6FAA6F,CAC9F,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,EACnC,YAAY,EACZ,gBAAgB,EAChB,GAAG,WAAW,EAEoB,EAAE,EAAE;IACtC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,qBAAqB,CAAC,sBAAsB,CAAC;YAC3C,YAAY;YACZ,gBAAgB;SACjB,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;YAClC,MAAM,8BAA8B,EAAE,CAAC;YACvC,qBAAqB,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;YAC9D,eAAe,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,gBAAgB,EAAE,CAAC;QACnB,OAAO,GAAG,EAAE,CAAC,qBAAqB,CAAC,qBAAqB,EAAE,CAAC;QAC3D,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC;IAClD,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nimport { PermissionsAndroid, Platform } from 'react-native';\n\nexport type ForegroundServicePermissionsConfigInternal = {\n enableCamera?: boolean;\n enableMicrophone?: boolean;\n enableScreenSharing?: boolean;\n};\n\n/**\n * A type representing the options required for configuring the foreground service notifcation.\n *\n * @param channelId The id of the channel. Must be unique per package.\n * @param channelName The user visible name of the channel.\n * @param notificationTitle The title (first row) of the notification, in a standard notification.\n * @param notificationContent The text (second row) of the notification, in a standard notification.\n */\nexport type ForegroundServiceNotificationConfig = {\n channelId: string;\n channelName: string;\n notificationTitle: string;\n notificationContent: string;\n};\n/**\n * A type representing the configuration for foreground service permissions.\n *\n * @param enableCamera Indicates whether the camera is enabled for the foreground service.\n * @param enableMicrophone Indicates whether the microphone is enabled for the foreground service.\n *\n */\nexport type ForegroundServicePermissionsConfig = Pick<\n ForegroundServicePermissionsConfigInternal,\n 'enableCamera' | 'enableMicrophone'\n>;\n\nconst requestNotificationsPermission = async () => {\n try {\n const result = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,\n );\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n console.warn(\n \"Notifications permission not granted. User won't be able to see a the app is in background.\",\n );\n }\n } catch (err) {\n console.warn(err);\n }\n};\n\nconst useForegroundServiceAndroid = ({\n enableCamera,\n enableMicrophone,\n ...restOptions\n}: ForegroundServiceNotificationConfig &\n ForegroundServicePermissionsConfig) => {\n const [isConfigured, setIsConfigured] = useState(false);\n\n useEffect(() => {\n if (!isConfigured) {\n return;\n }\n RNFishjamClientModule.startForegroundService({\n enableCamera,\n enableMicrophone,\n });\n }, [enableCamera, enableMicrophone, isConfigured]);\n\n useEffect(() => {\n const runConfiguration = async () => {\n await requestNotificationsPermission();\n RNFishjamClientModule.configureForegroundService(restOptions);\n setIsConfigured(true);\n };\n runConfiguration();\n return () => RNFishjamClientModule.stopForegroundService();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n\nconst emptyFunction = () => {};\n\n/**\n * useForegroundService\n *\n * A hook for managing a foreground service on Android. Does nothing on other platforms.\n * 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.\n *\n * @param {Object} config - Configuration options for the foreground service.\n * @param {boolean} config.enableCamera - Flag to enable or disable camera usage in the foreground service. Only enable after the user has granted the necessary permissions.\n * @param {boolean} config.enableMicrophone - Flag to enable or disable microphone usage in the foreground service. Only enable after the user has granted the necessary permissions.\n * @param {Object} config.channelId - The id of the channel. Must be unique per package.\n * @param {Object} config.channelName - The user visible name of the channel.\n * @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.\n * @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.\n *\n */\nexport const useForegroundService = Platform.select({\n android: useForegroundServiceAndroid,\n default: emptyFunction,\n});\n"]}
1
+ {"version":3,"file":"useForegroundService.js","sourceRoot":"","sources":["../../src/hooks/useForegroundService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAsB5D,MAAM,8BAA8B,GAAG,KAAK,IAAI,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAC7C,kBAAkB,CAAC,WAAW,CAAC,kBAAkB,CAClD,CAAC;QACF,IAAI,MAAM,KAAK,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CACV,6FAA6F,CAC9F,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,EACnC,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,iBAAiB,GACO,EAAE,EAAE;IAC5B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,qBAAqB,CAAC,sBAAsB,CAAC;YAC3C,YAAY;YACZ,gBAAgB;YAChB,SAAS;YACT,WAAW;YACX,mBAAmB;YACnB,iBAAiB;SAClB,CAAC,CAAC;IACL,CAAC,EAAE;QACD,SAAS;QACT,WAAW;QACX,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,mBAAmB;QACnB,iBAAiB;KAClB,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;YAClC,MAAM,8BAA8B,EAAE,CAAC;YACvC,eAAe,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,gBAAgB,EAAE,CAAC;QACnB,OAAO,GAAG,EAAE,CAAC,qBAAqB,CAAC,qBAAqB,EAAE,CAAC;IAC7D,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE/B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC;IAClD,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nimport { PermissionsAndroid, Platform } from 'react-native';\n\n/**\n * A type representing the configuration for foreground service permissions.\n *\n * @param enableCamera Indicates whether the camera is enabled for the foreground service.\n * @param enableMicrophone Indicates whether the microphone is enabled for the foreground service.\n * @param channelId The id of the channel. Must be unique per package.\n * @param channelName The user visible name of the channel.\n * @param notificationTitle The title (first row) of the notification, in a standard notification.\n * @param notificationContent The text (second row) of the notification, in a standard notification.\n *\n */\nexport type ForegroundServiceConfig = {\n enableCamera?: boolean;\n enableMicrophone?: boolean;\n channelId?: string;\n channelName?: string;\n notificationTitle?: string;\n notificationContent?: string;\n};\n\nconst requestNotificationsPermission = async () => {\n try {\n const result = await PermissionsAndroid.request(\n PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,\n );\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n console.warn(\n \"Notifications permission not granted. User won't be able to see a the app is in background.\",\n );\n }\n } catch (err) {\n console.warn(err);\n }\n};\n\nconst useForegroundServiceAndroid = ({\n enableCamera,\n enableMicrophone,\n channelId,\n channelName,\n notificationContent,\n notificationTitle,\n}: ForegroundServiceConfig) => {\n const [isConfigured, setIsConfigured] = useState(false);\n\n useEffect(() => {\n if (!isConfigured) {\n return;\n }\n RNFishjamClientModule.startForegroundService({\n enableCamera,\n enableMicrophone,\n channelId,\n channelName,\n notificationContent,\n notificationTitle,\n });\n }, [\n channelId,\n channelName,\n enableCamera,\n enableMicrophone,\n isConfigured,\n notificationContent,\n notificationTitle,\n ]);\n\n useEffect(() => {\n const runConfiguration = async () => {\n await requestNotificationsPermission();\n setIsConfigured(true);\n };\n runConfiguration();\n return () => RNFishjamClientModule.stopForegroundService();\n }, []);\n};\n\nconst emptyFunction = () => {};\n\n/**\n * useForegroundService\n *\n * A hook for managing a foreground service on Android. Does nothing on other platforms.\n * 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.\n *\n * @param {Object} config - Configuration options for the foreground service.\n * @param {boolean} config.enableCamera - Flag to enable or disable camera usage in the foreground service. Only enable after the user has granted the necessary permissions.\n * @param {boolean} config.enableMicrophone - Flag to enable or disable microphone usage in the foreground service. Only enable after the user has granted the necessary permissions.\n * @param {Object} config.channelId - The id of the channel. Must be unique per package.\n * @param {Object} config.channelName - The user visible name of the channel.\n * @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.\n * @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.\n *\n */\nexport const useForegroundService = Platform.select({\n android: useForegroundServiceAndroid,\n default: emptyFunction,\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useMicrophone.d.ts","sourceRoot":"","sources":["../../src/hooks/useMicrophone.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,aAAa;IAiBzB,+CAA+C;;IAE/C,2CAA2C;;EAG9C"}
1
+ {"version":3,"file":"useMicrophone.d.ts","sourceRoot":"","sources":["../../src/hooks/useMicrophone.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,aAAa;IAWzB,+CAA+C;;IAE/C,2CAA2C;;EAG9C"}
@@ -1,21 +1,16 @@
1
- import { useCallback, useState } from 'react';
1
+ import { useCallback } from 'react';
2
2
  import RNFishjamClientModule from '../RNFishjamClientModule';
3
- import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
3
+ import { ReceivableEvents } from './useFishjamEvent';
4
+ import { useFishjamEventState } from './useFishjamEventState';
4
5
  /**
5
6
  * This hook can toggle microphone on/off and provides current microphone state.
6
7
  * @category Devices
7
8
  * @group Hooks
8
9
  */
9
10
  export function useMicrophone() {
10
- const [isMicrophoneOn, setIsMicrophoneOn] = useState(RNFishjamClientModule.isMicrophoneOn);
11
- useFishjamEvent(ReceivableEvents.IsMicrophoneOn, setIsMicrophoneOn);
11
+ const isMicrophoneOn = useFishjamEventState(ReceivableEvents.IsMicrophoneOn, RNFishjamClientModule.isMicrophoneOn);
12
12
  const toggleMicrophone = useCallback(async () => {
13
- const status = await RNFishjamClientModule.toggleMicrophone();
14
- await RNFishjamClientModule.updateAudioTrackMetadata({
15
- active: status,
16
- type: 'audio',
17
- });
18
- setIsMicrophoneOn(status);
13
+ await RNFishjamClientModule.toggleMicrophone();
19
14
  }, []);
20
15
  return {
21
16
  /** Informs if microphone is streaming audio */
@@ -1 +1 @@
1
- {"version":3,"file":"useMicrophone.js","sourceRoot":"","sources":["../../src/hooks/useMicrophone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAClD,qBAAqB,CAAC,cAAc,CACrC,CAAC;IAEF,eAAe,CAAC,gBAAgB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IAEpE,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;QAC9D,MAAM,qBAAqB,CAAC,wBAAwB,CAAC;YACnD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,+CAA+C;QAC/C,cAAc;QACd,2CAA2C;QAC3C,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\n\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\n/**\n * This hook can toggle microphone on/off and provides current microphone state.\n * @category Devices\n * @group Hooks\n */\nexport function useMicrophone() {\n const [isMicrophoneOn, setIsMicrophoneOn] = useState<boolean>(\n RNFishjamClientModule.isMicrophoneOn,\n );\n\n useFishjamEvent(ReceivableEvents.IsMicrophoneOn, setIsMicrophoneOn);\n\n const toggleMicrophone = useCallback(async () => {\n const status = await RNFishjamClientModule.toggleMicrophone();\n await RNFishjamClientModule.updateAudioTrackMetadata({\n active: status,\n type: 'audio',\n });\n setIsMicrophoneOn(status);\n }, []);\n\n return {\n /** Informs if microphone is streaming audio */\n isMicrophoneOn,\n /** Function to toggle microphone on/off */\n toggleMicrophone,\n };\n}\n"]}
1
+ {"version":3,"file":"useMicrophone.js","sourceRoot":"","sources":["../../src/hooks/useMicrophone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,cAAc,GAAG,oBAAoB,CACzC,gBAAgB,CAAC,cAAc,EAC/B,qBAAqB,CAAC,cAAc,CACrC,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC9C,MAAM,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,+CAA+C;QAC/C,cAAc;QACd,2CAA2C;QAC3C,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react';\n\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents } from './useFishjamEvent';\nimport { useFishjamEventState } from './useFishjamEventState';\n\n/**\n * This hook can toggle microphone on/off and provides current microphone state.\n * @category Devices\n * @group Hooks\n */\nexport function useMicrophone() {\n const isMicrophoneOn = useFishjamEventState<boolean>(\n ReceivableEvents.IsMicrophoneOn,\n RNFishjamClientModule.isMicrophoneOn,\n );\n\n const toggleMicrophone = useCallback(async () => {\n await RNFishjamClientModule.toggleMicrophone();\n }, []);\n\n return {\n /** Informs if microphone is streaming audio */\n isMicrophoneOn,\n /** Function to toggle microphone on/off */\n toggleMicrophone,\n };\n}\n"]}