[FFmpeg-devel] [PATCH][4/4] Enable use of the extended API

Michael Niedermayer michaelni
Mon Dec 3 03:34:46 CET 2007


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 ...

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


[...]
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c.orig	2007-11-27 10:43:35.269134455 +0100
> +++ libavformat/utils.c	2007-11-27 10:44:58.611571860 +0100
> @@ -2028,6 +2028,8 @@
>  
>  int av_read_play(AVFormatContext *s)
>  {
> +    if (s->pb && s->pb->read_play)
> +        return av_url_read_fplay(s->pb);
>      if (!s->iformat->read_play)
>          return AVERROR(ENOSYS);
>      return s->iformat->read_play(s);
> @@ -2035,6 +2037,8 @@
>  
>  int av_read_pause(AVFormatContext *s)
>  {
> +    if (s->pb && s->pb->read_pause)
> +        return av_url_read_fpause(s->pb);
>      if (!s->iformat->read_pause)
>          return AVERROR(ENOSYS);
>      return s->iformat->read_pause(s);

i dont know if bypassing the demuxer is always safe ...


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- 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/20071203/3c021c56/attachment.pgp>



More information about the ffmpeg-devel mailing list