Changeset 208778 in webkit


Ignore:
Timestamp:
Nov 15, 2016 6:55:22 PM (7 years ago)
Author:
jonlee@apple.com
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:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208775 r208778  
     12016-11-15  Jon Lee  <jonlee@apple.com>
     2
     3        Report active video and audio capture devices separately
     4        https://bugs.webkit.org/show_bug.cgi?id=164769
     5
     6        Reviewed by Eric Carlson.
     7
     8        * fast/mediastream/MediaStream-page-muted-expected.txt: Update test.
     9        * fast/mediastream/MediaStream-page-muted.html:
     10
    1112016-11-15  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/LayoutTests/fast/mediastream/MediaStream-page-muted-expected.txt

    r208735 r208778  
    88PASS mediaStream is an instance of Object
    99PASS mediaStream.getTracks().length is 2
    10 PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
     10PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became true
    1111
    1212*** Muting capture devices
     
    1616PASS muteChangedEvent.target.muted is true
    1717
    18 PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became false
     18PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became false
    1919
    2020*** Unmuting capture devices
     
    2424PASS muteChangedEvent.target.muted is false
    2525
    26 PASS window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice') became true
     26PASS window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice') became true
    2727PASS successfullyParsed is true
    2828
  • trunk/LayoutTests/fast/mediastream/MediaStream-page-muted.html

    r208735 r208778  
    2929                    debug("");
    3030                    let shouldBeActive = muteChangedEvent.type == "mute" ? "false" : "true";
    31                     shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", shouldBeActive, nextStep);
     31                    shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice')", shouldBeActive, nextStep);
    3232                }
    3333            }
     
    5454                        }
    5555
    56                         shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveMediaCaptureDevice')", "true", muteCaptureDevices);
     56                        shouldBecomeEqual("window.internals.pageMediaState().includes('HasActiveAudioCaptureDevice') && window.internals.pageMediaState().includes('HasActiveVideoCaptureDevice')", "true", muteCaptureDevices);
    5757                    })
    5858                    .catch((err) => {
  • trunk/Source/WebCore/ChangeLog

    r208776 r208778  
     12016-11-15  Jon Lee  <jonlee@apple.com>
     2
     3        Report active video and audio capture devices separately
     4        https://bugs.webkit.org/show_bug.cgi?id=164769
     5
     6        Reviewed by Eric Carlson.
     7
     8        For UI purposes, separate the notion of any active capture device to
     9        an active audio and video capture device.
     10
     11        * page/MediaProducer.h: Replace HasActiveMediaCaptureDevice with
     12        HasActiveAudioCaptureDevice and HasActiveVideoCaptureDevice.
     13
     14        * Modules/mediastream/MediaStream.cpp:
     15        (WebCore::MediaStream::mediaState): Update the logic for mediaState().
     16        Since it is possible to arbitrarily add tracks from various sources,
     17        check specifically for a local AV source (meaning a capture device) that
     18        is producing data.
     19        * platform/mediastream/MediaStreamPrivate.cpp:
     20        (WebCore::MediaStreamPrivate::hasLocalVideoSource): Iterate over the tracks
     21        and look for video sources that are not remote.
     22        (WebCore::MediaStreamPrivate::hasLocalAudioSource): Ditto for audio.
     23        * platform/mediastream/MediaStreamPrivate.h:
     24        * testing/Internals.cpp:
     25        (WebCore::Internals::pageMediaState): Update internals reporting.
     26
    1272016-11-15  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp

    r208735 r208778  
    313313        return state;
    314314
    315     if (m_private->isProducingData())
    316         state |= HasActiveMediaCaptureDevice;
    317 
    318     if (m_private->hasAudio() || m_private->hasVideo())
     315    if (m_private->hasAudio()) {
    319316        state |= HasAudioOrVideo;
     317        if (m_private->hasLocalAudioSource() && m_private->isProducingData())
     318            state |= HasActiveAudioCaptureDevice;
     319    }
     320
     321    if (m_private->hasVideo()) {
     322        state |= HasAudioOrVideo;
     323        if (m_private->hasLocalVideoSource() && m_private->isProducingData())
     324            state |= HasActiveVideoCaptureDevice;
     325    }
    320326
    321327    return state;
  • trunk/Source/WebCore/page/MediaProducer.h

    r208735 r208778  
    4343        HasPlaybackTargetAvailabilityListener = 1 << 9,
    4444        HasAudioOrVideo = 1 << 10,
    45         HasActiveMediaCaptureDevice = 1 << 11,
     45        HasActiveAudioCaptureDevice = 1 << 11,
     46        HasActiveVideoCaptureDevice = 1 << 12,
    4647    };
    4748    typedef unsigned MediaStateFlags;
  • trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp

    r208687 r208778  
    200200}
    201201
     202bool MediaStreamPrivate::hasLocalVideoSource() const
     203{
     204    for (auto& track : m_trackSet.values()) {
     205        if (track->type() == RealtimeMediaSource::Type::Video && !track->remote())
     206            return true;
     207    }
     208    return false;
     209}
     210
     211bool MediaStreamPrivate::hasLocalAudioSource() const
     212{
     213    for (auto& track : m_trackSet.values()) {
     214        if (track->type() == RealtimeMediaSource::Type::Audio && !track->remote())
     215            return true;
     216    }
     217    return false;
     218}
     219
    202220bool MediaStreamPrivate::muted() const
    203221{
  • trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h

    r208687 r208778  
    102102    bool muted() const;
    103103
     104    bool hasLocalVideoSource() const;
     105    bool hasLocalAudioSource() const;
     106
    104107    FloatSize intrinsicSize() const;
    105108
  • trunk/Source/WebCore/testing/Internals.cpp

    r208735 r208778  
    30113011    if (state & MediaProducer::HasAudioOrVideo)
    30123012        string.append("HasAudioOrVideo,");
    3013     if (state & MediaProducer::HasActiveMediaCaptureDevice)
    3014         string.append("HasActiveMediaCaptureDevice,");
     3013    if (state & MediaProducer::HasActiveAudioCaptureDevice)
     3014        string.append("HasActiveAudioCaptureDevice,");
     3015    if (state & MediaProducer::HasActiveVideoCaptureDevice)
     3016        string.append("HasActiveVideoCaptureDevice,");
    30153017
    30163018    if (string.isEmpty())
  • trunk/Source/WebKit2/ChangeLog

    r208748 r208778  
     12016-11-15  Jon Lee  <jonlee@apple.com>
     2
     3        Report active video and audio capture devices separately
     4        https://bugs.webkit.org/show_bug.cgi?id=164769
     5
     6        Reviewed by Eric Carlson.
     7
     8        Replace kWKMediaHasActiveCaptureDevice with kWKMediaHasActiveAudioCaptureDevice and
     9        kWKMediaHasActiveVideoCaptureDevice
     10
     11        * UIProcess/API/C/WKPage.cpp:
     12        (WKPageGetMediaState):
     13        * UIProcess/API/C/WKPagePrivate.h:
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::isPlayingMediaDidChange): Update the mask to include the two
     16        bits.
     17
    1182016-11-14  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r208735 r208778  
    27492749    if (coreState & WebCore::MediaProducer::IsPlayingVideo)
    27502750        state |= kWKMediaIsPlayingVideo;
    2751     if (coreState & WebCore::MediaProducer::HasActiveMediaCaptureDevice)
    2752         state |= kWKMediaHasActiveCaptureDevice;
     2751    if (coreState & WebCore::MediaProducer::HasActiveAudioCaptureDevice)
     2752        state |= kWKMediaHasActiveAudioCaptureDevice;
     2753    if (coreState & WebCore::MediaProducer::HasActiveVideoCaptureDevice)
     2754        state |= kWKMediaHasActiveVideoCaptureDevice;
    27532755
    27542756    return state;
  • trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h

    r208735 r208778  
    134134    kWKMediaIsPlayingAudio = 1 << 0,
    135135    kWKMediaIsPlayingVideo = 1 << 1,
    136     kWKMediaHasActiveCaptureDevice = 1 << 2,
     136    kWKMediaHasActiveAudioCaptureDevice = 1 << 2,
     137    kWKMediaHasActiveVideoCaptureDevice = 1 << 3,
    137138};
    138139typedef uint32_t WKMediaState;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r208727 r208778  
    63896389    activityStateDidChange(ActivityState::IsAudible);
    63906390
    6391     playingMediaMask |= MediaProducer::HasActiveMediaCaptureDevice;
     6391    playingMediaMask |= MediaProducer::HasActiveAudioCaptureDevice | MediaProducer::HasActiveVideoCaptureDevice;
    63926392    if ((oldState & playingMediaMask) != (m_mediaState & playingMediaMask))
    63936393        m_uiClient->isPlayingAudioDidChange(*this);
Note: See TracChangeset for help on using the changeset viewer.