On Sun, 12 Jun 2016, Rodger Combs wrote:

This allows a consumer to run the muxer's init function without actually
writing the header, which is useful in chained muxers that support
automatic bitstream filtering.
---
libavformat/avformat.h | 34 +++++++++++++++++++++++++--
libavformat/internal.h | 10 ++++++++
libavformat/mux.c      | 64 +++++++++++++++++++++++++++++++++++++++-----------
libavformat/version.h  |  4 ++--
4 files changed, 94 insertions(+), 18 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d659ee4..d6b0b26 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -616,6 +616,8 @@ typedef struct AVOutputFormat {
     * AVStream parameters that need to be set before packets are sent.
     * This method must not write output.
     *
+     * Return 0 if streams were fully configured, 1 if not, negative AVERROR 
on failure
+     *
     * Any allocations made here must be freed in deinit().
     */
    int (*init)(struct AVFormatContext *);
@@ -2363,6 +2365,10 @@ void avformat_close_input(AVFormatContext **s);
 * @addtogroup lavf_encoding
 * @{
 */
+
+#define AVSTREAM_INIT_IN_WRITE_HEADER 0 ///< stream parameters initialized in 
avformat_write_header
+#define AVSTREAM_INIT_IN_INIT_OUTPUT  1 ///< stream parameters initialized in 
avformat_init_output
+
/**
 * Allocate the stream private data and write the stream header to
 * an output media file.
@@ -2374,14 +2380,38 @@ void avformat_close_input(AVFormatContext **s);
 *                 On return this parameter will be destroyed and replaced with 
a dict containing
 *                 options that were not found. May be NULL.
 *
- * @return 0 on success, negative AVERROR on failure.
+ * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec had not 
already been fully initialized in avformat_init,
+ *         AVSTREAM_INIT_IN_INIT_OUTPUT  on success if the codec had already 
been fully initialized in avformat_init,
+ *         negative AVERROR on failure.
 *
- * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
+ * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, 
avformat_init_output.
 */
av_warn_unused_result
int avformat_write_header(AVFormatContext *s, AVDictionary **options);

I don't see why you want to change avformat_write_header API. After a successful call to avformat_write_header, codecs/streams are always initialzied, aren't they? Who cares anymore if it was done in init or write_header?

Regards,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to