class Input {
public:
- Input(const std::string &stream_id);
+ Input(const std::string &stream_id, const std::string &url);
// Connect to the given URL and start streaming.
- // WARNING: Currently this blocks; it does not run in a separate thread!
- void run(const std::string &url);
+ void run();
+
+ // Stop streaming. NOTE: Does not currently work!
+ void stop();
private:
+ // Recovers the this pointer and calls do_work().
+ static void *do_work_thunk(void *arg);
+
+ // Actually does the download.
+ void do_work();
+
// Recovers the this pointer and calls curl_callback().
static size_t curl_callback_thunk(char *ptr, size_t size, size_t nmemb, void *userdata);
void drop_pending_data(size_t num_bytes);
std::string stream_id;
+ std::string url;
// Data we have received but not fully processed yet.
std::vector<char> pending_data;
// If <pending_data> starts with a Metacube header,
// this is true.
bool has_metacube_header;
+
+ pthread_t worker_thread;
+
+ // Whether we should stop or not.
+ volatile bool should_stop;
};
#endif // !defined(_INPUT_H)