Changeset 185477 in webkit


Ignore:
Timestamp:
Jun 11, 2015 2:49:49 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Media Session: Add plumbing for media control event delivery.
https://bugs.webkit.org/show_bug.cgi?id=145859

Patch by Matt Rajca <mrajca@apple.com> on 2015-06-11
Reviewed by Anders Carlsson.

Source/WebCore:

  • Modules/mediasession/MediaEventTypes.h: Added.
  • WebCore.xcodeproj/project.pbxproj:
  • page/Page.cpp:

(WebCore::Page::handleMediaEvent): Toggle media playback upon receiving the PlayPause event as described in the spec.

  • page/Page.h:

Source/WebKit2:

  • UIProcess/API/C/WKPage.cpp:

(WKPageHandleMediaEvent):

  • UIProcess/API/C/WKPagePrivate.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::handleMediaEvent):

  • UIProcess/WebPageProxy.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::handleMediaEvent):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
Location:
trunk/Source
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185472 r185477  
     12015-06-11  Matt Rajca  <mrajca@apple.com>
     2
     3        Media Session: Add plumbing for media control event delivery.
     4        https://bugs.webkit.org/show_bug.cgi?id=145859
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Modules/mediasession/MediaEventTypes.h: Added.
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * page/Page.cpp:
     11        (WebCore::Page::handleMediaEvent): Toggle media playback upon receiving the PlayPause event as described in the spec.
     12        * page/Page.h:
     13
    1142015-06-11  Jon Lee  <jonlee@apple.com>
    215
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r185459 r185477  
    57035703                C968B2E81B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C968B2E71B1E778100EF1F81 /* HTMLMediaElementMediaSession.cpp */; };
    57045704                C9DADBCB1B1D3B97001F17D8 /* JSMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */; };
     5705                C9F87CFE1B28F40E00979B83 /* MediaEventTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    57055706                CA3BF67C10D99BAE00E6CE53 /* ScrollAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */; };
    57065707                CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1327713278                C9DADBC91B1D3B25001F17D8 /* JSMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaSession.cpp; sourceTree = "<group>"; };
    1327813279                C9DADBCA1B1D3B25001F17D8 /* JSMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaSession.h; sourceTree = "<group>"; };
     13280                C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaEventTypes.h; sourceTree = "<group>"; };
    1327913281                CA3BF67B10D99BAE00E6CE53 /* ScrollAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollAnimator.cpp; sourceTree = "<group>"; };
    1328013282                CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = "<group>"; };
     
    1462314625                                C968B2E61B1E72F700EF1F81 /* HTMLMediaElementMediaSession.h */,
    1462414626                                C968B2E51B1E704500EF1F81 /* HTMLMediaElementMediaSession.idl */,
     14627                                C9F87CFD1B28E5F600979B83 /* MediaEventTypes.h */,
    1462514628                                C90843CD1B18E47D00B68564 /* MediaRemoteControls.cpp */,
    1462614629                                C90843CE1B18E47D00B68564 /* MediaRemoteControls.h */,
     
    2584025843                                07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */,
    2584125844                                E44613AD0CD6331000FADA75 /* MediaError.h in Headers */,
     25845                                C9F87CFE1B28F40E00979B83 /* MediaEventTypes.h in Headers */,
    2584225846                                4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */,
    2584325847                                07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */,
  • trunk/Source/WebCore/page/Page.cpp

    r185231 r185477  
    111111#endif
    112112
     113#if ENABLE(MEDIA_SESSION)
     114#include "MediaSessionManager.h"
     115#endif
     116
    113117namespace WebCore {
    114118
     
    12281232}
    12291233
     1234#if ENABLE(MEDIA_SESSION)
     1235void Page::handleMediaEvent(MediaEventType eventType)
     1236{
     1237    switch (eventType) {
     1238    case MediaEventType::PlayPause:
     1239        MediaSessionManager::singleton().togglePlayback();
     1240        break;
     1241    default:
     1242        break;
     1243    }
     1244}
     1245#endif
     1246
    12301247#if !ASSERT_DISABLED
    12311248void Page::checkSubframeCountConsistency() const
  • trunk/Source/WebCore/page/Page.h

    r185337 r185477  
    5353#if PLATFORM(COCOA)
    5454#include <wtf/SchedulePair.h>
     55#endif
     56
     57#if ENABLE(MEDIA_SESSION)
     58#include "MediaEventTypes.h"
    5559#endif
    5660
     
    444448    WEBCORE_EXPORT void setMuted(bool);
    445449
     450#if ENABLE(MEDIA_SESSION)
     451    WEBCORE_EXPORT void handleMediaEvent(MediaEventType);
     452#endif
     453
    446454#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    447455    void addPlaybackTargetPickerClient(uint64_t);
  • trunk/Source/WebKit2/ChangeLog

    r185475 r185477  
     12015-06-11  Matt Rajca  <mrajca@apple.com>
     2
     3        Media Session: Add plumbing for media control event delivery.
     4        https://bugs.webkit.org/show_bug.cgi?id=145859
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/C/WKPage.cpp:
     9        (WKPageHandleMediaEvent):
     10        * UIProcess/API/C/WKPagePrivate.h:
     11        * UIProcess/WebPageProxy.cpp:
     12        (WebKit::WebPageProxy::handleMediaEvent):
     13        * UIProcess/WebPageProxy.h:
     14        * WebProcess/WebPage/WebPage.cpp:
     15        (WebKit::WebPage::handleMediaEvent):
     16        * WebProcess/WebPage/WebPage.h:
     17        * WebProcess/WebPage/WebPage.messages.in:
     18
    1192015-06-11  Myles C. Maxfield  <mmaxfield@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp

    r185072 r185477  
    7979#endif
    8080
     81#if ENABLE(MEDIA_SESSION)
     82#include <WebCore/MediaEventTypes.h>
     83#endif
     84
    8185using namespace WebCore;
    8286using namespace WebKit;
     
    21222126}
    21232127
     2128void WKPageHandleMediaEvent(WKPageRef page, WKMediaEventType wkEventType)
     2129{
     2130#if ENABLE(MEDIA_SESSION)
     2131    MediaEventType eventType;
     2132
     2133    switch (wkEventType) {
     2134    case kWKMediaEventTypePlayPause:
     2135        eventType = MediaEventType::PlayPause;
     2136        break;
     2137    case kWKMediaEventTypeTrackNext:
     2138        eventType = MediaEventType::TrackNext;
     2139        break;
     2140    case kWKMediaEventTypeTrackPrevious:
     2141        eventType = MediaEventType::TrackPrevious;
     2142        break;
     2143    default:
     2144        ASSERT_NOT_REACHED();
     2145    }
     2146
     2147    toImpl(page)->handleMediaEvent(eventType);
     2148#else
     2149    UNUSED_PARAM(page);
     2150    UNUSED_PARAM(wkEventType);
     2151#endif
     2152}
     2153
    21242154void WKPagePostMessageToInjectedBundle(WKPageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
    21252155{
  • trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h

    r185072 r185477  
    112112WK_EXPORT void WKPageSetMuted(WKPageRef page, bool muted);
    113113
     114enum {
     115    kWKMediaEventTypePlayPause,
     116    kWKMediaEventTypeTrackNext,
     117    kWKMediaEventTypeTrackPrevious
     118};
     119typedef uint32_t WKMediaEventType;
     120
     121WK_EXPORT void WKPageHandleMediaEvent(WKPageRef page, WKMediaEventType event);
     122
    114123WK_EXPORT void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef page, WKURLRef url, bool shouldOpenExternalURLs);
    115124
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r184950 r185477  
    37753775}
    37763776
     3777#if ENABLE(MEDIA_SESSION)
     3778void WebPageProxy::handleMediaEvent(MediaEventType eventType)
     3779{
     3780    if (!isValid())
     3781        return;
     3782   
     3783    m_process->send(Messages::WebPage::HandleMediaEvent(eventType), m_pageID);
     3784}
     3785#endif
     3786
    37773787void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
    37783788{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r185123 r185477  
    923923    bool mayStartMediaWhenInWindow() const { return m_mayStartMediaWhenInWindow; }
    924924       
     925#if ENABLE(MEDIA_SESSION)
     926    void handleMediaEvent(WebCore::MediaEventType);
     927#endif
     928
    925929    // WebPopupMenuProxy::Client
    926930    virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent() override;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r185123 r185477  
    40494049}
    40504050
     4051#if ENABLE(MEDIA_SESSION)
     4052void WebPage::handleMediaEvent(uint32_t eventType)
     4053{
     4054    m_page->handleMediaEvent(static_cast<MediaEventType>(eventType));
     4055}
     4056#endif
     4057
    40514058void WebPage::setMayStartMediaWhenInWindow(bool mayStartMedia)
    40524059{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r185123 r185477  
    741741    void setMayStartMediaWhenInWindow(bool);
    742742
     743#if ENABLE(MEDIA_SESSION)
     744    void handleMediaEvent(uint32_t /* WebCore::MediaEventType */);
     745#endif
     746
    743747    void updateMainFrameScrollOffsetPinning();
    744748
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r185123 r185477  
    315315    SetMayStartMediaWhenInWindow(bool mayStartMedia)
    316316
     317#if ENABLE(MEDIA_SESSION)
     318    HandleMediaEvent(uint32_t eventType)
     319#endif
     320
    317321    // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
    318322    // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
Note: See TracChangeset for help on using the changeset viewer.