[Ffmpeg-devel] Re: [PATCH/RFC] http seeking

Ronald S. Bultje rbultje
Fri Jan 5 01:24:39 CET 2007


Hi Michael,

On Thu, 2007-01-04, Michael Niedermayer wrote:
> On Wed, Jan 03, 2007 at 11:42:27PM -0500, Ronald S. Bultje wrote:
> > +    if (s->filesize == -1 && (whence == SEEK_END || whence == AVSEEK_SIZE))
> > +        return -1;
> > +    else if (whence == AVSEEK_SIZE)
> > +        return s->filesize;
> > +    else if (h->is_streamed == 1)
> > +        return -1;
> 
> if (whence == AVSEEK_SIZE)
>     return s->filesize;
> else if (s->filesize == -1 && whence == SEEK_END || h->is_streamed)
>     return -1;

Fixed.

> > +
> > +    /* we save the old context in case the seek fails */
> > +    s->hd = NULL;
> > +    switch (whence) {
> > +        case SEEK_SET:
> > +            s->off = off;
> > +            break;
> > +        case SEEK_CUR:
> > +            s->off += off;
> > +            break;
> > +        case SEEK_END:
> > +            s->off = s->filesize - off;
> 
> its + off
[..]
> > +            break;
> > +    }
> > +    off = s->off;
> 
> if(whence == SEEK_CUR)
>     off += s->off;
> else if(whence == SEEK_END)
>     off += s->filesize;
> s->off= off;

Fixed also.

> > +    /* if it fails, continue on old connection */
> > +    if (http_open_cnx(h) < 0) {
> > +        s->hd = hd;
> > +        s->off = old_off;
> > +        return -1;
> > +    } else if (s->off != off) {
> > +        http_close_cnx (h);
> > +        s->hd = hd;
> > +        s->off = old_off;
> > +        return -1;
> > +    } else {
> > +        URLContext *new = s->hd;
> > +        s->hd = hd;
> > +        http_close_cnx(h);
> > +        s->hd = new;
> > +    }
> > +
> > +    return s->off;
> > +}
> 
> 
> if (http_open_cnx(h) < 0) {
> } else if(s->off != off) {
>     url_close(s->hd);
> } else{
>     url_close(hd);
>     return s->off;
> }
> s->hd = hd;
> s->off = old_off;
> return -1;
> 
> also maybe ttp_open_cnx() should fail and return -1 if s->off != off

I took that last approach, it looks a bit different now. New patch
attached.

Cheers,
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d
Type: text/x-patch
Size: 7477 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070104/691d34b6/attachment.bin>



More information about the ffmpeg-devel mailing list