[FFmpeg-devel] [PATCH 04/11] avformat/muxers: Add non-blocking mode support for av_write_trailer

sebechlebskyjan at gmail.com sebechlebskyjan at gmail.com
Tue Aug 2 16:24:15 EEST 2016


From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>

This makes av_write_trailer not to free the resources if write_trailer
call returns AVERROR(EAGAIN) allowing repeated calls of write_trailer of
non-blocking muxer.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
 libavformat/avformat.h | 6 +++++-
 libavformat/mux.c      | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 818184e..9191c69 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2508,8 +2508,12 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);
  *
  * May only be called after a successful call to avformat_write_header.
  *
+ * If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN)
+ * meaning the operation is pending and the call should be repeated.
+ *
  * @param s media file handle
- * @return 0 if OK, AVERROR_xxx on error
+ * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated,
+ *         other AVERROR on error
  */
 int av_write_trailer(AVFormatContext *s);
 
diff --git a/libavformat/mux.c b/libavformat/mux.c
index e9973ed..b58e4c1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1238,6 +1238,9 @@ fail:
         }
     }
 
+    if (ret == AVERROR(EAGAIN))
+        return ret;
+
     if (s->oformat->deinit)
         s->oformat->deinit(s);
 
-- 
1.9.1



More information about the ffmpeg-devel mailing list