From bfd37bb087ff11f473eca3c91ec1853f9589159f Mon Sep 17 00:00:00 2001 From: Pawel Domas <2965063+paweldomas@users.noreply.github.com> Date: Thu, 12 Aug 2021 13:05:05 -0500 Subject: [PATCH] multiple video stream WiP --- conference.js | 20 +++++++++++++++++++- react/features/base/tracks/actions.js | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/conference.js b/conference.js index 3318225a9..a94ff8fa9 100644 --- a/conference.js +++ b/conference.js @@ -105,6 +105,7 @@ import { updateSettings } from './react/features/base/settings'; import { + addLocalTrack, createLocalPresenterTrack, createLocalTracksF, destroyLocalTracks, @@ -1911,7 +1912,24 @@ export default { if (desktopVideoStream) { logger.debug(`_switchToScreenSharing is using ${desktopVideoStream} for useVideoStream`); - await this.useVideoStream(desktopVideoStream); + await new Promise((resolve, reject) => { + _replaceLocalVideoTrackQueue.enqueue(onFinish => { + APP.store.dispatch( + addLocalTrack(desktopVideoStream)) + .then(() => { + this._setSharingScreen(desktopVideoStream); + + // TODO FIXME + // this.setVideoMuteStatus(); + }) + .then(resolve) + .catch(error => { + logger.error(`_switchToScreenSharing failed: ${error}`); + reject(error); + }) + .then(onFinish); + }); + }); } if (this._desktopAudioStream) { diff --git a/react/features/base/tracks/actions.js b/react/features/base/tracks/actions.js index 15bdc447b..056c19927 100644 --- a/react/features/base/tracks/actions.js +++ b/react/features/base/tracks/actions.js @@ -5,6 +5,7 @@ import { sendAnalytics } from '../../analytics'; import { NOTIFICATION_TIMEOUT_TYPE, showErrorNotification, showNotification } from '../../notifications'; +import { getCurrentConference } from '../conference'; import { JitsiTrackErrors, JitsiTrackEvents, createLocalTrack } from '../lib-jitsi-meet'; import { CAMERA_FACING_MODE, @@ -312,6 +313,19 @@ export function replaceLocalTrack(oldTrack, newTrack, conference) { }; } +// eslint-disable-next-line require-jsdoc +export function addLocalTrack(newTrack) { + return async (dispatch, getState) => { + const conference = getCurrentConference(getState()); + + if (conference) { + await conference.addTrack(newTrack); + } + + return dispatch(_addTracks([ newTrack ])); + }; +} + /** * Replaces a stored track with another. *