[FFmpeg-cvslog] avio: Add AVIOInterruptCB

Martin Storsjö git at videolan.org
Mon Nov 14 00:43:06 CET 2011


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Sun Nov  6 14:10:16 2011 +0200| [6aa0b98fb27ab22bd62a365de44d9f16cc07d03e] | committer: Anton Khirnov

avio: Add AVIOInterruptCB

This is a better io interrupt callback function, which has an
opaque parameter, which is given to the interrupt callback.

This allows callers to precisely cancel IO for one single
AVFormatContext, without interrupt other ones in the same
process.

Note, it's not needed in AVIOContext, at the moment.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6aa0b98fb27ab22bd62a365de44d9f16cc07d03e
---

 libavformat/avformat.h |   11 +++++++++++
 libavformat/avio.h     |   17 +++++++++++++++++
 libavformat/url.h      |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 82d245e..33e820e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -994,6 +994,17 @@ typedef struct AVFormatContext {
      */
     int error_recognition;
 
+    /**
+     * Custom interrupt callbacks for the I/O layer.
+     *
+     * decoding: set by the user before avformat_open_input().
+     * encoding: set by the user before avformat_write_header()
+     * (mainly useful for AVFMT_NOFILE formats). The callback
+     * should also be passed to avio_open2() if it's used to
+     * open the file.
+     */
+    AVIOInterruptCB interrupt_callback;
+
     /*****************************************************************
      * All fields below this line are not part of the public API. They
      * may not be used outside of libavformat and can be changed and
diff --git a/libavformat/avio.h b/libavformat/avio.h
index be14e3c..a4041cb 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -36,6 +36,22 @@
 #define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
 
 /**
+ * Callback for checking whether to abort blocking functions.
+ * AVERROR_EXIT is returned in this case by the interrupted
+ * function. During blocking operations, callback is called with
+ * opaque as parameter. If the callback returns 1, the
+ * blocking operation will be aborted.
+ *
+ * No members can be added to this struct without a major bump, if
+ * new elements have been added after this struct in AVFormatContext
+ * or AVIOContext.
+ */
+typedef struct {
+    int (*callback)(void*);
+    void *opaque;
+} AVIOInterruptCB;
+
+/**
  * Bytestream IO Context.
  * New fields can be added to the end with minor version bumps.
  * Removal, reordering and changes to existing fields require a major
@@ -109,6 +125,7 @@ typedef struct URLContext {
     void *priv_data;
     char *filename; /**< specified URL */
     int is_connected;
+    AVIOInterruptCB interrupt_callback;
 } URLContext;
 
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
diff --git a/libavformat/url.h b/libavformat/url.h
index d69d0bc..c0f5322 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -42,6 +42,7 @@ typedef struct URLContext {
     int max_packet_size;        /**< if non zero, the stream is packetized with this max packet size */
     int is_streamed;            /**< true if streamed (no seek possible), default = false */
     int is_connected;
+    AVIOInterruptCB interrupt_callback;
 } URLContext;
 
 typedef struct URLProtocol {



More information about the ffmpeg-cvslog mailing list