Title: [226974] trunk/Source/WebCore
Revision
226974
Author
[email protected]
Date
2018-01-16 08:01:20 -0800 (Tue, 16 Jan 2018)

Log Message

[GStreamer] Live streaming cleanups
https://bugs.webkit.org/show_bug.cgi?id=181672

Reviewed by Michael Catanzaro.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleMessage): Switch to
streaming code path when no content-length was reported by the
http source element.
(WebCore::MediaPlayerPrivateGStreamer::totalBytes const): Return early when streaming.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(CachedResourceStreamingClient::responseReceived): Emit headers as
an element message, like souphttpsrc.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226973 => 226974)


--- trunk/Source/WebCore/ChangeLog	2018-01-16 15:59:59 UTC (rev 226973)
+++ trunk/Source/WebCore/ChangeLog	2018-01-16 16:01:20 UTC (rev 226974)
@@ -1,3 +1,19 @@
+2018-01-16  Philippe Normand  <[email protected]>
+
+        [GStreamer] Live streaming cleanups
+        https://bugs.webkit.org/show_bug.cgi?id=181672
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Switch to
+        streaming code path when no content-length was reported by the
+        http source element.
+        (WebCore::MediaPlayerPrivateGStreamer::totalBytes const): Return early when streaming.
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (CachedResourceStreamingClient::responseReceived): Emit headers as
+        an element message, like souphttpsrc.
+
 2018-01-15  Philippe Normand  <[email protected]>
 
         [GStreamer] misc fixes and cleanups

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2018-01-16 15:59:59 UTC (rev 226973)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2018-01-16 16:01:20 UTC (rev 226974)
@@ -30,7 +30,7 @@
 
 #include "FileSystem.h"
 #include "GStreamerUtilities.h"
-#include "URL.h"
+#include "HTTPHeaderNames.h"
 #include "MIMETypeRegistry.h"
 #include "MediaPlayer.h"
 #include "MediaPlayerRequestInstallMissingPluginsCallback.h"
@@ -37,6 +37,7 @@
 #include "NotImplemented.h"
 #include "SecurityOrigin.h"
 #include "TimeRanges.h"
+#include "URL.h"
 #include "WebKitWebSourceGStreamer.h"
 #include <glib.h>
 #include <gst/gst.h>
@@ -1054,6 +1055,18 @@
             handleProtectionEvent(event.get());
         }
 #endif
+        else if (gst_structure_has_name(structure, "http-headers")) {
+            GstStructure* responseHeaders;
+            if (gst_structure_get(structure, "response-headers", GST_TYPE_STRUCTURE, &responseHeaders, nullptr)) {
+                if (!gst_structure_has_field(responseHeaders, httpHeaderNameString(HTTPHeaderName::ContentLength).utf8().data())) {
+                    GST_INFO("Live stream detected. Disabling on-disk buffering");
+                    m_isStreaming = true;
+                    setDownloadBuffering();
+                }
+                gst_structure_free(responseHeaders);
+            }
+        } else
+            GST_DEBUG("Unhandled element message: %" GST_PTR_FORMAT, structure);
         break;
 #if ENABLE(VIDEO_TRACK)
     case GST_MESSAGE_TOC:
@@ -1326,6 +1339,9 @@
     if (!m_source)
         return 0;
 
+    if (m_isStreaming)
+        return 0;
+
     GstFormat fmt = GST_FORMAT_BYTES;
     gint64 length = 0;
     if (gst_element_query_duration(m_source.get(), fmt, &length)) {

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2018-01-16 15:59:59 UTC (rev 226973)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2018-01-16 16:01:20 UTC (rev 226974)
@@ -825,19 +825,26 @@
 
     gst_app_src_set_caps(priv->appsrc, caps.get());
 
-    // Emit a GST_EVENT_CUSTOM_DOWNSTREAM_STICKY event to let GStreamer know about the HTTP headers sent and received.
+    // Emit a GST_EVENT_CUSTOM_DOWNSTREAM_STICKY event and message to let
+    // GStreamer know about the HTTP headers sent and received.
     GstStructure* httpHeaders = gst_structure_new_empty("http-headers");
-    gst_structure_set(httpHeaders, "uri", G_TYPE_STRING, priv->originalURI.data(), nullptr);
+    gst_structure_set(httpHeaders, "uri", G_TYPE_STRING, priv->originalURI.data(),
+        "http-status-code", G_TYPE_UINT, response.httpStatusCode(), nullptr);
     if (!priv->redirectedURI.isNull())
         gst_structure_set(httpHeaders, "redirection-uri", G_TYPE_STRING, priv->redirectedURI.data(), nullptr);
     GUniquePtr<GstStructure> headers(gst_structure_new_empty("request-headers"));
     for (const auto& header : m_request.httpHeaderFields())
         gst_structure_set(headers.get(), header.key.utf8().data(), G_TYPE_STRING, header.value.utf8().data(), nullptr);
+    GST_DEBUG_OBJECT(src, "Request headers going downstream: %" GST_PTR_FORMAT, headers.get());
     gst_structure_set(httpHeaders, "request-headers", GST_TYPE_STRUCTURE, headers.get(), nullptr);
     headers.reset(gst_structure_new_empty("response-headers"));
     for (const auto& header : response.httpHeaderFields())
         gst_structure_set(headers.get(), header.key.utf8().data(), G_TYPE_STRING, header.value.utf8().data(), nullptr);
     gst_structure_set(httpHeaders, "response-headers", GST_TYPE_STRUCTURE, headers.get(), nullptr);
+    GST_DEBUG_OBJECT(src, "Response headers going downstream: %" GST_PTR_FORMAT, headers.get());
+
+    gst_element_post_message(GST_ELEMENT_CAST(src), gst_message_new_element(GST_OBJECT_CAST(src),
+        gst_structure_copy(httpHeaders)));
     gst_pad_push_event(GST_BASE_SRC_PAD(priv->appsrc), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, httpHeaders));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to