From 67ec7987581496c69b3058e632b7d78c9af08d2e Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Wed, 8 Dec 2021 22:53:12 +0000 Subject: [PATCH] feat(webcams): preserve floor holder's original camera profile --- .../components/video-provider/component.jsx | 19 ++++++++++++++----- .../video-provider/stream-sorting.js | 6 +++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx b/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx index d85dd782f2..58c38245fc 100755 --- a/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx @@ -251,14 +251,23 @@ class VideoProvider extends Component { this.setState({ socketOpen: true }); } - updateThreshold(numberOfPublishers) { + findAllPrivilegedStreams () { + const { streams } = this.props; + // Privileged streams are: floor holders + return streams.filter(stream => stream.floor); + } + + updateQualityThresholds(numberOfPublishers) { const { threshold, profile } = VideoService.getThreshold(numberOfPublishers); if (profile) { - const publishers = Object.values(this.webRtcPeers) + const privilegedStreams = this.findAllPrivilegedStreams(); + Object.values(this.webRtcPeers) .filter(peer => peer.isPublisher) .forEach((peer) => { - // 0 means no threshold in place. Reapply original one if needed - const profileToApply = (threshold === 0) ? peer.originalProfileId : profile; + // 1) Threshold 0 means original profile/inactive constraint + // 2) Privileged streams are: floor holders + const exempt = threshold === 0 || privilegedStreams.some(vs => vs.stream === peer.stream) + const profileToApply = exempt ? peer.originalProfileId : profile; VideoService.applyCameraProfile(peer, profileToApply); }); } @@ -302,7 +311,7 @@ class VideoProvider extends Component { this.disconnectStreams(streamsToDisconnect); if (CAMERA_QUALITY_THRESHOLDS_ENABLED) { - this.updateThreshold(this.props.totalNumberOfStreams); + this.updateQualityThresholds(this.props.totalNumberOfStreams); } } diff --git a/bigbluebutton-html5/imports/ui/components/video-provider/stream-sorting.js b/bigbluebutton-html5/imports/ui/components/video-provider/stream-sorting.js index 0c69393330..e27a0111db 100644 --- a/bigbluebutton-html5/imports/ui/components/video-provider/stream-sorting.js +++ b/bigbluebutton-html5/imports/ui/components/video-provider/stream-sorting.js @@ -75,7 +75,10 @@ export const sortLocalPresenterAlphabetical = (s1, s2) => { // 1.1.: the sorting function has the same behaviour as a regular .sort callback // 2 - add an entry to SORTING_METHODS, the key being the name to be used // in settings.yml and the value object like the aforementioned -const MANDATORY_DATA_TYPES = { userId: 1, stream: 1, name: 1, deviceId: 1, }; +const MANDATORY_DATA_TYPES = { + userId: 1, stream: 1, name: 1, deviceId: 1, floor: 1, +}; + const SORTING_METHODS = Object.freeze({ // Default LOCAL_ALPHABETICAL: { @@ -120,5 +123,6 @@ export const sortVideoStreams = (streams, mode) => { stream: videoStream.stream, userId: videoStream.userId, name: videoStream.name, + floor: videoStream.floor, })); };