]> git.sesse.net Git - nageru/blobdiff - player.h
Add a queue of frames going into VideoStream.
[nageru] / player.h
index 294ffbaa3b9d765baade1f20966c32cf42d4800d..f5adcf7a505dfed1636466bb06cf689c788bba5a 100644 (file)
--- a/player.h
+++ b/player.h
@@ -28,6 +28,11 @@ public:
        using done_callback_func = std::function<void()>;
        void set_done_callback(done_callback_func cb) { done_callback = cb; }
 
+       // Not thread-safe to set concurrently with playing.
+       // Will be called back from the player thread.
+       using next_clip_callback_func = std::function<Clip()>;
+       void set_next_clip_callback(next_clip_callback_func cb) { next_clip_callback = cb; }
+
        // Not thread-safe to set concurrently with playing.
        // Will be called back from the player thread.
        using progress_callback_func = std::function<void(double played_this_clip, double total_length)>;
@@ -45,6 +50,7 @@ private:
 
        JPEGFrameView *destination;
        done_callback_func done_callback;
+       next_clip_callback_func next_clip_callback;
        progress_callback_func progress_callback;
 
        std::mutex mu;
@@ -58,6 +64,11 @@ private:
        int override_stream_idx = -1;  // Under queue_state_mu.
 
        std::unique_ptr<VideoStream> video_stream;  // Can be nullptr.
+
+       // under queue_state_mu. Part of this instead of VideoStream so that we own
+       // its lock and can sleep on it.
+       size_t num_queued_frames = 0;
+       static constexpr size_t max_queued_frames = 10;
 };
 
 #endif  // !defined(_PLAYER_H)