mediasfu-shared 1.0.5 → 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 -13213
- 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 -13186
- 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 +74 -20
- 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,124 @@
|
|
|
1
|
+
import { HeadlessOptions, HeadlessParameters } from './headlessTypes';
|
|
2
|
+
|
|
3
|
+
export interface MediaPermission {
|
|
4
|
+
/** True when turning this media ON would be accepted right now. */
|
|
5
|
+
allowed: boolean;
|
|
6
|
+
/** Empty when allowed; otherwise the reason, phrased for a user. */
|
|
7
|
+
reason: string;
|
|
8
|
+
/**
|
|
9
|
+
* True when enabling is possible but needs the host to approve first
|
|
10
|
+
* (`audioSetting`/`videoSetting` of 'approval'). The control still works —
|
|
11
|
+
* it raises a request rather than turning media on immediately.
|
|
12
|
+
*/
|
|
13
|
+
needsApproval: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MediaPermissions {
|
|
17
|
+
microphone: MediaPermission;
|
|
18
|
+
camera: MediaPermission;
|
|
19
|
+
screenShare: MediaPermission;
|
|
20
|
+
/** True when the local user is a host (islevel '2') and bypasses most gates. */
|
|
21
|
+
isHost: boolean;
|
|
22
|
+
/** True when focus mode is on and the local user is not a panelist. */
|
|
23
|
+
focusModeBlocked: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type GetMediaPermissionsType = (
|
|
27
|
+
options: HeadlessOptions
|
|
28
|
+
) => MediaPermissions;
|
|
29
|
+
|
|
30
|
+
function isPanelist(parameters: HeadlessParameters): boolean {
|
|
31
|
+
const panelists = Array.isArray(parameters.panelists) ? parameters.panelists : [];
|
|
32
|
+
return panelists.some((entry: any) => entry?.name === parameters.member);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Can this user turn their mic, camera or screen share on *right now*?
|
|
37
|
+
*
|
|
38
|
+
* MediaSFU decides this inside `clickAudio` / `clickVideo` / `clickScreenShare`,
|
|
39
|
+
* which return `void` and report a refusal only through `showAlert`. That means
|
|
40
|
+
* a headless surface finds out a control was blocked *after* the user pressed
|
|
41
|
+
* it — the button looks broken. This evaluates the same gates up front so you
|
|
42
|
+
* can disable the control and say why instead.
|
|
43
|
+
*
|
|
44
|
+
* The branches mirror the SDK's own order: audio-only rooms, host recording
|
|
45
|
+
* locks, `adminRestrictSetting`, focus-mode panelist restrictions, and the
|
|
46
|
+
* `allow` / `approval` / `disallow` settings. Host (`islevel === '2'`) bypasses
|
|
47
|
+
* the participant-level gates, exactly as the controls do.
|
|
48
|
+
*
|
|
49
|
+
* Note this cannot predict two cases: room capacity checks, which the SDK
|
|
50
|
+
* resolves by asking the server (`checkProduce`), and OS-level device
|
|
51
|
+
* permission, which only surfaces when capture is attempted. Treat a `false`
|
|
52
|
+
* here as authoritative and a `true` as "nothing known blocks it".
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const perms = getMediaPermissions({ parameters });
|
|
57
|
+
* <button disabled={!perms.microphone.allowed} title={perms.microphone.reason}>
|
|
58
|
+
* {perms.microphone.needsApproval ? 'Ask to unmute' : 'Unmute'}
|
|
59
|
+
* </button>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function getMediaPermissions({ parameters }: HeadlessOptions): MediaPermissions {
|
|
63
|
+
const source: HeadlessParameters = parameters || {};
|
|
64
|
+
const isHost = String(source.islevel) === '2';
|
|
65
|
+
const recording = Boolean(source.recordStarted || source.recordResumed)
|
|
66
|
+
&& !(source.recordPaused || source.recordStopped);
|
|
67
|
+
const focusModeBlocked = Boolean(source.panelistsFocused) && !isHost && !isPanelist(source);
|
|
68
|
+
|
|
69
|
+
const evaluate = (
|
|
70
|
+
kind: 'audio' | 'video' | 'screenshare'
|
|
71
|
+
): MediaPermission => {
|
|
72
|
+
const allow = (): MediaPermission => ({ allowed: true, reason: '', needsApproval: false });
|
|
73
|
+
const deny = (reason: string): MediaPermission => ({ allowed: false, reason, needsApproval: false });
|
|
74
|
+
|
|
75
|
+
// An audio-only room refuses every visual producer outright.
|
|
76
|
+
if (source.audioOnlyRoom && kind !== 'audio') {
|
|
77
|
+
return deny('This is an audio-only event.');
|
|
78
|
+
}
|
|
79
|
+
// The host cannot drop media the recording depends on.
|
|
80
|
+
if (isHost && recording) {
|
|
81
|
+
if (kind === 'audio' && source.recordingMediaOptions === 'audio') {
|
|
82
|
+
return deny('Pause or stop the recording before changing your microphone.');
|
|
83
|
+
}
|
|
84
|
+
if (kind === 'video' && source.recordingMediaOptions === 'video') {
|
|
85
|
+
return deny('Pause or stop the recording before changing your camera.');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (isHost) return allow();
|
|
89
|
+
|
|
90
|
+
if (source.adminRestrictSetting) {
|
|
91
|
+
return deny('Access denied by the host.');
|
|
92
|
+
}
|
|
93
|
+
if (focusModeBlocked && kind === 'audio' && source.muteOthersMic) {
|
|
94
|
+
return deny('Only panelists can unmute while focus mode is active.');
|
|
95
|
+
}
|
|
96
|
+
if (focusModeBlocked && kind === 'video' && source.muteOthersCamera) {
|
|
97
|
+
return deny('Only panelists can enable video while focus mode is active.');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const setting = kind === 'audio'
|
|
101
|
+
? source.audioSetting
|
|
102
|
+
: kind === 'video'
|
|
103
|
+
? source.videoSetting
|
|
104
|
+
: source.screenshareSetting;
|
|
105
|
+
if (setting === 'disallow') {
|
|
106
|
+
return deny('The host has disabled this for participants.');
|
|
107
|
+
}
|
|
108
|
+
if (setting === 'approval') {
|
|
109
|
+
// Not a refusal: the control raises a request to the host.
|
|
110
|
+
return { allowed: true, reason: 'The host must approve this.', needsApproval: true };
|
|
111
|
+
}
|
|
112
|
+
return allow();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
microphone: evaluate('audio'),
|
|
117
|
+
camera: evaluate('video'),
|
|
118
|
+
screenShare: evaluate('screenshare'),
|
|
119
|
+
isHost,
|
|
120
|
+
focusModeBlocked,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default getMediaPermissions;
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { streamSuccessVideo } from '../../../consumers/streamSuccessVideo';
|
|
2
|
+
import { streamSuccessAudio } from '../../../consumers/streamSuccessAudio';
|
|
3
|
+
import { streamSuccessScreen } from '../../../consumers/streamSuccessScreen';
|
|
4
|
+
import { disconnectSendTransportVideo } from '../../../consumers/disconnectSendTransportVideo';
|
|
5
|
+
import { disconnectSendTransportAudio } from '../../../consumers/disconnectSendTransportAudio';
|
|
6
|
+
import { disconnectSendTransportScreen } from '../../../consumers/disconnectSendTransportScreen';
|
|
7
|
+
import { HeadlessOptions, HeadlessParameters } from './headlessTypes';
|
|
8
|
+
import { getCurrentParams } from './getCurrentParams';
|
|
9
|
+
import { getRoomReadiness } from './getRoomReadiness';
|
|
10
|
+
import { HeadlessActionResult } from './roomActions';
|
|
11
|
+
|
|
12
|
+
export type ProducerKind = 'video' | 'audio' | 'screen';
|
|
13
|
+
|
|
14
|
+
function hasLiveTrack(stream: MediaStream | null | undefined, kind: 'video' | 'audio'): boolean {
|
|
15
|
+
if (!stream || typeof stream.getTracks !== 'function') return false;
|
|
16
|
+
try {
|
|
17
|
+
return stream
|
|
18
|
+
.getTracks()
|
|
19
|
+
.some((track) => track.kind === kind && track.readyState === 'live');
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** `VidCons` allows a bare number or a {ideal,max,min} shape. */
|
|
26
|
+
function capOf(value: any): number {
|
|
27
|
+
if (typeof value === 'number') return value;
|
|
28
|
+
if (value && typeof value === 'object') {
|
|
29
|
+
const candidate = value.max ?? value.ideal;
|
|
30
|
+
if (typeof candidate === 'number') return candidate;
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CaptureLimits {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
frameRate: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GetCaptureLimitsOptions extends HeadlessOptions {
|
|
42
|
+
/** Camera and screen share have separate ceilings. Defaults to camera. */
|
|
43
|
+
kind?: ProducerKind;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type GetCaptureLimitsType = (options: GetCaptureLimitsOptions) => CaptureLimits;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The room's allowed capture ceiling — the same `vidCons` / `frameRate` that
|
|
50
|
+
* `clickVideo` feeds to `getUserMedia`. Zero means "no ceiling published".
|
|
51
|
+
*/
|
|
52
|
+
export function getCaptureLimits({ parameters, kind = 'video' }: GetCaptureLimitsOptions): CaptureLimits {
|
|
53
|
+
const source: HeadlessParameters = parameters || {};
|
|
54
|
+
// Screen share is governed by targetWidth/targetHeight (what startShareScreen
|
|
55
|
+
// passes to getDisplayMedia), not by the camera's vidCons.
|
|
56
|
+
if (kind === 'screen') {
|
|
57
|
+
return {
|
|
58
|
+
width: Number(source.targetWidth) || 0,
|
|
59
|
+
height: Number(source.targetHeight) || 0,
|
|
60
|
+
frameRate: Number(source.frameRate) || 30,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const vidCons: any = source.vidCons || {};
|
|
64
|
+
return {
|
|
65
|
+
width: capOf(vidCons.width),
|
|
66
|
+
height: capOf(vidCons.height),
|
|
67
|
+
frameRate: Number(source.frameRate) || 0,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Clamp an incoming track to the room's capture ceiling before it is published.
|
|
73
|
+
*
|
|
74
|
+
* This matters because the publish path here is deliberately *not* `clickVideo`.
|
|
75
|
+
* `clickVideo` applies `vidCons`/`frameRate` when it calls `getUserMedia`;
|
|
76
|
+
* `streamSuccessVideo` — which every produce* helper calls — never re-applies
|
|
77
|
+
* them to a track it is handed. Encoding limits still apply either way
|
|
78
|
+
* (`vParams`/`hParams` carry the `maxBitrate` ladder and are attached at
|
|
79
|
+
* `producerTransport.produce`), so bandwidth stays capped, but *capture
|
|
80
|
+
* dimensions and frame rate* would otherwise be unbounded.
|
|
81
|
+
*
|
|
82
|
+
* Order: try `applyConstraints` first, then verify with `getSettings`. Sources
|
|
83
|
+
* such as `canvas.captureStream()` frequently reject or ignore constraints, so
|
|
84
|
+
* verification is the part that actually enforces — an over-size track that
|
|
85
|
+
* cannot be clamped is refused rather than published.
|
|
86
|
+
*/
|
|
87
|
+
async function enforceCaptureLimits(
|
|
88
|
+
stream: MediaStream,
|
|
89
|
+
parameters: HeadlessParameters,
|
|
90
|
+
kind: ProducerKind,
|
|
91
|
+
allowUnconstrained: boolean
|
|
92
|
+
): Promise<{ ok: boolean; error: string }> {
|
|
93
|
+
if (kind === 'audio') return { ok: true, error: '' };
|
|
94
|
+
const limits = getCaptureLimits({ parameters, kind });
|
|
95
|
+
if (!limits.width && !limits.height && !limits.frameRate) return { ok: true, error: '' };
|
|
96
|
+
|
|
97
|
+
let track: MediaStreamTrack | undefined;
|
|
98
|
+
try {
|
|
99
|
+
track = stream.getVideoTracks()[0];
|
|
100
|
+
} catch {
|
|
101
|
+
return { ok: true, error: '' };
|
|
102
|
+
}
|
|
103
|
+
if (!track) return { ok: true, error: '' };
|
|
104
|
+
|
|
105
|
+
const constraints: MediaTrackConstraints = {};
|
|
106
|
+
if (limits.width) constraints.width = { max: limits.width };
|
|
107
|
+
if (limits.height) constraints.height = { max: limits.height };
|
|
108
|
+
if (limits.frameRate) constraints.frameRate = { max: limits.frameRate };
|
|
109
|
+
try {
|
|
110
|
+
await track.applyConstraints(constraints);
|
|
111
|
+
} catch {
|
|
112
|
+
// Canvas and element captures commonly reject this; verification below decides.
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let settings: MediaTrackSettings = {};
|
|
116
|
+
try {
|
|
117
|
+
settings = track.getSettings?.() || {};
|
|
118
|
+
} catch {
|
|
119
|
+
return { ok: true, error: '' };
|
|
120
|
+
}
|
|
121
|
+
// A source that reports nothing cannot be verified either way; let it through
|
|
122
|
+
// rather than block a legitimate publish on missing metadata.
|
|
123
|
+
if (!settings.width && !settings.height && !settings.frameRate) {
|
|
124
|
+
return { ok: true, error: '' };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const over: string[] = [];
|
|
128
|
+
if (limits.width && settings.width && settings.width > limits.width) {
|
|
129
|
+
over.push(`width ${settings.width} > ${limits.width}`);
|
|
130
|
+
}
|
|
131
|
+
if (limits.height && settings.height && settings.height > limits.height) {
|
|
132
|
+
over.push(`height ${settings.height} > ${limits.height}`);
|
|
133
|
+
}
|
|
134
|
+
if (limits.frameRate && settings.frameRate && settings.frameRate > limits.frameRate + 1) {
|
|
135
|
+
over.push(`frameRate ${Math.round(settings.frameRate)} > ${limits.frameRate}`);
|
|
136
|
+
}
|
|
137
|
+
if (over.length === 0) return { ok: true, error: '' };
|
|
138
|
+
if (allowUnconstrained) return { ok: true, error: '' };
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
error: `This source exceeds the room's capture allowance (${over.join(', ')}). `
|
|
143
|
+
+ 'Reduce the source size or frame rate before publishing.',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface ProduceMediaOptions extends HeadlessOptions {
|
|
148
|
+
/** The stream to publish. Must carry at least one live track of the right kind. */
|
|
149
|
+
stream: MediaStream;
|
|
150
|
+
/** What to publish it as. */
|
|
151
|
+
kind: ProducerKind;
|
|
152
|
+
/**
|
|
153
|
+
* Publish even when the source exceeds the room's `vidCons`/`frameRate`
|
|
154
|
+
* ceiling and cannot be clamped. Off by default: the ceiling is a room
|
|
155
|
+
* entitlement, so bypassing it must be a deliberate, visible choice.
|
|
156
|
+
*/
|
|
157
|
+
allowUnconstrained?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type ProduceMediaType = (
|
|
161
|
+
options: ProduceMediaOptions
|
|
162
|
+
) => Promise<HeadlessActionResult>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Publish **any** MediaStream to the room — not just the camera or microphone.
|
|
166
|
+
*
|
|
167
|
+
* `clickVideo` / `clickAudio` call `getUserMedia` internally, so they can only
|
|
168
|
+
* ever publish a real device. Anything else — a `<canvas>` capture, a `<video>`
|
|
169
|
+
* element playing a file, a Web Audio destination, a processed or synthesised
|
|
170
|
+
* track, a virtual camera — previously required monkey-patching
|
|
171
|
+
* `navigator.mediaDevices.getUserMedia` around the call, which is racy and
|
|
172
|
+
* leaks if the control throws. This publishes your stream directly.
|
|
173
|
+
*
|
|
174
|
+
* The stream stays yours: stop its tracks when you are done, or call
|
|
175
|
+
* {@link stopProducing} to tear the producer down first.
|
|
176
|
+
*
|
|
177
|
+
* @example Publish a canvas as your camera
|
|
178
|
+
* ```ts
|
|
179
|
+
* import { produceMedia } from 'mediasfu-shared';
|
|
180
|
+
*
|
|
181
|
+
* const canvas = document.querySelector('canvas')!;
|
|
182
|
+
* const stream = canvas.captureStream(30);
|
|
183
|
+
* await produceMedia({ parameters, stream, kind: 'video' });
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @example Publish a video file's audio and video
|
|
187
|
+
* ```ts
|
|
188
|
+
* const el = document.querySelector('video')!;
|
|
189
|
+
* const stream = (el as any).captureStream();
|
|
190
|
+
* await produceMedia({ parameters, stream, kind: 'video' });
|
|
191
|
+
* await produceMedia({ parameters, stream, kind: 'audio' });
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export async function produceMedia({
|
|
195
|
+
parameters,
|
|
196
|
+
stream,
|
|
197
|
+
kind,
|
|
198
|
+
allowUnconstrained = false,
|
|
199
|
+
}: ProduceMediaOptions): Promise<HeadlessActionResult> {
|
|
200
|
+
try {
|
|
201
|
+
const live = getCurrentParams({ parameters });
|
|
202
|
+
const readiness = getRoomReadiness({ parameters: live });
|
|
203
|
+
if (!readiness.ready) return { ok: false, error: readiness.reason };
|
|
204
|
+
|
|
205
|
+
const trackKind = kind === 'audio' ? 'audio' : 'video';
|
|
206
|
+
if (!hasLiveTrack(stream, trackKind)) {
|
|
207
|
+
return {
|
|
208
|
+
ok: false,
|
|
209
|
+
error: `The stream has no live ${trackKind} track to publish.`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// The room's capture ceiling is an entitlement, and this path bypasses
|
|
214
|
+
// clickVideo, which is where the SDK normally applies it.
|
|
215
|
+
const limited = await enforceCaptureLimits(stream, live, kind, allowUnconstrained);
|
|
216
|
+
if (!limited.ok) return limited;
|
|
217
|
+
|
|
218
|
+
if (kind === 'audio') {
|
|
219
|
+
await streamSuccessAudio({ stream, parameters: live as any });
|
|
220
|
+
} else if (kind === 'screen') {
|
|
221
|
+
await streamSuccessScreen({ stream, parameters: live as any });
|
|
222
|
+
} else {
|
|
223
|
+
await streamSuccessVideo({ stream, parameters: live as any });
|
|
224
|
+
}
|
|
225
|
+
return { ok: true, error: '' };
|
|
226
|
+
} catch (error: any) {
|
|
227
|
+
return { ok: false, error: error?.message || 'The media could not be published.' };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface StopProducingOptions extends HeadlessOptions {
|
|
232
|
+
kind: ProducerKind;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type StopProducingType = (
|
|
236
|
+
options: StopProducingOptions
|
|
237
|
+
) => Promise<HeadlessActionResult>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Tear down one of your producers without touching the others.
|
|
241
|
+
*
|
|
242
|
+
* `clickVideo`/`clickAudio` toggle capture *and* transport together. When you
|
|
243
|
+
* published a custom stream you usually want to stop only the transport and
|
|
244
|
+
* keep owning the stream (to swap sources without a visible gap, for example).
|
|
245
|
+
*
|
|
246
|
+
* @example Swap the published camera for a canvas without dropping the call
|
|
247
|
+
* ```ts
|
|
248
|
+
* await stopProducing({ parameters, kind: 'video' });
|
|
249
|
+
* await produceMedia({ parameters, stream: canvasStream, kind: 'video' });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export async function stopProducing({
|
|
253
|
+
parameters,
|
|
254
|
+
kind,
|
|
255
|
+
}: StopProducingOptions): Promise<HeadlessActionResult> {
|
|
256
|
+
try {
|
|
257
|
+
const live = getCurrentParams({ parameters });
|
|
258
|
+
if (kind === 'audio') {
|
|
259
|
+
await disconnectSendTransportAudio({ parameters: live as any });
|
|
260
|
+
} else if (kind === 'screen') {
|
|
261
|
+
await disconnectSendTransportScreen({ parameters: live as any });
|
|
262
|
+
} else {
|
|
263
|
+
await disconnectSendTransportVideo({ parameters: live as any });
|
|
264
|
+
}
|
|
265
|
+
return { ok: true, error: '' };
|
|
266
|
+
} catch (error: any) {
|
|
267
|
+
return { ok: false, error: error?.message || 'The producer could not be stopped.' };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface ProduceCanvasOptions extends HeadlessOptions {
|
|
272
|
+
canvas: HTMLCanvasElement;
|
|
273
|
+
/** Capture frame rate. Defaults to 30. */
|
|
274
|
+
frameRate?: number;
|
|
275
|
+
/** Publish as the camera (default) or as a screen share. */
|
|
276
|
+
as?: 'video' | 'screen';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export type ProduceCanvasType = (
|
|
280
|
+
options: ProduceCanvasOptions
|
|
281
|
+
) => Promise<HeadlessActionResult & { stream: MediaStream | null }>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Publish a `<canvas>` as video — slides, a whiteboard, a game, a generated
|
|
285
|
+
* overlay, a test pattern.
|
|
286
|
+
*
|
|
287
|
+
* Returns the captured stream so you can stop its tracks when finished.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* const { ok, stream } = await produceCanvas({ parameters, canvas, frameRate: 15 });
|
|
292
|
+
* // later
|
|
293
|
+
* stream?.getTracks().forEach((track) => track.stop());
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export async function produceCanvas({
|
|
297
|
+
parameters,
|
|
298
|
+
canvas,
|
|
299
|
+
frameRate = 30,
|
|
300
|
+
as = 'video',
|
|
301
|
+
}: ProduceCanvasOptions): Promise<HeadlessActionResult & { stream: MediaStream | null }> {
|
|
302
|
+
try {
|
|
303
|
+
if (!canvas || typeof (canvas as any).captureStream !== 'function') {
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
error: 'This canvas cannot be captured in the current browser.',
|
|
307
|
+
stream: null,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
const stream: MediaStream = (canvas as any).captureStream(frameRate);
|
|
311
|
+
const result = await produceMedia({ parameters, stream, kind: as });
|
|
312
|
+
if (!result.ok) {
|
|
313
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
314
|
+
return { ...result, stream: null };
|
|
315
|
+
}
|
|
316
|
+
return { ...result, stream };
|
|
317
|
+
} catch (error: any) {
|
|
318
|
+
return {
|
|
319
|
+
ok: false,
|
|
320
|
+
error: error?.message || 'The canvas could not be published.',
|
|
321
|
+
stream: null,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface ProduceElementOptions extends HeadlessOptions {
|
|
327
|
+
/** A playing `<video>` or `<audio>` element. */
|
|
328
|
+
element: HTMLMediaElement;
|
|
329
|
+
/** Publish the video track. Defaults to true for `<video>`. */
|
|
330
|
+
withVideo?: boolean;
|
|
331
|
+
/** Publish the audio track. Defaults to true. */
|
|
332
|
+
withAudio?: boolean;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export type ProduceElementType = (
|
|
336
|
+
options: ProduceElementOptions
|
|
337
|
+
) => Promise<HeadlessActionResult & { stream: MediaStream | null }>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Publish a playing `<video>` or `<audio>` element — media co-watching, a
|
|
341
|
+
* pre-recorded intro, background music, an HLS or MP4 source.
|
|
342
|
+
*
|
|
343
|
+
* The element must actually be playing: a paused element captures no frames, and
|
|
344
|
+
* browsers block autoplay with audio until the user has interacted with the page.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* const el = document.querySelector('video')!;
|
|
349
|
+
* await el.play();
|
|
350
|
+
* await produceElement({ parameters, element: el });
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
export async function produceElement({
|
|
354
|
+
parameters,
|
|
355
|
+
element,
|
|
356
|
+
withVideo,
|
|
357
|
+
withAudio = true,
|
|
358
|
+
}: ProduceElementOptions): Promise<HeadlessActionResult & { stream: MediaStream | null }> {
|
|
359
|
+
try {
|
|
360
|
+
const capture =
|
|
361
|
+
(element as any)?.captureStream || (element as any)?.mozCaptureStream;
|
|
362
|
+
if (typeof capture !== 'function') {
|
|
363
|
+
return {
|
|
364
|
+
ok: false,
|
|
365
|
+
error: 'This element cannot be captured in the current browser.',
|
|
366
|
+
stream: null,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
const stream: MediaStream = capture.call(element);
|
|
370
|
+
const wantsVideo = withVideo ?? hasLiveTrack(stream, 'video');
|
|
371
|
+
|
|
372
|
+
const results: HeadlessActionResult[] = [];
|
|
373
|
+
if (wantsVideo && hasLiveTrack(stream, 'video')) {
|
|
374
|
+
results.push(await produceMedia({ parameters, stream, kind: 'video' }));
|
|
375
|
+
}
|
|
376
|
+
if (withAudio && hasLiveTrack(stream, 'audio')) {
|
|
377
|
+
results.push(await produceMedia({ parameters, stream, kind: 'audio' }));
|
|
378
|
+
}
|
|
379
|
+
if (results.length === 0) {
|
|
380
|
+
return { ok: false, error: 'The element has no live tracks yet.', stream: null };
|
|
381
|
+
}
|
|
382
|
+
const failure = results.find((result) => !result.ok);
|
|
383
|
+
if (failure) return { ...failure, stream };
|
|
384
|
+
return { ok: true, error: '', stream };
|
|
385
|
+
} catch (error: any) {
|
|
386
|
+
return {
|
|
387
|
+
ok: false,
|
|
388
|
+
error: error?.message || 'The element could not be published.',
|
|
389
|
+
stream: null,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export interface ProduceDisplayOptions extends HeadlessOptions {
|
|
395
|
+
/** Passed to `getDisplayMedia`. Defaults to `{ video: true }`. */
|
|
396
|
+
constraints?: DisplayMediaStreamOptions;
|
|
397
|
+
/** Also publish the captured system/tab audio when the user shares it. */
|
|
398
|
+
withAudio?: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export type ProduceDisplayType = (
|
|
402
|
+
options: ProduceDisplayOptions
|
|
403
|
+
) => Promise<HeadlessActionResult & { stream: MediaStream | null }>;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Start a screen share from a headless surface.
|
|
407
|
+
*
|
|
408
|
+
* `getDisplayMedia` must be called from a user gesture, so invoke this directly
|
|
409
|
+
* in a click handler — not after an `await`.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```tsx
|
|
413
|
+
* <button onClick={() => produceDisplay({ parameters })}>Share screen</button>
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
export async function produceDisplay({
|
|
417
|
+
parameters,
|
|
418
|
+
constraints = { video: true },
|
|
419
|
+
withAudio = false,
|
|
420
|
+
}: ProduceDisplayOptions): Promise<HeadlessActionResult & { stream: MediaStream | null }> {
|
|
421
|
+
try {
|
|
422
|
+
const mediaDevices: any =
|
|
423
|
+
(parameters as HeadlessParameters)?.mediaDevices ||
|
|
424
|
+
(typeof navigator !== 'undefined' ? navigator.mediaDevices : null);
|
|
425
|
+
if (!mediaDevices || typeof mediaDevices.getDisplayMedia !== 'function') {
|
|
426
|
+
return {
|
|
427
|
+
ok: false,
|
|
428
|
+
error: 'Screen capture is unavailable in this browser.',
|
|
429
|
+
stream: null,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const stream: MediaStream = await mediaDevices.getDisplayMedia({
|
|
433
|
+
...constraints,
|
|
434
|
+
...(withAudio ? { audio: true } : {}),
|
|
435
|
+
});
|
|
436
|
+
const result = await produceMedia({ parameters, stream, kind: 'screen' });
|
|
437
|
+
if (!result.ok) {
|
|
438
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
439
|
+
return { ...result, stream: null };
|
|
440
|
+
}
|
|
441
|
+
if (withAudio && hasLiveTrack(stream, 'audio')) {
|
|
442
|
+
await produceMedia({ parameters, stream, kind: 'audio' });
|
|
443
|
+
}
|
|
444
|
+
return { ...result, stream };
|
|
445
|
+
} catch (error: any) {
|
|
446
|
+
// A user dismissing the picker rejects here; that is not an error worth shouting about.
|
|
447
|
+
const name = error?.name || '';
|
|
448
|
+
if (name === 'NotAllowedError' || name === 'AbortError') {
|
|
449
|
+
return { ok: false, error: 'Screen sharing was cancelled.', stream: null };
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
ok: false,
|
|
453
|
+
error: error?.message || 'The screen could not be shared.',
|
|
454
|
+
stream: null,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export interface ReplaceProducerTrackOptions extends HeadlessOptions {
|
|
460
|
+
/** The replacement track. Its kind decides which producer is swapped. */
|
|
461
|
+
track: MediaStreamTrack;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export type ReplaceProducerTrackType = (
|
|
465
|
+
options: ReplaceProducerTrackOptions
|
|
466
|
+
) => Promise<HeadlessActionResult>;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Swap the track on a live producer without renegotiating.
|
|
470
|
+
*
|
|
471
|
+
* This is the seamless path for switching camera, applying or removing a
|
|
472
|
+
* background effect, or moving between media sources: remote participants see
|
|
473
|
+
* no interruption, because the producer and its transport stay up.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* const processed = applyBackgroundBlur(cameraTrack);
|
|
478
|
+
* await replaceProducerTrack({ parameters, track: processed });
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
export async function replaceProducerTrack({
|
|
482
|
+
parameters,
|
|
483
|
+
track,
|
|
484
|
+
}: ReplaceProducerTrackOptions): Promise<HeadlessActionResult> {
|
|
485
|
+
try {
|
|
486
|
+
if (!track || track.readyState !== 'live') {
|
|
487
|
+
return { ok: false, error: 'The replacement track is not live.' };
|
|
488
|
+
}
|
|
489
|
+
const live = getCurrentParams({ parameters });
|
|
490
|
+
const producer =
|
|
491
|
+
track.kind === 'audio'
|
|
492
|
+
? live.audioProducer || live.localAudioProducer
|
|
493
|
+
: live.videoProducer || live.localVideoProducer;
|
|
494
|
+
if (!producer || typeof producer.replaceTrack !== 'function') {
|
|
495
|
+
return {
|
|
496
|
+
ok: false,
|
|
497
|
+
error: `There is no live ${track.kind} producer to replace.`,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
await producer.replaceTrack({ track });
|
|
501
|
+
return { ok: true, error: '' };
|
|
502
|
+
} catch (error: any) {
|
|
503
|
+
return { ok: false, error: error?.message || 'The track could not be replaced.' };
|
|
504
|
+
}
|
|
505
|
+
}
|