@fishjam-cloud/react-native-client 0.18.1 → 0.19.1
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 +1 -1
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +25 -15
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +52 -0
- package/build/RNFishjamClientModule.d.ts +6 -1
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/components/FishjamRoom/index.d.ts +6 -0
- package/build/components/FishjamRoom/index.d.ts.map +1 -1
- package/build/components/FishjamRoom/index.js +6 -0
- package/build/components/FishjamRoom/index.js.map +1 -1
- package/build/components/LivestreamView.d.ts +33 -1
- package/build/components/LivestreamView.d.ts.map +1 -1
- package/build/components/LivestreamView.js +1 -1
- package/build/components/LivestreamView.js.map +1 -1
- package/build/components/VideoPreviewView.d.ts +1 -1
- package/build/components/VideoPreviewView.js +1 -0
- package/build/components/VideoPreviewView.js.map +1 -1
- package/build/components/VideoRendererView.d.ts +2 -2
- package/build/components/VideoRendererView.js +3 -2
- package/build/components/VideoRendererView.js.map +1 -1
- package/build/consts/index.d.ts +3 -0
- package/build/consts/index.d.ts.map +1 -0
- package/build/consts/index.js +4 -0
- package/build/consts/index.js.map +1 -0
- package/build/debug/stats/useRTCStatistics.js.map +1 -1
- package/build/hooks/useCamera.d.ts +5 -5
- package/build/hooks/useCamera.js.map +1 -1
- package/build/hooks/useConnection.d.ts +18 -7
- package/build/hooks/useConnection.d.ts.map +1 -1
- package/build/hooks/useConnection.js +10 -2
- package/build/hooks/useConnection.js.map +1 -1
- package/build/hooks/useMicrophone.d.ts +6 -2
- package/build/hooks/useMicrophone.d.ts.map +1 -1
- package/build/hooks/useMicrophone.js +12 -2
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/usePeers.js.map +1 -1
- package/build/hooks/usePermissions.d.ts +24 -0
- package/build/hooks/usePermissions.d.ts.map +1 -0
- package/build/hooks/usePermissions.js +61 -0
- package/build/hooks/usePermissions.js.map +1 -0
- package/build/hooks/useSandbox.d.ts +13 -0
- package/build/hooks/useSandbox.d.ts.map +1 -0
- package/build/hooks/useSandbox.js +42 -0
- package/build/hooks/useSandbox.js.map +1 -0
- package/build/hooks/useScreenShare.d.ts +1 -1
- package/build/hooks/useScreenShare.js.map +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/types.d.ts +1 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/ios/CameraPermissionsRequester.swift +117 -0
- package/ios/RNFishjamClient.swift +31 -20
- package/ios/RNFishjamClientModule.swift +176 -119
- package/package.json +16 -11
- package/plugin/build/types.d.ts +5 -0
- package/plugin/build/withFishjamAndroid.js +16 -4
- package/plugin/build/withFishjamIos.d.ts +1 -1
- package/plugin/build/withFishjamIos.js +106 -48
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ There is also [API documentation](https://docs.fishjam.io/category/api) availabl
|
|
|
16
16
|
|
|
17
17
|
# Examples
|
|
18
18
|
|
|
19
|
-
There is simple example app, that allows you to test our service. To run it locally, follow [instructions](https://github.com/fishjam-cloud/mobile-client-sdk/tree/main/examples/
|
|
19
|
+
There is simple example app, that allows you to test our service. To run it locally, follow [instructions](https://github.com/fishjam-cloud/mobile-client-sdk/tree/main/examples/minimal-react-native).
|
|
20
20
|
|
|
21
21
|
## License
|
|
22
22
|
|
|
@@ -392,15 +392,26 @@ class RNFishjamClient(
|
|
|
392
392
|
localTracksSwitchListenerManager.notifySwitched()
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
395
|
+
suspend fun startMicrophone() {
|
|
396
|
+
// If microphone track already exist, just enable it
|
|
397
|
+
if (getLocalAudioTrack() != null) {
|
|
398
|
+
getLocalAudioTrack()?.let { setMicrophoneTrackState(it, true) }
|
|
399
|
+
} else {
|
|
400
|
+
if (!PermissionUtils.requestMicrophonePermission(appContext)) {
|
|
401
|
+
emitEvent(EmitableEvent.warning("Microphone permission not granted."))
|
|
402
|
+
return
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
val microphoneTrack = fishjamClient.createAudioTrack(getMicrophoneTrackMetadata(true))
|
|
406
|
+
setMicrophoneTrackState(microphoneTrack, true)
|
|
407
|
+
emitEndpoints()
|
|
399
408
|
}
|
|
409
|
+
}
|
|
400
410
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
411
|
+
fun stopMicrophone() {
|
|
412
|
+
if (getLocalAudioTrack() != null) {
|
|
413
|
+
getLocalAudioTrack()?.let { setMicrophoneTrackState(it, false) }
|
|
414
|
+
}
|
|
404
415
|
}
|
|
405
416
|
|
|
406
417
|
private fun setMicrophoneTrackState(
|
|
@@ -409,25 +420,24 @@ class RNFishjamClient(
|
|
|
409
420
|
) {
|
|
410
421
|
microphoneTrack.setEnabled(isEnabled)
|
|
411
422
|
isMicrophoneOn = isEnabled
|
|
423
|
+
updateLocalAudioTrackMetadata(getMicrophoneTrackMetadata(isEnabled))
|
|
412
424
|
emitEvent(EmitableEvent.isMicrophoneOn(isEnabled))
|
|
413
425
|
}
|
|
414
426
|
|
|
415
427
|
suspend fun toggleMicrophone(): Boolean {
|
|
416
|
-
if (
|
|
417
|
-
|
|
428
|
+
if (isMicrophoneOn) {
|
|
429
|
+
stopMicrophone()
|
|
418
430
|
} else {
|
|
419
|
-
|
|
431
|
+
startMicrophone()
|
|
420
432
|
}
|
|
421
433
|
|
|
422
|
-
updateLocalAudioTrackMetadata(getMicrophoneTrackMetadata())
|
|
423
|
-
|
|
424
434
|
return isMicrophoneOn
|
|
425
435
|
}
|
|
426
436
|
|
|
427
|
-
private fun getMicrophoneTrackMetadata(): Map<String, Any> =
|
|
437
|
+
private fun getMicrophoneTrackMetadata(isEnabled: Boolean): Map<String, Any> =
|
|
428
438
|
mapOf(
|
|
429
|
-
"active" to
|
|
430
|
-
"paused" to !
|
|
439
|
+
"active" to isEnabled,
|
|
440
|
+
"paused" to !isEnabled, // TODO: FCE-711,
|
|
431
441
|
"type" to "microphone"
|
|
432
442
|
)
|
|
433
443
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
package io.fishjam.reactnative
|
|
2
2
|
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import expo.modules.interfaces.permissions.Permissions
|
|
3
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
4
7
|
import expo.modules.kotlin.functions.Coroutine
|
|
5
8
|
import expo.modules.kotlin.modules.Module
|
|
6
9
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
@@ -179,6 +182,18 @@ class RNFishjamClientModule : Module() {
|
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
184
|
|
|
185
|
+
AsyncFunction("startMicrophone") Coroutine { ->
|
|
186
|
+
withContext(Dispatchers.Main) {
|
|
187
|
+
rnFishjamClient.startMicrophone()
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
AsyncFunction("stopMicrophone") Coroutine { ->
|
|
192
|
+
withContext(Dispatchers.Main) {
|
|
193
|
+
rnFishjamClient.stopMicrophone()
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
182
197
|
AsyncFunction("toggleCamera") Coroutine { ->
|
|
183
198
|
withContext(Dispatchers.Main) {
|
|
184
199
|
rnFishjamClient.toggleCamera()
|
|
@@ -302,5 +317,42 @@ class RNFishjamClientModule : Module() {
|
|
|
302
317
|
Function("stopForegroundService") {
|
|
303
318
|
rnFishjamClient.stopForegroundService()
|
|
304
319
|
}
|
|
320
|
+
|
|
321
|
+
AsyncFunction("requestCameraPermissionsAsync") { promise: Promise ->
|
|
322
|
+
Permissions.askForPermissionsWithPermissionsManager(
|
|
323
|
+
permissionsManager,
|
|
324
|
+
promise,
|
|
325
|
+
Manifest.permission.CAMERA
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
AsyncFunction("requestMicrophonePermissionsAsync") { promise: Promise ->
|
|
330
|
+
Permissions.askForPermissionsWithPermissionsManager(
|
|
331
|
+
permissionsManager,
|
|
332
|
+
promise,
|
|
333
|
+
Manifest.permission.RECORD_AUDIO
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
AsyncFunction("getCameraPermissionsAsync") { promise: Promise ->
|
|
338
|
+
Permissions.getPermissionsWithPermissionsManager(
|
|
339
|
+
permissionsManager,
|
|
340
|
+
promise,
|
|
341
|
+
Manifest.permission.CAMERA
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
AsyncFunction("getMicrophonePermissionsAsync") { promise: Promise ->
|
|
346
|
+
Permissions.getPermissionsWithPermissionsManager(
|
|
347
|
+
permissionsManager,
|
|
348
|
+
promise,
|
|
349
|
+
Manifest.permission.RECORD_AUDIO
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
305
354
|
}
|
|
355
|
+
|
|
356
|
+
private val permissionsManager: Permissions
|
|
357
|
+
get() = appContext.permissions ?: throw Exceptions.PermissionsModuleNotFound()
|
|
306
358
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PermissionResponse } from 'expo-modules-core';
|
|
1
2
|
import type { NativeModule } from 'expo-modules-core/types';
|
|
2
3
|
import type { ConnectionConfig } from './common/client';
|
|
3
4
|
import type { RTCStats } from './debug/stats/types';
|
|
@@ -16,7 +17,7 @@ type RNFishjamClient = {
|
|
|
16
17
|
isCameraOn: boolean;
|
|
17
18
|
isScreenShareOn: boolean;
|
|
18
19
|
isAppScreenShareOn: boolean;
|
|
19
|
-
cameras:
|
|
20
|
+
cameras: readonly Camera[];
|
|
20
21
|
currentCamera: Camera | null;
|
|
21
22
|
peerStatus: PeerStatus;
|
|
22
23
|
reconnectionStatus: ReconnectionStatus;
|
|
@@ -51,6 +52,10 @@ type RNFishjamClient = {
|
|
|
51
52
|
getStatistics: () => Promise<RTCStats>;
|
|
52
53
|
startForegroundService: (config: ForegroundServiceConfig) => Promise<void>;
|
|
53
54
|
stopForegroundService: () => void;
|
|
55
|
+
getCameraPermissionsAsync: () => Promise<PermissionResponse>;
|
|
56
|
+
requestCameraPermissionsAsync: () => Promise<PermissionResponse>;
|
|
57
|
+
getMicrophonePermissionsAsync: () => Promise<PermissionResponse>;
|
|
58
|
+
requestMicrophonePermissionsAsync: () => Promise<PermissionResponse>;
|
|
54
59
|
};
|
|
55
60
|
export declare const ReceivableEvents: {
|
|
56
61
|
readonly IsMicrophoneOn: "IsMicrophoneOn";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EACV,MAAM,EACN,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC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ACrC,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACzD,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,EAAE,IAAI,CAAC;IACzD,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC;IAC7C,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IACrC,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IACnC,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;IACjD,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,EAAE,kBAAkB,CAAC;IACjE,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;IAClE,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,EAAE;QAC1C,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,CAAC;CACH,CAAC;wBAEuD,eAAe,GACtE,YAAY,CACV,MAAM,CACJ,MAAM,OAAO,gBAAgB,EAC7B,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAC3C,CACF;AANH,wBAMI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.js","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.js","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA6F5E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB,EAAE,eAAe;IACzD,qBAAqB,EAAE,uBAAuB;IAC9C,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,+BAA+B,EAAE,iCAAiC;IAClE,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,iBAAiB,EAAE,mBAAmB;IACtC,yBAAyB,EAAE,2BAA2B;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,uBAAuB,EAAE,yBAAyB;CAC1C,CAAC;AAuBX,eAAe,mBAAmB,CAAC,iBAAiB,CAMjD,CAAC","sourcesContent":["import { PermissionResponse, requireNativeModule } from 'expo-modules-core';\n\nimport type { NativeModule } from 'expo-modules-core/types';\nimport type { ConnectionConfig } from './common/client';\nimport type { RTCStats } from './debug/stats/types';\nimport type { OnAudioDeviceEvent } from './hooks/useAudioSettings';\nimport type {\n Camera,\n CameraConfigInternal,\n CurrentCameraChangedType,\n} from './hooks/useCamera';\nimport type { PeerStatus, ReconnectionStatus } from './hooks/useConnection';\nimport type { ForegroundServiceConfig } from './hooks/useForegroundService';\nimport type { Peer } from './hooks/usePeers';\nimport type { ScreenShareOptionsInternal } from './hooks/useScreenShare';\nimport type { GenericMetadata, SimulcastConfig } from './types';\n\ntype Metadata = { [key: string]: unknown };\n\ntype RNFishjamClient = {\n isMicrophoneOn: boolean;\n isCameraOn: boolean;\n isScreenShareOn: boolean;\n isAppScreenShareOn: boolean; // only available on ios\n cameras: readonly Camera[];\n currentCamera: Camera | null;\n peerStatus: PeerStatus;\n reconnectionStatus: ReconnectionStatus;\n isCameraInitialized: boolean;\n\n getPeers: <\n PeerMetadataType extends Metadata,\n ServerMetadata extends Metadata = GenericMetadata,\n >() => Peer<PeerMetadataType, ServerMetadata>[];\n\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<boolean>;\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 updatePeerMetadata: <MetadataType extends Metadata>(\n metadata: MetadataType,\n ) => Promise<void>;\n updateVideoTrackMetadata: <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 startForegroundService: (config: ForegroundServiceConfig) => Promise<void>;\n stopForegroundService: () => void;\n getCameraPermissionsAsync: () => Promise<PermissionResponse>;\n requestCameraPermissionsAsync: () => Promise<PermissionResponse>;\n getMicrophonePermissionsAsync: () => Promise<PermissionResponse>;\n requestMicrophonePermissionsAsync: () => Promise<PermissionResponse>;\n};\n\nexport const ReceivableEvents = {\n IsMicrophoneOn: 'IsMicrophoneOn',\n IsScreenShareOn: 'IsScreenShareOn',\n IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS\n SimulcastConfigUpdate: 'SimulcastConfigUpdate',\n PeersUpdate: 'PeersUpdate',\n AudioDeviceUpdate: 'AudioDeviceUpdate',\n BandwidthEstimation: 'BandwidthEstimation',\n ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',\n ReconnectionStarted: 'ReconnectionStarted',\n Reconnected: 'Reconnected',\n Warning: 'Warning',\n PeerStatusChanged: 'PeerStatusChanged',\n ReconnectionStatusChanged: 'ReconnectionStatusChanged',\n CurrentCameraChanged: 'CurrentCameraChanged',\n TrackAspectRatioUpdated: 'TrackAspectRatioUpdated',\n} as const;\n\nexport type ReceivableEventPayloads = {\n [ReceivableEvents.IsMicrophoneOn]: boolean;\n [ReceivableEvents.IsScreenShareOn]: boolean;\n [ReceivableEvents.IsAppScreenShareOn]: boolean;\n [ReceivableEvents.SimulcastConfigUpdate]: SimulcastConfig;\n [ReceivableEvents.PeersUpdate]: void;\n [ReceivableEvents.AudioDeviceUpdate]: OnAudioDeviceEvent;\n [ReceivableEvents.BandwidthEstimation]: number | null;\n [ReceivableEvents.ReconnectionRetriesLimitReached]: void;\n [ReceivableEvents.ReconnectionStarted]: void;\n [ReceivableEvents.Reconnected]: void;\n [ReceivableEvents.Warning]: string;\n [ReceivableEvents.PeerStatusChanged]: PeerStatus;\n [ReceivableEvents.ReconnectionStatusChanged]: ReconnectionStatus;\n [ReceivableEvents.CurrentCameraChanged]: CurrentCameraChangedType;\n [ReceivableEvents.TrackAspectRatioUpdated]: {\n trackId: string;\n aspectRatio: number | null;\n };\n};\n\nexport default requireNativeModule('RNFishjamClient') as RNFishjamClient &\n NativeModule<\n Record<\n keyof typeof ReceivableEvents,\n (payload: ReceivableEventPayloads) => void\n >\n >;\n"]}
|
|
@@ -13,6 +13,12 @@ export type FishjamRoomProps = {
|
|
|
13
13
|
*
|
|
14
14
|
* Example usage:
|
|
15
15
|
* ```tsx
|
|
16
|
+
* import { FishjamRoom } from '@fishjam-cloud/react-native-client';
|
|
17
|
+
* import React from 'react';
|
|
18
|
+
*
|
|
19
|
+
* const FISHJAM_URL = 'https://fishjam.io/your_fishjam';
|
|
20
|
+
* const PEER_TOKEN = 'your-peer-token';
|
|
21
|
+
*
|
|
16
22
|
* <FishjamRoom
|
|
17
23
|
* fishjamUrl={FISHJAM_URL}
|
|
18
24
|
* peerToken={PEER_TOKEN}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,GAAI,2BAA2B,gBAAgB,gCA8BtE,CAAC"}
|
|
@@ -8,6 +8,12 @@ import { SafeAreaView } from 'react-native';
|
|
|
8
8
|
*
|
|
9
9
|
* Example usage:
|
|
10
10
|
* ```tsx
|
|
11
|
+
* import { FishjamRoom } from '@fishjam-cloud/react-native-client';
|
|
12
|
+
* import React from 'react';
|
|
13
|
+
*
|
|
14
|
+
* const FISHJAM_URL = 'https://fishjam.io/your_fishjam';
|
|
15
|
+
* const PEER_TOKEN = 'your-peer-token';
|
|
16
|
+
*
|
|
11
17
|
* <FishjamRoom
|
|
12
18
|
* fishjamUrl={FISHJAM_URL}
|
|
13
19
|
* peerToken={PEER_TOKEN}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAa5C
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FishjamRoom/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAa5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,UAAU,EAAE,SAAS,EAAoB,EAAE,EAAE;IACzE,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,CAAC;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC;gBACH,MAAM,aAAa,CAAC;oBAClB,gBAAgB,EAAE,IAAI;oBACtB,OAAO,EAAE,OAAO;oBAChB,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAC;gBACH,MAAM,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE;oBACpC,IAAI,EAAE,EAAE;oBACR,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;QACP,OAAO,GAAG,EAAE;YACV,SAAS,EAAE,CAAC;QACd,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE3C,OAAO,CACL,CAAC,YAAY,CACX;MAAA,CAAC,UAAU,CAAC,AAAD,EACb;IAAA,EAAE,YAAY,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { joinRoom, leaveRoom } from '../../common/client';\nimport { useCamera } from '../../hooks/useCamera';\nimport { VideosGrid } from './VideosGrid';\nimport { SafeAreaView } from 'react-native';\n\nexport type FishjamRoomProps = {\n /**\n * URL to your fishjam instance\n */\n fishjamUrl: string;\n /**\n * Peer Token\n */\n peerToken: string;\n};\n\n/**\n * Simple component that enables your camera and show all tracks\n *\n * Example usage:\n * ```tsx\n * import { FishjamRoom } from '@fishjam-cloud/react-native-client';\n * import React from 'react';\n *\n * const FISHJAM_URL = 'https://fishjam.io/your_fishjam';\n * const PEER_TOKEN = 'your-peer-token';\n *\n * <FishjamRoom\n * fishjamUrl={FISHJAM_URL}\n * peerToken={PEER_TOKEN}\n * />\n * ```\n * @category Components\n * @param {object} props\n * @param {string} props.fishjamUrl\n * @param {string} props.peerToken\n */\nexport const FishjamRoom = ({ fishjamUrl, peerToken }: FishjamRoomProps) => {\n const { prepareCamera } = useCamera();\n\n useEffect(() => {\n const join = async () => {\n try {\n await prepareCamera({\n simulcastEnabled: true,\n quality: 'HD169',\n cameraEnabled: true,\n });\n await joinRoom(fishjamUrl, peerToken, {\n peer: {},\n server: {},\n });\n } catch (e) {\n console.warn(e);\n }\n };\n join();\n return () => {\n leaveRoom();\n };\n }, [fishjamUrl, peerToken, prepareCamera]);\n\n return (\n <SafeAreaView>\n <VideosGrid />\n </SafeAreaView>\n );\n};\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
1
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { WhepClientViewRef } from 'react-native-whip-whep';
|
|
4
|
+
export type LivestreamViewRef = WhepClientViewRef;
|
|
2
5
|
/**
|
|
3
6
|
* Props of the LivestreamView component
|
|
4
7
|
*/
|
|
@@ -7,6 +10,35 @@ export type LivestreamViewProps = {
|
|
|
7
10
|
* Styles of the LivestreamView component
|
|
8
11
|
*/
|
|
9
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
|
+
/**
|
|
19
|
+
* A variable deciding whether the Picture-in-Picture is enabled.
|
|
20
|
+
* Defaults to true.
|
|
21
|
+
*/
|
|
22
|
+
pipEnabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A variable deciding whether the Picture-in-Picture mode should be started automatically after the app is backgrounded.
|
|
25
|
+
* Defaults to false.
|
|
26
|
+
*/
|
|
27
|
+
autoStartPip?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A variable deciding whether the Picture-in-Picture mode should be stopped automatically on iOS after the app is foregrounded.
|
|
30
|
+
* Always enabled on Android as PiP is not supported in foreground.
|
|
31
|
+
* Defaults to false.
|
|
32
|
+
*/
|
|
33
|
+
autoStopPip?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* A variable deciding the size of the Picture-in-Picture mode.
|
|
36
|
+
*/
|
|
37
|
+
pipSize?: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
ref?: Ref<LivestreamViewRef>;
|
|
10
42
|
};
|
|
11
43
|
/**
|
|
12
44
|
* Renders a video player playing the livestream set up with {@link useLivestream} hook.
|
|
@@ -15,5 +47,5 @@ export type LivestreamViewProps = {
|
|
|
15
47
|
* @param {object} props
|
|
16
48
|
* @param {object} props.style
|
|
17
49
|
*/
|
|
18
|
-
export declare const LivestreamView: ({ style }: LivestreamViewProps) => import("react").JSX.Element;
|
|
50
|
+
export declare const LivestreamView: ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }: LivestreamViewProps) => import("react").JSX.Element;
|
|
19
51
|
//# sourceMappingURL=LivestreamView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamView.d.ts","sourceRoot":"","sources":["../../src/components/LivestreamView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LivestreamView.d.ts","sourceRoot":"","sources":["../../src/components/LivestreamView.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,iBAAiB,GAAG,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;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,iBAAiB,CAAC,CAAC;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,8EAQ5B,mBAAmB,gCAUrB,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 LivestreamView = ({ style }) => (<WhepClientView style={style}/>);
|
|
9
|
+
export const LivestreamView = ({ style, orientation, pipEnabled, autoStartPip, autoStopPip, pipSize, ref, }) => (<WhepClientView ref={ref} style={style} orientation={orientation} pipEnabled={pipEnabled} autoStartPip={autoStartPip} autoStopPip={autoStopPip} pipSize={pipSize}/>);
|
|
10
10
|
//# sourceMappingURL=LivestreamView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivestreamView.js","sourceRoot":"","sources":["../../src/components/LivestreamView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"LivestreamView.js","sourceRoot":"","sources":["../../src/components/LivestreamView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AA4C3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,GAAG,GACiB,EAAE,EAAE,CAAC,CACzB,CAAC,cAAc,CACb,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,KAAsB,CAAC,CAC9B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,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 LivestreamViewRef = WhepClientViewRef;\n\n/**\n * Props of the LivestreamView component\n */\nexport type LivestreamViewProps = {\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<LivestreamViewRef>;\n};\n\n/**\n * Renders a video player playing the livestream set up with {@link useLivestream} hook.\n *\n * @category Components\n * @param {object} props\n * @param {object} props.style\n */\nexport const LivestreamView = ({\n style,\n orientation,\n pipEnabled,\n autoStartPip,\n autoStopPip,\n pipSize,\n ref,\n}: LivestreamViewProps) => (\n <WhepClientView\n ref={ref}\n style={style as CSSProperties}\n orientation={orientation}\n pipEnabled={pipEnabled}\n autoStartPip={autoStartPip}\n autoStopPip={autoStopPip}\n pipSize={pipSize}\n />\n);\n"]}
|
|
@@ -11,7 +11,7 @@ export type VideoPreviewViewProps = {
|
|
|
11
11
|
style?: StyleProp<ViewStyle>;
|
|
12
12
|
/**
|
|
13
13
|
* Id of the camera used for preview. Get available cameras with `cameras` property.
|
|
14
|
-
* @default the first front camera
|
|
14
|
+
* @default `the first front camera`
|
|
15
15
|
*/
|
|
16
16
|
cameraId?: CameraId;
|
|
17
17
|
};
|
|
@@ -13,4 +13,5 @@ const NativeView = requireNativeViewManager('VideoPreviewViewModule');
|
|
|
13
13
|
export const VideoPreviewView = React.forwardRef((props, ref) => (
|
|
14
14
|
// @ts-expect-error ref prop needs to be updated
|
|
15
15
|
<NativeView {...props} captureDeviceId={props.cameraId} ref={ref}/>));
|
|
16
|
+
VideoPreviewView.displayName = 'VideoPreviewView';
|
|
16
17
|
//# sourceMappingURL=VideoPreviewView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAG9C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACrE,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport { CameraId } from '../hooks/useCamera';\n\nexport type VideoPreviewViewProps = {\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n\n style?: StyleProp<ViewStyle>;\n /**\n * Id of the camera used for preview. Get available cameras with `cameras` property.\n * @default the first front camera
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.js","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAG9C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACrE,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport { CameraId } from '../hooks/useCamera';\n\nexport type VideoPreviewViewProps = {\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n\n style?: StyleProp<ViewStyle>;\n /**\n * Id of the camera used for preview. Get available cameras with `cameras` property.\n * @default `the first front camera`\n */\n cameraId?: CameraId;\n};\n\nconst NativeView: React.ComponentType<VideoPreviewViewProps> =\n requireNativeViewManager('VideoPreviewViewModule');\n\n/**\n * Render camera preview.\n * Allows to display camera preview before streaming is started\n *\n *\n * @category Components\n * @param {object} props\n * @param {string} props.cameraId\n */\nexport const VideoPreviewView = React.forwardRef<\n React.ComponentType<VideoPreviewViewProps>,\n VideoPreviewViewProps\n>((props, ref) => (\n // @ts-expect-error ref prop needs to be updated\n <NativeView {...props} captureDeviceId={props.cameraId} ref={ref} />\n));\n\nVideoPreviewView.displayName = 'VideoPreviewView';\n"]}
|
|
@@ -22,9 +22,9 @@ export type VideoRendererProps = {
|
|
|
22
22
|
* Render video track received from {@link usePeers} hook
|
|
23
23
|
*
|
|
24
24
|
* Example usage:
|
|
25
|
-
* ```
|
|
25
|
+
* ```js
|
|
26
26
|
* <VideoRendererView
|
|
27
|
-
* trackId={peer.
|
|
27
|
+
* trackId={peer.cameraTrack?.id}
|
|
28
28
|
* videoLayout="FIT"
|
|
29
29
|
* style={styles.videoContent}
|
|
30
30
|
* />
|
|
@@ -5,9 +5,9 @@ const NativeView = requireNativeViewManager('VideoRendererViewModule');
|
|
|
5
5
|
* Render video track received from {@link usePeers} hook
|
|
6
6
|
*
|
|
7
7
|
* Example usage:
|
|
8
|
-
* ```
|
|
8
|
+
* ```js
|
|
9
9
|
* <VideoRendererView
|
|
10
|
-
* trackId={peer.
|
|
10
|
+
* trackId={peer.cameraTrack?.id}
|
|
11
11
|
* videoLayout="FIT"
|
|
12
12
|
* style={styles.videoContent}
|
|
13
13
|
* />
|
|
@@ -21,4 +21,5 @@ const NativeView = requireNativeViewManager('VideoRendererViewModule');
|
|
|
21
21
|
export const VideoRendererView = React.forwardRef((props, ref) => (
|
|
22
22
|
// @ts-expect-error ref prop needs to be updated
|
|
23
23
|
<NativeView {...props} ref={ref}/>));
|
|
24
|
+
VideoRendererView.displayName = 'VideoRendererView';
|
|
24
25
|
//# sourceMappingURL=VideoRendererView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoRendererView.js","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAG/C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACpC,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle, StyleProp } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport type { TrackId } from '../hooks/usePeers';\n\nexport type VideoRendererProps = {\n /**\n * id of the video track which you want to render.\n */\n trackId: TrackId;\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n /**\n * Whether the video should be rendered if it's off screen or hidden.\n */\n skipRenderOutsideVisibleArea?: boolean;\n style?: StyleProp<ViewStyle>;\n};\n\nconst NativeView: React.ComponentType<VideoRendererProps> =\n requireNativeViewManager('VideoRendererViewModule');\n\n/**\n * Render video track received from {@link usePeers} hook\n *\n * Example usage:\n * ```
|
|
1
|
+
{"version":3,"file":"VideoRendererView.js","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAG/C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACpC,CAAC,CAAC;AAEH,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle, StyleProp } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport type { TrackId } from '../hooks/usePeers';\n\nexport type VideoRendererProps = {\n /**\n * id of the video track which you want to render.\n */\n trackId: TrackId;\n /**\n * Video layout inside of the component\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n /**\n * Whether the video should be rendered if it's off screen or hidden.\n */\n skipRenderOutsideVisibleArea?: boolean;\n style?: StyleProp<ViewStyle>;\n};\n\nconst NativeView: React.ComponentType<VideoRendererProps> =\n requireNativeViewManager('VideoRendererViewModule');\n\n/**\n * Render video track received from {@link usePeers} hook\n *\n * Example usage:\n * ```js\n * <VideoRendererView\n * trackId={peer.cameraTrack?.id}\n * videoLayout=\"FIT\"\n * style={styles.videoContent}\n * />\n * ```\n *\n * @category Components\n *\n * @param {Object} props\n * @param props.trackId\n */\nexport const VideoRendererView = React.forwardRef<\n React.ComponentType<VideoRendererProps>,\n VideoRendererProps\n>((props, ref) => (\n // @ts-expect-error ref prop needs to be updated\n <NativeView {...props} ref={ref} />\n));\n\nVideoRendererView.displayName = 'VideoRendererView';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,sCAAoC,CAAC;AAC1E,eAAO,MAAM,sBAAsB,oCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consts/index.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAEzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,oBAAoB,EAAE,CAAC;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,oBAAoB,EAAE,CAAC","sourcesContent":["const FISHJAM_CONNECT_PATH = 'fishjam.io/api/v1/connect';\n\nexport const FISHJAM_HTTP_CONNECT_URL = `https://${FISHJAM_CONNECT_PATH}`;\nexport const FISHJAM_WS_CONNECT_URL = `wss://${FISHJAM_CONNECT_PATH}`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRTCStatistics.js","sourceRoot":"","sources":["../../../src/debug/stats/useRTCStatistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,qBAAqB,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,eAAuB;IACtD,MAAM,QAAQ,GAAG,GAAG,CAAC;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;IAE7D,sDAAsD;IACtD,gDAAgD;IAChD,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAC,
|
|
1
|
+
{"version":3,"file":"useRTCStatistics.js","sourceRoot":"","sources":["../../../src/debug/stats/useRTCStatistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,qBAAqB,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,eAAuB;IACtD,MAAM,QAAQ,GAAG,GAAG,CAAC;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;IAE7D,sDAAsD;IACtD,gDAAgD;IAChD,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAC,KAA0B,EAAE,IAAwB,EAAE,EAAE;QACvD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,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ACL,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC/D,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,UAAU,CAAC,CAAC;YAC1B,aAAa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;IAErC,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import { takeRight } from 'lodash';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { RTCInboundStats, RTCOutboundStats, RTCStats } from './types';\nimport RNFishjamClientModule from '../../RNFishjamClientModule';\n\n/**\n * This hook provides access to current rtc statistics data.\n * @category Debugging\n */\nexport function useRTCStatistics(refreshInterval: number) {\n const MAX_SIZE = 120;\n const [statistics, setStatistics] = useState<RTCStats[]>([]);\n\n // Calculates diff between pervious and current stats,\n // providing end users with a per second metric.\n const processIncomingStats = useCallback(\n (stats: readonly RTCStats[], stat: Readonly<RTCStats>) => {\n Object.keys(stat).forEach((obj) => {\n if (obj.includes('Inbound')) {\n const rtcStats = stat[obj] as RTCInboundStats;\n\n if (\n stats.length > 0 &&\n Object.keys(stats[stats.length - 1]).includes(obj)\n ) {\n const prevRtcStats = stats[stats.length - 1][\n obj\n ] as RTCInboundStats;\n\n rtcStats['packetsLost/s'] =\n rtcStats['packetsLost'] - prevRtcStats['packetsLost'];\n rtcStats['packetsReceived/s'] =\n rtcStats['packetsReceived'] - prevRtcStats['packetsReceived'];\n rtcStats['bytesReceived/s'] =\n rtcStats['bytesReceived'] - prevRtcStats['bytesReceived'];\n rtcStats['framesReceived/s'] =\n rtcStats['framesReceived'] - prevRtcStats['framesReceived'];\n rtcStats['framesDropped/s'] =\n rtcStats['framesDropped'] - prevRtcStats['framesDropped'];\n } else {\n rtcStats['packetsLost/s'] = 0;\n rtcStats['packetsReceived/s'] = 0;\n rtcStats['bytesReceived/s'] = 0;\n rtcStats['framesReceived/s'] = 0;\n rtcStats['framesDropped/s'] = 0;\n }\n return stat;\n }\n // Outbound\n const rtcStats = stat[obj] as RTCOutboundStats;\n\n if (\n stats.length > 0 &&\n Object.keys(stats[stats.length - 1]).includes(obj)\n ) {\n const prevRtcStats = stats[stats.length - 1][obj] as RTCOutboundStats;\n\n rtcStats['bytesSent/s'] =\n rtcStats['bytesSent'] - prevRtcStats['bytesSent'];\n rtcStats['packetsSent/s'] =\n rtcStats['packetsSent'] - prevRtcStats['packetsSent'];\n rtcStats['framesEncoded/s'] =\n rtcStats['framesEncoded'] - prevRtcStats['framesEncoded'];\n } else {\n rtcStats['bytesSent/s'] = 0;\n rtcStats['packetsSent/s'] = 0;\n rtcStats['framesEncoded/s'] = 0;\n }\n return stat;\n });\n return stat;\n },\n [],\n );\n\n // Gets stats from the native libraries.\n const getStatistics = useCallback(async () => {\n const stats = await RNFishjamClientModule.getStatistics();\n setStatistics((prev) => {\n const newStats = [...prev, processIncomingStats(prev, stats)];\n takeRight(newStats, MAX_SIZE);\n return newStats;\n });\n }, [processIncomingStats]);\n\n useEffect(() => {\n const intervalId = setInterval(getStatistics, refreshInterval);\n return () => {\n clearInterval(intervalId);\n setStatistics([]);\n };\n }, [getStatistics, refreshInterval]);\n\n return { statistics };\n}\n"]}
|
|
@@ -27,12 +27,12 @@ export type CameraConfigBase = {
|
|
|
27
27
|
* To record horizontal video your phone orientation must be in landscape and your app must support this orientation.
|
|
28
28
|
*
|
|
29
29
|
* Platform specific capture formats:
|
|
30
|
-
* @see iOS
|
|
31
|
-
* @see Android
|
|
30
|
+
* @see [iOS](https://developer.apple.com/documentation/avfoundation/avcapturedevice/format)
|
|
31
|
+
* @see [Android](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50)
|
|
32
32
|
*
|
|
33
33
|
* WebRTC device orientation handling:
|
|
34
|
-
* @see iOS
|
|
35
|
-
* @see Android
|
|
34
|
+
* @see [iOS](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285)
|
|
35
|
+
* @see [Android](https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347)
|
|
36
36
|
*
|
|
37
37
|
* @default `true`
|
|
38
38
|
*/
|
|
@@ -45,7 +45,7 @@ export type CameraConfigBase = {
|
|
|
45
45
|
/**
|
|
46
46
|
* id of the camera to start capture with. Get available cameras with `cameras`.
|
|
47
47
|
* You can switch the cameras later with `switchCamera` functions.
|
|
48
|
-
* @default the first front camera
|
|
48
|
+
* @default `the first front camera`
|
|
49
49
|
*/
|
|
50
50
|
cameraId?: CameraId;
|
|
51
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAsFvE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAClC,CAAC;IACC,OAAO,EAAE,KAAK;CACf,CAA2B,CAAC;AAE/B,SAAS,kBAAkB,CACzB,gBAAqC;IAErC,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,MAA8B;IAE9B,OAAO;QACL,GAAG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AC;IAEF,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC1C,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,YAAY,EAAE,CAAC;QACzD,MAAM,qBAAqB,CAAC,wBAAwB,CAAC;YACnD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,QAAkB,EAAE,EAAE;QAC5D,MAAM,qBAAqB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;WAEG;QACH,UAAU;QACV;;WAEG;QACH,aAAa;QACb;;WAEG;QACH,eAAe;QACf;;;WAGG;QACH,OAAO;QACP;;WAEG;QACH,aAAa,EAAE,mBAAmB;QAClC;;WAEG;QACH,YAAY;QACZ;;;;WAIG;QACH,aAAa;QACb;;;;WAIG;QACH,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { Brand, SimulcastConfig } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type CameraId = Brand<string, 'CameraId'>;\n\nexport type CameraFacingDirection = 'front' | 'back' | 'unspecified';\n\nexport type Camera = {\n id: CameraId;\n name: string;\n facingDirection: CameraFacingDirection;\n};\n\nexport type CurrentCameraChangedType = {\n currentCamera: Camera | null;\n isCameraOn: boolean;\n isCameraInitialized: boolean;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\nexport type CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether to flip the dimensions of the video, that is whether to film in vertical orientation.\n * This basically switches width with height and is only used to select closes capture format.\n *\n * To record horizontal video your phone orientation must be in landscape and your app must support this orientation.\n *\n * Platform specific capture formats:\n * @see iOS
|
|
1
|
+
{"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAsFvE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAClC,CAAC;IACC,OAAO,EAAE,KAAK;CACf,CAA2B,CAAC;AAE/B,SAAS,kBAAkB,CACzB,gBAAqC;IAErC,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,MAA8B;IAE9B,OAAO;QACL,GAAG,MAAM;QACT,kBAAkB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpD,eAAe,EAAE,kBAAkB,CAAC,MAAM,CAAC,gBAAgB,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,eAAe,GAAG,oBAAoB,CAC1C,gBAAgB,CAAC,qBAAqB,EACtC,sBAAsB,EAAE,CACzB,CAAC;IAEF,MAAM,EACJ,aAAa,EAAE,kBAAkB,EACjC,UAAU,EACV,mBAAmB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Y,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;WAEG;QACH,UAAU;QACV;;WAEG;QACH,aAAa;QACb;;WAEG;QACH,eAAe;QACf;;;WAGG;QACH,OAAO;QACP;;WAEG;QACH,aAAa,EAAE,mBAAmB;QAClC;;WAEG;QACH,YAAY;QACZ;;;;WAIG;QACH,aAAa;QACb;;;;WAIG;QACH,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { Brand, SimulcastConfig } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type CameraId = Brand<string, 'CameraId'>;\n\nexport type CameraFacingDirection = 'front' | 'back' | 'unspecified';\n\nexport type Camera = {\n id: CameraId;\n name: string;\n facingDirection: CameraFacingDirection;\n};\n\nexport type CurrentCameraChangedType = {\n currentCamera: Camera | null;\n isCameraOn: boolean;\n isCameraInitialized: boolean;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\nexport type CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether to flip the dimensions of the video, that is whether to film in vertical orientation.\n * This basically switches width with height and is only used to select closes capture format.\n *\n * To record horizontal video your phone orientation must be in landscape and your app must support this orientation.\n *\n * Platform specific capture formats:\n * @see [iOS](https://developer.apple.com/documentation/avfoundation/avcapturedevice/format)\n * @see [Android](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50)\n *\n * WebRTC device orientation handling:\n * @see [iOS](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285)\n * @see [Android](https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347)\n *\n * @default `true`\n */\n flipDimensions?: boolean;\n /**\n * whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method\n * @default `true`\n */\n cameraEnabled?: boolean;\n /**\n * id of the camera to start capture with. Get available cameras with `cameras`.\n * You can switch the cameras later with `switchCamera` functions.\n * @default `the first front camera`\n */\n cameraId?: CameraId;\n};\n\nexport type CameraConfig = CameraConfigBase & {\n /**\n * whether video track uses simulcast. By default simulcast is disabled.\n */\n simulcastEnabled?: boolean;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n};\n\nexport type CameraConfigInternal = CameraConfigBase & {\n videoTrackMetadata?: { active: boolean; type: 'camera' };\n /**\n * SimulcastConfig of a video track. By default simulcast is disabled.\n */\n simulcastConfig?: SimulcastConfig;\n};\n\nconst defaultSimulcastConfig = () =>\n ({\n enabled: false,\n }) satisfies SimulcastConfig;\n\nfunction getSimulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n if (simulcastEnabled) {\n return { enabled: true };\n }\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: getSimulcastConfig(config.simulcastEnabled),\n };\n}\n\n/**\n * This hook can toggle camera on/off and provides current camera state.\n * @category Devices\n * @group Hooks\n */\nexport function useCamera() {\n const simulcastConfig = useFishjamEventState(\n ReceivableEvents.SimulcastConfigUpdate,\n defaultSimulcastConfig(), // TODO: Fetch from native\n );\n\n const {\n currentCamera: currentCameraState,\n isCameraOn,\n isCameraInitialized,\n } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {\n currentCamera: RNFishjamClientModule.currentCamera,\n isCameraOn: RNFishjamClientModule.isCameraOn,\n isCameraInitialized: RNFishjamClientModule.isCameraInitialized,\n });\n\n // For Android Expo converts null to undefined ¯\\_(ツ)_/¯\n const currentCamera = currentCameraState ?? null;\n\n const cameras = useMemo(() => RNFishjamClientModule.cameras, []);\n\n const prepareCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const camera = RNFishjamClientModule.cameras.find((cam) =>\n config.cameraId\n ? cam.id === config.cameraId\n : cam.facingDirection === 'front',\n );\n\n const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n return RNFishjamClientModule.startCamera(updatedConfig);\n },\n [],\n );\n\n const toggleCamera = useCallback(async () => {\n const state = await RNFishjamClientModule.toggleCamera();\n await RNFishjamClientModule.updateVideoTrackMetadata({\n active: state,\n type: 'camera',\n });\n }, []);\n\n const switchCamera = useCallback(async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\n }, []);\n\n return {\n /**\n * Informs if user camera is streaming video\n */\n isCameraOn,\n /**\n * Which camera is now used for streaming (or will be used as default when camera will be enabled)\n */\n currentCamera,\n /**\n * Simulcast configuration\n */\n simulcastConfig,\n /**\n * Property that lists cameras available on device.\n * @returns A promise that resolves to the list of available cameras.\n */\n cameras,\n /**\n * A value indicating if camera was already initialized (if `prepareCamera` was called).\n */\n isInitialized: isCameraInitialized,\n /**\n * Enable/disable current camera\n */\n toggleCamera,\n /**\n * Prepares camera and starts local video track\n * @param config configuration of the camera capture\n * @returns A promise that resolves when camera is started.\n */\n prepareCamera,\n /**\n * Switches to the specified camera.\n * List of available devices can be retrieved from `cameras` variable\n * @returns A promise that resolves when camera is switched.\n */\n switchCamera,\n };\n}\n"]}
|
|
@@ -18,10 +18,6 @@ export type ReconnectionStatus = 'idle' | 'reconnecting' | 'error';
|
|
|
18
18
|
*/
|
|
19
19
|
export type PeerStatus = 'connecting' | 'connected' | 'error' | 'idle';
|
|
20
20
|
export type JoinRoomConfig<PeerMetadata extends GenericMetadata = GenericMetadata> = {
|
|
21
|
-
/**
|
|
22
|
-
* Fishjam URL
|
|
23
|
-
*/
|
|
24
|
-
url: string;
|
|
25
21
|
/**
|
|
26
22
|
* Token received from server (or Room Manager)
|
|
27
23
|
*/
|
|
@@ -31,10 +27,25 @@ export type JoinRoomConfig<PeerMetadata extends GenericMetadata = GenericMetadat
|
|
|
31
27
|
*/
|
|
32
28
|
peerMetadata?: PeerMetadata;
|
|
33
29
|
/**
|
|
34
|
-
*
|
|
30
|
+
* Additional connection configuration
|
|
35
31
|
*/
|
|
36
32
|
config?: ConnectionConfig;
|
|
37
|
-
}
|
|
33
|
+
} & ({
|
|
34
|
+
/**
|
|
35
|
+
* Fishjam ID, which is used to connect to the room.
|
|
36
|
+
* Only use in sandbox.
|
|
37
|
+
* If provided, `url` must not be set.
|
|
38
|
+
*/
|
|
39
|
+
fishjamId: string;
|
|
40
|
+
url?: never;
|
|
41
|
+
} | {
|
|
42
|
+
/**
|
|
43
|
+
* Fishjam URL, used to connect to the room.
|
|
44
|
+
* If provided, `fishjamId` must not be set.
|
|
45
|
+
*/
|
|
46
|
+
url: string;
|
|
47
|
+
fishjamId?: never;
|
|
48
|
+
});
|
|
38
49
|
/**
|
|
39
50
|
* Connect/leave room. And get connection status.
|
|
40
51
|
* @group Hooks
|
|
@@ -46,7 +57,7 @@ export declare function useConnection(): {
|
|
|
46
57
|
*
|
|
47
58
|
* See {@link JoinRoomConfig} for parameter list
|
|
48
59
|
*/
|
|
49
|
-
joinRoom: <PeerMetadata extends GenericMetadata = GenericMetadata>({ url, peerToken, peerMetadata, config, }: JoinRoomConfig<PeerMetadata>) => Promise<void>;
|
|
60
|
+
joinRoom: <PeerMetadata extends GenericMetadata = GenericMetadata>({ url, peerToken, peerMetadata, config, fishjamId, }: JoinRoomConfig<PeerMetadata>) => Promise<void>;
|
|
50
61
|
/**
|
|
51
62
|
* Leave room and stop streaming
|
|
52
63
|
* @type function
|