]> git.sesse.net Git - cubemap/blob - udpinput.h
Fix a potential double-free.
[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(int stream_index);
23
24 private:
25         // Actually gets the packets.
26         virtual void do_work();
27
28         // Create the HTTP header.
29         void construct_header();
30
31         std::vector<int> stream_indices;
32
33         // The URL and its parsed components.
34         std::string url;
35         std::string host, port, path;
36
37         // The HTTP header we're sending to clients.
38         std::string http_header;
39
40         // The socket we are receiving on (or -1).
41         int sock;
42
43         // Temporary buffer, sized for the maximum size of an UDP packet.
44         char packet_buf[65536];
45 };
46
47 #endif  // !defined(_UDPINPUT_H)