X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fplayer.h;h=e64abd79f7b834b0f6521829576da8e4ef8bc9f5;hb=686a02a3ffed47c099c1d91d95d0d90e222d297d;hp=d2e861ee59434128e35ab3788c0ebaaeaa7ecc73;hpb=c6fb9649d9f9c2e2cf3d1ac16c6c359630fe72bf;p=nageru diff --git a/futatabi/player.h b/futatabi/player.h index d2e861e..e64abd7 100644 --- a/futatabi/player.h +++ b/futatabi/player.h @@ -37,6 +37,35 @@ public: void play(const std::vector &clips); void override_angle(unsigned stream_idx); // Assumes one-clip playlist only. + // Replace the part of the playlist that we haven't started playing yet + // (ie., from the point immediately after the last current playing clip + // and to the end) with the given one. + // + // E.g., if we have the playlist A, B, C, D, E, F, we're currently in a fade + // from B to C and run splice_play() with the list G, C, H, I, the resulting + // list will be A, B, C, H, I. (If the new list doesn't contain B nor C, + // there will be some heuristics.) Note that we always compare on ID only; + // changes will be ignored for the purposes of setting the split point, + // although the newly-spliced entries will of course get the new in/out points + // etc., which is the main reason for going through this exercise in the first + // place. + // + // If nothing is playing, the call will be ignored. + void splice_play(const std::vector &clips); + + // Set the status string that will be used for the video stream's status subtitles + // whenever we are not playing anything. + void set_pause_status(const std::string &status) + { + std::lock_guard lock(queue_state_mu); + pause_status = status; + } + + void set_master_speed(float speed) + { + change_master_speed = speed; + } + // Not thread-safe to set concurrently with playing. // Will be called back from the player thread. using done_callback_func = std::function; @@ -55,7 +84,7 @@ public: private: void thread_func(AVFormatContext *file_avctx); void play_playlist_once(); - void display_single_frame(int primary_stream_idx, const FrameOnDisk &primary_frame, int secondary_stream_idx, const FrameOnDisk &secondary_frame, double fade_alpha, std::chrono::steady_clock::time_point frame_start, bool snapped); + void display_single_frame(int primary_stream_idx, const FrameOnDisk &primary_frame, int secondary_stream_idx, const FrameOnDisk &secondary_frame, double fade_alpha, std::chrono::steady_clock::time_point frame_start, bool snapped, const std::string &subtitle); void open_output_stream(); static int write_packet2_thunk(void *opaque, uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time); int write_packet2(uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time); @@ -66,6 +95,7 @@ private: std::thread player_thread; std::atomic should_quit{ false }; + std::atomic change_master_speed{ 0.0f / 0.0f }; JPEGFrameView *destination; done_callback_func done_callback; @@ -79,6 +109,10 @@ private: int override_stream_idx = -1; // Under queue_state_mu. int64_t last_pts_played = -1; // Under queue_state_mu. Used by previews only. + bool splice_ready = false; // Under queue_state_mu. + std::vector to_splice_clip_list; // Under queue_state_mu. + std::string pause_status = "paused"; // Under queue_state_mu. + std::unique_ptr video_stream; // Can be nullptr. std::atomic metric_dropped_interpolated_frame{ 0 }; @@ -108,4 +142,6 @@ static inline double compute_total_time(const std::vector &clips) return compute_time_left(clips, 0, 0.0); } +std::string format_duration(double t); + #endif // !defined(_PLAYER_H)