]> git.sesse.net Git - cubemap/blob - udpinput.h
Deduplicate inputs.
[cubemap] / udpinput.h
1 #ifndef _UDPINPUT_H
2 #define _UDPINPUT_H 1
3
4 #include <string>
5 #include <vector>
6
7 #include "input.h"
8
9 class InputProto;
10
11 class UDPInput : public Input {
12 public:
13         UDPInput(const std::string &url);
14
15         // Serialization/deserialization.
16         UDPInput(const InputProto &serialized);
17         virtual InputProto serialize() const;
18
19         virtual std::string get_url() const { return url; }
20         virtual void close_socket();
21
22         virtual void add_destination(const std::string &stream_id)
23         {
24                 stream_ids.push_back(stream_id);
25         }
26
27 private:
28         // Actually gets the packets.
29         virtual void do_work();
30
31         // Create the HTTP header.
32         void construct_header();
33
34         std::vector<std::string> stream_ids;
35
36         // The URL and its parsed components.
37         std::string url;
38         std::string host, port, path;
39
40         // The socket we are receiving on (or -1).
41         int sock;
42 };
43
44 #endif  // !defined(_UDPINPUT_H)