Add WebKitAdditions extension point in HTMLMediaElement.
authoradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2016 22:05:26 +0000 (22:05 +0000)
committeradachan@apple.com <adachan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2016 22:05:26 +0000 (22:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158097

Reviewed by Eric Carlson.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::shouldOverrideBackgroundLoadingRestriction):
We need to load data in the background if playing to wireless playback target.
(WebCore::HTMLMediaElement::fullscreenModeChanged):
Moved from header file.
* html/HTMLMediaElement.h:

* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::clientWillPausePlayback):
The code to start m_clientDataBufferingTimer is also in visibilityChanged().
Moved that code to PlatformMediaSession::scheduleClientDataBufferingCheck() and call
that method here.
(WebCore::PlatformMediaSession::visibilityChanged):
Call PlatformMediaSession::scheduleClientDataBufferingCheck().
(WebCore::PlatformMediaSession::scheduleClientDataBufferingCheck):
Start m_clientDataBufferingTimer if it's not already active.
(WebCore::PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction):
Call the client.

* platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSessionClient::shouldOverrideBackgroundLoadingRestriction):

* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::sessionCanLoadMedia):
Call the new PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction().

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/audio/PlatformMediaSession.cpp
Source/WebCore/platform/audio/PlatformMediaSession.h
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp

index 328a07c..95fa13f 100644 (file)
@@ -1,3 +1,36 @@
+2016-05-25  Ada Chan  <adachan@apple.com>
+
+        Add WebKitAdditions extension point in HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=158097
+
+        Reviewed by Eric Carlson.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::shouldOverrideBackgroundLoadingRestriction):
+        We need to load data in the background if playing to wireless playback target.
+        (WebCore::HTMLMediaElement::fullscreenModeChanged):
+        Moved from header file.
+        * html/HTMLMediaElement.h:
+
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::PlatformMediaSession::clientWillPausePlayback):
+        The code to start m_clientDataBufferingTimer is also in visibilityChanged().
+        Moved that code to PlatformMediaSession::scheduleClientDataBufferingCheck() and call
+        that method here.
+        (WebCore::PlatformMediaSession::visibilityChanged):
+        Call PlatformMediaSession::scheduleClientDataBufferingCheck().
+        (WebCore::PlatformMediaSession::scheduleClientDataBufferingCheck):
+        Start m_clientDataBufferingTimer if it's not already active.
+        (WebCore::PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction):
+        Call the client.
+
+        * platform/audio/PlatformMediaSession.h:
+        (WebCore::PlatformMediaSessionClient::shouldOverrideBackgroundLoadingRestriction):
+
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::sessionCanLoadMedia):
+        Call the new PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction().
+
 2016-05-26  Jer Noble  <jer.noble@apple.com>
 
         Use std::atomic<> rather than OSAtomicIncrement in CARingBuffer.cpp
index ef6c98a..86f1eaa 100644 (file)
 #include <bindings/ScriptObject.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/HTMLMediaElementAdditions.cpp>
+#endif
+
 namespace WebCore {
 
 static const double SeekRepeatDelay = 0.1;
@@ -7024,6 +7028,23 @@ void HTMLMediaElement::updatePlaybackControlsManager()
         page->chrome().client().clearPlaybackControlsManager(*this);
 }
 
+#if !USE(APPLE_INTERNAL_SDK)
+bool HTMLMediaElement::shouldOverrideBackgroundLoadingRestriction() const
+{
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    if (isPlayingToWirelessPlaybackTarget())
+        return true;
+#endif
+
+    return false;
+}
+
+void HTMLMediaElement::fullscreenModeChanged(VideoFullscreenMode mode)
+{
+    m_videoFullscreenMode = mode;
+}
+#endif
+
 }
 
 #endif
index 04d0dbd..3be21cf 100644 (file)
@@ -370,7 +370,7 @@ public:
 
     using MediaPlayerEnums::VideoFullscreenMode;
     VideoFullscreenMode fullscreenMode() const { return m_videoFullscreenMode; }
-    virtual void fullscreenModeChanged(VideoFullscreenMode mode) { m_videoFullscreenMode = mode; }
+    virtual void fullscreenModeChanged(VideoFullscreenMode);
 
     void enterFullscreen(VideoFullscreenMode);
     void enterFullscreen() override;
@@ -757,6 +757,7 @@ private:
     bool canReceiveRemoteControlCommands() const override { return true; }
     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
+    bool shouldOverrideBackgroundLoadingRestriction() const override;
 
     void pageMutedStateDidChange() override;
 
index 6bf9ab3..783f8a0 100644 (file)
@@ -186,8 +186,7 @@ bool PlatformMediaSession::clientWillPausePlayback()
     
     setState(Paused);
     PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this);
-    if (!m_clientDataBufferingTimer.isActive())
-        m_clientDataBufferingTimer.startOneShot(kClientDataBufferingTimerThrottleDelay);
+    scheduleClientDataBufferingCheck();
     return true;
 }
 
@@ -248,6 +247,11 @@ void PlatformMediaSession::didReceiveRemoteControlCommand(RemoteControlCommandTy
 
 void PlatformMediaSession::visibilityChanged()
 {
+    scheduleClientDataBufferingCheck();
+}
+
+void PlatformMediaSession::scheduleClientDataBufferingCheck()
+{
     if (!m_clientDataBufferingTimer.isActive())
         m_clientDataBufferingTimer.startOneShot(kClientDataBufferingTimerThrottleDelay);
 }
@@ -283,6 +287,11 @@ bool PlatformMediaSession::isHidden() const
     return m_client.elementIsHidden();
 }
 
+bool PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction() const
+{
+    return m_client.shouldOverrideBackgroundLoadingRestriction();
+}
+
 void PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged(bool isWireless)
 {
     if (isWireless == m_isPlayingToWirelessPlaybackTarget)
index 09c6ec2..f95e24d 100644 (file)
@@ -137,6 +137,8 @@ public:
 
     bool isHidden() const;
 
+    bool shouldOverrideBackgroundLoadingRestriction() const;
+
     virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
     virtual bool isPlayingToWirelessPlaybackTarget() const { return m_isPlayingToWirelessPlaybackTarget; }
     void isPlayingToWirelessPlaybackTargetChanged(bool);
@@ -156,6 +158,8 @@ public:
     bool canProduceAudio() const { return m_canProduceAudio; }
     void setCanProduceAudio(bool);
 
+    void scheduleClientDataBufferingCheck();
+
 protected:
     PlatformMediaSessionClient& client() const { return m_client; }
 
@@ -203,6 +207,7 @@ public:
     virtual bool elementIsHidden() const { return false; }
 
     virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0;
+    virtual bool shouldOverrideBackgroundLoadingRestriction() const { return false; }
 
     virtual void wirelessRoutesAvailableDidChange() { }
     virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) { }
index d2918d8..f2b8957 100644 (file)
@@ -280,7 +280,7 @@ PlatformMediaSession* PlatformMediaSessionManager::currentSession()
     
 bool PlatformMediaSessionManager::sessionCanLoadMedia(const PlatformMediaSession& session) const
 {
-    return session.state() == PlatformMediaSession::Playing || !session.isHidden() || session.isPlayingToWirelessPlaybackTarget();
+    return session.state() == PlatformMediaSession::Playing || !session.isHidden() || session.shouldOverrideBackgroundLoadingRestriction();
 }
 
 void PlatformMediaSessionManager::applicationWillEnterBackground() const