[FFmpeg-devel] [PATCH v2 2/2] avformat: add avformat_flush()

wm4 nfxjfg at googlemail.com
Tue Sep 30 18:46:49 CEST 2014


TODO: add entry to APIchanges, bump minor version.
---
Updated the doxygen.
---
 libavformat/avformat.h | 17 +++++++++++++++++
 libavformat/utils.c    |  6 ++++++
 2 files changed, 23 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 78054de..550cc50 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2173,6 +2173,23 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
 
 /**
+ * Discard all internally buffered data. This can be useful when dealing with
+ * discontinuities in the byte stream. Generally works only with headerless
+ * formats.
+ *
+ * The set of streams, the detected duration, stream parameters and codecs do
+ * not change when calling this function. If you want a complete reset, it's
+ * better to open a new AVFormatContext.
+ *
+ * This does not flush the AVIOContext (s->pb). If necessary, call
+ * avio_flush(s->pb) before calling this function.
+ *
+ * @param s media file handle
+ * @return >=0 on success, error code otherwise
+ */
+int avformat_flush(AVFormatContext *s);
+
+/**
  * Start playing a network-based stream (e.g. RTSP stream) at the
  * current position.
  */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e0e78a7..9689aa0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2159,6 +2159,12 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
     return -1; //unreachable
 }
 
+int avformat_flush(AVFormatContext *s)
+{
+    ff_read_frame_flush(s);
+    return 0;
+}
+
 /*******************************************************/
 
 /**
-- 
2.1.1



More information about the ffmpeg-devel mailing list