[FFmpeg-devel] [PATCH] Fix seeking HTTP when server uses chunked encoding

Martin Storsjö martin
Sun Jun 20 11:50:03 CEST 2010

On Sat, 19 Jun 2010, Ronald S. Bultje wrote:

> On Tue, May 18, 2010 at 4:34 AM, Tomas H?rdin <tomas.hardin at codemill.se> wrote:
> > On Tue, 2010-05-11 at 17:18 +0200, Tomas H?rdin wrote:
> >> I've attached two patches. The first patch resets chunksize before
> >> parsing the headers, which fixes the rare case of a resource switching
> >> chunked encoding off between seeks (could happen once the size of a
> >> resource becomes known to the server). It also disallows read-write mode
> >> and removes the unused http_write() prototype.
> >>
> >> The second patch does a bit of refactoring to http_connect() as well,
> >> splitting it up into two functions: http_send_request() and
> >> http_parse_header().

I prefer the former, which does less refactoring at once.

Due to the changes from the RTSP HTTP tunneling stuff, the http code has 
changed a bit, so the patches don't apply cleanly any longer. I updated 
and adapted the first of Tomas' patches to the latest trunk, see the 
attached. (I removed the "disallow read-write mode" hunk for now, I don't 
see it as necessary for this.)

> > I talked to Bultje a bit on IRC and he wanted a small program to test
> > the patches with. I'm attaching it here for anyone else that might be
> > interested.
> >
> > It's a small patch to one of the libmicrohttpd examples
> > (fileserver_example.c) that adds basic handling of Range/Content-Range.
> > To compile, svn checkout https://ng.gnunet.org/svn/libmicrohttpd/ ,
> > apply the patch and install in the usual fashion. Then run
> > src/examples/fileserver_example in a folder with some test files on say
> > port 8888. Finally, ffplay http://localhost:8888/foo.avi before and
> > after applying the patch. You'll see that it won't seek properly without
> > the patch.
> Seeking works using e.g. Apache against current SVN.
> What exactly is the problem? Is it microhttpd-specific? I'm fine with
> changes, but need to see an actual need for them.

As far as I understand the issue, it's not specifiec to microhttpd, but to 
any server that serves normal content using chunked encoding. Most common 
http servers doesn't do that, but it's fully allowed if the client does 
the request using HTTP/1.1.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Properly-handle-seeking-in-http-streams-received-usi.patch
Type: text/x-diff
Size: 2458 bytes
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100620/889dcb44/attachment.patch>

More information about the ffmpeg-devel mailing list