[10/10] avformat: Add functions for doing global network initialization

Message ID 1320154365-10834-10-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Nov. 1, 2011, 1:32 p.m.
---
 doc/APIchanges         |    3 +++
 libavformat/avformat.h |   15 +++++++++++++++
 libavformat/utils.c    |   20 ++++++++++++++++++++
 libavformat/version.h  |    2 +-
 4 files changed, 39 insertions(+), 1 deletions(-)

Comments

Luca Barbato Nov. 4, 2011, 9:25 p.m. | #1
On 11/1/11 6:32 AM, Martin Storsjö wrote:
> ---
>   doc/APIchanges         |    3 +++
>   libavformat/avformat.h |   15 +++++++++++++++
>   libavformat/utils.c    |   20 ++++++++++++++++++++
>   libavformat/version.h  |    2 +-
>   4 files changed, 39 insertions(+), 1 deletions(-)
>

Looks fine as well

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 79aa202..da2844f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@  libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-10-xx - xxxxxxx - lavf 53.13.0
+  Add avformat_network_init()/avformat_network_uninit()
+
 2011-xx-xx - xxxxxxx - lavc 53.15.0
   Remove avcodec_parse_frame.
   Deprecate AVCodecContext.parse_only and CODEC_CAP_PARSE_ONLY.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index dd40c7f..4356303 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1743,4 +1743,19 @@  int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_co
  */
 const AVClass *avformat_get_class(void);
 
+/**
+ * Do global initialization of network components. This is optional,
+ * but recommended, since it avoids the overhead of implicitly
+ * doing the setup for each session.
+ *
+ * Since the next major version bump, calling this function will become
+ * mandatory if using network protocols.
+ */
+int avformat_network_init(void);
+
+/**
+ * Undo the initialization done by avformat_network_init.
+ */
+int avformat_network_deinit(void);
+
 #endif /* AVFORMAT_AVFORMAT_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1158079..c13ce3d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3964,3 +3964,23 @@  int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_co
     }
     return AVERROR_PATCHWELCOME;
 }
+
+int avformat_network_init(void)
+{
+#if CONFIG_NETWORK
+    int ret;
+    if ((ret = ff_network_init()) < 0)
+        return ret;
+    ff_tls_init();
+#endif
+    return 0;
+}
+
+int avformat_network_deinit(void)
+{
+#if CONFIG_NETWORK
+    ff_network_close();
+    ff_tls_deinit();
+#endif
+    return 0;
+}
diff --git a/libavformat/version.h b/libavformat/version.h
index c7b0778..48f2303 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,7 +24,7 @@ 
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR 12
+#define LIBAVFORMAT_VERSION_MINOR 13
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \