[FFmpeg-devel] [PATCH][4/4] Enable use of the extended API
Michael Niedermayer
michaelni
Thu Dec 13 23:26:12 CET 2007
On Thu, Dec 13, 2007 at 05:31:31PM +0100, Bj?rn Axelsson wrote:
> On Thu, 2007-12-13 at 16:25 +0100, Bj?rn Axelsson wrote:
> > On Mon, 2007-12-03 at 03:34 +0100, Michael Niedermayer wrote:
> > > On Tue, Nov 27, 2007 at 11:26:38AM +0100, Bj?rn Axelsson wrote:
> > > > On Thu, 2007-11-22 at 15:01 +0000, Bj?rn Axelsson wrote:
> > > > > Enable av_read_pause(), av_read_play() and the ASF demuxer's
> > > > > av_read_seek() to use the protocol-native functionality if available.
> > > > >
> > > > > I forgot to write this before: The code passes "make test" after each
> > > > > patch has been applied, and after all patches have been applied.
> > > > > Patch 2 depends on patch 1, and patch 4 on patch 2.
> > > > >
> > > > > There's still no code that uses this functionality, but I'll break up
> > > > > the MMS patch in smaller diffs and submit it soon.
> > > >
> > > > Patch updated for the changes in the previous patches and to handle the
> > > > case where read_seek() is given a stream index but that isn't supported
> > > > by the protocol's read_seek().
> > > > Please double-check the pts calculations I'm doing in asf.c, as I'm not
> > > > totally comfortable with them.
> > > >
> > > > The patch passes "make test" and also tests out ok with the upcoming MMS
> > > > implementation.
> > > >
> > > > --
> > > > Bj?rn Axelsson Phone: +46-(0)90-18 98 97
> > > > Intinor AB Fax: +46-(0)920-757 10
> > > > www.intinor.se
> > > > Interactive Television & Digital Media Distribution
> > >
> > > > Index: libavformat/asf.c
> > > > ===================================================================
> > > > --- libavformat/asf.c.orig 2007-11-27 10:43:35.269134455 +0100
> > > > +++ libavformat/asf.c 2007-11-27 11:20:30.010091214 +0100
> > > > @@ -1049,6 +1049,26 @@
> > > > if (asf->packet_size <= 0)
> > > > return -1;
> > > >
> > > > + /* Try using the protocol's read_seek if available */
> > > > + if(s->pb->read_seek) {
> > > > + int ret = av_url_read_fseek(s->pb, stream_index, pts, flags);
> > > > + if(ret == AVERROR(ENOTSUP) && stream_index != -1) {
> > > > + /* Retry with pts in AV_TIME_BASE from beginning of presentation
> > > > + * and stream_index = -1 */
> > > > + AVStream *st = s->streams[stream_index];
> > > > + uint64_t offs = st->start_time==AV_NOPTS_VALUE ? 0 : st->start_time;
> > > > + uint64_t npts = av_rescale(pts + offs,
> > > > + AV_TIME_BASE*(int64_t)st->time_base.num,
> > > > + st->time_base.den);
> > > > + ret = av_url_read_fseek(s->pb, -1, npts, flags);
> > > > + }
> > > > + if(ret != AVERROR(ENOTSUP)) {
> > > > + if(ret >= 0) // Success
> > > > + asf_reset_header(s);
> > > > + return ret;
> > > > + }
> > > > + }
> > >
> > > this is wrong, offs MUST always be 0
> > > this is due to the existing API for AVInputFormat read_seek
> > > and the cases for stream_index==-1 and stream_index!=-1
> > > the code as is, is inconsistant ...
> >
> > Thanks for the review. So the time rescaling would be correct with
> > offs=0? (See the new api_extension_enable.diff)
> >
> > > also the existing API is good, the one for av_url_read_fseek() is not
> > > and should be changed to match it, timestamps should always use the same
> > > 0 point
> >
> > If there's more to the av_url_read_fseek() API than the offset handling
> > that is bad, please elaborate since there are several other minor API
> > differences compared to the AVInputFormat read_seek() and
> > av_seek_frame(), but for good reasons.
> > If not, please see the attached patch av_url_read_fseek_api.diff that
> > copies the doc for stream_index==1 from av_read_seek().
> >
> > I also now realise that its interface is closer to av_seek_frame() than
> > to AVInputFormat read_seek(). Maybe calling it av_url_fseek_frame()
> > wouldn't be a bad idea.
yes i meant it should use the av_seek_frame() API not
AVInputFormat read_seek() though its fine as it is as well
the only difference is stream_index=-1 support IIRC
about the function name, choose whichever you prefer, both look ok
[...]
> @@ -1093,6 +1101,20 @@
> return 0;
> }
>
> +static int asf_read_play(AVFormatContext *s)
> +{
> + if (s->pb && s->pb->read_play)
> + return av_url_read_fplay(s->pb);
> + return AVERROR(ENOSYS);
> +}
> +
> +static int asf_read_pause(AVFormatContext *s)
> +{
> + if (s->pb && s->pb->read_pause)
> + return av_url_read_fpause(s->pb);
> + return AVERROR(ENOSYS);
> +}
> +
> AVInputFormat asf_demuxer = {
> "asf",
> "asf format",
> @@ -1103,4 +1125,6 @@
> asf_read_close,
> asf_read_seek,
> asf_read_pts,
> + .read_play = asf_read_play,
> + .read_pause = asf_read_pause,
> };
i think the 2 functions above could be defaults if read_play/read_pause
are NULL
that is
int av_read_pause(AVFormatContext *s)
{
if(s->iformat->read_pause)
return s->iformat->read_pause(s);
if(s->pb && s->pb->read_pause)
return av_url_read_fpause(s->pb);
return AVERROR(ENOSYS);
}
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071213/b54ec600/attachment.pgp>
More information about the ffmpeg-devel
mailing list