@voltkit-rtc/react-native 0.0.0-stage → 0.1.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/CHANGELOG.md +121 -0
- package/LICENSE +21 -0
- package/README.md +1608 -2
- package/android/build.gradle +70 -0
- package/android/consumer-rules.pro +21 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/AppVisibility.kt +67 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/AudioDevices.kt +67 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/AudioRouter.kt +487 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/CallServiceTypes.kt +120 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/NativeTimers.kt +106 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/NetworkWatch.kt +120 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/OutputChoice.kt +65 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/RtcConfig.kt +83 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/ScoLink.kt +61 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitCallService.kt +287 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcInitProvider.kt +215 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcModule.kt +313 -0
- package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcPackage.kt +30 -0
- package/android/src/main/res/drawable/voltkit_rtc_default_call_icon.xml +15 -0
- package/android/src/main/res/raw/voltkit_rtc_keep.xml +7 -0
- package/app.plugin.js +17 -0
- package/lib/commonjs/audio.js +215 -0
- package/lib/commonjs/audio.js.map +1 -0
- package/lib/commonjs/components.js +207 -0
- package/lib/commonjs/components.js.map +1 -0
- package/lib/commonjs/create-client.js +47 -0
- package/lib/commonjs/create-client.js.map +1 -0
- package/lib/commonjs/errors.js +99 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/globals.js +61 -0
- package/lib/commonjs/globals.js.map +1 -0
- package/lib/commonjs/index.js +234 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/local-media.js +392 -0
- package/lib/commonjs/local-media.js.map +1 -0
- package/lib/commonjs/native-session.js +365 -0
- package/lib/commonjs/native-session.js.map +1 -0
- package/lib/commonjs/native.js +99 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permissions.js +166 -0
- package/lib/commonjs/permissions.js.map +1 -0
- package/lib/commonjs/platform/android.js +126 -0
- package/lib/commonjs/platform/android.js.map +1 -0
- package/lib/commonjs/platform/common.js +138 -0
- package/lib/commonjs/platform/common.js.map +1 -0
- package/lib/commonjs/platform/devices.js +151 -0
- package/lib/commonjs/platform/devices.js.map +1 -0
- package/lib/commonjs/platform/index.js +35 -0
- package/lib/commonjs/platform/index.js.map +1 -0
- package/lib/commonjs/platform/ios.js +54 -0
- package/lib/commonjs/platform/ios.js.map +1 -0
- package/lib/commonjs/platform/streams.js +273 -0
- package/lib/commonjs/platform/streams.js.map +1 -0
- package/lib/commonjs/platform/timers.js +71 -0
- package/lib/commonjs/platform/timers.js.map +1 -0
- package/lib/commonjs/platform/visibility.js +60 -0
- package/lib/commonjs/platform/visibility.js.map +1 -0
- package/lib/commonjs/preflight.js +77 -0
- package/lib/commonjs/preflight.js.map +1 -0
- package/lib/commonjs/provider.js +75 -0
- package/lib/commonjs/provider.js.map +1 -0
- package/lib/commonjs/specs/NativeVoltkitRtc.js +29 -0
- package/lib/commonjs/specs/NativeVoltkitRtc.js.map +1 -0
- package/lib/module/audio.js +207 -0
- package/lib/module/audio.js.map +1 -0
- package/lib/module/components.js +200 -0
- package/lib/module/components.js.map +1 -0
- package/lib/module/create-client.js +42 -0
- package/lib/module/create-client.js.map +1 -0
- package/lib/module/errors.js +87 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/globals.js +53 -0
- package/lib/module/globals.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/local-media.js +387 -0
- package/lib/module/local-media.js.map +1 -0
- package/lib/module/native-session.js +360 -0
- package/lib/module/native-session.js.map +1 -0
- package/lib/module/native.js +87 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions.js +160 -0
- package/lib/module/permissions.js.map +1 -0
- package/lib/module/platform/android.js +122 -0
- package/lib/module/platform/android.js.map +1 -0
- package/lib/module/platform/common.js +128 -0
- package/lib/module/platform/common.js.map +1 -0
- package/lib/module/platform/devices.js +142 -0
- package/lib/module/platform/devices.js.map +1 -0
- package/lib/module/platform/index.js +24 -0
- package/lib/module/platform/index.js.map +1 -0
- package/lib/module/platform/ios.js +49 -0
- package/lib/module/platform/ios.js.map +1 -0
- package/lib/module/platform/streams.js +268 -0
- package/lib/module/platform/streams.js.map +1 -0
- package/lib/module/platform/timers.js +67 -0
- package/lib/module/platform/timers.js.map +1 -0
- package/lib/module/platform/visibility.js +54 -0
- package/lib/module/platform/visibility.js.map +1 -0
- package/lib/module/preflight.js +72 -0
- package/lib/module/preflight.js.map +1 -0
- package/lib/module/provider.js +70 -0
- package/lib/module/provider.js.map +1 -0
- package/lib/module/specs/NativeVoltkitRtc.js +37 -0
- package/lib/module/specs/NativeVoltkitRtc.js.map +1 -0
- package/lib/typescript/commonjs/audio.d.ts +58 -0
- package/lib/typescript/commonjs/audio.d.ts.map +1 -0
- package/lib/typescript/commonjs/components.d.ts +58 -0
- package/lib/typescript/commonjs/components.d.ts.map +1 -0
- package/lib/typescript/commonjs/create-client.d.ts +35 -0
- package/lib/typescript/commonjs/create-client.d.ts.map +1 -0
- package/lib/typescript/commonjs/errors.d.ts +34 -0
- package/lib/typescript/commonjs/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/globals.d.ts +16 -0
- package/lib/typescript/commonjs/globals.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +24 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/local-media.d.ts +86 -0
- package/lib/typescript/commonjs/local-media.d.ts.map +1 -0
- package/lib/typescript/commonjs/native-session.d.ts +38 -0
- package/lib/typescript/commonjs/native-session.d.ts.map +1 -0
- package/lib/typescript/commonjs/native.d.ts +18 -0
- package/lib/typescript/commonjs/native.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permissions.d.ts +30 -0
- package/lib/typescript/commonjs/permissions.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/android.d.ts +4 -0
- package/lib/typescript/commonjs/platform/android.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/common.d.ts +101 -0
- package/lib/typescript/commonjs/platform/common.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/devices.d.ts +42 -0
- package/lib/typescript/commonjs/platform/devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/index.d.ts +6 -0
- package/lib/typescript/commonjs/platform/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/ios.d.ts +4 -0
- package/lib/typescript/commonjs/platform/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/streams.d.ts +82 -0
- package/lib/typescript/commonjs/platform/streams.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/timers.d.ts +19 -0
- package/lib/typescript/commonjs/platform/timers.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/visibility.d.ts +11 -0
- package/lib/typescript/commonjs/platform/visibility.d.ts.map +1 -0
- package/lib/typescript/commonjs/preflight.d.ts +19 -0
- package/lib/typescript/commonjs/preflight.d.ts.map +1 -0
- package/lib/typescript/commonjs/provider.d.ts +35 -0
- package/lib/typescript/commonjs/provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/NativeVoltkitRtc.d.ts +157 -0
- package/lib/typescript/commonjs/specs/NativeVoltkitRtc.d.ts.map +1 -0
- package/lib/typescript/module/audio.d.ts +58 -0
- package/lib/typescript/module/audio.d.ts.map +1 -0
- package/lib/typescript/module/components.d.ts +58 -0
- package/lib/typescript/module/components.d.ts.map +1 -0
- package/lib/typescript/module/create-client.d.ts +35 -0
- package/lib/typescript/module/create-client.d.ts.map +1 -0
- package/lib/typescript/module/errors.d.ts +34 -0
- package/lib/typescript/module/errors.d.ts.map +1 -0
- package/lib/typescript/module/globals.d.ts +16 -0
- package/lib/typescript/module/globals.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +24 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/local-media.d.ts +86 -0
- package/lib/typescript/module/local-media.d.ts.map +1 -0
- package/lib/typescript/module/native-session.d.ts +38 -0
- package/lib/typescript/module/native-session.d.ts.map +1 -0
- package/lib/typescript/module/native.d.ts +18 -0
- package/lib/typescript/module/native.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permissions.d.ts +30 -0
- package/lib/typescript/module/permissions.d.ts.map +1 -0
- package/lib/typescript/module/platform/android.d.ts +4 -0
- package/lib/typescript/module/platform/android.d.ts.map +1 -0
- package/lib/typescript/module/platform/common.d.ts +101 -0
- package/lib/typescript/module/platform/common.d.ts.map +1 -0
- package/lib/typescript/module/platform/devices.d.ts +42 -0
- package/lib/typescript/module/platform/devices.d.ts.map +1 -0
- package/lib/typescript/module/platform/index.d.ts +6 -0
- package/lib/typescript/module/platform/index.d.ts.map +1 -0
- package/lib/typescript/module/platform/ios.d.ts +4 -0
- package/lib/typescript/module/platform/ios.d.ts.map +1 -0
- package/lib/typescript/module/platform/streams.d.ts +82 -0
- package/lib/typescript/module/platform/streams.d.ts.map +1 -0
- package/lib/typescript/module/platform/timers.d.ts +19 -0
- package/lib/typescript/module/platform/timers.d.ts.map +1 -0
- package/lib/typescript/module/platform/visibility.d.ts +11 -0
- package/lib/typescript/module/platform/visibility.d.ts.map +1 -0
- package/lib/typescript/module/preflight.d.ts +19 -0
- package/lib/typescript/module/preflight.d.ts.map +1 -0
- package/lib/typescript/module/provider.d.ts +35 -0
- package/lib/typescript/module/provider.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeVoltkitRtc.d.ts +157 -0
- package/lib/typescript/module/specs/NativeVoltkitRtc.d.ts.map +1 -0
- package/package.json +140 -4
- package/plugin/build/android.d.ts +36 -0
- package/plugin/build/android.js +265 -0
- package/plugin/build/index.d.ts +9 -0
- package/plugin/build/index.js +54 -0
- package/plugin/build/ios.d.ts +4 -0
- package/plugin/build/ios.js +43 -0
- package/plugin/build/options.d.ts +93 -0
- package/plugin/build/options.js +140 -0
- package/react-native.config.js +11 -0
- package/src/audio.ts +221 -0
- package/src/components.tsx +233 -0
- package/src/create-client.ts +53 -0
- package/src/errors.ts +81 -0
- package/src/globals.ts +54 -0
- package/src/index.ts +95 -0
- package/src/local-media.ts +420 -0
- package/src/native-session.tsx +384 -0
- package/src/native.ts +84 -0
- package/src/permissions.ts +173 -0
- package/src/platform/android.ts +128 -0
- package/src/platform/common.ts +157 -0
- package/src/platform/devices.ts +148 -0
- package/src/platform/index.ts +22 -0
- package/src/platform/ios.ts +48 -0
- package/src/platform/streams.ts +285 -0
- package/src/platform/timers.ts +72 -0
- package/src/platform/visibility.ts +59 -0
- package/src/preflight.ts +60 -0
- package/src/provider.tsx +88 -0
- package/src/specs/NativeVoltkitRtc.ts +180 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_globals","_errors","ANDROID","camera","microphone","notifications","unique","kinds","Set","notificationsNeedAsking","Platform","OS","Number","Version","requestMediaPermissions","wanted","out","length","ask","filter","k","kind","includes","results","PermissionsAndroid","requestMultiple","map","err","logError","androidStatus","requestIos","checkMediaPermissions","check","queryIos","result","webrtc","loadWebRTC","permissions","query","name","now","request","usePermissions","key","sort","join","useMemo","split","statuses","setStatuses","useState","live","useRef","refresh","useCallback","next","current","previous","same","useEffect","subscription","AppState","addEventListener","state","remove","granted","every","a","b","keys","Object"],"sour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B,KAAKH,OAAO,CAAC,CAAC;IACd,MAAMO,YAAY,GAAGC,qBAAQ,CAACC,gBAAgB,CAAC,QAAQ,EAAGC,KAAK,IAAK;MAClE,IAAIA,KAAK,KAAK,QAAQ,EAAE,KAAKV,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;IACF,OAAO,MAAM;MACXF,IAAI,CAACK,OAAO,GAAG,KAAK;MACpBI,YAAY,EAAEI,MAAM,CAAC,CAAC;IACxB,CAAC;EACH,CAAC,EAAE,CAACX,OAAO,CAAC,CAAC;EAEb,MAAMY,OAAO,GAAGjB,QAAQ,KAAK,IAAI,IAAIjC,MAAM,CAACmD,KAAK,CAAE9C,CAAC,IAAK4B,QAAQ,CAAC5B,CAAC,CAAC,KAAK,SAAS,CAAC;EACnF,OAAO,IAAA0B,cAAO,EAAC,OAAO;IAAEE,QAAQ;IAAEiB,OAAO;IAAExB,OAAO;IAAEY;EAAQ,CAAC,CAAC,EAAE,CAACL,QAAQ,EAAEiB,OAAO,EAAExB,OAAO,EAAEY,OAAO,CAAC,CAAC;AACxG;AAEA,SAASK,IAAIA,CAA2BS,CAA+B,EAAEC,CAAwB,EAAW;EAC1G,IAAI,CAACD,CAAC,EAAE,OAAO,KAAK;EACpB,MAAME,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,CAAC,CAAQ;EAClC,OAAOC,IAAI,CAACpD,MAAM,KAAKqD,MAAM,CAACD,IAAI,CAACF,CAAC,CAAC,CAAClD,MAAM,IAAIoD,IAAI,CAACH,KAAK,CAAE9C,CAAC,IAAK+C,CAAC,CAAC/C,CAAC,CAAC,KAAKgD,CAAC,CAAChD,CAAC,CAAC,CAAC;AAClF","ignoreList":[]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.androidPlatform = androidPlatform;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _client = require("@voltkit-rtc/client");
|
|
9
|
+
var _native = require("../native.js");
|
|
10
|
+
var _globals = require("../globals.js");
|
|
11
|
+
var _errors = require("../errors.js");
|
|
12
|
+
var _common = require("./common.js");
|
|
13
|
+
var _devices = require("./devices.js");
|
|
14
|
+
var _streams = require("./streams.js");
|
|
15
|
+
var _timers = require("./timers.js");
|
|
16
|
+
var _visibility = require("./visibility.js");
|
|
17
|
+
/**
|
|
18
|
+
* The client's platform on Android (ClientPlatform, @voltkit-rtc/client 0.9.12): react-native-webrtc for capture and
|
|
19
|
+
* streams, this package's native module for everything a browser gets from the DOM -- timers that keep running in the
|
|
20
|
+
* background and with the screen off, visibility from the process lifecycle, the network coming back, audio routing,
|
|
21
|
+
* audio focus, and stopping react-native-webrtc's screen-share service. Without the native module (Expo Go, an app not
|
|
22
|
+
* rebuilt) it falls back to JavaScript timers and AppState, routes nothing, and refuses screen sharing.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** The network came back (a native callback) or the app came back to the front: the client checks its socket. */
|
|
26
|
+
function onOnline(module, visibility, listener) {
|
|
27
|
+
const stops = [module ? (0, _native.listen)(module.onNetworkAvailable, 'onNetworkAvailable', () => listener()) : () => undefined, visibility.subscribe(visible => {
|
|
28
|
+
if (visible) listener();
|
|
29
|
+
})];
|
|
30
|
+
return () => {
|
|
31
|
+
for (const stop of stops) stop();
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The system took the microphone (a phone call took audio focus, or the audio device module could not record) and
|
|
37
|
+
* gave it back (focus regained). Cameras: react-native-webrtc ends the track instead, which the client handles.
|
|
38
|
+
*/
|
|
39
|
+
function onInterruption(module, kind, listener) {
|
|
40
|
+
if (kind !== 'mic') return () => undefined;
|
|
41
|
+
const stops = [(0, _native.listen)(module.onAudioFocusChanged, 'onAudioFocusChanged', ({
|
|
42
|
+
focus
|
|
43
|
+
}) => {
|
|
44
|
+
if (focus === 'loss' || focus === 'lossTransient') listener(true);else if (focus === 'gain') listener(false);
|
|
45
|
+
}), (0, _native.listen)(module.onMicrophoneError, 'onMicrophoneError', () => listener(true))];
|
|
46
|
+
return () => {
|
|
47
|
+
for (const stop of stops) stop();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Share the screen through react-native-webrtc's MediaProjection flow (ClientPlatform.getDisplayMedia). It needs its
|
|
53
|
+
* foreground service, which the init provider turns on from the manifest's meta-data (the Expo plugin's
|
|
54
|
+
* android.screenShare): without it Android refuses the projection, so `screen-share-service-required`. A refused
|
|
55
|
+
* consent is `screen-share-denied`.
|
|
56
|
+
*/
|
|
57
|
+
async function getDisplayMedia(module) {
|
|
58
|
+
const webrtc = (0, _globals.loadWebRTC)();
|
|
59
|
+
if (!webrtc) throw (0, _errors.webrtcMissing)();
|
|
60
|
+
if (!module || !(0, _native.nativeConstants)()?.screenShareEnabled) {
|
|
61
|
+
throw new _client.RpcError('screen-share-service-required', "screen sharing needs react-native-webrtc's screen-share service: turn on the Expo plugin's android.screenShare option (meta-data in.voltkit.rtc.SCREEN_SHARE=true) and rebuild the app");
|
|
62
|
+
}
|
|
63
|
+
let stream;
|
|
64
|
+
try {
|
|
65
|
+
stream = await webrtc.mediaDevices.getDisplayMedia({});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
const text = (0, _errors.describeError)(err);
|
|
68
|
+
// The consent refused: react-native-webrtc starts its service only after the user allows the share.
|
|
69
|
+
if (/NotAllowedError/.test(text)) throw new _client.RpcError('screen-share-denied', 'the screen share was not allowed');
|
|
70
|
+
if (/Another operation is pending/.test(text)) throw new _client.RpcError('screen-share-active', 'a screen share is already starting');
|
|
71
|
+
// Allowed, but its MediaProjectionService did not start in time (react-native-webrtc gives up after 10 s) or the
|
|
72
|
+
// capture failed: the service may still be starting, with no share to stop it (finding 5). Stop it.
|
|
73
|
+
module.stopScreenShareService().catch(stopErr => (0, _errors.logError)('could not stop the screen-share service', stopErr));
|
|
74
|
+
throw new _client.RpcError('screen-share-failed', `the screen share could not start: ${text}`);
|
|
75
|
+
}
|
|
76
|
+
const book = (0, _streams.streamBook)();
|
|
77
|
+
book.adopt(stream, 'capture');
|
|
78
|
+
book.markScreen(stream);
|
|
79
|
+
return stream;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The Android platform. One per process (platform/index.ts). */
|
|
83
|
+
function androidPlatform() {
|
|
84
|
+
const module = (0, _native.nativeModule)();
|
|
85
|
+
const book = (0, _streams.streamBook)();
|
|
86
|
+
const timers = module ? (0, _timers.nativeTimers)(module) : _timers.jsTimers;
|
|
87
|
+
const visibility = module ? (0, _visibility.nativeVisibility)(module) : (0, _visibility.appStateVisibility)();
|
|
88
|
+
if (module) {
|
|
89
|
+
// react-native-webrtc stops its MediaProjectionService only when the screen track is released; stopTrack releases
|
|
90
|
+
// it, and this makes sure (Phase 0 finding 5).
|
|
91
|
+
book.onScreenStopped = () => {
|
|
92
|
+
module.stopScreenShareService().catch(err => (0, _errors.logError)('could not stop the screen-share service', err));
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const platform = {
|
|
96
|
+
name: 'react-native',
|
|
97
|
+
describe: _common.describePlatform,
|
|
98
|
+
getUserMedia: constraints => (0, _common.captureUserMedia)(constraints),
|
|
99
|
+
getDisplayMedia: () => getDisplayMedia(module),
|
|
100
|
+
enumerateDevices: kind => (0, _devices.enumerateDevices)(module, kind),
|
|
101
|
+
onDeviceChange: listener => (0, _devices.onDeviceChange)(module, listener),
|
|
102
|
+
switchCameraInPlace: (track, deviceId) => (0, _devices.switchCameraInPlace)(track, deviceId),
|
|
103
|
+
createStream: tracks => book.create(tracks),
|
|
104
|
+
releaseStream: stream => book.release(stream),
|
|
105
|
+
adoptAppStream: stream => book.adopt(stream, 'app'),
|
|
106
|
+
stopTrack: track => book.stop(track),
|
|
107
|
+
verifyReplaceTrack: true,
|
|
108
|
+
detachTracks: tracks => book.detach(tracks),
|
|
109
|
+
appVisible: () => visibility.visible(),
|
|
110
|
+
onAppVisibility: listener => visibility.subscribe(listener),
|
|
111
|
+
onOnline: listener => onOnline(module, visibility, listener),
|
|
112
|
+
pixelRatio: () => _reactNative.PixelRatio.get(),
|
|
113
|
+
deviceEnv: _common.deviceEnv,
|
|
114
|
+
encodingProbe: () => _common.hardwareH264,
|
|
115
|
+
simulcastTemporalLayers: 3,
|
|
116
|
+
remoteAudioLevels: 'stats',
|
|
117
|
+
audioLevelIntervalMs: 500,
|
|
118
|
+
timers
|
|
119
|
+
};
|
|
120
|
+
if (module) {
|
|
121
|
+
platform.routeAudio = (kind, deviceId) => (0, _devices.routeAudio)(module, kind, deviceId);
|
|
122
|
+
platform.onInterruption = (kind, listener) => onInterruption(module, kind, listener);
|
|
123
|
+
}
|
|
124
|
+
return platform;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_client","_native","_globals","_errors","_common","_devices","_streams","_timers","_visibility","onOnline","module","visibility","listener","stops","listen","onNetworkAvailable","undefined","subscribe","visible","stop","onInterruption","kind","onAudioFocusChanged","focus","onMicrophoneError","getDisplayMedia","webrtc","loadWebRTC","webrtcMissing","nativeConstants","screenShareEnabled","RpcError","stream","mediaDevices","err","text","describeError","test","stopScreenShareService","catch","stopErr","logError","book","streamBook","adopt","markScreen","androidPlatform","nativeModule","timers","nativeTimers","jsTimers","nativeVisibility","appStateVisibility","onScreenStopped","platform","name","describe","describePlatform","getUserMedia","constraints","captureUserMedia","enumerateDevices","onDeviceChange","switchCameraInPlace","track","deviceId","createStream","tracks","create","releaseStream","release","adoptAppStream","stopTrack","verifyReplaceTrack","detachTracks","detach","appVisible","onAppVisibility","pixelRatio","PixelRatio","get","deviceEnv","encodingProbe","hardwareH264","simulcastTemporalLayers","remoteAudioLevels","audioLevelIntervalMs","routeAudio"],"sourceRoot":"../../../src","sources":["platform/android.ts"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1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.captureUserMedia = captureUserMedia;
|
|
7
|
+
exports.describePlatform = describePlatform;
|
|
8
|
+
exports.deviceEnv = deviceEnv;
|
|
9
|
+
exports.hardwareH264 = void 0;
|
|
10
|
+
exports.kindsOf = kindsOf;
|
|
11
|
+
exports.localStream = localStream;
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
var _client = require("@voltkit-rtc/client");
|
|
14
|
+
var _globals = require("../globals.js");
|
|
15
|
+
var _native = require("../native.js");
|
|
16
|
+
var _errors = require("../errors.js");
|
|
17
|
+
var _permissions = require("../permissions.js");
|
|
18
|
+
var _streams = require("./streams.js");
|
|
19
|
+
/**
|
|
20
|
+
* What the Android platform and the iOS preview share: what getDiagnostics() says, capture through react-native-webrtc
|
|
21
|
+
* with the permissions checked first and its errors made registry errors, and the device's facts.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The DOM's media types as the client declares them. This package compiles without the DOM library (React Native has
|
|
26
|
+
* none), so they are taken from the client's own declarations rather than named.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `ClientPlatform.adoptAppStream` (optional in @voltkit-rtc/client 0.9.12; this platform always provides it): the
|
|
31
|
+
* client is taking tracks from `stream`, a stream the app gave it (`publish(stream)`, `publishScreen({ stream })`),
|
|
32
|
+
* and will stop and release those tracks but never the stream, which is the app's. This platform then takes each track
|
|
33
|
+
* out of that stream before releasing it, so the app can release its stream after unpublish() or close() without
|
|
34
|
+
* react-native-webrtc 155 killing the app (Phase 0 finding 1). useLocalMedia().publish() is safe either way (its
|
|
35
|
+
* capture is made and released here).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The settings a track reports: react-native-webrtc's `MediaTrackSettings` (the web's has these fields too). A camera
|
|
40
|
+
* says its `width`, `height`, `frameRate`, `facingMode` (`'user'` or `'environment'`) and `deviceId`.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A media track by shape: react-native-webrtc's `MediaStreamTrack`, which every track this package hands out is
|
|
45
|
+
* (`useLocalMedia().stream?.getVideoTracks()[0]`), and the web's `MediaStreamTrack` as `@voltkit-rtc/client` types a
|
|
46
|
+
* remote track's `track`, which fits the same shape, so either goes into `VideoTrack` and `AudioTrack` as it is. Typed by
|
|
47
|
+
* shape so an app compiles without the DOM library (`@react-native/typescript-config` leaves it out, and the only
|
|
48
|
+
* `MediaStream` it then knows is an empty stub). `remote` and `release` are react-native-webrtc's: a received track, and
|
|
49
|
+
* freeing the native track, which the SDK does for its own tracks.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A media stream by shape: react-native-webrtc's `MediaStream`, which `useLocalMedia().stream` and `screenStream`
|
|
54
|
+
* are. Typed by shape for the same reason as `MediaStreamTrackLike`. `toURL()` is what an `RTCView` plays (`VideoTrack`
|
|
55
|
+
* does this), and `release()` frees the native stream: never call it on a stream the SDK made (see `VideoTrack`).
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/** The client's own stream (`client.local`), typed as react-native-webrtc's. */
|
|
59
|
+
function localStream(client) {
|
|
60
|
+
return client.local ?? null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** getDiagnostics().userAgent: `ReactNative android 37; react-native-webrtc 155.0.1; @voltkit-rtc/react-native 0.1.1`. */
|
|
64
|
+
function describePlatform() {
|
|
65
|
+
return `ReactNative ${_reactNative.Platform.OS} ${String(_reactNative.Platform.Version)}; react-native-webrtc ${(0, _globals.webrtcVersion)() ?? 'unknown'}; @voltkit-rtc/react-native ${_native.SDK_VERSION}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* What the client reads to pick its defaults: a phone or tablet, so two simulcast layers and the H.264 decision
|
|
70
|
+
* (there is no user agent in React Native, which gave phones a computer's three layers).
|
|
71
|
+
*/
|
|
72
|
+
function deviceEnv() {
|
|
73
|
+
const device = _reactNative.Platform.OS === 'ios' ? _reactNative.Platform.isPad ? 'iPad' : 'iPhone' : 'Android';
|
|
74
|
+
return {
|
|
75
|
+
userAgent: `ReactNative ${device} ${String(_reactNative.Platform.Version)}; Mobile`,
|
|
76
|
+
uaMobile: true,
|
|
77
|
+
maxTouchPoints: 5
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether H.264 is encoded in hardware, asked only for a phone whose WebRTC can send H.264 at all. On Android
|
|
83
|
+
* react-native-webrtc's libwebrtc has no software H.264 encoder (the emulator, without a hardware one, offers none), so
|
|
84
|
+
* a device that offers it encodes it in hardware: 'auto' then sends H.264, as the Android SDK does.
|
|
85
|
+
*/
|
|
86
|
+
const hardwareH264 = async () => ({
|
|
87
|
+
supported: true,
|
|
88
|
+
smooth: true,
|
|
89
|
+
powerEfficient: true
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/** The kinds a capture asks for, as permissions. */
|
|
93
|
+
exports.hardwareH264 = hardwareH264;
|
|
94
|
+
function kindsOf(constraints) {
|
|
95
|
+
const kinds = [];
|
|
96
|
+
if (constraints.video) kinds.push('camera');
|
|
97
|
+
if (constraints.audio) kinds.push('microphone');
|
|
98
|
+
return kinds;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Capture a camera and/or microphone through react-native-webrtc (ClientPlatform.getUserMedia). The permissions are
|
|
103
|
+
* checked first, without asking (a reconnect in the background must not open a dialog): one not granted rejects with
|
|
104
|
+
* `media-unavailable` `{ permission, status }` and nothing opens. react-native-webrtc drops a kind whose permission was
|
|
105
|
+
* refused without an error, so a stream missing a kind asked for is released and refused the same way. The stream is
|
|
106
|
+
* kept in the book, so it is released once its tracks are stopped.
|
|
107
|
+
*/
|
|
108
|
+
async function captureUserMedia(constraints) {
|
|
109
|
+
const webrtc = (0, _globals.loadWebRTC)();
|
|
110
|
+
if (!webrtc) throw (0, _errors.webrtcMissing)();
|
|
111
|
+
const kinds = kindsOf(constraints);
|
|
112
|
+
const statuses = await (0, _permissions.checkMediaPermissions)(kinds);
|
|
113
|
+
for (const kind of kinds) {
|
|
114
|
+
const status = statuses[kind];
|
|
115
|
+
if (status !== 'granted') throw (0, _errors.permissionRefused)(kind, status === 'blocked' ? 'blocked' : 'denied');
|
|
116
|
+
}
|
|
117
|
+
let stream;
|
|
118
|
+
try {
|
|
119
|
+
stream = await webrtc.mediaDevices.getUserMedia(constraints);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const name = err?.name;
|
|
122
|
+
if (name === 'SecurityError' || name === 'NotAllowedError') throw (0, _errors.permissionRefused)(kinds[0] ?? 'camera', 'denied');
|
|
123
|
+
throw new _client.RpcError('media-unavailable', `could not open the ${kinds.join(' and ')}: ${(0, _errors.describeError)(err)}`, {
|
|
124
|
+
reason: typeof name === 'string' ? name : 'capture-failed'
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const book = (0, _streams.streamBook)();
|
|
128
|
+
book.adopt(stream, 'capture');
|
|
129
|
+
const missing = constraints.video && stream.getVideoTracks().length === 0 ? 'camera' : constraints.audio && stream.getAudioTracks().length === 0 ? 'microphone' : null;
|
|
130
|
+
if (missing) {
|
|
131
|
+
const tracks = stream.getTracks();
|
|
132
|
+
book.release(stream);
|
|
133
|
+
for (const track of tracks) book.stop(track);
|
|
134
|
+
throw (0, _errors.permissionRefused)(missing, 'denied');
|
|
135
|
+
}
|
|
136
|
+
return stream;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_client","_globals","_native","_errors","_permissions","_streams","localStream","client","local","describePlatform","Platform","OS","String","Version","webrtcVersion","SDK_VERSION","deviceEnv","device","isPad","userAgent","uaMobile","maxTouchPoints","hardwareH264","supported","smooth","powerEfficient","exports","kindsOf","constraints","kinds","video","push","audio","captureUserMedia","webrtc","loadWebRTC","webrtcMissing","statuses","checkMediaPermissions","kind","status","permissionRefused","stream","mediaDevices","getUserMedia","err","name","RpcError","join","describeError","reason","book","streamBook","adopt","missing","getVideoTracks","length","getAudioTracks","tracks","getTracks","release","track","stop"],"sourceRoot":"../../../src","sources":["platform/common.ts"],"mappings":";;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAVA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAaA;AACO,SAASO,WAAWA,CAACC,MAAmC,EAA0B;EACvF,OAAQA,MAAM,CAACC,KAAK,IAA2C,IAAI;AACrE;;AAEA;AACO,SAASC,gBAAgBA,CAAA,EAAW;EACzC,OAAO,eAAeC,qBAAQ,CAACC,EAAE,IAAIC,MAAM,CAACF,qBAAQ,CAACG,OAAO,CAAC,yBAAyB,IAAAC,sBAAa,EAAC,CAAC,IAAI,SAAS,+BAA+BC,mBAAW,EAAE;AAChK;;AAEA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAA,EAAc;EACrC,MAAMC,MAAM,GAAGP,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAKD,qBAAQ,CAAyBQ,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAI,SAAS;EAChH,OAAO;IAAEC,SAAS,EAAE,eAAeF,MAAM,IAAIL,MAAM,CAAC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6
|
+
exports.enumerateDevices = enumerateDevices;
|
|
7
|
+
exports.listCameras = listCameras;
|
|
8
|
+
exports.onDeviceChange = onDeviceChange;
|
|
9
|
+
exports.routeAudio = routeAudio;
|
|
10
|
+
exports.switchCameraInPlace = switchCameraInPlace;
|
|
11
|
+
var _client = require("@voltkit-rtc/client");
|
|
12
|
+
var _globals = require("../globals.js");
|
|
13
|
+
var _native = require("../native.js");
|
|
14
|
+
var _errors = require("../errors.js");
|
|
15
|
+
/**
|
|
16
|
+
* Cameras, microphones and audio outputs.
|
|
17
|
+
*
|
|
18
|
+
* Cameras come from react-native-webrtc (ids "0", "1", ... with a facing), named as the Android SDK names them ("Front
|
|
19
|
+
* camera", "Back camera 2"). On Android the audio devices come from this package's audio router (speaker, earpiece,
|
|
20
|
+
* wired and USB headsets, Bluetooth, each with its `type`), which also routes sound and picks the microphone natively;
|
|
21
|
+
* without the native module, and on iOS, from react-native-webrtc's list.
|
|
22
|
+
*
|
|
23
|
+
* A camera is switched on its own track (react-native-webrtc's applyConstraints with the deviceId): the same track and
|
|
24
|
+
* producer, so nothing can fail half-way. react-native-webrtc falls back to the facing mode, without an error, for an
|
|
25
|
+
* id it does not know, so the id is checked against the list first (`bad-params`) and the camera it ended up on is
|
|
26
|
+
* checked after (`camera-failed`); the old camera keeps capturing either way.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** react-native-webrtc's own list: cameras with a facing, one microphone on Android. */
|
|
30
|
+
async function webrtcDevices() {
|
|
31
|
+
const webrtc = (0, _globals.loadWebRTC)();
|
|
32
|
+
if (!webrtc) return [];
|
|
33
|
+
try {
|
|
34
|
+
const list = await webrtc.mediaDevices.enumerateDevices();
|
|
35
|
+
return Array.isArray(list) ? list : [];
|
|
36
|
+
} catch (err) {
|
|
37
|
+
(0, _errors.logError)('could not list the cameras', err);
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const FACING_ORDER = {
|
|
42
|
+
front: 0,
|
|
43
|
+
back: 1,
|
|
44
|
+
external: 2
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** The cameras, front ones first, labelled as the Android SDK labels them. */
|
|
48
|
+
async function listCameras() {
|
|
49
|
+
const cameras = (await webrtcDevices()).filter(d => d.kind === 'videoinput' && typeof d.deviceId === 'string');
|
|
50
|
+
let fronts = 0;
|
|
51
|
+
let backs = 0;
|
|
52
|
+
const named = cameras.map(d => {
|
|
53
|
+
const facing = d.facing === 'front' || d.facing === 'user' ? 'front' : d.facing === 'environment' || d.facing === 'back' ? 'back' : 'external';
|
|
54
|
+
let label;
|
|
55
|
+
if (facing === 'front') label = (fronts += 1) === 1 ? 'Front camera' : `Front camera ${fronts}`;else if (facing === 'back') label = (backs += 1) === 1 ? 'Back camera' : `Back camera ${backs}`;else label = 'External camera';
|
|
56
|
+
return {
|
|
57
|
+
deviceId: d.deviceId,
|
|
58
|
+
groupId: typeof d.groupId === 'string' ? d.groupId : '',
|
|
59
|
+
kind: 'videoinput',
|
|
60
|
+
label,
|
|
61
|
+
facing
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return named.sort((a, b) => FACING_ORDER[a.facing ?? 'external'] - FACING_ORDER[b.facing ?? 'external']);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Audio devices from react-native-webrtc (iOS, or Android without the native module). */
|
|
68
|
+
async function webrtcAudio() {
|
|
69
|
+
return (await webrtcDevices()).filter(d => (d.kind === 'audioinput' || d.kind === 'audiooutput') && typeof d.deviceId === 'string').map(d => ({
|
|
70
|
+
deviceId: d.deviceId,
|
|
71
|
+
groupId: typeof d.groupId === 'string' ? d.groupId : '',
|
|
72
|
+
kind: d.kind,
|
|
73
|
+
label: typeof d.label === 'string' ? d.label : '',
|
|
74
|
+
...(d.kind === 'audioinput' ? {
|
|
75
|
+
type: 'builtinMic'
|
|
76
|
+
} : {})
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Audio devices from the audio router (Android). */
|
|
81
|
+
async function nativeAudio(module) {
|
|
82
|
+
try {
|
|
83
|
+
return (await module.listAudioDevices()).map(_native.toMediaDevice);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
(0, _errors.logError)('could not list the audio devices', err);
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Every device, or those of one kind (ClientPlatform.enumerateDevices). */
|
|
91
|
+
async function enumerateDevices(module, kind) {
|
|
92
|
+
const wantCameras = kind === undefined || kind === 'videoinput';
|
|
93
|
+
const wantAudio = kind === undefined || kind !== 'videoinput';
|
|
94
|
+
const [cameras, audio] = await Promise.all([wantCameras ? listCameras() : Promise.resolve([]), wantAudio ? module ? nativeAudio(module) : webrtcAudio() : Promise.resolve([])]);
|
|
95
|
+
const all = [...audio, ...cameras];
|
|
96
|
+
return kind === undefined ? all : all.filter(d => d.kind === kind);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Hear audio devices come and go (Android's router); cameras cannot be watched. */
|
|
100
|
+
function onDeviceChange(module, listener) {
|
|
101
|
+
if (!module) return null;
|
|
102
|
+
return (0, _native.listen)(module.onAudioDevicesChanged, 'onAudioDevicesChanged', () => listener());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Route sound to an output, or record from a microphone, natively (ClientPlatform.routeAudio). Outputs: true when
|
|
107
|
+
* routed, false when it cannot be chosen (the client then rejects with `bad-params`). Microphones: true when the audio
|
|
108
|
+
* device module records from it now; `bad-params` for one the router does not list; false (the client captures it)
|
|
109
|
+
* where the module cannot choose.
|
|
110
|
+
*/
|
|
111
|
+
async function routeAudio(module, kind, deviceId) {
|
|
112
|
+
if (kind === 'audioinput') {
|
|
113
|
+
const inputs = (await nativeAudio(module)).filter(d => d.kind === 'audioinput');
|
|
114
|
+
if (!inputs.some(d => d.deviceId === deviceId)) {
|
|
115
|
+
throw new _client.RpcError('bad-params', `switchDevice: there is no microphone with the id ${deviceId}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
return await (kind === 'audiooutput' ? module.selectAudioOutput(deviceId) : module.selectAudioInput(deviceId));
|
|
120
|
+
} catch (err) {
|
|
121
|
+
// The router's own failure (a TurboModule rejection is a plain Error): a registry error for the app.
|
|
122
|
+
throw (0, _errors.nativeFailure)(err);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** react-native-webrtc's camera track, as far as switching needs it. */
|
|
127
|
+
|
|
128
|
+
/** Turn the camera behind `track` to `deviceId`, on the same track (ClientPlatform.switchCameraInPlace). */
|
|
129
|
+
async function switchCameraInPlace(track, deviceId) {
|
|
130
|
+
if (track.kind !== 'video') throw new _client.RpcError('bad-params', 'switchDevice: that track is not a camera');
|
|
131
|
+
const cameras = await listCameras();
|
|
132
|
+
const target = cameras.find(c => c.deviceId === deviceId);
|
|
133
|
+
if (!target) throw new _client.RpcError('bad-params', `switchDevice: there is no camera with the id ${deviceId}`);
|
|
134
|
+
if (track.getSettings().deviceId === deviceId) return;
|
|
135
|
+
const constraints = {
|
|
136
|
+
...track.getConstraints(),
|
|
137
|
+
deviceId
|
|
138
|
+
};
|
|
139
|
+
// react-native-webrtc keeps the facing it has when none is given; the target's matches the id it is given.
|
|
140
|
+
if (target.facing === 'front' || target.facing === 'back') constraints.facingMode = target.facing === 'front' ? 'user' : 'environment';
|
|
141
|
+
try {
|
|
142
|
+
await track.applyConstraints(constraints);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
throw new _client.RpcError('camera-failed', `could not switch to camera ${deviceId}: ${(0, _errors.describeError)(err)}`);
|
|
145
|
+
}
|
|
146
|
+
const now = track.getSettings().deviceId;
|
|
147
|
+
if (now !== deviceId) {
|
|
148
|
+
throw new _client.RpcError('camera-failed', `the camera did not switch to ${deviceId}${typeof now === 'string' ? ` (it is still ${now})` : ''}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_client","require","_globals","_native","_errors","webrtcDevices","webrtc","loadWebRTC","list","mediaDevices","enumerateDevices","Array","isArray","err","logError","FACING_ORDER","front","back","external","listCameras","cameras","filter","d","kind","deviceId","fronts","backs","named","map","facing","label","groupId","sort","a","b","webrtcAudio","type","nativeAudio","module","listAudioDevices","toMediaDevice","wantCameras","undefined","wantAudio","audio","Promise","all","resolve","onDeviceChange","listener","listen","onAudioDevicesChanged","routeAudio","inputs","some","RpcError","selectAudioOutput","selectAudioInput","nativeFailure","switchCameraInPlace","track","target","find","c","getSettings","constraints","getConstraints","facingMode","applyConstraints","describeError","now"],"sourceRoot":"../../../src","sources":["platform/devices.ts"],"mappings":";;;;;;;;;;AAaA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA,eAAeI,aAAaA,CAAA,EAA4B;EACtD,MAAMC,MAAM,GAAG,IAAAC,mBAAU,EAAC,CAAC;EAC3B,IAAI,CAACD,MAAM,EAAE,OAAO,EAAE;EACtB,IAAI;IACF,MAAME,IAAI,GAAI,MAAMF,MAAM,CAACG,YAAY,CAACC,gBAAgB,CAAC,CAAa;IACtE,OAAOC,KAAK,CAACC,OAAO,CAACJ,IAAI,CAAC,GAAIA,IAAI,GAAsB,EAAE;EAC5D,CAAC,CAAC,OAAOK,GAAG,EAAE;IACZ,IAAAC,gBAAQ,EAAC,4BAA4B,EAAED,GAAG,CAAC;IAC3C,OAAO,EAAE;EACX;AACF;AAEA,MAAME,YAA0C,GAAG;EAAEC,KAAK,EAAE,CAAC;EAAEC,IAAI,EAAE,CAAC;EAAEC,QAAQ,EAAE;AAAE,CAAC;;AAErF;AACO,eAAeC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I,WAAW,CAAC,CAAC,CAACxC,QAAQ;EACxC,IAAI8C,GAAG,KAAK9C,QAAQ,EAAE;IACpB,MAAM,IAAI+B,gBAAQ,CAAC,eAAe,EAAE,gCAAgC/B,QAAQ,GAAG,OAAO8C,GAAG,KAAK,QAAQ,GAAG,iBAAiBA,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC;EAC1I;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reactNativePlatform = reactNativePlatform;
|
|
7
|
+
Object.defineProperty(exports, "streamBook", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _streams.streamBook;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _reactNative = require("react-native");
|
|
14
|
+
var _android = require("./android.js");
|
|
15
|
+
var _ios = require("./ios.js");
|
|
16
|
+
var _streams = require("./streams.js");
|
|
17
|
+
/**
|
|
18
|
+
* The React Native platform for @voltkit-rtc/client (ClientOptions.platform): one per process, for every client, view
|
|
19
|
+
* and hook, made on first use for the platform the app runs on. createClient() and the provider pass it; an app that
|
|
20
|
+
* makes a StreamClient itself passes `reactNativePlatform()` (or uses createClient).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
let shared = null;
|
|
24
|
+
|
|
25
|
+
/** The React Native platform for this app (Android, or the iOS preview). The same object every time. */
|
|
26
|
+
function reactNativePlatform() {
|
|
27
|
+
if (shared?.os !== _reactNative.Platform.OS) {
|
|
28
|
+
shared = {
|
|
29
|
+
os: _reactNative.Platform.OS,
|
|
30
|
+
platform: _reactNative.Platform.OS === 'ios' ? (0, _ios.iosPlatform)() : (0, _android.androidPlatform)()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return shared.platform;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_android","_ios","_streams","shared","reactNativePlatform","os","Platform","OS","platform","iosPlatform","androidPlatform"],"sourceRoot":"../../../src","sources":["platform/index.ts"],"mappings":";;;;;;;;;;;;AAKA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAYA,IAAAG,QAAA,GAAAH,OAAA;AApBA;AACA;AACA;AACA;AACA;;AAMA,IAAII,MAAuD,GAAG,IAAI;;AAElE;AACO,SAASC,mBAAmBA,CAAA,EAAmB;EACpD,IAAID,MAAM,EAAEE,EAAE,KAAKC,qBAAQ,CAACC,EAAE,EAAE;IAC9BJ,MAAM,GAAG;MAAEE,EAAE,EAAEC,qBAAQ,CAACC,EAAE;MAAEC,QAAQ,EAAEF,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,IAAAE,gBAAW,EAAC,CAAC,GAAG,IAAAC,wBAAe,EAAC;IAAE,CAAC;EACnG;EACA,OAAOP,MAAM,CAACK,QAAQ;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.iosPlatform = iosPlatform;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _errors = require("../errors.js");
|
|
9
|
+
var _common = require("./common.js");
|
|
10
|
+
var _devices = require("./devices.js");
|
|
11
|
+
var _streams = require("./streams.js");
|
|
12
|
+
var _timers = require("./timers.js");
|
|
13
|
+
var _visibility = require("./visibility.js");
|
|
14
|
+
/**
|
|
15
|
+
* The client's platform in the iOS preview (JavaScript only in 0.1.0: VoltKit has not compiled or run it). Capture,
|
|
16
|
+
* streams and views are react-native-webrtc's as on Android; visibility comes from AppState with `inactive` counted
|
|
17
|
+
* as visible; timers are JavaScript's. There is no audio routing (`media-unavailable` with `{ platform: 'ios' }`),
|
|
18
|
+
* no call service and no screen sharing (`screen-share-unsupported`).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
function iosPlatform() {
|
|
22
|
+
const book = (0, _streams.streamBook)();
|
|
23
|
+
const visibility = (0, _visibility.appStateVisibility)();
|
|
24
|
+
return {
|
|
25
|
+
name: 'react-native',
|
|
26
|
+
describe: _common.describePlatform,
|
|
27
|
+
getUserMedia: constraints => (0, _common.captureUserMedia)(constraints),
|
|
28
|
+
enumerateDevices: kind => (0, _devices.enumerateDevices)(null, kind),
|
|
29
|
+
routeAudio: async kind => {
|
|
30
|
+
if (kind === 'audiooutput') throw (0, _errors.iosUnsupported)('Choosing the audio output');
|
|
31
|
+
// A microphone is captured with its deviceId, as in a browser.
|
|
32
|
+
return false;
|
|
33
|
+
},
|
|
34
|
+
switchCameraInPlace: (track, deviceId) => (0, _devices.switchCameraInPlace)(track, deviceId),
|
|
35
|
+
createStream: tracks => book.create(tracks),
|
|
36
|
+
releaseStream: stream => book.release(stream),
|
|
37
|
+
adoptAppStream: stream => book.adopt(stream, 'app'),
|
|
38
|
+
stopTrack: track => book.stop(track),
|
|
39
|
+
verifyReplaceTrack: true,
|
|
40
|
+
detachTracks: tracks => book.detach(tracks),
|
|
41
|
+
appVisible: () => visibility.visible(),
|
|
42
|
+
onAppVisibility: listener => visibility.subscribe(listener),
|
|
43
|
+
onOnline: listener => visibility.subscribe(visible => {
|
|
44
|
+
if (visible) listener();
|
|
45
|
+
}),
|
|
46
|
+
pixelRatio: () => _reactNative.PixelRatio.get(),
|
|
47
|
+
deviceEnv: _common.deviceEnv,
|
|
48
|
+
simulcastTemporalLayers: 3,
|
|
49
|
+
remoteAudioLevels: 'stats',
|
|
50
|
+
audioLevelIntervalMs: 500,
|
|
51
|
+
timers: _timers.jsTimers
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_errors","_common","_devices","_streams","_timers","_visibility","iosPlatform","book","streamBook","visibility","appStateVisibility","name","describe","describePlatform","getUserMedia","constraints","captureUserMedia","enumerateDevices","kind","routeAudio","iosUnsupported","switchCameraInPlace","track","deviceId","createStream","tracks","create","releaseStream","stream","release","adoptAppStream","adopt","stopTrack","stop","verifyReplaceTrack","detachTracks","detach","appVisible","visible","onAppVisibility","listener","subscribe","onOnline","pixelRatio","PixelRatio","get","deviceEnv","simulcastTemporalLayers","remoteAudioLevels","audioLevelIntervalMs","timers","jsTimers"],"sourceRoot":"../../../src","sources":["platform/ios.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;;AAUO,SAASO,WAAWA,CAAA,EAAmC;EAC5D,MAAMC,IAAI,GAAG,IAAAC,mBAAU,EAAC,CAAC;EACzB,MAAMC,UAAU,GAAG,IAAAC,8BAAkB,EAAC,CAAC;EACvC,OAAO;IACLC,IAAI,EAAE,cAAc;IACpBC,QAAQ,EAAEC,wBAAgB;IAC1BC,YAAY,EAAGC,WAAW,IAAK,IAAAC,wBAAgB,EAACD,WAAW,CAAC;IAC5DE,gBAAgB,EAAGC,IAAI,IAAK,IAAAD,yBAAgB,EAAC,IAAI,EAAEC,IAAI,CAAC;IACxDC,UAAU,EAAE,MAAOD,IAAI,IAAK;MAC1B,IAAIA,IAAI,KAAK,aAAa,EAAE,MAAM,IAAAE,sBAAc,EAAC,2BAA2B,CAAC;MAC7E;MACA,OAAO,KAAK;IACd,CAAC;IACDC,mBAAmB,EAAEA,CAACC,KAAK,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