[MediaStream] Add Mock screen capture source
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 20:12:27 +0000 (20:12 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 20:12:27 +0000 (20:12 +0000)
commitd00f8b0392e7a967d7928cc07fb0ea4d6d7a22de
tree0f47a5e01c09cc4bf6682d9599ed7e24d6ded4f9
parent06101d13f763bbeac3aa1fa6f09aa1da74e9fd0d
[MediaStream] Add Mock screen capture source
https://bugs.webkit.org/show_bug.cgi?id=181291
<rdar://problem/36298164>

Reviewed by Dean Jackson.

Source/WebCore:

Tests:  http/tests/media/media-stream/get-display-media-prompt.html
        GetDisplayMediaTest.BasicPrompt
        GetDisplayMediaTest.Constraints

* Modules/mediastream/MediaDevices.cpp:
(WebCore::MediaDevices::MediaDevices): Add static_assert to ensure MediaDevices::DisplayCaptureSurfaceType
and RealtimeMediaSourceSettings::DisplaySurfaceType values are equivalent.
(WebCore::MediaDevices::getSupportedConstraints): Remove bogus code.
* Modules/mediastream/MediaDevices.h: Add DisplayCaptureSurfaceType.
* Modules/mediastream/MediaDevices.idl: Ditto.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::getSettings const): Add a FIXME.
* Modules/mediastream/MediaStreamTrack.h: Add displaySurface and logicalSurface.

* Modules/mediastream/MediaTrackSupportedConstraints.h: Remove displaySurface and logicalSurface.
* Modules/mediastream/MediaTrackSupportedConstraints.idl:

* SourcesCocoa.txt: Add DisplayCaptureManagerCocoa.cpp and DisplayCaptureSourceCocoa.cpp.

* WebCore.xcodeproj/project.pbxproj: Ditto.

* platform/mediastream/CaptureDevice.h:
(WebCore::CaptureDevice::encode const): Add.
(WebCore::CaptureDevice::decode):

* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::getMediaStreamDevices): Include display capture "devices".
(WebCore::RealtimeMediaSourceCenter::validateRequestConstraints): Deal with display capture devices.
(WebCore::RealtimeMediaSourceCenter::captureDeviceWithPersistentID): Ditto.
* platform/mediastream/RealtimeMediaSourceCenter.h:

* platform/mediastream/RealtimeMediaSourceSettings.h:
(WebCore::RealtimeMediaSourceSettings::displaySurface const): Return a DisplaySurfaceType.
(WebCore::RealtimeMediaSourceSettings::setDisplaySurface): Take a DisplaySurfaceType.

* platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp:
(WebCore::DisplayCaptureManagerCocoa::singleton):
(WebCore::DisplayCaptureManagerCocoa::~DisplayCaptureManagerCocoa):
(WebCore::DisplayCaptureManagerCocoa::captureDevices):
(WebCore::DisplayCaptureManagerCocoa::screenCaptureDeviceWithPersistentID):
(WebCore::DisplayCaptureManagerCocoa::captureDeviceWithPersistentID):
* platform/mediastream/mac/DisplayCaptureManagerCocoa.h:

* platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp: Added.
(WebCore::DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa):
(WebCore::DisplayCaptureSourceCocoa::~DisplayCaptureSourceCocoa):
(WebCore::DisplayCaptureSourceCocoa::capabilities const):
(WebCore::DisplayCaptureSourceCocoa::settings const):
(WebCore::DisplayCaptureSourceCocoa::settingsDidChange):
(WebCore::DisplayCaptureSourceCocoa::startProducingData):
(WebCore::DisplayCaptureSourceCocoa::stopProducingData):
(WebCore::DisplayCaptureSourceCocoa::elapsedTime):
(WebCore::DisplayCaptureSourceCocoa::applyFrameRate):
(WebCore::DisplayCaptureSourceCocoa::emitFrame):
* platform/mediastream/mac/DisplayCaptureSourceCocoa.h:

* platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
(WebCore::RealtimeMediaSourceCenterMac::displayCaptureDeviceManager): New.
* platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:

* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::deviceMap): Add screen capture "devices".
(WebCore::MockRealtimeMediaSource::displayDevices): New.
* platform/mock/MockRealtimeMediaSource.h:

* platform/mock/MockRealtimeMediaSourceCenter.cpp: Clean up includes.
* platform/mock/MockRealtimeMediaSourceCenter.h:

* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource): Mock two screen devices.
(WebCore::MockRealtimeVideoSource::updateSettings): Deal with mock screens.
(WebCore::MockRealtimeVideoSource::initializeCapabilities): Ditto.
(WebCore::MockRealtimeVideoSource::initializeSupportedConstraints): Ditto.
(WebCore::MockRealtimeVideoSource::drawText): Ditto.
(WebCore::MockRealtimeVideoSource::generateFrame): Ditto.
* platform/mock/MockRealtimeVideoSource.h:
(WebCore::MockRealtimeVideoSource::mockCamera const):
(WebCore::MockRealtimeVideoSource::mockScreen const):

Source/WebKit:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<MediaConstraints>::decode):
(IPC::ArgumentCoder<CaptureDevice>::encode): Deleted, moved to CaptureDevice.h
(IPC::ArgumentCoder<CaptureDevice>::decode): Ditto.
* Shared/WebCoreArgumentCoders.h:

* UIProcess/API/Cocoa/WKWebViewPrivate.h: Add _WKCaptureDeviceDisplay.
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::requestUserMediaAuthorizationForDevices): Deal with display capture.
(WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): Ditto.

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied): requiresAudio -> requiresAudioCapture.
(WebKit::UserMediaPermissionRequestManagerProxy::searchForGrantedRequest const): Never reuse
a previously granted display capture request.

* UIProcess/UserMediaPermissionRequestProxy.cpp:
(WebKit::UserMediaPermissionRequestProxy::allow): Search the eligible devices instead of asking
the source center to find devices.
* UIProcess/UserMediaPermissionRequestProxy.h:
(WebKit::UserMediaPermissionRequestProxy::requiresAudioCapture const): Renamed.
(WebKit::UserMediaPermissionRequestProxy::requiresVideoCapture const): Ditto.
(WebKit::UserMediaPermissionRequestProxy::requiresDisplayCapture const): New.
(WebKit::UserMediaPermissionRequestProxy::requiresAudio const): Deleted.
(WebKit::UserMediaPermissionRequestProxy::requiresVideo const): Deleted.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add new test.
* TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm:
* TestWebKitAPI/Tests/WebKit/getDisplayMedia.html:

LayoutTests:

* http/tests/media/media-stream/get-display-media-prompt-expected.txt: Added.
* http/tests/media/media-stream/get-display-media-prompt.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/media-stream/get-display-media-prompt-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/get-display-media-prompt.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaDevices.cpp
Source/WebCore/Modules/mediastream/MediaDevices.h
Source/WebCore/Modules/mediastream/MediaDevices.idl
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/MediaTrackSupportedConstraints.h
Source/WebCore/Modules/mediastream/MediaTrackSupportedConstraints.idl
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/CaptureDevice.h
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h
Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.h
Source/WebCore/platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp [new file with mode: 0644]
Source/WebCore/platform/mediastream/mac/DisplayCaptureManagerCocoa.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp [new file with mode: 0644]
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h [new file with mode: 0644]
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp
Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.h
Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSource.h
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.h
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
Source/WebCore/platform/mock/MockRealtimeVideoSource.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit/getDisplayMedia.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMedia.mm [new file with mode: 0644]