@ -5,6 +5,7 @@ import {
JitsiParticipantConnectionStatus
} from '../../../react/features/base/lib-jitsi-meet' ;
import {
getParticipants ,
getPinnedParticipant ,
pinParticipant
} from '../../../react/features/base/participants' ;
@ -21,8 +22,6 @@ import LocalVideo from './LocalVideo';
const remoteVideos = { } ;
let localVideoThumbnail = null ;
let currentDominantSpeaker = null ;
let eventEmitter = null ;
let largeVideo ;
@ -43,6 +42,24 @@ function onLocalFlipXChanged(val) {
}
}
/ * *
* Returns the user ID of the remote participant that is current the dominant
* speaker .
*
* @ private
* @ returns { string | null }
* /
function getCurrentRemoteDominantSpeakerID ( ) {
const dominantSpeaker = getParticipants ( APP . store . getState )
. find ( participant => participant . dominantSpeaker ) ;
if ( dominantSpeaker ) {
return dominantSpeaker . local ? null : dominantSpeaker . id ;
}
return null ;
}
/ * *
* Returns the corresponding resource id to the given peer container
* DOM element .
@ -228,8 +245,8 @@ const VideoLayout = {
if ( pinnedId ) {
newId = pinnedId ;
} else if ( currentDominantSpeaker ) {
newId = currentDominantSpeaker ;
} else if ( getCurrentRemoteDominantSpeakerID ( ) ) {
newId = getCurrentRemoteDominantSpeakerID ( ) ;
} else { // Otherwise select last visible video
newId = this . electLastVisibleVideo ( ) ;
}
@ -392,8 +409,8 @@ const VideoLayout = {
this . pinParticipant ( null ) ;
// Enable the currently set dominant speaker.
if ( currentDominantSpeaker ) {
this . updateLargeVideo ( currentDominantSpeaker ) ;
if ( getCurrentRemoteDominantSpeakerID ( ) ) {
this . updateLargeVideo ( getCurrentRemoteDominantSpeakerID ( ) ) ;
} else {
// if there is no currentDominantSpeaker, it can also be
// that local participant is the dominant speaker
@ -501,11 +518,11 @@ const VideoLayout = {
const pinnedId = this . getPinnedId ( ) ;
if ( ( ! pinnedId
&& ! currentDominantSpeaker
&& ! getCurrentRemoteDominantSpeakerID ( )
&& this . isLargeContainerTypeVisible ( VIDEO _CONTAINER _TYPE ) )
|| pinnedId === resourceJid
|| ( ! pinnedId && resourceJid
&& currentDominantSpeaker === resourceJid )
&& getCurrentRemoteDominantSpeakerID ( ) === resourceJid )
/ * P l a y b a c k s t a r t e d w h i l e w e ' r e o n t h e s t a g e - m a y n e e d t o u p d a t e
video source with the new stream * /
@ -662,43 +679,22 @@ const VideoLayout = {
/ * *
* On dominant speaker changed event .
*
* @ param { string } id - The participant ID of the new dominant speaker .
* @ returns { void }
* /
onDominantSpeakerChanged ( id ) {
if ( id === currentDominantSpeaker ) {
return ;
}
const oldSpeakerRemoteVideo = remoteVideos [ currentDominantSpeaker ] ;
Object . values ( remoteVideos ) . forEach ( remoteVideo =>
remoteVideo . showDominantSpeakerIndicator (
id === remoteVideo . getId ( ) ) ) ;
// We ignore local user events, but just unmark remote user as dominant
// while we are talking
localVideoThumbnail . showDominantSpeakerIndicator (
APP . conference . isLocalId ( id ) ) ;
if ( APP . conference . isLocalId ( id ) ) {
if ( oldSpeakerRemoteVideo ) {
oldSpeakerRemoteVideo . showDominantSpeakerIndicator ( false ) ;
currentDominantSpeaker = null ;
}
localVideoThumbnail . showDominantSpeakerIndicator ( true ) ;
return ;
}
const remoteVideo = remoteVideos [ id ] ;
if ( ! remoteVideo ) {
if ( ! remoteVideos [ id ] ) {
return ;
}
// Update the current dominant speaker.
remoteVideo . showDominantSpeakerIndicator ( true ) ;
localVideoThumbnail . showDominantSpeakerIndicator ( false ) ;
// let's remove the indications from the remote video if any
if ( oldSpeakerRemoteVideo ) {
oldSpeakerRemoteVideo . showDominantSpeakerIndicator ( false ) ;
}
currentDominantSpeaker = id ;
// Local video will not have container found, but that's ok
// since we don't want to switch to local video.
if ( ! interfaceConfig . filmStripOnly && ! this . getPinnedId ( )
@ -804,11 +800,6 @@ const VideoLayout = {
this . pinParticipant ( null ) ;
}
if ( currentDominantSpeaker === id ) {
logger . info ( 'Dominant speaker has left the conference' ) ;
currentDominantSpeaker = null ;
}
const remoteVideo = remoteVideos [ id ] ;
if ( remoteVideo ) {