@stream-io/video-react-sdk 0.0.1-alpha.9
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 +183 -0
- package/LICENSE +219 -0
- package/README.md +5 -0
- package/dist/css/styles.css +2351 -0
- package/dist/css/styles.css.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/Avatar/Avatar.d.ts +14 -0
- package/dist/src/components/Avatar/Avatar.js +11 -0
- package/dist/src/components/Avatar/Avatar.js.map +1 -0
- package/dist/src/components/Avatar/index.d.ts +1 -0
- package/dist/src/components/Avatar/index.js +2 -0
- package/dist/src/components/Avatar/index.js.map +1 -0
- package/dist/src/components/Button/CompositeButton.d.ts +16 -0
- package/dist/src/components/Button/CompositeButton.js +15 -0
- package/dist/src/components/Button/CompositeButton.js.map +1 -0
- package/dist/src/components/Button/CopyToClipboardButton.d.ts +27 -0
- package/dist/src/components/Button/CopyToClipboardButton.js +54 -0
- package/dist/src/components/Button/CopyToClipboardButton.js.map +1 -0
- package/dist/src/components/Button/IconButton.d.ts +7 -0
- package/dist/src/components/Button/IconButton.js +26 -0
- package/dist/src/components/Button/IconButton.js.map +1 -0
- package/dist/src/components/Button/TextButton.d.ts +2 -0
- package/dist/src/components/Button/TextButton.js +17 -0
- package/dist/src/components/Button/TextButton.js.map +1 -0
- package/dist/src/components/Button/index.d.ts +4 -0
- package/dist/src/components/Button/index.js +5 -0
- package/dist/src/components/Button/index.js.map +1 -0
- package/dist/src/components/CallControls/CallControls.d.ts +7 -0
- package/dist/src/components/CallControls/CallControls.js +8 -0
- package/dist/src/components/CallControls/CallControls.js.map +1 -0
- package/dist/src/components/CallControls/CallStatsButton.d.ts +6 -0
- package/dist/src/components/CallControls/CallStatsButton.js +10 -0
- package/dist/src/components/CallControls/CallStatsButton.js.map +1 -0
- package/dist/src/components/CallControls/CancelCallButton.d.ts +8 -0
- package/dist/src/components/CallControls/CancelCallButton.js +25 -0
- package/dist/src/components/CallControls/CancelCallButton.js.map +1 -0
- package/dist/src/components/CallControls/ReactionsButton.d.ts +11 -0
- package/dist/src/components/CallControls/ReactionsButton.js +33 -0
- package/dist/src/components/CallControls/ReactionsButton.js.map +1 -0
- package/dist/src/components/CallControls/RecordCallButton.d.ts +7 -0
- package/dist/src/components/CallControls/RecordCallButton.js +51 -0
- package/dist/src/components/CallControls/RecordCallButton.js.map +1 -0
- package/dist/src/components/CallControls/ScreenShareButton.d.ts +7 -0
- package/dist/src/components/CallControls/ScreenShareButton.js +54 -0
- package/dist/src/components/CallControls/ScreenShareButton.js.map +1 -0
- package/dist/src/components/CallControls/ToggleAudioButton.d.ts +9 -0
- package/dist/src/components/CallControls/ToggleAudioButton.js +66 -0
- package/dist/src/components/CallControls/ToggleAudioButton.js.map +1 -0
- package/dist/src/components/CallControls/ToggleAudioOutputButton.d.ts +5 -0
- package/dist/src/components/CallControls/ToggleAudioOutputButton.js +9 -0
- package/dist/src/components/CallControls/ToggleAudioOutputButton.js.map +1 -0
- package/dist/src/components/CallControls/ToggleCameraButton.d.ts +10 -0
- package/dist/src/components/CallControls/ToggleCameraButton.js +64 -0
- package/dist/src/components/CallControls/ToggleCameraButton.js.map +1 -0
- package/dist/src/components/CallControls/ToggleParticipantListButton.d.ts +6 -0
- package/dist/src/components/CallControls/ToggleParticipantListButton.js +7 -0
- package/dist/src/components/CallControls/ToggleParticipantListButton.js.map +1 -0
- package/dist/src/components/CallControls/index.d.ts +10 -0
- package/dist/src/components/CallControls/index.js +11 -0
- package/dist/src/components/CallControls/index.js.map +1 -0
- package/dist/src/components/CallParticipantsList/BlockedUserListing.d.ts +4 -0
- package/dist/src/components/CallParticipantsList/BlockedUserListing.js +19 -0
- package/dist/src/components/CallParticipantsList/BlockedUserListing.js.map +1 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListHeader.d.ts +6 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListHeader.js +7 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListHeader.js.map +1 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListing.d.ts +8 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListing.js +4 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListing.js.map +1 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.d.ts +15 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.js +77 -0
- package/dist/src/components/CallParticipantsList/CallParticipantListingItem.js.map +1 -0
- package/dist/src/components/CallParticipantsList/CallParticipantsList.d.ts +15 -0
- package/dist/src/components/CallParticipantsList/CallParticipantsList.js +82 -0
- package/dist/src/components/CallParticipantsList/CallParticipantsList.js.map +1 -0
- package/dist/src/components/CallParticipantsList/EmptyParticipantSearchList.d.ts +2 -0
- package/dist/src/components/CallParticipantsList/EmptyParticipantSearchList.js +5 -0
- package/dist/src/components/CallParticipantsList/EmptyParticipantSearchList.js.map +1 -0
- package/dist/src/components/CallParticipantsList/index.d.ts +3 -0
- package/dist/src/components/CallParticipantsList/index.js +4 -0
- package/dist/src/components/CallParticipantsList/index.js.map +1 -0
- package/dist/src/components/CallRecordingList/CallRecordingList.d.ts +20 -0
- package/dist/src/components/CallRecordingList/CallRecordingList.js +9 -0
- package/dist/src/components/CallRecordingList/CallRecordingList.js.map +1 -0
- package/dist/src/components/CallRecordingList/CallRecordingListHeader.d.ts +7 -0
- package/dist/src/components/CallRecordingList/CallRecordingListHeader.js +8 -0
- package/dist/src/components/CallRecordingList/CallRecordingListHeader.js.map +1 -0
- package/dist/src/components/CallRecordingList/CallRecordingListItem.d.ts +7 -0
- package/dist/src/components/CallRecordingList/CallRecordingListItem.js +11 -0
- package/dist/src/components/CallRecordingList/CallRecordingListItem.js.map +1 -0
- package/dist/src/components/CallRecordingList/EmptyCallRecordingListing.d.ts +2 -0
- package/dist/src/components/CallRecordingList/EmptyCallRecordingListing.js +5 -0
- package/dist/src/components/CallRecordingList/EmptyCallRecordingListing.js.map +1 -0
- package/dist/src/components/CallRecordingList/LoadingCallRecordingListing.d.ts +7 -0
- package/dist/src/components/CallRecordingList/LoadingCallRecordingListing.js +7 -0
- package/dist/src/components/CallRecordingList/LoadingCallRecordingListing.js.map +1 -0
- package/dist/src/components/CallRecordingList/index.d.ts +5 -0
- package/dist/src/components/CallRecordingList/index.js +6 -0
- package/dist/src/components/CallRecordingList/index.js.map +1 -0
- package/dist/src/components/Debug/DebugParticipantPublishQuality.d.ts +6 -0
- package/dist/src/components/Debug/DebugParticipantPublishQuality.js +46 -0
- package/dist/src/components/Debug/DebugParticipantPublishQuality.js.map +1 -0
- package/dist/src/components/Debug/DebugStatsView.d.ts +7 -0
- package/dist/src/components/Debug/DebugStatsView.js +26 -0
- package/dist/src/components/Debug/DebugStatsView.js.map +1 -0
- package/dist/src/components/Debug/useIsDebugMode.d.ts +5 -0
- package/dist/src/components/Debug/useIsDebugMode.js +18 -0
- package/dist/src/components/Debug/useIsDebugMode.js.map +1 -0
- package/dist/src/components/DeviceSettings/DeviceSelector.d.ts +7 -0
- package/dist/src/components/DeviceSettings/DeviceSelector.js +26 -0
- package/dist/src/components/DeviceSettings/DeviceSelector.js.map +1 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.d.ts +9 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.js +18 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorAudio.js.map +1 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.d.ts +5 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.js +10 -0
- package/dist/src/components/DeviceSettings/DeviceSelectorVideo.js.map +1 -0
- package/dist/src/components/DeviceSettings/DeviceSettings.d.ts +2 -0
- package/dist/src/components/DeviceSettings/DeviceSettings.js +15 -0
- package/dist/src/components/DeviceSettings/DeviceSettings.js.map +1 -0
- package/dist/src/components/DeviceSettings/index.d.ts +4 -0
- package/dist/src/components/DeviceSettings/index.js +5 -0
- package/dist/src/components/DeviceSettings/index.js.map +1 -0
- package/dist/src/components/Icon/Icon.d.ts +5 -0
- package/dist/src/components/Icon/Icon.js +4 -0
- package/dist/src/components/Icon/Icon.js.map +1 -0
- package/dist/src/components/Icon/index.d.ts +1 -0
- package/dist/src/components/Icon/index.js +2 -0
- package/dist/src/components/Icon/index.js.map +1 -0
- package/dist/src/components/LoadingIndicator/LoadingIndicator.d.ts +11 -0
- package/dist/src/components/LoadingIndicator/LoadingIndicator.js +6 -0
- package/dist/src/components/LoadingIndicator/LoadingIndicator.js.map +1 -0
- package/dist/src/components/LoadingIndicator/index.d.ts +1 -0
- package/dist/src/components/LoadingIndicator/index.js +2 -0
- package/dist/src/components/LoadingIndicator/index.js.map +1 -0
- package/dist/src/components/Menu/GenericMenu.d.ts +3 -0
- package/dist/src/components/Menu/GenericMenu.js +20 -0
- package/dist/src/components/Menu/GenericMenu.js.map +1 -0
- package/dist/src/components/Menu/MenuToggle.d.ts +12 -0
- package/dist/src/components/Menu/MenuToggle.js +40 -0
- package/dist/src/components/Menu/MenuToggle.js.map +1 -0
- package/dist/src/components/Menu/index.d.ts +2 -0
- package/dist/src/components/Menu/index.js +3 -0
- package/dist/src/components/Menu/index.js.map +1 -0
- package/dist/src/components/Moderation/Restricted.d.ts +19 -0
- package/dist/src/components/Moderation/Restricted.js +13 -0
- package/dist/src/components/Moderation/Restricted.js.map +1 -0
- package/dist/src/components/Moderation/index.d.ts +1 -0
- package/dist/src/components/Moderation/index.js +2 -0
- package/dist/src/components/Moderation/index.js.map +1 -0
- package/dist/src/components/Notification/Notification.d.ts +11 -0
- package/dist/src/components/Notification/Notification.js +25 -0
- package/dist/src/components/Notification/Notification.js.map +1 -0
- package/dist/src/components/Notification/PermissionNotification.d.ts +33 -0
- package/dist/src/components/Notification/PermissionNotification.js +26 -0
- package/dist/src/components/Notification/PermissionNotification.js.map +1 -0
- package/dist/src/components/Notification/SpeakingWhileMutedNotification.d.ts +3 -0
- package/dist/src/components/Notification/SpeakingWhileMutedNotification.js +45 -0
- package/dist/src/components/Notification/SpeakingWhileMutedNotification.js.map +1 -0
- package/dist/src/components/Notification/index.d.ts +3 -0
- package/dist/src/components/Notification/index.js +4 -0
- package/dist/src/components/Notification/index.js.map +1 -0
- package/dist/src/components/Permissions/PermissionRequests.d.ts +8 -0
- package/dist/src/components/Permissions/PermissionRequests.js +109 -0
- package/dist/src/components/Permissions/PermissionRequests.js.map +1 -0
- package/dist/src/components/Permissions/index.d.ts +1 -0
- package/dist/src/components/Permissions/index.js +2 -0
- package/dist/src/components/Permissions/index.js.map +1 -0
- package/dist/src/components/Reaction/Reaction.d.ts +10 -0
- package/dist/src/components/Reaction/Reaction.js +28 -0
- package/dist/src/components/Reaction/Reaction.js.map +1 -0
- package/dist/src/components/Reaction/index.d.ts +1 -0
- package/dist/src/components/Reaction/index.js +2 -0
- package/dist/src/components/Reaction/index.js.map +1 -0
- package/dist/src/components/Search/SearchInput.d.ts +14 -0
- package/dist/src/components/Search/SearchInput.js +34 -0
- package/dist/src/components/Search/SearchInput.js.map +1 -0
- package/dist/src/components/Search/SearchResults.d.ts +14 -0
- package/dist/src/components/Search/SearchResults.js +12 -0
- package/dist/src/components/Search/SearchResults.js.map +1 -0
- package/dist/src/components/Search/hooks/index.d.ts +1 -0
- package/dist/src/components/Search/hooks/index.js +2 -0
- package/dist/src/components/Search/hooks/index.js.map +1 -0
- package/dist/src/components/Search/hooks/useSearch.d.ts +15 -0
- package/dist/src/components/Search/hooks/useSearch.js +39 -0
- package/dist/src/components/Search/hooks/useSearch.js.map +1 -0
- package/dist/src/components/Search/index.d.ts +2 -0
- package/dist/src/components/Search/index.js +3 -0
- package/dist/src/components/Search/index.js.map +1 -0
- package/dist/src/components/StreamCall/CallParticipantsScreenView.d.ts +5 -0
- package/dist/src/components/StreamCall/CallParticipantsScreenView.js +34 -0
- package/dist/src/components/StreamCall/CallParticipantsScreenView.js.map +1 -0
- package/dist/src/components/StreamCall/CallParticipantsView.d.ts +5 -0
- package/dist/src/components/StreamCall/CallParticipantsView.js +11 -0
- package/dist/src/components/StreamCall/CallParticipantsView.js.map +1 -0
- package/dist/src/components/StreamCall/CallStats.d.ts +2 -0
- package/dist/src/components/StreamCall/CallStats.js +69 -0
- package/dist/src/components/StreamCall/CallStats.js.map +1 -0
- package/dist/src/components/StreamCall/CallStatsLatencyChart.d.ts +7 -0
- package/dist/src/components/StreamCall/CallStatsLatencyChart.js +39 -0
- package/dist/src/components/StreamCall/CallStatsLatencyChart.js.map +1 -0
- package/dist/src/components/StreamCall/Stage.d.ts +8 -0
- package/dist/src/components/StreamCall/Stage.js +13 -0
- package/dist/src/components/StreamCall/Stage.js.map +1 -0
- package/dist/src/components/StreamCall/hooks/index.d.ts +1 -0
- package/dist/src/components/StreamCall/hooks/index.js +2 -0
- package/dist/src/components/StreamCall/hooks/index.js.map +1 -0
- package/dist/src/components/StreamCall/hooks/useScrollPosition.d.ts +6 -0
- package/dist/src/components/StreamCall/hooks/useScrollPosition.js +63 -0
- package/dist/src/components/StreamCall/hooks/useScrollPosition.js.map +1 -0
- package/dist/src/components/StreamCall/index.d.ts +3 -0
- package/dist/src/components/StreamCall/index.js +4 -0
- package/dist/src/components/StreamCall/index.js.map +1 -0
- package/dist/src/components/StreamMeeting/StreamMeeting.d.ts +34 -0
- package/dist/src/components/StreamMeeting/StreamMeeting.js +26 -0
- package/dist/src/components/StreamMeeting/StreamMeeting.js.map +1 -0
- package/dist/src/components/StreamMeeting/index.d.ts +1 -0
- package/dist/src/components/StreamMeeting/index.js +2 -0
- package/dist/src/components/StreamMeeting/index.js.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts +15 -0
- package/dist/src/components/Tooltip/Tooltip.js +22 -0
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/src/components/Tooltip/WithTooltip.d.ts +5 -0
- package/dist/src/components/Tooltip/WithTooltip.js +23 -0
- package/dist/src/components/Tooltip/WithTooltip.js.map +1 -0
- package/dist/src/components/Tooltip/hooks/index.d.ts +1 -0
- package/dist/src/components/Tooltip/hooks/index.js +2 -0
- package/dist/src/components/Tooltip/hooks/index.js.map +1 -0
- package/dist/src/components/Tooltip/hooks/useEnterLeaveHandlers.d.ts +6 -0
- package/dist/src/components/Tooltip/hooks/useEnterLeaveHandlers.js +14 -0
- package/dist/src/components/Tooltip/hooks/useEnterLeaveHandlers.js.map +1 -0
- package/dist/src/components/Tooltip/index.d.ts +2 -0
- package/dist/src/components/Tooltip/index.js +3 -0
- package/dist/src/components/Tooltip/index.js.map +1 -0
- package/dist/src/components/Video/VideoPreview.d.ts +13 -0
- package/dist/src/components/Video/VideoPreview.js +70 -0
- package/dist/src/components/Video/VideoPreview.js.map +1 -0
- package/dist/src/components/Video/index.d.ts +4 -0
- package/dist/src/components/Video/index.js +5 -0
- package/dist/src/components/Video/index.js.map +1 -0
- package/dist/src/components/index.d.ts +16 -0
- package/dist/src/components/index.js +17 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/core/components/Audio/Audio.d.ts +6 -0
- package/dist/src/core/components/Audio/Audio.js +39 -0
- package/dist/src/core/components/Audio/Audio.js.map +1 -0
- package/dist/src/core/components/Audio/index.d.ts +1 -0
- package/dist/src/core/components/Audio/index.js +2 -0
- package/dist/src/core/components/Audio/index.js.map +1 -0
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.d.ts +21 -0
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.js +39 -0
- package/dist/src/core/components/CallLayout/PaginatedGridLayout.js.map +1 -0
- package/dist/src/core/components/CallLayout/SpeakerLayout.d.ts +2 -0
- package/dist/src/core/components/CallLayout/SpeakerLayout.js +52 -0
- package/dist/src/core/components/CallLayout/SpeakerLayout.js.map +1 -0
- package/dist/src/core/components/CallLayout/index.d.ts +2 -0
- package/dist/src/core/components/CallLayout/index.js +3 -0
- package/dist/src/core/components/CallLayout/index.js.map +1 -0
- package/dist/src/core/components/ParticipantBox/ParticipantBox.d.ts +48 -0
- package/dist/src/core/components/ParticipantBox/ParticipantBox.js +58 -0
- package/dist/src/core/components/ParticipantBox/ParticipantBox.js.map +1 -0
- package/dist/src/core/components/ParticipantBox/index.d.ts +1 -0
- package/dist/src/core/components/ParticipantBox/index.js +2 -0
- package/dist/src/core/components/ParticipantBox/index.js.map +1 -0
- package/dist/src/core/components/Video/BaseVideo.d.ts +9 -0
- package/dist/src/core/components/Video/BaseVideo.js +54 -0
- package/dist/src/core/components/Video/BaseVideo.js.map +1 -0
- package/dist/src/core/components/Video/Video.d.ts +8 -0
- package/dist/src/core/components/Video/Video.js +151 -0
- package/dist/src/core/components/Video/Video.js.map +1 -0
- package/dist/src/core/components/Video/VideoPlaceholder.d.ts +6 -0
- package/dist/src/core/components/Video/VideoPlaceholder.js +12 -0
- package/dist/src/core/components/Video/VideoPlaceholder.js.map +1 -0
- package/dist/src/core/components/Video/index.d.ts +2 -0
- package/dist/src/core/components/Video/index.js +3 -0
- package/dist/src/core/components/Video/index.js.map +1 -0
- package/dist/src/core/components/index.d.ts +5 -0
- package/dist/src/core/components/index.js +5 -0
- package/dist/src/core/components/index.js.map +1 -0
- package/dist/src/core/contexts/MediaDevicesContext.d.ts +82 -0
- package/dist/src/core/contexts/MediaDevicesContext.js +215 -0
- package/dist/src/core/contexts/MediaDevicesContext.js.map +1 -0
- package/dist/src/core/contexts/index.d.ts +1 -0
- package/dist/src/core/contexts/index.js +2 -0
- package/dist/src/core/contexts/index.js.map +1 -0
- package/dist/src/core/hooks/index.d.ts +2 -0
- package/dist/src/core/hooks/index.js +3 -0
- package/dist/src/core/hooks/index.js.map +1 -0
- package/dist/src/core/hooks/useAudioPublisher.d.ts +12 -0
- package/dist/src/core/hooks/useAudioPublisher.js +89 -0
- package/dist/src/core/hooks/useAudioPublisher.js.map +1 -0
- package/dist/src/core/hooks/useVideoPublisher.d.ts +12 -0
- package/dist/src/core/hooks/useVideoPublisher.js +91 -0
- package/dist/src/core/hooks/useVideoPublisher.js.map +1 -0
- package/dist/src/core/index.d.ts +3 -0
- package/dist/src/core/index.js +4 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.js +3 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/useFloatingUIPreset.d.ts +9 -0
- package/dist/src/hooks/useFloatingUIPreset.js +29 -0
- package/dist/src/hooks/useFloatingUIPreset.js.map +1 -0
- package/dist/src/hooks/useRtcStats.d.ts +11 -0
- package/dist/src/hooks/useRtcStats.js +39 -0
- package/dist/src/hooks/useRtcStats.js.map +1 -0
- package/dist/src/types/components.d.ts +7 -0
- package/dist/src/types/components.js +2 -0
- package/dist/src/types/components.js.map +1 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/index.ts +18 -0
- package/package.json +49 -0
- package/src/components/Avatar/Avatar.tsx +45 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/CompositeButton.tsx +59 -0
- package/src/components/Button/CopyToClipboardButton.tsx +129 -0
- package/src/components/Button/IconButton.tsx +32 -0
- package/src/components/Button/TextButton.tsx +12 -0
- package/src/components/Button/index.ts +4 -0
- package/src/components/CallControls/CallControls.tsx +32 -0
- package/src/components/CallControls/CallStatsButton.tsx +28 -0
- package/src/components/CallControls/CancelCallButton.tsx +28 -0
- package/src/components/CallControls/ReactionsButton.tsx +75 -0
- package/src/components/CallControls/RecordCallButton.tsx +68 -0
- package/src/components/CallControls/ScreenShareButton.tsx +85 -0
- package/src/components/CallControls/ToggleAudioButton.tsx +112 -0
- package/src/components/CallControls/ToggleAudioOutputButton.tsx +21 -0
- package/src/components/CallControls/ToggleCameraButton.tsx +109 -0
- package/src/components/CallControls/ToggleParticipantListButton.tsx +17 -0
- package/src/components/CallControls/index.ts +10 -0
- package/src/components/CallParticipantsList/BlockedUserListing.tsx +38 -0
- package/src/components/CallParticipantsList/CallParticipantListHeader.tsx +29 -0
- package/src/components/CallParticipantsList/CallParticipantListing.tsx +22 -0
- package/src/components/CallParticipantsList/CallParticipantListingItem.tsx +249 -0
- package/src/components/CallParticipantsList/CallParticipantsList.tsx +255 -0
- package/src/components/CallParticipantsList/EmptyParticipantSearchList.tsx +7 -0
- package/src/components/CallParticipantsList/index.ts +3 -0
- package/src/components/CallRecordingList/CallRecordingList.tsx +60 -0
- package/src/components/CallRecordingList/CallRecordingListHeader.tsx +29 -0
- package/src/components/CallRecordingList/CallRecordingListItem.tsx +67 -0
- package/src/components/CallRecordingList/EmptyCallRecordingListing.tsx +11 -0
- package/src/components/CallRecordingList/LoadingCallRecordingListing.tsx +21 -0
- package/src/components/CallRecordingList/index.ts +5 -0
- package/src/components/Debug/DebugParticipantPublishQuality.tsx +62 -0
- package/src/components/Debug/DebugStatsView.tsx +55 -0
- package/src/components/Debug/useIsDebugMode.ts +24 -0
- package/src/components/DeviceSettings/DeviceSelector.tsx +106 -0
- package/src/components/DeviceSettings/DeviceSelectorAudio.tsx +52 -0
- package/src/components/DeviceSettings/DeviceSelectorVideo.tsx +22 -0
- package/src/components/DeviceSettings/DeviceSettings.tsx +39 -0
- package/src/components/DeviceSettings/index.ts +4 -0
- package/src/components/Icon/Icon.tsx +11 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/LoadingIndicator/LoadingIndicator.tsx +28 -0
- package/src/components/LoadingIndicator/index.ts +1 -0
- package/src/components/Menu/GenericMenu.tsx +16 -0
- package/src/components/Menu/MenuToggle.tsx +81 -0
- package/src/components/Menu/index.ts +2 -0
- package/src/components/Moderation/Restricted.tsx +38 -0
- package/src/components/Moderation/index.ts +1 -0
- package/src/components/Notification/Notification.tsx +61 -0
- package/src/components/Notification/PermissionNotification.tsx +97 -0
- package/src/components/Notification/SpeakingWhileMutedNotification.tsx +60 -0
- package/src/components/Notification/index.ts +3 -0
- package/src/components/Permissions/PermissionRequests.tsx +182 -0
- package/src/components/Permissions/index.ts +1 -0
- package/src/components/Reaction/Reaction.tsx +48 -0
- package/src/components/Reaction/index.ts +1 -0
- package/src/components/Search/SearchInput.tsx +56 -0
- package/src/components/Search/SearchResults.tsx +40 -0
- package/src/components/Search/hooks/index.ts +1 -0
- package/src/components/Search/hooks/useSearch.ts +52 -0
- package/src/components/Search/index.ts +2 -0
- package/src/components/StreamCall/CallParticipantsScreenView.tsx +126 -0
- package/src/components/StreamCall/CallParticipantsView.tsx +25 -0
- package/src/components/StreamCall/CallStats.tsx +162 -0
- package/src/components/StreamCall/CallStatsLatencyChart.tsx +58 -0
- package/src/components/StreamCall/Stage.tsx +22 -0
- package/src/components/StreamCall/hooks/index.ts +1 -0
- package/src/components/StreamCall/hooks/useScrollPosition.ts +95 -0
- package/src/components/StreamCall/index.ts +4 -0
- package/src/components/StreamMeeting/StreamMeeting.tsx +80 -0
- package/src/components/StreamMeeting/index.ts +1 -0
- package/src/components/Tooltip/Tooltip.tsx +51 -0
- package/src/components/Tooltip/WithTooltip.tsx +39 -0
- package/src/components/Tooltip/hooks/index.ts +1 -0
- package/src/components/Tooltip/hooks/useEnterLeaveHandlers.ts +28 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/Video/VideoPreview.tsx +127 -0
- package/src/components/Video/index.ts +4 -0
- package/src/components/index.ts +16 -0
- package/src/core/components/Audio/Audio.tsx +42 -0
- package/src/core/components/Audio/index.ts +1 -0
- package/src/core/components/CallLayout/PaginatedGridLayout.tsx +163 -0
- package/src/core/components/CallLayout/SpeakerLayout.tsx +145 -0
- package/src/core/components/CallLayout/index.ts +2 -0
- package/src/core/components/ParticipantBox/ParticipantBox.tsx +248 -0
- package/src/core/components/ParticipantBox/index.ts +1 -0
- package/src/core/components/Video/BaseVideo.tsx +68 -0
- package/src/core/components/Video/Video.tsx +238 -0
- package/src/core/components/Video/VideoPlaceholder.tsx +40 -0
- package/src/core/components/Video/index.ts +2 -0
- package/src/core/components/index.ts +7 -0
- package/src/core/contexts/MediaDevicesContext.tsx +373 -0
- package/src/core/contexts/index.ts +1 -0
- package/src/core/hooks/index.ts +2 -0
- package/src/core/hooks/useAudioPublisher.ts +118 -0
- package/src/core/hooks/useVideoPublisher.ts +120 -0
- package/src/core/index.ts +3 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFloatingUIPreset.ts +48 -0
- package/src/hooks/useRtcStats.ts +36 -0
- package/src/types/components.ts +7 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DetailedHTMLProps,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
VideoHTMLAttributes,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
Call,
|
|
11
|
+
DebounceType,
|
|
12
|
+
SfuModels,
|
|
13
|
+
StreamVideoParticipant,
|
|
14
|
+
VisibilityState,
|
|
15
|
+
} from '@stream-io/video-client';
|
|
16
|
+
import clsx from 'clsx';
|
|
17
|
+
import { VideoPlaceholder } from './VideoPlaceholder';
|
|
18
|
+
import { BaseVideo } from './BaseVideo';
|
|
19
|
+
|
|
20
|
+
export const Video = (
|
|
21
|
+
props: DetailedHTMLProps<
|
|
22
|
+
VideoHTMLAttributes<HTMLVideoElement>,
|
|
23
|
+
HTMLVideoElement
|
|
24
|
+
> & {
|
|
25
|
+
call: Call;
|
|
26
|
+
kind: 'video' | 'screen';
|
|
27
|
+
participant: StreamVideoParticipant;
|
|
28
|
+
setVideoElementRef?: (element: HTMLElement | null) => void;
|
|
29
|
+
},
|
|
30
|
+
) => {
|
|
31
|
+
const { call, kind, participant, className, setVideoElementRef, ...rest } =
|
|
32
|
+
props;
|
|
33
|
+
const { sessionId, videoStream, screenShareStream, publishedTracks } =
|
|
34
|
+
participant;
|
|
35
|
+
|
|
36
|
+
const [videoElement, setVideoElement] = useState<HTMLVideoElement | null>(
|
|
37
|
+
null,
|
|
38
|
+
);
|
|
39
|
+
// const [videoTrackMuted, setVideoTrackMuted] = useState(false);
|
|
40
|
+
const [videoPlaying, setVideoPlaying] = useState(false);
|
|
41
|
+
const viewportVisibilityRef = useRef<VisibilityState | undefined>(
|
|
42
|
+
participant.viewportVisibilityState,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const stream = kind === 'video' ? videoStream : screenShareStream;
|
|
46
|
+
|
|
47
|
+
// TODO: handle track muting
|
|
48
|
+
// useEffect(() => {
|
|
49
|
+
// if (!stream) return;
|
|
50
|
+
|
|
51
|
+
// const [track] = stream.getVideoTracks();
|
|
52
|
+
// setVideoTrackMuted(track.muted);
|
|
53
|
+
|
|
54
|
+
// const handleMute = () => {
|
|
55
|
+
// setVideoTrackMuted(true);
|
|
56
|
+
// };
|
|
57
|
+
// const handleUnmute = () => {
|
|
58
|
+
// setVideoTrackMuted(false);
|
|
59
|
+
// };
|
|
60
|
+
|
|
61
|
+
// track.addEventListener('mute', handleMute);
|
|
62
|
+
// track.addEventListener('unmute', handleUnmute);
|
|
63
|
+
|
|
64
|
+
// return () => {
|
|
65
|
+
// track.removeEventListener('mute', handleMute);
|
|
66
|
+
// track.removeEventListener('unmute', handleUnmute);
|
|
67
|
+
// };
|
|
68
|
+
// }, [stream]);
|
|
69
|
+
|
|
70
|
+
const isPublishingTrack = publishedTracks.includes(
|
|
71
|
+
kind === 'video'
|
|
72
|
+
? SfuModels.TrackType.VIDEO
|
|
73
|
+
: SfuModels.TrackType.SCREEN_SHARE,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const displayPlaceholder =
|
|
77
|
+
!isPublishingTrack ||
|
|
78
|
+
(participant.viewportVisibilityState === VisibilityState.INVISIBLE &&
|
|
79
|
+
!screenShareStream) ||
|
|
80
|
+
!videoPlaying;
|
|
81
|
+
|
|
82
|
+
const lastDimensionRef = useRef<string | undefined>();
|
|
83
|
+
const updateSubscription = useCallback(
|
|
84
|
+
(
|
|
85
|
+
dimension?: SfuModels.VideoDimension,
|
|
86
|
+
type: DebounceType = DebounceType.SLOW,
|
|
87
|
+
) => {
|
|
88
|
+
call.updateSubscriptionsPartial(
|
|
89
|
+
kind,
|
|
90
|
+
{
|
|
91
|
+
[sessionId]: {
|
|
92
|
+
dimension,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
type,
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
[call, kind, sessionId],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// handle generic subscription updates
|
|
102
|
+
|
|
103
|
+
// handle visibility subscription updates
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
viewportVisibilityRef.current = participant.viewportVisibilityState;
|
|
106
|
+
|
|
107
|
+
if (!videoElement || !isPublishingTrack || participant.isLoggedInUser)
|
|
108
|
+
return;
|
|
109
|
+
|
|
110
|
+
const isInvisibleVVS =
|
|
111
|
+
participant.viewportVisibilityState === VisibilityState.INVISIBLE;
|
|
112
|
+
|
|
113
|
+
updateSubscription(
|
|
114
|
+
isInvisibleVVS
|
|
115
|
+
? undefined
|
|
116
|
+
: {
|
|
117
|
+
height: videoElement.clientHeight,
|
|
118
|
+
width: videoElement.clientWidth,
|
|
119
|
+
},
|
|
120
|
+
DebounceType.MEDIUM,
|
|
121
|
+
);
|
|
122
|
+
}, [
|
|
123
|
+
updateSubscription,
|
|
124
|
+
participant.viewportVisibilityState,
|
|
125
|
+
videoElement,
|
|
126
|
+
isPublishingTrack,
|
|
127
|
+
participant.isLoggedInUser,
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
// handle resize subscription updates
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!videoElement || !isPublishingTrack || participant.isLoggedInUser)
|
|
133
|
+
return;
|
|
134
|
+
|
|
135
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
136
|
+
const currentDimensions = `${videoElement.clientWidth},${videoElement.clientHeight}`;
|
|
137
|
+
|
|
138
|
+
// skip initial trigger of the observer
|
|
139
|
+
if (!lastDimensionRef.current) {
|
|
140
|
+
return (lastDimensionRef.current = currentDimensions);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (
|
|
144
|
+
lastDimensionRef.current === currentDimensions ||
|
|
145
|
+
viewportVisibilityRef.current === VisibilityState.INVISIBLE
|
|
146
|
+
)
|
|
147
|
+
return;
|
|
148
|
+
|
|
149
|
+
updateSubscription(
|
|
150
|
+
{
|
|
151
|
+
height: videoElement.clientHeight,
|
|
152
|
+
width: videoElement.clientWidth,
|
|
153
|
+
},
|
|
154
|
+
DebounceType.SLOW,
|
|
155
|
+
);
|
|
156
|
+
lastDimensionRef.current = currentDimensions;
|
|
157
|
+
});
|
|
158
|
+
resizeObserver.observe(videoElement);
|
|
159
|
+
|
|
160
|
+
return () => {
|
|
161
|
+
resizeObserver.disconnect();
|
|
162
|
+
};
|
|
163
|
+
}, [
|
|
164
|
+
updateSubscription,
|
|
165
|
+
videoElement,
|
|
166
|
+
participant.viewportVisibilityState,
|
|
167
|
+
isPublishingTrack,
|
|
168
|
+
participant.isLoggedInUser,
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if (!isPublishingTrack || !videoElement || participant.isLoggedInUser)
|
|
173
|
+
return;
|
|
174
|
+
|
|
175
|
+
updateSubscription(
|
|
176
|
+
{
|
|
177
|
+
height: videoElement.clientHeight,
|
|
178
|
+
width: videoElement.clientWidth,
|
|
179
|
+
},
|
|
180
|
+
DebounceType.FAST,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return () => {
|
|
184
|
+
updateSubscription(undefined, DebounceType.FAST);
|
|
185
|
+
};
|
|
186
|
+
}, [
|
|
187
|
+
updateSubscription,
|
|
188
|
+
videoElement,
|
|
189
|
+
isPublishingTrack,
|
|
190
|
+
participant.isLoggedInUser,
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
const [isWideMode, setIsWideMode] = useState(true);
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!stream || !videoElement) return;
|
|
196
|
+
|
|
197
|
+
setVideoPlaying(!videoElement.paused);
|
|
198
|
+
|
|
199
|
+
const calculateVideoRatio = () => {
|
|
200
|
+
setVideoPlaying(true);
|
|
201
|
+
const [track] = stream.getVideoTracks();
|
|
202
|
+
if (!track) return;
|
|
203
|
+
|
|
204
|
+
const { width = 0, height = 0 } = track.getSettings();
|
|
205
|
+
setIsWideMode(width > height);
|
|
206
|
+
};
|
|
207
|
+
videoElement.addEventListener('play', calculateVideoRatio);
|
|
208
|
+
return () => {
|
|
209
|
+
videoElement.removeEventListener('play', calculateVideoRatio);
|
|
210
|
+
};
|
|
211
|
+
}, [stream, videoElement]);
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<>
|
|
215
|
+
<BaseVideo
|
|
216
|
+
{...rest}
|
|
217
|
+
stream={stream}
|
|
218
|
+
className={clsx(className, {
|
|
219
|
+
'str-video__video--wide': isWideMode,
|
|
220
|
+
'str-video__video--tall': !isWideMode,
|
|
221
|
+
})}
|
|
222
|
+
data-user-id={participant.userId}
|
|
223
|
+
data-session-id={sessionId}
|
|
224
|
+
ref={(ref) => {
|
|
225
|
+
setVideoElement(ref);
|
|
226
|
+
setVideoElementRef?.(ref);
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
{displayPlaceholder && (
|
|
230
|
+
<VideoPlaceholder
|
|
231
|
+
style={{ position: 'absolute' }}
|
|
232
|
+
participant={participant}
|
|
233
|
+
ref={setVideoElementRef}
|
|
234
|
+
/>
|
|
235
|
+
)}
|
|
236
|
+
</>
|
|
237
|
+
);
|
|
238
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ComponentProps, forwardRef, useState } from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { StreamVideoParticipant } from '@stream-io/video-client';
|
|
4
|
+
|
|
5
|
+
export type VideoPlaceholderProps = {
|
|
6
|
+
participant: StreamVideoParticipant;
|
|
7
|
+
} & ComponentProps<'div'>;
|
|
8
|
+
|
|
9
|
+
export const VideoPlaceholder = forwardRef<
|
|
10
|
+
HTMLDivElement,
|
|
11
|
+
VideoPlaceholderProps
|
|
12
|
+
>(({ participant, style }, ref) => {
|
|
13
|
+
const [error, setError] = useState(false);
|
|
14
|
+
|
|
15
|
+
const name = participant?.name || participant?.userId;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="str-video__participant-placeholder" style={style} ref={ref}>
|
|
19
|
+
{(!participant.image || error) &&
|
|
20
|
+
(name ? (
|
|
21
|
+
<div className="str-video__participant-placeholder--initials-fallback">
|
|
22
|
+
<div>{name[0]}</div>
|
|
23
|
+
</div>
|
|
24
|
+
) : (
|
|
25
|
+
<div>Video is disabled</div>
|
|
26
|
+
))}
|
|
27
|
+
{participant.image && !error && (
|
|
28
|
+
<img
|
|
29
|
+
onError={() => setError(true)}
|
|
30
|
+
alt="participant-placeholder"
|
|
31
|
+
className={clsx('str-video__participant-placeholder--avatar', {
|
|
32
|
+
'str-video__participant-placeholder--avatar-speaking':
|
|
33
|
+
participant.isSpeaking,
|
|
34
|
+
})}
|
|
35
|
+
src={participant.image}
|
|
36
|
+
/>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { map, pairwise, take } from 'rxjs';
|
|
10
|
+
import {
|
|
11
|
+
CallingState,
|
|
12
|
+
checkIfAudioOutputChangeSupported,
|
|
13
|
+
disposeOfMediaStream,
|
|
14
|
+
getAudioDevices,
|
|
15
|
+
getAudioOutputDevices,
|
|
16
|
+
getAudioStream,
|
|
17
|
+
getVideoDevices,
|
|
18
|
+
getVideoStream,
|
|
19
|
+
SfuModels,
|
|
20
|
+
watchForDisconnectedAudioOutputDevice,
|
|
21
|
+
} from '@stream-io/video-client';
|
|
22
|
+
import {
|
|
23
|
+
useCall,
|
|
24
|
+
useCallCallingState,
|
|
25
|
+
useCallState,
|
|
26
|
+
} from '@stream-io/video-react-bindings';
|
|
27
|
+
|
|
28
|
+
import { useAudioPublisher, useVideoPublisher } from '../hooks';
|
|
29
|
+
|
|
30
|
+
type EnabledStateType = 'starting' | 'playing';
|
|
31
|
+
type DisabledStateType = 'uninitialized' | 'stopped';
|
|
32
|
+
type ErrorStateType = 'error';
|
|
33
|
+
type DeviceStateType = EnabledStateType | DisabledStateType | ErrorStateType;
|
|
34
|
+
|
|
35
|
+
type EnabledDeviceState<T extends EnabledStateType> = {
|
|
36
|
+
type: T;
|
|
37
|
+
enabled: true;
|
|
38
|
+
};
|
|
39
|
+
type DisabledDeviceState<T extends DisabledStateType> = {
|
|
40
|
+
type: T;
|
|
41
|
+
enabled: false;
|
|
42
|
+
};
|
|
43
|
+
type ErrorDeviceState = {
|
|
44
|
+
type: 'error';
|
|
45
|
+
message: string;
|
|
46
|
+
enabled: false;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type DeviceState =
|
|
50
|
+
| EnabledDeviceState<EnabledStateType>
|
|
51
|
+
| DisabledDeviceState<DisabledStateType>
|
|
52
|
+
| ErrorDeviceState;
|
|
53
|
+
|
|
54
|
+
const DEVICE_STATE_TOGGLE: Record<DeviceStateType, 'starting' | 'stopped'> = {
|
|
55
|
+
starting: 'stopped',
|
|
56
|
+
playing: 'stopped',
|
|
57
|
+
stopped: 'starting',
|
|
58
|
+
uninitialized: 'starting',
|
|
59
|
+
error: 'starting',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Exclude types from documentaiton site, but we should still add doc comments
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export const DEVICE_STATE: {
|
|
67
|
+
starting: EnabledDeviceState<'starting'>;
|
|
68
|
+
playing: EnabledDeviceState<'playing'>;
|
|
69
|
+
stopped: DisabledDeviceState<'stopped'>;
|
|
70
|
+
uninitialized: DisabledDeviceState<'uninitialized'>;
|
|
71
|
+
error: ErrorDeviceState;
|
|
72
|
+
} = {
|
|
73
|
+
starting: { type: 'starting', enabled: true },
|
|
74
|
+
playing: { type: 'playing', enabled: true },
|
|
75
|
+
stopped: { type: 'stopped', enabled: false },
|
|
76
|
+
uninitialized: { type: 'uninitialized', enabled: false },
|
|
77
|
+
error: { type: 'error', message: '', enabled: false },
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Exclude types from documentaiton site, but we should still add doc comments
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export type MediaDevicesContextAPI = {
|
|
85
|
+
audioInputDevices: MediaDeviceInfo[];
|
|
86
|
+
audioOutputDevices: MediaDeviceInfo[];
|
|
87
|
+
videoDevices: MediaDeviceInfo[];
|
|
88
|
+
disposeOfMediaStream: (stream: MediaStream) => void;
|
|
89
|
+
getAudioStream: (deviceId?: string) => Promise<MediaStream>;
|
|
90
|
+
getVideoStream: (deviceId?: string) => Promise<MediaStream>;
|
|
91
|
+
isAudioOutputChangeSupported: boolean;
|
|
92
|
+
initialAudioEnabled: boolean;
|
|
93
|
+
initialVideoState: DeviceState;
|
|
94
|
+
publishVideoStream: () => Promise<void>;
|
|
95
|
+
publishAudioStream: () => Promise<void>;
|
|
96
|
+
stopPublishingAudio: () => void;
|
|
97
|
+
stopPublishingVideo: () => void;
|
|
98
|
+
setInitialVideoState: (state: DeviceState) => void;
|
|
99
|
+
selectedAudioInputDeviceId?: string;
|
|
100
|
+
selectedAudioOutputDeviceId?: string;
|
|
101
|
+
selectedVideoDeviceId?: string;
|
|
102
|
+
switchDevice: (kind: MediaDeviceKind, deviceId?: string) => void;
|
|
103
|
+
toggleAudioMuteState: () => void;
|
|
104
|
+
toggleVideoMuteState: () => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const MediaDevicesContext = createContext<MediaDevicesContextAPI | null>(null);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Exclude types from documentaiton site, but we should still add doc comments
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
export type MediaDevicesProviderProps = PropsWithChildren<{
|
|
114
|
+
enumerate?: boolean;
|
|
115
|
+
initialAudioEnabled?: boolean;
|
|
116
|
+
initialVideoEnabled?: boolean;
|
|
117
|
+
initialAudioInputDeviceId?: string;
|
|
118
|
+
initialAudioOutputDeviceId?: string;
|
|
119
|
+
initialVideoInputDeviceId?: string;
|
|
120
|
+
}>;
|
|
121
|
+
|
|
122
|
+
// todo: republish the stream, when a new default device connected
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
* @param param0
|
|
126
|
+
* @returns
|
|
127
|
+
*
|
|
128
|
+
* @category Device Management
|
|
129
|
+
*/
|
|
130
|
+
export const MediaDevicesProvider = ({
|
|
131
|
+
children,
|
|
132
|
+
enumerate = true,
|
|
133
|
+
initialAudioEnabled,
|
|
134
|
+
initialVideoEnabled,
|
|
135
|
+
initialVideoInputDeviceId = 'default',
|
|
136
|
+
initialAudioOutputDeviceId = 'default',
|
|
137
|
+
initialAudioInputDeviceId = 'default',
|
|
138
|
+
}: MediaDevicesProviderProps) => {
|
|
139
|
+
const call = useCall();
|
|
140
|
+
const callingState = useCallCallingState();
|
|
141
|
+
const callState = useCallState();
|
|
142
|
+
const { localParticipant$ } = callState;
|
|
143
|
+
|
|
144
|
+
const [audioInputDevices, setAudioInputDevices] = useState<MediaDeviceInfo[]>(
|
|
145
|
+
[],
|
|
146
|
+
);
|
|
147
|
+
const [videoDevices, setVideoDevices] = useState<MediaDeviceInfo[]>([]);
|
|
148
|
+
const [audioOutputDevices, setAudioOutputDevices] = useState<
|
|
149
|
+
MediaDeviceInfo[]
|
|
150
|
+
>([]);
|
|
151
|
+
|
|
152
|
+
const [selectedAudioInputDeviceId, setSelectedAudioInputDeviceId] = useState<
|
|
153
|
+
MediaDevicesContextAPI['selectedAudioInputDeviceId']
|
|
154
|
+
>(initialAudioInputDeviceId);
|
|
155
|
+
const [selectedAudioOutputDeviceId, setSelectedAudioOutputDeviceId] =
|
|
156
|
+
useState<MediaDevicesContextAPI['selectedAudioOutputDeviceId']>(
|
|
157
|
+
initialAudioOutputDeviceId,
|
|
158
|
+
);
|
|
159
|
+
const [selectedVideoDeviceId, selectVideoDeviceId] = useState<
|
|
160
|
+
MediaDevicesContextAPI['selectedVideoDeviceId']
|
|
161
|
+
>(initialVideoInputDeviceId);
|
|
162
|
+
|
|
163
|
+
const [isAudioOutputChangeSupported] = useState<boolean>(() =>
|
|
164
|
+
checkIfAudioOutputChangeSupported(),
|
|
165
|
+
);
|
|
166
|
+
const [initAudioEnabled, setInitAudioEnabled] = useState<boolean>(
|
|
167
|
+
!!initialAudioEnabled,
|
|
168
|
+
);
|
|
169
|
+
const [initialVideoState, setInitialVideoState] = useState<DeviceState>(() =>
|
|
170
|
+
initialVideoEnabled ? DEVICE_STATE.starting : DEVICE_STATE.uninitialized,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const publishVideoStream = useVideoPublisher({
|
|
174
|
+
initialVideoMuted: !initialVideoState.enabled,
|
|
175
|
+
videoDeviceId: selectedVideoDeviceId,
|
|
176
|
+
});
|
|
177
|
+
const publishAudioStream = useAudioPublisher({
|
|
178
|
+
initialAudioMuted: !initAudioEnabled,
|
|
179
|
+
audioDeviceId: selectedAudioInputDeviceId,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const stopPublishingAudio = useCallback(() => {
|
|
183
|
+
if (
|
|
184
|
+
callingState === CallingState.IDLE ||
|
|
185
|
+
callingState === CallingState.RINGING
|
|
186
|
+
) {
|
|
187
|
+
setInitAudioEnabled(false);
|
|
188
|
+
} else {
|
|
189
|
+
call?.stopPublish(SfuModels.TrackType.AUDIO);
|
|
190
|
+
}
|
|
191
|
+
}, [call, callingState]);
|
|
192
|
+
|
|
193
|
+
const stopPublishingVideo = useCallback(() => {
|
|
194
|
+
if (
|
|
195
|
+
callingState === CallingState.IDLE ||
|
|
196
|
+
callingState === CallingState.RINGING
|
|
197
|
+
) {
|
|
198
|
+
setInitialVideoState(DEVICE_STATE.stopped);
|
|
199
|
+
} else {
|
|
200
|
+
call?.stopPublish(SfuModels.TrackType.VIDEO);
|
|
201
|
+
}
|
|
202
|
+
}, [call, callingState]);
|
|
203
|
+
|
|
204
|
+
const toggleAudioMuteState = useCallback(
|
|
205
|
+
() => setInitAudioEnabled((prev) => !prev),
|
|
206
|
+
[],
|
|
207
|
+
);
|
|
208
|
+
const toggleVideoMuteState = useCallback(
|
|
209
|
+
() =>
|
|
210
|
+
setInitialVideoState((prev) => {
|
|
211
|
+
const newType = DEVICE_STATE_TOGGLE[prev.type];
|
|
212
|
+
return DEVICE_STATE[newType];
|
|
213
|
+
}),
|
|
214
|
+
[],
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const switchDevice = useCallback(
|
|
218
|
+
(kind: MediaDeviceKind, deviceId?: string) => {
|
|
219
|
+
if (kind === 'videoinput') {
|
|
220
|
+
selectVideoDeviceId(deviceId);
|
|
221
|
+
}
|
|
222
|
+
if (kind === 'audioinput') {
|
|
223
|
+
setSelectedAudioInputDeviceId(deviceId);
|
|
224
|
+
}
|
|
225
|
+
if (kind === 'audiooutput') {
|
|
226
|
+
setSelectedAudioOutputDeviceId(deviceId);
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
[],
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (!enumerate) return;
|
|
234
|
+
|
|
235
|
+
const validateInitialInputDeviceId = getAudioDevices()
|
|
236
|
+
.pipe(take(1))
|
|
237
|
+
.subscribe((devices) => {
|
|
238
|
+
const initialDeviceFound = devices.find(
|
|
239
|
+
(device) => device.deviceId === initialAudioInputDeviceId,
|
|
240
|
+
);
|
|
241
|
+
if (!initialDeviceFound) {
|
|
242
|
+
setSelectedAudioInputDeviceId('default');
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const subscription = getAudioDevices().subscribe(setAudioInputDevices);
|
|
247
|
+
|
|
248
|
+
return () => {
|
|
249
|
+
subscription.unsubscribe();
|
|
250
|
+
validateInitialInputDeviceId.unsubscribe();
|
|
251
|
+
};
|
|
252
|
+
}, [enumerate, initialAudioInputDeviceId]);
|
|
253
|
+
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!enumerate) return;
|
|
256
|
+
|
|
257
|
+
const validateInitialInputDeviceId = getVideoDevices()
|
|
258
|
+
.pipe(take(1))
|
|
259
|
+
.subscribe((devices) => {
|
|
260
|
+
const initialDeviceFound = devices.find(
|
|
261
|
+
(device) => device.deviceId === initialVideoInputDeviceId,
|
|
262
|
+
);
|
|
263
|
+
if (!initialDeviceFound) {
|
|
264
|
+
selectVideoDeviceId('default');
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const subscription = getVideoDevices().subscribe(setVideoDevices);
|
|
269
|
+
|
|
270
|
+
return () => {
|
|
271
|
+
subscription.unsubscribe();
|
|
272
|
+
validateInitialInputDeviceId.unsubscribe();
|
|
273
|
+
};
|
|
274
|
+
}, [enumerate, initialVideoInputDeviceId]);
|
|
275
|
+
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
if (!enumerate) return;
|
|
278
|
+
|
|
279
|
+
const validateInitialInputDeviceId = getAudioOutputDevices()
|
|
280
|
+
.pipe(take(1))
|
|
281
|
+
.subscribe((devices) => {
|
|
282
|
+
const initialDeviceFound = devices.find(
|
|
283
|
+
(device) => device.deviceId === initialAudioOutputDeviceId,
|
|
284
|
+
);
|
|
285
|
+
if (!initialDeviceFound) {
|
|
286
|
+
setSelectedAudioOutputDeviceId('default');
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const subscription = getAudioOutputDevices().subscribe(
|
|
291
|
+
setAudioOutputDevices,
|
|
292
|
+
);
|
|
293
|
+
return () => {
|
|
294
|
+
subscription.unsubscribe();
|
|
295
|
+
validateInitialInputDeviceId.unsubscribe();
|
|
296
|
+
};
|
|
297
|
+
}, [enumerate, initialAudioOutputDeviceId]);
|
|
298
|
+
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
const subscription = getVideoDevices()
|
|
301
|
+
.pipe(pairwise())
|
|
302
|
+
.subscribe(([prev, current]) => {
|
|
303
|
+
// When there are 0 video devices (e.g. when laptop lid closed),
|
|
304
|
+
// we do not restart the video automatically when the device is again available,
|
|
305
|
+
// but rather leave this to the user.
|
|
306
|
+
if (prev.length > 0 && current.length === 0) {
|
|
307
|
+
setInitialVideoState(DEVICE_STATE.stopped);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
return () => subscription.unsubscribe();
|
|
312
|
+
}, [videoDevices.length]);
|
|
313
|
+
|
|
314
|
+
useEffect(() => {
|
|
315
|
+
if (!call || callingState !== CallingState.JOINED) return;
|
|
316
|
+
call.setAudioOutputDevice(selectedAudioOutputDeviceId);
|
|
317
|
+
}, [call, callingState, selectedAudioOutputDeviceId]);
|
|
318
|
+
|
|
319
|
+
useEffect(() => {
|
|
320
|
+
if (!localParticipant$) return;
|
|
321
|
+
const subscription = watchForDisconnectedAudioOutputDevice(
|
|
322
|
+
localParticipant$.pipe(map((p) => p?.audioOutputDeviceId)),
|
|
323
|
+
).subscribe(async () => {
|
|
324
|
+
setSelectedAudioOutputDeviceId('default');
|
|
325
|
+
});
|
|
326
|
+
return () => {
|
|
327
|
+
subscription.unsubscribe();
|
|
328
|
+
};
|
|
329
|
+
}, [localParticipant$]);
|
|
330
|
+
|
|
331
|
+
const contextValue: MediaDevicesContextAPI = {
|
|
332
|
+
audioInputDevices,
|
|
333
|
+
videoDevices,
|
|
334
|
+
audioOutputDevices,
|
|
335
|
+
disposeOfMediaStream,
|
|
336
|
+
getAudioStream,
|
|
337
|
+
getVideoStream,
|
|
338
|
+
isAudioOutputChangeSupported,
|
|
339
|
+
selectedAudioInputDeviceId,
|
|
340
|
+
selectedAudioOutputDeviceId,
|
|
341
|
+
selectedVideoDeviceId,
|
|
342
|
+
switchDevice,
|
|
343
|
+
initialAudioEnabled: initAudioEnabled,
|
|
344
|
+
initialVideoState,
|
|
345
|
+
setInitialVideoState,
|
|
346
|
+
toggleAudioMuteState,
|
|
347
|
+
toggleVideoMuteState,
|
|
348
|
+
publishAudioStream,
|
|
349
|
+
publishVideoStream,
|
|
350
|
+
stopPublishingAudio,
|
|
351
|
+
stopPublishingVideo,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<MediaDevicesContext.Provider value={contextValue}>
|
|
356
|
+
{children}
|
|
357
|
+
</MediaDevicesContext.Provider>
|
|
358
|
+
);
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
*
|
|
363
|
+
* @returns
|
|
364
|
+
*
|
|
365
|
+
* @category Device Management
|
|
366
|
+
*/
|
|
367
|
+
export const useMediaDevices = () => {
|
|
368
|
+
const value = useContext(MediaDevicesContext);
|
|
369
|
+
if (!value) {
|
|
370
|
+
console.warn(`Null MediaDevicesContext`);
|
|
371
|
+
}
|
|
372
|
+
return value as MediaDevicesContextAPI;
|
|
373
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MediaDevicesContext';
|