[FFmpeg-devel] [PATCH] Playlist API

Michael Niedermayer michaelni
Sat Aug 29 12:11:05 CEST 2009


On Wed, Aug 26, 2009 at 12:15:16PM -0700, Geza Kovacs wrote:
> On 08/26/2009 09:13 AM, Michael Niedermayer wrote:
> >> av_mallocz(sizeof(AVPlaylistContext)) -- since realloc is used to expand
> >> the various lists (and hence the first realloc acts as a malloc),
> >> there's no need to explicitly allocate anything else beforehand.
> > 
> > This has problems, setting defaults different from 0 is one
> > 
> 
> I assume you meant if you wanted to change the defaults to non-zero
> values sometime in the future? av_playlist_alloc is now used, though
> since the defaults are currently 0 anyway it's just doing a mallocz.

yes and good


> 
> >> I also added a convenience function av_playlist_add_item to add the new
> >> item to the end since that's probably the most common position where
> >> items would be inserted, I think it should be pretty harmless and
> >> self-explanatory but if you don't like it I can remove it.
> > 
> > insert() with index ctx->pelist_size could be used directly
> > 
> 
> ok, removed av_playlist_add_item
> 
> > also it should be possible for the user to add playlists through this
> > same api (like a .m3u) and have its contents automatically inserted
> > 
> 
> ok, added av_playlist_insert_playlist to do this
> 

> >> +    ctx->durations[pos] = 0;
> >> +    ctx->durations[ctx->pelist_size] = 0;
> > 
> > i thought these were sums of durations?
> > 
> 
> Yes, but since the AVFormatContext for the current and previous items
> might not have yet been allocated and opened when an item is added (in
> fact the way I'm currently using it all the items are added before any
> of the AVFormatContexts are allocated or opened), then the setting of
> the summed durations is deferred until the child AVFormatContext is
> actually allocated and opened (playlist_populate_context, invoked by
> read_packet once necessary). Same applies to nb_streams_list.

well, this sounds a little buggy ...
I mean first the user app can have a playlist and play that and after
playing such list of mp3s once or a few times the user might choose to
insert a few new mp3s, or remove a few but it does not seem the durations
or stream numbers would be updated in that case ...

also, it seems seeking would similarly fail with this system, but maybe
ive missed something ...
I mean, the seek code expects durations to be summed but as they are only
summed in read_packet they are not neccesarily summed for all elements
of a playlist making forward seek fail ...



[...]

> +    flist_tmp = av_realloc(ctx->flist, sizeof(*(ctx->flist)) * (++ctx->pelist_size));
> +    if (!flist_tmp) {
> +        av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_insert_item\n");
> +        return AVERROR_NOMEM;
> +    } else
> +        ctx->flist = flist_tmp;
> +    durations_tmp = av_realloc(ctx->durations,
> +                               sizeof(*(ctx->durations)) * (ctx->pelist_size));
> +    if (!durations_tmp) {
> +        av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_insert_item\n");
> +        return AVERROR_NOMEM;
> +    } else
> +        ctx->durations = durations_tmp;
> +    nb_streams_list_tmp = av_realloc(ctx->nb_streams_list,
> +                                     sizeof(*(ctx->nb_streams_list)) * (ctx->pelist_size));
> +    if (!nb_streams_list_tmp) {

> +        av_log(NULL, AV_LOG_ERROR, "av_realloc error in av_playlist_insert_item\n");
> +        return AVERROR_NOMEM;

Triplicated


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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20090829/14913e3a/attachment.pgp>



More information about the ffmpeg-devel mailing list