X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input.h;h=508eb59ae68cac1ba029c88caae5f67bbff73000;hp=c293071ecfa7a9f7aae9562905841cac690dc040;hb=f3ed48479f9209e708cd17698dc9e778e07284cd;hpb=519ddcdf0458032a2024d7acc57642fe27829dc0 diff --git a/input.h b/input.h index c293071..508eb59 100644 --- a/input.h +++ b/input.h @@ -6,13 +6,21 @@ 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); @@ -26,6 +34,7 @@ private: 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 pending_data; @@ -33,6 +42,11 @@ private: // If 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)