@stream-io/video-react-native-sdk 0.0.11 → 0.0.13
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 +13 -0
- package/README.md +2 -2
- package/dist/commonjs/components/Call/CallControls/ToggleAudioPreviewButton.js +3 -3
- package/dist/commonjs/components/Call/CallControls/ToggleAudioPreviewButton.js.map +1 -1
- package/dist/commonjs/components/Call/CallControls/ToggleVideoPreviewButton.js +3 -3
- package/dist/commonjs/components/Call/CallControls/ToggleVideoPreviewButton.js.map +1 -1
- package/dist/commonjs/providers/MediaStreamManagement.js +69 -28
- package/dist/commonjs/providers/MediaStreamManagement.js.map +1 -1
- package/dist/commonjs/providers/StreamVideo.js +1 -2
- package/dist/commonjs/providers/StreamVideo.js.map +1 -1
- package/dist/commonjs/translations/en.json +1 -3
- package/dist/commonjs/utils/StreamVideoRN/index.js +0 -16
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/CallControls/ToggleAudioPreviewButton.js +3 -3
- package/dist/module/components/Call/CallControls/ToggleAudioPreviewButton.js.map +1 -1
- package/dist/module/components/Call/CallControls/ToggleVideoPreviewButton.js +3 -3
- package/dist/module/components/Call/CallControls/ToggleVideoPreviewButton.js.map +1 -1
- package/dist/module/providers/MediaStreamManagement.js +71 -30
- package/dist/module/providers/MediaStreamManagement.js.map +1 -1
- package/dist/module/providers/StreamVideo.js +1 -2
- package/dist/module/providers/StreamVideo.js.map +1 -1
- package/dist/module/translations/en.json +1 -3
- package/dist/module/utils/StreamVideoRN/index.js +0 -16
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Call/CallControls/ToggleVideoPreviewButton.d.ts.map +1 -1
- package/dist/typescript/providers/MediaStreamManagement.d.ts +1 -1
- package/dist/typescript/providers/MediaStreamManagement.d.ts.map +1 -1
- package/dist/typescript/providers/StreamVideo.d.ts.map +1 -1
- package/dist/typescript/translations/index.d.ts +0 -2
- package/dist/typescript/translations/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +0 -10
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/Call/CallControls/ToggleAudioPreviewButton.tsx +3 -3
- package/src/components/Call/CallControls/ToggleVideoPreviewButton.tsx +4 -3
- package/src/providers/MediaStreamManagement.tsx +80 -51
- package/src/providers/StreamVideo.tsx +0 -2
- package/src/translations/en.json +1 -3
- package/src/utils/StreamVideoRN/index.ts +0 -21
- package/src/version.ts +1 -1
- package/dist/commonjs/providers/MediaDevices.js +0 -59
- package/dist/commonjs/providers/MediaDevices.js.map +0 -1
- package/dist/commonjs/utils/StreamVideoRN/permissions.js +0 -24
- package/dist/commonjs/utils/StreamVideoRN/permissions.js.map +0 -1
- package/dist/module/providers/MediaDevices.js +0 -53
- package/dist/module/providers/MediaDevices.js.map +0 -1
- package/dist/module/utils/StreamVideoRN/permissions.js +0 -15
- package/dist/module/utils/StreamVideoRN/permissions.js.map +0 -1
- package/dist/typescript/providers/MediaDevices.d.ts +0 -10
- package/dist/typescript/providers/MediaDevices.d.ts.map +0 -1
- package/dist/typescript/utils/StreamVideoRN/permissions.d.ts +0 -6
- package/dist/typescript/utils/StreamVideoRN/permissions.d.ts.map +0 -1
- package/src/providers/MediaDevices.tsx +0 -61
- package/src/utils/StreamVideoRN/permissions.ts +0 -25
|
@@ -2,7 +2,6 @@ import { StreamVideoProvider } from '@stream-io/video-react-bindings';
|
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
3
|
import { StreamVideoStoreProvider } from '../contexts/StreamVideoContext';
|
|
4
4
|
import NetInfo from '@react-native-community/netinfo';
|
|
5
|
-
import { MediaDevices } from './MediaDevices';
|
|
6
5
|
import { usePushRegisterEffect } from '../hooks';
|
|
7
6
|
import { translations } from '../translations';
|
|
8
7
|
import { ThemeProvider } from '../contexts/ThemeContext';
|
|
@@ -53,7 +52,7 @@ export const StreamVideo = props => {
|
|
|
53
52
|
i18nInstance: i18nInstance
|
|
54
53
|
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
55
54
|
style: style
|
|
56
|
-
}, /*#__PURE__*/React.createElement(StreamVideoStoreProvider, null, /*#__PURE__*/React.createElement(
|
|
55
|
+
}, /*#__PURE__*/React.createElement(StreamVideoStoreProvider, null, /*#__PURE__*/React.createElement(PushRegister, null), children)));
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StreamVideoProvider","React","useEffect","StreamVideoStoreProvider","NetInfo","
|
|
1
|
+
{"version":3,"names":["StreamVideoProvider","React","useEffect","StreamVideoStoreProvider","NetInfo","usePushRegisterEffect","translations","ThemeProvider","StreamVideo","props","client","children","translationsOverrides","i18nInstance","language","style","prevIsOnline","unsubscribe","addEventListener","state","_client$streamClient$","isConnected","isInternetReachable","isOnline","streamClient","wsConnection","onlineStatusChanged","type","createElement","PushRegister"],"sourceRoot":"../../../src","sources":["providers/StreamVideo.tsx"],"mappings":"AAAA,SACEA,mBAAmB,QAGd,iCAAiC;AACxC,OAAOC,KAAK,IAAuBC,SAAS,QAAQ,OAAO;AAC3D,SAASC,wBAAwB,QAAQ,gCAAgC;AACzE,OAAOC,OAAO,MAAM,iCAAiC;AACrD,SAASC,qBAAqB,QAAQ,UAAU;AAChD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAAsBC,aAAa,QAAQ,0BAA0B;AAGrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GACtBC,KAKC,IACE;EACH,MAAM;IACJC,MAAM;IACNC,QAAQ;IACRC,qBAAqB,GAAGN,YAAY;IACpCO,YAAY;IACZC,QAAQ;IACRC;EACF,CAAC,GAAGN,KAAK;;EAET;AACF;AACA;EACEP,SAAS,CAAC,MAAM;IACd,IAAIc,YAAY,GAAG,IAAI;IACvB,MAAMC,WAAW,GAAGb,OAAO,CAACc,gBAAgB,CAAEC,KAAK,IAAK;MAAA,IAAAC,qBAAA;MACtD,MAAM;QAAEC,WAAW;QAAEC;MAAoB,CAAC,GAAGH,KAAK;MAClD,MAAMI,QAAQ,GAAGF,WAAW,KAAK,IAAI,IAAIC,mBAAmB,KAAK,KAAK;MACtE,IAAIC,QAAQ,KAAKP,YAAY,EAAE;QAC7B;MACF;MACAA,YAAY,GAAGO,QAAQ;MACvB;MACA,CAAAH,qBAAA,GAAAV,MAAM,CAACc,YAAY,CAACC,YAAY,cAAAL,qBAAA,eAAhCA,qBAAA,CAAkCM,mBAAmB,CAAC;QACpDC,IAAI,EAAEJ,QAAQ,GAAG,QAAQ,GAAG;MAC9B,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAON,WAAW;EACpB,CAAC,EAAE,CAACP,MAAM,CAAC,CAAC;EAEZ,oBACET,KAAA,CAAA2B,aAAA,CAAC5B,mBAAmB;IAClBU,MAAM,EAAEA,MAAO;IACfI,QAAQ,EAAEA,QAAS;IACnBF,qBAAqB,EAAEA,qBAAsB;IAC7CC,YAAY,EAAEA;EAAa,gBAE3BZ,KAAA,CAAA2B,aAAA,CAACrB,aAAa;IAACQ,KAAK,EAAEA;EAAM,gBAC1Bd,KAAA,CAAA2B,aAAA,CAACzB,wBAAwB,qBACvBF,KAAA,CAAA2B,aAAA,CAACC,YAAY,MAAE,CAAC,EACflB,QACuB,CACb,CACI,CAAC;AAE1B,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMkB,YAAY,GAAGA,CAAA,KAAM;EACzBxB,qBAAqB,CAAC,CAAC;EACvB,OAAO,IAAI;AACb,CAAC"}
|
|
@@ -10,7 +10,5 @@
|
|
|
10
10
|
"Participants ({{ numberOfParticipants }})": "Participants ({{ numberOfParticipants }})",
|
|
11
11
|
"{{ userName }} is sharing their screen": "{{ userName }} is sharing their screen",
|
|
12
12
|
"{{ numberOfParticipants }} participant(s) are in the call.": "{{ numberOfParticipants }} participant(s) are in the call.",
|
|
13
|
-
"You are about to join a call with id {{ callId }}.": "You are about to join a call with id {{ callId }}."
|
|
14
|
-
"Microphone Permission Required To Enable Audio": "Microphone permission not granted, can not enable audio",
|
|
15
|
-
"Camera Permission Required To Enable Video": "Camera permission not granted, can not enable video"
|
|
13
|
+
"You are about to join a call with id {{ callId }}.": "You are about to join a call with id {{ callId }}."
|
|
16
14
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AndroidImportance } from '@notifee/react-native';
|
|
2
2
|
import { defaultEmojiReactions } from '../../constants';
|
|
3
3
|
import { setupFirebaseHandlerAndroid } from '../push/android';
|
|
4
|
-
import { isCameraPermissionGranted$, isMicPermissionGranted$ } from './permissions';
|
|
5
4
|
const DEFAULT_STREAM_VIDEO_CONFIG = {
|
|
6
5
|
supportedReactions: defaultEmojiReactions,
|
|
7
6
|
foregroundService: {
|
|
@@ -58,21 +57,6 @@ export class StreamVideoRN {
|
|
|
58
57
|
// After getting the config we should setup callkeep events, firebase handler asap to handle incoming calls from a dead state
|
|
59
58
|
setupFirebaseHandlerAndroid(pushConfig);
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Set native permissions config for StreamVideoRN.
|
|
64
|
-
* Note: This function should be called after the user has declined/granted camera and mic permissions.
|
|
65
|
-
* @example
|
|
66
|
-
* See sample-apps/react-native/dogfood/src/hooks/useSyncPermissions.ts
|
|
67
|
-
*/
|
|
68
|
-
static setPermissions(_ref) {
|
|
69
|
-
let {
|
|
70
|
-
isCameraPermissionGranted,
|
|
71
|
-
isMicPermissionGranted
|
|
72
|
-
} = _ref;
|
|
73
|
-
isCameraPermissionGranted$.next(isCameraPermissionGranted);
|
|
74
|
-
isMicPermissionGranted$.next(isMicPermissionGranted);
|
|
75
|
-
}
|
|
76
60
|
static getConfig() {
|
|
77
61
|
return this.config;
|
|
78
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AndroidImportance","defaultEmojiReactions","setupFirebaseHandlerAndroid","
|
|
1
|
+
{"version":3,"names":["AndroidImportance","defaultEmojiReactions","setupFirebaseHandlerAndroid","DEFAULT_STREAM_VIDEO_CONFIG","supportedReactions","foregroundService","android","channel","id","name","lights","vibration","importance","DEFAULT","notificationTexts","title","body","StreamVideoRN","config","updateConfig","setPushConfig","pushConfig","push","getConfig"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,2BAA2B,QAAQ,iBAAiB;AAG7D,MAAMC,2BAA8C,GAAG;EACrDC,kBAAkB,EAAEH,qBAAqB;EACzCI,iBAAiB,EAAE;IACjBC,OAAO,EAAE;MACPC,OAAO,EAAE;QACPC,EAAE,EAAE,gCAAgC;QACpCC,IAAI,EAAE,yCAAyC;QAC/CC,MAAM,EAAE,KAAK;QACbC,SAAS,EAAE,KAAK;QAChBC,UAAU,EAAEZ,iBAAiB,CAACa;MAChC,CAAC;MACDC,iBAAiB,EAAE;QACjBC,KAAK,EAAE,kBAAkB;QACzBC,IAAI,EAAE;MACR;IACF;EACF;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,CAAC;EACzB,OAAeC,MAAM,GAAGf,2BAA2B;EACnD;AACF;AACA;AACA;AACA;EACE,OAAOgB,YAAYA,CAACA,YAAsD,EAAE;IAC1E,IAAI,CAACD,MAAM,GAAG;MACZ,GAAG,IAAI,CAACA,MAAM;MACd,GAAGC;IACL,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,aAAaA,CAACC,UAAkD,EAAE;IACvE,IAAI,IAAI,CAACH,MAAM,CAACI,IAAI,EAAE;MACpB;MACA;IACF;IACA,IAAI,CAACJ,MAAM,CAACI,IAAI,GAAGD,UAAU;IAC7B;IACAnB,2BAA2B,CAACmB,UAAU,CAAC;EACzC;EAEA,OAAOE,SAASA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACL,MAAM;EACpB;AACF"}
|
package/dist/module/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.0.
|
|
1
|
+
export const version = '0.0.13';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleVideoPreviewButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Call/CallControls/ToggleVideoPreviewButton.tsx"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,wBAElC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ToggleVideoPreviewButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Call/CallControls/ToggleVideoPreviewButton.tsx"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,wBAElC,6BAA6B,gBAwC/B,CAAC"}
|
|
@@ -35,7 +35,7 @@ export type MediaStreamManagementContextAPI = {
|
|
|
35
35
|
*
|
|
36
36
|
* @category Device Management
|
|
37
37
|
*/
|
|
38
|
-
export declare const MediaStreamManagement: ({ initialAudioEnabled, initialVideoEnabled, children, }: PropsWithChildren<MediaDevicesInitialState>) => JSX.Element;
|
|
38
|
+
export declare const MediaStreamManagement: ({ initialAudioEnabled: propInitialAudioEnabled, initialVideoEnabled: propInitialVideoEnabled, children, }: PropsWithChildren<MediaDevicesInitialState>) => JSX.Element;
|
|
39
39
|
/**
|
|
40
40
|
* Context consumer retrieving MediaStreamManagementContextAPI.
|
|
41
41
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaStreamManagement.d.ts","sourceRoot":"","sources":["../../../src/providers/MediaStreamManagement.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"MediaStreamManagement.d.ts","sourceRoot":"","sources":["../../../src/providers/MediaStreamManagement.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C;;;OAGG;IACH,2BAA2B,EAAE,MAAM,IAAI,CAAC;IACxC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,IAAI,CAAC;CACzC,CAAC;AAKF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,8GAI/B,kBAAkB,wBAAwB,CAAC,gBAsH7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,uCAMpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamVideo.d.ts","sourceRoot":"","sources":["../../../src/providers/StreamVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAc,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StreamVideo.d.ts","sourceRoot":"","sources":["../../../src/providers/StreamVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAc,EAAE,iBAAiB,EAAa,MAAM,OAAO,CAAC;AAK5D,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,UACf,kBACL,gBAAgB,GACd,uBAAuB,GAAG;IACxB,KAAK,CAAC,EAAE,YAAY,KAAK,CAAC,CAAC;CAC5B,CACJ,gBA+CF,CAAC"}
|
|
@@ -12,8 +12,6 @@ export declare const translations: {
|
|
|
12
12
|
"{{ userName }} is sharing their screen": string;
|
|
13
13
|
"{{ numberOfParticipants }} participant(s) are in the call.": string;
|
|
14
14
|
"You are about to join a call with id {{ callId }}.": string;
|
|
15
|
-
"Microphone Permission Required To Enable Audio": string;
|
|
16
|
-
"Camera Permission Required To Enable Video": string;
|
|
17
15
|
};
|
|
18
16
|
};
|
|
19
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/translations/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/translations/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAAS,CAAC"}
|
|
@@ -23,16 +23,6 @@ export declare class StreamVideoRN {
|
|
|
23
23
|
* AppRegistry.registerComponent('app', () => App);
|
|
24
24
|
*/
|
|
25
25
|
static setPushConfig(pushConfig: NonNullable<StreamVideoConfig['push']>): void;
|
|
26
|
-
/**
|
|
27
|
-
* Set native permissions config for StreamVideoRN.
|
|
28
|
-
* Note: This function should be called after the user has declined/granted camera and mic permissions.
|
|
29
|
-
* @example
|
|
30
|
-
* See sample-apps/react-native/dogfood/src/hooks/useSyncPermissions.ts
|
|
31
|
-
*/
|
|
32
|
-
static setPermissions({ isCameraPermissionGranted, isMicPermissionGranted, }: {
|
|
33
|
-
isCameraPermissionGranted: boolean;
|
|
34
|
-
isMicPermissionGranted: boolean;
|
|
35
|
-
}): void;
|
|
36
26
|
static getConfig(): StreamVideoConfig;
|
|
37
27
|
}
|
|
38
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/StreamVideoRN/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/StreamVideoRN/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqB5C,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,MAAM,CAA+B;IACpD;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAO1E;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAUvE,MAAM,CAAC,SAAS;CAGjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.13";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-react-native-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"packageManager": "yarn@3.2.4",
|
|
5
5
|
"main": "dist/commonjs/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@stream-io/i18n": "^0.1.1",
|
|
49
|
-
"@stream-io/video-client": "^0.3.
|
|
50
|
-
"@stream-io/video-react-bindings": "^0.2.
|
|
49
|
+
"@stream-io/video-client": "^0.3.16",
|
|
50
|
+
"@stream-io/video-react-bindings": "^0.2.17",
|
|
51
51
|
"intl-pluralrules": "2.0.1",
|
|
52
52
|
"lodash.merge": "^4.6.2",
|
|
53
53
|
"react-native-url-polyfill": "1.3.0",
|
|
@@ -56,10 +56,10 @@ export const ToggleAudioPreviewButton = ({
|
|
|
56
56
|
svgContainer: toggleAudioPreviewButton.svgContainer,
|
|
57
57
|
}}
|
|
58
58
|
>
|
|
59
|
-
{status === '
|
|
60
|
-
<MicOff color={colors.static_white} />
|
|
61
|
-
) : (
|
|
59
|
+
{status === 'enabled' ? (
|
|
62
60
|
<Mic color={colors.static_black} />
|
|
61
|
+
) : (
|
|
62
|
+
<MicOff color={colors.static_white} />
|
|
63
63
|
)}
|
|
64
64
|
</CallControlsButton>
|
|
65
65
|
);
|
|
@@ -39,6 +39,7 @@ export const ToggleVideoPreviewButton = ({
|
|
|
39
39
|
}
|
|
40
40
|
toggleInitialVideoMuteState();
|
|
41
41
|
};
|
|
42
|
+
|
|
42
43
|
return (
|
|
43
44
|
<CallControlsButton
|
|
44
45
|
onPress={onPress}
|
|
@@ -53,10 +54,10 @@ export const ToggleVideoPreviewButton = ({
|
|
|
53
54
|
svgContainer: toggleVideoPreviewButton.svgContainer,
|
|
54
55
|
}}
|
|
55
56
|
>
|
|
56
|
-
{status === '
|
|
57
|
-
<VideoSlash color={colors.static_white} />
|
|
58
|
-
) : (
|
|
57
|
+
{status === 'enabled' ? (
|
|
59
58
|
<Video color={colors.static_black} />
|
|
59
|
+
) : (
|
|
60
|
+
<VideoSlash color={colors.static_white} />
|
|
60
61
|
)}
|
|
61
62
|
</CallControlsButton>
|
|
62
63
|
);
|
|
@@ -5,13 +5,9 @@ import React, {
|
|
|
5
5
|
useContext,
|
|
6
6
|
useEffect,
|
|
7
7
|
useMemo,
|
|
8
|
+
useState,
|
|
8
9
|
} from 'react';
|
|
9
|
-
import { useCall,
|
|
10
|
-
import {
|
|
11
|
-
isCameraPermissionGranted$,
|
|
12
|
-
isMicPermissionGranted$,
|
|
13
|
-
} from '../utils/StreamVideoRN/permissions';
|
|
14
|
-
import { Alert } from 'react-native';
|
|
10
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
15
11
|
import { useAppStateListener } from '../utils/hooks';
|
|
16
12
|
|
|
17
13
|
export type MediaDevicesInitialState = {
|
|
@@ -56,12 +52,12 @@ const MediaStreamContext =
|
|
|
56
52
|
* @category Device Management
|
|
57
53
|
*/
|
|
58
54
|
export const MediaStreamManagement = ({
|
|
59
|
-
initialAudioEnabled,
|
|
60
|
-
initialVideoEnabled,
|
|
55
|
+
initialAudioEnabled: propInitialAudioEnabled,
|
|
56
|
+
initialVideoEnabled: propInitialVideoEnabled,
|
|
61
57
|
children,
|
|
62
58
|
}: PropsWithChildren<MediaDevicesInitialState>) => {
|
|
63
59
|
const call = useCall();
|
|
64
|
-
const {
|
|
60
|
+
const { useCallSettings } = useCallStateHooks();
|
|
65
61
|
|
|
66
62
|
// Resume/Disable video stream tracks when app goes to background/foreground
|
|
67
63
|
// To save on CPU resources
|
|
@@ -74,64 +70,96 @@ export const MediaStreamManagement = ({
|
|
|
74
70
|
},
|
|
75
71
|
);
|
|
76
72
|
|
|
73
|
+
const [{ initialAudioEnabled, initialVideoEnabled }, setInitialDeviceState] =
|
|
74
|
+
useState({
|
|
75
|
+
initialAudioEnabled: !!propInitialAudioEnabled,
|
|
76
|
+
initialVideoEnabled: !!propInitialVideoEnabled,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const settings = useCallSettings();
|
|
80
|
+
|
|
81
|
+
// if prop is set, use that value.. the prop should override the backend settings
|
|
77
82
|
useEffect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
setInitialDeviceState((prev) => {
|
|
84
|
+
let initAudio = prev.initialAudioEnabled;
|
|
85
|
+
if (typeof propInitialAudioEnabled !== 'undefined') {
|
|
86
|
+
initAudio = propInitialAudioEnabled;
|
|
87
|
+
}
|
|
88
|
+
let initVideo = prev.initialVideoEnabled;
|
|
89
|
+
if (typeof propInitialVideoEnabled !== 'undefined') {
|
|
90
|
+
initVideo = propInitialVideoEnabled;
|
|
91
|
+
}
|
|
92
|
+
return { initialAudioEnabled: initAudio, initialVideoEnabled: initVideo };
|
|
93
|
+
});
|
|
94
|
+
}, [propInitialAudioEnabled, propInitialVideoEnabled]);
|
|
95
|
+
|
|
96
|
+
// use backend settings to set initial audio/video enabled state
|
|
97
|
+
// ONLY if the prop was undefined -- meaning user did not provide any value
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!settings) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { audio, video } = settings;
|
|
103
|
+
setInitialDeviceState((prev) => {
|
|
104
|
+
let initAudio = prev.initialAudioEnabled;
|
|
82
105
|
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
call?.microphone.state.status === 'disabled')
|
|
106
|
+
typeof propInitialAudioEnabled === 'undefined' &&
|
|
107
|
+
audio.mic_default_on
|
|
86
108
|
) {
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
call?.microphone.disable();
|
|
109
|
+
initAudio = true;
|
|
90
110
|
}
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
typeof initialVideoEnabled !== 'undefined' &&
|
|
94
|
-
isCameraPermissionGranted$.getValue()
|
|
95
|
-
) {
|
|
111
|
+
let initVideo = prev.initialVideoEnabled;
|
|
96
112
|
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
call?.camera.state.status === 'disabled')
|
|
113
|
+
typeof propInitialVideoEnabled === 'undefined' &&
|
|
114
|
+
video.camera_default_on
|
|
100
115
|
) {
|
|
101
|
-
|
|
102
|
-
} else {
|
|
103
|
-
call?.camera.disable();
|
|
116
|
+
initVideo = true;
|
|
104
117
|
}
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
return { initialAudioEnabled: initAudio, initialVideoEnabled: initVideo };
|
|
119
|
+
});
|
|
120
|
+
}, [propInitialAudioEnabled, propInitialVideoEnabled, settings]);
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
// The main logic
|
|
123
|
+
// Enable or Disable the audio/video stream based on the initial state
|
|
124
|
+
useEffect(() => {
|
|
109
125
|
if (
|
|
110
|
-
|
|
111
|
-
call?.microphone.state.status ===
|
|
126
|
+
initialAudioEnabled &&
|
|
127
|
+
(call?.microphone.state.status === undefined ||
|
|
128
|
+
call?.microphone.state.status === 'disabled')
|
|
112
129
|
) {
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
call?.microphone.enable();
|
|
131
|
+
} else if (
|
|
132
|
+
!initialAudioEnabled &&
|
|
133
|
+
call?.microphone.state.status === 'enabled'
|
|
134
|
+
) {
|
|
135
|
+
call?.microphone.disable();
|
|
115
136
|
}
|
|
116
137
|
|
|
117
|
-
call?.microphone.state.status === 'disabled'
|
|
118
|
-
? call?.microphone.enable()
|
|
119
|
-
: call?.microphone.disable();
|
|
120
|
-
}, [call, t]);
|
|
121
|
-
|
|
122
|
-
const toggleInitialVideoMuteState = useCallback(() => {
|
|
123
138
|
if (
|
|
124
|
-
|
|
125
|
-
call?.camera.state.status ===
|
|
139
|
+
initialVideoEnabled &&
|
|
140
|
+
(call?.camera.state.status === undefined ||
|
|
141
|
+
call?.camera.state.status === 'disabled')
|
|
126
142
|
) {
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
call?.camera.enable();
|
|
144
|
+
} else if (
|
|
145
|
+
!initialVideoEnabled &&
|
|
146
|
+
call?.camera.state.status === 'enabled'
|
|
147
|
+
) {
|
|
148
|
+
call?.camera.disable();
|
|
129
149
|
}
|
|
150
|
+
}, [call, initialAudioEnabled, initialVideoEnabled]);
|
|
151
|
+
|
|
152
|
+
const toggleInitialAudioMuteState = useCallback(() => {
|
|
153
|
+
call?.microphone.state.status === 'enabled'
|
|
154
|
+
? call?.microphone.disable()
|
|
155
|
+
: call?.microphone.enable();
|
|
156
|
+
}, [call]);
|
|
130
157
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
158
|
+
const toggleInitialVideoMuteState = useCallback(() => {
|
|
159
|
+
call?.camera.state.status === 'enabled'
|
|
160
|
+
? call?.camera.disable()
|
|
161
|
+
: call?.camera.enable();
|
|
162
|
+
}, [call]);
|
|
135
163
|
|
|
136
164
|
const contextValue = useMemo(() => {
|
|
137
165
|
return {
|
|
@@ -139,6 +167,7 @@ export const MediaStreamManagement = ({
|
|
|
139
167
|
toggleInitialVideoMuteState,
|
|
140
168
|
};
|
|
141
169
|
}, [toggleInitialAudioMuteState, toggleInitialVideoMuteState]);
|
|
170
|
+
|
|
142
171
|
return (
|
|
143
172
|
<MediaStreamContext.Provider value={contextValue}>
|
|
144
173
|
{children}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
import React, { PropsWithChildren, useEffect } from 'react';
|
|
7
7
|
import { StreamVideoStoreProvider } from '../contexts/StreamVideoContext';
|
|
8
8
|
import NetInfo from '@react-native-community/netinfo';
|
|
9
|
-
import { MediaDevices } from './MediaDevices';
|
|
10
9
|
import { usePushRegisterEffect } from '../hooks';
|
|
11
10
|
import { translations } from '../translations';
|
|
12
11
|
import { DeepPartial, ThemeProvider } from '../contexts/ThemeContext';
|
|
@@ -66,7 +65,6 @@ export const StreamVideo = (
|
|
|
66
65
|
>
|
|
67
66
|
<ThemeProvider style={style}>
|
|
68
67
|
<StreamVideoStoreProvider>
|
|
69
|
-
<MediaDevices />
|
|
70
68
|
<PushRegister />
|
|
71
69
|
{children}
|
|
72
70
|
</StreamVideoStoreProvider>
|
package/src/translations/en.json
CHANGED
|
@@ -10,7 +10,5 @@
|
|
|
10
10
|
"Participants ({{ numberOfParticipants }})": "Participants ({{ numberOfParticipants }})",
|
|
11
11
|
"{{ userName }} is sharing their screen": "{{ userName }} is sharing their screen",
|
|
12
12
|
"{{ numberOfParticipants }} participant(s) are in the call.": "{{ numberOfParticipants }} participant(s) are in the call.",
|
|
13
|
-
"You are about to join a call with id {{ callId }}.": "You are about to join a call with id {{ callId }}."
|
|
14
|
-
"Microphone Permission Required To Enable Audio": "Microphone permission not granted, can not enable audio",
|
|
15
|
-
"Camera Permission Required To Enable Video": "Camera permission not granted, can not enable video"
|
|
13
|
+
"You are about to join a call with id {{ callId }}.": "You are about to join a call with id {{ callId }}."
|
|
16
14
|
}
|
|
@@ -2,10 +2,6 @@ import { AndroidImportance } from '@notifee/react-native';
|
|
|
2
2
|
import { defaultEmojiReactions } from '../../constants';
|
|
3
3
|
import { setupFirebaseHandlerAndroid } from '../push/android';
|
|
4
4
|
import { StreamVideoConfig } from './types';
|
|
5
|
-
import {
|
|
6
|
-
isCameraPermissionGranted$,
|
|
7
|
-
isMicPermissionGranted$,
|
|
8
|
-
} from './permissions';
|
|
9
5
|
|
|
10
6
|
const DEFAULT_STREAM_VIDEO_CONFIG: StreamVideoConfig = {
|
|
11
7
|
supportedReactions: defaultEmojiReactions,
|
|
@@ -65,23 +61,6 @@ export class StreamVideoRN {
|
|
|
65
61
|
setupFirebaseHandlerAndroid(pushConfig);
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
/**
|
|
69
|
-
* Set native permissions config for StreamVideoRN.
|
|
70
|
-
* Note: This function should be called after the user has declined/granted camera and mic permissions.
|
|
71
|
-
* @example
|
|
72
|
-
* See sample-apps/react-native/dogfood/src/hooks/useSyncPermissions.ts
|
|
73
|
-
*/
|
|
74
|
-
static setPermissions({
|
|
75
|
-
isCameraPermissionGranted,
|
|
76
|
-
isMicPermissionGranted,
|
|
77
|
-
}: {
|
|
78
|
-
isCameraPermissionGranted: boolean;
|
|
79
|
-
isMicPermissionGranted: boolean;
|
|
80
|
-
}) {
|
|
81
|
-
isCameraPermissionGranted$.next(isCameraPermissionGranted);
|
|
82
|
-
isMicPermissionGranted$.next(isMicPermissionGranted);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
64
|
static getConfig() {
|
|
86
65
|
return this.config;
|
|
87
66
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.0.
|
|
1
|
+
export const version = '0.0.13';
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MediaDevices = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _videoClient = require("@stream-io/video-client");
|
|
9
|
-
var _contexts = require("../contexts");
|
|
10
|
-
var _permissions = require("../utils/StreamVideoRN/permissions");
|
|
11
|
-
/**
|
|
12
|
-
* A renderless component that provides the audio and video devices to the store
|
|
13
|
-
* This component must be a child of StreamVideoStoreProvider
|
|
14
|
-
* @internal
|
|
15
|
-
*
|
|
16
|
-
* @category Device Management
|
|
17
|
-
*/
|
|
18
|
-
const MediaDevices = () => {
|
|
19
|
-
const setState = (0, _contexts.useStreamVideoStoreSetState)();
|
|
20
|
-
const initialVideoDeviceSet = (0, _react.useRef)(false);
|
|
21
|
-
(0, _react.useEffect)(() => {
|
|
22
|
-
const setAudioDevices = audioDevices => {
|
|
23
|
-
setState({
|
|
24
|
-
audioDevices,
|
|
25
|
-
currentAudioDevice: audioDevices[0]
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
const subscription = (0, _permissions.subscribeToDevicesWhenPermissionGranted)(_permissions.isMicPermissionGranted$,
|
|
29
|
-
// @ts-expect-error Due to DOM typing incompatible with RN
|
|
30
|
-
_videoClient.getAudioDevices, setAudioDevices);
|
|
31
|
-
return () => subscription.unsubscribe();
|
|
32
|
-
}, [setState]);
|
|
33
|
-
(0, _react.useEffect)(() => {
|
|
34
|
-
const setVideoDevices = videoDevices => {
|
|
35
|
-
if (videoDevices.length > 0 && !initialVideoDeviceSet.current) {
|
|
36
|
-
const frontFacingVideoDevice = videoDevices.find(videoDevice => videoDevice.kind === 'videoinput' && videoDevice.facing === 'front');
|
|
37
|
-
const initialVideoDevice = frontFacingVideoDevice ?? videoDevices[0];
|
|
38
|
-
if (initialVideoDevice) {
|
|
39
|
-
initialVideoDeviceSet.current = true;
|
|
40
|
-
setState({
|
|
41
|
-
videoDevices,
|
|
42
|
-
currentVideoDevice: initialVideoDevice
|
|
43
|
-
});
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
setState({
|
|
48
|
-
videoDevices
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const subscription = (0, _permissions.subscribeToDevicesWhenPermissionGranted)(_permissions.isCameraPermissionGranted$,
|
|
52
|
-
// @ts-expect-error Due to DOM typing incompatible with RN
|
|
53
|
-
_videoClient.getVideoDevices, setVideoDevices);
|
|
54
|
-
return () => subscription.unsubscribe();
|
|
55
|
-
}, [setState]);
|
|
56
|
-
return null;
|
|
57
|
-
};
|
|
58
|
-
exports.MediaDevices = MediaDevices;
|
|
59
|
-
//# sourceMappingURL=MediaDevices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_videoClient","_contexts","_permissions","MediaDevices","setState","useStreamVideoStoreSetState","initialVideoDeviceSet","useRef","useEffect","setAudioDevices","audioDevices","currentAudioDevice","subscription","subscribeToDevicesWhenPermissionGranted","isMicPermissionGranted$","getAudioDevices","unsubscribe","setVideoDevices","videoDevices","length","current","frontFacingVideoDevice","find","videoDevice","kind","facing","initialVideoDevice","currentVideoDevice","isCameraPermissionGranted$","getVideoDevices","exports"],"sourceRoot":"../../../src","sources":["providers/MediaDevices.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,YAAY,GAAGA,CAAA,KAAiC;EAC3D,MAAMC,QAAQ,GAAG,IAAAC,qCAA2B,EAAC,CAAC;EAC9C,MAAMC,qBAAqB,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAE3C,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,eAAe,GAAIC,YAA+B,IAAK;MAC3DN,QAAQ,CAAC;QAAEM,YAAY;QAAEC,kBAAkB,EAAED,YAAY,CAAC,CAAC;MAAE,CAAC,CAAC;IACjE,CAAC;IAED,MAAME,YAAY,GAAG,IAAAC,oDAAuC,EAC1DC,oCAAuB;IACvB;IACAC,4BAAe,EACfN,eACF,CAAC;IACD,OAAO,MAAMG,YAAY,CAACI,WAAW,CAAC,CAAC;EACzC,CAAC,EAAE,CAACZ,QAAQ,CAAC,CAAC;EAEd,IAAAI,gBAAS,EAAC,MAAM;IACd,MAAMS,eAAe,GAAIC,YAA+B,IAAK;MAC3D,IAAIA,YAAY,CAACC,MAAM,GAAG,CAAC,IAAI,CAACb,qBAAqB,CAACc,OAAO,EAAE;QAC7D,MAAMC,sBAAsB,GAAGH,YAAY,CAACI,IAAI,CAC7CC,WAAW,IACVA,WAAW,CAACC,IAAI,KAAK,YAAY,IAAID,WAAW,CAACE,MAAM,KAAK,OAChE,CAAC;QACD,MAAMC,kBAAkB,GAAGL,sBAAsB,IAAIH,YAAY,CAAC,CAAC,CAAC;QACpE,IAAIQ,kBAAkB,EAAE;UACtBpB,qBAAqB,CAACc,OAAO,GAAG,IAAI;UACpChB,QAAQ,CAAC;YAAEc,YAAY;YAAES,kBAAkB,EAAED;UAAmB,CAAC,CAAC;UAClE;QACF;MACF;MACAtB,QAAQ,CAAC;QAAEc;MAAa,CAAC,CAAC;IAC5B,CAAC;IACD,MAAMN,YAAY,GAAG,IAAAC,oDAAuC,EAC1De,uCAA0B;IAC1B;IACAC,4BAAe,EACfZ,eACF,CAAC;IACD,OAAO,MAAML,YAAY,CAACI,WAAW,CAAC,CAAC;EACzC,CAAC,EAAE,CAACZ,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC0B,OAAA,CAAA3B,YAAA,GAAAA,YAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.subscribeToDevicesWhenPermissionGranted = exports.isMicPermissionGranted$ = exports.isCameraPermissionGranted$ = void 0;
|
|
7
|
-
var _operators = require("rxjs/operators");
|
|
8
|
-
var _rxjs = require("rxjs");
|
|
9
|
-
const isCameraPermissionGranted$ = new _rxjs.BehaviorSubject(false);
|
|
10
|
-
exports.isCameraPermissionGranted$ = isCameraPermissionGranted$;
|
|
11
|
-
const isMicPermissionGranted$ = new _rxjs.BehaviorSubject(false);
|
|
12
|
-
exports.isMicPermissionGranted$ = isMicPermissionGranted$;
|
|
13
|
-
const subscribeToDevicesWhenPermissionGranted = (isDevicePermissionGranted$, getDevicesFunc, subscriptionCallback) => isDevicePermissionGranted$.pipe((0, _operators.switchMap)(isDevicePermissionGranted => {
|
|
14
|
-
// if we don't have mic permission, we don't need to get the audio devices
|
|
15
|
-
// because we won't be able to use them anyway and this will trigger a permission request
|
|
16
|
-
// from RN WebRTC lib. This is not ideal because we want to control when the permission.
|
|
17
|
-
if (!isDevicePermissionGranted) {
|
|
18
|
-
// otherwise return EMPTY, which is an Observable that does nothing and just completes immediately
|
|
19
|
-
return _rxjs.EMPTY;
|
|
20
|
-
}
|
|
21
|
-
return getDevicesFunc();
|
|
22
|
-
})).subscribe(subscriptionCallback);
|
|
23
|
-
exports.subscribeToDevicesWhenPermissionGranted = subscribeToDevicesWhenPermissionGranted;
|
|
24
|
-
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_operators","require","_rxjs","isCameraPermissionGranted$","BehaviorSubject","exports","isMicPermissionGranted$","subscribeToDevicesWhenPermissionGranted","isDevicePermissionGranted$","getDevicesFunc","subscriptionCallback","pipe","switchMap","isDevicePermissionGranted","EMPTY","subscribe"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/permissions.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEO,MAAME,0BAA0B,GAAG,IAAIC,qBAAe,CAAU,KAAK,CAAC;AAACC,OAAA,CAAAF,0BAAA,GAAAA,0BAAA;AACvE,MAAMG,uBAAuB,GAAG,IAAIF,qBAAe,CAAU,KAAK,CAAC;AAACC,OAAA,CAAAC,uBAAA,GAAAA,uBAAA;AAEpE,MAAMC,uCAAuC,GAAGA,CACrDC,0BAAoD,EACpDC,cAAmD,EACnDC,oBAA+D,KAE/DF,0BAA0B,CACvBG,IAAI,CACH,IAAAC,oBAAS,EAAEC,yBAAyB,IAAK;EACvC;EACA;EACA;EACA,IAAI,CAACA,yBAAyB,EAAE;IAC9B;IACA,OAAOC,WAAK;EACd;EACA,OAAOL,cAAc,CAAC,CAAC;AACzB,CAAC,CACH,CAAC,CACAM,SAAS,CAACL,oBAAoB,CAAC;AAACL,OAAA,CAAAE,uCAAA,GAAAA,uCAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { getAudioDevices, getVideoDevices } from '@stream-io/video-client';
|
|
3
|
-
import { useStreamVideoStoreSetState } from '../contexts';
|
|
4
|
-
import { isCameraPermissionGranted$, isMicPermissionGranted$, subscribeToDevicesWhenPermissionGranted } from '../utils/StreamVideoRN/permissions';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A renderless component that provides the audio and video devices to the store
|
|
8
|
-
* This component must be a child of StreamVideoStoreProvider
|
|
9
|
-
* @internal
|
|
10
|
-
*
|
|
11
|
-
* @category Device Management
|
|
12
|
-
*/
|
|
13
|
-
export const MediaDevices = () => {
|
|
14
|
-
const setState = useStreamVideoStoreSetState();
|
|
15
|
-
const initialVideoDeviceSet = useRef(false);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const setAudioDevices = audioDevices => {
|
|
18
|
-
setState({
|
|
19
|
-
audioDevices,
|
|
20
|
-
currentAudioDevice: audioDevices[0]
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
const subscription = subscribeToDevicesWhenPermissionGranted(isMicPermissionGranted$,
|
|
24
|
-
// @ts-expect-error Due to DOM typing incompatible with RN
|
|
25
|
-
getAudioDevices, setAudioDevices);
|
|
26
|
-
return () => subscription.unsubscribe();
|
|
27
|
-
}, [setState]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const setVideoDevices = videoDevices => {
|
|
30
|
-
if (videoDevices.length > 0 && !initialVideoDeviceSet.current) {
|
|
31
|
-
const frontFacingVideoDevice = videoDevices.find(videoDevice => videoDevice.kind === 'videoinput' && videoDevice.facing === 'front');
|
|
32
|
-
const initialVideoDevice = frontFacingVideoDevice ?? videoDevices[0];
|
|
33
|
-
if (initialVideoDevice) {
|
|
34
|
-
initialVideoDeviceSet.current = true;
|
|
35
|
-
setState({
|
|
36
|
-
videoDevices,
|
|
37
|
-
currentVideoDevice: initialVideoDevice
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
setState({
|
|
43
|
-
videoDevices
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const subscription = subscribeToDevicesWhenPermissionGranted(isCameraPermissionGranted$,
|
|
47
|
-
// @ts-expect-error Due to DOM typing incompatible with RN
|
|
48
|
-
getVideoDevices, setVideoDevices);
|
|
49
|
-
return () => subscription.unsubscribe();
|
|
50
|
-
}, [setState]);
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=MediaDevices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","getAudioDevices","getVideoDevices","useStreamVideoStoreSetState","isCameraPermissionGranted$","isMicPermissionGranted$","subscribeToDevicesWhenPermissionGranted","MediaDevices","setState","initialVideoDeviceSet","setAudioDevices","audioDevices","currentAudioDevice","subscription","unsubscribe","setVideoDevices","videoDevices","length","current","frontFacingVideoDevice","find","videoDevice","kind","facing","initialVideoDevice","currentVideoDevice"],"sourceRoot":"../../../src","sources":["providers/MediaDevices.tsx"],"mappings":"AAAA,SAAgBA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,eAAe,EAAEC,eAAe,QAAQ,yBAAyB;AAC1E,SAA0BC,2BAA2B,QAAQ,aAAa;AAC1E,SACEC,0BAA0B,EAC1BC,uBAAuB,EACvBC,uCAAuC,QAClC,oCAAoC;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAiC;EAC3D,MAAMC,QAAQ,GAAGL,2BAA2B,CAAC,CAAC;EAC9C,MAAMM,qBAAqB,GAAGT,MAAM,CAAC,KAAK,CAAC;EAE3CD,SAAS,CAAC,MAAM;IACd,MAAMW,eAAe,GAAIC,YAA+B,IAAK;MAC3DH,QAAQ,CAAC;QAAEG,YAAY;QAAEC,kBAAkB,EAAED,YAAY,CAAC,CAAC;MAAE,CAAC,CAAC;IACjE,CAAC;IAED,MAAME,YAAY,GAAGP,uCAAuC,CAC1DD,uBAAuB;IACvB;IACAJ,eAAe,EACfS,eACF,CAAC;IACD,OAAO,MAAMG,YAAY,CAACC,WAAW,CAAC,CAAC;EACzC,CAAC,EAAE,CAACN,QAAQ,CAAC,CAAC;EAEdT,SAAS,CAAC,MAAM;IACd,MAAMgB,eAAe,GAAIC,YAA+B,IAAK;MAC3D,IAAIA,YAAY,CAACC,MAAM,GAAG,CAAC,IAAI,CAACR,qBAAqB,CAACS,OAAO,EAAE;QAC7D,MAAMC,sBAAsB,GAAGH,YAAY,CAACI,IAAI,CAC7CC,WAAW,IACVA,WAAW,CAACC,IAAI,KAAK,YAAY,IAAID,WAAW,CAACE,MAAM,KAAK,OAChE,CAAC;QACD,MAAMC,kBAAkB,GAAGL,sBAAsB,IAAIH,YAAY,CAAC,CAAC,CAAC;QACpE,IAAIQ,kBAAkB,EAAE;UACtBf,qBAAqB,CAACS,OAAO,GAAG,IAAI;UACpCV,QAAQ,CAAC;YAAEQ,YAAY;YAAES,kBAAkB,EAAED;UAAmB,CAAC,CAAC;UAClE;QACF;MACF;MACAhB,QAAQ,CAAC;QAAEQ;MAAa,CAAC,CAAC;IAC5B,CAAC;IACD,MAAMH,YAAY,GAAGP,uCAAuC,CAC1DF,0BAA0B;IAC1B;IACAF,eAAe,EACfa,eACF,CAAC;IACD,OAAO,MAAMF,YAAY,CAACC,WAAW,CAAC,CAAC;EACzC,CAAC,EAAE,CAACN,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { switchMap } from 'rxjs/operators';
|
|
2
|
-
import { BehaviorSubject, EMPTY } from 'rxjs';
|
|
3
|
-
export const isCameraPermissionGranted$ = new BehaviorSubject(false);
|
|
4
|
-
export const isMicPermissionGranted$ = new BehaviorSubject(false);
|
|
5
|
-
export const subscribeToDevicesWhenPermissionGranted = (isDevicePermissionGranted$, getDevicesFunc, subscriptionCallback) => isDevicePermissionGranted$.pipe(switchMap(isDevicePermissionGranted => {
|
|
6
|
-
// if we don't have mic permission, we don't need to get the audio devices
|
|
7
|
-
// because we won't be able to use them anyway and this will trigger a permission request
|
|
8
|
-
// from RN WebRTC lib. This is not ideal because we want to control when the permission.
|
|
9
|
-
if (!isDevicePermissionGranted) {
|
|
10
|
-
// otherwise return EMPTY, which is an Observable that does nothing and just completes immediately
|
|
11
|
-
return EMPTY;
|
|
12
|
-
}
|
|
13
|
-
return getDevicesFunc();
|
|
14
|
-
})).subscribe(subscriptionCallback);
|
|
15
|
-
//# sourceMappingURL=permissions.js.map
|