Title: [208778] trunk
Revision
208778
Author
[email protected]
Date
2016-11-15 18:55:22 -0800 (Tue, 15 Nov 2016)

Log Message

Report active video and audio capture devices separately
https://bugs.webkit.org/show_bug.cgi?id=164769

Reviewed by Eric Carlson.

Source/WebCore:

For UI purposes, separate the notion of any active capture device to
an active audio and video capture device.

* page/MediaProducer.h: Replace HasActiveMediaCaptureDevice with
HasActiveAudioCaptureDevice and HasActiveVideoCaptureDevice.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::mediaState): Update the logic for mediaState().
Since it is possible to arbitrarily add tracks from various sources,
check specifically for a local AV source (meaning a capture device) that
is producing data.
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::hasLocalVideoSource): Iterate over the tracks
and look for video sources that are not remote.
(WebCore::MediaStreamPrivate::hasLocalAudioSource): Ditto for audio.
* platform/mediastream/MediaStreamPrivate.h:
* testing/Internals.cpp:
(WebCore::Internals::pageMediaState): Update internals reporting.

Source/WebKit2:

Replace kWKMediaHasActiveCaptureDevice with kWKMediaHasActiveAudioCaptureDevice and
kWKMediaHasActiveVideoCaptureDevice

* UIProcess/API/C/WKPage.cpp:
(WKPageGetMediaState):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::isPlayingMediaDidChange): Update the mask to include the two
bits.

LayoutTests:

* fast/mediastream/MediaStream-page-muted-expected.txt: Update test.
* fast/mediastream/MediaStream-page-muted.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208777 => 208778)


--- trunk/LayoutTests/ChangeLog	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/LayoutTests/ChangeLog	2016-11-16 02:55:22 UTC (rev 208778)
@@ -1,3 +1,13 @@
+2016-11-15  Jon Lee  <[email protected]>
+
+        Report active video and audio capture devices separately
+        https://bugs.webkit.org/show_bug.cgi?id=164769
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/MediaStream-page-muted-expected.txt: Update test.
+        * fast/mediastream/MediaStream-page-muted.html:
+
 2016-11-15  Ryan Haddad  <[email protected]>
 
         Marking js/regress-141098.html as flaky on ios-simulator.

Modified: trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt (208777 => 208778)


--- trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt	2016-11-16 02:55:22 UTC (rev 208778)
@@ -7,7 +7,7 @@
 *** Mock capture devices should be enabled by default
 PASS mediaStream is an instance of Object
 PASS mediaStream.getTracks().length is 2
-PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
+PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became true
 
 *** Muting capture devices
 EVENT: mute
@@ -15,7 +15,7 @@
 EVENT: mute
 PASS muteChangedEvent.target.muted is true
 
-PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became false
+PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became false
 
 *** Unmuting capture devices
 EVENT: unmute
@@ -23,7 +23,7 @@
 EVENT: unmute
 PASS muteChangedEvent.target.muted is false
 
-PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
+PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html (208777 => 208778)


--- trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html	2016-11-16 02:55:22 UTC (rev 208778)
@@ -28,7 +28,7 @@
                 if (++eventCount == 2) {
                     debug("");
                     let shouldBeActive = muteChangedEvent.type == "mute" ? "false" : "true";
-                    shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", shouldBeActive, nextStep);
+                    shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice')", shouldBeActive, nextStep);
                 }
             }
             
@@ -53,7 +53,7 @@
                             tracks[i]._onunmute_ = muteChanged;
                         }
 
-                        shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", "true", muteCaptureDevices);
+                        shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice')", "true", muteCaptureDevices);
                     })
                     .catch((err) => {
                         testFailed(`mediaDevices.getUserMedia() failed with ${err.name}`);

Modified: trunk/Source/WebCore/ChangeLog (208777 => 208778)


--- trunk/Source/WebCore/ChangeLog	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/ChangeLog	2016-11-16 02:55:22 UTC (rev 208778)
@@ -1,3 +1,29 @@
+2016-11-15  Jon Lee  <[email protected]>
+
+        Report active video and audio capture devices separately
+        https://bugs.webkit.org/show_bug.cgi?id=164769
+
+        Reviewed by Eric Carlson.
+
+        For UI purposes, separate the notion of any active capture device to
+        an active audio and video capture device.
+
+        * page/MediaProducer.h: Replace HasActiveMediaCaptureDevice with
+        HasActiveAudioCaptureDevice and HasActiveVideoCaptureDevice.
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::mediaState): Update the logic for mediaState().
+        Since it is possible to arbitrarily add tracks from various sources,
+        check specifically for a local AV source (meaning a capture device) that
+        is producing data.
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::hasLocalVideoSource): Iterate over the tracks
+        and look for video sources that are not remote.
+        (WebCore::MediaStreamPrivate::hasLocalAudioSource): Ditto for audio.
+        * platform/mediastream/MediaStreamPrivate.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::pageMediaState): Update internals reporting.
+
 2016-11-15  Chris Dumez  <[email protected]>
 
         Avoid copying vector of attributes as much as possible in the HTML parser

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (208777 => 208778)


--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2016-11-16 02:55:22 UTC (rev 208778)
@@ -312,11 +312,17 @@
     if (!m_isActive)
         return state;
 
-    if (m_private->isProducingData())
-        state |= HasActiveMediaCaptureDevice;
+    if (m_private->hasAudio()) {
+        state |= HasAudioOrVideo;
+        if (m_private->hasLocalAudioSource() && m_private->isProducingData())
+            state |= HasActiveAudioCaptureDevice;
+    }
 
-    if (m_private->hasAudio() || m_private->hasVideo())
+    if (m_private->hasVideo()) {
         state |= HasAudioOrVideo;
+        if (m_private->hasLocalVideoSource() && m_private->isProducingData())
+            state |= HasActiveVideoCaptureDevice;
+    }
 
     return state;
 }

Modified: trunk/Source/WebCore/page/MediaProducer.h (208777 => 208778)


--- trunk/Source/WebCore/page/MediaProducer.h	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/page/MediaProducer.h	2016-11-16 02:55:22 UTC (rev 208778)
@@ -42,7 +42,8 @@
         IsPreviousTrackControlEnabled = 1 << 8,
         HasPlaybackTargetAvailabilityListener = 1 << 9,
         HasAudioOrVideo = 1 << 10,
-        HasActiveMediaCaptureDevice = 1 << 11,
+        HasActiveAudioCaptureDevice = 1 << 11,
+        HasActiveVideoCaptureDevice = 1 << 12,
     };
     typedef unsigned MediaStateFlags;
 

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp (208777 => 208778)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2016-11-16 02:55:22 UTC (rev 208778)
@@ -199,6 +199,24 @@
     return false;
 }
 
+bool MediaStreamPrivate::hasLocalVideoSource() const
+{
+    for (auto& track : m_trackSet.values()) {
+        if (track->type() == RealtimeMediaSource::Type::Video && !track->remote())
+            return true;
+    }
+    return false;
+}
+
+bool MediaStreamPrivate::hasLocalAudioSource() const
+{
+    for (auto& track : m_trackSet.values()) {
+        if (track->type() == RealtimeMediaSource::Type::Audio && !track->remote())
+            return true;
+    }
+    return false;
+}
+
 bool MediaStreamPrivate::muted() const
 {
     for (auto& track : m_trackSet.values()) {

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h (208777 => 208778)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2016-11-16 02:55:22 UTC (rev 208778)
@@ -101,6 +101,9 @@
     bool hasAudio() const;
     bool muted() const;
 
+    bool hasLocalVideoSource() const;
+    bool hasLocalAudioSource() const;
+
     FloatSize intrinsicSize() const;
 
     WeakPtr<MediaStreamPrivate> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }

Modified: trunk/Source/WebCore/testing/Internals.cpp (208777 => 208778)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-11-16 02:55:22 UTC (rev 208778)
@@ -3010,8 +3010,10 @@
         string.append("HasPlaybackTargetAvailabilityListener,");
     if (state & MediaProducer::HasAudioOrVideo)
         string.append("HasAudioOrVideo,");
-    if (state & MediaProducer::HasActiveMediaCaptureDevice)
-        string.append("HasActiveMediaCaptureDevice,");
+    if (state & MediaProducer::HasActiveAudioCaptureDevice)
+        string.append("HasActiveAudioCaptureDevice,");
+    if (state & MediaProducer::HasActiveVideoCaptureDevice)
+        string.append("HasActiveVideoCaptureDevice,");
 
     if (string.isEmpty())
         string.append("IsNotPlaying");

Modified: trunk/Source/WebKit2/ChangeLog (208777 => 208778)


--- trunk/Source/WebKit2/ChangeLog	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebKit2/ChangeLog	2016-11-16 02:55:22 UTC (rev 208778)
@@ -1,3 +1,20 @@
+2016-11-15  Jon Lee  <[email protected]>
+
+        Report active video and audio capture devices separately
+        https://bugs.webkit.org/show_bug.cgi?id=164769
+
+        Reviewed by Eric Carlson.
+
+        Replace kWKMediaHasActiveCaptureDevice with kWKMediaHasActiveAudioCaptureDevice and
+        kWKMediaHasActiveVideoCaptureDevice
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetMediaState):
+        * UIProcess/API/C/WKPagePrivate.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::isPlayingMediaDidChange): Update the mask to include the two
+        bits.
+
 2016-11-14  Simon Fraser  <[email protected]>
 
         [iOS WK2] Implement support for visual viewports

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (208777 => 208778)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2016-11-16 02:55:22 UTC (rev 208778)
@@ -2748,8 +2748,10 @@
         state |= kWKMediaIsPlayingAudio;
     if (coreState & WebCore::MediaProducer::IsPlayingVideo)
         state |= kWKMediaIsPlayingVideo;
-    if (coreState & WebCore::MediaProducer::HasActiveMediaCaptureDevice)
-        state |= kWKMediaHasActiveCaptureDevice;
+    if (coreState & WebCore::MediaProducer::HasActiveAudioCaptureDevice)
+        state |= kWKMediaHasActiveAudioCaptureDevice;
+    if (coreState & WebCore::MediaProducer::HasActiveVideoCaptureDevice)
+        state |= kWKMediaHasActiveVideoCaptureDevice;
 
     return state;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (208777 => 208778)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2016-11-16 02:55:22 UTC (rev 208778)
@@ -133,7 +133,8 @@
     kWKMediaIsNotPlaying = 0,
     kWKMediaIsPlayingAudio = 1 << 0,
     kWKMediaIsPlayingVideo = 1 << 1,
-    kWKMediaHasActiveCaptureDevice = 1 << 2,
+    kWKMediaHasActiveAudioCaptureDevice = 1 << 2,
+    kWKMediaHasActiveVideoCaptureDevice = 1 << 3,
 };
 typedef uint32_t WKMediaState;
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (208777 => 208778)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-11-16 01:35:09 UTC (rev 208777)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-11-16 02:55:22 UTC (rev 208778)
@@ -6388,7 +6388,7 @@
 
     activityStateDidChange(ActivityState::IsAudible);
 
-    playingMediaMask |= MediaProducer::HasActiveMediaCaptureDevice;
+    playingMediaMask |= MediaProducer::HasActiveAudioCaptureDevice | MediaProducer::HasActiveVideoCaptureDevice;
     if ((oldState & playingMediaMask) != (m_mediaState & playingMediaMask))
         m_uiClient->isPlayingAudioDidChange(*this);
 #if PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to