@ethora/chat-component-rn 26.10.9 → 26.10.11
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 +17 -0
- package/README.md +126 -1
- package/lib/commonjs/booking/index.js +44 -0
- package/lib/commonjs/booking/index.js.map +1 -0
- package/lib/commonjs/booking/pendingScheduledCall.js +275 -0
- package/lib/commonjs/booking/pendingScheduledCall.js.map +1 -0
- package/lib/commonjs/booking/scheduleForm.js +91 -0
- package/lib/commonjs/booking/scheduleForm.js.map +1 -0
- package/lib/commonjs/booking/scheduledCall.js +141 -0
- package/lib/commonjs/booking/scheduledCall.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallActions.js +128 -0
- package/lib/commonjs/booking/scheduledCallActions.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallLink.js +143 -0
- package/lib/commonjs/booking/scheduledCallLink.js.map +1 -0
- package/lib/commonjs/booking/scheduledCallStore.js +64 -0
- package/lib/commonjs/booking/scheduledCallStore.js.map +1 -0
- package/lib/commonjs/booking/startRoomCall.js +84 -0
- package/lib/commonjs/booking/startRoomCall.js.map +1 -0
- package/lib/commonjs/calls/callBusy.js +18 -0
- package/lib/commonjs/calls/callBusy.js.map +1 -0
- package/lib/commonjs/calls/callDisplay.js +73 -0
- package/lib/commonjs/calls/callDisplay.js.map +1 -0
- package/lib/commonjs/calls/callMode.js +175 -0
- package/lib/commonjs/calls/callMode.js.map +1 -0
- package/lib/commonjs/calls/declineReport.js +20 -0
- package/lib/commonjs/calls/declineReport.js.map +1 -0
- package/lib/commonjs/calls/p2p/P2PCallController.js +724 -0
- package/lib/commonjs/calls/p2p/P2PCallController.js.map +1 -0
- package/lib/commonjs/calls/p2p/icePolicy.js +107 -0
- package/lib/commonjs/calls/p2p/icePolicy.js.map +1 -0
- package/lib/commonjs/calls/p2p/negotiator.js +202 -0
- package/lib/commonjs/calls/p2p/negotiator.js.map +1 -0
- package/lib/commonjs/calls/p2p/p2pRuntime.js +147 -0
- package/lib/commonjs/calls/p2p/p2pRuntime.js.map +1 -0
- package/lib/commonjs/calls/p2p/signalInbox.js +98 -0
- package/lib/commonjs/calls/p2p/signalInbox.js.map +1 -0
- package/lib/commonjs/calls/p2p/signalStanza.js +141 -0
- package/lib/commonjs/calls/p2p/signalStanza.js.map +1 -0
- package/lib/commonjs/calls/p2p/webrtcRuntime.js +53 -0
- package/lib/commonjs/calls/p2p/webrtcRuntime.js.map +1 -0
- package/lib/commonjs/calls/senderTrust.js +43 -0
- package/lib/commonjs/calls/senderTrust.js.map +1 -0
- package/lib/commonjs/calls/startCall.js +51 -0
- package/lib/commonjs/calls/startCall.js.map +1 -0
- package/lib/commonjs/components/Booking/BookingIcons.js +55 -0
- package/lib/commonjs/components/Booking/BookingIcons.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduleCallButton.js +64 -0
- package/lib/commonjs/components/Booking/ScheduleCallButton.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduleCallSheet.js +351 -0
- package/lib/commonjs/components/Booking/ScheduleCallSheet.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallCard.js +203 -0
- package/lib/commonjs/components/Booking/ScheduledCallCard.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallHost.js +23 -0
- package/lib/commonjs/components/Booking/ScheduledCallHost.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallMessage.js +55 -0
- package/lib/commonjs/components/Booking/ScheduledCallMessage.js.map +1 -0
- package/lib/commonjs/components/Booking/ScheduledCallPreJoin.js +235 -0
- package/lib/commonjs/components/Booking/ScheduledCallPreJoin.js.map +1 -0
- package/lib/commonjs/components/Booking/bookingShared.js +305 -0
- package/lib/commonjs/components/Booking/bookingShared.js.map +1 -0
- package/lib/commonjs/components/MainComponents/AlbumGrid.js +6 -2
- package/lib/commonjs/components/MainComponents/AlbumGrid.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatHeader.js +18 -12
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MainComponents/LanguageSelectorButton.js +5 -2
- package/lib/commonjs/components/MainComponents/LanguageSelectorButton.js.map +1 -1
- package/lib/commonjs/components/MainComponents/LanguageSelectorModal.js +6 -3
- package/lib/commonjs/components/MainComponents/LanguageSelectorModal.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MediaMessage.js +13 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageContainer.js +13 -0
- package/lib/commonjs/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js +10 -0
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +7 -16
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/Message.js +27 -1
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatMediaGrid.js +159 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatMediaGrid.js.map +1 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +203 -134
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/LeaveChatModal.js +180 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/LeaveChatModal.js.map +1 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +19 -15
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +100 -162
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/MediaViewer.js +824 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/MediaViewer.js.map +1 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/useSaveFile.js +179 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/useSaveFile.js.map +1 -0
- package/lib/commonjs/components/Modals/MessageSearchModal/MessageSearchModal.js +22 -5
- package/lib/commonjs/components/Modals/MessageSearchModal/MessageSearchModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +15 -8
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/LanguageCard.js +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/LanguageCard.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js +3 -2
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/CallButtons.js +19 -11
- package/lib/commonjs/components/VideoCalls/CallButtons.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/CallControlBar.js +119 -0
- package/lib/commonjs/components/VideoCalls/CallControlBar.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/CallVideo.js +49 -0
- package/lib/commonjs/components/VideoCalls/CallVideo.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/GroupCallView.js +281 -0
- package/lib/commonjs/components/VideoCalls/GroupCallView.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/P2PCallRunner.js +151 -0
- package/lib/commonjs/components/VideoCalls/P2PCallRunner.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js +38 -14
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js +57 -128
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callActions.js +3 -0
- package/lib/commonjs/components/VideoCalls/callActions.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callElapsed.js +38 -0
- package/lib/commonjs/components/VideoCalls/callElapsed.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/callLive.js +15 -0
- package/lib/commonjs/components/VideoCalls/callLive.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/callSessionController.js +81 -24
- package/lib/commonjs/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callSessionTypes.js +41 -0
- package/lib/commonjs/components/VideoCalls/callSessionTypes.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/groupLayout.js +43 -0
- package/lib/commonjs/components/VideoCalls/groupLayout.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/p2pCallSession.js +272 -0
- package/lib/commonjs/components/VideoCalls/p2pCallSession.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/useCallKeep.js +7 -2
- package/lib/commonjs/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js +2 -1
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js.map +1 -1
- package/lib/commonjs/components/styled/MessageImage.js +4 -1
- package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
- package/lib/commonjs/components/styled/VideoMessage.js +5 -1
- package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
- package/lib/commonjs/context/MediaSourceContext.js +18 -0
- package/lib/commonjs/context/MediaSourceContext.js.map +1 -0
- package/lib/commonjs/context/xmppProvider.js +2 -1
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/callPush.js +3 -1
- package/lib/commonjs/helpers/callPush.js.map +1 -1
- package/lib/commonjs/helpers/constants/MODAL_COMPONENTS.js +3 -1
- package/lib/commonjs/helpers/constants/MODAL_COMPONENTS.js.map +1 -1
- package/lib/commonjs/helpers/constants/MODAL_TYPES.js +2 -0
- package/lib/commonjs/helpers/constants/MODAL_TYPES.js.map +1 -1
- package/lib/commonjs/helpers/incomingCallFromPush.js +63 -7
- package/lib/commonjs/helpers/incomingCallFromPush.js.map +1 -1
- package/lib/commonjs/helpers/publicChatsEntry.js +8 -6
- package/lib/commonjs/helpers/publicChatsEntry.js.map +1 -1
- package/lib/commonjs/helpers/pushPayload.js +5 -0
- package/lib/commonjs/helpers/pushPayload.js.map +1 -1
- package/lib/commonjs/helpers/reportRoom.js +76 -0
- package/lib/commonjs/helpers/reportRoom.js.map +1 -0
- package/lib/commonjs/helpers/roomMedia.js +118 -0
- package/lib/commonjs/helpers/roomMedia.js.map +1 -0
- package/lib/commonjs/i18n/strings.js +480 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +93 -0
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/callState.api.js +75 -0
- package/lib/commonjs/networking/api-requests/callState.api.js.map +1 -0
- package/lib/commonjs/networking/api-requests/push.api.js +29 -6
- package/lib/commonjs/networking/api-requests/push.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/rooms.api.js +17 -15
- package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/scheduledCalls.api.js +141 -0
- package/lib/commonjs/networking/api-requests/scheduledCalls.api.js.map +1 -0
- package/lib/commonjs/networking/callTokenStanza.js +210 -50
- package/lib/commonjs/networking/callTokenStanza.js.map +1 -1
- package/lib/commonjs/roomStore/callSlice.js +59 -4
- package/lib/commonjs/roomStore/callSlice.js.map +1 -1
- package/lib/commonjs/services/appBadge.js +80 -0
- package/lib/commonjs/services/appBadge.js.map +1 -0
- package/lib/commonjs/services/languageSettings.js +47 -15
- package/lib/commonjs/services/languageSettings.js.map +1 -1
- package/lib/commonjs/services/pushRegistration.js +21 -5
- package/lib/commonjs/services/pushRegistration.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/booking/index.js +5 -0
- package/lib/module/booking/index.js.map +1 -0
- package/lib/module/booking/pendingScheduledCall.js +261 -0
- package/lib/module/booking/pendingScheduledCall.js.map +1 -0
- package/lib/module/booking/scheduleForm.js +79 -0
- package/lib/module/booking/scheduleForm.js.map +1 -0
- package/lib/module/booking/scheduledCall.js +129 -0
- package/lib/module/booking/scheduledCall.js.map +1 -0
- package/lib/module/booking/scheduledCallActions.js +118 -0
- package/lib/module/booking/scheduledCallActions.js.map +1 -0
- package/lib/module/booking/scheduledCallLink.js +136 -0
- package/lib/module/booking/scheduledCallLink.js.map +1 -0
- package/lib/module/booking/scheduledCallStore.js +60 -0
- package/lib/module/booking/scheduledCallStore.js.map +1 -0
- package/lib/module/booking/startRoomCall.js +80 -0
- package/lib/module/booking/startRoomCall.js.map +1 -0
- package/lib/module/calls/callBusy.js +13 -0
- package/lib/module/calls/callBusy.js.map +1 -0
- package/lib/module/calls/callDisplay.js +65 -0
- package/lib/module/calls/callDisplay.js.map +1 -0
- package/lib/module/calls/callMode.js +168 -0
- package/lib/module/calls/callMode.js.map +1 -0
- package/lib/module/calls/declineReport.js +16 -0
- package/lib/module/calls/declineReport.js.map +1 -0
- package/lib/module/calls/p2p/P2PCallController.js +718 -0
- package/lib/module/calls/p2p/P2PCallController.js.map +1 -0
- package/lib/module/calls/p2p/icePolicy.js +102 -0
- package/lib/module/calls/p2p/icePolicy.js.map +1 -0
- package/lib/module/calls/p2p/negotiator.js +197 -0
- package/lib/module/calls/p2p/negotiator.js.map +1 -0
- package/lib/module/calls/p2p/p2pRuntime.js +137 -0
- package/lib/module/calls/p2p/p2pRuntime.js.map +1 -0
- package/lib/module/calls/p2p/signalInbox.js +93 -0
- package/lib/module/calls/p2p/signalInbox.js.map +1 -0
- package/lib/module/calls/p2p/signalStanza.js +135 -0
- package/lib/module/calls/p2p/signalStanza.js.map +1 -0
- package/lib/module/calls/p2p/webrtcRuntime.js +46 -0
- package/lib/module/calls/p2p/webrtcRuntime.js.map +1 -0
- package/lib/module/calls/senderTrust.js +38 -0
- package/lib/module/calls/senderTrust.js.map +1 -0
- package/lib/module/calls/startCall.js +47 -0
- package/lib/module/calls/startCall.js.map +1 -0
- package/lib/module/components/Booking/BookingIcons.js +48 -0
- package/lib/module/components/Booking/BookingIcons.js.map +1 -0
- package/lib/module/components/Booking/ScheduleCallButton.js +59 -0
- package/lib/module/components/Booking/ScheduleCallButton.js.map +1 -0
- package/lib/module/components/Booking/ScheduleCallSheet.js +345 -0
- package/lib/module/components/Booking/ScheduleCallSheet.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallCard.js +197 -0
- package/lib/module/components/Booking/ScheduledCallCard.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallHost.js +18 -0
- package/lib/module/components/Booking/ScheduledCallHost.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallMessage.js +48 -0
- package/lib/module/components/Booking/ScheduledCallMessage.js.map +1 -0
- package/lib/module/components/Booking/ScheduledCallPreJoin.js +229 -0
- package/lib/module/components/Booking/ScheduledCallPreJoin.js.map +1 -0
- package/lib/module/components/Booking/bookingShared.js +291 -0
- package/lib/module/components/Booking/bookingShared.js.map +1 -0
- package/lib/module/components/MainComponents/AlbumGrid.js +6 -2
- package/lib/module/components/MainComponents/AlbumGrid.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +20 -14
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MainComponents/LanguageSelectorButton.js +5 -2
- package/lib/module/components/MainComponents/LanguageSelectorButton.js.map +1 -1
- package/lib/module/components/MainComponents/LanguageSelectorModal.js +7 -4
- package/lib/module/components/MainComponents/LanguageSelectorModal.js.map +1 -1
- package/lib/module/components/MainComponents/MediaMessage.js +13 -0
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/MessageContainer.js +13 -0
- package/lib/module/components/MainComponents/MessageContainer.js.map +1 -1
- package/lib/module/components/MainComponents/ReduxWrapper.js +10 -0
- package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +7 -16
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/MessageBubble/Message.js +27 -1
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatMediaGrid.js +154 -0
- package/lib/module/components/Modals/ChatProfileModal/ChatMediaGrid.js.map +1 -0
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +204 -136
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/LeaveChatModal.js +175 -0
- package/lib/module/components/Modals/ChatProfileModal/LeaveChatModal.js.map +1 -0
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +21 -15
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +100 -163
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/MediaViewer.js +819 -0
- package/lib/module/components/Modals/FilePreviewModal/MediaViewer.js.map +1 -0
- package/lib/module/components/Modals/FilePreviewModal/useSaveFile.js +172 -0
- package/lib/module/components/Modals/FilePreviewModal/useSaveFile.js.map +1 -0
- package/lib/module/components/Modals/MessageSearchModal/MessageSearchModal.js +20 -4
- package/lib/module/components/Modals/MessageSearchModal/MessageSearchModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +17 -10
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/LanguageCard.js +1 -1
- package/lib/module/components/Modals/UserSettingsModal/LanguageCard.js.map +1 -1
- package/lib/module/components/VideoCalls/ActiveCallBar.js +3 -2
- package/lib/module/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/module/components/VideoCalls/CallButtons.js +19 -11
- package/lib/module/components/VideoCalls/CallButtons.js.map +1 -1
- package/lib/module/components/VideoCalls/CallControlBar.js +113 -0
- package/lib/module/components/VideoCalls/CallControlBar.js.map +1 -0
- package/lib/module/components/VideoCalls/CallVideo.js +43 -0
- package/lib/module/components/VideoCalls/CallVideo.js.map +1 -0
- package/lib/module/components/VideoCalls/GroupCallView.js +275 -0
- package/lib/module/components/VideoCalls/GroupCallView.js.map +1 -0
- package/lib/module/components/VideoCalls/P2PCallRunner.js +147 -0
- package/lib/module/components/VideoCalls/P2PCallRunner.js.map +1 -0
- package/lib/module/components/VideoCalls/VideoCallOverlay.js +38 -14
- package/lib/module/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/module/components/VideoCalls/VideoCallSession.js +46 -127
- package/lib/module/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/module/components/VideoCalls/callActions.js +3 -0
- package/lib/module/components/VideoCalls/callActions.js.map +1 -1
- package/lib/module/components/VideoCalls/callElapsed.js +33 -0
- package/lib/module/components/VideoCalls/callElapsed.js.map +1 -0
- package/lib/module/components/VideoCalls/callLive.js +10 -0
- package/lib/module/components/VideoCalls/callLive.js.map +1 -0
- package/lib/module/components/VideoCalls/callSessionController.js +80 -24
- package/lib/module/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/module/components/VideoCalls/callSessionTypes.js +37 -0
- package/lib/module/components/VideoCalls/callSessionTypes.js.map +1 -0
- package/lib/module/components/VideoCalls/groupLayout.js +36 -0
- package/lib/module/components/VideoCalls/groupLayout.js.map +1 -0
- package/lib/module/components/VideoCalls/p2pCallSession.js +256 -0
- package/lib/module/components/VideoCalls/p2pCallSession.js.map +1 -0
- package/lib/module/components/VideoCalls/useCallKeep.js +8 -2
- package/lib/module/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js +2 -1
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js.map +1 -1
- package/lib/module/components/styled/MessageImage.js +4 -1
- package/lib/module/components/styled/MessageImage.js.map +1 -1
- package/lib/module/components/styled/VideoMessage.js +5 -1
- package/lib/module/components/styled/VideoMessage.js.map +1 -1
- package/lib/module/context/MediaSourceContext.js +13 -0
- package/lib/module/context/MediaSourceContext.js.map +1 -0
- package/lib/module/context/xmppProvider.js +2 -1
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/callPush.js +3 -1
- package/lib/module/helpers/callPush.js.map +1 -1
- package/lib/module/helpers/constants/MODAL_COMPONENTS.js +2 -1
- package/lib/module/helpers/constants/MODAL_COMPONENTS.js.map +1 -1
- package/lib/module/helpers/constants/MODAL_TYPES.js +2 -0
- package/lib/module/helpers/constants/MODAL_TYPES.js.map +1 -1
- package/lib/module/helpers/incomingCallFromPush.js +63 -7
- package/lib/module/helpers/incomingCallFromPush.js.map +1 -1
- package/lib/module/helpers/publicChatsEntry.js +8 -6
- package/lib/module/helpers/publicChatsEntry.js.map +1 -1
- package/lib/module/helpers/pushPayload.js +5 -0
- package/lib/module/helpers/pushPayload.js.map +1 -1
- package/lib/module/helpers/reportRoom.js +70 -0
- package/lib/module/helpers/reportRoom.js.map +1 -0
- package/lib/module/helpers/roomMedia.js +112 -0
- package/lib/module/helpers/roomMedia.js.map +1 -0
- package/lib/module/i18n/strings.js +480 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +5 -0
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/callState.api.js +66 -0
- package/lib/module/networking/api-requests/callState.api.js.map +1 -0
- package/lib/module/networking/api-requests/push.api.js +29 -6
- package/lib/module/networking/api-requests/push.api.js.map +1 -1
- package/lib/module/networking/api-requests/rooms.api.js +17 -15
- package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/module/networking/api-requests/scheduledCalls.api.js +130 -0
- package/lib/module/networking/api-requests/scheduledCalls.api.js.map +1 -0
- package/lib/module/networking/callTokenStanza.js +210 -50
- package/lib/module/networking/callTokenStanza.js.map +1 -1
- package/lib/module/roomStore/callSlice.js +57 -3
- package/lib/module/roomStore/callSlice.js.map +1 -1
- package/lib/module/services/appBadge.js +74 -0
- package/lib/module/services/appBadge.js.map +1 -0
- package/lib/module/services/languageSettings.js +44 -13
- package/lib/module/services/languageSettings.js.map +1 -1
- package/lib/module/services/pushRegistration.js +21 -5
- package/lib/module/services/pushRegistration.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/booking/index.d.ts +3 -0
- package/lib/typescript/booking/index.d.ts.map +1 -0
- package/lib/typescript/booking/pendingScheduledCall.d.ts +80 -0
- package/lib/typescript/booking/pendingScheduledCall.d.ts.map +1 -0
- package/lib/typescript/booking/scheduleForm.d.ts +28 -0
- package/lib/typescript/booking/scheduleForm.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCall.d.ts +52 -0
- package/lib/typescript/booking/scheduledCall.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallActions.d.ts +22 -0
- package/lib/typescript/booking/scheduledCallActions.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallLink.d.ts +37 -0
- package/lib/typescript/booking/scheduledCallLink.d.ts.map +1 -0
- package/lib/typescript/booking/scheduledCallStore.d.ts +47 -0
- package/lib/typescript/booking/scheduledCallStore.d.ts.map +1 -0
- package/lib/typescript/booking/startRoomCall.d.ts +12 -0
- package/lib/typescript/booking/startRoomCall.d.ts.map +1 -0
- package/lib/typescript/calls/callBusy.d.ts +9 -0
- package/lib/typescript/calls/callBusy.d.ts.map +1 -0
- package/lib/typescript/calls/callDisplay.d.ts +23 -0
- package/lib/typescript/calls/callDisplay.d.ts.map +1 -0
- package/lib/typescript/calls/callMode.d.ts +106 -0
- package/lib/typescript/calls/callMode.d.ts.map +1 -0
- package/lib/typescript/calls/declineReport.d.ts +11 -0
- package/lib/typescript/calls/declineReport.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/P2PCallController.d.ts +150 -0
- package/lib/typescript/calls/p2p/P2PCallController.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/icePolicy.d.ts +37 -0
- package/lib/typescript/calls/p2p/icePolicy.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/negotiator.d.ts +57 -0
- package/lib/typescript/calls/p2p/negotiator.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/p2pRuntime.d.ts +41 -0
- package/lib/typescript/calls/p2p/p2pRuntime.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/signalInbox.d.ts +35 -0
- package/lib/typescript/calls/p2p/signalInbox.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/signalStanza.d.ts +52 -0
- package/lib/typescript/calls/p2p/signalStanza.d.ts.map +1 -0
- package/lib/typescript/calls/p2p/webrtcRuntime.d.ts +32 -0
- package/lib/typescript/calls/p2p/webrtcRuntime.d.ts.map +1 -0
- package/lib/typescript/calls/senderTrust.d.ts +8 -0
- package/lib/typescript/calls/senderTrust.d.ts.map +1 -0
- package/lib/typescript/calls/startCall.d.ts +17 -0
- package/lib/typescript/calls/startCall.d.ts.map +1 -0
- package/lib/typescript/components/Booking/BookingIcons.d.ts +9 -0
- package/lib/typescript/components/Booking/BookingIcons.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduleCallButton.d.ts +11 -0
- package/lib/typescript/components/Booking/ScheduleCallButton.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduleCallSheet.d.ts +4 -0
- package/lib/typescript/components/Booking/ScheduleCallSheet.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallCard.d.ts +14 -0
- package/lib/typescript/components/Booking/ScheduledCallCard.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallHost.d.ts +10 -0
- package/lib/typescript/components/Booking/ScheduledCallHost.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallMessage.d.ts +20 -0
- package/lib/typescript/components/Booking/ScheduledCallMessage.d.ts.map +1 -0
- package/lib/typescript/components/Booking/ScheduledCallPreJoin.d.ts +8 -0
- package/lib/typescript/components/Booking/ScheduledCallPreJoin.d.ts.map +1 -0
- package/lib/typescript/components/Booking/bookingShared.d.ts +199 -0
- package/lib/typescript/components/Booking/bookingShared.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/AlbumGrid.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorButton.d.ts +3 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorButton.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/LanguageSelectorModal.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts +3 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageContainer.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ReduxWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatMediaGrid.d.ts +16 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatMediaGrid.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/LeaveChatModal.d.ts +18 -0
- package/lib/typescript/components/Modals/ChatProfileModal/LeaveChatModal.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts +16 -0
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/MediaViewer.d.ts +27 -0
- package/lib/typescript/components/Modals/FilePreviewModal/MediaViewer.d.ts.map +1 -0
- package/lib/typescript/components/Modals/FilePreviewModal/useSaveFile.d.ts +9 -0
- package/lib/typescript/components/Modals/FilePreviewModal/useSaveFile.d.ts.map +1 -0
- package/lib/typescript/components/Modals/MessageSearchModal/MessageSearchModal.d.ts +8 -0
- package/lib/typescript/components/Modals/MessageSearchModal/MessageSearchModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/LanguageCard.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/ActiveCallBar.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/CallButtons.d.ts +2 -1
- package/lib/typescript/components/VideoCalls/CallButtons.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/CallControlBar.d.ts +17 -0
- package/lib/typescript/components/VideoCalls/CallControlBar.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/CallVideo.d.ts +23 -0
- package/lib/typescript/components/VideoCalls/CallVideo.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/GroupCallView.d.ts +22 -0
- package/lib/typescript/components/VideoCalls/GroupCallView.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/P2PCallRunner.d.ts +2 -0
- package/lib/typescript/components/VideoCalls/P2PCallRunner.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/VideoCallOverlay.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts +10 -12
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callActions.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callElapsed.d.ts +8 -0
- package/lib/typescript/components/VideoCalls/callElapsed.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/callLive.d.ts +9 -0
- package/lib/typescript/components/VideoCalls/callLive.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts +10 -31
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callSessionTypes.d.ts +60 -0
- package/lib/typescript/components/VideoCalls/callSessionTypes.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/groupLayout.d.ts +23 -0
- package/lib/typescript/components/VideoCalls/groupLayout.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/p2pCallSession.d.ts +31 -0
- package/lib/typescript/components/VideoCalls/p2pCallSession.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/useCallKeep.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/useOngoingCallNotification.d.ts.map +1 -1
- package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
- package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
- package/lib/typescript/context/MediaSourceContext.d.ts +4 -0
- package/lib/typescript/context/MediaSourceContext.d.ts.map +1 -0
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/callPush.d.ts +11 -1
- package/lib/typescript/helpers/callPush.d.ts.map +1 -1
- package/lib/typescript/helpers/constants/MODAL_COMPONENTS.d.ts.map +1 -1
- package/lib/typescript/helpers/constants/MODAL_TYPES.d.ts +2 -0
- package/lib/typescript/helpers/constants/MODAL_TYPES.d.ts.map +1 -1
- package/lib/typescript/helpers/incomingCallFromPush.d.ts.map +1 -1
- package/lib/typescript/helpers/publicChatsEntry.d.ts +7 -5
- package/lib/typescript/helpers/publicChatsEntry.d.ts.map +1 -1
- package/lib/typescript/helpers/pushPayload.d.ts +1 -1
- package/lib/typescript/helpers/pushPayload.d.ts.map +1 -1
- package/lib/typescript/helpers/reportRoom.d.ts +19 -0
- package/lib/typescript/helpers/reportRoom.d.ts.map +1 -0
- package/lib/typescript/helpers/roomMedia.d.ts +26 -0
- package/lib/typescript/helpers/roomMedia.d.ts.map +1 -0
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +6 -1
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/callState.api.d.ts +25 -0
- package/lib/typescript/networking/api-requests/callState.api.d.ts.map +1 -0
- package/lib/typescript/networking/api-requests/push.api.d.ts +9 -2
- package/lib/typescript/networking/api-requests/push.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts +8 -6
- package/lib/typescript/networking/api-requests/rooms.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/scheduledCalls.api.d.ts +86 -0
- package/lib/typescript/networking/api-requests/scheduledCalls.api.d.ts.map +1 -0
- package/lib/typescript/networking/callTokenStanza.d.ts.map +1 -1
- package/lib/typescript/roomStore/callSlice.d.ts +23 -1
- package/lib/typescript/roomStore/callSlice.d.ts.map +1 -1
- package/lib/typescript/services/appBadge.d.ts +3 -0
- package/lib/typescript/services/appBadge.d.ts.map +1 -0
- package/lib/typescript/services/languageSettings.d.ts +7 -0
- package/lib/typescript/services/languageSettings.d.ts.map +1 -1
- package/lib/typescript/services/pushRegistration.d.ts.map +1 -1
- package/lib/typescript/types/models/modal.model.d.ts +18 -0
- package/lib/typescript/types/models/modal.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +85 -4
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +9 -2
- package/src/booking/index.ts +10 -0
- package/src/booking/pendingScheduledCall.ts +272 -0
- package/src/booking/scheduleForm.ts +84 -0
- package/src/booking/scheduledCall.ts +163 -0
- package/src/booking/scheduledCallActions.ts +141 -0
- package/src/booking/scheduledCallLink.ts +145 -0
- package/src/booking/scheduledCallStore.ts +69 -0
- package/src/booking/startRoomCall.ts +103 -0
- package/src/calls/callBusy.ts +10 -0
- package/src/calls/callDisplay.ts +74 -0
- package/src/calls/callMode.ts +286 -0
- package/src/calls/declineReport.ts +16 -0
- package/src/calls/p2p/P2PCallController.ts +813 -0
- package/src/calls/p2p/icePolicy.ts +99 -0
- package/src/calls/p2p/negotiator.ts +186 -0
- package/src/calls/p2p/p2pRuntime.ts +164 -0
- package/src/calls/p2p/signalInbox.ts +117 -0
- package/src/calls/p2p/signalStanza.ts +205 -0
- package/src/calls/p2p/webrtcRuntime.ts +60 -0
- package/src/calls/senderTrust.ts +40 -0
- package/src/calls/startCall.ts +56 -0
- package/src/components/Booking/BookingIcons.tsx +44 -0
- package/src/components/Booking/ScheduleCallButton.tsx +66 -0
- package/src/components/Booking/ScheduleCallSheet.tsx +380 -0
- package/src/components/Booking/ScheduledCallCard.tsx +216 -0
- package/src/components/Booking/ScheduledCallHost.tsx +18 -0
- package/src/components/Booking/ScheduledCallMessage.tsx +62 -0
- package/src/components/Booking/ScheduledCallPreJoin.tsx +230 -0
- package/src/components/Booking/bookingShared.tsx +295 -0
- package/src/components/MainComponents/AlbumGrid.tsx +5 -1
- package/src/components/MainComponents/ChatHeader.tsx +18 -11
- package/src/components/MainComponents/LanguageSelectorButton.tsx +9 -2
- package/src/components/MainComponents/LanguageSelectorModal.tsx +10 -6
- package/src/components/MainComponents/MediaMessage.tsx +13 -2
- package/src/components/MainComponents/MessageContainer.tsx +15 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +10 -0
- package/src/components/MainComponents/RoomList.tsx +8 -19
- package/src/components/MessageBubble/Message.tsx +24 -1
- package/src/components/Modals/ChatProfileModal/ChatMediaGrid.tsx +174 -0
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +119 -48
- package/src/components/Modals/ChatProfileModal/LeaveChatModal.tsx +191 -0
- package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +22 -22
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +115 -185
- package/src/components/Modals/FilePreviewModal/MediaViewer.tsx +880 -0
- package/src/components/Modals/FilePreviewModal/useSaveFile.ts +207 -0
- package/src/components/Modals/MessageSearchModal/MessageSearchModal.tsx +56 -30
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +28 -9
- package/src/components/Modals/UserSettingsModal/LanguageCard.tsx +9 -7
- package/src/components/VideoCalls/ActiveCallBar.tsx +6 -5
- package/src/components/VideoCalls/CallButtons.tsx +23 -12
- package/src/components/VideoCalls/CallControlBar.tsx +131 -0
- package/src/components/VideoCalls/CallVideo.tsx +59 -0
- package/src/components/VideoCalls/GroupCallView.tsx +324 -0
- package/src/components/VideoCalls/P2PCallRunner.tsx +192 -0
- package/src/components/VideoCalls/VideoCallOverlay.tsx +62 -17
- package/src/components/VideoCalls/VideoCallSession.tsx +55 -133
- package/src/components/VideoCalls/callActions.ts +3 -0
- package/src/components/VideoCalls/callElapsed.ts +27 -0
- package/src/components/VideoCalls/callLive.ts +13 -0
- package/src/components/VideoCalls/callSessionController.ts +130 -55
- package/src/components/VideoCalls/callSessionTypes.ts +80 -0
- package/src/components/VideoCalls/groupLayout.ts +48 -0
- package/src/components/VideoCalls/p2pCallSession.ts +291 -0
- package/src/components/VideoCalls/useCallKeep.ts +9 -2
- package/src/components/VideoCalls/useOngoingCallNotification.ts +2 -2
- package/src/components/styled/MessageImage.tsx +3 -1
- package/src/components/styled/VideoMessage.tsx +5 -1
- package/src/context/MediaSourceContext.tsx +14 -0
- package/src/context/xmppProvider.tsx +3 -0
- package/src/helpers/callPush.ts +13 -1
- package/src/helpers/constants/MODAL_COMPONENTS.tsx +4 -1
- package/src/helpers/constants/MODAL_TYPES.ts +2 -0
- package/src/helpers/incomingCallFromPush.ts +65 -7
- package/src/helpers/publicChatsEntry.ts +8 -7
- package/src/helpers/pushPayload.ts +9 -1
- package/src/helpers/reportRoom.ts +93 -0
- package/src/helpers/roomMedia.ts +126 -0
- package/src/i18n/strings.ts +480 -0
- package/src/main.ts +33 -0
- package/src/networking/api-requests/callState.api.ts +83 -0
- package/src/networking/api-requests/push.api.ts +28 -3
- package/src/networking/api-requests/rooms.api.ts +25 -15
- package/src/networking/api-requests/scheduledCalls.api.ts +232 -0
- package/src/networking/callTokenStanza.ts +247 -50
- package/src/roomStore/callSlice.ts +86 -2
- package/src/services/appBadge.ts +85 -0
- package/src/services/languageSettings.ts +43 -8
- package/src/services/pushRegistration.ts +34 -3
- package/src/types/models/modal.model.ts +16 -0
- package/src/types/types.ts +86 -4
- package/src/version.ts +1 -1
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.remoteEndNotice = exports.describeMediaError = exports.P2PCallController = void 0;
|
|
7
|
+
var _icePolicy = require("./icePolicy");
|
|
8
|
+
var _negotiator = require("./negotiator");
|
|
9
|
+
// One peer to peer call, from getUserMedia to hang-up. Everything that talks
|
|
10
|
+
// to the outside world is injected (RTCPeerConnection, getUserMedia, the
|
|
11
|
+
// signal transport, ICE credential refresh), so the class is plain TypeScript
|
|
12
|
+
// and runs under a fake connection in unit tests. The decisions live in the
|
|
13
|
+
// small pure modules next to it (negotiator, icePolicy, signalStanza); this
|
|
14
|
+
// class only wires them to a real connection and cleans up after itself.
|
|
15
|
+
//
|
|
16
|
+
// Media encryption: a WebRTC peer connection already encrypts media between
|
|
17
|
+
// the two peers with DTLS-SRTP, so the LiveKit insertable-streams E2EE layer
|
|
18
|
+
// (and its OMEMO key exchange) is deliberately NOT applied on this path.
|
|
19
|
+
|
|
20
|
+
const DEFAULT_TIMINGS = {
|
|
21
|
+
connectTimeoutMs: 25_000,
|
|
22
|
+
// While nobody has answered, the offer and candidates are sent again: a
|
|
23
|
+
// callee that was still reconnecting (woken by push) missed the first copy,
|
|
24
|
+
// and the stanzas are not stored for later. Duplicates are no-ops there.
|
|
25
|
+
offerResendMs: [4_000, 10_000]
|
|
26
|
+
};
|
|
27
|
+
const describeMediaError = error => {
|
|
28
|
+
const name = error?.name || '';
|
|
29
|
+
const text = String(error?.message || '').toLowerCase();
|
|
30
|
+
if (name === 'NotAllowedError' || name === 'SecurityError' || text.includes('permission') || text.includes('denied')) {
|
|
31
|
+
return 'Camera or microphone permission denied';
|
|
32
|
+
}
|
|
33
|
+
if (name === 'NotFoundError' || name === 'OverconstrainedError') {
|
|
34
|
+
return 'No camera or microphone found on this device';
|
|
35
|
+
}
|
|
36
|
+
if (name === 'NotReadableError' || name === 'AbortError') {
|
|
37
|
+
return 'Your camera or microphone is already in use by another app';
|
|
38
|
+
}
|
|
39
|
+
return 'Could not access your camera or microphone';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What to show when the PEER ended the call for a reason that is a failure
|
|
44
|
+
* rather than a normal hang up / decline. Null means "just close the call".
|
|
45
|
+
*/
|
|
46
|
+
exports.describeMediaError = describeMediaError;
|
|
47
|
+
const remoteEndNotice = reason => {
|
|
48
|
+
switch (reason) {
|
|
49
|
+
case 'media-error':
|
|
50
|
+
return 'The other person could not access their camera or microphone';
|
|
51
|
+
case 'connect-timeout':
|
|
52
|
+
case 'connection-failed':
|
|
53
|
+
case 'negotiation-error':
|
|
54
|
+
case 'setup-error':
|
|
55
|
+
return 'The call could not be connected';
|
|
56
|
+
default:
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.remoteEndNotice = remoteEndNotice;
|
|
61
|
+
const AUDIO_CONSTRAINTS = {
|
|
62
|
+
echoCancellation: true,
|
|
63
|
+
noiseSuppression: true,
|
|
64
|
+
autoGainControl: true
|
|
65
|
+
};
|
|
66
|
+
const VIDEO_CONSTRAINTS = {
|
|
67
|
+
width: {
|
|
68
|
+
ideal: 1280
|
|
69
|
+
},
|
|
70
|
+
height: {
|
|
71
|
+
ideal: 720
|
|
72
|
+
},
|
|
73
|
+
facingMode: 'user'
|
|
74
|
+
};
|
|
75
|
+
class P2PCallController {
|
|
76
|
+
policy = new _icePolicy.IceRestartPolicy();
|
|
77
|
+
listeners = new Set();
|
|
78
|
+
pc = null;
|
|
79
|
+
localStream = null;
|
|
80
|
+
audioTrack = null;
|
|
81
|
+
videoTrack = null;
|
|
82
|
+
videoSender = null;
|
|
83
|
+
ownedTracks = [];
|
|
84
|
+
remoteStream = null;
|
|
85
|
+
remoteCleanups = [];
|
|
86
|
+
queue = Promise.resolve();
|
|
87
|
+
timers = new Set();
|
|
88
|
+
graceTimer = null;
|
|
89
|
+
deadlineTimer = null;
|
|
90
|
+
connectTimer = null;
|
|
91
|
+
started = false;
|
|
92
|
+
disposed = false;
|
|
93
|
+
endSent = false;
|
|
94
|
+
connectedOnce = false;
|
|
95
|
+
negotiated = false;
|
|
96
|
+
cameraBusy = false;
|
|
97
|
+
lastConn = null;
|
|
98
|
+
|
|
99
|
+
// Outgoing candidates wait until the offer/answer they belong to is out, so
|
|
100
|
+
// the peer never sees a candidate before its description.
|
|
101
|
+
candidateGateOpen = false;
|
|
102
|
+
heldOutgoingCandidates = [];
|
|
103
|
+
sentCandidates = [];
|
|
104
|
+
lastOffer = null;
|
|
105
|
+
constructor(params, deps, events = {}, timings = {}) {
|
|
106
|
+
this.params = params;
|
|
107
|
+
this.deps = deps;
|
|
108
|
+
this.events = events;
|
|
109
|
+
this.timings = {
|
|
110
|
+
...DEFAULT_TIMINGS,
|
|
111
|
+
...timings
|
|
112
|
+
};
|
|
113
|
+
this.callId = params.callId;
|
|
114
|
+
this.role = params.role;
|
|
115
|
+
this.kind = params.kind;
|
|
116
|
+
this.negotiator = new _negotiator.P2PNegotiator({
|
|
117
|
+
callId: params.callId,
|
|
118
|
+
role: params.role,
|
|
119
|
+
peerLocal: params.peerLocal
|
|
120
|
+
});
|
|
121
|
+
this.snapshot = {
|
|
122
|
+
status: 'preparing',
|
|
123
|
+
localStream: null,
|
|
124
|
+
remoteStream: null,
|
|
125
|
+
micEnabled: params.startWithMicOn !== false,
|
|
126
|
+
camEnabled: params.kind === 'video' && params.startWithCameraOn !== false,
|
|
127
|
+
remoteVideoLive: false,
|
|
128
|
+
notice: null
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ---- observable state (useSyncExternalStore friendly) -------------------
|
|
133
|
+
|
|
134
|
+
subscribe = listener => {
|
|
135
|
+
this.listeners.add(listener);
|
|
136
|
+
return () => {
|
|
137
|
+
this.listeners.delete(listener);
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
getSnapshot = () => this.snapshot;
|
|
141
|
+
update(patch) {
|
|
142
|
+
this.snapshot = {
|
|
143
|
+
...this.snapshot,
|
|
144
|
+
...patch
|
|
145
|
+
};
|
|
146
|
+
for (const listener of Array.from(this.listeners)) listener();
|
|
147
|
+
}
|
|
148
|
+
log(message, detail) {
|
|
149
|
+
this.deps.log?.(`[p2p ${this.callId}] ${message}`, detail);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ---- timers -------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
later(fn, ms) {
|
|
155
|
+
const id = setTimeout(() => {
|
|
156
|
+
this.timers.delete(id);
|
|
157
|
+
if (!this.disposed) fn();
|
|
158
|
+
}, ms);
|
|
159
|
+
this.timers.add(id);
|
|
160
|
+
return id;
|
|
161
|
+
}
|
|
162
|
+
cancel(id) {
|
|
163
|
+
if (id === null) return;
|
|
164
|
+
clearTimeout(id);
|
|
165
|
+
this.timers.delete(id);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ---- lifecycle ----------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Caller: get media, build the connection, offer. Callee: get media, build
|
|
172
|
+
* the connection, then apply the offer that may already be waiting. Safe to
|
|
173
|
+
* call once; every failure ends the call with a message instead of throwing.
|
|
174
|
+
*/
|
|
175
|
+
async start() {
|
|
176
|
+
if (this.started || this.disposed) return;
|
|
177
|
+
this.started = true;
|
|
178
|
+
this.update({
|
|
179
|
+
status: 'preparing'
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Credentials are fetched while the permission prompt is open.
|
|
183
|
+
const icePromise = this.params.iceServers.length > 0 ? Promise.resolve(this.params.iceServers) : this.deps.fetchIceServers().then(list => list || []).catch(() => []);
|
|
184
|
+
try {
|
|
185
|
+
await this.acquireMedia();
|
|
186
|
+
} catch (error) {
|
|
187
|
+
this.log('getUserMedia failed', error);
|
|
188
|
+
this.fail(describeMediaError(error), 'media-error');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this.disposed) {
|
|
192
|
+
this.releaseMedia();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const servers = await icePromise;
|
|
196
|
+
if (this.disposed) return;
|
|
197
|
+
try {
|
|
198
|
+
this.createConnection(servers);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
this.log('peer connection setup failed', error);
|
|
201
|
+
this.fail('Could not start the call', 'setup-error');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.enqueue(async () => {
|
|
205
|
+
await this.runCommands(this.negotiator.markReady());
|
|
206
|
+
if (this.role === 'caller' && !this.disposed) {
|
|
207
|
+
await this.sendOffer(false);
|
|
208
|
+
this.update({
|
|
209
|
+
status: 'waiting'
|
|
210
|
+
});
|
|
211
|
+
this.scheduleOfferResends();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Feed a signal from the peer (already routed by callId). */
|
|
217
|
+
receive(signal) {
|
|
218
|
+
if (this.disposed) return;
|
|
219
|
+
const commands = this.negotiator.receive(signal);
|
|
220
|
+
// An end must act immediately: it can arrive while the permission prompt
|
|
221
|
+
// is still open, before the connection (and so the job queue) is running.
|
|
222
|
+
const end = commands.find(c => c.type === 'remote-end');
|
|
223
|
+
if (end && end.type === 'remote-end') {
|
|
224
|
+
this.handleRemoteEnd(end.reason);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (commands.length > 0) this.enqueue(() => this.runCommands(commands));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Local user hung up (or cancelled): tell the peer and release everything. */
|
|
231
|
+
hangup(reason = 'hangup') {
|
|
232
|
+
if (this.disposed) return;
|
|
233
|
+
this.sendEnd(reason);
|
|
234
|
+
this.dispose();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Release every resource: timers, listeners, media tracks, the connection.
|
|
239
|
+
* Idempotent, safe from any exit path. Tells the peer unless it is already
|
|
240
|
+
* known to be over.
|
|
241
|
+
*/
|
|
242
|
+
dispose() {
|
|
243
|
+
if (this.disposed) return;
|
|
244
|
+
this.disposed = true;
|
|
245
|
+
if (this.started && !this.negotiator.isEnded) this.sendEnd('hangup');
|
|
246
|
+
for (const id of this.timers) clearTimeout(id);
|
|
247
|
+
this.timers.clear();
|
|
248
|
+
this.negotiator.stop();
|
|
249
|
+
for (const cleanup of this.remoteCleanups) {
|
|
250
|
+
try {
|
|
251
|
+
cleanup();
|
|
252
|
+
} catch {
|
|
253
|
+
/* listener already gone */
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
this.remoteCleanups = [];
|
|
257
|
+
const pc = this.pc;
|
|
258
|
+
this.pc = null;
|
|
259
|
+
if (pc) {
|
|
260
|
+
pc.onicecandidate = null;
|
|
261
|
+
pc.ontrack = null;
|
|
262
|
+
pc.onconnectionstatechange = null;
|
|
263
|
+
pc.oniceconnectionstatechange = null;
|
|
264
|
+
try {
|
|
265
|
+
pc.close();
|
|
266
|
+
} catch {
|
|
267
|
+
/* already closed */
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
this.releaseMedia();
|
|
271
|
+
this.snapshot = {
|
|
272
|
+
...this.snapshot,
|
|
273
|
+
status: this.snapshot.status === 'failed' ? 'failed' : 'ended',
|
|
274
|
+
localStream: null,
|
|
275
|
+
remoteStream: null,
|
|
276
|
+
remoteVideoLive: false
|
|
277
|
+
};
|
|
278
|
+
for (const listener of Array.from(this.listeners)) listener();
|
|
279
|
+
this.listeners.clear();
|
|
280
|
+
this.events.onDisposed?.({
|
|
281
|
+
started: this.started
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
sendEnd(reason) {
|
|
285
|
+
if (this.endSent) return;
|
|
286
|
+
this.endSent = true;
|
|
287
|
+
try {
|
|
288
|
+
this.deps.sendSignal('end', {
|
|
289
|
+
reason
|
|
290
|
+
});
|
|
291
|
+
} catch (error) {
|
|
292
|
+
this.log('end signal failed', error);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
fail(message, reason) {
|
|
296
|
+
if (this.disposed) return;
|
|
297
|
+
this.sendEnd(reason);
|
|
298
|
+
this.snapshot = {
|
|
299
|
+
...this.snapshot,
|
|
300
|
+
status: 'failed',
|
|
301
|
+
notice: message
|
|
302
|
+
};
|
|
303
|
+
this.events.onFailed?.(message);
|
|
304
|
+
this.dispose();
|
|
305
|
+
}
|
|
306
|
+
handleRemoteEnd(reason) {
|
|
307
|
+
if (this.disposed) return;
|
|
308
|
+
// The peer already knows; do not echo an end back.
|
|
309
|
+
this.endSent = true;
|
|
310
|
+
this.snapshot = {
|
|
311
|
+
...this.snapshot,
|
|
312
|
+
status: 'ended'
|
|
313
|
+
};
|
|
314
|
+
this.events.onRemoteEnd?.(reason);
|
|
315
|
+
this.dispose();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ---- media --------------------------------------------------------------
|
|
319
|
+
|
|
320
|
+
async acquireMedia() {
|
|
321
|
+
const wantVideo = this.kind === 'video' && this.params.startWithCameraOn !== false;
|
|
322
|
+
const stream = await this.deps.getUserMedia({
|
|
323
|
+
audio: AUDIO_CONSTRAINTS,
|
|
324
|
+
video: wantVideo ? VIDEO_CONSTRAINTS : false
|
|
325
|
+
});
|
|
326
|
+
this.localStream = stream;
|
|
327
|
+
this.ownedTracks = stream.getTracks();
|
|
328
|
+
this.audioTrack = stream.getAudioTracks()[0] || null;
|
|
329
|
+
this.videoTrack = stream.getVideoTracks()[0] || null;
|
|
330
|
+
if (this.audioTrack && this.params.startWithMicOn === false) {
|
|
331
|
+
this.audioTrack.enabled = false;
|
|
332
|
+
}
|
|
333
|
+
this.update({
|
|
334
|
+
localStream: stream,
|
|
335
|
+
micEnabled: !!this.audioTrack && this.audioTrack.enabled,
|
|
336
|
+
camEnabled: !!this.videoTrack
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
releaseMedia() {
|
|
340
|
+
const tracks = new Set(this.ownedTracks);
|
|
341
|
+
this.localStream?.getTracks().forEach(t => tracks.add(t));
|
|
342
|
+
for (const track of tracks) {
|
|
343
|
+
try {
|
|
344
|
+
track.stop();
|
|
345
|
+
} catch {
|
|
346
|
+
/* already stopped */
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
this.ownedTracks = [];
|
|
350
|
+
this.audioTrack = null;
|
|
351
|
+
this.videoTrack = null;
|
|
352
|
+
this.videoSender = null;
|
|
353
|
+
this.localStream = null;
|
|
354
|
+
}
|
|
355
|
+
toggleMic() {
|
|
356
|
+
if (this.disposed || !this.audioTrack) return;
|
|
357
|
+
this.audioTrack.enabled = !this.audioTrack.enabled;
|
|
358
|
+
this.update({
|
|
359
|
+
micEnabled: this.audioTrack.enabled
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Turning the camera off stops sending video and releases the device (the
|
|
365
|
+
* camera light goes out); turning it on opens the camera again and swaps it
|
|
366
|
+
* into the existing sender, so no renegotiation is needed.
|
|
367
|
+
*/
|
|
368
|
+
async toggleCamera() {
|
|
369
|
+
if (this.disposed || this.kind !== 'video' || !this.videoSender || !this.localStream || this.cameraBusy) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
this.cameraBusy = true;
|
|
373
|
+
try {
|
|
374
|
+
if (this.videoTrack) {
|
|
375
|
+
const track = this.videoTrack;
|
|
376
|
+
this.videoTrack = null;
|
|
377
|
+
try {
|
|
378
|
+
await this.videoSender.replaceTrack(null);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
this.log('replaceTrack(null) failed', error);
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
this.localStream.removeTrack(track);
|
|
384
|
+
} catch {
|
|
385
|
+
/* not in the stream */
|
|
386
|
+
}
|
|
387
|
+
track.stop();
|
|
388
|
+
this.ownedTracks = this.ownedTracks.filter(t => t !== track);
|
|
389
|
+
this.update({
|
|
390
|
+
camEnabled: false,
|
|
391
|
+
notice: null
|
|
392
|
+
});
|
|
393
|
+
} else {
|
|
394
|
+
const media = await this.deps.getUserMedia({
|
|
395
|
+
video: VIDEO_CONSTRAINTS
|
|
396
|
+
});
|
|
397
|
+
const track = media.getVideoTracks()[0];
|
|
398
|
+
if (!track) return;
|
|
399
|
+
if (this.disposed || !this.videoSender || !this.localStream) {
|
|
400
|
+
track.stop();
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
await this.videoSender.replaceTrack(track);
|
|
404
|
+
this.localStream.addTrack(track);
|
|
405
|
+
this.videoTrack = track;
|
|
406
|
+
this.ownedTracks.push(track);
|
|
407
|
+
this.update({
|
|
408
|
+
camEnabled: true,
|
|
409
|
+
notice: null
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
} catch (error) {
|
|
413
|
+
this.log('camera toggle failed', error);
|
|
414
|
+
this.update({
|
|
415
|
+
notice: describeMediaError(error)
|
|
416
|
+
});
|
|
417
|
+
} finally {
|
|
418
|
+
this.cameraBusy = false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
dismissNotice() {
|
|
422
|
+
if (this.snapshot.notice) this.update({
|
|
423
|
+
notice: null
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// ---- peer connection ----------------------------------------------------
|
|
428
|
+
|
|
429
|
+
createConnection(servers) {
|
|
430
|
+
const pc = this.deps.createPeerConnection({
|
|
431
|
+
iceServers: servers,
|
|
432
|
+
iceCandidatePoolSize: 2
|
|
433
|
+
});
|
|
434
|
+
this.pc = pc;
|
|
435
|
+
pc.onicecandidate = event => {
|
|
436
|
+
const c = event.candidate;
|
|
437
|
+
if (!c || !c.candidate) return;
|
|
438
|
+
const json = typeof c.toJSON === 'function' ? c.toJSON() : {
|
|
439
|
+
candidate: c.candidate,
|
|
440
|
+
sdpMid: c.sdpMid,
|
|
441
|
+
sdpMLineIndex: c.sdpMLineIndex
|
|
442
|
+
};
|
|
443
|
+
if (this.candidateGateOpen) this.emitCandidate(json);else this.heldOutgoingCandidates.push(json);
|
|
444
|
+
};
|
|
445
|
+
pc.ontrack = event => this.onRemoteTrack(event.track);
|
|
446
|
+
pc.onconnectionstatechange = () => this.onConnectionState();
|
|
447
|
+
pc.oniceconnectionstatechange = () => this.onConnectionState();
|
|
448
|
+
const stream = this.localStream;
|
|
449
|
+
if (stream) {
|
|
450
|
+
if (this.audioTrack) pc.addTrack(this.audioTrack, stream);
|
|
451
|
+
if (this.kind === 'video') {
|
|
452
|
+
if (this.videoTrack) {
|
|
453
|
+
this.videoSender = pc.addTrack(this.videoTrack, stream);
|
|
454
|
+
} else {
|
|
455
|
+
// Camera starts off: keep a video section so it can be turned on
|
|
456
|
+
// later without renegotiating.
|
|
457
|
+
this.videoSender = pc.addTransceiver('video', {
|
|
458
|
+
direction: 'sendrecv'
|
|
459
|
+
}).sender;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
emitCandidate(candidate) {
|
|
465
|
+
this.sentCandidates.push(candidate);
|
|
466
|
+
this.deps.sendSignal('candidate', candidate);
|
|
467
|
+
}
|
|
468
|
+
openCandidateGate() {
|
|
469
|
+
this.candidateGateOpen = true;
|
|
470
|
+
const held = this.heldOutgoingCandidates;
|
|
471
|
+
this.heldOutgoingCandidates = [];
|
|
472
|
+
for (const candidate of held) this.emitCandidate(candidate);
|
|
473
|
+
}
|
|
474
|
+
onRemoteTrack(track) {
|
|
475
|
+
if (!this.remoteStream) this.remoteStream = this.deps.createMediaStream();
|
|
476
|
+
const stream = this.remoteStream;
|
|
477
|
+
if (!stream.getTracks().includes(track)) stream.addTrack(track);
|
|
478
|
+
const refresh = () => this.update({
|
|
479
|
+
remoteVideoLive: this.remoteVideoLive()
|
|
480
|
+
});
|
|
481
|
+
track.addEventListener('mute', refresh);
|
|
482
|
+
track.addEventListener('unmute', refresh);
|
|
483
|
+
track.addEventListener('ended', refresh);
|
|
484
|
+
this.remoteCleanups.push(() => {
|
|
485
|
+
track.removeEventListener('mute', refresh);
|
|
486
|
+
track.removeEventListener('unmute', refresh);
|
|
487
|
+
track.removeEventListener('ended', refresh);
|
|
488
|
+
});
|
|
489
|
+
this.update({
|
|
490
|
+
remoteStream: stream,
|
|
491
|
+
remoteVideoLive: this.remoteVideoLive()
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
remoteVideoLive() {
|
|
495
|
+
return (this.remoteStream?.getVideoTracks() || []).some(t => t.readyState === 'live' && !t.muted);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// ---- negotiation --------------------------------------------------------
|
|
499
|
+
|
|
500
|
+
enqueue(job) {
|
|
501
|
+
this.queue = this.queue.then(() => this.disposed ? undefined : job()).catch(error => {
|
|
502
|
+
this.log('negotiation step failed', error);
|
|
503
|
+
// A broken negotiation cannot recover on its own.
|
|
504
|
+
this.fail('Could not set up the call', 'negotiation-error');
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
async sendOffer(iceRestart) {
|
|
508
|
+
const pc = this.pc;
|
|
509
|
+
if (!pc || this.disposed) return;
|
|
510
|
+
this.candidateGateOpen = false;
|
|
511
|
+
const offer = await pc.createOffer(iceRestart ? {
|
|
512
|
+
iceRestart: true
|
|
513
|
+
} : undefined);
|
|
514
|
+
await pc.setLocalDescription(offer);
|
|
515
|
+
if (this.disposed) return;
|
|
516
|
+
const sdp = pc.localDescription?.sdp || offer.sdp || '';
|
|
517
|
+
this.negotiator.markLocalOffer();
|
|
518
|
+
this.lastOffer = {
|
|
519
|
+
type: 'offer',
|
|
520
|
+
sdp
|
|
521
|
+
};
|
|
522
|
+
this.sentCandidates = [];
|
|
523
|
+
this.deps.sendSignal('offer', this.lastOffer);
|
|
524
|
+
this.openCandidateGate();
|
|
525
|
+
}
|
|
526
|
+
scheduleOfferResends() {
|
|
527
|
+
for (const ms of this.timings.offerResendMs) {
|
|
528
|
+
this.later(() => {
|
|
529
|
+
if (!this.negotiator.awaitingAnswer || !this.lastOffer) return;
|
|
530
|
+
this.log('re-sending offer');
|
|
531
|
+
this.deps.sendSignal('offer', this.lastOffer);
|
|
532
|
+
for (const candidate of this.sentCandidates) {
|
|
533
|
+
this.deps.sendSignal('candidate', candidate);
|
|
534
|
+
}
|
|
535
|
+
}, ms);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async runCommands(commands) {
|
|
539
|
+
for (const command of commands) {
|
|
540
|
+
if (this.disposed || !this.pc) return;
|
|
541
|
+
switch (command.type) {
|
|
542
|
+
case 'apply-offer':
|
|
543
|
+
await this.applyOffer(command);
|
|
544
|
+
break;
|
|
545
|
+
case 'apply-answer':
|
|
546
|
+
await this.pc.setRemoteDescription({
|
|
547
|
+
type: 'answer',
|
|
548
|
+
sdp: command.sdp
|
|
549
|
+
});
|
|
550
|
+
await this.runCommands(this.negotiator.markRemoteApplied());
|
|
551
|
+
this.onNegotiated();
|
|
552
|
+
break;
|
|
553
|
+
case 'add-candidate':
|
|
554
|
+
try {
|
|
555
|
+
await this.pc.addIceCandidate(command.candidate);
|
|
556
|
+
} catch (error) {
|
|
557
|
+
// A candidate from a superseded ICE session; harmless.
|
|
558
|
+
this.log('addIceCandidate ignored', error);
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
case 'remote-end':
|
|
562
|
+
// Handled synchronously in receive(); never queued.
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
async applyOffer(command) {
|
|
568
|
+
const pc = this.pc;
|
|
569
|
+
if (!pc) return;
|
|
570
|
+
if (command.rollback && pc.signalingState === 'have-local-offer') {
|
|
571
|
+
await pc.setLocalDescription({
|
|
572
|
+
type: 'rollback'
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
await pc.setRemoteDescription({
|
|
576
|
+
type: 'offer',
|
|
577
|
+
sdp: command.sdp
|
|
578
|
+
});
|
|
579
|
+
await this.runCommands(this.negotiator.markRemoteApplied());
|
|
580
|
+
if (this.disposed || !this.pc) return;
|
|
581
|
+
this.candidateGateOpen = false;
|
|
582
|
+
const answer = await pc.createAnswer();
|
|
583
|
+
await pc.setLocalDescription(answer);
|
|
584
|
+
if (this.disposed) return;
|
|
585
|
+
this.deps.sendSignal('answer', {
|
|
586
|
+
type: 'answer',
|
|
587
|
+
sdp: pc.localDescription?.sdp || answer.sdp || ''
|
|
588
|
+
});
|
|
589
|
+
this.openCandidateGate();
|
|
590
|
+
if (command.initial) this.onNegotiated();
|
|
591
|
+
}
|
|
592
|
+
onNegotiated() {
|
|
593
|
+
if (this.negotiated || this.disposed) return;
|
|
594
|
+
this.negotiated = true;
|
|
595
|
+
if (!this.connectedOnce) {
|
|
596
|
+
this.update({
|
|
597
|
+
status: 'connecting'
|
|
598
|
+
});
|
|
599
|
+
this.connectTimer = this.later(() => {
|
|
600
|
+
if (!this.connectedOnce) {
|
|
601
|
+
this.fail('Could not connect the call', 'connect-timeout');
|
|
602
|
+
}
|
|
603
|
+
}, this.timings.connectTimeoutMs);
|
|
604
|
+
}
|
|
605
|
+
this.events.onNegotiated?.();
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// ---- connection health --------------------------------------------------
|
|
609
|
+
|
|
610
|
+
connState() {
|
|
611
|
+
const pc = this.pc;
|
|
612
|
+
if (!pc) return 'closed';
|
|
613
|
+
const cs = pc.connectionState;
|
|
614
|
+
if (cs) return cs;
|
|
615
|
+
// Browsers without connectionState: map the ICE state.
|
|
616
|
+
switch (pc.iceConnectionState) {
|
|
617
|
+
case 'connected':
|
|
618
|
+
case 'completed':
|
|
619
|
+
return 'connected';
|
|
620
|
+
case 'disconnected':
|
|
621
|
+
return 'disconnected';
|
|
622
|
+
case 'failed':
|
|
623
|
+
return 'failed';
|
|
624
|
+
case 'closed':
|
|
625
|
+
return 'closed';
|
|
626
|
+
case 'checking':
|
|
627
|
+
return 'connecting';
|
|
628
|
+
default:
|
|
629
|
+
return 'new';
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
onConnectionState() {
|
|
633
|
+
if (this.disposed) return;
|
|
634
|
+
const state = this.connState();
|
|
635
|
+
if (state === this.lastConn) return;
|
|
636
|
+
this.lastConn = state;
|
|
637
|
+
this.log(`connection ${state}`);
|
|
638
|
+
if (state === 'connected') {
|
|
639
|
+
this.cancel(this.graceTimer);
|
|
640
|
+
this.cancel(this.deadlineTimer);
|
|
641
|
+
this.cancel(this.connectTimer);
|
|
642
|
+
this.graceTimer = this.deadlineTimer = this.connectTimer = null;
|
|
643
|
+
this.runIceAction(this.policy.onState(state));
|
|
644
|
+
this.update({
|
|
645
|
+
status: 'connected'
|
|
646
|
+
});
|
|
647
|
+
if (!this.connectedOnce) {
|
|
648
|
+
this.connectedOnce = true;
|
|
649
|
+
this.events.onConnected?.();
|
|
650
|
+
}
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
if (state === 'connecting') {
|
|
654
|
+
if (this.connectedOnce) this.update({
|
|
655
|
+
status: 'reconnecting'
|
|
656
|
+
});
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (state === 'disconnected' || state === 'failed') {
|
|
660
|
+
if (this.connectedOnce) this.update({
|
|
661
|
+
status: 'reconnecting'
|
|
662
|
+
});
|
|
663
|
+
this.runIceAction(this.policy.onState(state));
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
runIceAction(action) {
|
|
667
|
+
switch (action.type) {
|
|
668
|
+
case 'wait':
|
|
669
|
+
this.cancel(this.graceTimer);
|
|
670
|
+
this.graceTimer = this.later(() => {
|
|
671
|
+
this.graceTimer = null;
|
|
672
|
+
this.runIceAction(this.policy.onGraceElapsed());
|
|
673
|
+
}, action.ms);
|
|
674
|
+
break;
|
|
675
|
+
case 'restart':
|
|
676
|
+
this.cancel(this.graceTimer);
|
|
677
|
+
this.graceTimer = null;
|
|
678
|
+
this.cancel(this.deadlineTimer);
|
|
679
|
+
this.deadlineTimer = this.later(() => {
|
|
680
|
+
this.deadlineTimer = null;
|
|
681
|
+
const down = this.lastConn !== 'connected';
|
|
682
|
+
this.runIceAction(this.policy.onRestartDeadline(down));
|
|
683
|
+
}, action.deadlineMs);
|
|
684
|
+
this.enqueue(() => this.restartIce());
|
|
685
|
+
break;
|
|
686
|
+
case 'give-up':
|
|
687
|
+
this.fail('Connection lost', 'connection-failed');
|
|
688
|
+
break;
|
|
689
|
+
case 'recovered':
|
|
690
|
+
case 'none':
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** ICE restart with fresh TURN credentials; the caller of this is the policy. */
|
|
696
|
+
async restartIce() {
|
|
697
|
+
const pc = this.pc;
|
|
698
|
+
if (!pc || this.disposed) return;
|
|
699
|
+
let fresh = null;
|
|
700
|
+
try {
|
|
701
|
+
fresh = await this.deps.fetchIceServers();
|
|
702
|
+
} catch {
|
|
703
|
+
fresh = null;
|
|
704
|
+
}
|
|
705
|
+
if (this.disposed || !this.pc) return;
|
|
706
|
+
if (fresh && fresh.length > 0) {
|
|
707
|
+
try {
|
|
708
|
+
pc.setConfiguration({
|
|
709
|
+
...pc.getConfiguration(),
|
|
710
|
+
iceServers: fresh
|
|
711
|
+
});
|
|
712
|
+
} catch (error) {
|
|
713
|
+
this.log('setConfiguration failed', error);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
// A negotiation is already in flight (e.g. the peer is restarting too);
|
|
717
|
+
// the restart deadline still guards the outcome.
|
|
718
|
+
if (pc.signalingState !== 'stable') return;
|
|
719
|
+
if (typeof pc.restartIce === 'function') pc.restartIce();
|
|
720
|
+
await this.sendOffer(true);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
exports.P2PCallController = P2PCallController;
|
|
724
|
+
//# sourceMappingURL=P2PCallController.js.map
|