[FFmpeg-cvslog] avformat: add callback for opening further files

Michael Niedermayer git at videolan.org
Mon May 11 22:06:31 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon May 11 17:45:13 2015 +0200| [541d75f9a0b6e1b360345e289cb44e43a39643cd] | committer: Michael Niedermayer

avformat: add callback for opening further files

Previous version reviewed-by: wm4 <nfxjfg at googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 doc/APIchanges              |    3 +++
 libavformat/avformat.h      |   21 +++++++++++++++++++++
 libavformat/avio_internal.h |    3 +++
 libavformat/aviobuf.c       |    6 ++++++
 libavformat/utils.c         |    1 +
 libavformat/version.h       |    2 +-
 6 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 822e6e5..a173931 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-05-11 - XXXXXXX - lavf 56.33.100 - avformat.h
+  Add AVOpenCallback AVFormatContext.open_cb
+
 2015-05-07 - a7dd933 - 56.38.100 - avcodec.h
   Add av_packet_side_data_name().
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 339ff52..f0593b8 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1237,6 +1237,8 @@ typedef struct AVChapter {
 typedef int (*av_format_control_message)(struct AVFormatContext *s, int type,
                                          void *data, size_t data_size);
 
+typedef int (*AVOpenCallback)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
+                              const AVIOInterruptCB *int_cb, AVDictionary **options);
 
 /**
  * The duration of a video can be estimated through various ways, and this enum can be used
@@ -1780,6 +1782,23 @@ typedef struct AVFormatContext {
      * Demuxing: Set by user.
      */
     enum AVCodecID data_codec_id;
+
+    /**
+     * Called to open further IO contexts when needed for demuxing.
+     *
+     * This can be set by the user application to perform security checks on
+     * the URLs before opening them.
+     * The function should behave like avio_open2(), AVFormatContext is provided
+     * as contextual information and to reach AVFormatContext.opaque.
+     *
+     * If NULL then avio_open2() is used.
+     *
+     * Must not be accessed directly from outside avformat.
+     * @See av_format_set_open_cb()
+     *
+     * Demuxing: Set by user.
+     */
+    int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);
 } AVFormatContext;
 
 int av_format_get_probe_score(const AVFormatContext *s);
@@ -1797,6 +1816,8 @@ void *    av_format_get_opaque(const AVFormatContext *s);
 void      av_format_set_opaque(AVFormatContext *s, void *opaque);
 av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);
 void      av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback);
+AVOpenCallback av_format_get_open_cb(const AVFormatContext *s);
+void      av_format_set_open_cb(AVFormatContext *s, AVOpenCallback callback);
 
 /**
  * This function will cause global side data to be injected in the next packet
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 1ed5831..c354771 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -157,4 +157,7 @@ int ffio_close_null_buf(AVIOContext *s);
  */
 void ffio_free_dyn_buf(AVIOContext **s);
 
+int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
+                       const AVIOInterruptCB *int_cb, AVDictionary **options);
+
 #endif /* AVFORMAT_AVIO_INTERNAL_H */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 333c75c..9701d74 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -918,6 +918,12 @@ int avio_open2(AVIOContext **s, const char *filename, int flags,
     return 0;
 }
 
+int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
+                       const AVIOInterruptCB *int_cb, AVDictionary **options)
+{
+    return avio_open2(pb, url, flags, int_cb, options);
+}
+
 int avio_close(AVIOContext *s)
 {
     URLContext *h;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d1f1d09..db2b4f6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -112,6 +112,7 @@ MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, data_codec)
 MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding)
 MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)
 MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)
+MAKE_ACCESSORS(AVFormatContext, format, AVOpenCallback, open_cb)
 
 int64_t av_stream_get_end_pts(const AVStream *st)
 {
diff --git a/libavformat/version.h b/libavformat/version.h
index 6373017..071fe5d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR  32
+#define LIBAVFORMAT_VERSION_MINOR  33
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list