Title: [243537] trunk/Source/WebCore
Revision
243537
Author
[email protected]
Date
2019-03-27 04:34:53 -0700 (Wed, 27 Mar 2019)

Log Message

[GStreamer] Remove the HLS queue buffering query hack
https://bugs.webkit.org/show_bug.cgi?id=196244

Reviewed by Xabier Rodriguez-Calvar.

Because the http src element now provides network statistics to
the player we can now compute an estimation of the data loading in
case the buffering query isn't handled by any element of the
pipeline.

No new tests, existing HLS tests cover this change.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::fillTimerFired):
(WebCore::findHLSQueue): Deleted.
(WebCore::isHLSProgressing): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (243536 => 243537)


--- trunk/Source/WebCore/ChangeLog	2019-03-27 11:34:50 UTC (rev 243536)
+++ trunk/Source/WebCore/ChangeLog	2019-03-27 11:34:53 UTC (rev 243537)
@@ -1,3 +1,22 @@
+2019-03-27  Philippe Normand  <[email protected]>
+
+        [GStreamer] Remove the HLS queue buffering query hack
+        https://bugs.webkit.org/show_bug.cgi?id=196244
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Because the http src element now provides network statistics to
+        the player we can now compute an estimation of the data loading in
+        case the buffering query isn't handled by any element of the
+        pipeline.
+
+        No new tests, existing HLS tests cover this change.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::fillTimerFired):
+        (WebCore::findHLSQueue): Deleted.
+        (WebCore::isHLSProgressing): Deleted.
+
 2019-03-26  Said Abou-Hallawa  <[email protected]>
 
         Unreviewed Windows build fix

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2019-03-27 11:34:50 UTC (rev 243536)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2019-03-27 11:34:53 UTC (rev 243537)
@@ -1374,8 +1374,8 @@
                 }
             }
         } else if (gst_structure_has_name(structure, "webkit-network-statistics")) {
-            if (gst_structure_get_uint64(structure, "read-position", &m_networkReadPosition))
-                GST_DEBUG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT, m_networkReadPosition);
+            if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr))
+                GST_DEBUG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize);
         } else
             GST_DEBUG_OBJECT(pipeline(), "Unhandled element message: %" GST_PTR_FORMAT, structure);
         break;
@@ -1582,63 +1582,27 @@
 }
 #endif
 
-static gint findHLSQueue(gconstpointer a, gconstpointer)
+void MediaPlayerPrivateGStreamer::fillTimerFired()
 {
-    GValue* item = static_cast<GValue*>(const_cast<gpointer>(a));
-    GstElement* element = GST_ELEMENT(g_value_get_object(item));
-    if (g_str_has_prefix(GST_ELEMENT_NAME(element), "queue")) {
-        GstElement* parent = GST_ELEMENT(GST_ELEMENT_PARENT(element));
-        if (!GST_IS_OBJECT(parent))
-            return 1;
+    GRefPtr<GstQuery> query = adoptGRef(gst_query_new_buffering(GST_FORMAT_PERCENT));
+    double fillStatus = 100.0;
 
-        if (g_str_has_prefix(GST_ELEMENT_NAME(GST_ELEMENT_PARENT(parent)), "hlsdemux"))
-            return 0;
-    }
+    if (gst_element_query(m_pipeline.get(), query.get())) {
+        int64_t stop;
+        GstFormat format;
+        gst_query_parse_buffering_range(query.get(), &format, nullptr, &stop, nullptr);
+        ASSERT(format == GST_FORMAT_PERCENT);
 
-    return 1;
-}
-
-static bool isHLSProgressing(GstElement* playbin, GstQuery* query)
-{
-    GValue item = { };
-    GstIterator* binIterator = gst_bin_iterate_recurse(GST_BIN(playbin));
-    bool foundHLSQueue = gst_iterator_find_custom(binIterator, reinterpret_cast<GCompareFunc>(findHLSQueue), &item, nullptr);
-    gst_iterator_free(binIterator);
-
-    if (!foundHLSQueue)
-        return false;
-
-    GstElement* queueElement = GST_ELEMENT(g_value_get_object(&item));
-    bool queryResult = gst_element_query(queueElement, query);
-    g_value_unset(&item);
-
-    return queryResult;
-}
-
-void MediaPlayerPrivateGStreamer::fillTimerFired()
-{
-    GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
-
-    if (G_UNLIKELY(!gst_element_query(m_pipeline.get(), query))) {
-        // This query always fails for live pipelines. In the case of HLS, try and find
-        // the queue inside the HLS element to get a proxy measure of progress. Note
-        // that the percentage value is rather meaningless as used below.
-        // This is a hack, see https://bugs.webkit.org/show_bug.cgi?id=141469.
-        if (!isHLSProgressing(m_pipeline.get(), query)) {
-            gst_query_unref(query);
-            return;
-        }
+        if (stop != -1)
+            fillStatus = 100.0 * stop / GST_FORMAT_PERCENT_MAX;
+    } else if (m_httpResponseTotalSize) {
+        GST_DEBUG_OBJECT(pipeline(), "[Buffering] Query failed, falling back to network read position estimation");
+        fillStatus = 100.0 * (m_networkReadPosition / m_httpResponseTotalSize);
+    } else {
+        GST_DEBUG_OBJECT(pipeline(), "[Buffering] Unable to determine on-disk buffering status");
+        return;
     }
 
-    gint64 start, stop;
-    gdouble fillStatus = 100.0;
-
-    gst_query_parse_buffering_range(query, nullptr, &start, &stop, nullptr);
-    gst_query_unref(query);
-
-    if (stop != -1)
-        fillStatus = 100.0 * stop / GST_FORMAT_PERCENT_MAX;
-
     GST_DEBUG_OBJECT(pipeline(), "[Buffering] Download buffer filled up to %f%%", fillStatus);
 
     MediaTime mediaDuration = durationMediaTime();

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2019-03-27 11:34:50 UTC (rev 243536)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2019-03-27 11:34:53 UTC (rev 243537)
@@ -287,6 +287,7 @@
 #endif
     virtual bool isMediaSource() const { return false; }
 
+    uint64_t m_httpResponseTotalSize { 0 };
     uint64_t m_networkReadPosition { 0 };
     mutable uint64_t m_readPositionAtLastDidLoadingProgress { 0 };
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (243536 => 243537)


--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2019-03-27 11:34:50 UTC (rev 243536)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2019-03-27 11:34:53 UTC (rev 243537)
@@ -998,8 +998,6 @@
     if (LIKELY (priv->requestedPosition == priv->readPosition))
         priv->requestedPosition = newPosition;
     priv->readPosition = newPosition;
-    gst_element_post_message(GST_ELEMENT_CAST(src), gst_message_new_element(GST_OBJECT_CAST(src),
-        gst_structure_new("webkit-network-statistics", "read-position", G_TYPE_UINT64, priv->readPosition, nullptr)));
 
     uint64_t newSize = 0;
     if (priv->haveSize && (newPosition > priv->size)) {
@@ -1017,6 +1015,9 @@
         gst_element_post_message(GST_ELEMENT_CAST(src), gst_message_new_duration_changed(GST_OBJECT_CAST(src)));
     }
 
+    gst_element_post_message(GST_ELEMENT_CAST(src), gst_message_new_element(GST_OBJECT_CAST(src),
+        gst_structure_new("webkit-network-statistics", "read-position", G_TYPE_UINT64, priv->readPosition, "size", G_TYPE_UINT64, priv->size, nullptr)));
+
     checkUpdateBlocksize(length);
 
     if (!priv->wasResponseReceived)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to