Title: [228945] trunk/Source/WebCore
Revision
228945
Author
ph...@webkit.org
Date
2018-02-23 02:06:46 -0800 (Fri, 23 Feb 2018)

Log Message

[GStreamer] HTTP totalBytes query returns 0 after seeking (sometimes)
https://bugs.webkit.org/show_bug.cgi?id=183002

Reviewed by Xabier Rodriguez-Calvar.

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webkit_web_src_init): Initialize member variables. Also no need
to set the appsrc size at that point.
(webKitWebSrcStop): There is no need to reset the size when
seeking. Size should in most cases represent the Content-Length
response attribute, even when seeking.
(webKitWebSrcStart): No need to reset the size attribute.
(webKitWebSrcQueryWithParent): Let appsrc handle DURATION queries.
(CachedResourceStreamingClient::responseReceived): Emit duration notification one time only.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228944 => 228945)


--- trunk/Source/WebCore/ChangeLog	2018-02-23 09:57:37 UTC (rev 228944)
+++ trunk/Source/WebCore/ChangeLog	2018-02-23 10:06:46 UTC (rev 228945)
@@ -1,5 +1,22 @@
 2018-02-23  Philippe Normand  <pnorm...@igalia.com>
 
+        [GStreamer] HTTP totalBytes query returns 0 after seeking (sometimes)
+        https://bugs.webkit.org/show_bug.cgi?id=183002
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webkit_web_src_init): Initialize member variables. Also no need
+        to set the appsrc size at that point.
+        (webKitWebSrcStop): There is no need to reset the size when
+        seeking. Size should in most cases represent the Content-Length
+        response attribute, even when seeking.
+        (webKitWebSrcStart): No need to reset the size attribute.
+        (webKitWebSrcQueryWithParent): Let appsrc handle DURATION queries.
+        (CachedResourceStreamingClient::responseReceived): Emit duration notification one time only.
+
+2018-02-23  Philippe Normand  <pnorm...@igalia.com>
+
         [GStreamer] media/video-src-blob-using-open-panel.html crashes in Debug
         https://bugs.webkit.org/show_bug.cgi?id=183005
 

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2018-02-23 09:57:37 UTC (rev 228944)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2018-02-23 10:06:46 UTC (rev 228945)
@@ -83,6 +83,7 @@
     bool didPassAccessControlCheck;
 
     guint64 offset;
+    bool haveSize;
     guint64 size;
     gboolean seekable;
     bool paused;
@@ -204,6 +205,9 @@
 
     priv->notifier = MainThreadNotifier<MainThreadSourceNotification>::create();
 
+    priv->haveSize = FALSE;
+    priv->size = 0;
+
     priv->appsrc = GST_APP_SRC(gst_element_factory_make("appsrc", nullptr));
     if (!priv->appsrc) {
         GST_ERROR_OBJECT(src, "Failed to create appsrc");
@@ -246,7 +250,6 @@
     gst_base_src_set_automatic_eos(GST_BASE_SRC(priv->appsrc), FALSE);
 
     gst_app_src_set_caps(priv->appsrc, nullptr);
-    gst_app_src_set_size(priv->appsrc, -1);
 }
 
 static void webKitWebSrcDispose(GObject* object)
@@ -360,7 +363,6 @@
     priv->offset = 0;
 
     if (!wasSeeking) {
-        priv->size = 0;
         priv->requestedOffset = 0;
         priv->player = nullptr;
         priv->seekable = FALSE;
@@ -446,8 +448,6 @@
     request.setAllowCookies(true);
     request.setFirstPartyForCookies(url);
 
-    priv->size = 0;
-
     request.setHTTPReferrer(priv->player->referrer());
 
     if (priv->httpMethod.get())
@@ -563,18 +563,6 @@
     gboolean result = FALSE;
 
     switch (GST_QUERY_TYPE(query)) {
-    case GST_QUERY_DURATION: {
-        GstFormat format;
-
-        gst_query_parse_duration(query, &format, nullptr);
-
-        GST_LOG_OBJECT(src, "duration query in format %s, current size: %lu", gst_format_get_name(format), priv->size);
-        if (format == GST_FORMAT_BYTES && priv->size > 0) {
-            gst_query_set_duration(query, format, priv->size);
-            result = TRUE;
-        }
-        break;
-    }
     case GST_QUERY_URI: {
         gst_query_set_uri(query, priv->originalURI.data());
         if (!priv->redirectedURI.isNull())
@@ -792,14 +780,17 @@
     if (length > 0 && priv->requestedOffset && response.httpStatusCode() == 206)
         length += priv->requestedOffset;
 
-    priv->size = length >= 0 ? length : 0;
     priv->seekable = length > 0 && g_ascii_strcasecmp("none", response.httpHeaderField(HTTPHeaderName::AcceptRanges).utf8().data());
 
-    GST_DEBUG_OBJECT(src, "Size: %" G_GINT64_FORMAT ", seekable: %s", priv->size, priv->seekable ? "yes" : "no");
+    GST_DEBUG_OBJECT(src, "Size: %lld, seekable: %s", length, priv->seekable ? "yes" : "no");
     // notify size/duration
-    if (length > 0)
-        gst_app_src_set_size(priv->appsrc, length);
-    else {
+    if (length > 0) {
+        if (!priv->haveSize || (static_cast<long long>(priv->size) != length)) {
+            priv->haveSize = TRUE;
+            priv->size = length;
+            gst_app_src_set_size(priv->appsrc, length);
+        }
+    } else {
         gst_app_src_set_size(priv->appsrc, -1);
         if (!priv->seekable)
             gst_app_src_set_stream_type(priv->appsrc, GST_APP_STREAM_TYPE_STREAM);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to