]> git.sesse.net Git - nageru/blobdiff - ffmpeg_capture.h
Add a Lua function to rewind the video.
[nageru] / ffmpeg_capture.h
index 8c75b4f705c25691bb2a967fc68c11b6d6ebeac0..daf353eec6bdad339dc5e1ddbf87a4d36709726c 100644 (file)
@@ -26,6 +26,7 @@
 #include <functional>
 #include <map>
 #include <memory>
+#include <mutex>
 #include <set>
 #include <string>
 #include <thread>
@@ -48,6 +49,12 @@ public:
                return card_index;
        }
 
+       void rewind()
+       {
+               std::lock_guard<std::mutex> lock(queue_mu);
+               command_queue.push_back(QueuedCommand { QueuedCommand::REWIND });
+       }
+
        // CaptureInterface.
        void set_video_frame_allocator(bmusb::FrameAllocator *allocator) override
        {
@@ -147,6 +154,12 @@ private:
 
        std::atomic<bool> producer_thread_should_quit{false};
        std::thread producer_thread;
+
+       std::mutex queue_mu;
+       struct QueuedCommand {
+               enum Command { REWIND } command;
+       };
+       std::vector<QueuedCommand> command_queue;  // Protected by <queue_mu>.
 };
 
 #endif  // !defined(_FFMPEG_CAPTURE_H)