[FFmpeg-cvslog] avformat/utils: Add ff_format_output_open() function

Jan Sebechlebsky git at videolan.org
Sat Jul 16 01:48:37 CEST 2016


ffmpeg | branch: master | Jan Sebechlebsky <sebechlebskyjan at gmail.com> | Mon Jul  4 16:45:13 2016 +0200| [6a3515a5a49e985b0f2ce430c9cae9e21dd6d7c2] | committer: Marton Balint

avformat/utils: Add ff_format_output_open() function

Add ff_format_output_open utility function to wrap
io_open callback of AVFormatContext structure.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
Signed-off-by: Marton Balint <cus at passwd.hu>

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

 libavformat/internal.h |   10 ++++++++++
 libavformat/utils.c    |   10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 1b44bea..0119749 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -572,6 +572,16 @@ int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *
  */
 #define FFERROR_REDO FFERRTAG('R','E','D','O')
 
+/**
+ * Utility function to open IO stream of output format.
+ *
+ * @param s AVFormatContext
+ * @param url URL or file name to open for writing
+ * @options optional options which will be passed to io_open callback
+ * @return >=0 on success, negative AVERROR in case of failure
+ */
+int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options);
+
 /*
  * A wrapper around AVFormatContext.io_close that should be used
  * instead of calling the pointer directly.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f2b0e6e..e5a99ff 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -5169,6 +5169,16 @@ int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options)
+{
+    if (!s->oformat)
+        return AVERROR(EINVAL);
+
+    if (!(s->oformat->flags & AVFMT_NOFILE))
+        return s->io_open(s, &s->pb, url, AVIO_FLAG_WRITE, options);
+    return 0;
+}
+
 void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
 {
     if (*pb)



More information about the ffmpeg-cvslog mailing list