From: Sebastian Dröge Date: Sun, 31 Oct 2010 17:08:17 +0000 (+0100) Subject: souphttpsrc: Don't send seeks behind the end of file to the server X-Git-Tag: RELEASE-0.10.27~310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a9372529222300c7b6eacfcf8b9a844b96021c9;p=platform%2Fupstream%2Fgst-plugins-good.git souphttpsrc: Don't send seeks behind the end of file to the server Also improve debug output, re-initialize the content size and let the seek handler error out on invalid seek segments. Fixes bug #632977. --- diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 9eb6bd2..4d77984 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -320,6 +320,7 @@ gst_soup_http_src_reset (GstSoupHTTPSrc * src) src->seekable = FALSE; src->read_position = 0; src->request_position = 0; + src->content_size = 0; gst_caps_replace (&src->src_caps, NULL); g_free (src->iradio_name); @@ -1175,7 +1176,11 @@ 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->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) { + 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_UNEXPECTED; + } else 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 @@ -1365,11 +1370,24 @@ gst_soup_http_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment) GST_DEBUG_OBJECT (src, "do_seek(%" G_GUINT64_FORMAT ")", segment->start); - if (src->read_position == segment->start) + if (src->read_position == segment->start) { + GST_DEBUG_OBJECT (src, "Seeking to current read position"); return TRUE; + } + + if (!src->seekable) { + GST_WARNING_OBJECT (src, "Not seekable"); + return FALSE; + } - if (!src->seekable) + if (segment->rate != 1.0 || segment->format != GST_FORMAT_BYTES) { + GST_WARNING_OBJECT (src, "Invalid seek segment"); return FALSE; + } + + if (src->content_size != 0 && segment->start >= src->content_size) { + GST_WARNING_OBJECT (src, "Seeking behind end of file, will go to EOS soon"); + } /* Wait for create() to handle the jump in offset. */ src->request_position = segment->start;