diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-01-13 23:27:52 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-01-13 23:27:52 +0000 |
commit | 08c8e66a996ddbb129f42e0fa121397b65b95aa9 (patch) | |
tree | dd1c3fafc4104ac02aa24bf297ef620d7b79cf8a /libavformat/http.c | |
parent | a1f42882e191109175a428d588c773afaa44c516 (diff) | |
download | ffmpeg-streaming-08c8e66a996ddbb129f42e0fa121397b65b95aa9.zip ffmpeg-streaming-08c8e66a996ddbb129f42e0fa121397b65b95aa9.tar.gz |
restore old buffer content when seek failed in http protocol, fix issue #1631
Originally committed as revision 21208 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/http.c')
-rw-r--r-- | libavformat/http.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index a404ff3..0c07592 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -394,6 +394,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) HTTPContext *s = h->priv_data; URLContext *old_hd = s->hd; int64_t old_off = s->off; + uint8_t old_buf[BUFFER_SIZE]; + int old_buf_size; if (whence == AVSEEK_SIZE) return s->filesize; @@ -401,6 +403,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) return -1; /* we save the old context in case the seek fails */ + old_buf_size = s->buf_end - s->buf_ptr; + memcpy(old_buf, s->buf_ptr, old_buf_size); s->hd = NULL; if (whence == SEEK_CUR) off += s->off; @@ -410,6 +414,9 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence) /* if it fails, continue on old connection */ if (http_open_cnx(h) < 0) { + memcpy(s->buffer, old_buf, old_buf_size); + s->buf_ptr = s->buffer; + s->buf_end = s->buffer + old_buf_size; s->hd = old_hd; s->off = old_off; return -1; |