From c43e7001ab57bb86d329a9bd1c95f37bed5c470b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 4 May 2013 13:19:53 +0200 Subject: [PATCH] souphttpsrc: Don't consider the content size from the HTTP headers as absolutely correct The HTTP server could give wrong information, e.g. if the HTTP stream is chunk-encoded or compressed, or if the server does not know the complete size at the time when the file is requested by the client. Also see https://bugs.webkit.org/show_bug.cgi?id=115354 --- ext/soup/gstsouphttpsrc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 543bbeb1fb..0e08ee9508 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -990,6 +990,16 @@ gst_soup_http_src_got_chunk_cb (SoupMessage * msg, SoupBuffer * chunk, src->request_position = new_position; src->read_position = new_position; + if (src->content_size != 0 && new_position > src->content_size) { + GST_DEBUG_OBJECT (src, "Got position previous estimated content size " + "(%" G_GINT64_FORMAT " > %" G_GINT64_FORMAT ")", new_position, + src->content_size); + src->content_size = new_position; + basesrc->segment.duration = src->content_size; + gst_element_post_message (GST_ELEMENT (src), + gst_message_new_duration_changed (GST_OBJECT (src))); + } + src->ret = GST_FLOW_OK; g_main_loop_quit (src->loop); gst_soup_http_src_session_pause_message (src); @@ -1138,11 +1148,7 @@ gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) src = GST_SOUP_HTTP_SRC (psrc); if (src->msg && (src->request_position != src->read_position)) { - if (src->content_size != 0 && src->request_position >= src->content_size) { - GST_WARNING_OBJECT (src, "Seeking behind the end of file -- EOS"); - return GST_FLOW_EOS; - } else if (src->session_io_status == - GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) { + if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) { gst_soup_http_src_add_range_header (src, src->request_position); } else { GST_DEBUG_OBJECT (src, "Seek from position %" G_GUINT64_FORMAT @@ -1347,7 +1353,8 @@ gst_soup_http_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment) } if (src->content_size != 0 && segment->start >= src->content_size) { - GST_WARNING_OBJECT (src, "Seeking behind end of file, will go to EOS soon"); + GST_WARNING_OBJECT (src, + "Potentially seeking behind end of file, might EOS immediately"); } /* Wait for create() to handle the jump in offset. */ -- 2.34.1