Skip to content

Commit

Permalink
fix(media) Deprecate startScreenSharing config option for web browsers.
Browse files Browse the repository at this point in the history
This is no longer supported as per the w3c spec for getDisplayMedia.
  • Loading branch information
jallamsetty1 committed Jan 25, 2022
1 parent b3c4fb6 commit 64322db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
51 changes: 26 additions & 25 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@ export default {

// Always get a handle on the audio input device so that we have statistics (such as "No audio input" or
// "Are you trying to speak?" ) even if the user joins the conference muted.
const initialDevices = config.disableInitialGUM ? [] : [ 'audio' ];
const initialDevices = config.disableInitialGUM ? [] : [ MEDIA_TYPE.AUDIO ];
const requestedAudio = !config.disableInitialGUM;
let requestedVideo = false;

if (!config.disableInitialGUM
&& !options.startWithVideoMuted
&& !options.startAudioOnly
&& !options.startScreenSharing) {
initialDevices.push('video');
initialDevices.push(MEDIA_TYPE.VIDEO);
requestedVideo = true;
}

Expand All @@ -518,21 +518,35 @@ export default {
// spend much time displaying the overlay screen. If GUM is not resolved within 15 seconds it will
// probably never resolve.
const timeout = browser.isElectron() ? 15000 : 60000;
const audioOptions = {
devices: [ MEDIA_TYPE.AUDIO ],
timeout,
firePermissionPromptIsShownEvent: true,
fireSlowPromiseEvent: true
};

// FIXME is there any simpler way to rewrite this spaghetti below ?
if (options.startScreenSharing) {
tryCreateLocalTracks = this._createDesktopTrack()
// This option has been deprecated since it is no longer supported as per the w3c spec.
// https://w3c.github.io/mediacapture-screen-share/#dom-mediadevices-getdisplaymedia. If the user has not
// interacted with the webpage before the getDisplayMedia call, the promise will be rejected by the
// browser. This has already been implemented in Firefox and Safari and will be implemented in Chrome soon.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1198918
// Please note that Spot uses the same config option to use an external video input device label as
// screenshare and calls getUserMedia instead of getDisplayMedia for capturing the media. Therefore it
// needs to be supported here if _desktopSharingSourceDevice is provided.
const errMessage = new Error('startScreenSharing config option is no longer supported for web browsers');
const desktopPromise = config._desktopSharingSourceDevice
? this._createDesktopTrack()
: Promise.reject(errMessage);

tryCreateLocalTracks = desktopPromise
.then(([ desktopStream ]) => {
if (!requestedAudio) {
return [ desktopStream ];
}

return createLocalTracksF({
devices: [ 'audio' ],
timeout,
firePermissionPromptIsShownEvent: true,
fireSlowPromiseEvent: true
})
return createLocalTracksF(audioOptions)
.then(([ audioStream ]) =>
[ desktopStream, audioStream ])
.catch(error => {
Expand All @@ -545,14 +559,7 @@ export default {
logger.error('Failed to obtain desktop stream', error);
errors.screenSharingError = error;

return requestedAudio
? createLocalTracksF({
devices: [ 'audio' ],
timeout,
firePermissionPromptIsShownEvent: true,
fireSlowPromiseEvent: true
})
: [];
return requestedAudio ? createLocalTracksF(audioOptions) : [];
})
.catch(error => {
errors.audioOnlyError = error;
Expand Down Expand Up @@ -587,13 +594,7 @@ export default {
return [];
}

return (
createLocalTracksF({
devices: [ 'audio' ],
timeout,
firePermissionPromptIsShownEvent: true,
fireSlowPromiseEvent: true
}));
return createLocalTracksF(audioOptions);
} else if (requestedAudio && !requestedVideo) {
errors.audioOnlyError = err;

Expand All @@ -615,7 +616,7 @@ export default {
// Try video only...
return requestedVideo
? createLocalTracksF({
devices: [ 'video' ],
devices: [ MEDIA_TYPE.VIDEO ],
firePermissionPromptIsShownEvent: true,
fireSlowPromiseEvent: true
})
Expand Down
6 changes: 5 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ var config = {
// max: 5
// },

// Try to start calls with screen-sharing instead of camera video.
// This option has been deprecated since it is no longer supported as per the w3c spec.
// https://w3c.github.io/mediacapture-screen-share/#dom-mediadevices-getdisplaymedia. If the user has not
// interacted with the webpage before the getDisplayMedia call, the promise will be rejected by the browser. This
// has already been implemented in Firefox and Safari and will be implemented in Chrome soon.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1198918
// startScreenSharing: false,

// Recording
Expand Down

0 comments on commit 64322db

Please sign in to comment.