History

lavf: add avformat_new_stream as a replacement for av_new_stream.

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

Anton Khirnov committed 15 years ago

Commit 569129a1 parent 73447eb4 files · +40 −4Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avformat.h +21 −0
  3. libavformat/utils.c +11 −2
  4. libavformat/version.h +5 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-10-xx - xxxxxxx - lavf 53.10.0
17+ Add avformat_new_stream(). Deprecate av_new_stream().
18+
1619 2011-xx-xx - xxxxxxx - lavf 53.9.0
1720 Add AVFMT_NO_BYTE_SEEK AVInputFormat flag.
1821
libavformat/avformat.h+21−0
@@ -1311,6 +1311,7 @@ void av_close_input_file(AVFormatContext *s); · 1310 unmodified lines
13111311 */
13121312 void avformat_free_context(AVFormatContext *s);
13131313
1314+#if FF_API_NEW_STREAM
13141315 /**
13151316 * Add a new stream to a media file.
13161317 *
@@ -1321,7 +1322,27 @@ void avformat_free_context(AVFormatContext *s); · 4 unmodified lines
13211322 * @param s media file handle
13221323 * @param id file-format-dependent stream ID
13231324 */
1325+attribute_deprecated
13241326 AVStream *av_new_stream(AVFormatContext *s, int id);
1327+#endif
1328+
1329+/**
1330+ * Add a new stream to a media file.
1331+ *
1332+ * When demuxing, it is called by the demuxer in read_header(). If the
1333+ * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
1334+ * be called in read_packet().
1335+ *
1336+ * When muxing, should be called by the user before avformat_write_header().
1337+ *
1338+ * @param c If non-NULL, the AVCodecContext corresponding to the new stream
1339+ * will be initialized to use this codec. This is needed for e.g. codec-specific
1340+ * defaults to be set, so codec should be provided if it is known.
1341+ *
1342+ * @return newly created stream or NULL on error.
1343+ */
1344+AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c);
1345+
13251346 AVProgram *av_new_program(AVFormatContext *s, int id);
13261347
13271348 /**
libavformat/utils.c+11−2
@@ -2657,7 +2657,17 @@ void av_close_input_file(AVFormatContext *s) · 2656 unmodified lines
26572657 avio_close(pb);
26582658 }
26592659
2660+#if FF_API_NEW_STREAM
26602661 AVStream *av_new_stream(AVFormatContext *s, int id)
2662+{
2663+ AVStream *st = avformat_new_stream(s, NULL);
2664+ if (st)
2665+ st->id = id;
2666+ return st;
2667+}
2668+#endif
2669+
2670+AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
26612671 {
26622672 AVStream *st;
26632673 int i;
@@ -2678,13 +2688,12 @@ AVStream *av_new_stream(AVFormatContext *s, int id) · 14 unmodified lines
26782688 return NULL;
26792689 }
26802690
2681− st->codec = avcodec_alloc_context3(NULL);
2691+ st->codec = avcodec_alloc_context3(c);
26822692 if (s->iformat) {
26832693 /* no default bitrate if decoding */
26842694 st->codec->bit_rate = 0;
26852695 }
26862696 st->index = s->nb_streams;
2687− st->id = id;
26882697 st->start_time = AV_NOPTS_VALUE;
26892698 st->duration = AV_NOPTS_VALUE;
26902699 /* we set the current DTS to 0 so that formats without any timestamps
libavformat/version.h+5−2
@@ -24,8 +24,8 @@ · 23 unmodified lines
2424 #include "libavutil/avutil.h"
2525
2626 #define LIBAVFORMAT_VERSION_MAJOR 53
27−#define LIBAVFORMAT_VERSION_MINOR 9
28−#define LIBAVFORMAT_VERSION_MICRO 1
27+#define LIBAVFORMAT_VERSION_MINOR 10
28+#define LIBAVFORMAT_VERSION_MICRO 0
2929
3030 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3131 LIBAVFORMAT_VERSION_MINOR, \
@@ -95,5 +95,8 @@ · 63 unmodified lines
9595 #ifndef FF_API_RTSP_URL_OPTIONS
9696 #define FF_API_RTSP_URL_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 54)
9797 #endif
98+#ifndef FF_API_NEW_STREAM
99+#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 54)
100+#endif
98101
99102 #endif /* AVFORMAT_VERSION_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t