Title: [201435] trunk/Source/WebCore
Revision
201435
Author
adac...@apple.com
Date
2016-05-26 15:05:26 -0700 (Thu, 26 May 2016)

Log Message

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().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201434 => 201435)


--- trunk/Source/WebCore/ChangeLog	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/ChangeLog	2016-05-26 22:05:26 UTC (rev 201435)
@@ -1,3 +1,36 @@
+2016-05-25  Ada Chan  <adac...@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.no...@apple.com>
 
         Use std::atomic<> rather than OSAtomicIncrement in CARingBuffer.cpp

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (201434 => 201435)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-05-26 22:05:26 UTC (rev 201435)
@@ -152,6 +152,10 @@
 #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 @@
         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

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (201434 => 201435)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-05-26 22:05:26 UTC (rev 201435)
@@ -370,7 +370,7 @@
 
     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 @@
     bool canReceiveRemoteControlCommands() const override { return true; }
     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
+    bool shouldOverrideBackgroundLoadingRestriction() const override;
 
     void pageMutedStateDidChange() override;
 

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (201434 => 201435)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2016-05-26 22:05:26 UTC (rev 201435)
@@ -186,8 +186,7 @@
     
     setState(Paused);
     PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this);
-    if (!m_clientDataBufferingTimer.isActive())
-        m_clientDataBufferingTimer.startOneShot(kClientDataBufferingTimerThrottleDelay);
+    scheduleClientDataBufferingCheck();
     return true;
 }
 
@@ -248,6 +247,11 @@
 
 void PlatformMediaSession::visibilityChanged()
 {
+    scheduleClientDataBufferingCheck();
+}
+
+void PlatformMediaSession::scheduleClientDataBufferingCheck()
+{
     if (!m_clientDataBufferingTimer.isActive())
         m_clientDataBufferingTimer.startOneShot(kClientDataBufferingTimerThrottleDelay);
 }
@@ -283,6 +287,11 @@
     return m_client.elementIsHidden();
 }
 
+bool PlatformMediaSession::shouldOverrideBackgroundLoadingRestriction() const
+{
+    return m_client.shouldOverrideBackgroundLoadingRestriction();
+}
+
 void PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged(bool isWireless)
 {
     if (isWireless == m_isPlayingToWirelessPlaybackTarget)

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (201434 => 201435)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2016-05-26 22:05:26 UTC (rev 201435)
@@ -137,6 +137,8 @@
 
     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 @@
     bool canProduceAudio() const { return m_canProduceAudio; }
     void setCanProduceAudio(bool);
 
+    void scheduleClientDataBufferingCheck();
+
 protected:
     PlatformMediaSessionClient& client() const { return m_client; }
 
@@ -203,6 +207,7 @@
     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>&&) { }

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (201434 => 201435)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2016-05-26 22:03:34 UTC (rev 201434)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2016-05-26 22:05:26 UTC (rev 201435)
@@ -280,7 +280,7 @@
     
 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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to