fix(remote-control): fix remote-control when multi-stream is enabled.

This commit is contained in:
Jaya Allamsetty 2022-08-04 09:38:50 -04:00
parent 0f57c37d6a
commit 4d41d36020
3 changed files with 28 additions and 10 deletions

View File

@ -166,7 +166,7 @@ async function _maybeApplyAudioMixerEffect(desktopAudioTrack, state) {
* @param {Store} store - The redux store. * @param {Store} store - The redux store.
* @returns {void} * @returns {void}
*/ */
async function _toggleScreenSharing({ enabled, audioOnly = false }, store) { async function _toggleScreenSharing({ enabled, audioOnly = false, shareOptions = {} }, store) {
const { dispatch, getState } = store; const { dispatch, getState } = store;
const state = getState(); const state = getState();
const audioOnlySharing = isAudioOnlySharing(state); const audioOnlySharing = isAudioOnlySharing(state);
@ -185,9 +185,13 @@ async function _toggleScreenSharing({ enabled, audioOnly = false }, store) {
if (enable) { if (enable) {
let tracks; let tracks;
const options = {
devices: [ VIDEO_TYPE.DESKTOP ],
...shareOptions
};
try { try {
tracks = await createLocalTracksF({ devices: [ VIDEO_TYPE.DESKTOP ] }); tracks = await createLocalTracksF(options);
} catch (error) { } catch (error) {
_handleScreensharingError(error, store); _handleScreensharingError(error, store);

View File

@ -297,25 +297,27 @@ export function showNoDataFromSourceVideoError(jitsiTrack) {
} }
/** /**
* Signals that the local participant is ending screensharing or beginning the * Signals that the local participant is ending screensharing or beginning the screensharing flow.
* screensharing flow.
* *
* @param {boolean} enabled - The state to toggle screen sharing to. * @param {boolean} enabled - The state to toggle screen sharing to.
* @param {boolean} audioOnly - Only share system audio. * @param {boolean} audioOnly - Only share system audio.
* @param {boolean} ignoreDidHaveVideo - Whether or not to ignore if video was on when sharing started. * @param {boolean} ignoreDidHaveVideo - Whether or not to ignore if video was on when sharing started.
* @param {Object} shareOptions - The options to be passed for capturing screenshare.
* @returns {{ * @returns {{
* type: TOGGLE_SCREENSHARING, * type: TOGGLE_SCREENSHARING,
* on: boolean, * on: boolean,
* audioOnly: boolean, * audioOnly: boolean,
* ignoreDidHaveVideo: boolean * ignoreDidHaveVideo: boolean,
* shareOptions: Object
* }} * }}
*/ */
export function toggleScreensharing(enabled, audioOnly = false, ignoreDidHaveVideo = false) { export function toggleScreensharing(enabled, audioOnly = false, ignoreDidHaveVideo = false, shareOptions = {}) {
return { return {
type: TOGGLE_SCREENSHARING, type: TOGGLE_SCREENSHARING,
enabled, enabled,
audioOnly, audioOnly,
ignoreDidHaveVideo ignoreDidHaveVideo,
shareOptions
}; };
} }

View File

@ -1,9 +1,10 @@
// @flow // @flow
import { getMultipleVideoSendingSupportFeatureFlag } from '../base/config/functions.any';
import { openDialog } from '../base/dialog'; import { openDialog } from '../base/dialog';
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet'; import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import { getParticipantDisplayName, getPinnedParticipant, pinParticipant } from '../base/participants'; import { getParticipantDisplayName, getPinnedParticipant, pinParticipant } from '../base/participants';
import { getLocalVideoTrack } from '../base/tracks'; import { getLocalDesktopTrack, getLocalVideoTrack, toggleScreensharing } from '../base/tracks';
import { NOTIFICATION_TIMEOUT_TYPE, showNotification } from '../notifications'; import { NOTIFICATION_TIMEOUT_TYPE, showNotification } from '../notifications';
import { import {
@ -500,7 +501,9 @@ export function sendStartRequest() {
return (dispatch: Function, getState: Function) => { return (dispatch: Function, getState: Function) => {
const state = getState(); const state = getState();
const tracks = state['features/base/tracks']; const tracks = state['features/base/tracks'];
const track = getLocalVideoTrack(tracks); const track = getMultipleVideoSendingSupportFeatureFlag(state)
? getLocalDesktopTrack(tracks)
: getLocalVideoTrack(tracks);
const { sourceId } = track?.jitsiTrack || {}; const { sourceId } = track?.jitsiTrack || {};
const { transport } = state['features/remote-control'].receiver; const { transport } = state['features/remote-control'].receiver;
@ -530,12 +533,21 @@ export function grant(participantId: string) {
let promise; let promise;
const state = getState(); const state = getState();
const tracks = state['features/base/tracks']; const tracks = state['features/base/tracks'];
const track = getLocalVideoTrack(tracks); const isMultiStreamSupportEnabled = getMultipleVideoSendingSupportFeatureFlag(state);
const track = isMultiStreamSupportEnabled ? getLocalDesktopTrack(tracks) : getLocalVideoTrack(tracks);
const isScreenSharing = track?.videoType === 'desktop'; const isScreenSharing = track?.videoType === 'desktop';
const { sourceType } = track?.jitsiTrack || {}; const { sourceType } = track?.jitsiTrack || {};
if (isScreenSharing && sourceType === 'screen') { if (isScreenSharing && sourceType === 'screen') {
promise = dispatch(sendStartRequest()); promise = dispatch(sendStartRequest());
} else if (isMultiStreamSupportEnabled) {
promise = dispatch(toggleScreensharing(
true,
false,
true,
{ desktopSharingSources: [ 'screen' ] }
))
.then(() => dispatch(sendStartRequest()));
} else { } else {
// FIXME: Use action here once toggleScreenSharing is moved to redux. // FIXME: Use action here once toggleScreenSharing is moved to redux.
promise = APP.conference.toggleScreenSharing( promise = APP.conference.toggleScreenSharing(