Skip to content
Permalink
Browse files
[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.

Canonical link: https://commits.webkit.org/198812@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228945 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
philn committed Feb 23, 2018
1 parent 427b9c4 commit 0c34c6abc1fd7bc82b32ddd381c2669445fcf85e
Showing with 29 additions and 21 deletions.
  1. +17 −0 Source/WebCore/ChangeLog
  2. +12 −21 Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
@@ -1,3 +1,20 @@
2018-02-23 Philippe Normand <pnormand@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 <pnormand@igalia.com>

[GStreamer] media/video-src-blob-using-open-panel.html crashes in Debug
@@ -83,6 +83,7 @@ struct _WebKitWebSrcPrivate {
bool didPassAccessControlCheck;

guint64 offset;
bool haveSize;
guint64 size;
gboolean seekable;
bool paused;
@@ -204,6 +205,9 @@ static void webkit_web_src_init(WebKitWebSrc* src)

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 @@ static void webkit_web_src_init(WebKitWebSrc* src)
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 @@ static void webKitWebSrcStop(WebKitWebSrc* src)
priv->offset = 0;

if (!wasSeeking) {
priv->size = 0;
priv->requestedOffset = 0;
priv->player = nullptr;
priv->seekable = FALSE;
@@ -446,8 +448,6 @@ static void webKitWebSrcStart(WebKitWebSrc* src)
request.setAllowCookies(true);
request.setFirstPartyForCookies(url);

priv->size = 0;

request.setHTTPReferrer(priv->player->referrer());

if (priv->httpMethod.get())
@@ -563,18 +563,6 @@ static gboolean webKitWebSrcQueryWithParent(GstPad* pad, GstObject* parent, GstQ
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 @@ void CachedResourceStreamingClient::responseReceived(PlatformMediaResource&, con
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);

0 comments on commit 0c34c6a

Please sign in to comment.