[MediaStream] Add Mac screen capture source
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 23:34:30 +0000 (23:34 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 23:34:30 +0000 (23:34 +0000)
commitc3149d656f3ef197e7e6deae71dab88b730b0603
tree288b3656c4d4633e74ecaf2e3337696e956352c3
parent08695211329b4f1a7fed0944647ccd550f39c7c2
[MediaStream] Add Mac screen capture source
https://bugs.webkit.org/show_bug.cgi?id=181333
<rdar://problem/36323219>

Reviewed by Dean Jackson.

Source/WebCore:

* SourcesCocoa.txt: Add ScreenDisplayCaptureSourceMac.mm.

* WebCore.xcodeproj/project.pbxproj: Ditto.

* platform/cocoa/CoreVideoSoftLink.cpp: Declare new constants used.
* platform/cocoa/CoreVideoSoftLink.h:

* platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp:
(WebCore::displayReconfigurationCallBack): Call refreshCaptureDevices.
(WebCore::DisplayCaptureManagerCocoa::~DisplayCaptureManagerCocoa): Unregister for display
reconfiguration callbacks.
(WebCore::DisplayCaptureManagerCocoa::captureDevices): Register for display reconfigrations.
(WebCore::DisplayCaptureManagerCocoa::refreshCaptureDevices): Use CGActiveDisplayList to
get list of active screens.
(WebCore::DisplayCaptureManagerCocoa::screenCaptureDeviceWithPersistentID): Validate screen
ID, return CaptureDevice.
* platform/mediastream/mac/DisplayCaptureManagerCocoa.h:

* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::VideoCaptureSourceFactoryMac::createVideoCaptureSource): Deal with screen capture
on macOS.

Implement Mac screen capture with CGDisplayStream.
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h: Added.
(WebCore::ScreenDisplayCaptureSourceMac::DisplaySurface::~DisplaySurface):
(WebCore::ScreenDisplayCaptureSourceMac::DisplaySurface::operator=):
(WebCore::ScreenDisplayCaptureSourceMac::DisplaySurface::ioSurface const):
* platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm: Added.
(WebCore::roundUpToMacroblockMultiple):
(WebCore::ScreenDisplayCaptureSourceMac::updateDisplayID):
(WebCore::ScreenDisplayCaptureSourceMac::create):
(WebCore::ScreenDisplayCaptureSourceMac::ScreenDisplayCaptureSourceMac):
(WebCore::ScreenDisplayCaptureSourceMac::~ScreenDisplayCaptureSourceMac):
(WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream):
(WebCore::ScreenDisplayCaptureSourceMac::startProducingData):
(WebCore::ScreenDisplayCaptureSourceMac::stopProducingData):
(WebCore::ScreenDisplayCaptureSourceMac::sampleBufferFromPixelBuffer):
(WebCore::ScreenDisplayCaptureSourceMac::pixelBufferFromIOSurface):
(WebCore::ScreenDisplayCaptureSourceMac::generateFrame):
(WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream):
(WebCore::ScreenDisplayCaptureSourceMac::applySize):
(WebCore::ScreenDisplayCaptureSourceMac::applyFrameRate):
(WebCore::ScreenDisplayCaptureSourceMac::commitConfiguration):
(WebCore::ScreenDisplayCaptureSourceMac::displayWasReconfigured):
(WebCore::ScreenDisplayCaptureSourceMac::displayReconfigurationCallBack):
(WebCore::ScreenDisplayCaptureSourceMac::frameAvailable):

Source/WebCore/PAL:

* pal/spi/cg/CoreGraphicsSPI.h: Declare some CGDisplayMode SPI.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
Source/WebCore/platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp
Source/WebCore/platform/mediastream/mac/DisplayCaptureManagerCocoa.h
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm [new file with mode: 0644]