]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/network.h
Merge remote branch 'qatar/master'
[ffmpeg] / libavformat / network.h
index 58a8e80e72a75e799688a62947968ad773481904..f2a0c97d77ce9a2118264a387c8d9dd4d03447d4 100644 (file)
@@ -22,6 +22,7 @@
 #define AVFORMAT_NETWORK_H
 
 #include "config.h"
+#include "os_support.h"
 
 #if HAVE_WINSOCK2_H
 #include <winsock2.h>
@@ -55,6 +56,10 @@ static inline int ff_neterrno() {
 #include <arpa/inet.h>
 #endif
 
+#if HAVE_POLL_H
+#include <poll.h>
+#endif
+
 int ff_socket_nonblock(int socket, int enable);
 
 static inline int ff_network_init(void)
@@ -67,6 +72,15 @@ static inline int ff_network_init(void)
     return 1;
 }
 
+static inline int ff_network_wait_fd(int fd, int write)
+{
+    int ev = write ? POLLOUT : POLLIN;
+    struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
+    int ret;
+    ret = poll(&p, 1, 100);
+    return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
+}
+
 static inline void ff_network_close(void)
 {
 #if HAVE_WINSOCK2_H