2022-08-05 15:23:03 +00:00
|
|
|
import {
|
|
|
|
getParticipantById,
|
|
|
|
getVirtualScreenshareParticipantByOwnerId,
|
2022-10-06 11:12:57 +00:00
|
|
|
getVirtualScreenshareParticipantOwnerId,
|
|
|
|
isScreenShareParticipant
|
2022-11-28 10:52:24 +00:00
|
|
|
} from '../base/participants/functions';
|
|
|
|
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
|
2020-11-14 04:09:25 +00:00
|
|
|
|
2022-09-27 07:10:28 +00:00
|
|
|
import { pause, resume } from './actions';
|
2020-11-14 04:09:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listens for large video participant ID changes.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
2022-11-28 10:52:24 +00:00
|
|
|
const { participantId = '' } = state['features/large-video'];
|
2020-11-14 04:09:25 +00:00
|
|
|
const { controller } = state['features/remote-control'];
|
|
|
|
const { controlled } = controller;
|
|
|
|
|
|
|
|
if (!controlled) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2022-08-05 15:23:03 +00:00
|
|
|
const participant = getParticipantById(state, participantId);
|
|
|
|
|
2022-10-06 11:12:57 +00:00
|
|
|
if (isScreenShareParticipant(participant)) {
|
2022-08-05 15:23:03 +00:00
|
|
|
// multistream support is enabled and the user has selected the desktop sharing thumbnail.
|
|
|
|
const id = getVirtualScreenshareParticipantOwnerId(participantId);
|
|
|
|
|
|
|
|
return id === controlled;
|
|
|
|
}
|
|
|
|
|
|
|
|
const virtualParticipant = getVirtualScreenshareParticipantByOwnerId(state, participantId);
|
|
|
|
|
|
|
|
if (virtualParticipant) { // multistream is enabled and the user has selected the camera thumbnail.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-11-14 04:09:25 +00:00
|
|
|
return controlled === participantId;
|
|
|
|
},
|
|
|
|
/* listener */ (isControlledParticipantOnStage, { dispatch }) => {
|
|
|
|
if (isControlledParticipantOnStage === true) {
|
|
|
|
dispatch(resume());
|
|
|
|
} else if (isControlledParticipantOnStage === false) {
|
|
|
|
dispatch(pause());
|
|
|
|
}
|
|
|
|
|
|
|
|
// else {
|
|
|
|
// isControlledParticipantOnStage === undefined. Ignore!
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
);
|