@fishjam-cloud/react-native-client 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/io/fishjam/reactnative/Errors.kt +1 -2
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +52 -27
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +40 -79
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +4 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +5 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +4 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +2 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +3 -2
- package/android/src/main/java/io/fishjam/reactnative/{FishjamForegroundService.kt → foregroundService/FishjamForegroundService.kt} +7 -2
- package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +147 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +27 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +45 -0
- package/build/RNFishjamClientModule.d.ts +6 -2
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/hooks/useAppScreenShare.d.ts +11 -0
- package/build/hooks/useAppScreenShare.d.ts.map +1 -0
- package/build/hooks/useAppScreenShare.js +54 -0
- package/build/hooks/useAppScreenShare.js.map +1 -0
- package/build/hooks/useFishjamEvent.d.ts +1 -0
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +1 -0
- package/build/hooks/useFishjamEvent.js.map +1 -1
- package/build/hooks/useForegroundService.d.ts +44 -0
- package/build/hooks/useForegroundService.d.ts.map +1 -0
- package/build/hooks/useForegroundService.js +57 -0
- package/build/hooks/useForegroundService.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts +1 -1
- package/build/hooks/useMicrophone.js +1 -1
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/useScreenShare.d.ts +1 -0
- package/build/hooks/useScreenShare.d.ts.map +1 -1
- package/build/hooks/useScreenShare.js +20 -13
- package/build/hooks/useScreenShare.js.map +1 -1
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/types.d.ts +0 -25
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -10
- package/build/types.js.map +1 -1
- package/ios/Events.swift +1 -0
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +144 -57
- package/ios/RNFishjamClientModule.swift +32 -24
- package/ios/VideoPreviewView.swift +6 -10
- package/ios/VideoRendererView.swift +5 -14
- package/package.json +6 -6
- package/plugin/build/withFishjamAndroid.js +1 -1
- package/build/utils/foregroundService.d.ts +0 -32
- package/build/utils/foregroundService.d.ts.map +0 -1
- package/build/utils/foregroundService.js +0 -43
- package/build/utils/foregroundService.js.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package io.fishjam.reactnative.managers
|
|
2
|
+
|
|
3
|
+
interface LocalCameraTrackChangedListener {
|
|
4
|
+
fun onLocalCameraTrackChanged()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class LocalCameraTracksChangedListenersManager {
|
|
8
|
+
private var listeners: MutableList<LocalCameraTrackChangedListener> = mutableListOf()
|
|
9
|
+
|
|
10
|
+
fun add(listener: LocalCameraTrackChangedListener) {
|
|
11
|
+
listeners.add(listener)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fun remove(listener: LocalCameraTrackChangedListener) {
|
|
15
|
+
listeners.remove(listener)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun notifyListeners() {
|
|
19
|
+
for (listener in listeners) listener.onLocalCameraTrackChanged()
|
|
20
|
+
}
|
|
21
|
+
}
|
package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package io.fishjam.reactnative.managers
|
|
2
|
+
|
|
3
|
+
interface LocalTrackSwitchListener {
|
|
4
|
+
suspend fun onLocalTrackWillSwitch()
|
|
5
|
+
|
|
6
|
+
suspend fun onLocalTrackSwitched()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class LocalTracksSwitchListenersManager {
|
|
10
|
+
private val listeners: MutableList<LocalTrackSwitchListener> = mutableListOf()
|
|
11
|
+
|
|
12
|
+
fun add(listener: LocalTrackSwitchListener) {
|
|
13
|
+
listeners.add(listener)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
fun remove(listener: LocalTrackSwitchListener) {
|
|
17
|
+
listeners.remove(listener)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
suspend fun notifyWillSwitch() {
|
|
21
|
+
for (listener in listeners) listener.onLocalTrackWillSwitch()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
suspend fun notifySwitched() {
|
|
25
|
+
for (listener in listeners) listener.onLocalTrackSwitched()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package io.fishjam.reactnative.managers
|
|
2
|
+
|
|
3
|
+
interface TrackUpdateListener {
|
|
4
|
+
fun onTracksUpdate()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class TracksUpdateListenersManager {
|
|
8
|
+
private val listeners: MutableList<TrackUpdateListener> = mutableListOf()
|
|
9
|
+
|
|
10
|
+
fun add(listener: TrackUpdateListener) {
|
|
11
|
+
listeners.add(listener)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fun remove(listener: TrackUpdateListener) {
|
|
15
|
+
listeners.remove(listener)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun notifyListeners() {
|
|
19
|
+
for (listener in listeners) listener.onTracksUpdate()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package io.fishjam.reactnative.utils
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.content.pm.PackageManager
|
|
5
|
+
import expo.modules.interfaces.permissions.Permissions
|
|
6
|
+
import expo.modules.interfaces.permissions.PermissionsStatus
|
|
7
|
+
import expo.modules.kotlin.AppContext
|
|
8
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
9
|
+
import kotlin.coroutines.resume
|
|
10
|
+
import kotlin.coroutines.suspendCoroutine
|
|
11
|
+
|
|
12
|
+
object PermissionUtils {
|
|
13
|
+
fun hasCameraPermission(appContext: AppContext?): Boolean = hasPermission(appContext, Manifest.permission.CAMERA)
|
|
14
|
+
|
|
15
|
+
fun hasMicrophonePermission(appContext: AppContext?): Boolean = hasPermission(appContext, Manifest.permission.RECORD_AUDIO)
|
|
16
|
+
|
|
17
|
+
suspend fun requestCameraPermission(appContext: AppContext?): Boolean = requestAccessIfNeeded(appContext, Manifest.permission.CAMERA)
|
|
18
|
+
|
|
19
|
+
suspend fun requestMicrophonePermission(appContext: AppContext?): Boolean =
|
|
20
|
+
requestAccessIfNeeded(appContext, Manifest.permission.RECORD_AUDIO)
|
|
21
|
+
|
|
22
|
+
private suspend fun requestAccessIfNeeded(
|
|
23
|
+
appContext: AppContext?,
|
|
24
|
+
permission: String
|
|
25
|
+
): Boolean {
|
|
26
|
+
val permissionsManager: Permissions =
|
|
27
|
+
appContext?.permissions
|
|
28
|
+
?: throw Exceptions.PermissionsModuleNotFound()
|
|
29
|
+
|
|
30
|
+
if (hasPermission(appContext, permission)) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return suspendCoroutine { continuation ->
|
|
35
|
+
permissionsManager.askForPermissions({ result ->
|
|
36
|
+
continuation.resume(result[permission]?.status == PermissionsStatus.GRANTED)
|
|
37
|
+
}, permission)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fun hasPermission(
|
|
42
|
+
appContext: AppContext?,
|
|
43
|
+
permission: String
|
|
44
|
+
): Boolean = appContext?.reactContext?.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED
|
|
45
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EventEmitter } from 'expo-modules-core';
|
|
2
2
|
import { NativeModule } from 'react-native';
|
|
3
3
|
import type { RTCStats } from './debug/stats/types';
|
|
4
|
-
import type {
|
|
4
|
+
import type { SimulcastConfig } from './types';
|
|
5
5
|
import type { CameraConfigInternal, Camera } from './hooks/useCamera';
|
|
6
6
|
import type { Peer } from './hooks/usePeers';
|
|
7
7
|
import type { ScreenShareOptionsInternal } from './hooks/useScreenShare';
|
|
8
8
|
import type { ConnectionConfig } from './common/client';
|
|
9
9
|
import { PeerStatus } from './hooks/usePeerStatus';
|
|
10
|
+
import { ForegroundServiceNotificationConfig, ForegroundServicePermissionsConfigInternal } from './hooks/useForegroundService';
|
|
10
11
|
type Metadata = {
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
};
|
|
@@ -14,6 +15,7 @@ type RNFishjamClient = {
|
|
|
14
15
|
isMicrophoneOn: boolean;
|
|
15
16
|
isCameraOn: boolean;
|
|
16
17
|
isScreenShareOn: boolean;
|
|
18
|
+
isAppScreenShareOn: boolean;
|
|
17
19
|
cameras: ReadonlyArray<Camera>;
|
|
18
20
|
peerStatus: PeerStatus;
|
|
19
21
|
joinRoom: (url: string, peerToken: string, peerMetadata: Metadata, config: ConnectionConfig) => Promise<void>;
|
|
@@ -25,6 +27,7 @@ type RNFishjamClient = {
|
|
|
25
27
|
switchCamera: (cameraId: string) => Promise<void>;
|
|
26
28
|
handleScreenSharePermission: () => Promise<'granted' | 'denied'>;
|
|
27
29
|
toggleScreenShare: (screenShareOptions: Partial<ScreenShareOptionsInternal>) => Promise<void>;
|
|
30
|
+
toggleAppScreenShare: (screenShareOptions: Partial<ScreenShareOptionsInternal>) => Promise<void>;
|
|
28
31
|
getPeers: <PeerMetadataType extends Metadata>() => Promise<Peer<PeerMetadataType>[]>;
|
|
29
32
|
updatePeerMetadata: <MetadataType extends Metadata>(metadata: MetadataType) => Promise<void>;
|
|
30
33
|
updateVideoTrackMetadata: <MetadataType extends Metadata>(metadata: MetadataType) => Promise<void>;
|
|
@@ -44,7 +47,8 @@ type RNFishjamClient = {
|
|
|
44
47
|
setVideoTrackBandwidth: (bandwidth: number) => Promise<void>;
|
|
45
48
|
changeWebRTCLoggingSeverity: (severity: string) => Promise<void>;
|
|
46
49
|
getStatistics: () => Promise<RTCStats>;
|
|
47
|
-
|
|
50
|
+
configureForegroundService: (config: ForegroundServiceNotificationConfig) => void;
|
|
51
|
+
startForegroundService: (config: ForegroundServicePermissionsConfigInternal) => Promise<void>;
|
|
48
52
|
stopForegroundService: () => void;
|
|
49
53
|
};
|
|
50
54
|
export declare const nativeModuleEventEmitter: EventEmitter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC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AE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.js","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAyFtE,MAAM,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AAEvE,eAAe,YAA8C,CAAC","sourcesContent":["import { EventEmitter, requireNativeModule } from 'expo-modules-core';\nimport { NativeModule } from 'react-native';\n\nimport type { RTCStats } from './debug/stats/types';\nimport type { SimulcastConfig } from './types';\nimport type { CameraConfigInternal, Camera } from './hooks/useCamera';\nimport type { Peer } from './hooks/usePeers';\nimport type { ScreenShareOptionsInternal } from './hooks/useScreenShare';\nimport type { ConnectionConfig } from './common/client';\nimport { PeerStatus } from './hooks/usePeerStatus';\nimport {\n ForegroundServiceNotificationConfig,\n ForegroundServicePermissionsConfigInternal,\n} from './hooks/useForegroundService';\n\ntype Metadata = { [key: string]: any };\n\ntype RNFishjamClient = {\n isMicrophoneOn: boolean;\n isCameraOn: boolean;\n isScreenShareOn: boolean;\n isAppScreenShareOn: boolean; // only available on ios\n cameras: ReadonlyArray<Camera>;\n peerStatus: PeerStatus;\n joinRoom: (\n url: string,\n peerToken: string,\n peerMetadata: Metadata,\n config: ConnectionConfig,\n ) => Promise<void>;\n leaveRoom: () => Promise<void>;\n startCamera: (config: CameraConfigInternal) => Promise<void>;\n toggleMicrophone: () => Promise<boolean>;\n toggleCamera: () => Promise<boolean>;\n flipCamera: () => Promise<void>;\n switchCamera: (cameraId: string) => Promise<void>;\n handleScreenSharePermission: () => Promise<'granted' | 'denied'>;\n toggleScreenShare: (\n screenShareOptions: Partial<ScreenShareOptionsInternal>,\n ) => Promise<void>;\n toggleAppScreenShare: (\n screenShareOptions: Partial<ScreenShareOptionsInternal>,\n ) => Promise<void>;\n getPeers: <PeerMetadataType extends Metadata>() => Promise<\n Peer<PeerMetadataType>[]\n >;\n updatePeerMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateVideoTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateAudioTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateScreenShareTrackMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n setOutputAudioDevice: (audioDevice: string) => Promise<void>;\n startAudioSwitcher: () => Promise<void>;\n stopAudioSwitcher: () => Promise<void>;\n selectAudioSessionMode: (sessionMode: string) => Promise<void>;\n showAudioRoutePicker: () => Promise<void>;\n toggleScreenShareTrackEncoding: (\n encoding: string,\n ) => Promise<SimulcastConfig>;\n setScreenShareTrackBandwidth: (bandwidth: number) => Promise<void>;\n setScreenShareTrackEncodingBandwidth: (\n encoding: string,\n bandwidth: number,\n ) => Promise<void>;\n setTargetTrackEncoding: (trackId: string, encoding: string) => Promise<void>;\n toggleVideoTrackEncoding: (encoding: string) => Promise<SimulcastConfig>;\n setVideoTrackEncodingBandwidth: (\n encoding: string,\n bandwidth: number,\n ) => Promise<void>;\n setVideoTrackBandwidth: (bandwidth: number) => Promise<void>;\n changeWebRTCLoggingSeverity: (severity: string) => Promise<void>;\n getStatistics: () => Promise<RTCStats>;\n configureForegroundService: (\n config: ForegroundServiceNotificationConfig,\n ) => void;\n startForegroundService: (\n config: ForegroundServicePermissionsConfigInternal,\n ) => Promise<void>;\n stopForegroundService: () => void;\n};\n\nconst nativeModule = requireNativeModule('RNFishjamClient');\nexport const nativeModuleEventEmitter = new EventEmitter(nativeModule);\n\nexport default nativeModule as RNFishjamClient & NativeModule;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SimulcastConfig } from '../types';
|
|
2
|
+
import { ScreenShareOptions } from './useScreenShare';
|
|
3
|
+
type AppScreenShareData = {
|
|
4
|
+
isAppScreenShareOn: boolean;
|
|
5
|
+
simulcastConfig: SimulcastConfig;
|
|
6
|
+
toggleAppScreenShare: (screenShareOptions?: Partial<ScreenShareOptions>) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
declare function useDefaultAppScreenShareAndroid(): AppScreenShareData;
|
|
9
|
+
export declare const useAppScreenShare: typeof useDefaultAppScreenShareAndroid;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=useAppScreenShare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useAppScreenShare.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAUtD,KAAK,kBAAkB,GAAG;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,oBAAoB,EAAE,CACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC;AA+CF,iBAAS,+BAA+B,IAAI,kBAAkB,CAM7D;AAED,eAAO,MAAM,iBAAiB,wCAG5B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
3
|
+
import { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
const defaultSimulcastConfig = () => ({
|
|
6
|
+
enabled: false,
|
|
7
|
+
activeEncodings: [],
|
|
8
|
+
});
|
|
9
|
+
let screenShareSimulcastConfig = defaultSimulcastConfig();
|
|
10
|
+
/**
|
|
11
|
+
* This hook can toggle client app screen sharing on/off and provides current screen share state. It works only on iOS.
|
|
12
|
+
* @returns An object with functions to manage app screen share on iOS and null on android.
|
|
13
|
+
* @category Screenshare
|
|
14
|
+
* @group Hooks
|
|
15
|
+
*/
|
|
16
|
+
function useIosAppScreenShare() {
|
|
17
|
+
const [isAppScreenShareOn, setIsAppScreenShareOn] = useState(RNFishjamClientModule.isAppScreenShareOn);
|
|
18
|
+
const [simulcastConfig, setSimulcastConfig] = useState(screenShareSimulcastConfig);
|
|
19
|
+
useFishjamEvent(ReceivableEvents.IsAppScreenShareOn, setIsAppScreenShareOn);
|
|
20
|
+
const toggleAppScreenShare = useCallback(async (screenShareOptions = {}) => {
|
|
21
|
+
const options = {
|
|
22
|
+
...screenShareOptions,
|
|
23
|
+
screenShareMetadata: {
|
|
24
|
+
displayName: 'presenting',
|
|
25
|
+
type: 'screensharing',
|
|
26
|
+
active: !isAppScreenShareOn,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
await RNFishjamClientModule.toggleAppScreenShare(options);
|
|
30
|
+
screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
|
|
31
|
+
setSimulcastConfig(screenShareSimulcastConfig);
|
|
32
|
+
}, [isAppScreenShareOn]);
|
|
33
|
+
return {
|
|
34
|
+
isAppScreenShareOn,
|
|
35
|
+
simulcastConfig,
|
|
36
|
+
/**
|
|
37
|
+
* Toggles the screen share on/off.
|
|
38
|
+
* Emits warning on ios when user is screensharing full screen.
|
|
39
|
+
*/
|
|
40
|
+
toggleAppScreenShare,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function useDefaultAppScreenShareAndroid() {
|
|
44
|
+
return {
|
|
45
|
+
isAppScreenShareOn: false,
|
|
46
|
+
simulcastConfig: defaultSimulcastConfig(),
|
|
47
|
+
toggleAppScreenShare: async () => { },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const useAppScreenShare = Platform.select({
|
|
51
|
+
ios: useIosAppScreenShare,
|
|
52
|
+
default: useDefaultAppScreenShareAndroid,
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=useAppScreenShare.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -2,6 +2,7 @@ export declare const ReceivableEvents: {
|
|
|
2
2
|
readonly IsCameraOn: "IsCameraOn";
|
|
3
3
|
readonly IsMicrophoneOn: "IsMicrophoneOn";
|
|
4
4
|
readonly IsScreenShareOn: "IsScreenShareOn";
|
|
5
|
+
readonly IsAppScreenShareOn: "IsAppScreenShareOn";
|
|
5
6
|
readonly SimulcastConfigUpdate: "SimulcastConfigUpdate";
|
|
6
7
|
readonly PeersUpdate: "PeersUpdate";
|
|
7
8
|
readonly AudioDeviceUpdate: "AudioDeviceUpdate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFishjamEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"useFishjamEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAenB,CAAC;AAEX,wBAAgB,eAAe,CAAC,CAAC,EAC/B,SAAS,EAAE,MAAM,OAAO,gBAAgB,EACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,QAU7B"}
|
|
@@ -4,6 +4,7 @@ export const ReceivableEvents = {
|
|
|
4
4
|
IsCameraOn: 'IsCameraOn',
|
|
5
5
|
IsMicrophoneOn: 'IsMicrophoneOn',
|
|
6
6
|
IsScreenShareOn: 'IsScreenShareOn',
|
|
7
|
+
IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS
|
|
7
8
|
SimulcastConfigUpdate: 'SimulcastConfigUpdate',
|
|
8
9
|
PeersUpdate: 'PeersUpdate',
|
|
9
10
|
AudioDeviceUpdate: 'AudioDeviceUpdate',
|
|
@@ -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,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 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,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"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type ForegroundServicePermissionsConfigInternal = {
|
|
2
|
+
enableCamera?: boolean;
|
|
3
|
+
enableMicrophone?: boolean;
|
|
4
|
+
enableScreenSharing?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A type representing the options required for configuring the foreground service notifcation.
|
|
8
|
+
*
|
|
9
|
+
* @param channelId The id of the channel. Must be unique per package.
|
|
10
|
+
* @param channelName The user visible name of the channel.
|
|
11
|
+
* @param notificationTitle The title (first row) of the notification, in a standard notification.
|
|
12
|
+
* @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
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export type ForegroundServicePermissionsConfig = Pick<ForegroundServicePermissionsConfigInternal, 'enableCamera' | 'enableMicrophone'>;
|
|
28
|
+
/**
|
|
29
|
+
* useForegroundService
|
|
30
|
+
*
|
|
31
|
+
* A hook for managing a foreground service on Android. Does nothing on other platforms.
|
|
32
|
+
* You can use this hook to keep your app running in the background. You're also required to run a foreground service when screen sharing.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} config - Configuration options for the foreground service.
|
|
35
|
+
* @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.
|
|
36
|
+
* @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.
|
|
37
|
+
* @param {Object} config.channelId - The id of the channel. Must be unique per package.
|
|
38
|
+
* @param {Object} config.channelName - The user visible name of the channel.
|
|
39
|
+
* @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.
|
|
40
|
+
* @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export declare const useForegroundService: ({ enableCamera, enableMicrophone, ...restOptions }: ForegroundServiceNotificationConfig & ForegroundServicePermissionsConfig) => void;
|
|
44
|
+
//# sourceMappingURL=useForegroundService.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
3
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
4
|
+
const requestNotificationsPermission = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);
|
|
7
|
+
if (result !== PermissionsAndroid.RESULTS.GRANTED) {
|
|
8
|
+
console.warn("Notifications permission not granted. User won't be able to see a the app is in background.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.warn(err);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const useForegroundServiceAndroid = ({ enableCamera, enableMicrophone, ...restOptions }) => {
|
|
16
|
+
const [isConfigured, setIsConfigured] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!isConfigured) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
RNFishjamClientModule.startForegroundService({
|
|
22
|
+
enableCamera,
|
|
23
|
+
enableMicrophone,
|
|
24
|
+
});
|
|
25
|
+
}, [enableCamera, enableMicrophone, isConfigured]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const runConfiguration = async () => {
|
|
28
|
+
await requestNotificationsPermission();
|
|
29
|
+
RNFishjamClientModule.configureForegroundService(restOptions);
|
|
30
|
+
setIsConfigured(true);
|
|
31
|
+
};
|
|
32
|
+
runConfiguration();
|
|
33
|
+
return () => RNFishjamClientModule.stopForegroundService();
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, []);
|
|
36
|
+
};
|
|
37
|
+
const emptyFunction = () => { };
|
|
38
|
+
/**
|
|
39
|
+
* useForegroundService
|
|
40
|
+
*
|
|
41
|
+
* A hook for managing a foreground service on Android. Does nothing on other platforms.
|
|
42
|
+
* 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.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} config - Configuration options for the foreground service.
|
|
45
|
+
* @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.
|
|
46
|
+
* @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.
|
|
47
|
+
* @param {Object} config.channelId - The id of the channel. Must be unique per package.
|
|
48
|
+
* @param {Object} config.channelName - The user visible name of the channel.
|
|
49
|
+
* @param {Object} config.notificationTitle - The title (first row) of the notification, in a standard notification.
|
|
50
|
+
* @param {Object} config.notificationContent - The text (second row) of the notification, in a standard notification.
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
export const useForegroundService = Platform.select({
|
|
54
|
+
android: useForegroundServiceAndroid,
|
|
55
|
+
default: emptyFunction,
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=useForegroundService.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @group Hooks
|
|
5
5
|
*/
|
|
6
6
|
export declare function useMicrophone(): {
|
|
7
|
-
/** Informs if
|
|
7
|
+
/** Informs if microphone is streaming audio */
|
|
8
8
|
isMicrophoneOn: boolean;
|
|
9
9
|
/** Function to toggle microphone on/off */
|
|
10
10
|
toggleMicrophone: () => Promise<void>;
|
|
@@ -18,7 +18,7 @@ export function useMicrophone() {
|
|
|
18
18
|
setIsMicrophoneOn(status);
|
|
19
19
|
}, []);
|
|
20
20
|
return {
|
|
21
|
-
/** Informs if
|
|
21
|
+
/** Informs if microphone is streaming audio */
|
|
22
22
|
isMicrophoneOn,
|
|
23
23
|
/** Function to toggle microphone on/off */
|
|
24
24
|
toggleMicrophone,
|
|
@@ -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
|
|
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"]}
|
|
@@ -33,6 +33,7 @@ export declare function useScreenShare(): {
|
|
|
33
33
|
simulcastConfig: SimulcastConfig;
|
|
34
34
|
/**
|
|
35
35
|
* Toggles the screen share on/off
|
|
36
|
+
* Emits warning on ios when user is screensharing app screen.
|
|
36
37
|
*/
|
|
37
38
|
toggleScreenShare: (screenShareOptions?: Partial<ScreenShareOptions>) => Promise<void>;
|
|
38
39
|
handleScreenSharePermission: () => Promise<"granted" | "denied">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,mBAAmB,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG;IACvC,mBAAmB,EAAE,aAAa,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AASF;;;;;GAKG;AACH,wBAAgB,cAAc;;;
|
|
1
|
+
{"version":3,"file":"useScreenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;OAEG;IACH,YAAY,EAAE,mBAAmB,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG;IACvC,mBAAmB,EAAE,aAAa,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AASF;;;;;GAKG;AACH,wBAAgB,cAAc;;;IAuE1B;;;OAGG;6CA7BwB,OAAO,CAAC,kBAAkB,CAAC;;IAiCtD;;OAEG;8CAjDe,cAAc;IAmDhC;;;;OAIG;+CA1Ec,aAAa;IA4E9B;;;;;OAKG;qDAxEc,aAAa,aAAa,cAAc;EAmF5D"}
|
|
@@ -17,19 +17,6 @@ export function useScreenShare() {
|
|
|
17
17
|
const [isScreenShareOn, setIsScreenShareOn] = useState(RNFishjamClientModule.isScreenShareOn);
|
|
18
18
|
const [simulcastConfig, setSimulcastConfig] = useState(screenShareSimulcastConfig);
|
|
19
19
|
useFishjamEvent(ReceivableEvents.IsScreenShareOn, setIsScreenShareOn);
|
|
20
|
-
const toggleScreenShare = useCallback(async (screenShareOptions = {}) => {
|
|
21
|
-
const options = {
|
|
22
|
-
...screenShareOptions,
|
|
23
|
-
screenShareMetadata: {
|
|
24
|
-
displayName: 'presenting',
|
|
25
|
-
type: 'screensharing',
|
|
26
|
-
active: !isScreenShareOn,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
await RNFishjamClientModule.toggleScreenShare(options);
|
|
30
|
-
screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
|
|
31
|
-
setSimulcastConfig(screenShareSimulcastConfig);
|
|
32
|
-
}, [isScreenShareOn]);
|
|
33
20
|
const toggleScreenShareTrackEncoding = useCallback(async (encoding) => {
|
|
34
21
|
screenShareSimulcastConfig =
|
|
35
22
|
await RNFishjamClientModule.toggleScreenShareTrackEncoding(encoding);
|
|
@@ -47,11 +34,31 @@ export function useScreenShare() {
|
|
|
47
34
|
}
|
|
48
35
|
return 'denied';
|
|
49
36
|
}, []);
|
|
37
|
+
const toggleScreenShare = useCallback(async (screenShareOptions = {}) => {
|
|
38
|
+
if (Platform.OS === 'android' && !isScreenShareOn) {
|
|
39
|
+
(await handleScreenSharePermission()) == 'granted' &&
|
|
40
|
+
(await RNFishjamClientModule.startForegroundService({
|
|
41
|
+
enableScreenSharing: true,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
const options = {
|
|
45
|
+
...screenShareOptions,
|
|
46
|
+
screenShareMetadata: {
|
|
47
|
+
displayName: 'presenting',
|
|
48
|
+
type: 'screensharing',
|
|
49
|
+
active: !isScreenShareOn,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
await RNFishjamClientModule.toggleScreenShare(options);
|
|
53
|
+
screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
|
|
54
|
+
setSimulcastConfig(screenShareSimulcastConfig);
|
|
55
|
+
}, [isScreenShareOn, handleScreenSharePermission]);
|
|
50
56
|
return {
|
|
51
57
|
isScreenShareOn,
|
|
52
58
|
simulcastConfig,
|
|
53
59
|
/**
|
|
54
60
|
* Toggles the screen share on/off
|
|
61
|
+
* Emits warning on ios when user is screensharing app screen.
|
|
55
62
|
*/
|
|
56
63
|
toggleScreenShare,
|
|
57
64
|
handleScreenSharePermission,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenShare.js","sourceRoot":"","sources":["../../src/hooks/useScreenShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAS9C,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAyBtE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,EAAE,KAAK;IACd,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,IAAI,0BAA0B,GAAoB,sBAAsB,EAA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C,kCAAkC;QACzF,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IACjD,CAAC,EACD,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;IAEF,OAAO;QACL,eAAe;QACf,eAAe;QAEf;;;WAGG;QACH,iBAAiB;QACjB,2BAA2B;QAE3B;;WAEG;QACH,4BAA4B;QAC5B;;;;WAIG;QACH,8BAA8B;QAC9B;;;;;WAKG;QACH,oCAAoC;QACpC;;;;;;;WAOG;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\n\nimport {\n BandwidthLimit,\n SimulcastConfig,\n TrackBandwidthLimit,\n TrackEncoding,\n TrackMetadata,\n} from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { Platform } from 'react-native';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\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 /**\n * bandwidth limit of a screen share track. By default there is no bandwidth limit.\n */\n maxBandwidth: TrackBandwidthLimit;\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 enabled: false,\n activeEncodings: [],\n});\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 Screenshare\n * @group Hooks\n */\nexport function useScreenShare() {\n const [isScreenShareOn, setIsScreenShareOn] = useState(\n RNFishjamClientModule.isScreenShareOn,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n screenShareSimulcastConfig,\n );\n\n useFishjamEvent(ReceivableEvents.IsScreenShareOn, setIsScreenShareOn);\n\n const toggleScreenShareTrackEncoding = useCallback(\n async (encoding: TrackEncoding) => {\n screenShareSimulcastConfig =\n await RNFishjamClientModule.toggleScreenShareTrackEncoding(encoding);\n setSimulcastConfig(screenShareSimulcastConfig);\n },\n [],\n );\n\n const setScreenShareTrackEncodingBandwidth = useCallback(\n async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setScreenShareTrackEncodingBandwidth(\n encoding,\n bandwidth,\n );\n },\n [],\n );\n\n const setScreenShareTrackBandwidth = useCallback(\n async (bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setScreenShareTrackBandwidth(bandwidth);\n },\n [],\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 (await handleScreenSharePermission()) == 'granted' &&\n (await RNFishjamClientModule.startForegroundService({\n enableScreenSharing: true,\n }));\n }\n const options = {\n ...screenShareOptions,\n screenShareMetadata: {\n displayName: 'presenting',\n type: 'screensharing' as const,\n active: !isScreenShareOn,\n },\n };\n await RNFishjamClientModule.toggleScreenShare(options);\n screenShareSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings\n setSimulcastConfig(screenShareSimulcastConfig);\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 * @deprecated\n */\n setScreenShareTrackBandwidth,\n /**\n * Toggles simulcast encoding of a screen share track on/off\n * @param encoding encoding to toggle\n * @deprecated\n */\n toggleScreenShareTrackEncoding,\n /**\n * updates maximum bandwidth for the given simulcast encoding of the screen share track\n * @param encoding encoding to update\n * @param bandwidth BandwidthLimit to set\n * @deprecated\n */\n setScreenShareTrackEncodingBandwidth,\n /**\n * updates maximum bandwidth for the screen share 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 bandwidth BandwidthLimit to set\n * @deprecated\n */\n };\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Peer, Track, TrackType, VadStatus, EncodingReason, } from './hooks/usePeers';
|
|
1
|
+
export type { Peer, Track, TrackType, VadStatus, EncodingReason, AudioTrack, VideoTrack, } from './hooks/usePeers';
|
|
2
2
|
export { usePeers } from './hooks/usePeers';
|
|
3
3
|
export type { AudioOutputDevice, AudioOutputDeviceType, AudioSessionMode, } from './hooks/useAudioSettings';
|
|
4
4
|
export { useAudioSettings } from './hooks/useAudioSettings';
|
|
@@ -8,6 +8,7 @@ export { useCamera } from './hooks/useCamera';
|
|
|
8
8
|
export { useMicrophone } from './hooks/useMicrophone';
|
|
9
9
|
export type { ScreenShareOptions, ScreenShareQuality, } from './hooks/useScreenShare';
|
|
10
10
|
export { useScreenShare } from './hooks/useScreenShare';
|
|
11
|
+
export { useAppScreenShare } from './hooks/useAppScreenShare';
|
|
11
12
|
export type { ReconnectionStatus } from './hooks/useReconnection';
|
|
12
13
|
export { useReconnection } from './hooks/useReconnection';
|
|
13
14
|
export { updatePeerMetadata } from './common/metadata';
|
|
@@ -18,9 +19,9 @@ export type { VideoPreviewViewProps } from './components/VideoPreviewView';
|
|
|
18
19
|
export { VideoPreviewView } from './components/VideoPreviewView';
|
|
19
20
|
export type { VideoRendererProps } from './components/VideoRendererView';
|
|
20
21
|
export { VideoRendererView } from './components/VideoRendererView';
|
|
21
|
-
export { AndroidForegroundServiceType } from './types';
|
|
22
|
-
export { startForegroundService, stopForegroundService, } from './utils/foregroundService';
|
|
23
22
|
export type { PeerStatus } from './hooks/usePeerStatus';
|
|
24
23
|
export { usePeerStatus } from './hooks/usePeerStatus';
|
|
24
|
+
export type { ForegroundServiceNotificationConfig, ForegroundServicePermissionsConfig, } from './hooks/useForegroundService';
|
|
25
|
+
export { useForegroundService } from './hooks/useForegroundService';
|
|
25
26
|
export type { TrackBandwidthLimit, TrackEncoding, SimulcastBandwidthLimit, BandwidthLimit, SimulcastConfig, VideoLayout, } from './types';
|
|
26
27
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,YAAY,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,SAAS,EACT,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,YAAY,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,SAAS,EACT,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,YAAY,EACV,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACn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