@ -3,8 +3,11 @@
import debounce from 'lodash/debounce' ;
import { _handleParticipantError } from '../base/conference' ;
import { getParticipantCount } from '../base/participants' ;
import { getSourceNameSignalingFeatureFlag } from '../base/config' ;
import { MEDIA _TYPE } from '../base/media' ;
import { getLocalParticipant , getParticipantCount } from '../base/participants' ;
import { StateListenerRegistry } from '../base/redux' ;
import { getTrackSourceNameByMediaTypeAndParticipant } from '../base/tracks' ;
import { reportError } from '../base/util' ;
import { shouldDisplayTileView } from '../video-layout' ;
@ -193,43 +196,107 @@ function _updateReceiverVideoConstraints({ getState }) {
const maxFrameHeight = Math . min ( maxReceiverVideoQuality , preferredVideoQuality ) ;
const { remoteScreenShares } = state [ 'features/video-layout' ] ;
const { visibleRemoteParticipants } = state [ 'features/filmstrip' ] ;
const tracks = state [ 'features/base/tracks' ] ;
const sourceNameSignaling = getSourceNameSignalingFeatureFlag ( state ) ;
const localParticipantId = getLocalParticipant ( state ) . id ;
const receiverConstraints = {
constraints : { } ,
defaultConstraints : { 'maxHeight' : VIDEO _QUALITY _LEVELS . NONE } ,
lastN ,
onStageEndpoints : [ ] ,
selectedEndpoints : [ ]
... sourceNameSignaling ? { onStageSources : [ ] } : { onStageEndpoints : [ ] } ,
... sourceNameSignaling ? { selectedSources : [ ] } : { selectedEndpoints : [ ] }
} ;
// Tile view.
if ( shouldDisplayTileView ( state ) ) {
if ( ! visibleRemoteParticipants ? . size ) {
return ;
if ( sourceNameSignaling ) {
const visibleRemoteTrackSourceNames = [ ] ;
let largeVideoSourceName ;
if ( visibleRemoteParticipants ? . size ) {
visibleRemoteParticipants . forEach ( participantId => {
const sourceName = getTrackSourceNameByMediaTypeAndParticipant ( tracks , MEDIA _TYPE . VIDEO , participantId ) ;
if ( sourceName ) {
visibleRemoteTrackSourceNames . push ( sourceName ) ;
}
} ) ;
}
visibleRemoteParticipants . forEach ( participantId => {
receiverConstraints . constraints [ participantId ] = { 'maxHeight' : maxFrameHeight } ;
} ) ;
if ( localParticipantId !== largeVideoParticipantId ) {
largeVideoSourceName = getTrackSourceNameByMediaTypeAndParticipant (
tracks , MEDIA _TYPE . VIDEO ,
largeVideoParticipantId
) ;
}
// Prioritize screenshare in tile view.
remoteScreenShares ? . length && ( receiverConstraints . selectedEndpoints = remoteScreenShares ) ;
// Tile view.
if ( shouldDisplayTileView ( state ) ) {
if ( ! visibleRemoteTrackSourceNames ? . length ) {
return ;
}
// Stage view.
} else {
if ( ! visibleRemoteParticipants ? . size && ! largeVideoParticipantId ) {
return ;
visibleRemoteTrackSourceNames . forEach ( sourceName => {
receiverConstraints . constraints [ sourceName ] = { 'maxHeight' : maxFrameHeight } ;
} ) ;
// Prioritize screenshare in tile view.
if ( remoteScreenShares ? . length ) {
const remoteScreenShareSourceNames = remoteScreenShares . map ( remoteScreenShare =>
getTrackSourceNameByMediaTypeAndParticipant ( tracks , MEDIA _TYPE . VIDEO , remoteScreenShare )
) ;
receiverConstraints . selectedSources = remoteScreenShareSourceNames ;
}
// Stage view.
} else {
if ( ! visibleRemoteTrackSourceNames ? . length && ! largeVideoSourceName ) {
return ;
}
if ( visibleRemoteTrackSourceNames ? . length ) {
visibleRemoteTrackSourceNames . forEach ( sourceName => {
receiverConstraints . constraints [ sourceName ] = { 'maxHeight' : VIDEO _QUALITY _LEVELS . LOW } ;
} ) ;
}
if ( largeVideoSourceName ) {
receiverConstraints . constraints [ largeVideoSourceName ] = { 'maxHeight' : maxFrameHeight } ;
receiverConstraints . onStageSources = [ largeVideoSourceName ] ;
}
}
if ( visibleRemoteParticipants ? . size > 0 ) {
} else {
// Tile view.
// eslint-disable-next-line no-lonely-if
if ( shouldDisplayTileView ( state ) ) {
if ( ! visibleRemoteParticipants ? . size ) {
return ;
}
visibleRemoteParticipants . forEach ( participantId => {
receiverConstraints . constraints [ participantId ] = { 'maxHeight' : VIDEO _QUALITY _LEVELS . LOW } ;
receiverConstraints . constraints [ participantId ] = { 'maxHeight' : maxFrameHeight } ;
} ) ;
}
if ( largeVideoParticipantId ) {
receiverConstraints . constraints [ largeVideoParticipantId ] = { 'maxHeight' : maxFrameHeight } ;
receiverConstraints . onStageEndpoints = [ largeVideoParticipantId ] ;
// Prioritize screenshare in tile view.
remoteScreenShares ? . length && ( receiverConstraints . selectedEndpoints = remoteScreenShares ) ;
// Stage view.
} else {
if ( ! visibleRemoteParticipants ? . size && ! largeVideoParticipantId ) {
return ;
}
if ( visibleRemoteParticipants ? . size > 0 ) {
visibleRemoteParticipants . forEach ( participantId => {
receiverConstraints . constraints [ participantId ] = { 'maxHeight' : VIDEO _QUALITY _LEVELS . LOW } ;
} ) ;
}
if ( largeVideoParticipantId ) {
receiverConstraints . constraints [ largeVideoParticipantId ] = { 'maxHeight' : maxFrameHeight } ;
receiverConstraints . onStageEndpoints = [ largeVideoParticipantId ] ;
}
}
}