]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tcp.c
Motion Pixels MVI Demuxer.
[ffmpeg] / libavformat / tcp.c
index 36b67076af8dac8509b6b4048b8a72b9e25be420..6c25e72b6f1d52215cc45654150a497c2e19b35c 100644 (file)
@@ -21,6 +21,7 @@
 #include "avformat.h"
 #include <unistd.h>
 #include "network.h"
+#include "os_support.h"
 #include <sys/time.h>
 
 typedef struct TCPContext {
@@ -49,10 +50,14 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     if (!s)
         return AVERROR(ENOMEM);
     h->priv_data = s;
+    h->is_streamed = 1;
 
     if (port <= 0 || port >= 65536)
         goto fail;
 
+    if(!ff_network_init())
+        return AVERROR(EIO);
+
     dest_addr.sin_family = AF_INET;
     dest_addr.sin_port = htons(port);
     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
@@ -69,7 +74,8 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     if (ret < 0) {
         if (ff_neterrno() == FF_NETERROR(EINTR))
             goto redo;
-        if (ff_neterrno() != FF_NETERROR(EINPROGRESS))
+        if (ff_neterrno() != FF_NETERROR(EINPROGRESS) &&
+            ff_neterrno() != FF_NETERROR(EAGAIN))
             goto fail;
 
         /* wait until we are connected or until abort */
@@ -98,7 +104,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     return 0;
 
  fail:
-    ret = AVERROR_IO;
+    ret = AVERROR(EIO);
  fail1:
     if (fd >= 0)
         closesocket(fd);
@@ -173,6 +179,7 @@ static int tcp_close(URLContext *h)
 {
     TCPContext *s = h->priv_data;
     closesocket(s->fd);
+    ff_network_close();
     av_free(s);
     return 0;
 }