[MediaStream] Host should be able to mute screen capture and camera/microphone indepe...
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 20:44:29 +0000 (20:44 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 20:44:29 +0000 (20:44 +0000)
commit337ddb4203df82d4538f273e2874347658d10e14
tree764961158f36337c30166b7203110beac147aff5
parentfdb1e7ea1270a56edf7ab7601a25cc82f9dbc06a
[MediaStream] Host should be able to mute screen capture and camera/microphone independently
https://bugs.webkit.org/show_bug.cgi?id=196555
<rdar://problem/47303865>

Reviewed by Youenn Fablet.

Source/WebCore:

Test: fast/mediastream/media-stream-page-muted.html

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::MediaStream): Call setCaptureTracksMuted to pass page muted
state to tracks.
(WebCore::MediaStream::startProducingData): Ditto.
(WebCore::MediaStream::setCaptureTracksMuted): New.
* Modules/mediastream/MediaStream.h:

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack): Call setMuted with page muted state.
(WebCore::MediaStreamTrack::setMuted): Set muted according to page state and source type.
(WebCore::MediaStreamTrack::pageMutedStateDidChange): Call setMuted.
(WebCore::MediaStreamTrack::mediaState const): Update for new page state.
* Modules/mediastream/MediaStreamTrack.h:

* page/MediaProducer.h: Split capture muted state into two: camera/microphone and screen.

* page/Page.h:
(WebCore::Page::isMediaCaptureMuted const): Update for state changes.

* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::setCaptureTracksMuted): Deleted.
(WebCore::MediaStreamPrivate::hasCaptureVideoSource const): Deleted.
* platform/mediastream/MediaStreamPrivate.h:

* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::setMuted): Log state.
(WebCore::RealtimeMediaSource::notifyMutedChange): Call notifyMutedObservers on the
next runloop so events aren't dispatched synchronously.

* testing/Internals.cpp:
(WebCore::Internals::setPageMuted): Add new state.

Source/WebKit:

* UIProcess/API/C/WKPagePrivate.h: Add kWKMediaScreenCaptureMuted.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setPageMuted:]):
(-[WKWebView _setMediaCaptureMuted:]): Deleted, it was unused.
(-[WKWebView _muteMediaCapture]): Deleted, it was unused.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest): Fix
a log comment typo.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setMediaStreamCaptureMuted): Use the new flag.
(WebKit::WebPageProxy::activateMediaStreamCaptureInPage): Ditto.
(WebKit::WebPageProxy::setMuted): Ditto.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isMediaStreamCaptureMuted const): Ditto.

LayoutTests:

* fast/mediastream/media-stream-page-muted-expected.txt: Added.
* fast/mediastream/media-stream-page-muted.html: Added.
* fast/mediastream/media-stream-track-interrupted.html: Read page muted state before
interrupting capture track because the page state now changes immediately.
* fast/mediastream/media-stream-track-muted.html: Ditto, for muting.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243899 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/media-stream-page-muted-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/media-stream-page-muted.html [new file with mode: 0644]
LayoutTests/fast/mediastream/media-stream-track-interrupted.html
LayoutTests/fast/mediastream/media-stream-track-muted.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/page/MediaProducer.h
Source/WebCore/page/Page.h
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKPagePrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h