[MediaStream] Separate media capture and audio playback muting
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 17:53:12 +0000 (17:53 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 17:53:12 +0000 (17:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163855
<rdar://problem/28827186>

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/mediastream/MediaStream-page-muted.html

Change page.muted from a bool to a bitfield so audio and media capture muted are independent.
Fix a couple of bugs in the mock media capture device uncovered by new test case.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::pageMutedStateDidChange): page.isMuted -> page.mutedState.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::pageMutedStateDidChange): Ditto.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateVolume): Ditto.
(WebCore::HTMLMediaElement::effectiveMuted): Ditto.

* page/MediaProducer.h: Add MutedState enum.

* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::setMuted): Take MutedStateFlags instead of bool. m_muted -> m_mutedState.
* page/Page.h:

* platform/mock/MockRealtimeMediaSource.cpp:
(WebCore::MockRealtimeMediaSource::startProducingData): Call setMuted.
(WebCore::MockRealtimeMediaSource::stopProducingData): Ditto.
* platform/mock/MockRealtimeMediaSource.h:

* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::stopProducingData): Call correct base class method.

* testing/Internals.cpp:
(WebCore::Internals::setPageMuted): Change parameter from a bool to a string.
* testing/Internals.h:

* testing/Internals.idl:

Source/WebKit2:

* Shared/WebPageCreationParameters.h: Change 'muted' from bool to MutedStateFlags.

* UIProcess/API/C/WKPage.cpp: Change parameter from bool to WKMediaMutedState.
(WKPageSetMuted):
* UIProcess/API/C/WKPagePrivate.h: Define WKMediaMutedState.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setMuted): m_muted -> m_mutedState.
(WebKit::WebPageProxy::creationParameters): Ditto.
* UIProcess/WebPageProxy.h:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::isMuted): page.isMuted -> page.mutedState.

* WebProcess/WebPage/WebPage.messages.in: Change SetMuted parameter.

LayoutTests:

* fast/mediastream/MediaStream-page-muted-expected.txt: Added.
* fast/mediastream/MediaStream-page-muted.html: Added.
* media/video-muted-after-setting-page-muted-state.html: Updated.

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

26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/MediaStream-page-muted.html [new file with mode: 0644]
LayoutTests/media/video-muted-after-setting-page-muted-state.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/page/MediaProducer.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp
Source/WebCore/platform/mock/MockRealtimeMediaSource.h
Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 3f753e4..6e59c13 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-24  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Separate media capture and audio playback muting
+        https://bugs.webkit.org/show_bug.cgi?id=163855
+        <rdar://problem/28827186>
+
+        Reviewed by Darin Adler.
+
+        * fast/mediastream/MediaStream-page-muted-expected.txt: Added.
+        * fast/mediastream/MediaStream-page-muted.html: Added.
+        * media/video-muted-after-setting-page-muted-state.html: Updated.
+
 2016-10-24  Youenn Fablet  <youenn@apple.com>
 
         Activate WEB_RTC compilation flags for Mac bots
diff --git a/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt b/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt
new file mode 100644 (file)
index 0000000..0d93fc2
--- /dev/null
@@ -0,0 +1,29 @@
+Test enabling/disabling mock media capture devices
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+*** Mock capture devices should be enabled by default
+PASS mediaStream is an instance of Object
+PASS mediaStream.getTracks().length is 2
+
+*** Muting capture devices
+EVENT: mute
+PASS event.target.muted is true
+
+EVENT: mute
+PASS event.target.muted is true
+
+
+*** Unmuting capture devices
+EVENT: unmute
+PASS event.target.muted is false
+
+EVENT: unmute
+PASS event.target.muted is false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/MediaStream-page-muted.html b/LayoutTests/fast/mediastream/MediaStream-page-muted.html
new file mode 100644 (file)
index 0000000..d6a5f44
--- /dev/null
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+    <head>
+        <script src="../../resources/js-test-pre.js"></script>
+        <script>
+            let mediaStream;
+            let eventCount = 0;
+
+            function muteChanged(ev)
+            {
+                event = ev;
+                debug(`EVENT: ${ev.type}`);
+                shouldBe('event.target.muted', (ev.type == "mute").toString());
+                debug("");
+
+                if (++eventCount == 2) {
+                    eventCount = 0;
+
+                    if (ev.type == "unmute") {
+                        finishJSTest();
+                        return;
+                    }
+
+                    if (window.internals) {
+                        debug("<br>*** Unmuting capture devices");
+                        internals.setPageMuted("");
+                    }
+                }
+            }
+            
+            function testWhenEnabled()
+            {
+                navigator.mediaDevices
+                    .getUserMedia({audio:{}, video:{}})
+                    .then(stream => {
+                        mediaStream = stream;
+                        shouldBeType("mediaStream", "Object");
+                        shouldBe("mediaStream.getTracks().length", "2");
+
+                        var tracks = mediaStream.getTracks();
+                        for (var i = 0; i < tracks.length; i++) {
+                            tracks[i].onmute = muteChanged;
+                            tracks[i].onunmute = muteChanged;
+                        }
+
+                        if (window.internals) {
+                            debug("<br>*** Muting capture devices");
+                            internals.setPageMuted("capturedevices");
+                        }
+                    })
+                    .catch((err) => {
+                        testFailed(`mediaDevices.getUserMedia() failed with ${err.name}`);
+                        finishJSTest();
+                    });
+            }
+
+            function start()
+            {
+                debug(`<br>*** Mock capture devices should be enabled by default`);
+                if (window.testRunner)
+                    testRunner.setUserMediaPermission(true);
+
+                testWhenEnabled();
+            }
+
+        </script>
+    </head>
+
+    <body onload="start()">
+        <p id="description"></p>
+        <div id="console"></div>
+        <script>
+            description("Test enabling/disabling mock media capture devices");
+            window.jsTestIsAsync = true;
+
+            window.successfullyParsed = true;
+        </script>
+        <script src="../../resources/js-test-post.js"></script>
+    </body>
+</html>
index e50d13f..7e57008 100644 (file)
@@ -5,13 +5,13 @@
 <script>
     testExpected("video.muted", false);
     if (window.internals)
-        internals.setPageMuted(true);
+        internals.setPageMuted("audio");
     testExpected("video.muted", false);
 
     run("video.muted = true");
     testExpected("video.muted", true);
     if (window.internals)
-        internals.setPageMuted(false);
+        internals.setPageMuted("");
     testExpected("video.muted", true);
     endTest();
 </script>
index 0116abc..147c5dc 100644 (file)
@@ -1,3 +1,47 @@
+2016-10-24  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Separate media capture and audio playback muting
+        https://bugs.webkit.org/show_bug.cgi?id=163855
+        <rdar://problem/28827186>
+
+        Reviewed by Darin Adler.
+
+        Test: fast/mediastream/MediaStream-page-muted.html
+
+        Change page.muted from a bool to a bitfield so audio and media capture muted are independent.
+        Fix a couple of bugs in the mock media capture device uncovered by new test case.
+        
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::pageMutedStateDidChange): page.isMuted -> page.mutedState.
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::pageMutedStateDidChange): Ditto.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateVolume): Ditto.
+        (WebCore::HTMLMediaElement::effectiveMuted): Ditto.
+
+        * page/MediaProducer.h: Add MutedState enum.
+
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::setMuted): Take MutedStateFlags instead of bool. m_muted -> m_mutedState.
+        * page/Page.h:
+
+        * platform/mock/MockRealtimeMediaSource.cpp:
+        (WebCore::MockRealtimeMediaSource::startProducingData): Call setMuted.
+        (WebCore::MockRealtimeMediaSource::stopProducingData): Ditto.
+        * platform/mock/MockRealtimeMediaSource.h:
+
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::stopProducingData): Call correct base class method.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setPageMuted): Change parameter from a bool to a string.
+        * testing/Internals.h:
+
+        * testing/Internals.idl:
+
 2016-10-24  Darin Adler  <darin@apple.com>
 
         Try to fix Windows build.
index 20dd8e3..096110e 100644 (file)
@@ -256,7 +256,7 @@ void MediaStream::pageMutedStateDidChange()
     if (!document)
         return;
 
-    bool pageMuted = document->page()->isMuted();
+    bool pageMuted = document->page()->isMediaCaptureMuted();
     if (m_externallyMuted == pageMuted)
         return;
 
index c389071..5eaf15a 100644 (file)
@@ -973,7 +973,7 @@ MediaProducer::MediaStateFlags AudioContext::mediaState() const
 void AudioContext::pageMutedStateDidChange()
 {
     if (m_destinationNode && document()->page())
-        m_destinationNode->setMuted(document()->page()->isMuted());
+        m_destinationNode->setMuted(document()->page()->isAudioMuted());
 }
 
 void AudioContext::isPlayingAudioDidChange()
index b2c130d..34952e5 100644 (file)
@@ -4846,7 +4846,7 @@ void HTMLMediaElement::updateVolume()
 
         if (m_mediaController) {
             volumeMultiplier *= m_mediaController->volume();
-            shouldMute = m_mediaController->muted() || (page && page->isMuted());
+            shouldMute = m_mediaController->muted() || (page && page->isAudioMuted());
         }
 
 #if ENABLE(MEDIA_SESSION)
@@ -7007,7 +7007,7 @@ void HTMLMediaElement::pageMutedStateDidChange()
 
 bool HTMLMediaElement::effectiveMuted() const
 {
-    return muted() || (document().page() && document().page()->isMuted());
+    return muted() || (document().page() && document().page()->isAudioMuted());
 }
 
 void HTMLMediaElement::updateAudioAssertionState()
index 9a66c88..5ae1737 100644 (file)
@@ -48,6 +48,14 @@ public:
     typedef unsigned MediaStateFlags;
 
     virtual MediaStateFlags mediaState() const = 0;
+
+    enum MutedState {
+        NoneMuted = 0,
+        AudioIsMuted = 1 << 0,
+        CaptureDevicesAreMuted = 1 << 1,
+    };
+    typedef unsigned MutedStateFlags;
+
     virtual void pageMutedStateDidChange() = 0;
 
 protected:
index f9ff715..782886f 100644 (file)
@@ -193,7 +193,6 @@ Page::Page(PageConfiguration&& pageConfiguration)
     , m_inLowQualityInterpolationMode(false)
     , m_areMemoryCacheClientCallsEnabled(true)
     , m_mediaVolume(1)
-    , m_muted(false)
     , m_pageScaleFactor(1)
     , m_zoomedOutPageScaleFactor(0)
     , m_topContentInset(0)
@@ -1381,12 +1380,12 @@ void Page::updateIsPlayingMedia(uint64_t sourceElementID)
     chrome().client().isPlayingMediaDidChange(state, sourceElementID);
 }
 
-void Page::setMuted(bool muted)
+void Page::setMuted(MediaProducer::MutedStateFlags muted)
 {
-    if (m_muted == muted)
+    if (m_mutedState == muted)
         return;
 
-    m_muted = muted;
+    m_mutedState = muted;
 
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (!frame->document())
index 6000fc2..314f216 100644 (file)
@@ -480,8 +480,10 @@ public:
 
     MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
     void updateIsPlayingMedia(uint64_t);
-    bool isMuted() const { return m_muted; }
-    WEBCORE_EXPORT void setMuted(bool);
+    MediaProducer::MutedStateFlags mutedState() const { return m_mutedState; }
+    bool isAudioMuted() const { return m_mutedState & MediaProducer::AudioIsMuted; }
+    bool isMediaCaptureMuted() const { return m_mutedState & MediaProducer::CaptureDevicesAreMuted; };
+    WEBCORE_EXPORT void setMuted(MediaProducer::MutedStateFlags);
 
 #if ENABLE(MEDIA_SESSION)
     WEBCORE_EXPORT void handleMediaEvent(MediaEventType);
@@ -609,7 +611,7 @@ private:
     bool m_inLowQualityInterpolationMode;
     bool m_areMemoryCacheClientCallsEnabled;
     float m_mediaVolume;
-    bool m_muted;
+    MediaProducer::MutedStateFlags m_mutedState { MediaProducer::NoneMuted };
 
     float m_pageScaleFactor;
     float m_zoomedOutPageScaleFactor;
index fa2d02d..15796f1 100644 (file)
@@ -84,7 +84,7 @@ void RealtimeMediaSource::removeObserver(RealtimeMediaSource::Observer* observer
 
 void RealtimeMediaSource::setMuted(bool muted)
 {
-    if (m_muted == muted)
+    if (m_stopped || m_muted == muted)
         return;
 
     m_muted = muted;
@@ -150,7 +150,6 @@ void RealtimeMediaSource::requestStop(Observer* callingObserver)
     stop(callingObserver);
 }
 
-#if 1
 double RealtimeMediaSource::fitnessDistance(const MediaConstraint& constraint)
 {
     RealtimeMediaSourceCapabilities& capabilities = *this->capabilities();
@@ -275,7 +274,6 @@ double RealtimeMediaSource::fitnessDistance(const MediaConstraint& constraint)
 
     return 0;
 }
-#endif
 
 template <typename ValueType>
 static void applyNumericConstraint(const NumericConstraint<ValueType>& constraint, ValueType current, ValueType capabilityMin, ValueType capabilityMax, RealtimeMediaSource* source, void (RealtimeMediaSource::*applier)(ValueType))
index 467be87..6a52cc2 100644 (file)
@@ -124,6 +124,18 @@ RealtimeMediaSourceSupportedConstraints& MockRealtimeMediaSource::supportedConst
     return m_supportedConstraints;
 }
 
+void MockRealtimeMediaSource::startProducingData()
+{
+    m_isProducingData = true;
+    setMuted(false);
+}
+
+void MockRealtimeMediaSource::stopProducingData()
+{
+    m_isProducingData = false;
+    setMuted(true);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index 5111cab..7a0123a 100644 (file)
@@ -69,8 +69,8 @@ protected:
     virtual void initializeCapabilities(RealtimeMediaSourceCapabilities&) = 0;
     virtual void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints&) = 0;
 
-    void startProducingData() override { m_isProducingData = true; }
-    void stopProducingData() override { m_isProducingData = false; }
+    void startProducingData() override;
+    void stopProducingData() override;
 
     RefPtr<RealtimeMediaSourceCapabilities> capabilities() override;
     const RealtimeMediaSourceSettings& settings() override;
index 1372a7a..ef9900d 100644 (file)
@@ -85,7 +85,7 @@ void MockRealtimeVideoSource::startProducingData()
 
 void MockRealtimeVideoSource::stopProducingData()
 {
-    MockRealtimeMediaSource::startProducingData();
+    MockRealtimeMediaSource::stopProducingData();
     m_timer.stop();
     m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
     m_startTime = NAN;
index 79d2b11..48a175e 100644 (file)
@@ -86,6 +86,7 @@
 #include "MainFrame.h"
 #include "MallocStatistics.h"
 #include "MediaPlayer.h"
+#include "MediaProducer.h"
 #include "MemoryCache.h"
 #include "MemoryInfo.h"
 #include "MemoryPressureHandler.h"
@@ -2945,14 +2946,24 @@ ExceptionOr<String> Internals::pageOverlayLayerTreeAsText() const
     return MockPageOverlayClient::singleton().layerTreeAsText(document->frame()->mainFrame());
 }
 
-void Internals::setPageMuted(bool muted)
+void Internals::setPageMuted(const String& states)
 {
     Document* document = contextDocument();
     if (!document)
         return;
 
+    WebCore::MediaProducer::MutedStateFlags state = MediaProducer::NoneMuted;
+    Vector<String> stateString;
+    states.split(',', false, stateString);
+    for (auto& muteString : stateString) {
+        if (equalLettersIgnoringASCIICase(muteString, "audio"))
+            state |= MediaProducer::AudioIsMuted;
+        if (equalLettersIgnoringASCIICase(muteString, "capturedevices"))
+            state |= MediaProducer::CaptureDevicesAreMuted;
+    }
+
     if (Page* page = document->page())
-        page->setMuted(muted);
+        page->setMuted(state);
 }
 
 bool Internals::isPagePlayingAudio()
index 5668409..8aebc6d 100644 (file)
@@ -440,7 +440,7 @@ public:
     ExceptionOr<Ref<MockPageOverlay>> installMockPageOverlay(PageOverlayType);
     ExceptionOr<String> pageOverlayLayerTreeAsText() const;
 
-    void setPageMuted(bool);
+    void setPageMuted(const String&);
     bool isPagePlayingAudio();
 
     void setPageDefersLoading(bool);
index 288e712..a83e65b 100644 (file)
@@ -417,7 +417,7 @@ enum UserInterfaceLayoutDirection {
     [MayThrowException] MockPageOverlay installMockPageOverlay(PageOverlayType type);
     [MayThrowException] DOMString pageOverlayLayerTreeAsText();
 
-    void setPageMuted(boolean muted);
+    void setPageMuted(DOMString mutedState);
     boolean isPagePlayingAudio();
 
     void setPageDefersLoading(boolean defersLoading);
index b85adfd..300d69b 100644 (file)
@@ -1,3 +1,28 @@
+2016-10-24  Eric Carlson  <eric.carlson@apple.com>
+
+        [MediaStream] Separate media capture and audio playback muting
+        https://bugs.webkit.org/show_bug.cgi?id=163855
+        <rdar://problem/28827186>
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebPageCreationParameters.h: Change 'muted' from bool to MutedStateFlags.
+
+        * UIProcess/API/C/WKPage.cpp: Change parameter from bool to WKMediaMutedState.
+        (WKPageSetMuted):
+        * UIProcess/API/C/WKPagePrivate.h: Define WKMediaMutedState.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::setMuted): m_muted -> m_mutedState.
+        (WebKit::WebPageProxy::creationParameters): Ditto.
+        * UIProcess/WebPageProxy.h:
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::isMuted): page.isMuted -> page.mutedState.
+
+        * WebProcess/WebPage/WebPage.messages.in: Change SetMuted parameter.
+
 2016-10-24  Youenn Fablet  <youenn@apple.com>
 
         Activate WEB_RTC compilation flags for Mac bots
index ff84c48..c5befd2 100644 (file)
@@ -35,6 +35,7 @@
 #include <WebCore/Color.h>
 #include <WebCore/FloatSize.h>
 #include <WebCore/IntSize.h>
+#include <WebCore/MediaProducer.h>
 #include <WebCore/Pagination.h>
 #include <WebCore/ScrollTypes.h>
 #include <WebCore/SessionID.h>
@@ -99,7 +100,7 @@ struct WebPageCreationParameters {
     float topContentInset;
     
     float mediaVolume;
-    bool muted;
+    WebCore::MediaProducer::MutedStateFlags muted;
     bool mayStartMediaWhenInWindow;
 
     WebCore::IntSize minimumLayoutSize;
index 8699a03..bb60d3d 100644 (file)
@@ -2601,7 +2601,7 @@ void WKPageSetMediaVolume(WKPageRef page, float volume)
     toImpl(page)->setMediaVolume(volume);    
 }
 
-void WKPageSetMuted(WKPageRef page, bool muted)
+void WKPageSetMuted(WKPageRef page, WKMediaMutedState muted)
 {
     toImpl(page)->setMuted(muted);
 }
index 367b8f2..e4c2f11 100644 (file)
@@ -120,7 +120,14 @@ WK_EXPORT bool WKPageGetAddsVisitedLinks(WKPageRef page);
 WK_EXPORT void WKPageSetAddsVisitedLinks(WKPageRef page, bool visitedLinks);
 
 WK_EXPORT bool WKPageIsPlayingAudio(WKPageRef page);
-WK_EXPORT void WKPageSetMuted(WKPageRef page, bool muted);
+
+enum {
+    kWKMediaNoneMuted = 0,
+    kWKMediaAudioMuted = 1 << 0,
+    kWKMediaCaptureDevicesMuted = 1 << 1,
+};
+typedef uint32_t WKMediaMutedState;
+WK_EXPORT void WKPageSetMuted(WKPageRef page, WKMediaMutedState muted);
 
 enum {
     kWKMediaIsNotPlaying = 0,
@@ -130,6 +137,7 @@ enum {
 };
 typedef uint32_t WKMediaState;
 
+
 WK_EXPORT WKMediaState WKPageGetMediaState(WKPageRef page);
 
 enum {
index d3160f2..3392cd9 100644 (file)
@@ -444,7 +444,6 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_suppressVisibilityUpdates(false)
     , m_autoSizingShouldExpandToViewHeight(false)
     , m_mediaVolume(1)
-    , m_muted(false)
     , m_mayStartMediaWhenInWindow(true)
     , m_waitingForDidUpdateViewState(false)
 #if PLATFORM(COCOA)
@@ -1588,7 +1587,7 @@ void WebPageProxy::updateThrottleState()
 
     // We should suppress if the page is not active, is visually idle, and supression is enabled.
     bool isLoading = m_pageLoadState.isLoading();
-    bool isPlayingAudio = m_mediaState & MediaProducer::IsPlayingAudio && !m_muted;
+    bool isPlayingAudio = m_mediaState & MediaProducer::IsPlayingAudio && !(m_mutedState & MediaProducer::AudioIsMuted);
     bool pageShouldBeSuppressed = !isLoading && !isPlayingAudio && processSuppressionEnabled && (m_viewState & ViewState::IsVisuallyIdle);
     if (m_pageSuppressed != pageShouldBeSuppressed) {
         m_pageSuppressed = pageShouldBeSuppressed;
@@ -4152,17 +4151,17 @@ void WebPageProxy::setMediaVolume(float volume)
     m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);    
 }
 
-void WebPageProxy::setMuted(bool muted)
+void WebPageProxy::setMuted(WebCore::MediaProducer::MutedStateFlags state)
 {
-    if (m_muted == muted)
+    if (m_mutedState == state)
         return;
 
-    m_muted = muted;
+    m_mutedState = state;
 
     if (!isValid())
         return;
 
-    m_process->send(Messages::WebPage::SetMuted(muted), m_pageID);
+    m_process->send(Messages::WebPage::SetMuted(state), m_pageID);
 
     updateThrottleState();
 }
@@ -5483,7 +5482,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
     parameters.viewScaleFactor = m_viewScaleFactor;
     parameters.topContentInset = m_topContentInset;
     parameters.mediaVolume = m_mediaVolume;
-    parameters.muted = m_muted;
+    parameters.muted = m_mutedState;
     parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow;
     parameters.minimumLayoutSize = m_minimumLayoutSize;
     parameters.autoSizingShouldExpandToViewHeight = m_autoSizingShouldExpandToViewHeight;
index b61df89..aafc4c5 100644 (file)
@@ -937,7 +937,7 @@ public:
     void printMainFrame();
     
     void setMediaVolume(float);
-    void setMuted(bool);
+    void setMuted(WebCore::MediaProducer::MutedStateFlags);
     void setMayStartMediaWhenInWindow(bool);
     bool mayStartMediaWhenInWindow() const { return m_mayStartMediaWhenInWindow; }
         
@@ -1852,7 +1852,7 @@ private:
     WebCore::IntSize m_minimumLayoutSize;
 
     float m_mediaVolume;
-    bool m_muted;
+    WebCore::MediaProducer::MutedStateFlags m_mutedState { WebCore::MediaProducer::NoneMuted };
     bool m_mayStartMediaWhenInWindow;
 
     bool m_waitingForDidUpdateViewState;
index df15195..4504342 100644 (file)
@@ -1531,7 +1531,7 @@ bool PluginView::isMuted() const
     if (!frame() || !frame()->page())
         return false;
 
-    return frame()->page()->isMuted();
+    return frame()->page()->isAudioMuted();
 }
 #endif
 
index 42d972b..5a3eb19 100644 (file)
@@ -314,7 +314,7 @@ messages -> WebPage LegacyReceiver {
 
     # Media
     SetMediaVolume(float volume)
-    SetMuted(bool muted)
+    SetMuted(WebCore::MediaProducer::MutedStateFlags muted)
     SetMayStartMediaWhenInWindow(bool mayStartMedia)
 
 #if ENABLE(MEDIA_SESSION)