]> git.sesse.net Git - cubemap/blobdiff - udpstream.h
Add support for UDP outputs.
[cubemap] / udpstream.h
diff --git a/udpstream.h b/udpstream.h
new file mode 100644 (file)
index 0000000..3424b98
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _UDPSTREAM_H
+#define _UDPSTREAM_H 1
+
+// A single UDP destination. This is done a lot less efficient than HTTP streaming
+// since we expect to have so few of them, which also means things are a lot simpler.
+// In particular, we run in the input's thread, so there is no backlog, which means
+// that there is no state (UDP itself is, of course, stateless).
+
+#include <arpa/inet.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+class MarkPool;
+
+class UDPStream {
+public:
+       // <mark_pool> can be NULL. Does not take ownership of the mark pool.
+       UDPStream(const sockaddr_in6 &dst, MarkPool *mark_pool);
+       ~UDPStream();
+
+       void send(const char *data, size_t bytes);
+
+private:
+       UDPStream(const UDPStream& other);
+
+       sockaddr_in6 dst;
+       int sock;
+       MarkPool *mark_pool;
+       int fwmark;
+};
+
+#endif  // !defined(_UDPSTREAM_H)