@ -8,6 +8,7 @@ import { shouldShowModeratedNotification } from '../../av-moderation/functions';
import { hideNotification , isModerationNotificationDisplayed } from '../../notifications' ;
import { isPrejoinPageVisible } from '../../prejoin/functions' ;
import { getCurrentConference } from '../conference/functions' ;
import { getMultipleVideoSupportFeatureFlag } from '../config' ;
import { getAvailableDevices } from '../devices/actions' ;
import {
CAMERA _FACING _MODE ,
@ -18,15 +19,20 @@ import {
VIDEO _MUTISM _AUTHORITY ,
TOGGLE _CAMERA _FACING _MODE ,
toggleCameraFacingMode ,
VIDEO _TYPE
SET _SCREENSHARE _MUTED ,
VIDEO _TYPE ,
setScreenshareMuted ,
SCREENSHARE _MUTISM _AUTHORITY
} from '../media' ;
import { MiddlewareRegistry , StateListenerRegistry } from '../redux' ;
import {
TRACK _ADDED ,
TOGGLE _SCREENSHARING ,
TRACK _ADDED ,
TRACK _MUTE _UNMUTE _FAILED ,
TRACK _NO _DATA _FROM _SOURCE ,
TRACK _REMOVED ,
TRACK _STOPPED ,
TRACK _UPDATED
} from './actionTypes' ;
import {
@ -34,6 +40,7 @@ import {
destroyLocalTracks ,
showNoDataFromSourceVideoError ,
toggleScreensharing ,
trackMuteUnmuteFailed ,
trackRemoved ,
trackNoDataFromSourceNotificationInfoChanged
} from './actions' ;
@ -107,6 +114,10 @@ MiddlewareRegistry.register(store => next => action => {
break ;
}
case SET _SCREENSHARE _MUTED :
_setMuted ( store , action , action . mediaType ) ;
break ;
case SET _VIDEO _MUTED :
if ( ! action . muted
&& isUserInteractionRequiredForUnmute ( store . getState ( ) ) ) {
@ -156,19 +167,54 @@ MiddlewareRegistry.register(store => next => action => {
const { enabled , audioOnly , ignoreDidHaveVideo } = action ;
APP . UI . emitEvent ( UIEvents . TOGGLE _SCREENSHARING , { enabled ,
if ( ! getMultipleVideoSupportFeatureFlag ( store . getState ( ) ) ) {
APP . UI . emitEvent ( UIEvents . TOGGLE _SCREENSHARING ,
{
enabled ,
audioOnly ,
ignoreDidHaveVideo } ) ;
ignoreDidHaveVideo
} ) ;
}
}
break ;
case TRACK _MUTE _UNMUTE _FAILED : {
const { jitsiTrack } = action . track ;
const muted = action . wasMuted ;
const isVideoTrack = jitsiTrack . getType ( ) !== MEDIA _TYPE . AUDIO ;
if ( typeof APP !== 'undefined' ) {
if ( isVideoTrack && jitsiTrack . getVideoType ( ) === VIDEO _TYPE . DESKTOP
&& getMultipleVideoSupportFeatureFlag ( store . getState ( ) ) ) {
store . dispatch ( setScreenshareMuted ( ! muted ) ) ;
} else if ( isVideoTrack ) {
APP . conference . setVideoMuteStatus ( ) ;
} else {
APP . conference . setAudioMuteStatus ( ! muted ) ;
}
}
break ;
}
case TRACK _STOPPED : {
const { jitsiTrack } = action . track ;
if ( typeof APP !== 'undefined'
&& getMultipleVideoSupportFeatureFlag ( store . getState ( ) )
&& jitsiTrack . getVideoType ( ) === VIDEO _TYPE . DESKTOP ) {
store . dispatch ( toggleScreensharing ( false ) ) ;
}
break ;
}
case TRACK _UPDATED : {
// TODO Remove the following calls to APP.UI once components interested
// in track mute changes are moved into React and/or redux.
if ( typeof APP !== 'undefined' ) {
const result = next ( action ) ;
const state = store . getState ( ) ;
if ( isPrejoinPageVisible ( store . getState ( ) ) ) {
if ( isPrejoinPageVisible ( state ) ) {
return result ;
}
@ -181,10 +227,11 @@ MiddlewareRegistry.register(store => next => action => {
// Do not change the video mute state for local presenter tracks.
if ( jitsiTrack . type === MEDIA _TYPE . PRESENTER ) {
APP . conference . mutePresenter ( muted ) ;
} else if ( jitsiTrack . isLocal ( ) && ! ( jitsiTrack . videoType === VIDEO _TYPE . DESKTOP ) ) {
} else if ( jitsiTrack . isLocal ( ) && ! ( jitsiTrack . getVideoType ( ) === VIDEO _TYPE . DESKTOP ) ) {
APP . conference . setVideoMuteStatus ( ) ;
} else if ( jitsiTrack . isLocal ( ) && muted && jitsiTrack . videoType === VIDEO _TYPE . DESKTOP ) {
store . dispatch ( toggleScreensharing ( false , false , true ) ) ;
} else if ( jitsiTrack . isLocal ( ) && muted && jitsiTrack . getVideoType ( ) === VIDEO _TYPE . DESKTOP ) {
! getMultipleVideoSupportFeatureFlag ( state )
&& store . dispatch ( toggleScreensharing ( false , false , true ) ) ;
} else {
APP . UI . setVideoMuted ( participantID ) ;
}
@ -335,25 +382,34 @@ function _removeNoDataFromSourceNotification({ getState, dispatch }, track) {
* @ private
* @ returns { void }
* /
function _setMuted ( store , { ensureTrack , authority , muted } , mediaType : MEDIA _TYPE ) {
const localTrack
= _getLocalTrack ( store , mediaType , /* includePending */ true ) ;
async function _setMuted ( store , { ensureTrack , authority , muted } , mediaType : MEDIA _TYPE ) {
const { dispatch , getState } = store ;
const localTrack = _getLocalTrack ( store , mediaType , /* includePending */ true ) ;
const state = getState ( ) ;
if ( mediaType === MEDIA _TYPE . SCREENSHARE
&& getMultipleVideoSupportFeatureFlag ( state )
&& ! muted ) {
return ;
}
if ( localTrack ) {
// The `jitsiTrack` property will have a value only for a localTrack for
// which `getUserMedia` has already completed. If there's no
// `jitsiTrack`, then the `muted` state will be applied once the
// `jitsiTrack` is created.
// The `jitsiTrack` property will have a value only for a localTrack for which `getUserMedia` has already
// completed. If there's no `jitsiTrack`, then the `muted` state will be applied once the `jitsiTrack` is
// created.
const { jitsiTrack } = localTrack ;
const isAudioOnly = authority === VIDEO _MUTISM _AUTHORITY . AUDIO _ONLY ;
const isAudioOnly = ( mediaType === MEDIA _TYPE . VIDEO && authority === VIDEO _MUTISM _AUTHORITY . AUDIO _ONLY )
|| ( mediaType === MEDIA _TYPE . SCREENSHARE && authority === SCREENSHARE _MUTISM _AUTHORITY . AUDIO _ONLY ) ;
// screenshare cannot be muted or unmuted using the video mute button
// anymore, unless it is muted by audioOnly.
jitsiTrack && ( jitsiTrack . videoType !== 'desktop' || isAudioOnly )
&& setTrackMuted ( jitsiTrack , muted ) ;
} else if ( ! muted && ensureTrack && ( typeof APP === 'undefined' || isPrejoinPageVisible ( store . getState ( ) ) ) ) {
// Screenshare cannot be unmuted using the video mute button unless it is muted by audioOnly in the legacy
// screensharing mode.
if ( jitsiTrack
&& ( jitsiTrack . videoType !== 'desktop' || isAudioOnly || getMultipleVideoSupportFeatureFlag ( state ) ) ) {
setTrackMuted ( jitsiTrack , muted , state ) . catch ( ( ) => dispatch ( trackMuteUnmuteFailed ( localTrack , muted ) ) ) ;
}
} else if ( ! muted && ensureTrack && ( typeof APP === 'undefined' || isPrejoinPageVisible ( state ) ) ) {
// FIXME: This only runs on mobile now because web has its own way of
// creating local tracks. Adjust the check once they are unified.
store . dispatch ( createLocalTracksA ( { devices : [ mediaType ] } ) ) ;
dispatch ( createLocalTracksA ( { devices : [ mediaType ] } ) ) ;
}
}