It takes a codec parameter, thus enabling codec-specific defaults.
Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2011-10-xx - xxxxxxx - lavf 53.10.0 | |
| 17 | + Add avformat_new_stream(). Deprecate av_new_stream(). | |
| 18 | + | |
| 16 | 19 | 2011-xx-xx - xxxxxxx - lavf 53.9.0 |
| 17 | 20 | Add AVFMT_NO_BYTE_SEEK AVInputFormat flag. |
| 18 | 21 | |
| @@ -1311,6 +1311,7 @@ void av_close_input_file(AVFormatContext *s); · 1310 unmodified lines | ||
| 1311 | 1311 | */ |
| 1312 | 1312 | void avformat_free_context(AVFormatContext *s); |
| 1313 | 1313 | |
| 1314 | +#if FF_API_NEW_STREAM | |
| 1314 | 1315 | /** |
| 1315 | 1316 | * Add a new stream to a media file. |
| 1316 | 1317 | * |
| @@ -1321,7 +1322,27 @@ void avformat_free_context(AVFormatContext *s); · 4 unmodified lines | ||
| 1321 | 1322 | * @param s media file handle |
| 1322 | 1323 | * @param id file-format-dependent stream ID |
| 1323 | 1324 | */ |
| 1325 | +attribute_deprecated | |
| 1324 | 1326 | 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 | + | |
| 1325 | 1346 | AVProgram *av_new_program(AVFormatContext *s, int id); |
| 1326 | 1347 | |
| 1327 | 1348 | /** |
| @@ -2657,7 +2657,17 @@ void av_close_input_file(AVFormatContext *s) · 2656 unmodified lines | ||
| 2657 | 2657 | avio_close(pb); |
| 2658 | 2658 | } |
| 2659 | 2659 | |
| 2660 | +#if FF_API_NEW_STREAM | |
| 2660 | 2661 | 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) | |
| 2661 | 2671 | { |
| 2662 | 2672 | AVStream *st; |
| 2663 | 2673 | int i; |
| @@ -2678,13 +2688,12 @@ AVStream *av_new_stream(AVFormatContext *s, int id) · 14 unmodified lines | ||
| 2678 | 2688 | return NULL; |
| 2679 | 2689 | } |
| 2680 | 2690 | |
| 2681 | − st->codec = avcodec_alloc_context3(NULL); | |
| 2691 | + st->codec = avcodec_alloc_context3(c); | |
| 2682 | 2692 | if (s->iformat) { |
| 2683 | 2693 | /* no default bitrate if decoding */ |
| 2684 | 2694 | st->codec->bit_rate = 0; |
| 2685 | 2695 | } |
| 2686 | 2696 | st->index = s->nb_streams; |
| 2687 | − st->id = id; | |
| 2688 | 2697 | st->start_time = AV_NOPTS_VALUE; |
| 2689 | 2698 | st->duration = AV_NOPTS_VALUE; |
| 2690 | 2699 | /* we set the current DTS to 0 so that formats without any timestamps |
| @@ -24,8 +24,8 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "libavutil/avutil.h" |
| 25 | 25 | |
| 26 | 26 | #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 | |
| 29 | 29 | |
| 30 | 30 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 31 | 31 | LIBAVFORMAT_VERSION_MINOR, \ |
| @@ -95,5 +95,8 @@ · 63 unmodified lines | ||
| 95 | 95 | #ifndef FF_API_RTSP_URL_OPTIONS |
| 96 | 96 | #define FF_API_RTSP_URL_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 54) |
| 97 | 97 | #endif |
| 98 | +#ifndef FF_API_NEW_STREAM | |
| 99 | +#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 54) | |
| 100 | +#endif | |
| 98 | 101 | |
| 99 | 102 | #endif /* AVFORMAT_VERSION_H */ |