[FFmpeg-devel] [PATCH] http: add the seek option to disable seeking.

Nicolas George nicolas.george at normalesup.org
Sat May 19 21:50:40 CEST 2012


Some streaming servers seem to support seeking
but will just skip over the relevant data.

See trac ticket #1320.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavformat/http.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 2589a8f..1e59b4e 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -52,6 +52,7 @@ typedef struct {
     char *headers;
     int willclose;          /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */
     int chunked_post;
+    int enable_seek;
 } HTTPContext;
 
 #define OFFSET(x) offsetof(HTTPContext, x)
@@ -61,6 +62,7 @@ typedef struct {
 static const AVOption options[] = {
 {"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, E },
 {"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"seek", "enable seeking using HTTP range feature", OFFSET(enable_seek), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, D},
 {"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
 {NULL}
 };
@@ -299,9 +301,9 @@ static int process_line(URLContext *h, char *line, int line_count,
                 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
                     s->filesize = atoll(slash+1);
             }
-            h->is_streamed = 0; /* we _can_ in fact seek */
+            h->is_streamed = !s->enable_seek; /* we _can_ in fact seek */
         } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
-            h->is_streamed = 0;
+            h->is_streamed = !s->enable_seek;
         } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {
             s->filesize = -1;
             s->chunksize = 0;
-- 
1.7.10



More information about the ffmpeg-devel mailing list