[FFmpeg-cvslog] lavf: add avformat_new_stream as a replacement for av_new_stream.

Anton Khirnov git at videolan.org
Thu Oct 20 02:37:10 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Jun 18 11:19:27 2011 +0200| [569129a6dc503379c0486008224dfaff8f0ee81f] | committer: Anton Khirnov

lavf: add avformat_new_stream as a replacement for av_new_stream.

It takes a codec parameter, thus enabling codec-specific defaults.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=569129a6dc503379c0486008224dfaff8f0ee81f
---

 doc/APIchanges         |    3 +++
 libavformat/avformat.h |   21 +++++++++++++++++++++
 libavformat/utils.c    |   13 +++++++++++--
 libavformat/version.h  |    7 +++++--
 4 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c4557f0..bd55cb0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-10-xx - xxxxxxx - lavf 53.10.0
+  Add avformat_new_stream(). Deprecate av_new_stream().
+
 2011-xx-xx - xxxxxxx - lavf 53.9.0
   Add AVFMT_NO_BYTE_SEEK AVInputFormat flag.
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4e7e883..65f66d8 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1311,6 +1311,7 @@ void av_close_input_file(AVFormatContext *s);
  */
 void avformat_free_context(AVFormatContext *s);
 
+#if FF_API_NEW_STREAM
 /**
  * Add a new stream to a media file.
  *
@@ -1321,7 +1322,27 @@ void avformat_free_context(AVFormatContext *s);
  * @param s media file handle
  * @param id file-format-dependent stream ID
  */
+attribute_deprecated
 AVStream *av_new_stream(AVFormatContext *s, int id);
+#endif
+
+/**
+ * Add a new stream to a media file.
+ *
+ * When demuxing, it is 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, should be called by the user before avformat_write_header().
+ *
+ * @param c If non-NULL, the AVCodecContext corresponding to the new stream
+ * will be initialized to use this codec. This is needed for e.g. codec-specific
+ * defaults to be set, so codec should be provided if it is known.
+ *
+ * @return newly created stream or NULL on error.
+ */
+AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
+
 AVProgram *av_new_program(AVFormatContext *s, int id);
 
 /**
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6393b62..9735d45 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2657,8 +2657,18 @@ void av_close_input_file(AVFormatContext *s)
         avio_close(pb);
 }
 
+#if FF_API_NEW_STREAM
 AVStream *av_new_stream(AVFormatContext *s, int id)
 {
+    AVStream *st = avformat_new_stream(s, NULL);
+    if (st)
+        st->id = id;
+    return st;
+}
+#endif
+
+AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
+{
     AVStream *st;
     int i;
     AVStream **streams;
@@ -2678,13 +2688,12 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
         return NULL;
     }
 
-    st->codec = avcodec_alloc_context3(NULL);
+    st->codec = avcodec_alloc_context3(c);
     if (s->iformat) {
         /* no default bitrate if decoding */
         st->codec->bit_rate = 0;
     }
     st->index = s->nb_streams;
-    st->id = id;
     st->start_time = AV_NOPTS_VALUE;
     st->duration = AV_NOPTS_VALUE;
         /* we set the current DTS to 0 so that formats without any timestamps
diff --git a/libavformat/version.h b/libavformat/version.h
index db20bd6..9de30ea 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,8 +24,8 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR  9
-#define LIBAVFORMAT_VERSION_MICRO  1
+#define LIBAVFORMAT_VERSION_MINOR 10
+#define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
@@ -95,5 +95,8 @@
 #ifndef FF_API_RTSP_URL_OPTIONS
 #define FF_API_RTSP_URL_OPTIONS        (LIBAVFORMAT_VERSION_MAJOR < 54)
 #endif
+#ifndef FF_API_NEW_STREAM
+#define FF_API_NEW_STREAM              (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
 
 #endif /* AVFORMAT_VERSION_H */



More information about the ffmpeg-cvslog mailing list