mediasfu-shared 1.0.6 → 1.1.0
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/HEADLESS_GUIDE.md +156 -0
- package/README.md +113 -62
- package/dist/ProducerClient/producerClientEmits/createDeviceClient.d.ts +23 -0
- package/dist/ProducerClient/producerClientEmits/createDeviceClient.d.ts.map +1 -0
- package/dist/ProducerClient/producerClientEmits/joinRoomClient.d.ts +22 -0
- package/dist/ProducerClient/producerClientEmits/joinRoomClient.d.ts.map +1 -0
- package/dist/ProducerClient/producerClientEmits/updateRoomParametersClient.d.ts +85 -0
- package/dist/ProducerClient/producerClientEmits/updateRoomParametersClient.d.ts.map +1 -0
- package/dist/consumers/addVideosGrid.d.ts +10 -0
- package/dist/consumers/addVideosGrid.d.ts.map +1 -0
- package/dist/consumers/autoAdjust.d.ts +41 -0
- package/dist/consumers/autoAdjust.d.ts.map +1 -0
- package/dist/consumers/calculateRowsAndColumns.d.ts +24 -0
- package/dist/consumers/calculateRowsAndColumns.d.ts.map +1 -0
- package/dist/consumers/changeVids.d.ts +252 -0
- package/dist/consumers/changeVids.d.ts.map +1 -0
- package/dist/consumers/checkGrid.d.ts +42 -0
- package/dist/consumers/checkGrid.d.ts.map +1 -0
- package/dist/consumers/checkPermission.d.ts +42 -0
- package/dist/consumers/checkPermission.d.ts.map +1 -0
- package/dist/consumers/checkScreenShare.d.ts +59 -0
- package/dist/consumers/checkScreenShare.d.ts.map +1 -0
- package/dist/consumers/closeAndResize.d.ts +157 -0
- package/dist/consumers/closeAndResize.d.ts.map +1 -0
- package/dist/consumers/compareActiveNames.d.ts +50 -0
- package/dist/consumers/compareActiveNames.d.ts.map +1 -0
- package/dist/consumers/compareScreenStates.d.ts +55 -0
- package/dist/consumers/compareScreenStates.d.ts.map +1 -0
- package/dist/consumers/connectIps.d.ts +66 -0
- package/dist/consumers/connectIps.d.ts.map +1 -0
- package/dist/consumers/connectLocalIps.d.ts +52 -0
- package/dist/consumers/connectLocalIps.d.ts.map +1 -0
- package/dist/consumers/connectRecvTransport.d.ts +64 -0
- package/dist/consumers/connectRecvTransport.d.ts.map +1 -0
- package/dist/consumers/connectSendTransport.d.ts +75 -0
- package/dist/consumers/connectSendTransport.d.ts.map +1 -0
- package/dist/consumers/connectSendTransportAudio.d.ts +62 -0
- package/dist/consumers/connectSendTransportAudio.d.ts.map +1 -0
- package/dist/consumers/connectSendTransportScreen.d.ts +72 -0
- package/dist/consumers/connectSendTransportScreen.d.ts.map +1 -0
- package/dist/consumers/connectSendTransportVideo.d.ts +75 -0
- package/dist/consumers/connectSendTransportVideo.d.ts.map +1 -0
- package/dist/consumers/consumerResume.d.ts +16 -0
- package/dist/consumers/consumerResume.d.ts.map +1 -0
- package/dist/consumers/controlMedia.d.ts +61 -0
- package/dist/consumers/controlMedia.d.ts.map +1 -0
- package/dist/consumers/createSendTransport.d.ts +80 -0
- package/dist/consumers/createSendTransport.d.ts.map +1 -0
- package/dist/consumers/disconnectSendTransportAudio.d.ts +79 -0
- package/dist/consumers/disconnectSendTransportAudio.d.ts.map +1 -0
- package/dist/consumers/disconnectSendTransportScreen.d.ts +61 -0
- package/dist/consumers/disconnectSendTransportScreen.d.ts.map +1 -0
- package/dist/consumers/disconnectSendTransportVideo.d.ts +72 -0
- package/dist/consumers/disconnectSendTransportVideo.d.ts.map +1 -0
- package/dist/consumers/dispStreams.d.ts +189 -0
- package/dist/consumers/dispStreams.d.ts.map +1 -0
- package/dist/consumers/frameworkConsumerContract.d.ts +2 -0
- package/dist/consumers/frameworkConsumerContract.d.ts.map +1 -0
- package/dist/consumers/generatePageContent.d.ts +68 -0
- package/dist/consumers/generatePageContent.d.ts.map +1 -0
- package/dist/consumers/getEstimate.d.ts +62 -0
- package/dist/consumers/getEstimate.d.ts.map +1 -0
- package/dist/consumers/getPipedProducersAlt.d.ts +62 -0
- package/dist/consumers/getPipedProducersAlt.d.ts.map +1 -0
- package/dist/consumers/getProducersPiped.d.ts +49 -0
- package/dist/consumers/getProducersPiped.d.ts.map +1 -0
- package/dist/consumers/getVideos.d.ts +49 -0
- package/dist/consumers/getVideos.d.ts.map +1 -0
- package/dist/consumers/gridLayout/addVideosGrid.engine.d.ts +19 -0
- package/dist/consumers/gridLayout/addVideosGrid.engine.d.ts.map +1 -0
- package/dist/consumers/gridLayout/prepopulateUserMedia.engine.d.ts +138 -0
- package/dist/consumers/gridLayout/prepopulateUserMedia.engine.d.ts.map +1 -0
- package/dist/consumers/mixStreams.d.ts +37 -0
- package/dist/consumers/mixStreams.d.ts.map +1 -0
- package/dist/consumers/onScreenChanges.d.ts +62 -0
- package/dist/consumers/onScreenChanges.d.ts.map +1 -0
- package/dist/consumers/prepopulateUserMedia.d.ts +10 -0
- package/dist/consumers/prepopulateUserMedia.d.ts.map +1 -0
- package/dist/consumers/processConsumerTransports.d.ts +73 -0
- package/dist/consumers/processConsumerTransports.d.ts.map +1 -0
- package/dist/consumers/processConsumerTransportsAudio.d.ts +57 -0
- package/dist/consumers/processConsumerTransportsAudio.d.ts.map +1 -0
- package/dist/consumers/rePort.d.ts +63 -0
- package/dist/consumers/rePort.d.ts.map +1 -0
- package/dist/consumers/reUpdateInter.d.ts +142 -0
- package/dist/consumers/reUpdateInter.d.ts.map +1 -0
- package/dist/consumers/readjust.d.ts +68 -0
- package/dist/consumers/readjust.d.ts.map +1 -0
- package/dist/consumers/receiveAllPipedTransports.d.ts +44 -0
- package/dist/consumers/receiveAllPipedTransports.d.ts.map +1 -0
- package/dist/consumers/receiveRoomMessages.d.ts +31 -0
- package/dist/consumers/receiveRoomMessages.d.ts.map +1 -0
- package/dist/consumers/reorderStreams.d.ts +98 -0
- package/dist/consumers/reorderStreams.d.ts.map +1 -0
- package/dist/consumers/requestScreenShare.d.ts +47 -0
- package/dist/consumers/requestScreenShare.d.ts.map +1 -0
- package/dist/consumers/resumePauseAudioStreams.d.ts +85 -0
- package/dist/consumers/resumePauseAudioStreams.d.ts.map +1 -0
- package/dist/consumers/resumePauseStreams.d.ts +68 -0
- package/dist/consumers/resumePauseStreams.d.ts.map +1 -0
- package/dist/consumers/resumeSendTransportAudio.d.ts +65 -0
- package/dist/consumers/resumeSendTransportAudio.d.ts.map +1 -0
- package/dist/consumers/signalNewConsumerTransport.d.ts +59 -0
- package/dist/consumers/signalNewConsumerTransport.d.ts.map +1 -0
- package/dist/consumers/socketReceiveMethods/joinConsumeRoom.d.ts +76 -0
- package/dist/consumers/socketReceiveMethods/joinConsumeRoom.d.ts.map +1 -0
- package/dist/consumers/socketReceiveMethods/newPipeProducer.d.ts +119 -0
- package/dist/consumers/socketReceiveMethods/newPipeProducer.d.ts.map +1 -0
- package/dist/consumers/socketReceiveMethods/producerClosed.d.ts +53 -0
- package/dist/consumers/socketReceiveMethods/producerClosed.d.ts.map +1 -0
- package/dist/consumers/startShareScreen.d.ts +58 -0
- package/dist/consumers/startShareScreen.d.ts.map +1 -0
- package/dist/consumers/stopShareScreen.d.ts +127 -0
- package/dist/consumers/stopShareScreen.d.ts.map +1 -0
- package/dist/consumers/streamSuccessAudio.d.ts +149 -0
- package/dist/consumers/streamSuccessAudio.d.ts.map +1 -0
- package/dist/consumers/streamSuccessAudioSwitch.d.ts +131 -0
- package/dist/consumers/streamSuccessAudioSwitch.d.ts.map +1 -0
- package/dist/consumers/streamSuccessScreen.d.ts +109 -0
- package/dist/consumers/streamSuccessScreen.d.ts.map +1 -0
- package/dist/consumers/streamSuccessVideo.d.ts +160 -0
- package/dist/consumers/streamSuccessVideo.d.ts.map +1 -0
- package/dist/consumers/switchUserAudio.d.ts +56 -0
- package/dist/consumers/switchUserAudio.d.ts.map +1 -0
- package/dist/consumers/switchUserVideo.d.ts +77 -0
- package/dist/consumers/switchUserVideo.d.ts.map +1 -0
- package/dist/consumers/switchUserVideoAlt.d.ts +69 -0
- package/dist/consumers/switchUserVideoAlt.d.ts.map +1 -0
- package/dist/consumers/translationConsumerSwitch.d.ts +67 -0
- package/dist/consumers/translationConsumerSwitch.d.ts.map +1 -0
- package/dist/consumers/trigger.d.ts +71 -0
- package/dist/consumers/trigger.d.ts.map +1 -0
- package/dist/consumers/updateMiniCardsGrid.d.ts +65 -0
- package/dist/consumers/updateMiniCardsGrid.d.ts.map +1 -0
- package/dist/consumers/updateParticipantAudioDecibels.d.ts +31 -0
- package/dist/consumers/updateParticipantAudioDecibels.d.ts.map +1 -0
- package/dist/getParticipantMedia-D9ChmEqq.js +15265 -0
- package/dist/getParticipantMedia-D9ChmEqq.js.map +1 -0
- package/dist/getParticipantMedia-DWvIhPPY.cjs +15281 -0
- package/dist/getParticipantMedia-DWvIhPPY.cjs.map +1 -0
- package/dist/index.cjs +2677 -13249
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +191 -11233
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2668 -13222
- package/dist/index.js.map +1 -1
- package/dist/index.native.cjs +346 -0
- package/dist/index.native.cjs.map +1 -0
- package/dist/index.native.d.ts +204 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/index.native.js +346 -0
- package/dist/index.native.js.map +1 -0
- package/dist/methods/background/launchBackground.d.ts +10 -0
- package/dist/methods/background/launchBackground.d.ts.map +1 -0
- package/dist/methods/breakoutRooms/breakoutRoomUpdated.d.ts +67 -0
- package/dist/methods/breakoutRooms/breakoutRoomUpdated.d.ts.map +1 -0
- package/dist/methods/breakoutRooms/handleStartBreakout.d.ts +42 -0
- package/dist/methods/breakoutRooms/handleStartBreakout.d.ts.map +1 -0
- package/dist/methods/breakoutRooms/handleStopBreakout.d.ts +33 -0
- package/dist/methods/breakoutRooms/handleStopBreakout.d.ts.map +1 -0
- package/dist/methods/breakoutRooms/index.d.ts +5 -0
- package/dist/methods/breakoutRooms/index.d.ts.map +1 -0
- package/dist/methods/breakoutRooms/launchBreakoutRooms.d.ts +25 -0
- package/dist/methods/breakoutRooms/launchBreakoutRooms.d.ts.map +1 -0
- package/dist/methods/coHost/launchCoHost.d.ts +25 -0
- package/dist/methods/coHost/launchCoHost.d.ts.map +1 -0
- package/dist/methods/coHostMethods/index.d.ts +3 -0
- package/dist/methods/coHostMethods/index.d.ts.map +1 -0
- package/dist/methods/coHostMethods/modifyCoHostSettings.d.ts +49 -0
- package/dist/methods/coHostMethods/modifyCoHostSettings.d.ts.map +1 -0
- package/dist/methods/displaySettings/index.d.ts +2 -0
- package/dist/methods/displaySettings/index.d.ts.map +1 -0
- package/dist/methods/displaySettings/launchDisplaySettings.d.ts +25 -0
- package/dist/methods/displaySettings/launchDisplaySettings.d.ts.map +1 -0
- package/dist/methods/displaySettings/modifyDisplaySettings.d.ts +106 -0
- package/dist/methods/displaySettings/modifyDisplaySettings.d.ts.map +1 -0
- package/dist/methods/exit/confirmExit.d.ts +38 -0
- package/dist/methods/exit/confirmExit.d.ts.map +1 -0
- package/dist/methods/exit/index.d.ts +3 -0
- package/dist/methods/exit/index.d.ts.map +1 -0
- package/dist/methods/exit/launchConfirmExit.d.ts +23 -0
- package/dist/methods/exit/launchConfirmExit.d.ts.map +1 -0
- package/dist/methods/index.d.ts +66 -0
- package/dist/methods/index.d.ts.map +1 -0
- package/dist/methods/mediaSettings/launchMediaSettings.d.ts +38 -0
- package/dist/methods/mediaSettings/launchMediaSettings.d.ts.map +1 -0
- package/dist/methods/menu/launchMenuModal.d.ts +22 -0
- package/dist/methods/menu/launchMenuModal.d.ts.map +1 -0
- package/dist/methods/message/index.d.ts +2 -0
- package/dist/methods/message/index.d.ts.map +1 -0
- package/dist/methods/message/launchMessages.d.ts +24 -0
- package/dist/methods/message/launchMessages.d.ts.map +1 -0
- package/dist/methods/message/sendMessage.d.ts +63 -0
- package/dist/methods/message/sendMessage.d.ts.map +1 -0
- package/dist/methods/panelists/focusPanelists.d.ts +24 -0
- package/dist/methods/panelists/focusPanelists.d.ts.map +1 -0
- package/dist/methods/panelists/index.d.ts +4 -0
- package/dist/methods/panelists/index.d.ts.map +1 -0
- package/dist/methods/panelists/launchPanelists.d.ts +7 -0
- package/dist/methods/panelists/launchPanelists.d.ts.map +1 -0
- package/dist/methods/panelists/updatePanelists.d.ts +35 -0
- package/dist/methods/panelists/updatePanelists.d.ts.map +1 -0
- package/dist/methods/participants/index.d.ts +4 -0
- package/dist/methods/participants/index.d.ts.map +1 -0
- package/dist/methods/participants/launchParticipants.d.ts +22 -0
- package/dist/methods/participants/launchParticipants.d.ts.map +1 -0
- package/dist/methods/participants/messageParticipants.d.ts +43 -0
- package/dist/methods/participants/messageParticipants.d.ts.map +1 -0
- package/dist/methods/participants/muteParticipants.d.ts +41 -0
- package/dist/methods/participants/muteParticipants.d.ts.map +1 -0
- package/dist/methods/participants/removeParticipants.d.ts +47 -0
- package/dist/methods/participants/removeParticipants.d.ts.map +1 -0
- package/dist/methods/permissions/index.d.ts +4 -0
- package/dist/methods/permissions/index.d.ts.map +1 -0
- package/dist/methods/permissions/launchPermissions.d.ts +7 -0
- package/dist/methods/permissions/launchPermissions.d.ts.map +1 -0
- package/dist/methods/permissions/updateParticipantPermission.d.ts +25 -0
- package/dist/methods/permissions/updateParticipantPermission.d.ts.map +1 -0
- package/dist/methods/permissions/updatePermissionConfig.d.ts +22 -0
- package/dist/methods/permissions/updatePermissionConfig.d.ts.map +1 -0
- package/dist/methods/polls/handleCreatePoll.d.ts +39 -0
- package/dist/methods/polls/handleCreatePoll.d.ts.map +1 -0
- package/dist/methods/polls/handleEndPoll.d.ts +34 -0
- package/dist/methods/polls/handleEndPoll.d.ts.map +1 -0
- package/dist/methods/polls/handleVotePoll.d.ts +39 -0
- package/dist/methods/polls/handleVotePoll.d.ts.map +1 -0
- package/dist/methods/polls/index.d.ts +4 -0
- package/dist/methods/polls/index.d.ts.map +1 -0
- package/dist/methods/polls/launchPoll.d.ts +22 -0
- package/dist/methods/polls/launchPoll.d.ts.map +1 -0
- package/dist/methods/polls/pollUpdated.d.ts +38 -0
- package/dist/methods/polls/pollUpdated.d.ts.map +1 -0
- package/dist/methods/prejoin/handleCreateRoom.d.ts +77 -0
- package/dist/methods/prejoin/handleCreateRoom.d.ts.map +1 -0
- package/dist/methods/prejoin/handleJoinRoom.d.ts +56 -0
- package/dist/methods/prejoin/handleJoinRoom.d.ts.map +1 -0
- package/dist/methods/prejoin/index.d.ts +5 -0
- package/dist/methods/prejoin/index.d.ts.map +1 -0
- package/dist/methods/recording/checkPauseState.d.ts +34 -0
- package/dist/methods/recording/checkPauseState.d.ts.map +1 -0
- package/dist/methods/recording/checkResumeState.d.ts +30 -0
- package/dist/methods/recording/checkResumeState.d.ts.map +1 -0
- package/dist/methods/recording/confirmRecording.d.ts +46 -0
- package/dist/methods/recording/confirmRecording.d.ts.map +1 -0
- package/dist/methods/recording/launchRecording.d.ts +56 -0
- package/dist/methods/recording/launchRecording.d.ts.map +1 -0
- package/dist/methods/recording/recordPauseTimer.d.ts +31 -0
- package/dist/methods/recording/recordPauseTimer.d.ts.map +1 -0
- package/dist/methods/recording/recordResumeTimer.d.ts +29 -0
- package/dist/methods/recording/recordResumeTimer.d.ts.map +1 -0
- package/dist/methods/recording/recordStartTimer.d.ts +45 -0
- package/dist/methods/recording/recordStartTimer.d.ts.map +1 -0
- package/dist/methods/recording/recordUpdateTimer.d.ts +29 -0
- package/dist/methods/recording/recordUpdateTimer.d.ts.map +1 -0
- package/dist/methods/recording/startRecording.d.ts +122 -0
- package/dist/methods/recording/startRecording.d.ts.map +1 -0
- package/dist/methods/recording/stopRecording.d.ts +36 -0
- package/dist/methods/recording/stopRecording.d.ts.map +1 -0
- package/dist/methods/recording/timeLeftRecording.d.ts +13 -0
- package/dist/methods/recording/timeLeftRecording.d.ts.map +1 -0
- package/dist/methods/recording/updateRecording.d.ts +49 -0
- package/dist/methods/recording/updateRecording.d.ts.map +1 -0
- package/dist/methods/requests/hostRequestResponse.d.ts +33 -0
- package/dist/methods/requests/hostRequestResponse.d.ts.map +1 -0
- package/dist/methods/requests/index.d.ts +2 -0
- package/dist/methods/requests/index.d.ts.map +1 -0
- package/dist/methods/requests/launchRequests.d.ts +22 -0
- package/dist/methods/requests/launchRequests.d.ts.map +1 -0
- package/dist/methods/requests/respondToRequests.d.ts +38 -0
- package/dist/methods/requests/respondToRequests.d.ts.map +1 -0
- package/dist/methods/settings/index.d.ts +3 -0
- package/dist/methods/settings/index.d.ts.map +1 -0
- package/dist/methods/settings/launchSettings.d.ts +22 -0
- package/dist/methods/settings/launchSettings.d.ts.map +1 -0
- package/dist/methods/settings/modifySettings.d.ts +45 -0
- package/dist/methods/settings/modifySettings.d.ts.map +1 -0
- package/dist/methods/socketReceive/allMembers.d.ts +117 -0
- package/dist/methods/socketReceive/allMembers.d.ts.map +1 -0
- package/dist/methods/socketReceive/allMembersRest.d.ts +122 -0
- package/dist/methods/socketReceive/allMembersRest.d.ts.map +1 -0
- package/dist/methods/socketReceive/allWaitingRoomMembers.d.ts +24 -0
- package/dist/methods/socketReceive/allWaitingRoomMembers.d.ts.map +1 -0
- package/dist/methods/socketReceive/banParticipant.d.ts +44 -0
- package/dist/methods/socketReceive/banParticipant.d.ts.map +1 -0
- package/dist/methods/socketReceive/controlMediaHost.d.ts +62 -0
- package/dist/methods/socketReceive/controlMediaHost.d.ts.map +1 -0
- package/dist/methods/socketReceive/disconnect.d.ts +24 -0
- package/dist/methods/socketReceive/disconnect.d.ts.map +1 -0
- package/dist/methods/socketReceive/disconnectUserSelf.d.ts +29 -0
- package/dist/methods/socketReceive/disconnectUserSelf.d.ts.map +1 -0
- package/dist/methods/socketReceive/getDomains.d.ts +48 -0
- package/dist/methods/socketReceive/getDomains.d.ts.map +1 -0
- package/dist/methods/socketReceive/meetingEnded.d.ts +27 -0
- package/dist/methods/socketReceive/meetingEnded.d.ts.map +1 -0
- package/dist/methods/socketReceive/meetingStillThere.d.ts +19 -0
- package/dist/methods/socketReceive/meetingStillThere.d.ts.map +1 -0
- package/dist/methods/socketReceive/panelistReceiveMethods.d.ts +66 -0
- package/dist/methods/socketReceive/panelistReceiveMethods.d.ts.map +1 -0
- package/dist/methods/socketReceive/participantRequested.d.ts +28 -0
- package/dist/methods/socketReceive/participantRequested.d.ts.map +1 -0
- package/dist/methods/socketReceive/permissionReceiveMethods.d.ts +23 -0
- package/dist/methods/socketReceive/permissionReceiveMethods.d.ts.map +1 -0
- package/dist/methods/socketReceive/personJoined.d.ts +24 -0
- package/dist/methods/socketReceive/personJoined.d.ts.map +1 -0
- package/dist/methods/socketReceive/producerMediaClosed.d.ts +66 -0
- package/dist/methods/socketReceive/producerMediaClosed.d.ts.map +1 -0
- package/dist/methods/socketReceive/producerMediaPaused.d.ts +70 -0
- package/dist/methods/socketReceive/producerMediaPaused.d.ts.map +1 -0
- package/dist/methods/socketReceive/producerMediaResumed.d.ts +53 -0
- package/dist/methods/socketReceive/producerMediaResumed.d.ts.map +1 -0
- package/dist/methods/socketReceive/reInitiateRecording.d.ts +33 -0
- package/dist/methods/socketReceive/reInitiateRecording.d.ts.map +1 -0
- package/dist/methods/socketReceive/receiveMessage.d.ts +36 -0
- package/dist/methods/socketReceive/receiveMessage.d.ts.map +1 -0
- package/dist/methods/socketReceive/recordingNotice.d.ts +98 -0
- package/dist/methods/socketReceive/recordingNotice.d.ts.map +1 -0
- package/dist/methods/socketReceive/roomRecordParams.d.ts +60 -0
- package/dist/methods/socketReceive/roomRecordParams.d.ts.map +1 -0
- package/dist/methods/socketReceive/screenProducerId.d.ts +36 -0
- package/dist/methods/socketReceive/screenProducerId.d.ts.map +1 -0
- package/dist/methods/socketReceive/startRecords.d.ts +31 -0
- package/dist/methods/socketReceive/startRecords.d.ts.map +1 -0
- package/dist/methods/socketReceive/stoppedRecording.d.ts +24 -0
- package/dist/methods/socketReceive/stoppedRecording.d.ts.map +1 -0
- package/dist/methods/socketReceive/translationReceiveMethods.d.ts +227 -0
- package/dist/methods/socketReceive/translationReceiveMethods.d.ts.map +1 -0
- package/dist/methods/socketReceive/updateConsumingDomains.d.ts +60 -0
- package/dist/methods/socketReceive/updateConsumingDomains.d.ts.map +1 -0
- package/dist/methods/socketReceive/updateMediaSettings.d.ts +28 -0
- package/dist/methods/socketReceive/updateMediaSettings.d.ts.map +1 -0
- package/dist/methods/socketReceive/updatedCoHost.d.ts +38 -0
- package/dist/methods/socketReceive/updatedCoHost.d.ts.map +1 -0
- package/dist/methods/socketReceive/userWaiting.d.ts +30 -0
- package/dist/methods/socketReceive/userWaiting.d.ts.map +1 -0
- package/dist/methods/stream/clickAudio.d.ts +71 -0
- package/dist/methods/stream/clickAudio.d.ts.map +1 -0
- package/dist/methods/stream/clickChat.d.ts +11 -0
- package/dist/methods/stream/clickChat.d.ts.map +1 -0
- package/dist/methods/stream/clickScreenShare.d.ts +45 -0
- package/dist/methods/stream/clickScreenShare.d.ts.map +1 -0
- package/dist/methods/stream/clickVideo.d.ts +101 -0
- package/dist/methods/stream/clickVideo.d.ts.map +1 -0
- package/dist/methods/stream/index.d.ts +5 -0
- package/dist/methods/stream/index.d.ts.map +1 -0
- package/dist/methods/stream/switchAudio.d.ts +40 -0
- package/dist/methods/stream/switchAudio.d.ts.map +1 -0
- package/dist/methods/stream/switchVideo.d.ts +56 -0
- package/dist/methods/stream/switchVideo.d.ts.map +1 -0
- package/dist/methods/stream/switchVideoAlt.d.ts +55 -0
- package/dist/methods/stream/switchVideoAlt.d.ts.map +1 -0
- package/dist/methods/utils/SoundPlayer.d.ts +19 -0
- package/dist/methods/utils/SoundPlayer.d.ts.map +1 -0
- package/dist/methods/utils/checkLimitsAndMakeRequest.d.ts +30 -0
- package/dist/methods/utils/checkLimitsAndMakeRequest.d.ts.map +1 -0
- package/dist/methods/utils/createResponseJoinRoom.d.ts +24 -0
- package/dist/methods/utils/createResponseJoinRoom.d.ts.map +1 -0
- package/dist/methods/utils/createRoomOnMediaSFU.d.ts +28 -0
- package/dist/methods/utils/createRoomOnMediaSFU.d.ts.map +1 -0
- package/dist/methods/utils/formatNumber.d.ts +21 -0
- package/dist/methods/utils/formatNumber.d.ts.map +1 -0
- package/dist/methods/utils/generateRandomMessages.d.ts +11 -0
- package/dist/methods/utils/generateRandomMessages.d.ts.map +1 -0
- package/dist/methods/utils/generateRandomParticipants.d.ts +10 -0
- package/dist/methods/utils/generateRandomParticipants.d.ts.map +1 -0
- package/dist/methods/utils/generateRandomPolls.d.ts +7 -0
- package/dist/methods/utils/generateRandomPolls.d.ts.map +1 -0
- package/dist/methods/utils/generateRandomRequestList.d.ts +10 -0
- package/dist/methods/utils/generateRandomRequestList.d.ts.map +1 -0
- package/dist/methods/utils/generateRandomWaitingRoomList.d.ts +4 -0
- package/dist/methods/utils/generateRandomWaitingRoomList.d.ts.map +1 -0
- package/dist/methods/utils/getModalPosition.d.ts +7 -0
- package/dist/methods/utils/getModalPosition.d.ts.map +1 -0
- package/dist/methods/utils/getOverlayPosition.d.ts +22 -0
- package/dist/methods/utils/getOverlayPosition.d.ts.map +1 -0
- package/dist/methods/utils/getParticipantMedia.d.ts +55 -0
- package/dist/methods/utils/getParticipantMedia.d.ts.map +1 -0
- package/dist/methods/utils/headless/getCurrentParams.d.ts +27 -0
- package/dist/methods/utils/headless/getCurrentParams.d.ts.map +1 -0
- package/dist/methods/utils/headless/getMediaStreams.d.ts +96 -0
- package/dist/methods/utils/headless/getMediaStreams.d.ts.map +1 -0
- package/dist/methods/utils/headless/getRoomReadiness.d.ts +25 -0
- package/dist/methods/utils/headless/getRoomReadiness.d.ts.map +1 -0
- package/dist/methods/utils/headless/headlessTypes.d.ts +89 -0
- package/dist/methods/utils/headless/headlessTypes.d.ts.map +1 -0
- package/dist/methods/utils/headless/index.d.ts +29 -0
- package/dist/methods/utils/headless/index.d.ts.map +1 -0
- package/dist/methods/utils/headless/mediaPermissions.d.ts +53 -0
- package/dist/methods/utils/headless/mediaPermissions.d.ts.map +1 -0
- package/dist/methods/utils/headless/mediaProduction.d.ts +177 -0
- package/dist/methods/utils/headless/mediaProduction.d.ts.map +1 -0
- package/dist/methods/utils/headless/moderation.d.ts +157 -0
- package/dist/methods/utils/headless/moderation.d.ts.map +1 -0
- package/dist/methods/utils/headless/participantState.d.ts +128 -0
- package/dist/methods/utils/headless/participantState.d.ts.map +1 -0
- package/dist/methods/utils/headless/playback.d.ts +106 -0
- package/dist/methods/utils/headless/playback.d.ts.map +1 -0
- package/dist/methods/utils/headless/roomActions.d.ts +88 -0
- package/dist/methods/utils/headless/roomActions.d.ts.map +1 -0
- package/dist/methods/utils/headless/sessionControls.d.ts +159 -0
- package/dist/methods/utils/headless/sessionControls.d.ts.map +1 -0
- package/dist/methods/utils/headless/sessionExtras.d.ts +291 -0
- package/dist/methods/utils/headless/sessionExtras.d.ts.map +1 -0
- package/dist/methods/utils/headless/sessionFeatures.d.ts +159 -0
- package/dist/methods/utils/headless/sessionFeatures.d.ts.map +1 -0
- package/dist/methods/utils/headless/viewerSession.d.ts +125 -0
- package/dist/methods/utils/headless/viewerSession.d.ts.map +1 -0
- package/dist/methods/utils/headless/virtualBackground.d.ts +72 -0
- package/dist/methods/utils/headless/virtualBackground.d.ts.map +1 -0
- package/dist/methods/utils/initialValuesState.d.ts +388 -0
- package/dist/methods/utils/initialValuesState.d.ts.map +1 -0
- package/dist/methods/utils/joinRoomOnMediaSFU.d.ts +56 -0
- package/dist/methods/utils/joinRoomOnMediaSFU.d.ts.map +1 -0
- package/dist/methods/utils/liveSubtitle.d.ts +36 -0
- package/dist/methods/utils/liveSubtitle.d.ts.map +1 -0
- package/dist/methods/utils/meetingTimeRemaining.d.ts +15 -0
- package/dist/methods/utils/meetingTimeRemaining.d.ts.map +1 -0
- package/dist/methods/utils/meetingTimer/startMeetingProgressTimer.d.ts +35 -0
- package/dist/methods/utils/meetingTimer/startMeetingProgressTimer.d.ts.map +1 -0
- package/dist/methods/utils/producer/aParams.d.ts +3 -0
- package/dist/methods/utils/producer/aParams.d.ts.map +1 -0
- package/dist/methods/utils/producer/hParams.d.ts +3 -0
- package/dist/methods/utils/producer/hParams.d.ts.map +1 -0
- package/dist/methods/utils/producer/screenParams.d.ts +3 -0
- package/dist/methods/utils/producer/screenParams.d.ts.map +1 -0
- package/dist/methods/utils/producer/vParams.d.ts +3 -0
- package/dist/methods/utils/producer/vParams.d.ts.map +1 -0
- package/dist/methods/utils/producer/videoCaptureConstraints.d.ts +145 -0
- package/dist/methods/utils/producer/videoCaptureConstraints.d.ts.map +1 -0
- package/dist/methods/utils/resolveMediaSFURoomApi.d.ts +4 -0
- package/dist/methods/utils/resolveMediaSFURoomApi.d.ts.map +1 -0
- package/dist/methods/utils/sleep.d.ts +21 -0
- package/dist/methods/utils/sleep.d.ts.map +1 -0
- package/dist/methods/utils/translationLanguages.d.ts +100 -0
- package/dist/methods/utils/translationLanguages.d.ts.map +1 -0
- package/dist/methods/utils/validateAlphanumeric.d.ts +21 -0
- package/dist/methods/utils/validateAlphanumeric.d.ts.map +1 -0
- package/dist/methods/utils/webrtc.d.ts +18 -0
- package/dist/methods/utils/webrtc.d.ts.map +1 -0
- package/dist/methods/waiting/index.d.ts +2 -0
- package/dist/methods/waiting/index.d.ts.map +1 -0
- package/dist/methods/waiting/launchWaiting.d.ts +23 -0
- package/dist/methods/waiting/launchWaiting.d.ts.map +1 -0
- package/dist/methods/waiting/respondToWaiting.d.ts +40 -0
- package/dist/methods/waiting/respondToWaiting.d.ts.map +1 -0
- package/dist/methods/welcome/handleWelcomeRequest.d.ts +47 -0
- package/dist/methods/welcome/handleWelcomeRequest.d.ts.map +1 -0
- package/dist/methods/welcome/index.d.ts +3 -0
- package/dist/methods/welcome/index.d.ts.map +1 -0
- package/dist/methods/whiteboard/captureCanvasStream.d.ts +38 -0
- package/dist/methods/whiteboard/captureCanvasStream.d.ts.map +1 -0
- package/dist/methods/whiteboard/handleStartWhiteboard.d.ts +31 -0
- package/dist/methods/whiteboard/handleStartWhiteboard.d.ts.map +1 -0
- package/dist/methods/whiteboard/handleStopWhiteboard.d.ts +25 -0
- package/dist/methods/whiteboard/handleStopWhiteboard.d.ts.map +1 -0
- package/dist/methods/whiteboard/index.d.ts +5 -0
- package/dist/methods/whiteboard/index.d.ts.map +1 -0
- package/dist/methods/whiteboard/launchConfigureWhiteboard.d.ts +23 -0
- package/dist/methods/whiteboard/launchConfigureWhiteboard.d.ts.map +1 -0
- package/dist/producers/producerEmits/joinConRoom.d.ts +54 -0
- package/dist/producers/producerEmits/joinConRoom.d.ts.map +1 -0
- package/dist/producers/producerEmits/joinLocalRoom.d.ts +30 -0
- package/dist/producers/producerEmits/joinLocalRoom.d.ts.map +1 -0
- package/dist/producers/producerEmits/joinRoom.d.ts +35 -0
- package/dist/producers/producerEmits/joinRoom.d.ts.map +1 -0
- package/dist/readme/mediasfu-platform-capabilities.webp +0 -0
- package/dist/sockets/SocketManager.d.ts +102 -0
- package/dist/sockets/SocketManager.d.ts.map +1 -0
- package/dist/types/shared-base-types.d.ts +656 -0
- package/dist/types/shared-base-types.d.ts.map +1 -0
- package/dist/types/types.d.ts +124 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +106 -99
- package/src/consumers/connectSendTransportScreen.ts +4 -1
- package/src/consumers/createSendTransport.ts +33 -28
- package/src/consumers/streamSuccessVideo.ts +34 -5
- package/src/index.native.ts +24 -1
- package/src/index.ts +5 -0
- package/src/methods/exit/confirmExit.ts +11 -4
- package/src/methods/utils/getParticipantMedia.ts +112 -0
- package/src/methods/utils/headless/getCurrentParams.ts +44 -0
- package/src/methods/utils/headless/getMediaStreams.ts +256 -0
- package/src/methods/utils/headless/getRoomReadiness.ts +49 -0
- package/src/methods/utils/headless/headlessTypes.ts +102 -0
- package/src/methods/utils/headless/index.ts +28 -0
- package/src/methods/utils/headless/mediaPermissions.ts +124 -0
- package/src/methods/utils/headless/mediaProduction.ts +505 -0
- package/src/methods/utils/headless/moderation.ts +455 -0
- package/src/methods/utils/headless/participantState.ts +254 -0
- package/src/methods/utils/headless/playback.ts +336 -0
- package/src/methods/utils/headless/roomActions.ts +230 -0
- package/src/methods/utils/headless/sessionControls.ts +335 -0
- package/src/methods/utils/headless/sessionExtras.ts +593 -0
- package/src/methods/utils/headless/sessionFeatures.ts +480 -0
- package/src/methods/utils/headless/viewerSession.ts +246 -0
- package/src/methods/utils/headless/virtualBackground.ts +265 -0
- package/src/methods/utils/resolveMediaSFURoomApi.ts +2 -2
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { Participant } from '../../../types/types';
|
|
2
|
+
import { removeParticipants } from '../../participants/removeParticipants';
|
|
3
|
+
import { respondToWaiting } from '../../waiting/respondToWaiting';
|
|
4
|
+
import { respondToRequests } from '../../requests/respondToRequests';
|
|
5
|
+
import { modifyCoHostSettings } from '../../coHostMethods/modifyCoHostSettings';
|
|
6
|
+
import { HeadlessOptions, HeadlessParameters } from './headlessTypes';
|
|
7
|
+
import { getCurrentParams } from './getCurrentParams';
|
|
8
|
+
import { HeadlessActionResult } from './roomActions';
|
|
9
|
+
|
|
10
|
+
/** The co-host responsibility keys MediaSFU recognises. */
|
|
11
|
+
export type ModerationArea = 'media' | 'participants' | 'chat' | 'waiting';
|
|
12
|
+
|
|
13
|
+
export interface ModerationPermissions {
|
|
14
|
+
/** True when the local user is the host (islevel '2'). */
|
|
15
|
+
isHost: boolean;
|
|
16
|
+
/** True when the local user is the room's co-host. */
|
|
17
|
+
isCoHost: boolean;
|
|
18
|
+
/** Turn other participants' camera/mic/screen off. */
|
|
19
|
+
canControlMedia: boolean;
|
|
20
|
+
/** Remove or ban participants. */
|
|
21
|
+
canManageParticipants: boolean;
|
|
22
|
+
/** Moderate chat. */
|
|
23
|
+
canManageChat: boolean;
|
|
24
|
+
/** Admit or deny people in the waiting room. */
|
|
25
|
+
canManageWaitingRoom: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type GetModerationPermissionsType = (
|
|
29
|
+
options: HeadlessOptions
|
|
30
|
+
) => ModerationPermissions;
|
|
31
|
+
|
|
32
|
+
function hasResponsibility(
|
|
33
|
+
parameters: HeadlessParameters,
|
|
34
|
+
area: ModerationArea
|
|
35
|
+
): boolean {
|
|
36
|
+
const list = Array.isArray(parameters?.coHostResponsibility)
|
|
37
|
+
? parameters.coHostResponsibility
|
|
38
|
+
: [];
|
|
39
|
+
return list.find((item: any) => item?.name === area)?.value === true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What the local user is allowed to moderate.
|
|
44
|
+
*
|
|
45
|
+
* MediaSFU's rule is `islevel === '2' || (coHost === member && <area>.value)`,
|
|
46
|
+
* and it is enforced *inside* each action — an unauthorised call is swallowed
|
|
47
|
+
* with an alert rather than returning an error. That makes it very easy to ship
|
|
48
|
+
* a moderation button that silently does nothing for co-hosts. Gate your UI on
|
|
49
|
+
* this instead.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { getModerationPermissions } from 'mediasfu-shared';
|
|
54
|
+
*
|
|
55
|
+
* const perms = getModerationPermissions({ parameters });
|
|
56
|
+
* <button disabled={!perms.canControlMedia}>Mute everyone</button>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function getModerationPermissions({
|
|
60
|
+
parameters,
|
|
61
|
+
}: HeadlessOptions): ModerationPermissions {
|
|
62
|
+
const source = parameters || {};
|
|
63
|
+
const isHost = String(source.islevel) === '2';
|
|
64
|
+
const isCoHost = Boolean(source.coHost && source.coHost === source.member);
|
|
65
|
+
const allow = (area: ModerationArea) =>
|
|
66
|
+
isHost || (isCoHost && hasResponsibility(source, area));
|
|
67
|
+
return {
|
|
68
|
+
isHost,
|
|
69
|
+
isCoHost,
|
|
70
|
+
canControlMedia: allow('media'),
|
|
71
|
+
canManageParticipants: allow('participants'),
|
|
72
|
+
canManageChat: allow('chat'),
|
|
73
|
+
canManageWaitingRoom: allow('waiting'),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function participantList(parameters: HeadlessParameters): Participant[] {
|
|
78
|
+
const source = parameters || {};
|
|
79
|
+
const primary = Array.isArray(source.participants) ? source.participants : [];
|
|
80
|
+
if (primary.length > 0) return primary;
|
|
81
|
+
return Array.isArray(source.participantsAll) ? source.participantsAll : [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function findParticipant(
|
|
85
|
+
parameters: HeadlessParameters,
|
|
86
|
+
{ id, name }: { id?: string; name?: string }
|
|
87
|
+
): Participant | null {
|
|
88
|
+
const participants = participantList(parameters);
|
|
89
|
+
return (
|
|
90
|
+
(id ? participants.find((part) => part.id === id) : undefined) ||
|
|
91
|
+
(name ? participants.find((part) => part.name === name) : undefined) ||
|
|
92
|
+
null
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface SetParticipantMediaOptions extends HeadlessOptions {
|
|
97
|
+
/** Participant display name. */
|
|
98
|
+
name?: string;
|
|
99
|
+
/** Participant id. Takes precedence over `name`. */
|
|
100
|
+
id?: string;
|
|
101
|
+
/** Which media to switch off. */
|
|
102
|
+
kind: 'audio' | 'video' | 'screenshare' | 'all';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type SetParticipantMediaType = (
|
|
106
|
+
options: SetParticipantMediaOptions
|
|
107
|
+
) => Promise<HeadlessActionResult>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Turn a participant's media off as host or authorised co-host.
|
|
111
|
+
*
|
|
112
|
+
* This is one-directional by design: MediaSFU lets a moderator *stop* someone's
|
|
113
|
+
* camera, microphone or screen share, but cannot start it on their behalf — the
|
|
114
|
+
* participant must re-enable it themselves.
|
|
115
|
+
*
|
|
116
|
+
* The SDK's own `controlMedia` consumer only emits for `type: 'audio'` and
|
|
117
|
+
* `type: 'video'`; `'all'` and `'screenshare'` fall through its guard and do
|
|
118
|
+
* nothing. This helper emits the `controlMedia` event directly with the same
|
|
119
|
+
* permission and self-protection checks applied uniformly, so every kind works.
|
|
120
|
+
* Hosts (`islevel === '2'`) cannot be muted by anyone, including other hosts.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { setParticipantMedia } from 'mediasfu-shared';
|
|
125
|
+
*
|
|
126
|
+
* await setParticipantMedia({ parameters, name: 'Paul', kind: 'video' });
|
|
127
|
+
* await setParticipantMedia({ parameters, name: 'Paul', kind: 'all' });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export async function setParticipantMedia({
|
|
131
|
+
parameters,
|
|
132
|
+
name = '',
|
|
133
|
+
id = '',
|
|
134
|
+
kind,
|
|
135
|
+
}: SetParticipantMediaOptions): Promise<HeadlessActionResult> {
|
|
136
|
+
try {
|
|
137
|
+
const live = getCurrentParams({ parameters });
|
|
138
|
+
const permissions = getModerationPermissions({ parameters: live });
|
|
139
|
+
if (!permissions.canControlMedia) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
error: 'You are not allowed to control media for other participants.',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const socket = live?.socket;
|
|
146
|
+
if (!socket || typeof socket.emit !== 'function' || !live?.roomName) {
|
|
147
|
+
return { ok: false, error: 'The room connection is not ready.' };
|
|
148
|
+
}
|
|
149
|
+
const participant = findParticipant(live, { id, name });
|
|
150
|
+
if (!participant) return { ok: false, error: 'That participant is not in the room.' };
|
|
151
|
+
if (String(participant.islevel) === '2') {
|
|
152
|
+
return { ok: false, error: 'A host’s media cannot be turned off.' };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
socket.emit('controlMedia', {
|
|
156
|
+
participantId: participant.id,
|
|
157
|
+
participantName: participant.name,
|
|
158
|
+
type: kind,
|
|
159
|
+
roomName: live.roomName,
|
|
160
|
+
});
|
|
161
|
+
return { ok: true, error: '' };
|
|
162
|
+
} catch (error: any) {
|
|
163
|
+
return { ok: false, error: error?.message || 'The media control failed.' };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface ModerateParticipantOptions extends HeadlessOptions {
|
|
168
|
+
name?: string;
|
|
169
|
+
id?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Mute a participant's microphone. See {@link setParticipantMedia}. */
|
|
173
|
+
export function muteParticipant(
|
|
174
|
+
options: ModerateParticipantOptions
|
|
175
|
+
): Promise<HeadlessActionResult> {
|
|
176
|
+
return setParticipantMedia({ ...options, kind: 'audio' });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Turn a participant's camera off. See {@link setParticipantMedia}. */
|
|
180
|
+
export function disableParticipantVideo(
|
|
181
|
+
options: ModerateParticipantOptions
|
|
182
|
+
): Promise<HeadlessActionResult> {
|
|
183
|
+
return setParticipantMedia({ ...options, kind: 'video' });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Stop a participant's screen share. See {@link setParticipantMedia}. */
|
|
187
|
+
export function stopParticipantScreenShare(
|
|
188
|
+
options: ModerateParticipantOptions
|
|
189
|
+
): Promise<HeadlessActionResult> {
|
|
190
|
+
return setParticipantMedia({ ...options, kind: 'screenshare' });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface MuteEveryoneOptions extends HeadlessOptions {
|
|
194
|
+
/** Which media to switch off for everyone. Defaults to `audio`. */
|
|
195
|
+
kind?: 'audio' | 'video' | 'screenshare' | 'all';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export type MuteEveryoneType = (
|
|
199
|
+
options: MuteEveryoneOptions
|
|
200
|
+
) => Promise<HeadlessActionResult>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Turn media off for every non-host participant.
|
|
204
|
+
*
|
|
205
|
+
* MediaSFU has no bulk primitive, so this fans out per participant. Hosts and
|
|
206
|
+
* the local user are skipped. Succeeds if at least one participant was
|
|
207
|
+
* actioned; reports the failure otherwise.
|
|
208
|
+
*/
|
|
209
|
+
export async function muteEveryone({
|
|
210
|
+
parameters,
|
|
211
|
+
kind = 'audio',
|
|
212
|
+
}: MuteEveryoneOptions): Promise<HeadlessActionResult> {
|
|
213
|
+
const live = getCurrentParams({ parameters });
|
|
214
|
+
const permissions = getModerationPermissions({ parameters: live });
|
|
215
|
+
if (!permissions.canControlMedia) {
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
error: 'You are not allowed to control media for other participants.',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const targets = participantList(live).filter(
|
|
222
|
+
(part) => String(part.islevel) !== '2' && part.name !== live.member
|
|
223
|
+
);
|
|
224
|
+
if (targets.length === 0) return { ok: false, error: 'There is nobody else to mute.' };
|
|
225
|
+
|
|
226
|
+
const results = await Promise.all(
|
|
227
|
+
targets.map((part) =>
|
|
228
|
+
setParticipantMedia({ parameters: live, id: part.id, name: part.name, kind })
|
|
229
|
+
)
|
|
230
|
+
);
|
|
231
|
+
const failed = results.filter((result) => !result.ok);
|
|
232
|
+
if (failed.length === results.length) {
|
|
233
|
+
return { ok: false, error: failed[0]?.error || 'No participant could be muted.' };
|
|
234
|
+
}
|
|
235
|
+
return { ok: true, error: '' };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export type RemoveParticipantType = (
|
|
239
|
+
options: ModerateParticipantOptions
|
|
240
|
+
) => Promise<HeadlessActionResult>;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Remove a participant from the room.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* await removeParticipant({ parameters, name: 'Paul' });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
export async function removeParticipant({
|
|
251
|
+
parameters,
|
|
252
|
+
name = '',
|
|
253
|
+
id = '',
|
|
254
|
+
}: ModerateParticipantOptions): Promise<HeadlessActionResult> {
|
|
255
|
+
try {
|
|
256
|
+
const live = getCurrentParams({ parameters });
|
|
257
|
+
const permissions = getModerationPermissions({ parameters: live });
|
|
258
|
+
if (!permissions.canManageParticipants) {
|
|
259
|
+
return { ok: false, error: 'You are not allowed to remove participants.' };
|
|
260
|
+
}
|
|
261
|
+
const participant = findParticipant(live, { id, name });
|
|
262
|
+
if (!participant) return { ok: false, error: 'That participant is not in the room.' };
|
|
263
|
+
if (String(participant.islevel) === '2') {
|
|
264
|
+
return { ok: false, error: 'A host cannot be removed.' };
|
|
265
|
+
}
|
|
266
|
+
await removeParticipants({
|
|
267
|
+
coHostResponsibility: live.coHostResponsibility || [],
|
|
268
|
+
participant,
|
|
269
|
+
member: live.member || '',
|
|
270
|
+
islevel: live.islevel || '1',
|
|
271
|
+
showAlert: live.showAlert,
|
|
272
|
+
coHost: live.coHost || '',
|
|
273
|
+
participants: participantList(live),
|
|
274
|
+
socket: live.socket,
|
|
275
|
+
roomName: live.roomName || '',
|
|
276
|
+
updateParticipants: live.updateParticipants,
|
|
277
|
+
});
|
|
278
|
+
return { ok: true, error: '' };
|
|
279
|
+
} catch (error: any) {
|
|
280
|
+
return { ok: false, error: error?.message || 'The participant could not be removed.' };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface RespondToWaitingParticipantOptions extends HeadlessOptions {
|
|
285
|
+
name?: string;
|
|
286
|
+
id?: string;
|
|
287
|
+
/** True to admit, false to deny. */
|
|
288
|
+
admit: boolean;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export type RespondToWaitingParticipantType = (
|
|
292
|
+
options: RespondToWaitingParticipantOptions
|
|
293
|
+
) => Promise<HeadlessActionResult>;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Admit or deny somebody waiting to join.
|
|
297
|
+
*
|
|
298
|
+
* Reads `waitingRoomList` off the bag, so you only supply the person's name or
|
|
299
|
+
* id and whether to let them in.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* for (const person of parameters.waitingRoomList ?? []) {
|
|
304
|
+
* await respondToWaitingParticipant({ parameters, id: person.id, admit: true });
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
export async function respondToWaitingParticipant({
|
|
309
|
+
parameters,
|
|
310
|
+
name = '',
|
|
311
|
+
id = '',
|
|
312
|
+
admit,
|
|
313
|
+
}: RespondToWaitingParticipantOptions): Promise<HeadlessActionResult> {
|
|
314
|
+
try {
|
|
315
|
+
const live = getCurrentParams({ parameters });
|
|
316
|
+
const permissions = getModerationPermissions({ parameters: live });
|
|
317
|
+
if (!permissions.canManageWaitingRoom) {
|
|
318
|
+
return { ok: false, error: 'You are not allowed to manage the waiting room.' };
|
|
319
|
+
}
|
|
320
|
+
const waitingList = Array.isArray(live.waitingRoomList) ? live.waitingRoomList : [];
|
|
321
|
+
const entry =
|
|
322
|
+
(id ? waitingList.find((person: any) => person?.id === id) : undefined) ||
|
|
323
|
+
(name ? waitingList.find((person: any) => person?.name === name) : undefined);
|
|
324
|
+
if (!entry) return { ok: false, error: 'That person is no longer waiting to join.' };
|
|
325
|
+
|
|
326
|
+
await respondToWaiting({
|
|
327
|
+
participantId: entry.id,
|
|
328
|
+
participantName: entry.name,
|
|
329
|
+
updateWaitingList: live.updateWaitingRoomList,
|
|
330
|
+
waitingList,
|
|
331
|
+
type: admit,
|
|
332
|
+
roomName: live.roomName || '',
|
|
333
|
+
socket: live.socket,
|
|
334
|
+
});
|
|
335
|
+
return { ok: true, error: '' };
|
|
336
|
+
} catch (error: any) {
|
|
337
|
+
return {
|
|
338
|
+
ok: false,
|
|
339
|
+
error: error?.message || 'The waiting-room response failed.',
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface RespondToParticipantRequestOptions extends HeadlessOptions {
|
|
345
|
+
/** The request id from `parameters.requestList`. */
|
|
346
|
+
requestId?: string;
|
|
347
|
+
/** Or match by requester name. */
|
|
348
|
+
name?: string;
|
|
349
|
+
/** True to approve, false to reject. */
|
|
350
|
+
approve: boolean;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export type RespondToParticipantRequestType = (
|
|
354
|
+
options: RespondToParticipantRequestOptions
|
|
355
|
+
) => Promise<HeadlessActionResult>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Approve or reject a participant request (raise hand, ask to share, ask to
|
|
359
|
+
* speak). Requests live on `parameters.requestList`; each carries an `icon`
|
|
360
|
+
* naming the capability being asked for.
|
|
361
|
+
*/
|
|
362
|
+
export async function respondToParticipantRequest({
|
|
363
|
+
parameters,
|
|
364
|
+
requestId = '',
|
|
365
|
+
name = '',
|
|
366
|
+
approve,
|
|
367
|
+
}: RespondToParticipantRequestOptions): Promise<HeadlessActionResult> {
|
|
368
|
+
try {
|
|
369
|
+
const live = getCurrentParams({ parameters });
|
|
370
|
+
const permissions = getModerationPermissions({ parameters: live });
|
|
371
|
+
if (!permissions.canManageParticipants) {
|
|
372
|
+
return { ok: false, error: 'You are not allowed to respond to requests.' };
|
|
373
|
+
}
|
|
374
|
+
const requestList = Array.isArray(live.requestList) ? live.requestList : [];
|
|
375
|
+
const request =
|
|
376
|
+
(requestId
|
|
377
|
+
? requestList.find((item: any) => item?.id === requestId)
|
|
378
|
+
: undefined) ||
|
|
379
|
+
(name
|
|
380
|
+
? requestList.find(
|
|
381
|
+
(item: any) => item?.name === name || item?.username === name
|
|
382
|
+
)
|
|
383
|
+
: undefined);
|
|
384
|
+
if (!request) return { ok: false, error: 'That request is no longer pending.' };
|
|
385
|
+
|
|
386
|
+
await respondToRequests({
|
|
387
|
+
socket: live.socket,
|
|
388
|
+
request,
|
|
389
|
+
updateRequestList: live.updateRequestList,
|
|
390
|
+
requestList,
|
|
391
|
+
action: approve ? 'accepted' : 'rejected',
|
|
392
|
+
roomName: live.roomName || '',
|
|
393
|
+
});
|
|
394
|
+
return { ok: true, error: '' };
|
|
395
|
+
} catch (error: any) {
|
|
396
|
+
return { ok: false, error: error?.message || 'The request response failed.' };
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface SetCoHostOptions extends HeadlessOptions {
|
|
401
|
+
/** Participant to promote. Pass '' to clear the current co-host. */
|
|
402
|
+
name: string;
|
|
403
|
+
/** Areas the co-host may moderate. Defaults to media + participants. */
|
|
404
|
+
areas?: ModerationArea[];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export type SetCoHostType = (
|
|
408
|
+
options: SetCoHostOptions
|
|
409
|
+
) => Promise<HeadlessActionResult>;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Promote a participant to co-host and choose what they may moderate.
|
|
413
|
+
*
|
|
414
|
+
* Only the host may do this. Areas not listed are explicitly disabled, so this
|
|
415
|
+
* sets the complete responsibility set rather than merging with the previous one.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* await setCoHost({ parameters, name: 'Paul', areas: ['media', 'waiting'] });
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
export async function setCoHost({
|
|
423
|
+
parameters,
|
|
424
|
+
name,
|
|
425
|
+
areas = ['media', 'participants'],
|
|
426
|
+
}: SetCoHostOptions): Promise<HeadlessActionResult> {
|
|
427
|
+
try {
|
|
428
|
+
const live = getCurrentParams({ parameters });
|
|
429
|
+
if (String(live.islevel) !== '2') {
|
|
430
|
+
return { ok: false, error: 'Only the host can assign a co-host.' };
|
|
431
|
+
}
|
|
432
|
+
const all: ModerationArea[] = ['media', 'participants', 'chat', 'waiting'];
|
|
433
|
+
const responsibilities = all.map((area) => ({
|
|
434
|
+
name: area,
|
|
435
|
+
value: areas.includes(area),
|
|
436
|
+
dedicated: false,
|
|
437
|
+
}));
|
|
438
|
+
|
|
439
|
+
await modifyCoHostSettings({
|
|
440
|
+
roomName: live.roomName || '',
|
|
441
|
+
showAlert: live.showAlert,
|
|
442
|
+
selectedParticipant: name,
|
|
443
|
+
coHost: live.coHost || '',
|
|
444
|
+
coHostResponsibility: responsibilities,
|
|
445
|
+
updateIsCoHostModalVisible:
|
|
446
|
+
live.updateIsCoHostModalVisible || (() => undefined),
|
|
447
|
+
updateCoHostResponsibility: live.updateCoHostResponsibility,
|
|
448
|
+
updateCoHost: live.updateCoHost,
|
|
449
|
+
socket: live.socket,
|
|
450
|
+
});
|
|
451
|
+
return { ok: true, error: '' };
|
|
452
|
+
} catch (error: any) {
|
|
453
|
+
return { ok: false, error: error?.message || 'The co-host update failed.' };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Participant } from '../../../types/types';
|
|
2
|
+
import { HeadlessOptions, HeadlessParameters } from './headlessTypes';
|
|
3
|
+
|
|
4
|
+
/** MediaSFU writes 'none' rather than an empty string when a producer is absent. */
|
|
5
|
+
function hasProducer(value: unknown): boolean {
|
|
6
|
+
return (
|
|
7
|
+
typeof value === 'string' &&
|
|
8
|
+
value.length > 3 &&
|
|
9
|
+
value.toLowerCase() !== 'none'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function participantList(parameters: HeadlessParameters): Participant[] {
|
|
14
|
+
const source = parameters || {};
|
|
15
|
+
const primary = Array.isArray(source.participants) ? source.participants : [];
|
|
16
|
+
if (primary.length > 0) return primary;
|
|
17
|
+
return Array.isArray(source.participantsAll) ? source.participantsAll : [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ParticipantMediaState {
|
|
21
|
+
participant: Participant | null;
|
|
22
|
+
/** The participant's own display name, or '' when unresolved. */
|
|
23
|
+
name: string;
|
|
24
|
+
/** True when this row is the local user. */
|
|
25
|
+
isSelf: boolean;
|
|
26
|
+
/** True when the participant is a host (islevel '2'). */
|
|
27
|
+
isHost: boolean;
|
|
28
|
+
/** True when the participant is publishing a camera. */
|
|
29
|
+
hasVideo: boolean;
|
|
30
|
+
/** True when the participant is publishing a microphone. */
|
|
31
|
+
hasAudio: boolean;
|
|
32
|
+
/** True when the participant's microphone is muted. */
|
|
33
|
+
muted: boolean;
|
|
34
|
+
/** The camera producer id, or '' when not publishing. */
|
|
35
|
+
videoProducerId: string;
|
|
36
|
+
/** The microphone producer id, or '' when not publishing. */
|
|
37
|
+
audioProducerId: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface GetParticipantMediaStateOptions extends HeadlessOptions {
|
|
41
|
+
/** Match by display name. */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** Match by participant id. Takes precedence over `name`. */
|
|
44
|
+
id?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type GetParticipantMediaStateType = (
|
|
48
|
+
options: GetParticipantMediaStateOptions
|
|
49
|
+
) => ParticipantMediaState;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether a participant is publishing, and what to label them.
|
|
53
|
+
*
|
|
54
|
+
* "Is this person on camera?" is not `participant.muted` and not the presence of
|
|
55
|
+
* a stream in your grid — it is whether `videoID` holds a real producer
|
|
56
|
+
* reference. MediaSFU writes the string `'none'` rather than an empty value when
|
|
57
|
+
* there is no producer, which is why a naive truthiness check reports everyone
|
|
58
|
+
* as publishing.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { getParticipantMediaState } from 'mediasfu-shared';
|
|
63
|
+
*
|
|
64
|
+
* const paul = getParticipantMediaState({ parameters, name: 'Paul' });
|
|
65
|
+
* if (paul.hasVideo) renderCamera(paul.videoProducerId);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function getParticipantMediaState({
|
|
69
|
+
parameters,
|
|
70
|
+
name = '',
|
|
71
|
+
id = '',
|
|
72
|
+
}: GetParticipantMediaStateOptions): ParticipantMediaState {
|
|
73
|
+
const source = parameters || {};
|
|
74
|
+
const participants = participantList(source);
|
|
75
|
+
const participant =
|
|
76
|
+
(id ? participants.find((part) => part.id === id) : undefined) ||
|
|
77
|
+
(name ? participants.find((part) => part.name === name) : undefined) ||
|
|
78
|
+
null;
|
|
79
|
+
|
|
80
|
+
const videoProducerId = hasProducer(participant?.videoID)
|
|
81
|
+
? (participant!.videoID as string)
|
|
82
|
+
: '';
|
|
83
|
+
const audioProducerId = hasProducer(participant?.audioID)
|
|
84
|
+
? (participant!.audioID as string)
|
|
85
|
+
: '';
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
participant,
|
|
89
|
+
name: participant?.name || '',
|
|
90
|
+
isSelf: Boolean(participant?.name && participant.name === source.member),
|
|
91
|
+
isHost: String(participant?.islevel) === '2',
|
|
92
|
+
hasVideo: Boolean(videoProducerId),
|
|
93
|
+
hasAudio: Boolean(audioProducerId),
|
|
94
|
+
muted: participant?.muted === true,
|
|
95
|
+
videoProducerId,
|
|
96
|
+
audioProducerId,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type ListParticipantMediaStatesType = (
|
|
101
|
+
options: HeadlessOptions
|
|
102
|
+
) => ParticipantMediaState[];
|
|
103
|
+
|
|
104
|
+
/** {@link getParticipantMediaState} for everyone currently in the room. */
|
|
105
|
+
export function listParticipantMediaStates({
|
|
106
|
+
parameters,
|
|
107
|
+
}: HeadlessOptions): ParticipantMediaState[] {
|
|
108
|
+
const source = parameters || {};
|
|
109
|
+
return participantList(source).map((participant) =>
|
|
110
|
+
getParticipantMediaState({
|
|
111
|
+
parameters: source,
|
|
112
|
+
id: participant.id,
|
|
113
|
+
name: participant.name,
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ActiveSpeaker {
|
|
119
|
+
/** Loudest participant's display name, or '' when the room is quiet. */
|
|
120
|
+
name: string;
|
|
121
|
+
/** That participant's average loudness. */
|
|
122
|
+
level: number;
|
|
123
|
+
participant: Participant | null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type GetActiveSpeakerType = (options: HeadlessOptions) => ActiveSpeaker;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The loudest participant right now.
|
|
130
|
+
*
|
|
131
|
+
* Reads `audioDecibels`, which the SDK maintains per participant. MediaSFU's own
|
|
132
|
+
* grids treat roughly 127.5 as the noise floor, so quieter rooms report no
|
|
133
|
+
* active speaker rather than flickering between people.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const speaker = getActiveSpeaker({ parameters });
|
|
138
|
+
* if (speaker.name) highlight(speaker.name);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export function getActiveSpeaker({ parameters }: HeadlessOptions): ActiveSpeaker {
|
|
142
|
+
const source = parameters || {};
|
|
143
|
+
const decibels = Array.isArray(source.audioDecibels) ? source.audioDecibels : [];
|
|
144
|
+
const participants = participantList(source);
|
|
145
|
+
|
|
146
|
+
let best: { name: string; averageLoudness: number } | null = null;
|
|
147
|
+
for (const entry of decibels) {
|
|
148
|
+
if (!entry?.name || typeof entry.averageLoudness !== 'number') continue;
|
|
149
|
+
if (entry.averageLoudness <= 127.5) continue;
|
|
150
|
+
if (!best || entry.averageLoudness > best.averageLoudness) best = entry;
|
|
151
|
+
}
|
|
152
|
+
if (!best) return { name: '', level: 0, participant: null };
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
name: best.name,
|
|
156
|
+
level: best.averageLoudness,
|
|
157
|
+
participant: participants.find((part) => part.name === best!.name) || null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface MediaDeviceList {
|
|
162
|
+
cameras: MediaDeviceInfo[];
|
|
163
|
+
microphones: MediaDeviceInfo[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type ListMediaDevicesType = (
|
|
167
|
+
options: HeadlessOptions
|
|
168
|
+
) => Promise<MediaDeviceList>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Cameras and microphones available for a device picker.
|
|
172
|
+
*
|
|
173
|
+
* Uses the SDK's own `getMediaDevicesList` when the bag exposes it, so the
|
|
174
|
+
* result reflects the same `mediaDevices` instance the SDK captures with;
|
|
175
|
+
* otherwise falls back to `navigator.mediaDevices.enumerateDevices()`.
|
|
176
|
+
*
|
|
177
|
+
* Labels are blank until the user has granted permission once — call this after
|
|
178
|
+
* the first successful capture if you need readable device names.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const { cameras } = await listMediaDevices({ parameters });
|
|
183
|
+
* await runMediaControl({
|
|
184
|
+
* parameters,
|
|
185
|
+
* control: 'switchVideo',
|
|
186
|
+
* extra: { videoPreference: cameras[1].deviceId },
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export async function listMediaDevices({
|
|
191
|
+
parameters,
|
|
192
|
+
}: HeadlessOptions): Promise<MediaDeviceList> {
|
|
193
|
+
const source = parameters || {};
|
|
194
|
+
try {
|
|
195
|
+
if (typeof source.getMediaDevicesList === 'function') {
|
|
196
|
+
const [cameras, microphones] = await Promise.all([
|
|
197
|
+
source.getMediaDevicesList('videoinput'),
|
|
198
|
+
source.getMediaDevicesList('audioinput'),
|
|
199
|
+
]);
|
|
200
|
+
return {
|
|
201
|
+
cameras: Array.isArray(cameras) ? cameras : [],
|
|
202
|
+
microphones: Array.isArray(microphones) ? microphones : [],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
206
|
+
return {
|
|
207
|
+
cameras: devices.filter((device) => device.kind === 'videoinput'),
|
|
208
|
+
microphones: devices.filter((device) => device.kind === 'audioinput'),
|
|
209
|
+
};
|
|
210
|
+
} catch {
|
|
211
|
+
return { cameras: [], microphones: [] };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface SelectedDevices {
|
|
216
|
+
/** Device id of the camera currently in use, or '' when none is selected. */
|
|
217
|
+
cameraId: string;
|
|
218
|
+
/** Device id of the microphone currently in use, or '' when none is selected. */
|
|
219
|
+
microphoneId: string;
|
|
220
|
+
/** Cameras the SDK has enumerated for this room. */
|
|
221
|
+
cameras: MediaDeviceInfo[];
|
|
222
|
+
/** Microphones the SDK has enumerated for this room. */
|
|
223
|
+
microphones: MediaDeviceInfo[];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type GetSelectedDevicesType = (options: HeadlessOptions) => SelectedDevices;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Which camera and microphone the SDK is actually using, plus the device lists
|
|
230
|
+
* it has already enumerated.
|
|
231
|
+
*
|
|
232
|
+
* Unlike {@link listMediaDevices} this is synchronous and needs no permission
|
|
233
|
+
* prompt: it reads `userDefaultVideoInputDevice` / `userDefaultAudioInputDevice`
|
|
234
|
+
* and the `videoInputs` / `audioInputs` the SDK populated during setup. Use it
|
|
235
|
+
* to mark the current entry in a device picker; use `listMediaDevices` when you
|
|
236
|
+
* need a freshly enumerated list.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```tsx
|
|
240
|
+
* const { cameras, cameraId } = getSelectedDevices({ parameters });
|
|
241
|
+
* <select value={cameraId} onChange={(e) => room.controls.selectCamera(e.target.value)}>
|
|
242
|
+
* {cameras.map((d) => <option key={d.deviceId} value={d.deviceId}>{d.label}</option>)}
|
|
243
|
+
* </select>
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export function getSelectedDevices({ parameters }: HeadlessOptions): SelectedDevices {
|
|
247
|
+
const source = parameters || {};
|
|
248
|
+
return {
|
|
249
|
+
cameraId: source.userDefaultVideoInputDevice || '',
|
|
250
|
+
microphoneId: source.userDefaultAudioInputDevice || '',
|
|
251
|
+
cameras: Array.isArray(source.videoInputs) ? source.videoInputs : [],
|
|
252
|
+
microphones: Array.isArray(source.audioInputs) ? source.audioInputs : [],
|
|
253
|
+
};
|
|
254
|
+
}
|