]> git.sesse.net Git - cubemap/blobdiff - input.h
Fix an issue where clients would be put twice into sleeping_clients (probably since...
[cubemap] / input.h
diff --git a/input.h b/input.h
index c293071ecfa7a9f7aae9562905841cac690dc040..508eb59ae68cac1ba029c88caae5f67bbff73000 100644 (file)
--- 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<char> pending_data;
@@ -33,6 +42,11 @@ private:
        // 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)