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.
* @returns {void}
*/
async function _toggleScreenSharing({ enabled, audioOnly = false }, store) {
async function _toggleScreenSharing({ enabled, audioOnly = false, shareOptions = {} }, store) {
const { dispatch, getState } = store;
const state = getState();
const audioOnlySharing = isAudioOnlySharing(state);
@ -185,9 +185,13 @@ async function _toggleScreenSharing({ enabled, audioOnly = false }, store) {
if (enable) {
let tracks;
const options = {
devices: [ VIDEO_TYPE.DESKTOP ],
...shareOptions
};
try {
tracks = await createLocalTracksF({ devices: [ VIDEO_TYPE.DESKTOP ] });
tracks = await createLocalTracksF(options);
} catch (error) {
_handleScreensharingError(error, store);

View File

@ -297,25 +297,27 @@ export function showNoDataFromSourceVideoError(jitsiTrack) {
}
/**
* Signals that the local participant is ending screensharing or beginning the
* screensharing flow.
* Signals that the local participant is ending screensharing or beginning the screensharing flow.
*
* @param {boolean} enabled - The state to toggle screen sharing to.
* @param {boolean} audioOnly - Only share system audio.
* @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 {{
* type: TOGGLE_SCREENSHARING,
* on: 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 {
type: TOGGLE_SCREENSHARING,
enabled,
audioOnly,
ignoreDidHaveVideo
ignoreDidHaveVideo,
shareOptions
};
}

View File

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