[FFmpeg-devel] [PATCH] lavf: add subfile protocol.
Lukasz Marek
lukasz.m.luki at gmail.com
Thu Feb 27 00:53:27 CET 2014
> +static int64_t subfile_seek(URLContext *h, int64_t pos, int whence)
> +{
> + SubfileContext *c = h->priv_data;
> + int64_t new_pos = -1;
> + int ret;
> +
> + if (whence == AVSEEK_SIZE)
> + return c->end - c->start;
> + switch (whence) {
> + case SEEK_SET:
> + new_pos = c->start + pos;
> + break;
> + case SEEK_CUR:
> + new_pos += pos;
> + break;
> + case SEEK_END:
> + new_pos = c->end + c->pos;
> + break;
> + }
> + if (new_pos < c->start)
> + return AVERROR(EINVAL);
Note:
In file protocol lseek is used. If you pass SEEK_SET and n as new pos it
always returns n and errno = 0. Even when seeking beyond end of the file
or before beginning. When you look at code file.c it will return 0 in
case seeking to position before beginning. I simulated similar behavior
in ftp.c and forgot about it in libssh.c where negative value is
returned. http.c also return negative value (like lseek). In all these
cases seeking is done anyway and this protocol may be inconsistent with
them. Unfortunately ffmpeg doesn't state clearly what should happen in
such case in docs.
Seeking to c->start may be more expected by users I think.
BTW, I used to send an email to list about that before and as I remember
Michael responded to take file.c as reference.
> + c->pos = new_pos;
> + if ((ret = slave_seek(h)) < 0)
> + return ret;
> + return c->pos - c->start;
> +}
--
Best Regards,
Lukasz Marek
I may be drunk, Miss, but in the morning I will be sober and you will
still be ugly. - Winston Churchill
More information about the ffmpeg-devel
mailing list