@stream-io/video-react-sdk 0.0.1-alpha.9 → 0.0.1-alpha.90
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 +21 -153
- package/README.md +1 -1
- package/dist/css/styles.css +273 -407
- package/dist/css/styles.css.map +1 -1
- package/dist/src/components/Button/CompositeButton.js +2 -4
- package/dist/src/components/Button/CompositeButton.js.map +1 -1
- package/dist/src/components/CallControls/AcceptCallButton.d.ts +7 -0
- package/dist/src/components/CallControls/AcceptCallButton.js +27 -0
- package/dist/src/components/CallControls/AcceptCallButton.js.map +1 -0
- package/dist/src/components/CallControls/CallControls.d.ts +1 -3
- package/dist/src/components/CallControls/CallControls.js +2 -5
- package/dist/src/components/CallControls/CallControls.js.map +1 -1
- package/dist/src/components/CallControls/CallStatsButton.d.ts +1 -5
- package/dist/src/components/CallControls/CallStatsButton.js +2 -4
- package/dist/src/components/CallControls/CallStatsButton.js.map +1 -1
- package/dist/src/components/CallControls/CancelCallButton.d.ts +2 -3
- package/dist/src/components/CallControls/CancelCallButton.js +4 -2
- package/dist/src/components/CallControls/CancelCallButton.js.map +1 -1
- package/dist/src/components/CallControls/ReactionsButton.js +1 -2
- package/dist/src/components/CallControls/ReactionsButton.js.map +1 -1
- package/dist/src/components/CallControls/RecordCallButton.d.ts +1 -3
- package/dist/src/components/CallControls/RecordCallButton.js +10 -6
- package/dist/src/components/CallControls/RecordCallButton.js.map +1 -1
- package/dist/src/components/CallControls/ScreenShareButton.d.ts +1 -3
- package/dist/src/components/CallControls/ScreenShareButton.js +7 -7
- package/dist/src/components/CallControls/ScreenShareButton.js.map +1 -1
- package/dist/src/components/CallControls/ToggleAudioButton.d.ts +1 -1
- package/dist/src/components/CallControls/ToggleAudioButton.js +17 -10
- package/dist/src/components/CallControls/ToggleAudioButton.js.map +1 -1
- package/dist/src/components/CallControls/ToggleVideoButton.d.ts +10 -0
- package/dist/src/components/CallControls/{ToggleCameraButton.js → ToggleVideoButton.js} +17 -11
- package/dist/src/components/CallControls/ToggleVideoButton.js.map +1 -0
- package/dist/src/components/CallControls/index.d.ts +2 -2
- package/dist/src/components/CallControls/index.js +2 -2
- package/dist/src/components/CallControls/index.js.map +1 -1
- package/dist/src/components/CallParticipantsList/BlockedUserListing.js +1 -2
- package/dist/src/components/CallParticipantsList/BlockedUserListing.js.map +1 -1
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.d.ts +2 -1
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.js +13 -5
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.js.map +1 -1
- package/dist/src/components/CallParticipantsList/CallParticipantsList.js +1 -2
- package/dist/src/components/CallParticipantsList/CallParticipantsList.js.map +1 -1
- package/dist/src/components/CallStats/CallStats.d.ts +6 -0
- package/dist/src/components/{StreamCall → CallStats}/CallStats.js +3 -3
- package/dist/src/components/CallStats/CallStats.js.map +1 -0
- package/dist/src/components/CallStats/CallStatsLatencyChart.js.map +1 -0
- package/dist/src/components/CallStats/index.d.ts +2 -0
- package/dist/src/components/CallStats/index.js +3 -0
- package/dist/src/components/CallStats/index.js.map +1 -0
- package/dist/src/components/Debug/DebugStatsView.d.ts +1 -1
- package/dist/src/components/Debug/DebugStatsView.js +32 -7
- package/dist/src/components/Debug/DebugStatsView.js.map +1 -1
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.js +5 -3
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.js.map +1 -1
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.js +3 -2
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.js.map +1 -1
- package/dist/src/components/Notification/SpeakingWhileMutedNotification.js +4 -2
- package/dist/src/components/Notification/SpeakingWhileMutedNotification.js.map +1 -1
- package/dist/src/components/PendingCallPanel/PendingCallControls.d.ts +2 -0
- package/dist/src/components/PendingCallPanel/PendingCallControls.js +13 -0
- package/dist/src/components/PendingCallPanel/PendingCallControls.js.map +1 -0
- package/dist/src/components/PendingCallPanel/PendingCallPanel.d.ts +2 -0
- package/dist/src/components/PendingCallPanel/PendingCallPanel.js +34 -0
- package/dist/src/components/PendingCallPanel/PendingCallPanel.js.map +1 -0
- package/dist/src/components/PendingCallPanel/index.d.ts +2 -0
- package/dist/src/components/PendingCallPanel/index.js +3 -0
- package/dist/src/components/PendingCallPanel/index.js.map +1 -0
- package/dist/src/components/Permissions/PermissionRequests.js +2 -8
- package/dist/src/components/Permissions/PermissionRequests.js.map +1 -1
- package/dist/src/components/StreamCall/CallParticipantsScreenView.js +3 -3
- package/dist/src/components/StreamCall/CallParticipantsScreenView.js.map +1 -1
- package/dist/src/components/StreamCall/CallParticipantsView.js +2 -3
- package/dist/src/components/StreamCall/CallParticipantsView.js.map +1 -1
- package/dist/src/components/StreamTheme/StreamTheme.d.ts +5 -0
- package/dist/src/components/StreamTheme/StreamTheme.js +18 -0
- package/dist/src/components/StreamTheme/StreamTheme.js.map +1 -0
- package/dist/src/components/StreamTheme/index.d.ts +1 -0
- package/dist/src/components/StreamTheme/index.js +2 -0
- package/dist/src/components/StreamTheme/index.js.map +1 -0
- package/dist/src/components/Video/VideoPreview.js +10 -5
- package/dist/src/components/Video/VideoPreview.js.map +1 -1
- package/dist/src/components/Video/index.d.ts +1 -1
- package/dist/src/components/Video/index.js +1 -1
- package/dist/src/components/Video/index.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.js +2 -2
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.d.ts +3 -7
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.js +13 -14
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.js.map +1 -1
- package/dist/src/core/components/CallLayout/SpeakerLayout.d.ts +6 -1
- package/dist/src/core/components/CallLayout/SpeakerLayout.js +13 -7
- package/dist/src/core/components/CallLayout/SpeakerLayout.js.map +1 -1
- package/dist/src/core/components/ParticipantView/DefaultParticipantViewUI.d.ts +18 -0
- package/dist/src/core/components/ParticipantView/DefaultParticipantViewUI.js +36 -0
- package/dist/src/core/components/ParticipantView/DefaultParticipantViewUI.js.map +1 -0
- package/dist/src/core/components/ParticipantView/ParticipantView.d.ts +79 -0
- package/dist/src/core/components/ParticipantView/ParticipantView.js +33 -0
- package/dist/src/core/components/ParticipantView/ParticipantView.js.map +1 -0
- package/dist/src/core/components/ParticipantView/index.d.ts +2 -0
- package/dist/src/core/components/ParticipantView/index.js +3 -0
- package/dist/src/core/components/ParticipantView/index.js.map +1 -0
- package/dist/src/core/components/StreamCall/StreamCall.d.ts +73 -0
- package/dist/src/core/components/StreamCall/StreamCall.js +60 -0
- package/dist/src/core/components/StreamCall/StreamCall.js.map +1 -0
- package/dist/src/core/components/StreamCall/index.d.ts +1 -0
- package/dist/src/core/components/StreamCall/index.js +2 -0
- package/dist/src/core/components/StreamCall/index.js.map +1 -0
- package/dist/src/core/components/Video/BaseVideo.d.ts +3 -3
- package/dist/src/core/components/Video/BaseVideo.js +6 -12
- package/dist/src/core/components/Video/BaseVideo.js.map +1 -1
- package/dist/src/core/components/Video/DefaultVideoPlaceholder.d.ts +6 -0
- package/dist/src/core/components/Video/DefaultVideoPlaceholder.js +9 -0
- package/dist/src/core/components/Video/DefaultVideoPlaceholder.js.map +1 -0
- package/dist/src/core/components/Video/Video.d.ts +11 -6
- package/dist/src/core/components/Video/Video.js +31 -28
- package/dist/src/core/components/Video/Video.js.map +1 -1
- package/dist/src/core/components/index.d.ts +3 -2
- package/dist/src/core/components/index.js +2 -1
- package/dist/src/core/components/index.js.map +1 -1
- package/dist/src/core/contexts/MediaDevicesContext.d.ts +117 -19
- package/dist/src/core/contexts/MediaDevicesContext.js +52 -90
- package/dist/src/core/contexts/MediaDevicesContext.js.map +1 -1
- package/dist/src/core/hooks/index.d.ts +2 -0
- package/dist/src/core/hooks/index.js +2 -0
- package/dist/src/core/hooks/index.js.map +1 -1
- package/dist/src/core/hooks/useAudioPublisher.js +9 -3
- package/dist/src/core/hooks/useAudioPublisher.js.map +1 -1
- package/dist/src/core/hooks/useDevices.d.ts +80 -0
- package/dist/src/core/hooks/useDevices.js +113 -0
- package/dist/src/core/hooks/useDevices.js.map +1 -0
- package/dist/src/core/hooks/useTrackElementVisibility.d.ts +6 -0
- package/dist/src/core/hooks/useTrackElementVisibility.js +27 -0
- package/dist/src/core/hooks/useTrackElementVisibility.js.map +1 -0
- package/dist/src/core/hooks/useVideoPublisher.js +35 -6
- package/dist/src/core/hooks/useVideoPublisher.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.js +0 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/utilities/applyElementToRef.d.ts +2 -0
- package/dist/src/utilities/applyElementToRef.js +8 -0
- package/dist/src/utilities/applyElementToRef.js.map +1 -0
- package/dist/src/utilities/chunk.d.ts +1 -0
- package/dist/src/utilities/chunk.js +5 -0
- package/dist/src/utilities/chunk.js.map +1 -0
- package/dist/src/utilities/index.d.ts +3 -0
- package/dist/src/utilities/index.js +4 -0
- package/dist/src/utilities/index.js.map +1 -0
- package/dist/src/utilities/isComponentType.d.ts +2 -0
- package/dist/src/utilities/isComponentType.js +7 -0
- package/dist/src/utilities/isComponentType.js.map +1 -0
- package/package.json +12 -10
- package/src/components/Button/CompositeButton.tsx +4 -13
- package/src/components/CallControls/AcceptCallButton.tsx +36 -0
- package/src/components/CallControls/CallControls.tsx +13 -19
- package/src/components/CallControls/CallStatsButton.tsx +6 -14
- package/src/components/CallControls/CancelCallButton.tsx +12 -4
- package/src/components/CallControls/ReactionsButton.tsx +1 -2
- package/src/components/CallControls/RecordCallButton.tsx +12 -7
- package/src/components/CallControls/ScreenShareButton.tsx +7 -8
- package/src/components/CallControls/ToggleAudioButton.tsx +23 -12
- package/src/components/CallControls/{ToggleCameraButton.tsx → ToggleVideoButton.tsx} +20 -13
- package/src/components/CallControls/index.ts +2 -2
- package/src/components/CallParticipantsList/BlockedUserListing.tsx +1 -2
- package/src/components/CallParticipantsList/CallParticipantListingItem.tsx +27 -3
- package/src/components/CallParticipantsList/CallParticipantsList.tsx +1 -1
- package/src/components/{StreamCall → CallStats}/CallStats.tsx +3 -3
- package/src/components/CallStats/index.ts +2 -0
- package/src/components/Debug/DebugStatsView.tsx +60 -7
- package/src/components/DeviceSettings/DeviceSelectorAudio.tsx +9 -4
- package/src/components/DeviceSettings/DeviceSelectorVideo.tsx +3 -3
- package/src/components/Notification/SpeakingWhileMutedNotification.tsx +9 -8
- package/src/components/PendingCallPanel/PendingCallControls.tsx +27 -0
- package/src/components/PendingCallPanel/PendingCallPanel.tsx +71 -0
- package/src/components/PendingCallPanel/index.ts +2 -0
- package/src/components/Permissions/PermissionRequests.tsx +2 -8
- package/src/components/StreamCall/CallParticipantsScreenView.tsx +3 -4
- package/src/components/StreamCall/CallParticipantsView.tsx +3 -4
- package/src/components/StreamTheme/StreamTheme.tsx +19 -0
- package/src/components/StreamTheme/index.ts +1 -0
- package/src/components/Video/VideoPreview.tsx +16 -6
- package/src/components/Video/index.ts +1 -1
- package/src/components/index.ts +2 -2
- package/src/core/components/CallLayout/PaginatedGridLayout.tsx +32 -36
- package/src/core/components/CallLayout/SpeakerLayout.tsx +48 -25
- package/src/core/components/ParticipantView/DefaultParticipantViewUI.tsx +160 -0
- package/src/core/components/ParticipantView/ParticipantView.tsx +156 -0
- package/src/core/components/ParticipantView/index.ts +2 -0
- package/src/core/components/StreamCall/StreamCall.tsx +157 -0
- package/src/core/components/StreamCall/index.ts +1 -0
- package/src/core/components/Video/BaseVideo.tsx +9 -24
- package/src/core/components/Video/DefaultVideoPlaceholder.tsx +36 -0
- package/src/core/components/Video/Video.tsx +62 -48
- package/src/core/components/index.ts +3 -2
- package/src/core/contexts/MediaDevicesContext.tsx +179 -136
- package/src/core/hooks/index.ts +2 -0
- package/src/core/hooks/useAudioPublisher.ts +9 -3
- package/src/core/hooks/useDevices.ts +161 -0
- package/src/core/hooks/useTrackElementVisibility.ts +44 -0
- package/src/core/hooks/useVideoPublisher.ts +36 -4
- package/src/hooks/index.ts +0 -1
- package/src/utilities/applyElementToRef.ts +12 -0
- package/src/utilities/chunk.ts +8 -0
- package/src/utilities/index.ts +3 -0
- package/src/utilities/isComponentType.ts +9 -0
- package/dist/src/components/CallControls/ToggleCameraButton.d.ts +0 -10
- package/dist/src/components/CallControls/ToggleCameraButton.js.map +0 -1
- package/dist/src/components/CallControls/ToggleParticipantListButton.d.ts +0 -6
- package/dist/src/components/CallControls/ToggleParticipantListButton.js +0 -7
- package/dist/src/components/CallControls/ToggleParticipantListButton.js.map +0 -1
- package/dist/src/components/Moderation/Restricted.d.ts +0 -19
- package/dist/src/components/Moderation/Restricted.js +0 -13
- package/dist/src/components/Moderation/Restricted.js.map +0 -1
- package/dist/src/components/Moderation/index.d.ts +0 -1
- package/dist/src/components/Moderation/index.js +0 -2
- package/dist/src/components/Moderation/index.js.map +0 -1
- package/dist/src/components/StreamCall/CallStats.d.ts +0 -2
- package/dist/src/components/StreamCall/CallStats.js.map +0 -1
- package/dist/src/components/StreamCall/CallStatsLatencyChart.js.map +0 -1
- package/dist/src/components/StreamMeeting/StreamMeeting.d.ts +0 -34
- package/dist/src/components/StreamMeeting/StreamMeeting.js +0 -26
- package/dist/src/components/StreamMeeting/StreamMeeting.js.map +0 -1
- package/dist/src/components/StreamMeeting/index.d.ts +0 -1
- package/dist/src/components/StreamMeeting/index.js +0 -2
- package/dist/src/components/StreamMeeting/index.js.map +0 -1
- package/dist/src/core/components/ParticipantBox/ParticipantBox.d.ts +0 -48
- package/dist/src/core/components/ParticipantBox/ParticipantBox.js +0 -58
- package/dist/src/core/components/ParticipantBox/ParticipantBox.js.map +0 -1
- package/dist/src/core/components/ParticipantBox/index.d.ts +0 -1
- package/dist/src/core/components/ParticipantBox/index.js +0 -2
- package/dist/src/core/components/ParticipantBox/index.js.map +0 -1
- package/dist/src/core/components/Video/VideoPlaceholder.d.ts +0 -6
- package/dist/src/core/components/Video/VideoPlaceholder.js +0 -12
- package/dist/src/core/components/Video/VideoPlaceholder.js.map +0 -1
- package/dist/src/hooks/useRtcStats.d.ts +0 -11
- package/dist/src/hooks/useRtcStats.js +0 -39
- package/dist/src/hooks/useRtcStats.js.map +0 -1
- package/src/components/CallControls/ToggleParticipantListButton.tsx +0 -17
- package/src/components/Moderation/Restricted.tsx +0 -38
- package/src/components/Moderation/index.ts +0 -1
- package/src/components/StreamMeeting/StreamMeeting.tsx +0 -80
- package/src/components/StreamMeeting/index.ts +0 -1
- package/src/core/components/ParticipantBox/ParticipantBox.tsx +0 -248
- package/src/core/components/ParticipantBox/index.ts +0 -1
- package/src/core/components/Video/VideoPlaceholder.tsx +0 -40
- package/src/hooks/useRtcStats.ts +0 -36
- /package/dist/src/components/{StreamCall → CallStats}/CallStatsLatencyChart.d.ts +0 -0
- /package/dist/src/components/{StreamCall → CallStats}/CallStatsLatencyChart.js +0 -0
- /package/src/components/{StreamCall → CallStats}/CallStatsLatencyChart.tsx +0 -0
|
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { createContext, useCallback, useContext, useEffect, useState, } from 'react';
|
|
12
|
-
import { map
|
|
13
|
-
import { CallingState, checkIfAudioOutputChangeSupported, disposeOfMediaStream,
|
|
14
|
-
import { useCall, useCallCallingState, useCallState, } from '@stream-io/video-react-bindings';
|
|
15
|
-
import { useAudioPublisher, useVideoPublisher } from '../hooks';
|
|
12
|
+
import { map } from 'rxjs';
|
|
13
|
+
import { CallingState, checkIfAudioOutputChangeSupported, disposeOfMediaStream, getAudioStream, getVideoStream, SfuModels, watchForDisconnectedAudioOutputDevice, } from '@stream-io/video-client';
|
|
14
|
+
import { useCall, useCallCallingState, useCallMetadata, useCallState, } from '@stream-io/video-react-bindings';
|
|
15
|
+
import { useAudioInputDeviceFallback, useAudioOutputDeviceFallback, useAudioPublisher, useVideoDeviceFallback, useVideoPublisher, } from '../hooks';
|
|
16
16
|
const DEVICE_STATE_TOGGLE = {
|
|
17
17
|
starting: 'stopped',
|
|
18
18
|
playing: 'stopped',
|
|
@@ -21,7 +21,7 @@ const DEVICE_STATE_TOGGLE = {
|
|
|
21
21
|
error: 'starting',
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* Exclude types from
|
|
24
|
+
* Exclude types from documentation site, but we should still add doc comments
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
27
|
export const DEVICE_STATE = {
|
|
@@ -31,29 +31,52 @@ export const DEVICE_STATE = {
|
|
|
31
31
|
uninitialized: { type: 'uninitialized', enabled: false },
|
|
32
32
|
error: { type: 'error', message: '', enabled: false },
|
|
33
33
|
};
|
|
34
|
+
const DEFAULT_DEVICE_ID = 'default';
|
|
34
35
|
const MediaDevicesContext = createContext(null);
|
|
35
|
-
// todo: republish the stream, when a new default device connected
|
|
36
36
|
/**
|
|
37
|
+
* Context provider that internally puts in place mechanisms that:
|
|
38
|
+
* 1. fall back to selecting a default device when trying to switch to a non-existent device
|
|
39
|
+
* 2. fall back to a default device when an active device is disconnected
|
|
40
|
+
* 3. stop publishing a media stream when a non-default device is disconnected
|
|
41
|
+
* 4. republish a media stream from the newly connected default device
|
|
42
|
+
* 5. republish a media stream when a new device is selected
|
|
37
43
|
*
|
|
38
|
-
*
|
|
44
|
+
* Provides `MediaDevicesContextAPI` that allow the integrators to handle:
|
|
45
|
+
* 1. the initial device state enablement (for example apt for lobby scenario)
|
|
46
|
+
* 2. media stream retrieval and disposal
|
|
47
|
+
* 3. media stream publishing
|
|
48
|
+
* 4. specific device selection
|
|
49
|
+
* @param params
|
|
39
50
|
* @returns
|
|
40
51
|
*
|
|
41
52
|
* @category Device Management
|
|
42
53
|
*/
|
|
43
|
-
export const MediaDevicesProvider = ({ children,
|
|
54
|
+
export const MediaDevicesProvider = ({ children, initialAudioEnabled, initialVideoEnabled, initialVideoInputDeviceId = DEFAULT_DEVICE_ID, initialAudioOutputDeviceId = DEFAULT_DEVICE_ID, initialAudioInputDeviceId = DEFAULT_DEVICE_ID, }) => {
|
|
44
55
|
const call = useCall();
|
|
45
56
|
const callingState = useCallCallingState();
|
|
46
57
|
const callState = useCallState();
|
|
58
|
+
const metadata = useCallMetadata();
|
|
47
59
|
const { localParticipant$ } = callState;
|
|
48
|
-
const [
|
|
49
|
-
const [
|
|
50
|
-
const [audioOutputDevices, setAudioOutputDevices] = useState([]);
|
|
51
|
-
const [selectedAudioInputDeviceId, setSelectedAudioInputDeviceId] = useState(initialAudioInputDeviceId);
|
|
52
|
-
const [selectedAudioOutputDeviceId, setSelectedAudioOutputDeviceId] = useState(initialAudioOutputDeviceId);
|
|
60
|
+
const [selectedAudioInputDeviceId, selectAudioInputDeviceId] = useState(initialAudioInputDeviceId);
|
|
61
|
+
const [selectedAudioOutputDeviceId, selectAudioOutputDeviceId] = useState(initialAudioOutputDeviceId);
|
|
53
62
|
const [selectedVideoDeviceId, selectVideoDeviceId] = useState(initialVideoInputDeviceId);
|
|
54
63
|
const [isAudioOutputChangeSupported] = useState(() => checkIfAudioOutputChangeSupported());
|
|
55
|
-
const [initAudioEnabled,
|
|
64
|
+
const [initAudioEnabled, setInitialAudioEnabled] = useState(!!initialAudioEnabled);
|
|
56
65
|
const [initialVideoState, setInitialVideoState] = useState(() => initialVideoEnabled ? DEVICE_STATE.starting : DEVICE_STATE.uninitialized);
|
|
66
|
+
const settings = metadata === null || metadata === void 0 ? void 0 : metadata.settings;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!settings ||
|
|
69
|
+
![CallingState.IDLE, CallingState.RINGING].includes(callingState)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const { audio, video } = settings;
|
|
73
|
+
if (typeof initialAudioEnabled === 'undefined' && audio.mic_default_on) {
|
|
74
|
+
setInitialAudioEnabled(audio.mic_default_on);
|
|
75
|
+
}
|
|
76
|
+
if (typeof initialVideoEnabled === 'undefined' && video.camera_default_on) {
|
|
77
|
+
setInitialVideoState(DEVICE_STATE.starting);
|
|
78
|
+
}
|
|
79
|
+
}, [callingState, initialAudioEnabled, initialVideoEnabled, settings]);
|
|
57
80
|
const publishVideoStream = useVideoPublisher({
|
|
58
81
|
initialVideoMuted: !initialVideoState.enabled,
|
|
59
82
|
videoDeviceId: selectedVideoDeviceId,
|
|
@@ -65,7 +88,7 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
65
88
|
const stopPublishingAudio = useCallback(() => {
|
|
66
89
|
if (callingState === CallingState.IDLE ||
|
|
67
90
|
callingState === CallingState.RINGING) {
|
|
68
|
-
|
|
91
|
+
setInitialAudioEnabled(false);
|
|
69
92
|
}
|
|
70
93
|
else {
|
|
71
94
|
call === null || call === void 0 ? void 0 : call.stopPublish(SfuModels.TrackType.AUDIO);
|
|
@@ -80,8 +103,10 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
80
103
|
call === null || call === void 0 ? void 0 : call.stopPublish(SfuModels.TrackType.VIDEO);
|
|
81
104
|
}
|
|
82
105
|
}, [call, callingState]);
|
|
83
|
-
const
|
|
84
|
-
|
|
106
|
+
const toggleInitialAudioMuteState = useCallback(() => setInitialAudioEnabled((prev) => {
|
|
107
|
+
return !prev;
|
|
108
|
+
}), []);
|
|
109
|
+
const toggleInitialVideoMuteState = useCallback(() => setInitialVideoState((prev) => {
|
|
85
110
|
const newType = DEVICE_STATE_TOGGLE[prev.type];
|
|
86
111
|
return DEVICE_STATE[newType];
|
|
87
112
|
}), []);
|
|
@@ -90,76 +115,15 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
90
115
|
selectVideoDeviceId(deviceId);
|
|
91
116
|
}
|
|
92
117
|
if (kind === 'audioinput') {
|
|
93
|
-
|
|
118
|
+
selectAudioInputDeviceId(deviceId);
|
|
94
119
|
}
|
|
95
120
|
if (kind === 'audiooutput') {
|
|
96
|
-
|
|
121
|
+
selectAudioOutputDeviceId(deviceId);
|
|
97
122
|
}
|
|
98
123
|
}, []);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const validateInitialInputDeviceId = getAudioDevices()
|
|
103
|
-
.pipe(take(1))
|
|
104
|
-
.subscribe((devices) => {
|
|
105
|
-
const initialDeviceFound = devices.find((device) => device.deviceId === initialAudioInputDeviceId);
|
|
106
|
-
if (!initialDeviceFound) {
|
|
107
|
-
setSelectedAudioInputDeviceId('default');
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
const subscription = getAudioDevices().subscribe(setAudioInputDevices);
|
|
111
|
-
return () => {
|
|
112
|
-
subscription.unsubscribe();
|
|
113
|
-
validateInitialInputDeviceId.unsubscribe();
|
|
114
|
-
};
|
|
115
|
-
}, [enumerate, initialAudioInputDeviceId]);
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
if (!enumerate)
|
|
118
|
-
return;
|
|
119
|
-
const validateInitialInputDeviceId = getVideoDevices()
|
|
120
|
-
.pipe(take(1))
|
|
121
|
-
.subscribe((devices) => {
|
|
122
|
-
const initialDeviceFound = devices.find((device) => device.deviceId === initialVideoInputDeviceId);
|
|
123
|
-
if (!initialDeviceFound) {
|
|
124
|
-
selectVideoDeviceId('default');
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const subscription = getVideoDevices().subscribe(setVideoDevices);
|
|
128
|
-
return () => {
|
|
129
|
-
subscription.unsubscribe();
|
|
130
|
-
validateInitialInputDeviceId.unsubscribe();
|
|
131
|
-
};
|
|
132
|
-
}, [enumerate, initialVideoInputDeviceId]);
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
if (!enumerate)
|
|
135
|
-
return;
|
|
136
|
-
const validateInitialInputDeviceId = getAudioOutputDevices()
|
|
137
|
-
.pipe(take(1))
|
|
138
|
-
.subscribe((devices) => {
|
|
139
|
-
const initialDeviceFound = devices.find((device) => device.deviceId === initialAudioOutputDeviceId);
|
|
140
|
-
if (!initialDeviceFound) {
|
|
141
|
-
setSelectedAudioOutputDeviceId('default');
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const subscription = getAudioOutputDevices().subscribe(setAudioOutputDevices);
|
|
145
|
-
return () => {
|
|
146
|
-
subscription.unsubscribe();
|
|
147
|
-
validateInitialInputDeviceId.unsubscribe();
|
|
148
|
-
};
|
|
149
|
-
}, [enumerate, initialAudioOutputDeviceId]);
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
const subscription = getVideoDevices()
|
|
152
|
-
.pipe(pairwise())
|
|
153
|
-
.subscribe(([prev, current]) => {
|
|
154
|
-
// When there are 0 video devices (e.g. when laptop lid closed),
|
|
155
|
-
// we do not restart the video automatically when the device is again available,
|
|
156
|
-
// but rather leave this to the user.
|
|
157
|
-
if (prev.length > 0 && current.length === 0) {
|
|
158
|
-
setInitialVideoState(DEVICE_STATE.stopped);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return () => subscription.unsubscribe();
|
|
162
|
-
}, [videoDevices.length]);
|
|
124
|
+
useAudioInputDeviceFallback(() => switchDevice('audioinput', DEFAULT_DEVICE_ID), selectedAudioInputDeviceId);
|
|
125
|
+
useAudioOutputDeviceFallback(() => switchDevice('audiooutput', DEFAULT_DEVICE_ID), selectedAudioOutputDeviceId);
|
|
126
|
+
useVideoDeviceFallback(() => switchDevice('videoinput', DEFAULT_DEVICE_ID), selectedVideoDeviceId);
|
|
163
127
|
useEffect(() => {
|
|
164
128
|
if (!call || callingState !== CallingState.JOINED)
|
|
165
129
|
return;
|
|
@@ -169,16 +133,13 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
169
133
|
if (!localParticipant$)
|
|
170
134
|
return;
|
|
171
135
|
const subscription = watchForDisconnectedAudioOutputDevice(localParticipant$.pipe(map((p) => p === null || p === void 0 ? void 0 : p.audioOutputDeviceId))).subscribe(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
|
|
136
|
+
selectAudioOutputDeviceId(DEFAULT_DEVICE_ID);
|
|
173
137
|
}));
|
|
174
138
|
return () => {
|
|
175
139
|
subscription.unsubscribe();
|
|
176
140
|
};
|
|
177
141
|
}, [localParticipant$]);
|
|
178
142
|
const contextValue = {
|
|
179
|
-
audioInputDevices,
|
|
180
|
-
videoDevices,
|
|
181
|
-
audioOutputDevices,
|
|
182
143
|
disposeOfMediaStream,
|
|
183
144
|
getAudioStream,
|
|
184
145
|
getVideoStream,
|
|
@@ -189,9 +150,10 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
189
150
|
switchDevice,
|
|
190
151
|
initialAudioEnabled: initAudioEnabled,
|
|
191
152
|
initialVideoState,
|
|
153
|
+
setInitialAudioEnabled,
|
|
192
154
|
setInitialVideoState,
|
|
193
|
-
|
|
194
|
-
|
|
155
|
+
toggleInitialAudioMuteState,
|
|
156
|
+
toggleInitialVideoMuteState,
|
|
195
157
|
publishAudioStream,
|
|
196
158
|
publishVideoStream,
|
|
197
159
|
stopPublishingAudio,
|
|
@@ -200,7 +162,7 @@ export const MediaDevicesProvider = ({ children, enumerate = true, initialAudioE
|
|
|
200
162
|
return (_jsx(MediaDevicesContext.Provider, Object.assign({ value: contextValue }, { children: children })));
|
|
201
163
|
};
|
|
202
164
|
/**
|
|
203
|
-
*
|
|
165
|
+
* Context consumer retrieving MediaDevicesContextAPI.
|
|
204
166
|
* @returns
|
|
205
167
|
*
|
|
206
168
|
* @category Device Management
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaDevicesContext.js","sourceRoot":"","sources":["../../../../src/core/contexts/MediaDevicesContext.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EACL,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"MediaDevicesContext.js","sourceRoot":"","sources":["../../../../src/core/contexts/MediaDev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MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,KAAK,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC9C,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;KAC1C;IACD,OAAO,KAA+B,CAAC;AACzC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC"}
|
|
@@ -29,7 +29,9 @@ export const useAudioPublisher = ({ initialAudioMuted, audioDeviceId, }) => {
|
|
|
29
29
|
throw new Error(`No permission to publish audio`);
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
const audioStream = yield getAudioStream(
|
|
32
|
+
const audioStream = yield getAudioStream({
|
|
33
|
+
deviceId: audioDeviceId,
|
|
34
|
+
});
|
|
33
35
|
yield call.publishAudioStream(audioStream);
|
|
34
36
|
}
|
|
35
37
|
catch (e) {
|
|
@@ -69,12 +71,16 @@ export const useAudioPublisher = ({ initialAudioMuted, audioDeviceId, }) => {
|
|
|
69
71
|
// We need to stop the original track first in order
|
|
70
72
|
// we can retrieve the new default device stream
|
|
71
73
|
track.stop();
|
|
72
|
-
const audioStream = yield getAudioStream(
|
|
74
|
+
const audioStream = yield getAudioStream({
|
|
75
|
+
deviceId: 'default',
|
|
76
|
+
});
|
|
73
77
|
yield call.publishAudioStream(audioStream);
|
|
74
78
|
}));
|
|
75
79
|
const handleTrackEnded = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
80
|
if (selectedAudioDeviceId === audioDeviceId) {
|
|
77
|
-
const audioStream = yield getAudioStream(
|
|
81
|
+
const audioStream = yield getAudioStream({
|
|
82
|
+
deviceId: audioDeviceId,
|
|
83
|
+
});
|
|
78
84
|
yield call.publishAudioStream(audioStream);
|
|
79
85
|
}
|
|
80
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioPublisher.js","sourceRoot":"","sources":["../../../../src/core/hooks/useAudioPublisher.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,SAAS,EACT,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAUzC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,iBAAiB,EACjB,aAAa,GACM,EAAE,EAAE;IACvB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAExC,MAAM,iBAAiB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,CAAC,QAAQ,CAC7D,SAAS,CAAC,SAAS,CAAC,KAAK,CAC1B,CAAC;IAEF,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAS,EAAE;QAChD,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC,IAAI,CAAC,kBAA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,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEvE,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Observes changes in connected devices and maintains an up-to-date array of connected MediaDeviceInfo objects.
|
|
4
|
+
* @param observeDevices
|
|
5
|
+
* @category Device Management
|
|
6
|
+
*/
|
|
7
|
+
export declare const useDevices: (observeDevices: () => Observable<MediaDeviceInfo[]>) => MediaDeviceInfo[];
|
|
8
|
+
/**
|
|
9
|
+
* Observes changes and maintains an array of connected video input devices
|
|
10
|
+
* @category Device Management
|
|
11
|
+
*/
|
|
12
|
+
export declare const useVideoDevices: () => MediaDeviceInfo[];
|
|
13
|
+
/**
|
|
14
|
+
* Observes changes and maintains an array of connected audio input devices
|
|
15
|
+
* @category Device Management
|
|
16
|
+
*/
|
|
17
|
+
export declare const useAudioInputDevices: () => MediaDeviceInfo[];
|
|
18
|
+
/**
|
|
19
|
+
* Observes changes and maintains an array of connected audio output devices
|
|
20
|
+
* @category Device Management
|
|
21
|
+
*/
|
|
22
|
+
export declare const useAudioOutputDevices: () => MediaDeviceInfo[];
|
|
23
|
+
/**
|
|
24
|
+
* Verifies that newly selected device id exists among the registered devices.
|
|
25
|
+
* If the selected device id is not found among existing devices, switches to the default device.
|
|
26
|
+
* @param devices$
|
|
27
|
+
* @param switchToDefaultDevice
|
|
28
|
+
* @param selectedDeviceId
|
|
29
|
+
* @category Device Management
|
|
30
|
+
*/
|
|
31
|
+
export declare const useDeviceFallback: (devices$: Observable<MediaDeviceInfo[]>, switchToDefaultDevice: () => void, selectedDeviceId?: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Verifies that newly selected video device id exists among the registered devices.
|
|
34
|
+
* If the selected device id is not found among existing devices, switches to the default video device.
|
|
35
|
+
* @param switchToDefaultDevice
|
|
36
|
+
* @param selectedDeviceId
|
|
37
|
+
* @category Device Management
|
|
38
|
+
*/
|
|
39
|
+
export declare const useVideoDeviceFallback: (switchToDefaultDevice: () => void, selectedDeviceId?: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Verifies that newly selected audio input device id exists among the registered devices.
|
|
42
|
+
* If the selected device id is not found among existing devices, switches to the default audio input device.
|
|
43
|
+
* @param switchToDefaultDevice
|
|
44
|
+
* @param selectedDeviceId
|
|
45
|
+
* @category Device Management
|
|
46
|
+
*/
|
|
47
|
+
export declare const useAudioInputDeviceFallback: (switchToDefaultDevice: () => void, selectedDeviceId?: string) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Verifies that newly selected audio output device id exists among the registered devices.
|
|
50
|
+
* If the selected device id is not found among existing devices, switches to the default audio output device.
|
|
51
|
+
* @param switchToDefaultDevice
|
|
52
|
+
* @param selectedDeviceId
|
|
53
|
+
* @category Device Management
|
|
54
|
+
*/
|
|
55
|
+
export declare const useAudioOutputDeviceFallback: (switchToDefaultDevice: () => void, selectedDeviceId?: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Observes devices of certain kind are made unavailable and executes onDisconnect callback
|
|
58
|
+
* @param observeDevices
|
|
59
|
+
* @param onDisconnect
|
|
60
|
+
* @category Device Management
|
|
61
|
+
*/
|
|
62
|
+
export declare const useOnUnavailableDevices: (observeDevices: Observable<MediaDeviceInfo[]>, onDisconnect: () => void) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Observes disconnect of all video devices and executes onDisconnect callback
|
|
65
|
+
* @param onDisconnect
|
|
66
|
+
* @category Device Management
|
|
67
|
+
*/
|
|
68
|
+
export declare const useOnUnavailableVideoDevices: (onDisconnect: () => void) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Observes disconnect of all audio input devices and executes onDisconnect callback
|
|
71
|
+
* @param onDisconnect
|
|
72
|
+
* @category Device Management
|
|
73
|
+
*/
|
|
74
|
+
export declare const useOnUnavailableAudioInputDevices: (onDisconnect: () => void) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Observes disconnect of all audio output devices and executes onDisconnect callback
|
|
77
|
+
* @param onDisconnect
|
|
78
|
+
* @category Device Management
|
|
79
|
+
*/
|
|
80
|
+
export declare const useOnUnavailableAudioOutputDevices: (onDisconnect: () => void) => void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { pairwise } from 'rxjs';
|
|
3
|
+
import { getAudioDevices, getAudioOutputDevices, getVideoDevices, } from '@stream-io/video-client';
|
|
4
|
+
/**
|
|
5
|
+
* Observes changes in connected devices and maintains an up-to-date array of connected MediaDeviceInfo objects.
|
|
6
|
+
* @param observeDevices
|
|
7
|
+
* @category Device Management
|
|
8
|
+
*/
|
|
9
|
+
export const useDevices = (observeDevices) => {
|
|
10
|
+
const [devices, setDevices] = useState([]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const subscription = observeDevices().subscribe(setDevices);
|
|
13
|
+
return () => {
|
|
14
|
+
subscription.unsubscribe();
|
|
15
|
+
};
|
|
16
|
+
}, [observeDevices]);
|
|
17
|
+
return devices;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Observes changes and maintains an array of connected video input devices
|
|
21
|
+
* @category Device Management
|
|
22
|
+
*/
|
|
23
|
+
export const useVideoDevices = () => useDevices(getVideoDevices);
|
|
24
|
+
/**
|
|
25
|
+
* Observes changes and maintains an array of connected audio input devices
|
|
26
|
+
* @category Device Management
|
|
27
|
+
*/
|
|
28
|
+
export const useAudioInputDevices = () => useDevices(getAudioDevices);
|
|
29
|
+
/**
|
|
30
|
+
* Observes changes and maintains an array of connected audio output devices
|
|
31
|
+
* @category Device Management
|
|
32
|
+
*/
|
|
33
|
+
export const useAudioOutputDevices = () => useDevices(getAudioOutputDevices);
|
|
34
|
+
/**
|
|
35
|
+
* Verifies that newly selected device id exists among the registered devices.
|
|
36
|
+
* If the selected device id is not found among existing devices, switches to the default device.
|
|
37
|
+
* @param devices$
|
|
38
|
+
* @param switchToDefaultDevice
|
|
39
|
+
* @param selectedDeviceId
|
|
40
|
+
* @category Device Management
|
|
41
|
+
*/
|
|
42
|
+
export const useDeviceFallback = (devices$, switchToDefaultDevice, selectedDeviceId) => {
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const validateDeviceId = devices$.pipe().subscribe((devices) => {
|
|
45
|
+
const deviceFound = devices.find((device) => device.deviceId === selectedDeviceId);
|
|
46
|
+
if (!deviceFound)
|
|
47
|
+
switchToDefaultDevice();
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
validateDeviceId.unsubscribe();
|
|
51
|
+
};
|
|
52
|
+
}, [devices$, selectedDeviceId, switchToDefaultDevice]);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Verifies that newly selected video device id exists among the registered devices.
|
|
56
|
+
* If the selected device id is not found among existing devices, switches to the default video device.
|
|
57
|
+
* @param switchToDefaultDevice
|
|
58
|
+
* @param selectedDeviceId
|
|
59
|
+
* @category Device Management
|
|
60
|
+
*/
|
|
61
|
+
export const useVideoDeviceFallback = (switchToDefaultDevice, selectedDeviceId) => useDeviceFallback(getVideoDevices(), switchToDefaultDevice, selectedDeviceId);
|
|
62
|
+
/**
|
|
63
|
+
* Verifies that newly selected audio input device id exists among the registered devices.
|
|
64
|
+
* If the selected device id is not found among existing devices, switches to the default audio input device.
|
|
65
|
+
* @param switchToDefaultDevice
|
|
66
|
+
* @param selectedDeviceId
|
|
67
|
+
* @category Device Management
|
|
68
|
+
*/
|
|
69
|
+
export const useAudioInputDeviceFallback = (switchToDefaultDevice, selectedDeviceId) => useDeviceFallback(getAudioDevices(), switchToDefaultDevice, selectedDeviceId);
|
|
70
|
+
/**
|
|
71
|
+
* Verifies that newly selected audio output device id exists among the registered devices.
|
|
72
|
+
* If the selected device id is not found among existing devices, switches to the default audio output device.
|
|
73
|
+
* @param switchToDefaultDevice
|
|
74
|
+
* @param selectedDeviceId
|
|
75
|
+
* @category Device Management
|
|
76
|
+
*/
|
|
77
|
+
export const useAudioOutputDeviceFallback = (switchToDefaultDevice, selectedDeviceId) => useDeviceFallback(getAudioOutputDevices(), switchToDefaultDevice, selectedDeviceId);
|
|
78
|
+
/**
|
|
79
|
+
* Observes devices of certain kind are made unavailable and executes onDisconnect callback
|
|
80
|
+
* @param observeDevices
|
|
81
|
+
* @param onDisconnect
|
|
82
|
+
* @category Device Management
|
|
83
|
+
*/
|
|
84
|
+
export const useOnUnavailableDevices = (observeDevices, onDisconnect) => {
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const subscription = observeDevices
|
|
87
|
+
.pipe(pairwise())
|
|
88
|
+
.subscribe(([prev, current]) => {
|
|
89
|
+
if (prev.length > 0 && current.length === 0)
|
|
90
|
+
onDisconnect();
|
|
91
|
+
});
|
|
92
|
+
return () => subscription.unsubscribe();
|
|
93
|
+
}, [observeDevices, onDisconnect]);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Observes disconnect of all video devices and executes onDisconnect callback
|
|
97
|
+
* @param onDisconnect
|
|
98
|
+
* @category Device Management
|
|
99
|
+
*/
|
|
100
|
+
export const useOnUnavailableVideoDevices = (onDisconnect) => useOnUnavailableDevices(getVideoDevices(), onDisconnect);
|
|
101
|
+
/**
|
|
102
|
+
* Observes disconnect of all audio input devices and executes onDisconnect callback
|
|
103
|
+
* @param onDisconnect
|
|
104
|
+
* @category Device Management
|
|
105
|
+
*/
|
|
106
|
+
export const useOnUnavailableAudioInputDevices = (onDisconnect) => useOnUnavailableDevices(getAudioDevices(), onDisconnect);
|
|
107
|
+
/**
|
|
108
|
+
* Observes disconnect of all audio output devices and executes onDisconnect callback
|
|
109
|
+
* @param onDisconnect
|
|
110
|
+
* @category Device Management
|
|
111
|
+
*/
|
|
112
|
+
export const useOnUnavailableAudioOutputDevices = (onDisconnect) => useOnUnavailableDevices(getAudioOutputDevices(), onDisconnect);
|
|
113
|
+
//# sourceMappingURL=useDevices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDevices.js","sourceRoot":"","sources":["../../../../src/core/hooks/useDevices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAc,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,cAAmD,EACnD,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAoB,EAAE,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,cAAc,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAE5D,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,QAAuC,EACvC,qBAAiC,EACjC,gBAAyB,EACzB,EAAE;IACF,SAAS,CAAC,GAAG,EAAE;QACb,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;YAC7B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,YAAY,EAAE,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,YAAwB,EAAE,EAAE,CACvE,uBAAuB,CAAC,eAAe,EAAE,EAAE,YAAY,CAAC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,YAAwB,EAAE,EAAE,CAC5E,uBAAuB,CAAC,eAAe,EAAE,EAAE,YAAY,CAAC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,YAAwB,EAAE,EAAE,CAC7E,uBAAuB,CAAC,qBAAqB,EAAE,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ViewportTracker } from '@stream-io/video-client';
|
|
2
|
+
export declare const useTrackElementVisibility: <T extends HTMLElement>({ trackedElement, viewportTracker: propsViewportTracker, sessionId, }: {
|
|
3
|
+
trackedElement: T | null;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
viewportTracker?: ViewportTracker | undefined;
|
|
6
|
+
}) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { VisibilityState } from '@stream-io/video-client';
|
|
3
|
+
import { useCall } from '@stream-io/video-react-bindings';
|
|
4
|
+
export const useTrackElementVisibility = ({ trackedElement, viewportTracker: propsViewportTracker, sessionId, }) => {
|
|
5
|
+
const call = useCall();
|
|
6
|
+
const viewportTracker = propsViewportTracker !== null && propsViewportTracker !== void 0 ? propsViewportTracker : call === null || call === void 0 ? void 0 : call.viewportTracker;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!trackedElement || !viewportTracker || !call)
|
|
9
|
+
return;
|
|
10
|
+
const unobserve = viewportTracker.observe(trackedElement, (entry) => {
|
|
11
|
+
call.state.updateParticipant(sessionId, (p) => (Object.assign(Object.assign({}, p), { viewportVisibilityState:
|
|
12
|
+
// observer triggers when element is "moved" to be a fullscreen element
|
|
13
|
+
// keep it VISIBLE if that happens to prevent fullscreen with placeholder
|
|
14
|
+
entry.isIntersecting || document.fullscreenElement === trackedElement
|
|
15
|
+
? VisibilityState.VISIBLE
|
|
16
|
+
: VisibilityState.INVISIBLE })));
|
|
17
|
+
});
|
|
18
|
+
return () => {
|
|
19
|
+
unobserve();
|
|
20
|
+
// reset visibility state to UNKNOWN upon cleanup
|
|
21
|
+
// so that the layouts that are not actively observed
|
|
22
|
+
// can still function normally (runtime layout switching)
|
|
23
|
+
call.state.updateParticipant(sessionId, (p) => (Object.assign(Object.assign({}, p), { viewportVisibilityState: VisibilityState.UNKNOWN })));
|
|
24
|
+
};
|
|
25
|
+
}, [trackedElement, viewportTracker, call, sessionId]);
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useTrackElementVisibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrackElementVisibility.js","sourceRoot":"","sources":["../../../../src/core/hooks/useTrackElementVisibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAmB,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAwB,EAC/D,cAAc,EACd,eAAe,EAAE,oBAAoB,EACrC,SAAS,GAKV,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,MAAM,eAAe,GAAG,oB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