[FFmpeg-devel] [PATCH 06/11] avformat: add av_abort_output() function
sebechlebskyjan at gmail.com
sebechlebskyjan at gmail.com
Tue Aug 2 16:24:17 EEST 2016
From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
libavformat/avformat.h | 14 ++++++++++++++
libavformat/mux.c | 16 ++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 9191c69..9173908 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2510,6 +2510,8 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);
*
* If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN)
* meaning the operation is pending and the call should be repeated.
+ * If caller decides to abort operation (after too many calls have returned
+ * AVERROR(EAGAIN)), it can be done by calling @ref av_abort_output().
*
* @param s media file handle
* @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated,
@@ -2518,6 +2520,18 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);
int av_write_trailer(AVFormatContext *s);
/**
+ * Abort non-blocking muxer operation and free private data.
+ *
+ * May only be called after a successful call to avformat_write_header,
+ * and used only with muxer operating in non-blocking mode (AVFMT_FLAG_NONBLOCK)
+ * must be set.
+ *
+ * @param s media file handle
+ * return >= 0 on success, negative AVERROR on error
+ */
+int av_abort_output(AVFormatContext *s);
+
+/**
* Return the output format in the list of registered output formats
* which best matches the provided parameters, or return NULL if
* there is no match.
diff --git a/libavformat/mux.c b/libavformat/mux.c
index bc9c98f..888a9f1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1267,6 +1267,22 @@ fail:
return ret;
}
+int av_abort_output(AVFormatContext *s)
+{
+ int ret;
+
+ if (!(s->flags & AVFMT_FLAG_NONBLOCK))
+ return AVERROR(EINVAL);
+
+ ret = av_write_trailer(s);
+ if (ret == AVERROR(EAGAIN)) {
+ deinit_muxer(s);
+ ret = 0;
+ }
+
+ return ret;
+}
+
int av_get_output_timestamp(struct AVFormatContext *s, int stream,
int64_t *dts, int64_t *wall)
{
--
1.9.1
More information about the ffmpeg-devel
mailing list