Pārlūkot izejas kodu

fix(media) Deprecate startScreenSharing config option for web browsers.

This is no longer supported as per the w3c spec for getDisplayMedia.
master
Jaya Allamsetty 3 gadus atpakaļ
vecāks
revīzija
64322db56a
2 mainītis faili ar 31 papildinājumiem un 26 dzēšanām
  1. 26
    25
      conference.js
  2. 5
    1
      config.js

+ 26
- 25
conference.js Parādīt failu

@@ -486,7 +486,7 @@ export default {
486 486
 
487 487
         // Always get a handle on the audio input device so that we have statistics (such as "No audio input" or
488 488
         // "Are you trying to speak?" ) even if the user joins the conference muted.
489
-        const initialDevices = config.disableInitialGUM ? [] : [ 'audio' ];
489
+        const initialDevices = config.disableInitialGUM ? [] : [ MEDIA_TYPE.AUDIO ];
490 490
         const requestedAudio = !config.disableInitialGUM;
491 491
         let requestedVideo = false;
492 492
 
@@ -494,7 +494,7 @@ export default {
494 494
                 && !options.startWithVideoMuted
495 495
                 && !options.startAudioOnly
496 496
                 && !options.startScreenSharing) {
497
-            initialDevices.push('video');
497
+            initialDevices.push(MEDIA_TYPE.VIDEO);
498 498
             requestedVideo = true;
499 499
         }
500 500
 
@@ -518,21 +518,35 @@ export default {
518 518
         // spend much time displaying the overlay screen. If GUM is not resolved within 15 seconds it will
519 519
         // probably never resolve.
520 520
         const timeout = browser.isElectron() ? 15000 : 60000;
521
+        const audioOptions = {
522
+            devices: [ MEDIA_TYPE.AUDIO ],
523
+            timeout,
524
+            firePermissionPromptIsShownEvent: true,
525
+            fireSlowPromiseEvent: true
526
+        };
521 527
 
522 528
         // FIXME is there any simpler way to rewrite this spaghetti below ?
523 529
         if (options.startScreenSharing) {
524
-            tryCreateLocalTracks = this._createDesktopTrack()
530
+            // This option has been deprecated since it is no longer supported as per the w3c spec.
531
+            // https://w3c.github.io/mediacapture-screen-share/#dom-mediadevices-getdisplaymedia. If the user has not
532
+            // interacted with the webpage before the getDisplayMedia call, the promise will be rejected by the
533
+            // browser. This has already been implemented in Firefox and Safari and will be implemented in Chrome soon.
534
+            // https://bugs.chromium.org/p/chromium/issues/detail?id=1198918
535
+            // Please note that Spot uses the same config option to use an external video input device label as
536
+            // screenshare and calls getUserMedia instead of getDisplayMedia for capturing the media. Therefore it
537
+            // needs to be supported here if _desktopSharingSourceDevice is provided.
538
+            const errMessage = new Error('startScreenSharing config option is no longer supported for web browsers');
539
+            const desktopPromise = config._desktopSharingSourceDevice
540
+                ? this._createDesktopTrack()
541
+                : Promise.reject(errMessage);
542
+
543
+            tryCreateLocalTracks = desktopPromise
525 544
                 .then(([ desktopStream ]) => {
526 545
                     if (!requestedAudio) {
527 546
                         return [ desktopStream ];
528 547
                     }
529 548
 
530
-                    return createLocalTracksF({
531
-                        devices: [ 'audio' ],
532
-                        timeout,
533
-                        firePermissionPromptIsShownEvent: true,
534
-                        fireSlowPromiseEvent: true
535
-                    })
549
+                    return createLocalTracksF(audioOptions)
536 550
                         .then(([ audioStream ]) =>
537 551
                             [ desktopStream, audioStream ])
538 552
                         .catch(error => {
@@ -545,14 +559,7 @@ export default {
545 559
                     logger.error('Failed to obtain desktop stream', error);
546 560
                     errors.screenSharingError = error;
547 561
 
548
-                    return requestedAudio
549
-                        ? createLocalTracksF({
550
-                            devices: [ 'audio' ],
551
-                            timeout,
552
-                            firePermissionPromptIsShownEvent: true,
553
-                            fireSlowPromiseEvent: true
554
-                        })
555
-                        : [];
562
+                    return requestedAudio ? createLocalTracksF(audioOptions) : [];
556 563
                 })
557 564
                 .catch(error => {
558 565
                     errors.audioOnlyError = error;
@@ -587,13 +594,7 @@ export default {
587 594
                             return [];
588 595
                         }
589 596
 
590
-                        return (
591
-                            createLocalTracksF({
592
-                                devices: [ 'audio' ],
593
-                                timeout,
594
-                                firePermissionPromptIsShownEvent: true,
595
-                                fireSlowPromiseEvent: true
596
-                            }));
597
+                        return createLocalTracksF(audioOptions);
597 598
                     } else if (requestedAudio && !requestedVideo) {
598 599
                         errors.audioOnlyError = err;
599 600
 
@@ -615,7 +616,7 @@ export default {
615 616
                     // Try video only...
616 617
                     return requestedVideo
617 618
                         ? createLocalTracksF({
618
-                            devices: [ 'video' ],
619
+                            devices: [ MEDIA_TYPE.VIDEO ],
619 620
                             firePermissionPromptIsShownEvent: true,
620 621
                             fireSlowPromiseEvent: true
621 622
                         })

+ 5
- 1
config.js Parādīt failu

@@ -236,7 +236,11 @@ var config = {
236 236
     //     max: 5
237 237
     // },
238 238
 
239
-    // Try to start calls with screen-sharing instead of camera video.
239
+    // This option has been deprecated since it is no longer supported as per the w3c spec.
240
+    // https://w3c.github.io/mediacapture-screen-share/#dom-mediadevices-getdisplaymedia. If the user has not
241
+    // interacted with the webpage before the getDisplayMedia call, the promise will be rejected by the browser. This
242
+    // has already been implemented in Firefox and Safari and will be implemented in Chrome soon.
243
+    // https://bugs.chromium.org/p/chromium/issues/detail?id=1198918
240 244
     // startScreenSharing: false,
241 245
 
242 246
     // Recording

Notiek ielāde…
Atcelt
Saglabāt