Use the main screen for screen capture
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 May 2019 02:56:13 +0000 (02:56 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 May 2019 02:56:13 +0000 (02:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197804
<rdar://problem/47671383>

Reviewed by Eric Carlson.

If the main screen, i.e. the screen that has focus at the time of
selection of the screen to capture, is capturable, add it to the list
of screen devices, but do not add any other screen.
This will make sure the main screen is selected.
Manually tested.

* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
(WebCore::ScreenDisplayCaptureSourceMac::screenCaptureDevices):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245216 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm

index 880b4ca..2958afd 100644 (file)
@@ -1,3 +1,20 @@
+2019-05-12  Youenn Fablet  <youenn@apple.com>
+
+        Use the main screen for screen capture
+        https://bugs.webkit.org/show_bug.cgi?id=197804
+        <rdar://problem/47671383>
+
+        Reviewed by Eric Carlson.
+
+        If the main screen, i.e. the screen that has focus at the time of
+        selection of the screen to capture, is capturable, add it to the list
+        of screen devices, but do not add any other screen.
+        This will make sure the main screen is selected.
+        Manually tested.
+
+        * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
+        (WebCore::ScreenDisplayCaptureSourceMac::screenCaptureDevices):
+
 2019-05-12  Takashi Komori  <Takashi.Komori@sony.com>
 
         [Curl] Suppress extra didReceiveAuthenticationChallenge call when accessing a server which checks basic auth.
index f6d631e..087ad0a 100644 (file)
@@ -35,6 +35,7 @@
 #include "MediaSampleAVFObjC.h"
 #include "NotImplemented.h"
 #include "PlatformLayer.h"
+#include "PlatformScreen.h"
 #include "RealtimeMediaSourceSettings.h"
 #include "RealtimeVideoUtilities.h"
 
@@ -303,6 +304,14 @@ Optional<CaptureDevice> ScreenDisplayCaptureSourceMac::screenCaptureDeviceWithPe
 
 void ScreenDisplayCaptureSourceMac::screenCaptureDevices(Vector<CaptureDevice>& displays)
 {
+    auto screenID = displayID([NSScreen mainScreen]);
+    if (CGDisplayIDToOpenGLDisplayMask(screenID)) {
+        CaptureDevice displayDevice(String::number(screenID), CaptureDevice::DeviceType::Screen, makeString("Screen 0"));
+        displayDevice.setEnabled(true);
+        displays.append(WTFMove(displayDevice));
+        return;
+    }
+
     uint32_t displayCount = 0;
     auto err = CGGetActiveDisplayList(0, nullptr, &displayCount);
     if (err) {