@fishjam-cloud/react-native-client 0.23.0-RC.0 → 0.24.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 (73) hide show
  1. package/android/src/main/java/io/fishjam/reactnative/PipContainerView.kt +282 -0
  2. package/android/src/main/java/io/fishjam/reactnative/PipContainerViewModule.kt +41 -0
  3. package/android/src/main/java/io/fishjam/reactnative/PipTrackSelector.kt +98 -0
  4. package/android/src/main/java/io/fishjam/reactnative/PipViewFactory.kt +186 -0
  5. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +9 -1
  6. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +2 -0
  7. package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +2 -0
  8. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +152 -11
  9. package/android/src/main/java/io/fishjam/reactnative/helpers/PictureInPictureHelperFragment.kt +20 -0
  10. package/android/src/main/java/io/fishjam/reactnative/managers/ListenerManager.kt +3 -1
  11. package/build/RNFishjamClientModule.d.ts +2 -0
  12. package/build/RNFishjamClientModule.d.ts.map +1 -1
  13. package/build/RNFishjamClientModule.js.map +1 -1
  14. package/build/components/FishjamRoom/index.d.ts.map +1 -1
  15. package/build/components/FishjamRoom/index.js +0 -1
  16. package/build/components/FishjamRoom/index.js.map +1 -1
  17. package/build/components/PipContainerView.d.ts +48 -0
  18. package/build/components/PipContainerView.d.ts.map +1 -0
  19. package/build/components/PipContainerView.js +34 -0
  20. package/build/components/PipContainerView.js.map +1 -0
  21. package/build/hooks/useAppScreenShare.d.ts +0 -2
  22. package/build/hooks/useAppScreenShare.d.ts.map +1 -1
  23. package/build/hooks/useAppScreenShare.js +0 -8
  24. package/build/hooks/useAppScreenShare.js.map +1 -1
  25. package/build/hooks/useCamera.d.ts +2 -2
  26. package/build/hooks/useCamera.d.ts.map +1 -1
  27. package/build/hooks/useCamera.js +1 -3
  28. package/build/hooks/useCamera.js.map +1 -1
  29. package/build/hooks/useScreenShare.d.ts +2 -3
  30. package/build/hooks/useScreenShare.d.ts.map +1 -1
  31. package/build/hooks/useScreenShare.js +0 -7
  32. package/build/hooks/useScreenShare.js.map +1 -1
  33. package/build/index.d.ts +2 -0
  34. package/build/index.d.ts.map +1 -1
  35. package/build/index.js +1 -0
  36. package/build/index.js.map +1 -1
  37. package/build/livestream/components/LivestreamStreamer.d.ts +3 -30
  38. package/build/livestream/components/LivestreamStreamer.d.ts.map +1 -1
  39. package/build/livestream/components/LivestreamStreamer.js +3 -27
  40. package/build/livestream/components/LivestreamStreamer.js.map +1 -1
  41. package/build/livestream/components/LivestreamViewer.d.ts +2 -7
  42. package/build/livestream/components/LivestreamViewer.d.ts.map +1 -1
  43. package/build/livestream/components/LivestreamViewer.js +1 -1
  44. package/build/livestream/components/LivestreamViewer.js.map +1 -1
  45. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts +49 -0
  46. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts.map +1 -0
  47. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js +58 -0
  48. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js.map +1 -0
  49. package/build/livestream/hooks/useLivestreamStreamer.d.ts +40 -3
  50. package/build/livestream/hooks/useLivestreamStreamer.d.ts.map +1 -1
  51. package/build/livestream/hooks/useLivestreamStreamer.js +44 -3
  52. package/build/livestream/hooks/useLivestreamStreamer.js.map +1 -1
  53. package/build/livestream/hooks/useLivestreamViewer.d.ts +7 -0
  54. package/build/livestream/hooks/useLivestreamViewer.d.ts.map +1 -1
  55. package/build/livestream/hooks/useLivestreamViewer.js +39 -11
  56. package/build/livestream/hooks/useLivestreamViewer.js.map +1 -1
  57. package/build/livestream/index.d.ts +2 -1
  58. package/build/livestream/index.d.ts.map +1 -1
  59. package/build/livestream/index.js +2 -1
  60. package/build/livestream/index.js.map +1 -1
  61. package/expo-module.config.json +4 -2
  62. package/ios/PictureInPictureManager.swift +215 -0
  63. package/ios/PipContainerView.swift +56 -0
  64. package/ios/PipContainerViewModule.swift +48 -0
  65. package/ios/RNFishjamClient.swift +1 -0
  66. package/ios/RNFishjamClientModule.swift +4 -3
  67. package/package.json +2 -2
  68. package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +1 -1
  69. package/plugin/broadcastExtensionFiles/Info.plist +1 -1
  70. package/plugin/build/types.d.ts +1 -0
  71. package/plugin/build/withFishjam.js +2 -2
  72. package/plugin/build/withFishjamAndroid.js +44 -5
  73. package/plugin/build/withFishjamIos.js +7 -2
@@ -2,10 +2,6 @@ import { useCallback } from 'react';
2
2
  import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
3
3
  import { Platform } from 'react-native';
4
4
  import { useFishjamEventState } from './internal/useFishjamEventState';
5
- const defaultSimulcastConfig = () => ({
6
- enabled: false,
7
- });
8
- let screenShareSimulcastConfig = defaultSimulcastConfig();
9
5
  /**
10
6
  * This hook can toggle screen sharing on/off and provides current screen share state.
11
7
  * @returns An object with functions to manage screen share.
@@ -14,7 +10,6 @@ let screenShareSimulcastConfig = defaultSimulcastConfig();
14
10
  */
15
11
  export function useScreenShare() {
16
12
  const isScreenShareOn = useFishjamEventState(ReceivableEvents.IsScreenShareOn, RNFishjamClientModule.isScreenShareOn);
17
- const simulcastConfig = useFishjamEventState(ReceivableEvents.SimulcastConfigUpdate, screenShareSimulcastConfig);
18
13
  const handleScreenSharePermission = useCallback(async () => {
19
14
  if (Platform.OS === 'android') {
20
15
  return await RNFishjamClientModule.handleScreenSharePermission();
@@ -36,11 +31,9 @@ export function useScreenShare() {
36
31
  },
37
32
  };
38
33
  await RNFishjamClientModule.toggleScreenShare(options);
39
- screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
40
34
  }, [isScreenShareOn, handleScreenSharePermission]);
41
35
  return {
42
36
  isScreenShareOn,
43
- simulcastConfig,
44
37
  /**
45
38
  * Toggles the screen share on/off
46
39
  * Emits warning on ios when user is screensharing app screen.
@@ -1 +1 @@
1
- {"version":3,"file":"useScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpC,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAqBvE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAClC,CAAC;IACC,OAAO,EAAE,KAAK;CACf,CAA2B,CAAC;AAE/B,IAAI,0BAA0B,GAAoB,sBAAsB,EAAE,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,eAAe,GAAG,oBAAoB,CAC1C,gBAAgB,CAAC,eAAe,EAChC,qBAAqB,CAAC,eAAe,CACtC,CAAC;IAEF,MAAM,eAAe,GAAG,oBAAoB,CAC1C,gBAAgB,CAAC,qBAAqB,EACtC,0BAA0B,CAC3B,CAAC;IAEF,MAAM,2BAA2B,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACzD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,MAAM,qBAAqB,CAAC,2BAA2B,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,iBAAiB,GAAG,WAAW,CACnC,KAAK,EAAE,qBAAkD,EAAE,EAAE,EAAE;QAC7D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,IAAI,CAAC,MAAM,2BAA2B,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;gBACxD,OAAO;YACT,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG;YACd,GAAG,kBAAkB;YACrB,mBAAmB,EAAE;gBACnB,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,kBAA2B;gBACjC,MAAM,EAAE,CAAC,eAAe;aACzB;SACF,CAAC;QACF,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACvD,0BAA0B,GAAG,sBAAsB,EAAE,CAAC,CAAC,kCAAkC;IAC3F,CAAC,EACD,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;IAEF,OAAO;QACL,eAAe;QACf,eAAe;QAEf;;;WAGG;QACH,iBAAiB;QACjB,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react';\n\nimport { SimulcastConfig, TrackMetadata } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { Platform } from 'react-native';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type ScreenShareQuality = 'VGA' | 'HD5' | 'HD15' | 'FHD15' | 'FHD30';\n\nexport type ScreenShareOptions = {\n /**\n * Resolution + fps of screen share track, one of: `VGA`, `HD5`, `HD15`, `FHD15`, `FHD30`.\n * Note that quality might be worse than specified due to device capabilities, internet\n * connection etc.\n * @default `HD15`\n */\n quality: ScreenShareQuality;\n};\nexport type ScreenShareOptionsInternal = {\n screenShareMetadata: TrackMetadata & { displayName?: string };\n /**\n * SimulcastConfig of a screen share track. By default simulcast is disabled.\n */\n simulcastConfig: SimulcastConfig;\n};\n\nconst defaultSimulcastConfig = () =>\n ({\n enabled: false,\n }) satisfies SimulcastConfig;\n\nlet screenShareSimulcastConfig: SimulcastConfig = defaultSimulcastConfig();\n\n/**\n * This hook can toggle screen sharing on/off and provides current screen share state.\n * @returns An object with functions to manage screen share.\n * @category Connection\n * @group Hooks\n */\nexport function useScreenShare() {\n const isScreenShareOn = useFishjamEventState(\n ReceivableEvents.IsScreenShareOn,\n RNFishjamClientModule.isScreenShareOn,\n );\n\n const simulcastConfig = useFishjamEventState(\n ReceivableEvents.SimulcastConfigUpdate,\n screenShareSimulcastConfig,\n );\n\n const handleScreenSharePermission = useCallback(async () => {\n if (Platform.OS === 'android') {\n return await RNFishjamClientModule.handleScreenSharePermission();\n }\n return 'denied';\n }, []);\n\n const toggleScreenShare = useCallback(\n async (screenShareOptions: Partial<ScreenShareOptions> = {}) => {\n if (Platform.OS === 'android' && !isScreenShareOn) {\n if ((await handleScreenSharePermission()) !== 'granted') {\n return;\n }\n }\n const options = {\n ...screenShareOptions,\n screenShareMetadata: {\n displayName: 'presenting',\n type: 'screenShareVideo' as const,\n active: !isScreenShareOn,\n },\n };\n await RNFishjamClientModule.toggleScreenShare(options);\n screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings\n },\n [isScreenShareOn, handleScreenSharePermission],\n );\n\n return {\n isScreenShareOn,\n simulcastConfig,\n\n /**\n * Toggles the screen share on/off\n * Emits warning on ios when user is screensharing app screen.\n */\n toggleScreenShare,\n handleScreenSharePermission,\n };\n}\n"]}
1
+ {"version":3,"file":"useScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpC,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAqBvE;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,eAAe,GAAG,oBAAoB,CAC1C,gBAAgB,CAAC,eAAe,EAChC,qBAAqB,CAAC,eAAe,CACtC,CAAC;IAEF,MAAM,2BAA2B,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACzD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,MAAM,qBAAqB,CAAC,2BAA2B,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,iBAAiB,GAAG,WAAW,CACnC,KAAK,EAAE,qBAAkD,EAAE,EAAE,EAAE;QAC7D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,IAAI,CAAC,MAAM,2BAA2B,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;gBACxD,OAAO;YACT,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG;YACd,GAAG,kBAAkB;YACrB,mBAAmB,EAAE;gBACnB,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,kBAA2B;gBACjC,MAAM,EAAE,CAAC,eAAe;aACzB;SACF,CAAC;QACF,MAAM,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC,EACD,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;IAEF,OAAO;QACL,eAAe;QAEf;;;WAGG;QACH,iBAAiB;QACjB,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from 'react';\n\nimport { SimulcastConfig, TrackMetadata } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { Platform } from 'react-native';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type ScreenShareQuality = 'VGA' | 'HD5' | 'HD15' | 'FHD15' | 'FHD30';\n\nexport type ScreenShareOptions = {\n /**\n * Resolution + fps of screen share track, one of: `VGA`, `HD5`, `HD15`, `FHD15`, `FHD30`.\n * Note that quality might be worse than specified due to device capabilities, internet\n * connection etc.\n * @default `HD15`\n */\n quality: ScreenShareQuality;\n};\nexport type ScreenShareOptionsInternal = {\n screenShareMetadata: TrackMetadata & { displayName?: string };\n /**\n * @deprecated Simulcast is no longer supported\n */\n simulcastConfig?: SimulcastConfig;\n};\n\n/**\n * This hook can toggle screen sharing on/off and provides current screen share state.\n * @returns An object with functions to manage screen share.\n * @category Connection\n * @group Hooks\n */\nexport function useScreenShare() {\n const isScreenShareOn = useFishjamEventState(\n ReceivableEvents.IsScreenShareOn,\n RNFishjamClientModule.isScreenShareOn,\n );\n\n const handleScreenSharePermission = useCallback(async () => {\n if (Platform.OS === 'android') {\n return await RNFishjamClientModule.handleScreenSharePermission();\n }\n return 'denied';\n }, []);\n\n const toggleScreenShare = useCallback(\n async (screenShareOptions: Partial<ScreenShareOptions> = {}) => {\n if (Platform.OS === 'android' && !isScreenShareOn) {\n if ((await handleScreenSharePermission()) !== 'granted') {\n return;\n }\n }\n const options = {\n ...screenShareOptions,\n screenShareMetadata: {\n displayName: 'presenting',\n type: 'screenShareVideo' as const,\n active: !isScreenShareOn,\n },\n };\n await RNFishjamClientModule.toggleScreenShare(options);\n },\n [isScreenShareOn, handleScreenSharePermission],\n );\n\n return {\n isScreenShareOn,\n\n /**\n * Toggles the screen share on/off\n * Emits warning on ios when user is screensharing app screen.\n */\n toggleScreenShare,\n handleScreenSharePermission,\n };\n}\n"]}
package/build/index.d.ts CHANGED
@@ -2,8 +2,10 @@ export type { SimulcastConfig, VideoLayout, GenericMetadata, TrackMetadata, Bran
2
2
  export { updatePeerMetadata } from './common/metadata';
3
3
  export type { VideoPreviewViewProps } from './components/VideoPreviewView';
4
4
  export type { VideoRendererProps } from './components/VideoRendererView';
5
+ export type { PipContainerViewRef, PipContainerViewProps, PictureInPictureConfig, } from './components/PipContainerView';
5
6
  export { VideoPreviewView } from './components/VideoPreviewView';
6
7
  export { VideoRendererView } from './components/VideoRendererView';
8
+ export { PipContainerView } from './components/PipContainerView';
7
9
  export type { Peer, PeerId, Track, TrackId, TrackType, VadStatus, EncodingReason, TrackBase, AudioTrack, VideoTrack, UsePeersResult, PeerWithTracks, PeerTrackMetadata, DistinguishedTracks, } from './hooks/usePeers';
8
10
  export type { AudioOutputDevice, AudioOutputDeviceType, AudioSessionMode, } from './hooks/useAudioSettings';
9
11
  export type { CameraId, Camera, CameraConfig, VideoQuality, CameraFacingDirection, CameraConfigBase, } from './hooks/useCamera';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,KAAK,EACL,QAAQ,GACT,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAInE,YAAY,EACV,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,o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,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKvD,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/build/index.js CHANGED
@@ -4,6 +4,7 @@ import { initializeWarningListener } from './utils/errorListener';
4
4
  export { updatePeerMetadata } from './common/metadata';
5
5
  export { VideoPreviewView } from './components/VideoPreviewView';
6
6
  export { VideoRendererView } from './components/VideoRendererView';
7
+ export { PipContainerView } from './components/PipContainerView';
7
8
  // #endregion
8
9
  // #region hooks
9
10
  export { useAudioSettings } from './hooks/useAudioSettings';
@@ -1 +1 @@
1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,CAAC;AAE5B,mBAAmB;AACnB,OAAO,EAAE,uBAAuB,EAAe,MAAM,gBAAgB,CAAC","sourcesContent":["import { initializeWarningListener } from './utils/errorListener';\n\n// #region types\nexport type {\n SimulcastConfig,\n VideoLayout,\n GenericMetadata,\n TrackMetadata,\n Brand,\n RoomType,\n} from './types';\n// #endregion\n\n// #region methods\nexport { updatePeerMetadata } from './common/metadata';\n\n// #region components\nexport type { VideoPreviewViewProps } from './components/VideoPreviewView';\nexport type { VideoRendererProps } from './components/VideoRendererView';\n\nexport { VideoPreviewView } from './components/VideoPreviewView';\nexport { VideoRendererView } from './components/VideoRendererView';\n// #endregion\n\n// #region types for hooks\nexport type {\n Peer,\n PeerId,\n Track,\n TrackId,\n TrackType,\n VadStatus,\n EncodingReason,\n TrackBase,\n AudioTrack,\n VideoTrack,\n UsePeersResult,\n PeerWithTracks,\n PeerTrackMetadata,\n DistinguishedTracks,\n} from './hooks/usePeers';\n\nexport type {\n AudioOutputDevice,\n AudioOutputDeviceType,\n AudioSessionMode,\n} from './hooks/useAudioSettings';\n\nexport type {\n CameraId,\n Camera,\n CameraConfig,\n VideoQuality,\n CameraFacingDirection,\n CameraConfigBase,\n} from './hooks/useCamera';\n\nexport type {\n ScreenShareOptions,\n ScreenShareQuality,\n} from './hooks/useScreenShare';\nexport type { ForegroundServiceConfig } from './hooks/useForegroundService';\nexport type {\n JoinRoomConfig,\n ReconnectionStatus,\n PeerStatus,\n ConnectionConfig,\n} from './hooks/useConnection';\nexport type { AppScreenShareData } from './hooks/useAppScreenShare';\nexport type { UseSandboxProps } from './hooks/useSandbox';\nexport type {\n UseCallKitResult,\n CallKitConfig,\n CallKitAction,\n} from './hooks/useCallKit';\n// #endregion\n\n// #region hooks\nexport { useAudioSettings } from './hooks/useAudioSettings';\nexport { useBandwidthEstimation } from './hooks/useBandwidthEstimation';\nexport { useCamera } from './hooks/useCamera';\nexport { useMicrophone } from './hooks/useMicrophone';\nexport { useScreenShare } from './hooks/useScreenShare';\nexport { useAppScreenShare } from './hooks/useAppScreenShare';\nexport { useReconnection } from './hooks/useReconnection';\nexport { usePeerStatus } from './hooks/usePeerStatus';\nexport { usePeers } from './hooks/usePeers';\nexport { useForegroundService } from './hooks/useForegroundService';\nexport { useConnection } from './hooks/useConnection';\nexport { useUpdatePeerMetadata } from './hooks/useUpdatePeerMetadata';\nexport { useSandbox } from './hooks/useSandbox';\nexport {\n useCallKitService,\n useCallKit,\n useCallKitEvent,\n} from './hooks/useCallKit';\n// #endregion\n\nexport {\n useCameraPermissions,\n useMicrophonePermissions,\n} from './hooks/usePermissions';\n\nexport type { FishjamRoomProps } from './components/FishjamRoom';\nexport { FishjamRoom } from './components/FishjamRoom';\n\ninitializeWarningListener();\n\n// Debug/config API\nexport { setOverwriteDebugConfig, DebugConfig } from './utils/config';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAWlE,aAAa;AAEb,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAUvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAsDjE,aAAa;AAEb,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,aAAa;AAEb,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,yBAAyB,EAAE,CAAC;AAE5B,mBAAmB;AACnB,OAAO,EAAE,uBAAuB,EAAe,MAAM,gBAAgB,CAAC","sourcesContent":["import { initializeWarningListener } from './utils/errorListener';\n\n// #region types\nexport type {\n SimulcastConfig,\n VideoLayout,\n GenericMetadata,\n TrackMetadata,\n Brand,\n RoomType,\n} from './types';\n// #endregion\n\n// #region methods\nexport { updatePeerMetadata } from './common/metadata';\n\n// #region components\nexport type { VideoPreviewViewProps } from './components/VideoPreviewView';\nexport type { VideoRendererProps } from './components/VideoRendererView';\nexport type {\n PipContainerViewRef,\n PipContainerViewProps,\n PictureInPictureConfig,\n} from './components/PipContainerView';\nexport { VideoPreviewView } from './components/VideoPreviewView';\nexport { VideoRendererView } from './components/VideoRendererView';\nexport { PipContainerView } from './components/PipContainerView';\n// #endregion\n\n// #region types for hooks\nexport type {\n Peer,\n PeerId,\n Track,\n TrackId,\n TrackType,\n VadStatus,\n EncodingReason,\n TrackBase,\n AudioTrack,\n VideoTrack,\n UsePeersResult,\n PeerWithTracks,\n PeerTrackMetadata,\n DistinguishedTracks,\n} from './hooks/usePeers';\n\nexport type {\n AudioOutputDevice,\n AudioOutputDeviceType,\n AudioSessionMode,\n} from './hooks/useAudioSettings';\n\nexport type {\n CameraId,\n Camera,\n CameraConfig,\n VideoQuality,\n CameraFacingDirection,\n CameraConfigBase,\n} from './hooks/useCamera';\n\nexport type {\n ScreenShareOptions,\n ScreenShareQuality,\n} from './hooks/useScreenShare';\nexport type { ForegroundServiceConfig } from './hooks/useForegroundService';\nexport type {\n JoinRoomConfig,\n ReconnectionStatus,\n PeerStatus,\n ConnectionConfig,\n} from './hooks/useConnection';\nexport type { AppScreenShareData } from './hooks/useAppScreenShare';\nexport type { UseSandboxProps } from './hooks/useSandbox';\nexport type {\n UseCallKitResult,\n CallKitConfig,\n CallKitAction,\n} from './hooks/useCallKit';\n// #endregion\n\n// #region hooks\nexport { useAudioSettings } from './hooks/useAudioSettings';\nexport { useBandwidthEstimation } from './hooks/useBandwidthEstimation';\nexport { useCamera } from './hooks/useCamera';\nexport { useMicrophone } from './hooks/useMicrophone';\nexport { useScreenShare } from './hooks/useScreenShare';\nexport { useAppScreenShare } from './hooks/useAppScreenShare';\nexport { useReconnection } from './hooks/useReconnection';\nexport { usePeerStatus } from './hooks/usePeerStatus';\nexport { usePeers } from './hooks/usePeers';\nexport { useForegroundService } from './hooks/useForegroundService';\nexport { useConnection } from './hooks/useConnection';\nexport { useUpdatePeerMetadata } from './hooks/useUpdatePeerMetadata';\nexport { useSandbox } from './hooks/useSandbox';\nexport {\n useCallKitService,\n useCallKit,\n useCallKitEvent,\n} from './hooks/useCallKit';\n// #endregion\n\nexport {\n useCameraPermissions,\n useMicrophonePermissions,\n} from './hooks/usePermissions';\n\nexport type { FishjamRoomProps } from './components/FishjamRoom';\nexport { FishjamRoom } from './components/FishjamRoom';\n\ninitializeWarningListener();\n\n// Debug/config API\nexport { setOverwriteDebugConfig, DebugConfig } from './utils/config';\n"]}
@@ -1,5 +1,5 @@
1
1
  import { StyleProp, ViewStyle } from 'react-native';
2
- import { Camera, SenderAudioCodecName, SenderVideoCodecName, VideoParameters, WhipClient } from 'react-native-whip-whep';
2
+ import { WhipClientViewRef } from 'react-native-whip-whep';
3
3
  /**
4
4
  * Props of the LivestreamView component
5
5
  */
@@ -8,37 +8,10 @@ export type LivestreamStreamerProps = {
8
8
  * Styles of the LivestreamView component
9
9
  */
10
10
  style?: StyleProp<ViewStyle>;
11
- /**
12
- * If video track should be enabled.
13
- */
14
- videoEnabled: boolean;
15
- /**
16
- * If audio track should be enabled.
17
- */
18
- audioEnabled: boolean;
19
- /**
20
- * Camera to use for the livestream.
21
- * Use {@link cameras} to get the list of supported cameras.
22
- */
23
- camera?: Camera;
24
- /**
25
- * Set video parameters for the camera
26
- */
27
- videoParameters?: VideoParameters;
28
- /**
29
- * Set the preferred video codecs for sending the video.
30
- * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.
31
- */
32
- preferredVideoCodecs?: SenderVideoCodecName[];
33
- /**
34
- * Set the preferred audio codecs for sending the audio.
35
- * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.
36
- */
37
- preferredAudioCodecs?: SenderAudioCodecName[];
38
11
  /**
39
12
  * Reference to the WhipClient instance. Needs to be passed from the {@link useLivestreamStreamer} hook.
40
13
  */
41
- whipClientRef: React.RefObject<WhipClient | null>;
14
+ ref: React.RefObject<WhipClientViewRef | null>;
42
15
  };
43
16
  /**
44
17
  * Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.
@@ -47,5 +20,5 @@ export type LivestreamStreamerProps = {
47
20
  * @param {object} props
48
21
  * @param {object} props.style
49
22
  */
50
- export declare const LivestreamStreamer: ({ style, whipClientRef, videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }: LivestreamStreamerProps) => import("react").JSX.Element;
23
+ export declare const LivestreamStreamer: ({ style, ref }: LivestreamStreamerProps) => import("react").JSX.Element;
51
24
  //# sourceMappingURL=LivestreamStreamer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LivestreamStreamer.d.ts","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,MAAM,EAEN,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC9C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE9C;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,4HAShC,uBAAuB,gCAgCzB,CAAC"}
1
+ {"version":3,"file":"LivestreamStreamer.d.ts","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAkB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;OAEG;IACH,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,gBAAgB,uBAAuB,gCAEzE,CAAC"}
@@ -1,5 +1,4 @@
1
- import { useEffect, useRef } from 'react';
2
- import { cameras, WhipClient, WhipClientView, } from 'react-native-whip-whep';
1
+ import { WhipClientView } from 'react-native-whip-whep';
3
2
  /**
4
3
  * Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.
5
4
  *
@@ -7,30 +6,7 @@ import { cameras, WhipClient, WhipClientView, } from 'react-native-whip-whep';
7
6
  * @param {object} props
8
7
  * @param {object} props.style
9
8
  */
10
- export const LivestreamStreamer = ({ style, whipClientRef, videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }) => {
11
- const whipClient = useRef(null);
12
- useEffect(() => {
13
- whipClient.current = new WhipClient({
14
- audioEnabled,
15
- videoEnabled,
16
- videoParameters,
17
- videoDeviceId: camera?.id ?? cameras[0].id,
18
- }, preferredVideoCodecs, preferredAudioCodecs);
19
- whipClientRef.current = whipClient.current;
20
- return () => {
21
- whipClient.current?.disconnect();
22
- whipClient.current?.cleanup();
23
- whipClientRef.current = null;
24
- };
25
- }, [
26
- camera,
27
- videoParameters,
28
- videoEnabled,
29
- audioEnabled,
30
- preferredVideoCodecs,
31
- preferredAudioCodecs,
32
- whipClientRef,
33
- ]);
34
- return <WhipClientView style={style}/>;
9
+ export const LivestreamStreamer = ({ style, ref }) => {
10
+ return <WhipClientView style={style} ref={ref}/>;
35
11
  };
36
12
  //# sourceMappingURL=LivestreamStreamer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LivestreamStreamer.js","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAEL,OAAO,EAIP,UAAU,EACV,cAAc,GACf,MAAM,wBAAwB,CAAC;AA4ChC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GACI,EAAE,EAAE;IAC5B,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,IAAI,UAAU,CACjC;YACE,YAAY;YACZ,YAAY;YACZ,eAAe;YACf,aAAa,EAAE,MAAM,EAAE,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;SAC3C,EACD,oBAAoB,EACpB,oBAAoB,CACrB,CAAC;QACF,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAE3C,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;YACjC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YAC9B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,eAAe;QACf,YAAY;QACZ,YAAY;QACZ,oBAAoB;QACpB,oBAAoB;QACpB,aAAa;KACd,CAAC,CAAC;IAEH,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAsB,CAAC,EAAG,CAAC;AAC3D,CAAC,CAAC","sourcesContent":["import { CSSProperties, useEffect, useRef } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport {\n Camera,\n cameras,\n SenderAudioCodecName,\n SenderVideoCodecName,\n VideoParameters,\n WhipClient,\n WhipClientView,\n} from 'react-native-whip-whep';\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamStreamerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n /**\n * If video track should be enabled.\n */\n videoEnabled: boolean;\n /**\n * If audio track should be enabled.\n */\n audioEnabled: boolean;\n /**\n * Camera to use for the livestream.\n * Use {@link cameras} to get the list of supported cameras.\n */\n camera?: Camera;\n /**\n * Set video parameters for the camera\n */\n videoParameters?: VideoParameters;\n /**\n * Set the preferred video codecs for sending the video.\n * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.\n */\n preferredVideoCodecs?: SenderVideoCodecName[];\n /**\n * Set the preferred audio codecs for sending the audio.\n * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.\n */\n preferredAudioCodecs?: SenderAudioCodecName[];\n\n /**\n * Reference to the WhipClient instance. Needs to be passed from the {@link useLivestreamStreamer} hook.\n */\n whipClientRef: React.RefObject<WhipClient | null>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamStreamer = ({\n style,\n whipClientRef,\n videoEnabled,\n audioEnabled,\n camera,\n videoParameters,\n preferredVideoCodecs,\n preferredAudioCodecs,\n}: LivestreamStreamerProps) => {\n const whipClient = useRef<WhipClient | null>(null);\n\n useEffect(() => {\n whipClient.current = new WhipClient(\n {\n audioEnabled,\n videoEnabled,\n videoParameters,\n videoDeviceId: camera?.id ?? cameras[0].id,\n },\n preferredVideoCodecs,\n preferredAudioCodecs,\n );\n whipClientRef.current = whipClient.current;\n\n return () => {\n whipClient.current?.disconnect();\n whipClient.current?.cleanup();\n whipClientRef.current = null;\n };\n }, [\n camera,\n videoParameters,\n videoEnabled,\n audioEnabled,\n preferredVideoCodecs,\n preferredAudioCodecs,\n whipClientRef,\n ]);\n\n return <WhipClientView style={style as CSSProperties} />;\n};\n"]}
1
+ {"version":3,"file":"LivestreamStreamer.js","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamStreamer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAiB3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAA2B,EAAE,EAAE;IAC5E,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAsB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CAAC;AACrE,CAAC,CAAC","sourcesContent":["import { CSSProperties } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { WhipClientView, WhipClientViewRef } from 'react-native-whip-whep';\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamStreamerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n\n /**\n * Reference to the WhipClient instance. Needs to be passed from the {@link useLivestreamStreamer} hook.\n */\n ref: React.RefObject<WhipClientViewRef | null>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamStreamer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamStreamer = ({ style, ref }: LivestreamStreamerProps) => {\n return <WhipClientView style={style as CSSProperties} ref={ref} />;\n};\n"]}
@@ -10,11 +10,6 @@ export type LivestreamViewerProps = {
10
10
  * Styles of the LivestreamView component
11
11
  */
12
12
  style?: StyleProp<ViewStyle>;
13
- /**
14
- * Used to override the orientation of the video (from metadata).
15
- * Defaults to "portrait".
16
- */
17
- orientation?: 'landscape' | 'portrait';
18
13
  /**
19
14
  * A variable deciding whether the Picture-in-Picture is enabled.
20
15
  * Defaults to true.
@@ -38,7 +33,7 @@ export type LivestreamViewerProps = {
38
33
  width: number;
39
34
  height: number;
40
35
  };
41
- ref?: Ref<LivestreamViewerRef>;
36
+ ref: Ref<LivestreamViewerRef>;
42
37
  };
43
38
  /**
44
39
  * Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.
@@ -47,5 +42,5 @@ export type LivestreamViewerProps = {
47
42
  * @param {object} props
48
43
  * @param {object} props.style
49
44
  */
50
- export declare const LivestreamViewer: ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }: LivestreamViewerProps) => import("react").JSX.Element;
45
+ export declare const LivestreamViewer: ({ style, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }: LivestreamViewerProps) => import("react").JSX.Element;
51
46
  //# sourceMappingURL=LivestreamViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LivestreamViewer.d.ts","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAkB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,8EAQ9B,qBAAqB,gCASvB,CAAC"}
1
+ {"version":3,"file":"LivestreamViewer.d.ts","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAkB,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAC/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,iEAO9B,qBAAqB,gCASvB,CAAC"}
@@ -6,5 +6,5 @@ import { WhepClientView } from 'react-native-whip-whep';
6
6
  * @param {object} props
7
7
  * @param {object} props.style
8
8
  */
9
- export const LivestreamViewer = ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }) => (<WhepClientView ref={ref} style={style} pipEnabled={pipEnabled} autoStartPip={autoStartPip} autoStopPip={autoStopPip} pipSize={pipSize}/>);
9
+ export const LivestreamViewer = ({ style, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }) => (<WhepClientView ref={ref} style={style} pipEnabled={pipEnabled} autoStartPip={autoStartPip} autoStopPip={autoStopPip} pipSize={pipSize}/>);
10
10
  //# sourceMappingURL=LivestreamViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LivestreamViewer.js","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AA4C3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,GAAG,GACmB,EAAE,EAAE,CAAC,CAC3B,CAAC,cAAc,CACb,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,KAAsB,CAAC,CAC9B,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,CAAC,EACjB,CACH,CAAC","sourcesContent":["import { CSSProperties, Ref } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { WhepClientView, WhepClientViewRef } from 'react-native-whip-whep';\n\nexport type LivestreamViewerRef = WhepClientViewRef;\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamViewerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Used to override the orientation of the video (from metadata).\n * Defaults to \"portrait\".\n */\n orientation?: 'landscape' | 'portrait';\n /**\n * A variable deciding whether the Picture-in-Picture is enabled.\n * Defaults to true.\n */\n pipEnabled?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be started automatically after the app is backgrounded.\n * Defaults to false.\n */\n autoStartPip?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be stopped automatically on iOS after the app is foregrounded.\n * Always enabled on Android as PiP is not supported in foreground.\n * Defaults to false.\n */\n autoStopPip?: boolean;\n /**\n * A variable deciding the size of the Picture-in-Picture mode.\n */\n pipSize?: {\n width: number;\n height: number;\n };\n\n ref?: Ref<LivestreamViewerRef>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamViewer = ({\n style,\n orientation,\n pipEnabled,\n autoStartPip,\n autoStopPip,\n pipSize,\n ref,\n}: LivestreamViewerProps) => (\n <WhepClientView\n ref={ref}\n style={style as CSSProperties}\n pipEnabled={pipEnabled}\n autoStartPip={autoStartPip}\n autoStopPip={autoStopPip}\n pipSize={pipSize}\n />\n);\n"]}
1
+ {"version":3,"file":"LivestreamViewer.js","sourceRoot":"","sources":["../../../src/livestream/components/LivestreamViewer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAuC3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,KAAK,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,GAAG,GACmB,EAAE,EAAE,CAAC,CAC3B,CAAC,cAAc,CACb,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,KAAsB,CAAC,CAC9B,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,CAAC,EACjB,CACH,CAAC","sourcesContent":["import { CSSProperties, Ref } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { WhepClientView, WhepClientViewRef } from 'react-native-whip-whep';\n\nexport type LivestreamViewerRef = WhepClientViewRef;\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamViewerProps = {\n /**\n * Styles of the LivestreamView component\n */\n style?: StyleProp<ViewStyle>;\n /**\n * A variable deciding whether the Picture-in-Picture is enabled.\n * Defaults to true.\n */\n pipEnabled?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be started automatically after the app is backgrounded.\n * Defaults to false.\n */\n autoStartPip?: boolean;\n /**\n * A variable deciding whether the Picture-in-Picture mode should be stopped automatically on iOS after the app is foregrounded.\n * Always enabled on Android as PiP is not supported in foreground.\n * Defaults to false.\n */\n autoStopPip?: boolean;\n /**\n * A variable deciding the size of the Picture-in-Picture mode.\n */\n pipSize?: {\n width: number;\n height: number;\n };\n\n ref: Ref<LivestreamViewerRef>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestreamViewer} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamViewer = ({\n style,\n pipEnabled,\n autoStartPip,\n autoStopPip,\n pipSize,\n ref,\n}: LivestreamViewerProps) => (\n <WhepClientView\n ref={ref}\n style={style as CSSProperties}\n pipEnabled={pipEnabled}\n autoStartPip={autoStartPip}\n autoStopPip={autoStopPip}\n pipSize={pipSize}\n />\n);\n"]}
@@ -0,0 +1,49 @@
1
+ import { SenderAudioCodecName, SenderVideoCodecName, VideoParameters, WhipClientViewRef } from 'react-native-whip-whep';
2
+ /**
3
+ * @category Livestream
4
+ */
5
+ export interface useLivestreamScreenSharingStreamerResult {
6
+ /**
7
+ * Callback used to start publishing the selected audio and video media streams.
8
+ *
9
+ * @remarks
10
+ * Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.
11
+ */
12
+ connect: (token: string, urlOverride?: string) => Promise<void>;
13
+ /** Callback to stop publishing anything previously published with {@link connect} */
14
+ disconnect: () => Promise<void>;
15
+ /** Utility flag which indicates the current connection status */
16
+ isConnected: boolean;
17
+ /**
18
+ * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.
19
+ */
20
+ whipClientRef: React.RefObject<WhipClientViewRef | null>;
21
+ }
22
+ export type UseLivestreamScreenSharingStreamerParams = {
23
+ /**
24
+ * If audio track should be enabled.
25
+ * Defaults to true.
26
+ */
27
+ audioEnabled?: boolean;
28
+ /**
29
+ * Set video parameters for the screen share stream.
30
+ */
31
+ videoParameters?: VideoParameters;
32
+ /**
33
+ * Set the preferred video codecs for sending the video.
34
+ * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.
35
+ */
36
+ preferredVideoCodecs?: SenderVideoCodecName[];
37
+ /**
38
+ * Set the preferred audio codecs for sending the audio.
39
+ * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.
40
+ */
41
+ preferredAudioCodecs?: SenderAudioCodecName[];
42
+ };
43
+ /**
44
+ * Hook for publishing a screen sharing livestream, which can be then received with {@link useLivestreamViewer}
45
+ * @category Livestream
46
+ * @group Hooks
47
+ */
48
+ export declare const useLivestreamScreenSharingStreamer: ({ audioEnabled, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }?: UseLivestreamScreenSharingStreamerParams) => useLivestreamScreenSharingStreamerResult;
49
+ //# sourceMappingURL=useLivestreamScreenSharingStreamer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLivestreamScreenSharingStreamer.d.ts","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamScreenSharingStreamer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACvD;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,qFAAqF;IACrF,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC9C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,GAAI,iFAKhD,wCAA6C,KAAG,wCAqDlD,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { useCallback, useRef, useEffect } from 'react';
2
+ import { useWhipConnectionState, } from 'react-native-whip-whep';
3
+ import { FISHJAM_WHIP_URL } from '../../consts';
4
+ /**
5
+ * Hook for publishing a screen sharing livestream, which can be then received with {@link useLivestreamViewer}
6
+ * @category Livestream
7
+ * @group Hooks
8
+ */
9
+ export const useLivestreamScreenSharingStreamer = ({ audioEnabled, videoParameters, preferredVideoCodecs, preferredAudioCodecs, } = {}) => {
10
+ const state = useWhipConnectionState();
11
+ const isConnected = state === 'connected';
12
+ const whipClientRef = useRef(null);
13
+ const connect = useCallback(async (token, urlOverride) => {
14
+ const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;
15
+ await whipClientRef.current?.connect({
16
+ authToken: token,
17
+ serverUrl: resolvedUrl,
18
+ });
19
+ }, []);
20
+ const disconnect = useCallback(async () => {
21
+ await whipClientRef.current?.disconnect();
22
+ }, []);
23
+ useEffect(() => {
24
+ try {
25
+ const initializeScreenShare = async () => {
26
+ await whipClientRef.current?.initializeScreenShare({
27
+ audioEnabled: audioEnabled ?? true,
28
+ videoEnabled: true,
29
+ videoParameters: videoParameters,
30
+ preferredVideoCodecs: preferredVideoCodecs,
31
+ preferredAudioCodecs: preferredAudioCodecs,
32
+ });
33
+ };
34
+ initializeScreenShare().catch((error) => {
35
+ console.error('Failed to initialize screen share:', error);
36
+ });
37
+ }
38
+ catch (error) {
39
+ console.error('Failed to initialize screen share:', error);
40
+ }
41
+ const ref = whipClientRef.current;
42
+ return () => {
43
+ ref?.disconnect();
44
+ };
45
+ }, [
46
+ videoParameters,
47
+ audioEnabled,
48
+ preferredVideoCodecs,
49
+ preferredAudioCodecs,
50
+ ]);
51
+ return {
52
+ connect,
53
+ disconnect,
54
+ isConnected,
55
+ whipClientRef,
56
+ };
57
+ };
58
+ //# sourceMappingURL=useLivestreamScreenSharingStreamer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLivestreamScreenSharingStreamer.js","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamScreenSharingStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAKL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AA6ChD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EACjD,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,oBAAoB,MACwB,EAAE,EAA4C,EAAE;IAC5F,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,CAAC;IAE1C,MAAM,aAAa,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;QACxE,MAAM,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC;QAEpD,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;YACnC,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,MAAM,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC;YACH,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE;gBACvC,MAAM,aAAa,CAAC,OAAO,EAAE,qBAAqB,CAAC;oBACjD,YAAY,EAAE,YAAY,IAAI,IAAI;oBAClC,YAAY,EAAE,IAAI;oBAClB,eAAe,EAAE,eAAe;oBAChC,oBAAoB,EAAE,oBAAoB;oBAC1C,oBAAoB,EAAE,oBAAoB;iBAC3C,CAAC,CAAC;YACL,CAAC,CAAC;YACF,qBAAqB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtC,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC;QAClC,OAAO,GAAG,EAAE;YACV,GAAG,EAAE,UAAU,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,eAAe;QACf,YAAY;QACZ,oBAAoB;QACpB,oBAAoB;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,UAAU;QACV,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useRef, useEffect } from 'react';\nimport {\n SenderAudioCodecName,\n SenderVideoCodecName,\n VideoParameters,\n WhipClientViewRef,\n useWhipConnectionState,\n} from 'react-native-whip-whep';\nimport { FISHJAM_WHIP_URL } from '../../consts';\n\n/**\n * @category Livestream\n */\nexport interface useLivestreamScreenSharingStreamerResult {\n /**\n * Callback used to start publishing the selected audio and video media streams.\n *\n * @remarks\n * Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.\n */\n connect: (token: string, urlOverride?: string) => Promise<void>;\n /** Callback to stop publishing anything previously published with {@link connect} */\n disconnect: () => Promise<void>;\n /** Utility flag which indicates the current connection status */\n isConnected: boolean;\n /**\n * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.\n */\n whipClientRef: React.RefObject<WhipClientViewRef | null>;\n}\n\nexport type UseLivestreamScreenSharingStreamerParams = {\n /**\n * If audio track should be enabled.\n * Defaults to true.\n */\n audioEnabled?: boolean;\n /**\n * Set video parameters for the screen share stream.\n */\n videoParameters?: VideoParameters;\n /**\n * Set the preferred video codecs for sending the video.\n * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.\n */\n preferredVideoCodecs?: SenderVideoCodecName[];\n /**\n * Set the preferred audio codecs for sending the audio.\n * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.\n */\n preferredAudioCodecs?: SenderAudioCodecName[];\n};\n\n/**\n * Hook for publishing a screen sharing livestream, which can be then received with {@link useLivestreamViewer}\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamScreenSharingStreamer = ({\n audioEnabled,\n videoParameters,\n preferredVideoCodecs,\n preferredAudioCodecs,\n}: UseLivestreamScreenSharingStreamerParams = {}): useLivestreamScreenSharingStreamerResult => {\n const state = useWhipConnectionState();\n const isConnected = state === 'connected';\n\n const whipClientRef = useRef<WhipClientViewRef | null>(null);\n\n const connect = useCallback(async (token: string, urlOverride?: string) => {\n const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;\n\n await whipClientRef.current?.connect({\n authToken: token,\n serverUrl: resolvedUrl,\n });\n }, []);\n\n const disconnect = useCallback(async () => {\n await whipClientRef.current?.disconnect();\n }, []);\n\n useEffect(() => {\n try {\n const initializeScreenShare = async () => {\n await whipClientRef.current?.initializeScreenShare({\n audioEnabled: audioEnabled ?? true,\n videoEnabled: true,\n videoParameters: videoParameters,\n preferredVideoCodecs: preferredVideoCodecs,\n preferredAudioCodecs: preferredAudioCodecs,\n });\n };\n initializeScreenShare().catch((error) => {\n console.error('Failed to initialize screen share:', error);\n });\n } catch (error) {\n console.error('Failed to initialize screen share:', error);\n }\n const ref = whipClientRef.current;\n return () => {\n ref?.disconnect();\n };\n }, [\n videoParameters,\n audioEnabled,\n preferredVideoCodecs,\n preferredAudioCodecs,\n ]);\n\n return {\n connect,\n disconnect,\n isConnected,\n whipClientRef,\n };\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { WhipClient } from 'react-native-whip-whep';
1
+ import { Camera, SenderAudioCodecName, SenderVideoCodecName, VideoParameters, WhipClientViewRef } from 'react-native-whip-whep';
2
2
  /**
3
3
  * @category Livestream
4
4
  */
@@ -12,17 +12,54 @@ export interface useLivestreamStreamerResult {
12
12
  connect: (token: string, urlOverride?: string) => Promise<void>;
13
13
  /** Callback to stop publishing anything previously published with {@link connect} */
14
14
  disconnect: () => Promise<void>;
15
+ /** Callback to flip camera */
16
+ flipCamera: () => Promise<void>;
17
+ /** Callback to switch camera to the one passed as arguement */
18
+ switchCamera: (deviceId: string) => Promise<void>;
19
+ /** Callback to get the id of camera which is used for streaming */
20
+ currentCameraDeviceId: () => Promise<string | undefined>;
15
21
  /** Utility flag which indicates the current connection status */
16
22
  isConnected: boolean;
17
23
  /**
18
24
  * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.
19
25
  */
20
- whipClientRef: React.RefObject<WhipClient | null>;
26
+ whipClientRef: React.RefObject<WhipClientViewRef | null>;
21
27
  }
28
+ export type UseLivestreamStreamerParams = {
29
+ /**
30
+ * If video track should be enabled.
31
+ * Defaults to true.
32
+ */
33
+ videoEnabled?: boolean;
34
+ /**
35
+ * If audio track should be enabled.
36
+ * Defaults to true.
37
+ */
38
+ audioEnabled?: boolean;
39
+ /**
40
+ * Camera to use for the livestream.
41
+ * Use {@link cameras} to get the list of supported cameras.
42
+ */
43
+ camera?: Camera;
44
+ /**
45
+ * Set video parameters for the camera
46
+ */
47
+ videoParameters?: VideoParameters;
48
+ /**
49
+ * Set the preferred video codecs for sending the video.
50
+ * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.
51
+ */
52
+ preferredVideoCodecs?: SenderVideoCodecName[];
53
+ /**
54
+ * Set the preferred audio codecs for sending the audio.
55
+ * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.
56
+ */
57
+ preferredAudioCodecs?: SenderAudioCodecName[];
58
+ };
22
59
  /**
23
60
  * Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}
24
61
  * @category Livestream
25
62
  * @group Hooks
26
63
  */
27
- export declare const useLivestreamStreamer: () => useLivestreamStreamerResult;
64
+ export declare const useLivestreamStreamer: ({ videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, }?: UseLivestreamStreamerParams) => useLivestreamStreamerResult;
28
65
  //# sourceMappingURL=useLivestreamStreamer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG5E;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,qFAAqF;IACrF,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACnD;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,2BAwBxC,CAAC"}
1
+ {"version":3,"file":"useLivestreamStreamer.d.ts","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAEN,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAGhC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,qFAAqF;IACrF,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,8BAA8B;IAC9B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,+DAA+D;IAC/D,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,oEAAoE;IACpE,qBAAqB,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACzD,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC9C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,uGAOnC,2BAAgC,KAAG,2BAuErC,CAAC"}
@@ -1,12 +1,12 @@
1
- import { useCallback, useRef } from 'react';
2
- import { useWhipConnectionState } from 'react-native-whip-whep';
1
+ import { useCallback, useRef, useEffect } from 'react';
2
+ import { cameras, useWhipConnectionState, } from 'react-native-whip-whep';
3
3
  import { FISHJAM_WHIP_URL } from '../../consts';
4
4
  /**
5
5
  * Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}
6
6
  * @category Livestream
7
7
  * @group Hooks
8
8
  */
9
- export const useLivestreamStreamer = () => {
9
+ export const useLivestreamStreamer = ({ videoEnabled, audioEnabled, camera, videoParameters, preferredVideoCodecs, preferredAudioCodecs, } = {}) => {
10
10
  const state = useWhipConnectionState();
11
11
  const isConnected = state === 'connected';
12
12
  const whipClientRef = useRef(null);
@@ -20,9 +20,50 @@ export const useLivestreamStreamer = () => {
20
20
  const disconnect = useCallback(async () => {
21
21
  await whipClientRef.current?.disconnect();
22
22
  }, []);
23
+ const flipCamera = useCallback(async () => {
24
+ await whipClientRef.current?.flipCamera();
25
+ }, []);
26
+ const switchCamera = useCallback(async (deviceId) => {
27
+ return await whipClientRef.current?.switchCamera(deviceId);
28
+ }, []);
29
+ const currentCameraDeviceId = useCallback(async () => {
30
+ return await whipClientRef.current?.currentCameraDeviceId();
31
+ }, []);
32
+ useEffect(() => {
33
+ try {
34
+ const initializeCamera = async () => {
35
+ await whipClientRef.current?.initializeCamera({
36
+ audioEnabled: audioEnabled ?? true,
37
+ videoEnabled: videoEnabled ?? true,
38
+ videoParameters: videoParameters,
39
+ preferredVideoCodecs: preferredVideoCodecs,
40
+ preferredAudioCodecs: preferredAudioCodecs,
41
+ }, camera?.id ?? cameras[0].id);
42
+ };
43
+ initializeCamera();
44
+ }
45
+ catch {
46
+ console.error('Failed to initialize camera');
47
+ }
48
+ const ref = whipClientRef.current;
49
+ return () => {
50
+ ref?.disconnect();
51
+ };
52
+ }, [
53
+ camera,
54
+ videoParameters,
55
+ videoEnabled,
56
+ audioEnabled,
57
+ preferredVideoCodecs,
58
+ preferredAudioCodecs,
59
+ whipClientRef,
60
+ ]);
23
61
  return {
24
62
  connect,
25
63
  disconnect,
64
+ flipCamera,
65
+ switchCamera,
66
+ currentCameraDeviceId,
26
67
  isConnected,
27
68
  whipClientRef,
28
69
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLivestreamStreamer.js","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAc,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAuBhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAgC,EAAE;IACrE,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,CAAC;IAE1C,MAAM,aAAa,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,KAAa,EAAE,WAAoB,EAAE,EAAE;QACxE,MAAM,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC;QACpD,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;YACnC,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,MAAM,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,OAAO;QACP,UAAU;QACV,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useRef } from 'react';\nimport { useWhipConnectionState, WhipClient } from 'react-native-whip-whep';\nimport { FISHJAM_WHIP_URL } from '../../consts';\n\n/**\n * @category Livestream\n */\nexport interface useLivestreamStreamerResult {\n /**\n * Callback used to start publishing the selected audio and video media streams.\n *\n * @remarks\n * Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.\n */\n connect: (token: string, urlOverride?: string) => Promise<void>;\n /** Callback to stop publishing anything previously published with {@link connect} */\n disconnect: () => Promise<void>;\n /** Utility flag which indicates the current connection status */\n isConnected: boolean;\n /**\n * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.\n */\n whipClientRef: React.RefObject<WhipClient | null>;\n}\n\n/**\n * Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamStreamer = (): useLivestreamStreamerResult => {\n const state = useWhipConnectionState();\n const isConnected = state === 'connected';\n\n const whipClientRef = useRef<WhipClient | null>(null);\n\n const connect = useCallback(async (token: string, urlOverride?: string) => {\n const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;\n await whipClientRef.current?.connect({\n authToken: token,\n serverUrl: resolvedUrl,\n });\n }, []);\n\n const disconnect = useCallback(async () => {\n await whipClientRef.current?.disconnect();\n }, []);\n\n return {\n connect,\n disconnect,\n isConnected,\n whipClientRef,\n };\n};\n"]}
1
+ {"version":3,"file":"useLivestreamStreamer.js","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAEL,OAAO,EAKP,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AA6DhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,oBAAoB,MACW,EAAE,EAA+B,EAAE;IAClE,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,CAAC;IAE1C,MAAM,aAAa,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,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E,CAC5B,CAAC;YACJ,CAAC,CAAC;YACF,gBAAgB,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC;QAClC,OAAO,GAAG,EAAE;YACV,GAAG,EAAE,UAAU,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,eAAe;QACf,YAAY;QACZ,YAAY;QACZ,oBAAoB;QACpB,oBAAoB;QACpB,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,UAAU;QACV,UAAU;QACV,YAAY;QACZ,qBAAqB;QACrB,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useRef, useEffect } from 'react';\nimport {\n Camera,\n cameras,\n SenderAudioCodecName,\n SenderVideoCodecName,\n VideoParameters,\n WhipClientViewRef,\n useWhipConnectionState,\n} from 'react-native-whip-whep';\nimport { FISHJAM_WHIP_URL } from '../../consts';\n\n/**\n * @category Livestream\n */\nexport interface useLivestreamStreamerResult {\n /**\n * Callback used to start publishing the selected audio and video media streams.\n *\n * @remarks\n * Calling {@link connect} multiple times will have the effect of only publishing the **last** specified inputs.\n */\n connect: (token: string, urlOverride?: string) => Promise<void>;\n /** Callback to stop publishing anything previously published with {@link connect} */\n disconnect: () => Promise<void>;\n /** Callback to flip camera */\n flipCamera: () => Promise<void>;\n /** Callback to switch camera to the one passed as arguement */\n switchCamera: (deviceId: string) => Promise<void>;\n /** Callback to get the id of camera which is used for streaming */\n currentCameraDeviceId: () => Promise<string | undefined>;\n /** Utility flag which indicates the current connection status */\n isConnected: boolean;\n /**\n * Reference to the WhipClient instance. Needs to be passed to the {@link LivestreamStreamer} component.\n */\n whipClientRef: React.RefObject<WhipClientViewRef | null>;\n}\n\nexport type UseLivestreamStreamerParams = {\n /**\n * If video track should be enabled.\n * Defaults to true.\n */\n videoEnabled?: boolean;\n /**\n * If audio track should be enabled.\n * Defaults to true.\n */\n audioEnabled?: boolean;\n /**\n * Camera to use for the livestream.\n * Use {@link cameras} to get the list of supported cameras.\n */\n camera?: Camera;\n /**\n * Set video parameters for the camera\n */\n videoParameters?: VideoParameters;\n /**\n * Set the preferred video codecs for sending the video.\n * Use {@link WhipClient.getSupportedVideoCodecs} to get the list of supported video codecs.\n */\n preferredVideoCodecs?: SenderVideoCodecName[];\n /**\n * Set the preferred audio codecs for sending the audio.\n * Use {@link WhipClient.getSupportedAudioCodecs} to get the list of supported audio codecs.\n */\n preferredAudioCodecs?: SenderAudioCodecName[];\n};\n\n/**\n * Hook for publishing a livestream, which can be then received with {@link useLivestreamViewer}\n * @category Livestream\n * @group Hooks\n */\nexport const useLivestreamStreamer = ({\n videoEnabled,\n audioEnabled,\n camera,\n videoParameters,\n preferredVideoCodecs,\n preferredAudioCodecs,\n}: UseLivestreamStreamerParams = {}): useLivestreamStreamerResult => {\n const state = useWhipConnectionState();\n const isConnected = state === 'connected';\n\n const whipClientRef = useRef<WhipClientViewRef | null>(null);\n\n const connect = useCallback(async (token: string, urlOverride?: string) => {\n const resolvedUrl = urlOverride ?? FISHJAM_WHIP_URL;\n await whipClientRef.current?.connect({\n authToken: token,\n serverUrl: resolvedUrl,\n });\n }, []);\n\n const disconnect = useCallback(async () => {\n await whipClientRef.current?.disconnect();\n }, []);\n\n const flipCamera = useCallback(async () => {\n await whipClientRef.current?.flipCamera();\n }, []);\n\n const switchCamera = useCallback(async (deviceId: string) => {\n return await whipClientRef.current?.switchCamera(deviceId);\n }, []);\n\n const currentCameraDeviceId = useCallback(async () => {\n return await whipClientRef.current?.currentCameraDeviceId();\n }, []);\n\n useEffect(() => {\n try {\n const initializeCamera = async () => {\n await whipClientRef.current?.initializeCamera(\n {\n audioEnabled: audioEnabled ?? true,\n videoEnabled: videoEnabled ?? true,\n videoParameters: videoParameters,\n preferredVideoCodecs: preferredVideoCodecs,\n preferredAudioCodecs: preferredAudioCodecs,\n },\n camera?.id ?? cameras[0].id,\n );\n };\n initializeCamera();\n } catch {\n console.error('Failed to initialize camera');\n }\n const ref = whipClientRef.current;\n return () => {\n ref?.disconnect();\n };\n }, [\n camera,\n videoParameters,\n videoEnabled,\n audioEnabled,\n preferredVideoCodecs,\n preferredAudioCodecs,\n whipClientRef,\n ]);\n\n return {\n connect,\n disconnect,\n flipCamera,\n switchCamera,\n currentCameraDeviceId,\n isConnected,\n whipClientRef,\n };\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { WhepClientViewRef } from 'react-native-whip-whep';
1
2
  export type ConnectViewerConfig = {
2
3
  token: string;
3
4
  streamId?: never;
@@ -19,6 +20,12 @@ export interface useLivestreamViewerResult {
19
20
  disconnect: () => Promise<void>;
20
21
  /** Utility flag which indicates the current connection status */
21
22
  isConnected: boolean;
23
+ /** Utility flag which indicates if whep client is connecting */
24
+ isLoading: boolean;
25
+ /**
26
+ * Reference to the WhepClient instance. Needs to be passed to the {@link LivestreamViewer} component.
27
+ */
28
+ whepClientRef: React.RefObject<WhepClientViewRef | null>;
22
29
  }
23
30
  /**
24
31
  * Hook for receiving a published livestream.
@@ -1 +1 @@
1
- {"version":3,"file":"useLivestreamViewer.d.ts","sourceRoot":"","sources":["../../../src/livestream/hooks/useLivestreamViewer.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAC3B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACnC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAOxC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,4EAA4E;IAC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