diff --git a/modules/qualitycontrol/SendVideoController.js b/modules/qualitycontrol/SendVideoController.js index aac13e95c7..072b93c5a6 100644 --- a/modules/qualitycontrol/SendVideoController.js +++ b/modules/qualitycontrol/SendVideoController.js @@ -6,6 +6,7 @@ import FeatureFlags from '../flags/FeatureFlags'; import MediaSessionEvents from '../xmpp/MediaSessionEvents'; const logger = getLogger(__filename); +const MAX_LOCAL_RESOLUTION = 2160; /** * The class manages send video constraints across media sessions({@link JingleSessionPC}) which belong to @@ -24,6 +25,7 @@ export default class SendVideoController { */ constructor(conference, rtc) { this._conference = conference; + this._preferredSendMaxFrameHeight = MAX_LOCAL_RESOLUTION; this._rtc = rtc; /** @@ -37,12 +39,30 @@ export default class SendVideoController { session => this._onMediaSessionStarted(session)); this._conference.on( JitsiConferenceEvents._MEDIA_SESSION_ACTIVE_CHANGED, - () => this._propagateSendMaxFrameHeight()); + () => this._configureConstraintsForLocalSources()); this._rtc.on( RTCEvents.SENDER_VIDEO_CONSTRAINTS_CHANGED, videoConstraints => this._onSenderConstraintsReceived(videoConstraints)); } + /** + * Configures the video encodings on the local sources when a media connection is established or becomes active. + * + * @returns {Promise} + * @private + */ + _configureConstraintsForLocalSources() { + if (FeatureFlags.isSourceNameSignalingEnabled()) { + for (const track of this._rtc.getLocalVideoTracks()) { + const sourceName = track.getSourceName(); + + sourceName && this._propagateSendMaxFrameHeight(sourceName); + } + } else { + this._propagateSendMaxFrameHeight(); + } + } + /** * Handles the {@link JitsiConferenceEvents.MEDIA_SESSION_STARTED}, that is when the conference creates new media * session. It doesn't mean it's already active though. For example the JVB connection may be created after @@ -56,7 +76,7 @@ export default class SendVideoController { MediaSessionEvents.REMOTE_VIDEO_CONSTRAINTS_CHANGED, session => { if (session === this._conference.getActiveMediaSession()) { - this._propagateSendMaxFrameHeight(); + this._configureConstraintsForLocalSources(); } }); } @@ -65,6 +85,8 @@ export default class SendVideoController { * Propagates the video constraints if they have changed. * * @param {Object} videoConstraints - The sender video constraints received from the bridge. + * @returns {Promise} + * @private */ _onSenderConstraintsReceived(videoConstraints) { if (FeatureFlags.isSourceNameSignalingEnabled()) { @@ -88,7 +110,7 @@ export default class SendVideoController { } /** - * Figures out the send video constraint as specified by {@link selectSendMaxFrameHeight} and sets it on all media + * Figures out the send video constraint as specified by {@link _selectSendMaxFrameHeight} and sets it on all media * sessions for the reasons mentioned in this class description. * * @param {string} sourceName - The source for which sender constraints have changed. @@ -99,7 +121,7 @@ export default class SendVideoController { if (FeatureFlags.isSourceNameSignalingEnabled() && !sourceName) { throw new Error('sourceName missing for calculating the sendMaxHeight for video tracks'); } - const sendMaxFrameHeight = this.selectSendMaxFrameHeight(sourceName); + const sendMaxFrameHeight = this._selectSendMaxFrameHeight(sourceName); const promises = []; if (sendMaxFrameHeight >= 0) { @@ -117,8 +139,9 @@ export default class SendVideoController { * * @param {string} sourceName - The source for which sender constraints have changed. * @returns {number|undefined} + * @private */ - selectSendMaxFrameHeight(sourceName = null) { + _selectSendMaxFrameHeight(sourceName = null) { if (FeatureFlags.isSourceNameSignalingEnabled() && !sourceName) { throw new Error('sourceName missing for calculating the sendMaxHeight for video tracks'); } diff --git a/types/auto/modules/qualitycontrol/SendVideoController.d.ts b/types/auto/modules/qualitycontrol/SendVideoController.d.ts index 5aa93d6af6..4e62c3ad47 100644 --- a/types/auto/modules/qualitycontrol/SendVideoController.d.ts +++ b/types/auto/modules/qualitycontrol/SendVideoController.d.ts @@ -15,12 +15,20 @@ export default class SendVideoController { */ constructor(conference: any, rtc: any); _conference: any; + _preferredSendMaxFrameHeight: number; _rtc: any; /** * Source name based sender constraints. * @type {Map}; */ _sourceSenderConstraints: Map; + /** + * Configures the video encodings on the local sources when a media connection is established or becomes active. + * + * @returns {Promise} + * @private + */ + private _configureConstraintsForLocalSources; /** * Handles the {@link JitsiConferenceEvents.MEDIA_SESSION_STARTED}, that is when the conference creates new media * session. It doesn't mean it's already active though. For example the JVB connection may be created after @@ -34,11 +42,13 @@ export default class SendVideoController { * Propagates the video constraints if they have changed. * * @param {Object} videoConstraints - The sender video constraints received from the bridge. + * @returns {Promise} + * @private */ - _onSenderConstraintsReceived(videoConstraints: any): void; + private _onSenderConstraintsReceived; _senderVideoConstraints: any; /** - * Figures out the send video constraint as specified by {@link selectSendMaxFrameHeight} and sets it on all media + * Figures out the send video constraint as specified by {@link _selectSendMaxFrameHeight} and sets it on all media * sessions for the reasons mentioned in this class description. * * @param {string} sourceName - The source for which sender constraints have changed. @@ -52,8 +62,9 @@ export default class SendVideoController { * * @param {string} sourceName - The source for which sender constraints have changed. * @returns {number|undefined} + * @private */ - selectSendMaxFrameHeight(sourceName?: string): number | undefined; + private _selectSendMaxFrameHeight; /** * Sets local preference for max send video frame height. * @@ -61,5 +72,4 @@ export default class SendVideoController { * @returns {Promise} - resolved when the operation is complete. */ setPreferredSendMaxFrameHeight(maxFrameHeight: number): Promise; - _preferredSendMaxFrameHeight: number; }