]> git.sesse.net Git - cubemap/blob - input.h
Merge remote-tracking branch 'origin/master'
[cubemap] / input.h
1 #ifndef _INPUT_H
2 #define _INPUT_H 1
3
4 #include <vector>
5 #include <string>
6
7 class Input {
8 public:
9         Input(const std::string &stream_id);
10
11         // Connect to the given URL and start streaming.
12         // WARNING: Currently this blocks; it does not run in a separate thread!
13         void run(const std::string &url);
14
15 private:
16         // Recovers the this pointer and calls curl_callback().
17         static size_t curl_callback_thunk(char *ptr, size_t size, size_t nmemb, void *userdata);
18
19         // Stores the given data, looks for Metacube blocks (skipping data if needed),
20         // and calls process_block() for each one.
21         void curl_callback(char *ptr, size_t bytes);
22         void process_block(const char *data, uint32_t size, uint32_t flags);
23
24         // Drops <num_bytes> bytes from the head of <pending_data>,
25         // and outputs a warning.
26         void drop_pending_data(size_t num_bytes);
27
28         std::string stream_id;
29
30         // Data we have received but not fully processed yet.
31         std::vector<char> pending_data;
32
33         // If <pending_data> starts with a Metacube header,
34         // this is true.
35         bool has_metacube_header;
36 };
37
38 #endif  // !defined(_INPUT_H)