]> git.sesse.net Git - nageru/blobdiff - ffmpeg_capture.h
Remove a now obsolete comment.
[nageru] / ffmpeg_capture.h
index 8c75b4f705c25691bb2a967fc68c11b6d6ebeac0..e6b4ed481f6b151e8a687a1f7b0aec5dab7d0472 100644 (file)
 //
 // There is currently no audio support. There is also no support for changing
 // the video underway (unlike images), although there really should be.
-// Finally, there is currently no support for controlling the video from Lua.
 
 #include <assert.h>
 #include <stdint.h>
 #include <functional>
 #include <map>
 #include <memory>
+#include <mutex>
 #include <set>
 #include <string>
 #include <thread>
@@ -48,6 +48,18 @@ public:
                return card_index;
        }
 
+       void rewind()
+       {
+               std::lock_guard<std::mutex> lock(queue_mu);
+               command_queue.push_back(QueuedCommand { QueuedCommand::REWIND });
+       }
+
+       void change_rate(double new_rate)
+       {
+               std::lock_guard<std::mutex> lock(queue_mu);
+               command_queue.push_back(QueuedCommand { QueuedCommand::CHANGE_RATE, new_rate });
+       }
+
        // CaptureInterface.
        void set_video_frame_allocator(bmusb::FrameAllocator *allocator) override
        {
@@ -147,6 +159,13 @@ private:
 
        std::atomic<bool> producer_thread_should_quit{false};
        std::thread producer_thread;
+
+       std::mutex queue_mu;
+       struct QueuedCommand {
+               enum Command { REWIND, CHANGE_RATE } command;
+               double new_rate;  // For CHANGE_RATE.
+       };
+       std::vector<QueuedCommand> command_queue;  // Protected by <queue_mu>.
 };
 
 #endif  // !defined(_FFMPEG_CAPTURE_H)