Title: [152391] trunk
Revision
152391
Author
[email protected]
Date
2013-07-04 00:44:16 -0700 (Thu, 04 Jul 2013)

Log Message

[GStreamer] support preload="metadata"
https://bugs.webkit.org/show_bug.cgi?id=116817

Reviewed by Eric Carlson.

Source/WebCore:

Add appropriate behavior for preload="metadata". Delay enabling download buffering
until playback is started in this case. This behavior fits with the standard quite
well and this is the most exact match we can get (at least without adding too much
extra complexity). What matters mostly is that we can avoid loading the media
before playback but we have the first frame and the metadata.

Test: media/video-load-preload-metadata.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::prepareToPlay): Set |m_preload| to |Auto|
so we will start download buffering if we did not start it yet.
(WebCore::MediaPlayerPrivateGStreamer::play): Ditto.
(MediaPlayerPrivateGStreamer::setDownloadBuffering): Only start download
buffering if |m_preload == Auto|. Also make sure we don't clear the download
flag once we started downloading because it would result in not well defined
behavior and it does not really makes sense.
(MediaPlayerPrivateGStreamer::setPreload): Set download buffering accordingly.

LayoutTests:

* media/video-load-preload-metadata.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152390 => 152391)


--- trunk/LayoutTests/ChangeLog	2013-07-04 06:44:59 UTC (rev 152390)
+++ trunk/LayoutTests/ChangeLog	2013-07-04 07:44:16 UTC (rev 152391)
@@ -1,3 +1,12 @@
+2013-07-04  Balazs Kelemen  <[email protected]>
+
+        [GStreamer] support preload="metadata"
+        https://bugs.webkit.org/show_bug.cgi?id=116817
+
+        Reviewed by Eric Carlson.
+
+        * media/video-load-preload-metadata.html: Added.
+
 2013-07-03  Chris Fleizach  <[email protected]>
 
         AX: Items the img aria role aren't inserting an object replacement character

Added: trunk/LayoutTests/media/video-load-preload-metadata-expected.txt (0 => 152391)


--- trunk/LayoutTests/media/video-load-preload-metadata-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-load-preload-metadata-expected.txt	2013-07-04 07:44:16 UTC (rev 152391)
@@ -0,0 +1,12 @@
+Test that preload="metadata" disables buffering before playback.
+
+EXPECTED (video.preload == 'metadata') OK
+EVENT(loadedmetadata)
+EXPECTED (video.readyState < '4') OK
+EXPECTED (video.buffered.length == '0') OK
+RUN(video.play())
+EVENT(canplaythrough)
+TEST(playbackStarted) OK
+EXPECTED (video.buffered.length > '0') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/video-load-preload-metadata.html (0 => 152391)


--- trunk/LayoutTests/media/video-load-preload-metadata.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-load-preload-metadata.html	2013-07-04 07:44:16 UTC (rev 152391)
@@ -0,0 +1,40 @@
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            var playbackStarted = false;
+            function start()
+            {
+                findMediaElement();
+                video.src = "" "content/test");
+
+                testExpected("video.preload", "metadata");
+                waitForEvent('loadedmetadata', onLoadedMetadata);
+                waitForEvent('canplaythrough', onCanPlayThrough);
+                failTestIn(2000);
+            }
+            function onLoadedMetadata()
+            {
+                testExpected("video.readyState", HTMLMediaElement.HAVE_ENOUGH_DATA, "<");
+
+                setTimeout(function () {
+                    testExpected("video.buffered.length", 0, "==");
+                    playbackStarted = true;
+                    run("video.play()");
+                }, 250);
+            }
+            function onCanPlayThrough()
+            {
+                test("playbackStarted");
+                testExpected("video.buffered.length", 0, ">");
+                endTest();
+            }
+        </script>
+    </head>
+
+    <body _onload_="start()">
+        <video controls preload="metadata"></video>
+        <p>Test that preload="metadata" disables buffering before playback.</p>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (152390 => 152391)


--- trunk/Source/WebCore/ChangeLog	2013-07-04 06:44:59 UTC (rev 152390)
+++ trunk/Source/WebCore/ChangeLog	2013-07-04 07:44:16 UTC (rev 152391)
@@ -1,3 +1,28 @@
+2013-07-04  Balazs Kelemen  <[email protected]>
+
+        [GStreamer] support preload="metadata"
+        https://bugs.webkit.org/show_bug.cgi?id=116817
+
+        Reviewed by Eric Carlson.
+
+        Add appropriate behavior for preload="metadata". Delay enabling download buffering
+        until playback is started in this case. This behavior fits with the standard quite
+        well and this is the most exact match we can get (at least without adding too much
+        extra complexity). What matters mostly is that we can avoid loading the media
+        before playback but we have the first frame and the metadata.
+
+        Test: media/video-load-preload-metadata.html
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::prepareToPlay): Set |m_preload| to |Auto|
+        so we will start download buffering if we did not start it yet.
+        (WebCore::MediaPlayerPrivateGStreamer::play): Ditto.
+        (MediaPlayerPrivateGStreamer::setDownloadBuffering): Only start download
+        buffering if |m_preload == Auto|. Also make sure we don't clear the download
+        flag once we started downloading because it would result in not well defined
+        behavior and it does not really makes sense.
+        (MediaPlayerPrivateGStreamer::setPreload): Set download buffering accordingly.
+
 2013-07-03  Jae Hyun Park  <[email protected]>
 
         [Coordinated Graphics] Don't use && operator in ASSERT

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (152390 => 152391)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2013-07-04 06:44:59 UTC (rev 152390)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2013-07-04 07:44:16 UTC (rev 152391)
@@ -396,6 +396,7 @@
 
 void MediaPlayerPrivateGStreamer::prepareToPlay()
 {
+    m_preload = MediaPlayer::Auto;
     if (m_delayingLoad) {
         m_delayingLoad = false;
         commitLoad();
@@ -407,6 +408,7 @@
     if (changePipelineState(GST_STATE_PLAYING)) {
         m_isEndReached = false;
         m_delayingLoad = false;
+        m_preload = MediaPlayer::Auto;
         setDownloadBuffering();
         LOG_MEDIA_MESSAGE("Play");
     }
@@ -1081,8 +1083,10 @@
         if (state <= GST_STATE_READY) {
             m_resetPipeline = true;
             m_mediaDuration = 0;
-        } else
+        } else {
+            m_resetPipeline = false;
             cacheDuration();
+        }
 
         bool didBuffering = m_buffering;
 
@@ -1517,7 +1521,12 @@
 
     GstPlayFlags flags;
     g_object_get(m_playBin.get(), "flags", &flags, NULL);
-    bool shouldDownload = !isLiveStream();
+
+    // We don't want to stop downloading if we already started it.
+    if (flags & GST_PLAY_FLAG_DOWNLOAD && m_readyState > MediaPlayer::HaveNothing && !m_resetPipeline)
+        return;
+
+    bool shouldDownload = !isLiveStream() && m_preload == MediaPlayer::Auto;
     if (shouldDownload) {
         LOG_MEDIA_MESSAGE("Enabling on-disk buffering");
         g_object_set(m_playBin.get(), "flags", flags | GST_PLAY_FLAG_DOWNLOAD, NULL);
@@ -1535,6 +1544,7 @@
         return;
 
     m_preload = preload;
+    setDownloadBuffering();
 
     if (m_delayingLoad && m_preload != MediaPlayer::None) {
         m_delayingLoad = false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to