Title: [160992] trunk/Source/WebCore
Revision
160992
Author
commit-qu...@webkit.org
Date
2013-12-23 05:15:07 -0800 (Mon, 23 Dec 2013)

Log Message

[GStreamer] video/audio seeking is not unified.
https://bugs.webkit.org/show_bug.cgi?id=125852

Patch by Piotr Grad <p.g...@samsung.com> on 2013-12-23
Reviewed by Philippe Normand.

This bug is fixing regression with seeking audio/video elements and unifies seeking
in MediaPlayerPrivateGStreamer.

Test: media/video-seek-with-negative-playback.html

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::seek):
(WebCore::MediaPlayerPrivateGStreamer::seekIncludingRate):
(WebCore::MediaPlayerPrivateGStreamer::setRate):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160991 => 160992)


--- trunk/Source/WebCore/ChangeLog	2013-12-23 10:18:51 UTC (rev 160991)
+++ trunk/Source/WebCore/ChangeLog	2013-12-23 13:15:07 UTC (rev 160992)
@@ -1,3 +1,22 @@
+2013-12-23  Piotr Grad  <p.g...@samsung.com>
+
+        [GStreamer] video/audio seeking is not unified.
+        https://bugs.webkit.org/show_bug.cgi?id=125852
+
+        Reviewed by Philippe Normand.
+
+        This bug is fixing regression with seeking audio/video elements and unifies seeking
+        in MediaPlayerPrivateGStreamer.
+
+        Test: media/video-seek-with-negative-playback.html
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::seek):
+        (WebCore::MediaPlayerPrivateGStreamer::seekIncludingRate):
+        (WebCore::MediaPlayerPrivateGStreamer::setRate):
+        (WebCore::MediaPlayerPrivateGStreamer::updateStates):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+
 2013-12-23  ChangSeok Oh  <changseok...@collabora.com>
 
         [GTK][WK2] WebGL is not working with GLES

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2013-12-23 10:18:51 UTC (rev 160991)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2013-12-23 13:15:07 UTC (rev 160992)
@@ -599,18 +599,8 @@
                 loadingFailed(MediaPlayer::Empty);
         }
     } else {
-        gint64 startTime, endTime;
-        if (m_player->rate() > 0) {
-            startTime = clockTime;
-            endTime = GST_CLOCK_TIME_NONE;
-        } else {
-            startTime = 0;
-            endTime = clockTime;
-        }
-
         // We can seek now.
-        if (!gst_element_seek(m_playBin.get(), m_player->rate(), GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
-            GST_SEEK_TYPE_SET, startTime, GST_SEEK_TYPE_SET, endTime)) {
+        if (!doSeek(clockTime, m_player->rate(), static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE))) {
             LOG_MEDIA_MESSAGE("[Seek] seeking to %f failed", time);
             return;
         }
@@ -621,6 +611,27 @@
     m_isEndReached = false;
 }
 
+bool MediaPlayerPrivateGStreamer::doSeek(gint64 position, float rate, GstSeekFlags seekType)
+{
+    gint64 startTime, endTime;
+
+    if (rate > 0) {
+        startTime = position;
+        endTime = GST_CLOCK_TIME_NONE;
+    } else {
+        startTime = 0;
+        // If we are at beginning of media, start from the end to
+        // avoid immediate EOS.
+        if (position < 0)
+            endTime = static_cast<gint64>(duration() * GST_SECOND);
+        else
+            endTime = position;
+    }
+
+    return gst_element_seek(m_playBin.get(), rate, GST_FORMAT_TIME, seekType,
+        GST_SEEK_TYPE_SET, startTime, GST_SEEK_TYPE_SET, endTime);
+}
+
 bool MediaPlayerPrivateGStreamer::paused() const
 {
     if (m_isEndReached) {
@@ -842,8 +853,6 @@
     }
 
     float currentPosition = static_cast<float>(playbackPosition() * GST_SECOND);
-    GstSeekFlags flags = (GstSeekFlags)(GST_SEEK_FLAG_FLUSH);
-    gint64 start, end;
     bool mute = false;
 
     INFO_MEDIA_MESSAGE("Set Rate to %f", rate);
@@ -851,25 +860,15 @@
         // Mute the sound if the playback rate is too extreme and
         // audio pitch is not adjusted.
         mute = (!m_preservesPitch && (rate < 0.8 || rate > 2));
-        start = currentPosition;
-        end = GST_CLOCK_TIME_NONE;
     } else {
-        start = 0;
+        if (currentPosition == 0.0f)
+            currentPosition = -1.0f;
         mute = true;
-
-        // If we are at beginning of media, start from the end to
-        // avoid immediate EOS.
-        if (currentPosition <= 0)
-            end = static_cast<gint64>(duration() * GST_SECOND);
-        else
-            end = currentPosition;
     }
 
     INFO_MEDIA_MESSAGE("Need to mute audio?: %d", (int) mute);
 
-    if (!gst_element_seek(m_playBin.get(), rate, GST_FORMAT_TIME, flags,
-                          GST_SEEK_TYPE_SET, start,
-                          GST_SEEK_TYPE_SET, end))
+    if (!doSeek(currentPosition, rate, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH)))
         ERROR_MEDIA_MESSAGE("Set rate to %f failed", rate);
     else
         g_object_set(m_playBin.get(), "mute", mute, NULL);
@@ -1457,8 +1456,7 @@
     if (m_seekIsPending && getStateResult == GST_STATE_CHANGE_SUCCESS && (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING)) {
         LOG_MEDIA_MESSAGE("[Seek] committing pending seek to %f", m_seekTime);
         m_seekIsPending = false;
-        m_seeking = gst_element_seek(m_playBin.get(), m_player->rate(), GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
-            GST_SEEK_TYPE_SET, toGstClockTime(m_seekTime), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+        m_seeking = doSeek(toGstClockTime(m_seekTime), m_player->rate(), static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE));
         if (!m_seeking)
             LOG_MEDIA_MESSAGE("[Seek] seeking to %f failed", m_seekTime);
     }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (160991 => 160992)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2013-12-23 10:18:51 UTC (rev 160991)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2013-12-23 13:15:07 UTC (rev 160992)
@@ -146,7 +146,9 @@
     void processTableOfContents(GstMessage*);
     void processTableOfContentsEntry(GstTocEntry*, GstTocEntry* parent);
 #endif
+    bool doSeek(gint64 position, float rate, GstSeekFlags seekType);
 
+
     virtual String engineDescription() const { return "GStreamer"; }
     virtual bool isLiveStream() const { return m_isStreaming; }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to