]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/network.c
avformat: make avformat_network_init() explicitly optional
[ffmpeg] / libavformat / network.c
index 6c3d9def3b79a903cde10354fd8070cd28d928fc..d5c82e9ab9ba83645c97a13d4bc2857dea1b0775 100644 (file)
@@ -54,20 +54,11 @@ void ff_tls_deinit(void)
 #endif
 }
 
-int ff_network_inited_globally;
-
 int ff_network_init(void)
 {
 #if HAVE_WINSOCK2_H
     WSADATA wsaData;
-#endif
 
-    if (!ff_network_inited_globally)
-        av_log(NULL, AV_LOG_WARNING, "Using network protocols without global "
-                                     "network initialization. Please use "
-                                     "avformat_network_init(), this will "
-                                     "become mandatory later.\n");
-#if HAVE_WINSOCK2_H
     if (WSAStartup(MAKEWORD(1,1), &wsaData))
         return 0;
 #endif
@@ -103,6 +94,24 @@ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterrupt
     }
 }
 
+int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
+{
+    int64_t wait_start = av_gettime_relative();
+
+    while (1) {
+        int64_t time_left;
+
+        if (ff_check_interrupt(int_cb))
+            return AVERROR_EXIT;
+
+        time_left = timeout - (av_gettime_relative() - wait_start);
+        if (time_left <= 0)
+            return AVERROR(ETIMEDOUT);
+
+        av_usleep(FFMIN(time_left, POLLING_TIME * 1000));
+    }
+}
+
 void ff_network_close(void)
 {
 #if HAVE_WINSOCK2_H