From faf4b5f160d8be8e4b9fc95f7f892417eef36ed7 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Mon, 20 Mar 2017 14:59:49 +0900 Subject: [PATCH] souphttpsrc: check range response when update content_size In case request_position is content_size, the response content_length can be zero with status code 200. (reproduced in Youtube http streaming) Change-Id: If28565375e0e13dc84054fd2383268467faf68aa (cherry picked from commit 0ae443abd9066053d0412c28fe9d9afddc8488c8) --- ext/soup/gstsouphttpsrc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 3adf9b9..830dd66 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -1262,8 +1262,11 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src) GstEvent *http_headers_event; GstStructure *http_headers, *headers; const gchar *accept_ranges; +#ifdef TIZEN_FEATURE_SOUP_MODIFICATION + gint64 start = 0, stop = 0, total = 0; +#endif - GST_INFO_OBJECT (src, "got headers"); + GST_INFO_OBJECT (src, "got headers : %d", msg->status_code); #ifdef TIZEN_FEATURE_SOUP_MODIFICATION soup_message_headers_foreach (msg->response_headers, gst_soup_http_src_headers_foreach, src); @@ -1319,7 +1322,17 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src) newsize = src->request_position + soup_message_headers_get_content_length (msg->response_headers); } else { - newsize = soup_message_headers_get_content_length (msg->response_headers); + if (soup_message_headers_get_content_range(msg->response_headers, &start, &stop, &total) && (total > 0)) { + GST_DEBUG_OBJECT (src, "get range header : %" G_GINT64_FORMAT + "~%" G_GINT64_FORMAT"/%"G_GINT64_FORMAT, start, stop, total); + newsize = (guint64)total; + } else { + if ((src->have_size) && (src->content_size <= src->request_position)) { + newsize = src->content_size; + } else { + newsize = soup_message_headers_get_content_length (msg->response_headers); + } + } } #else newsize = src->request_position + @@ -1350,7 +1363,8 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src) #ifdef TIZEN_FEATURE_SOUP_MODIFICATION /* The Range request header is always included. * @ref gst_soup_http_src_add_range_header() */ - else if (msg->status_code == SOUP_STATUS_OK) { + else if ((msg->status_code == SOUP_STATUS_OK) && + (soup_message_headers_get_content_range(msg->response_headers, &start, &stop, &total) == FALSE)) { GST_DEBUG_OBJECT (src, "there is no accept range header"); src->seekable = FALSE; } -- 2.7.4