File buffer-ranges.patch of Package libQtWebKit4

From c3934e3270b74e95b3d15657c0b34e0ff3aa6a13 Mon Sep 17 00:00:00 2001
From: Xabier Rodriguez Calvar <calvaris@igalia.com>
Date: Mon, 4 Mar 2013 11:25:18 +0100
Subject: [PATCH] [GStreamer] Buffering ranges are reported incorrectly with GStreamer 1.0

https://bugs.webkit.org/show_bug.cgi?id=105319

Patch by Xabier Rodriguez Calvar <calvaris@igalia.com> on 2012-12-21
Reviewed by Philippe Normand.

We add the gPercentMax constant to select between 100 and
GST_FORMAT_PERCENT_MAX depending if we are compiling against
GStreamer 0.10 or 1.0 and we use that in the corresponding method.

Current tests should suffice.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::buffered): Added the use of
gPercentMax constant instead of 100 to have the different code
paths for GStreamer 0.10 and 1.0.

Change-Id: I04d57303e683353b8734c62ef5016fa965a9627b
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
---
 .../gstreamer/MediaPlayerPrivateGStreamer.cpp      |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
index f2bd292..736fd5a 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
@@ -74,10 +74,17 @@ typedef enum {
     GST_PLAY_FLAG_BUFFERING     = 0x000000100
 } GstPlayFlags;
 
+// gPercentMax is used when parsing buffering ranges with
+// gst_query_parse_nth_buffering_range as there was a bug in GStreamer
+// 0.10 that was using 100 instead of GST_FORMAT_PERCENT_MAX. This was
+// corrected in 1.0. gst_query_parse_buffering_range worked as
+// expected with GST_FORMAT_PERCENT_MAX in both cases.
 #ifdef GST_API_VERSION_1
 static const char* gPlaybinName = "playbin";
+static const gint64 gPercentMax = GST_FORMAT_PERCENT_MAX;
 #else
 static const char* gPlaybinName = "playbin2";
+static const gint64 gPercentMax = 100;
 #endif
 
 GST_DEBUG_CATEGORY_STATIC(webkit_media_player_debug);
@@ -749,11 +756,11 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateGStreamer::buffered() const
         return timeRanges.release();
     }
 
-    gint64 rangeStart = 0, rangeStop = 0;
     for (guint index = 0; index < gst_query_get_n_buffering_ranges(query); index++) {
+        gint64 rangeStart = 0, rangeStop = 0;
         if (gst_query_parse_nth_buffering_range(query, index, &rangeStart, &rangeStop))
-            timeRanges->add(static_cast<float>((rangeStart * mediaDuration) / 100),
-                            static_cast<float>((rangeStop * mediaDuration) / 100));
+            timeRanges->add(static_cast<float>((rangeStart * mediaDuration) / gPercentMax),
+                static_cast<float>((rangeStop * mediaDuration) / gPercentMax));
     }
 
     // Fallback to the more general maxTimeLoaded() if no range has
-- 
1.7.1
 
openSUSE Build Service is sponsored by