9 Input(const std::string &stream_id, const std::string &url);
11 // Connect to the given URL and start streaming.
14 // Stops the streaming, but lets the file descriptor stay open.
18 // Recovers the this pointer and calls do_work().
19 static void *do_work_thunk(void *arg);
21 // Actually does the download.
24 // Open a socket that connects to the given host and port. Does DNS resolving.
25 int lookup_and_connect(const std::string &host, const std::string &port);
27 // Stores the given data, looks for Metacube blocks (skipping data if needed),
28 // and calls process_block() for each one.
29 void process_data(char *ptr, size_t bytes);
31 // Drops <num_bytes> bytes from the head of <pending_data>,
32 // and outputs a warning.
33 void drop_pending_data(size_t num_bytes);
40 CLOSING_SOCKET, // Due to error.
44 std::string stream_id;
46 // The URL and its parsed components.
48 std::string host, port, path;
50 // The HTTP request, with headers and all.
51 // Only relevant for SENDING_REQUEST.
54 // How many bytes we've sent of the request so far.
55 // Only relevant for SENDING_REQUEST.
56 size_t request_bytes_sent;
58 // The HTTP response we've received so far. Only relevant for RECEIVING_HEADER.
61 // Data we have received but not fully processed yet.
62 std::vector<char> pending_data;
64 // If <pending_data> starts with a Metacube header,
66 bool has_metacube_header;
68 // The socket we are downloading on (or -1).
71 // Handle to the thread that actually does the download.
72 pthread_t worker_thread;
74 // Whether we should stop or not.
75 volatile bool should_stop;
78 #endif // !defined(_INPUT_H)