]> git.sesse.net Git - nageru/blobdiff - ffmpeg_capture.h
Factor out rewinding code in its own member function.
[nageru] / ffmpeg_capture.h
index e6b4ed481f6b151e8a687a1f7b0aec5dab7d0472..095078267c1987d67e7e843ded7e90cb57641136 100644 (file)
@@ -31,6 +31,7 @@
 #include <thread>
 
 #include "bmusb/bmusb.h"
+#include "quittable_sleeper.h"
 
 class FFmpegCapture : public bmusb::CaptureInterface
 {
@@ -140,6 +141,7 @@ public:
 private:
        void producer_thread_func();
        bool play_video(const std::string &pathname);
+       void internal_rewind();
 
        std::string description, filename;
        uint16_t timecode = 0;
@@ -157,9 +159,12 @@ private:
        std::unique_ptr<bmusb::FrameAllocator> owned_audio_frame_allocator;
        bmusb::frame_callback_t frame_callback = nullptr;
 
-       std::atomic<bool> producer_thread_should_quit{false};
+       QuittableSleeper producer_thread_should_quit;
        std::thread producer_thread;
 
+       int64_t pts_origin, last_pts;
+       std::chrono::steady_clock::time_point start, next_frame_start;
+
        std::mutex queue_mu;
        struct QueuedCommand {
                enum Command { REWIND, CHANGE_RATE } command;