@fishjam-cloud/react-native-client 0.1.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/.eslintignore +7 -0
- package/.eslintrc +6 -0
- package/.prettierrc +9 -0
- package/.watchmanconfig +1 -0
- package/android/.editorconfig +9 -0
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +34 -0
- package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +61 -0
- package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +14 -0
- package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +31 -0
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +866 -0
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +294 -0
- package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +11 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +40 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +17 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +58 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +25 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +77 -0
- package/app.plugin.js +1 -0
- package/babel.config.js +2 -0
- package/build/RNFishjamClientModule.d.ts +47 -0
- package/build/RNFishjamClientModule.d.ts.map +1 -0
- package/build/RNFishjamClientModule.js +4 -0
- package/build/RNFishjamClientModule.js.map +1 -0
- package/build/common/client.d.ts +19 -0
- package/build/common/client.d.ts.map +1 -0
- package/build/common/client.js +8 -0
- package/build/common/client.js.map +1 -0
- package/build/common/eventEmitter.d.ts +16 -0
- package/build/common/eventEmitter.d.ts.map +1 -0
- package/build/common/eventEmitter.js +17 -0
- package/build/common/eventEmitter.js.map +1 -0
- package/build/common/metadata.d.ts +7 -0
- package/build/common/metadata.d.ts.map +1 -0
- package/build/common/metadata.js +9 -0
- package/build/common/metadata.js.map +1 -0
- package/build/common/webRTC.d.ts +19 -0
- package/build/common/webRTC.d.ts.map +1 -0
- package/build/common/webRTC.js +22 -0
- package/build/common/webRTC.js.map +1 -0
- package/build/components/VideoPreviewView.d.ts +21 -0
- package/build/components/VideoPreviewView.d.ts.map +1 -0
- package/build/components/VideoPreviewView.js +7 -0
- package/build/components/VideoPreviewView.js.map +1 -0
- package/build/components/VideoRendererView.d.ts +19 -0
- package/build/components/VideoRendererView.d.ts.map +1 -0
- package/build/components/VideoRendererView.js +7 -0
- package/build/components/VideoRendererView.js.map +1 -0
- package/build/hooks/useAudioSettings.d.ts +23 -0
- package/build/hooks/useAudioSettings.d.ts.map +1 -0
- package/build/hooks/useAudioSettings.js +72 -0
- package/build/hooks/useAudioSettings.js.map +1 -0
- package/build/hooks/useBandwidthEstimation.d.ts +12 -0
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -0
- package/build/hooks/useBandwidthEstimation.js +16 -0
- package/build/hooks/useBandwidthEstimation.js.map +1 -0
- package/build/hooks/useCamera.d.ts +80 -0
- package/build/hooks/useCamera.d.ts.map +1 -0
- package/build/hooks/useCamera.js +140 -0
- package/build/hooks/useCamera.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts +8 -0
- package/build/hooks/useMicrophone.d.ts.map +1 -0
- package/build/hooks/useMicrophone.js +27 -0
- package/build/hooks/useMicrophone.js.map +1 -0
- package/build/hooks/useParticipants.d.ts +62 -0
- package/build/hooks/useParticipants.d.ts.map +1 -0
- package/build/hooks/useParticipants.js +32 -0
- package/build/hooks/useParticipants.js.map +1 -0
- package/build/hooks/useReconnection.d.ts +5 -0
- package/build/hooks/useReconnection.d.ts.map +1 -0
- package/build/hooks/useReconnection.js +23 -0
- package/build/hooks/useReconnection.js.map +1 -0
- package/build/hooks/useScreencast.d.ts +38 -0
- package/build/hooks/useScreencast.d.ts.map +1 -0
- package/build/hooks/useScreencast.js +81 -0
- package/build/hooks/useScreencast.js.map +1 -0
- package/build/index.d.ts +24 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +14 -0
- package/build/index.js.map +1 -0
- package/build/protos/fishjam/peer_notifications.d.ts +63 -0
- package/build/protos/fishjam/peer_notifications.d.ts.map +1 -0
- package/build/protos/fishjam/peer_notifications.js +235 -0
- package/build/protos/fishjam/peer_notifications.js.map +1 -0
- package/build/stats/types.d.ts +55 -0
- package/build/stats/types.d.ts.map +1 -0
- package/build/stats/types.js +2 -0
- package/build/stats/types.js.map +1 -0
- package/build/stats/useRTCStatistics.d.ts +8 -0
- package/build/stats/useRTCStatistics.d.ts.map +1 -0
- package/build/stats/useRTCStatistics.js +78 -0
- package/build/stats/useRTCStatistics.js.map +1 -0
- package/build/types.d.ts +43 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/Events.swift +13 -0
- package/ios/RNFishjamClient.podspec +30 -0
- package/ios/RNFishjamClient.swift +836 -0
- package/ios/RNFishjamClientModule.swift +220 -0
- package/ios/Utils.swift +43 -0
- package/ios/VideoPreviewView.swift +64 -0
- package/ios/VideoPreviewViewModule.swift +21 -0
- package/ios/VideoRendererView.swift +84 -0
- package/ios/VideoRendererViewModule.swift +17 -0
- package/ios/swift-format-config.json +56 -0
- package/package.json +89 -0
- package/plugin/broadcastExtensionFiles/Info.plist +27 -0
- package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +50 -0
- package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +10 -0
- package/plugin/src/withMembrane.ts +310 -0
- package/plugin/tsconfig.json +9 -0
- package/scripts/lint.sh +18 -0
- package/scripts/lint_check.sh +14 -0
- package/src/RNFishjamClientModule.ts +73 -0
- package/src/__tests__/index.test.tsx +199 -0
- package/src/common/client.ts +33 -0
- package/src/common/eventEmitter.ts +21 -0
- package/src/common/metadata.ts +12 -0
- package/src/common/webRTC.ts +31 -0
- package/src/components/VideoPreviewView.tsx +33 -0
- package/src/components/VideoRendererView.tsx +31 -0
- package/src/hooks/useAudioSettings.ts +115 -0
- package/src/hooks/useBandwidthEstimation.ts +24 -0
- package/src/hooks/useCamera.ts +270 -0
- package/src/hooks/useMicrophone.ts +38 -0
- package/src/hooks/useParticipants.ts +118 -0
- package/src/hooks/useReconnection.ts +41 -0
- package/src/hooks/useScreencast.ts +146 -0
- package/src/index.tsx +63 -0
- package/src/protos/fishjam/peer_notifications.ts +299 -0
- package/src/stats/types.ts +56 -0
- package/src/stats/useRTCStatistics.ts +97 -0
- package/src/types.ts +49 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +5 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NativeModulesProxy, EventEmitter } from 'expo-modules-core';
|
|
2
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
3
|
+
export const ReceivableEvents = {
|
|
4
|
+
IsCameraOn: 'IsCameraOn',
|
|
5
|
+
IsMicrophoneOn: 'IsMicrophoneOn',
|
|
6
|
+
IsScreencastOn: 'IsScreencastOn',
|
|
7
|
+
SimulcastConfigUpdate: 'SimulcastConfigUpdate',
|
|
8
|
+
PeersUpdate: 'PeersUpdate',
|
|
9
|
+
AudioDeviceUpdate: 'AudioDeviceUpdate',
|
|
10
|
+
SendMediaEvent: 'SendMediaEvent',
|
|
11
|
+
BandwidthEstimation: 'BandwidthEstimation',
|
|
12
|
+
ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',
|
|
13
|
+
ReconnectionStarted: 'ReconnectionStarted',
|
|
14
|
+
Reconnected: 'Reconnected',
|
|
15
|
+
};
|
|
16
|
+
export const eventEmitter = new EventEmitter(RNFishjamClientModule ?? NativeModulesProxy.RNFishjamClient);
|
|
17
|
+
//# sourceMappingURL=eventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEmitter.js","sourceRoot":"","sources":["../../src/common/eventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,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;CAClB,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,CAC1C,qBAAqB,IAAI,kBAAkB,CAAC,eAAe,CAC5D,CAAC","sourcesContent":["import { NativeModulesProxy, EventEmitter } from 'expo-modules-core';\n\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nexport const ReceivableEvents = {\n IsCameraOn: 'IsCameraOn',\n IsMicrophoneOn: 'IsMicrophoneOn',\n IsScreencastOn: 'IsScreencastOn',\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} as const;\n\nexport const eventEmitter = new EventEmitter(\n RNFishjamClientModule ?? NativeModulesProxy.RNFishjamClient,\n);\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GenericMetadata } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* a function that updates endpoints's metadata on the server
|
|
4
|
+
* @param metadata a map indexed by strings, containing participants metadata to be sent to the server
|
|
5
|
+
*/
|
|
6
|
+
export declare function updatePeerMetadata<ParticipantMetadata extends GenericMetadata = GenericMetadata>(metadata: ParticipantMetadata): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/common/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,mBAAmB,SAAS,eAAe,GAAG,eAAe,EAC7D,QAAQ,EAAE,mBAAmB,iBAE9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
2
|
+
/**
|
|
3
|
+
* a function that updates endpoints's metadata on the server
|
|
4
|
+
* @param metadata a map indexed by strings, containing participants metadata to be sent to the server
|
|
5
|
+
*/
|
|
6
|
+
export async function updatePeerMetadata(metadata) {
|
|
7
|
+
await RNFishjamClientModule.updatePeerMetadata(metadata);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/common/metadata.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAEtC,QAA6B;IAC7B,MAAM,qBAAqB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { GenericMetadata } from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\n/**\n * a function that updates endpoints's metadata on the server\n * @param metadata a map indexed by strings, containing participants metadata to be sent to the server\n */\nexport async function updatePeerMetadata<\n ParticipantMetadata extends GenericMetadata = GenericMetadata,\n>(metadata: ParticipantMetadata) {\n await RNFishjamClientModule.updatePeerMetadata(metadata);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TrackEncoding } from '../types';
|
|
2
|
+
export type LoggingSeverity = 'verbose' | 'info' | 'warning' | 'error' | 'none';
|
|
3
|
+
/**
|
|
4
|
+
* sets track encoding that server should send to the client library.
|
|
5
|
+
* The encoding will be sent whenever it is available. If chooses encoding is
|
|
6
|
+
* temporarily unavailable, some other encoding will be sent until choose encoding
|
|
7
|
+
* becomes active again.
|
|
8
|
+
*
|
|
9
|
+
* @param trackId id of a track which encoding you want to select
|
|
10
|
+
* @param encoding encoding to select
|
|
11
|
+
*/
|
|
12
|
+
export declare function setTargetTrackEncoding(trackId: string, encoding: TrackEncoding): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Function that changes level of debugging logs in WebRTC.
|
|
15
|
+
* @param severity to use when displaying logs
|
|
16
|
+
* @returns a promise that is resolved when debug severity is changed
|
|
17
|
+
*/
|
|
18
|
+
export declare function changeWebRTCLoggingSeverity(severity: LoggingSeverity): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=webRTC.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRTC.d.ts","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhF;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,iBAGxB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
2
|
+
/**
|
|
3
|
+
* sets track encoding that server should send to the client library.
|
|
4
|
+
* The encoding will be sent whenever it is available. If chooses encoding is
|
|
5
|
+
* temporarily unavailable, some other encoding will be sent until choose encoding
|
|
6
|
+
* becomes active again.
|
|
7
|
+
*
|
|
8
|
+
* @param trackId id of a track which encoding you want to select
|
|
9
|
+
* @param encoding encoding to select
|
|
10
|
+
*/
|
|
11
|
+
export async function setTargetTrackEncoding(trackId, encoding) {
|
|
12
|
+
await RNFishjamClientModule.setTargetTrackEncoding(trackId, encoding);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Function that changes level of debugging logs in WebRTC.
|
|
16
|
+
* @param severity to use when displaying logs
|
|
17
|
+
* @returns a promise that is resolved when debug severity is changed
|
|
18
|
+
*/
|
|
19
|
+
export function changeWebRTCLoggingSeverity(severity) {
|
|
20
|
+
return RNFishjamClientModule.changeWebRTCLoggingSeverity(severity);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=webRTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRTC.js","sourceRoot":"","sources":["../../src/common/webRTC.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAI7D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAe,EACf,QAAuB;IAEvB,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAyB;IAEzB,OAAO,qBAAqB,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { TrackEncoding } from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\n\nexport type LoggingSeverity = 'verbose' | 'info' | 'warning' | 'error' | 'none';\n\n/**\n * sets track encoding that server should send to the client library.\n * The encoding will be sent whenever it is available. If chooses encoding is\n * temporarily unavailable, some other encoding will be sent until choose encoding\n * becomes active again.\n *\n * @param trackId id of a track which encoding you want to select\n * @param encoding encoding to select\n */\nexport async function setTargetTrackEncoding(\n trackId: string,\n encoding: TrackEncoding,\n) {\n await RNFishjamClientModule.setTargetTrackEncoding(trackId, encoding);\n}\n\n/**\n * Function that changes level of debugging logs in WebRTC.\n * @param severity to use when displaying logs\n * @returns a promise that is resolved when debug severity is changed\n */\nexport function changeWebRTCLoggingSeverity(\n severity: LoggingSeverity,\n): Promise<void> {\n return RNFishjamClientModule.changeWebRTCLoggingSeverity(severity);\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { VideoLayout } from '../types';
|
|
4
|
+
import { CaptureDeviceId } from '../hooks/useCamera';
|
|
5
|
+
export type VideoPreviewViewProps = {
|
|
6
|
+
/**
|
|
7
|
+
* `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view
|
|
8
|
+
* with video and it may cut some parts of the video. `FIT` scales the video so the whole
|
|
9
|
+
* video is visible, but it may leave some empty space in the view.
|
|
10
|
+
* @default `FILL`
|
|
11
|
+
*/
|
|
12
|
+
videoLayout?: VideoLayout;
|
|
13
|
+
style?: ViewStyle;
|
|
14
|
+
/**
|
|
15
|
+
* Id of the camera used for preview. Get available cameras with `getCaptureDevices()` function.
|
|
16
|
+
* @default the first front camera
|
|
17
|
+
*/
|
|
18
|
+
captureDeviceId?: CaptureDeviceId;
|
|
19
|
+
};
|
|
20
|
+
export declare const VideoPreviewView: React.ForwardRefExoticComponent<VideoPreviewViewProps & React.RefAttributes<React.ComponentType<VideoPreviewViewProps>>>;
|
|
21
|
+
//# sourceMappingURL=VideoPreviewView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoPreviewView.d.ts","sourceRoot":"","sources":["../../src/components/VideoPreviewView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAKF,eAAO,MAAM,gBAAgB,0HAM3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeViewManager('VideoPreviewViewModule');
|
|
4
|
+
export const VideoPreviewView = React.forwardRef((props, ref) => (
|
|
5
|
+
// @ts-expect-error ref prop needs to be updated
|
|
6
|
+
<NativeView {...props} ref={ref}/>));
|
|
7
|
+
//# sourceMappingURL=VideoPreviewView.js.map
|
|
@@ -0,0 +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;AAsB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;AAErD,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,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACpC,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\nimport { CaptureDeviceId } from '../hooks/useCamera';\n\nexport type VideoPreviewViewProps = {\n /**\n * `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view\n * with video and it may cut some parts of the video. `FIT` scales the video so the whole\n * video is visible, but it may leave some empty space in the view.\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n style?: ViewStyle;\n /**\n * Id of the camera used for preview. Get available cameras with `getCaptureDevices()` function.\n * @default the first front camera\n */\n captureDeviceId?: CaptureDeviceId;\n};\n\nconst NativeView: React.ComponentType<VideoPreviewViewProps> =\n requireNativeViewManager('VideoPreviewViewModule');\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} ref={ref} />\n));\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { VideoLayout } from '../types';
|
|
4
|
+
export type VideoRendererProps = {
|
|
5
|
+
/**
|
|
6
|
+
* id of the video track which you want to render.
|
|
7
|
+
*/
|
|
8
|
+
trackId: string;
|
|
9
|
+
/**
|
|
10
|
+
* `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view
|
|
11
|
+
* with video and it may cut some parts of the video. `FIT` scales the video so the whole
|
|
12
|
+
* video is visible, but it may leave some empty space in the view.
|
|
13
|
+
* @default `FILL`
|
|
14
|
+
*/
|
|
15
|
+
videoLayout?: VideoLayout;
|
|
16
|
+
style?: ViewStyle;
|
|
17
|
+
};
|
|
18
|
+
export declare const VideoRendererView: React.ForwardRefExoticComponent<VideoRendererProps & React.RefAttributes<React.ComponentType<VideoRendererProps>>>;
|
|
19
|
+
//# sourceMappingURL=VideoRendererView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoRendererView.d.ts","sourceRoot":"","sources":["../../src/components/VideoRendererView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAKF,eAAO,MAAM,iBAAiB,oHAM5B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeViewManager('VideoRendererViewModule');
|
|
4
|
+
export const VideoRendererView = React.forwardRef((props, ref) => (
|
|
5
|
+
// @ts-expect-error ref prop needs to be updated
|
|
6
|
+
<NativeView {...props} ref={ref}/>));
|
|
7
|
+
//# sourceMappingURL=VideoRendererView.js.map
|
|
@@ -0,0 +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;AAoB/B,MAAM,UAAU,GACd,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAG/C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAChB,gDAAgD;AAChD,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAG,CACpC,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { ViewStyle } from 'react-native';\n\nimport { VideoLayout } from '../types';\n\nexport type VideoRendererProps = {\n /**\n * id of the video track which you want to render.\n */\n trackId: string;\n /**\n * `FILL` or `FIT` - it works just like RN Image component. `FILL` fills the whole view\n * with video and it may cut some parts of the video. `FIT` scales the video so the whole\n * video is visible, but it may leave some empty space in the view.\n * @default `FILL`\n */\n videoLayout?: VideoLayout;\n style?: ViewStyle;\n};\n\nconst NativeView: React.ComponentType<VideoRendererProps> =\n requireNativeViewManager('VideoRendererViewModule');\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"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type AudioOutputDeviceType = 'bluetooth' | 'headset' | 'speaker' | 'earpiece';
|
|
2
|
+
export type AudioSessionMode = 'voiceChat' | 'videoChat';
|
|
3
|
+
export type AudioOutputDevice = {
|
|
4
|
+
type: AudioOutputDeviceType;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This hook manages audio settings.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAudioSettings(): {
|
|
11
|
+
/**
|
|
12
|
+
* currently selected output audio device
|
|
13
|
+
*/
|
|
14
|
+
selectedAudioOutputDevice: AudioOutputDevice | null;
|
|
15
|
+
/**
|
|
16
|
+
* [Android only] available audio output devices to be set
|
|
17
|
+
*/
|
|
18
|
+
availableDevices: AudioOutputDevice[];
|
|
19
|
+
selectOutputAudioDevice: (device: AudioOutputDeviceType) => Promise<void>;
|
|
20
|
+
selectAudioSessionMode: (audioSessionMode: AudioSessionMode) => Promise<void>;
|
|
21
|
+
showAudioRoutePicker: () => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=useAudioSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAudioSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AASF;;GAEG;AACH,wBAAgB,gBAAgB;IAyE5B;;OAEG;;IAEH;;OAEG;;sCAhDY,qBAAqB;+CAkBX,gBAAgB;;EAoC5C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
4
|
+
import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
|
|
5
|
+
/**
|
|
6
|
+
* This hook manages audio settings.
|
|
7
|
+
*/
|
|
8
|
+
export function useAudioSettings() {
|
|
9
|
+
const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] = useState(null);
|
|
10
|
+
const [availableDevices, setAvailableDevices] = useState([]);
|
|
11
|
+
const onAudioDevice = useCallback((event) => {
|
|
12
|
+
setSelectedAudioOutputDevice(event.AudioDeviceUpdate.selectedDevice);
|
|
13
|
+
setAvailableDevices(event.AudioDeviceUpdate.availableDevices);
|
|
14
|
+
}, []);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const eventListener = eventEmitter.addListener(ReceivableEvents.AudioDeviceUpdate, onAudioDevice);
|
|
17
|
+
RNFishjamClientModule.startAudioSwitcher();
|
|
18
|
+
return () => {
|
|
19
|
+
eventListener.remove();
|
|
20
|
+
if (Platform.OS === 'android') {
|
|
21
|
+
RNFishjamClientModule.stopAudioSwitcher();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}, [onAudioDevice]);
|
|
25
|
+
/**
|
|
26
|
+
* [Android only] selects output audio device.
|
|
27
|
+
* For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.
|
|
28
|
+
*/
|
|
29
|
+
const selectOutputAudioDevice = useCallback(async (device) => {
|
|
30
|
+
if (Platform.OS === 'ios') {
|
|
31
|
+
throw Error('selectOutputAudioDevice function is supported only on Android. ' +
|
|
32
|
+
'To select an output audio device on iOS use selectAudioSessionMode or showAudioRoutePicker functions');
|
|
33
|
+
}
|
|
34
|
+
await RNFishjamClientModule.setOutputAudioDevice(device);
|
|
35
|
+
}, []);
|
|
36
|
+
/**
|
|
37
|
+
* [iOS only] selects audio session mode. For more information refer to Apple's documentation:
|
|
38
|
+
* https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
const selectAudioSessionMode = useCallback(async (audioSessionMode) => {
|
|
42
|
+
if (Platform.OS === 'android') {
|
|
43
|
+
throw Error('selectAudioSessionMode function is supported only on iOS');
|
|
44
|
+
}
|
|
45
|
+
await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);
|
|
46
|
+
}, []);
|
|
47
|
+
/**
|
|
48
|
+
* [iOS only] Shows a picker modal that allows user to select output audio device. For more
|
|
49
|
+
* information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview
|
|
50
|
+
*/
|
|
51
|
+
const showAudioRoutePicker = useCallback(async () => {
|
|
52
|
+
if (Platform.OS === 'android') {
|
|
53
|
+
throw Error('showAudioRoutePicker function is supported only on iOS. ' +
|
|
54
|
+
'To select an output audio device on Android use selectOutputAudioDevice function');
|
|
55
|
+
}
|
|
56
|
+
await RNFishjamClientModule.showAudioRoutePicker();
|
|
57
|
+
}, []);
|
|
58
|
+
return {
|
|
59
|
+
/**
|
|
60
|
+
* currently selected output audio device
|
|
61
|
+
*/
|
|
62
|
+
selectedAudioOutputDevice,
|
|
63
|
+
/**
|
|
64
|
+
* [Android only] available audio output devices to be set
|
|
65
|
+
*/
|
|
66
|
+
availableDevices,
|
|
67
|
+
selectOutputAudioDevice,
|
|
68
|
+
selectAudioSessionMode,
|
|
69
|
+
showAudioRoutePicker,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=useAudioSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAudioSettings.js","sourceRoot":"","sources":["../../src/hooks/useAudioSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAsBxE;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,yBAAyB,EAAE,4BAA4B,CAAC,GAC7D,QAAQ,CAA2B,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CACtD,EAAE,CACH,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,KAAyB,EAAE,EAAE;QAC9D,4BAA4B,CAAC,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;QACrE,mBAAmB,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAC5C,gBAAgB,CAAC,iBAAiB,EAClC,aAAa,CACd,CAAC;QACF,qBAAqB,CAAC,kBAAkB,EAAE,CAAC;QAC3C,OAAO,GAAG,EAAE;Y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{ useCallback, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, eventEmitter } from '../common/eventEmitter';\n\nexport type AudioOutputDeviceType =\n | 'bluetooth'\n | 'headset'\n | 'speaker'\n | 'earpiece';\n\nexport type AudioSessionMode = 'voiceChat' | 'videoChat';\n\nexport type AudioOutputDevice = {\n type: AudioOutputDeviceType;\n name: string;\n};\n\ntype OnAudioDeviceEvent = {\n AudioDeviceUpdate: {\n selectedDevice: AudioOutputDevice;\n availableDevices: AudioOutputDevice[];\n };\n};\n\n/**\n * This hook manages audio settings.\n */\nexport function useAudioSettings() {\n const [selectedAudioOutputDevice, setSelectedAudioOutputDevice] =\n useState<AudioOutputDevice | null>(null);\n const [availableDevices, setAvailableDevices] = useState<AudioOutputDevice[]>(\n [],\n );\n\n const onAudioDevice = useCallback((event: OnAudioDeviceEvent) => {\n setSelectedAudioOutputDevice(event.AudioDeviceUpdate.selectedDevice);\n setAvailableDevices(event.AudioDeviceUpdate.availableDevices);\n }, []);\n\n useEffect(() => {\n const eventListener = eventEmitter.addListener(\n ReceivableEvents.AudioDeviceUpdate,\n onAudioDevice,\n );\n RNFishjamClientModule.startAudioSwitcher();\n return () => {\n eventListener.remove();\n if (Platform.OS === 'android') {\n RNFishjamClientModule.stopAudioSwitcher();\n }\n };\n }, [onAudioDevice]);\n\n /**\n * [Android only] selects output audio device.\n * For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.\n */\n const selectOutputAudioDevice = useCallback(\n async (device: AudioOutputDeviceType) => {\n if (Platform.OS === 'ios') {\n throw Error(\n 'selectOutputAudioDevice function is supported only on Android. ' +\n 'To select an output audio device on iOS use selectAudioSessionMode or showAudioRoutePicker functions',\n );\n }\n await RNFishjamClientModule.setOutputAudioDevice(device);\n },\n [],\n );\n\n /**\n * [iOS only] selects audio session mode. For more information refer to Apple's documentation:\n * https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/\n *\n */\n const selectAudioSessionMode = useCallback(\n async (audioSessionMode: AudioSessionMode) => {\n if (Platform.OS === 'android') {\n throw Error('selectAudioSessionMode function is supported only on iOS');\n }\n await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);\n },\n [],\n );\n\n /**\n * [iOS only] Shows a picker modal that allows user to select output audio device. For more\n * information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview\n */\n const showAudioRoutePicker = useCallback(async () => {\n if (Platform.OS === 'android') {\n throw Error(\n 'showAudioRoutePicker function is supported only on iOS. ' +\n 'To select an output audio device on Android use selectOutputAudioDevice function',\n );\n }\n await RNFishjamClientModule.showAudioRoutePicker();\n }, []);\n\n return {\n /**\n * currently selected output audio device\n */\n selectedAudioOutputDevice,\n /**\n * [Android only] available audio output devices to be set\n */\n availableDevices,\n selectOutputAudioDevice,\n selectAudioSessionMode,\n showAudioRoutePicker,\n };\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type BandwidthEstimationEvent = {
|
|
2
|
+
BandwidthEstimation: number;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* This hook provides current bandwidth estimation
|
|
6
|
+
* estimation - client's available incoming bitrate estimated
|
|
7
|
+
* by the server. It's measured in bits per second.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useBandwidthEstimation(): {
|
|
10
|
+
estimation: number | null;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useBandwidthEstimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG;IAAE,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,sBAAsB;;EAYrC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
|
|
3
|
+
/**
|
|
4
|
+
* This hook provides current bandwidth estimation
|
|
5
|
+
* estimation - client's available incoming bitrate estimated
|
|
6
|
+
* by the server. It's measured in bits per second.
|
|
7
|
+
*/
|
|
8
|
+
export function useBandwidthEstimation() {
|
|
9
|
+
const [estimation, setEstimation] = useState(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const eventListener = eventEmitter.addListener(ReceivableEvents.BandwidthEstimation, (event) => setEstimation(event.BandwidthEstimation));
|
|
12
|
+
return () => eventListener.remove();
|
|
13
|
+
}, []);
|
|
14
|
+
return { estimation };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useBandwidthEstimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAIxE;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAElE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAC5C,gBAAgB,CAAC,mBAAmB,EACpC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,mBAAmB,CAAC,CACpD,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { ReceivableEvents, eventEmitter } from '../common/eventEmitter';\n\nexport type BandwidthEstimationEvent = { BandwidthEstimation: number };\n\n/**\n * This hook provides current bandwidth estimation\n * estimation - client's available incoming bitrate estimated\n * by the server. It's measured in bits per second.\n */\nexport function useBandwidthEstimation() {\n const [estimation, setEstimation] = useState<number | null>(null);\n\n useEffect(() => {\n const eventListener = eventEmitter.addListener<BandwidthEstimationEvent>(\n ReceivableEvents.BandwidthEstimation,\n (event) => setEstimation(event.BandwidthEstimation),\n );\n return () => eventListener.remove();\n }, []);\n\n return { estimation };\n}\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BandwidthLimit, Brand, SimulcastBandwidthLimit, SimulcastConfig, TrackBandwidthLimit, TrackEncoding } from '../types';
|
|
2
|
+
export type CaptureDeviceId = Brand<string, 'CaptureDeviceId'>;
|
|
3
|
+
export type CaptureDevice = {
|
|
4
|
+
id: CaptureDeviceId;
|
|
5
|
+
name: string;
|
|
6
|
+
isFrontFacing: boolean;
|
|
7
|
+
isBackFacing: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type VideoQuality = 'QVGA169' | 'VGA169' | 'QHD169' | 'HD169' | 'FHD169' | 'QVGA43' | 'VGA43' | 'QHD43' | 'HD43' | 'FHD43';
|
|
10
|
+
type CameraConfigBase = {
|
|
11
|
+
/**
|
|
12
|
+
* resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,
|
|
13
|
+
* `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than
|
|
14
|
+
* specified due to device capabilities, internet connection etc.
|
|
15
|
+
* @default `VGA_169`
|
|
16
|
+
*/
|
|
17
|
+
quality?: VideoQuality;
|
|
18
|
+
/**
|
|
19
|
+
* whether to flip the dimensions of the video, that is whether to film in vertical orientation.
|
|
20
|
+
* @default `true`
|
|
21
|
+
*/
|
|
22
|
+
flipVideo?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method
|
|
25
|
+
* @default `true`
|
|
26
|
+
*/
|
|
27
|
+
cameraEnabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* id of the camera to start capture with. Get available cameras with `getCaptureDevices()`.
|
|
30
|
+
* You can switch the cameras later with `flipCamera`/`switchCamera` functions.
|
|
31
|
+
* @default the first front camera
|
|
32
|
+
*/
|
|
33
|
+
captureDeviceId?: CaptureDeviceId;
|
|
34
|
+
};
|
|
35
|
+
export type CameraConfig = CameraConfigBase & {
|
|
36
|
+
/**
|
|
37
|
+
* whether video track uses simulcast. By default simulcast is disabled.
|
|
38
|
+
*/
|
|
39
|
+
simulcastEnabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* bandwidth limit of a video track. By default there is no bandwidth limit.
|
|
42
|
+
*/
|
|
43
|
+
maxBandwidth?: TrackBandwidthLimit;
|
|
44
|
+
};
|
|
45
|
+
export type CameraConfigInternal = CameraConfigBase & {
|
|
46
|
+
videoTrackMetadata?: {
|
|
47
|
+
active: boolean;
|
|
48
|
+
type: 'camera';
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* SimulcastConfig of a video track. By default simulcast is disabled.
|
|
52
|
+
*/
|
|
53
|
+
simulcastConfig?: SimulcastConfig;
|
|
54
|
+
/**
|
|
55
|
+
* bandwidth limit of a video track. By default there is no bandwidth limit.
|
|
56
|
+
*/
|
|
57
|
+
maxBandwidth?: TrackBandwidthLimit;
|
|
58
|
+
} & ({
|
|
59
|
+
maxBandwidthInt?: BandwidthLimit;
|
|
60
|
+
} | {
|
|
61
|
+
maxBandwidthMap?: SimulcastBandwidthLimit;
|
|
62
|
+
});
|
|
63
|
+
export declare function updateCameraConfig(config: Readonly<CameraConfig>): CameraConfigInternal;
|
|
64
|
+
/**
|
|
65
|
+
* This hook can toggle camera on/off and provides current camera state.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useCamera(): {
|
|
68
|
+
isCameraOn: boolean;
|
|
69
|
+
simulcastConfig: SimulcastConfig;
|
|
70
|
+
toggleCamera: () => Promise<void>;
|
|
71
|
+
startCamera: (config?: Readonly<CameraConfig>) => Promise<void>;
|
|
72
|
+
flipCamera: () => Promise<void>;
|
|
73
|
+
switchCamera: (captureDeviceId: CaptureDeviceId) => Promise<void>;
|
|
74
|
+
getCaptureDevices: () => Promise<CaptureDevice[]>;
|
|
75
|
+
toggleVideoTrackEncoding: (encoding: TrackEncoding) => Promise<void>;
|
|
76
|
+
setVideoTrackEncodingBandwidth: (encoding: TrackEncoding, bandwidth: BandwidthLimit) => Promise<void>;
|
|
77
|
+
setVideoTrackBandwidth: (bandwidth: BandwidthLimit) => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=useCamera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,KAAK,EACL,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,eAAe,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,OAAO,GACP,MAAM,GACN,OAAO,CAAC;AAEZ,KAAK,gBAAgB,GAAG;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,kBAAkB,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IACzD;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,GAAG,CACE;IAAE,eAAe,CAAC,EAAE,cAAc,CAAA;CAAE,GACpC;IAAE,eAAe,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAChD,CAAC;AAuCJ,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAC7B,oBAAoB,CAOtB;AAED;;GAEG;AACH,wBAAgB,SAAS;;;;2BAyEN,QAAQ,CAAC,YAAY,CAAC;;oCAmBkB,eAAe;;yCA7DrD,aAAa;+CAcb,aAAa,aAAa,cAAc;wCAkEvC,cAAc;EAkBnC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
4
|
+
import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
|
|
5
|
+
const defaultSimulcastConfig = () => ({
|
|
6
|
+
enabled: false,
|
|
7
|
+
activeEncodings: [],
|
|
8
|
+
});
|
|
9
|
+
function maxBandwidthConfig(maxBandwidth) {
|
|
10
|
+
if (Platform.OS === 'android') {
|
|
11
|
+
if (typeof maxBandwidth === 'object') {
|
|
12
|
+
return {
|
|
13
|
+
maxBandwidth: undefined,
|
|
14
|
+
maxBandwidthMap: maxBandwidth,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return {
|
|
19
|
+
maxBandwidth: undefined,
|
|
20
|
+
maxBandwidthInt: maxBandwidth,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { maxBandwidth };
|
|
25
|
+
}
|
|
26
|
+
function simulcastConfig(simulcastEnabled) {
|
|
27
|
+
// iOS has a limit of 3 hardware encoders
|
|
28
|
+
// 3 simulcast layers + 1 screencast layer = 4, which is too much
|
|
29
|
+
// so we limit simulcast layers to 2
|
|
30
|
+
if (simulcastEnabled) {
|
|
31
|
+
return Platform.select({
|
|
32
|
+
ios: { enabled: true, activeEncodings: ['l', 'h'] },
|
|
33
|
+
android: { enabled: true, activeEncodings: ['l', 'm', 'h'] },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
export function updateCameraConfig(config) {
|
|
39
|
+
return {
|
|
40
|
+
...config,
|
|
41
|
+
...maxBandwidthConfig(config.maxBandwidth),
|
|
42
|
+
videoTrackMetadata: { active: true, type: 'camera' },
|
|
43
|
+
simulcastConfig: simulcastConfig(config.simulcastEnabled),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* This hook can toggle camera on/off and provides current camera state.
|
|
48
|
+
*/
|
|
49
|
+
export function useCamera() {
|
|
50
|
+
const [isCameraOn, setIsCameraOn] = useState(RNFishjamClientModule.isCameraOn);
|
|
51
|
+
const [simulcastConfig, setSimulcastConfig] = useState(defaultSimulcastConfig());
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const eventListener = eventEmitter.addListener(ReceivableEvents.SimulcastConfigUpdate, (event) => setSimulcastConfig(event));
|
|
54
|
+
return () => eventListener.remove();
|
|
55
|
+
}, []);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const eventListener = eventEmitter.addListener(ReceivableEvents.IsCameraOn, (event) => setIsCameraOn(event.IsCameraOn));
|
|
58
|
+
setIsCameraOn(RNFishjamClientModule.isCameraOn);
|
|
59
|
+
return () => eventListener.remove();
|
|
60
|
+
}, []);
|
|
61
|
+
/**
|
|
62
|
+
* toggles encoding of a video track on/off
|
|
63
|
+
* @param encoding encoding to toggle
|
|
64
|
+
*/
|
|
65
|
+
const toggleVideoTrackEncoding = useCallback(async (encoding) => {
|
|
66
|
+
const videoSimulcastConfig = await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);
|
|
67
|
+
setSimulcastConfig(videoSimulcastConfig);
|
|
68
|
+
}, []);
|
|
69
|
+
/**
|
|
70
|
+
* updates maximum bandwidth for the given simulcast encoding of the video track
|
|
71
|
+
* @param encoding encoding to update
|
|
72
|
+
* @param bandwidth BandwidthLimit to set
|
|
73
|
+
*/
|
|
74
|
+
const setVideoTrackEncodingBandwidth = useCallback(async (encoding, bandwidth) => {
|
|
75
|
+
await RNFishjamClientModule.setVideoTrackEncodingBandwidth(encoding, bandwidth);
|
|
76
|
+
}, []);
|
|
77
|
+
/**
|
|
78
|
+
* Function to toggle camera on/off
|
|
79
|
+
*/
|
|
80
|
+
const toggleCamera = useCallback(async () => {
|
|
81
|
+
const state = await RNFishjamClientModule.toggleCamera();
|
|
82
|
+
await RNFishjamClientModule.updateVideoTrackMetadata({
|
|
83
|
+
active: state,
|
|
84
|
+
type: 'camera',
|
|
85
|
+
});
|
|
86
|
+
setIsCameraOn(state);
|
|
87
|
+
}, []);
|
|
88
|
+
/**
|
|
89
|
+
* Starts local camera capture.
|
|
90
|
+
* @param config configuration of the camera capture
|
|
91
|
+
* @returns A promise that resolves when camera is started.
|
|
92
|
+
*/
|
|
93
|
+
const startCamera = useCallback(async (config = {}) => {
|
|
94
|
+
const updatedConfig = updateCameraConfig(config);
|
|
95
|
+
await RNFishjamClientModule.startCamera(updatedConfig);
|
|
96
|
+
}, []);
|
|
97
|
+
/**
|
|
98
|
+
* Function that toggles between front and back camera. By default the front camera is used.
|
|
99
|
+
* @returns A promise that resolves when camera is toggled.
|
|
100
|
+
*/
|
|
101
|
+
const flipCamera = useCallback(async () => {
|
|
102
|
+
await RNFishjamClientModule.flipCamera();
|
|
103
|
+
}, []);
|
|
104
|
+
/**
|
|
105
|
+
* Function that switches to the specified camera. By default the front camera is used.
|
|
106
|
+
* @returns A promise that resolves when camera is switched.
|
|
107
|
+
*/
|
|
108
|
+
const switchCamera = useCallback(async (captureDeviceId) => {
|
|
109
|
+
await RNFishjamClientModule.switchCamera(captureDeviceId);
|
|
110
|
+
}, []);
|
|
111
|
+
/** Function that queries available cameras.
|
|
112
|
+
* @returns A promise that resolves to the list of available cameras.
|
|
113
|
+
*/
|
|
114
|
+
const getCaptureDevices = useCallback(async () => {
|
|
115
|
+
return RNFishjamClientModule.getCaptureDevices();
|
|
116
|
+
}, []);
|
|
117
|
+
/**
|
|
118
|
+
* updates maximum bandwidth for the video track. This value directly translates
|
|
119
|
+
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
120
|
+
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
121
|
+
* their resolution.
|
|
122
|
+
* @param BandwidthLimit to set
|
|
123
|
+
*/
|
|
124
|
+
const setVideoTrackBandwidth = useCallback(async (bandwidth) => {
|
|
125
|
+
await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);
|
|
126
|
+
}, []);
|
|
127
|
+
return {
|
|
128
|
+
isCameraOn,
|
|
129
|
+
simulcastConfig,
|
|
130
|
+
toggleCamera,
|
|
131
|
+
startCamera,
|
|
132
|
+
flipCamera,
|
|
133
|
+
switchCamera,
|
|
134
|
+
getCaptureDevices,
|
|
135
|
+
toggleVideoTrackEncoding,
|
|
136
|
+
setVideoTrackEncodingBandwidth,
|
|
137
|
+
setVideoTrackBandwidth,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#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G;IACH,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC/C,OAAO,qBAAqB,CAAC,iBAAiB,EAAE,CAAC;IACnD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP;;;;;;OAMG;IACH,MAAM,sBAAsB,GAAG,WAAW,CACxC,KAAK,EAAE,SAAyB,EAAE,EAAE;QAClC,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO;QACL,UAAU;QACV,eAAe;QACf,YAAY;QACZ,WAAW;QACX,UAAU;QACV,YAAY;QACZ,iBAAiB;QACjB,wBAAwB;QACxB,8BAA8B;QAC9B,sBAAsB;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n BandwidthLimit,\n Brand,\n SimulcastBandwidthLimit,\n SimulcastConfig,\n TrackBandwidthLimit,\n TrackEncoding,\n} from '../types';\nimport RNFishjamClientModule from '../RNFishjamClientModule';\nimport { ReceivableEvents, eventEmitter } from '../common/eventEmitter';\n\ntype IsCameraOnEvent = { IsCameraOn: boolean };\ntype SimulcastConfigUpdateEvent = SimulcastConfig;\nexport type CaptureDeviceId = Brand<string, 'CaptureDeviceId'>;\n\nexport type CaptureDevice = {\n id: CaptureDeviceId;\n name: string;\n isFrontFacing: boolean;\n isBackFacing: boolean;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\ntype CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether to flip the dimensions of the video, that is whether to film in vertical orientation.\n * @default `true`\n */\n flipVideo?: 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 `getCaptureDevices()`.\n * You can switch the cameras later with `flipCamera`/`switchCamera` functions.\n * @default the first front camera\n */\n captureDeviceId?: CaptureDeviceId;\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 maxBandwidth?: TrackBandwidthLimit;\n};\n\nexport type CameraConfigInternal = CameraConfigBase & {\n videoTrackMetadata?: { active: boolean; type: 'camera' };\n /**\n * SimulcastConfig of a video track. By default simulcast is disabled.\n */\n simulcastConfig?: SimulcastConfig;\n /**\n * bandwidth limit of a video track. By default there is no bandwidth limit.\n */\n maxBandwidth?: TrackBandwidthLimit;\n} & (\n | { maxBandwidthInt?: BandwidthLimit }\n | { maxBandwidthMap?: SimulcastBandwidthLimit }\n );\n\nconst defaultSimulcastConfig = () => ({\n enabled: false,\n activeEncodings: [],\n});\n\nfunction maxBandwidthConfig(maxBandwidth: TrackBandwidthLimit | undefined) {\n if (Platform.OS === 'android') {\n if (typeof maxBandwidth === 'object') {\n return {\n maxBandwidth: undefined,\n maxBandwidthMap: maxBandwidth,\n };\n } else {\n return {\n maxBandwidth: undefined,\n maxBandwidthInt: maxBandwidth,\n };\n }\n }\n return { maxBandwidth };\n}\n\nfunction simulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n // iOS has a limit of 3 hardware encoders\n // 3 simulcast layers + 1 screencast layer = 4, which is too much\n // so we limit simulcast layers to 2\n if (simulcastEnabled) {\n return Platform.select<SimulcastConfig>({\n ios: { enabled: true, activeEncodings: ['l', 'h'] },\n android: { enabled: true, activeEncodings: ['l', 'm', 'h'] },\n });\n }\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n ...maxBandwidthConfig(config.maxBandwidth),\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: simulcastConfig(config.simulcastEnabled),\n };\n}\n\n/**\n * This hook can toggle camera on/off and provides current camera state.\n */\nexport function useCamera() {\n const [isCameraOn, setIsCameraOn] = useState<boolean>(\n RNFishjamClientModule.isCameraOn,\n );\n\n const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(\n defaultSimulcastConfig(),\n );\n\n useEffect(() => {\n const eventListener = eventEmitter.addListener<SimulcastConfigUpdateEvent>(\n ReceivableEvents.SimulcastConfigUpdate,\n (event) => setSimulcastConfig(event),\n );\n return () => eventListener.remove();\n }, []);\n\n useEffect(() => {\n const eventListener = eventEmitter.addListener<IsCameraOnEvent>(\n ReceivableEvents.IsCameraOn,\n (event) => setIsCameraOn(event.IsCameraOn),\n );\n setIsCameraOn(RNFishjamClientModule.isCameraOn);\n return () => eventListener.remove();\n }, []);\n\n /**\n * toggles encoding of a video track on/off\n * @param encoding encoding to toggle\n */\n const toggleVideoTrackEncoding = useCallback(\n async (encoding: TrackEncoding) => {\n const videoSimulcastConfig =\n await RNFishjamClientModule.toggleVideoTrackEncoding(encoding);\n setSimulcastConfig(videoSimulcastConfig);\n },\n [],\n );\n\n /**\n * updates maximum bandwidth for the given simulcast encoding of the video track\n * @param encoding encoding to update\n * @param bandwidth BandwidthLimit to set\n */\n const setVideoTrackEncodingBandwidth = useCallback(\n async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackEncodingBandwidth(\n encoding,\n bandwidth,\n );\n },\n [],\n );\n\n /**\n * Function to toggle camera on/off\n */\n const toggleCamera = useCallback(async () => {\n const state = await RNFishjamClientModule.toggleCamera();\n await RNFishjamClientModule.updateVideoTrackMetadata({\n active: state,\n type: 'camera',\n });\n setIsCameraOn(state);\n }, []);\n\n /**\n * Starts local camera capture.\n * @param config configuration of the camera capture\n * @returns A promise that resolves when camera is started.\n */\n\n const startCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const updatedConfig = updateCameraConfig(config);\n await RNFishjamClientModule.startCamera(updatedConfig);\n },\n [],\n );\n\n /**\n * Function that toggles between front and back camera. By default the front camera is used.\n * @returns A promise that resolves when camera is toggled.\n */\n const flipCamera = useCallback(async () => {\n await RNFishjamClientModule.flipCamera();\n }, []);\n\n /**\n * Function that switches to the specified camera. By default the front camera is used.\n * @returns A promise that resolves when camera is switched.\n */\n const switchCamera = useCallback(async (captureDeviceId: CaptureDeviceId) => {\n await RNFishjamClientModule.switchCamera(captureDeviceId);\n }, []);\n\n /** Function that queries available cameras.\n * @returns A promise that resolves to the list of available cameras.\n */\n const getCaptureDevices = useCallback(async () => {\n return RNFishjamClientModule.getCaptureDevices();\n }, []);\n\n /**\n * updates maximum bandwidth for the video track. This value directly translates\n * to quality of the stream and the amount of RTP packets being sent. In case simulcast\n * is enabled bandwidth is split between all of the variant streams proportionally to\n * their resolution.\n * @param BandwidthLimit to set\n */\n const setVideoTrackBandwidth = useCallback(\n async (bandwidth: BandwidthLimit) => {\n await RNFishjamClientModule.setVideoTrackBandwidth(bandwidth);\n },\n [],\n );\n\n return {\n isCameraOn,\n simulcastConfig,\n toggleCamera,\n startCamera,\n flipCamera,\n switchCamera,\n getCaptureDevices,\n toggleVideoTrackEncoding,\n setVideoTrackEncodingBandwidth,\n setVideoTrackBandwidth,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMicrophone.d.ts","sourceRoot":"","sources":["../../src/hooks/useMicrophone.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,aAAa;;;EA2B5B"}
|