From: Jan Sebechlebsky <sebechlebsky...@gmail.com> Add comments regarding AVFMG_FLAG_NONBLOCK usage with muxers. Add assert forbiding use of nonblocking muxer with av_interleaved_write_frame.
Signed-off-by: Jan Sebechlebsky <sebechlebsky...@gmail.com> --- Changes since the last version of the patch: - added assert to the beginning of av_interleaved_write_frame ensuring it is not called with muxer in nonblocking mode. - Changed commit description. libavformat/avformat.h | 9 ++++++++- libavformat/mux.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 83903b5..79c2511 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1428,7 +1428,7 @@ typedef struct AVFormatContext { int flags; #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. -#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. +#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input / writing packets to output. #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled @@ -2391,6 +2391,10 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options); * the interleaving should call av_interleaved_write_frame() instead of this * function. * + * In case the muxer is operating in non-blocking mode (AVFMT_FLAG_NONBLOCK + * is set), this function can return AVERROR(EAGAIN) meaning the call should + * be repeated. + * * @param s media file handle * @param pkt The packet containing the data to be written. Note that unlike * av_interleaved_write_frame(), this function does not take @@ -2433,6 +2437,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); * knowledge of future packets, improving e.g. the behaviour of the mp4 * muxer for VFR content in fragmenting mode. * + * This call is not supported and must not be called if muxer is operating + * in non-blocking mode (AVFMT_FLAG_NONBLOCK is set). + * * @param s media file handle * @param pkt The packet containing the data to be written. * <br> diff --git a/libavformat/mux.c b/libavformat/mux.c index 0f002a3..b4698b7 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1139,6 +1139,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret, flush = 0; + av_assert0(!(s->flags & AVFMT_FLAG_NONBLOCK)); + ret = prepare_input_packet(s, pkt); if (ret < 0) goto fail; -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel