[FFmpeg-devel] [PATCH] [RFC]avformat: introduce AVStreamGroup

Anton Khirnov anton at khirnov.net
Tue Oct 3 18:43:53 EEST 2023


Quoting James Almer (2023-10-02 14:10:11)
> 
> I figured it would be nice to have it for the sake of convenience. For 
> formats like HEIF, new streams should in theory be created once the 
> group they will belong to is known.
> I have no strong attachment to this function, so it can go if you think 
> it's superfluous.

I expect the use cases for it to be limited and the advantage not that
big, so yeah, I'd prefer it dropped.

> > 
> >> +
> >> +/**
> >> + * Add an already allocated stream to a stream group.
> >> + *
> >> + * When demuxing, it may be called by the demuxer in read_header(). If the
> >> + * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
> >> + * be called in read_packet().
> >> + *
> >> + * When muxing, may be called by the user before avformat_write_header() after
> >> + * having allocated a new group with avformat_new_stream_group() and stream with
> >> + * avformat_new_stream().
> >> + *
> >> + * User is required to call avformat_free_context() to clean up the allocation
> >> + * by av_stream_group_add_stream().
> >> + *
> >> + * @param stg stream group belonging to a media file.
> >> + * @param st  stream in the media file to add to the group.
> >> + *
> >> + * @return 0 on success, or a negative AVERROR otherwise.
> >> + * @see avformat_new_stream, av_stream_group_new_stream, avformat_new_stream_group.
> >> + */
> >> +int av_stream_group_add_stream(AVStreamGroup *stg, const AVStream *st);
> > 
> > It'd be nice to have the streamgroup-related functions consistenly
> > namespaced.
> > 
> > E.g.
> > * avformat_stream_group_add()
> > * avformat_stream_group_add_stream()
> > * ff_stream_group_free()
> > etc.
> > 
> > alternatively for the first two:
> > * avformat_stream_group_create()
> > * avformat_stream_group_extend()
> 
> I named avformat_new_stream_group() essentially the same as 
> avformat_new_stream(), then namespaced the functions that take a 
> AVStreamGroup as input.
> I don't particularly like _extend(), but i guess i could do something like
> 
> AVStreamGroup *avformat_stream_group_create(AVFormatContext *s)
> int avformat_stream_group_add_stream(AVStreamGroup *stg,
>                                       const AVStream *st);

Fine with me.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list