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