X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fplayer.h;h=33a83e5c550101870036b1e9297202e42cd82958;hb=f1cddd2fcaf4d166b31c7d28e4ccd2201c5508f2;hp=c7f8e070a71a0ce697e1c21edd14727a3892762f;hpb=9b7d691b4cc5db7dbfc18c82e86c1207fcac4722;p=nageru diff --git a/futatabi/player.h b/futatabi/player.h index c7f8e07..33a83e5 100644 --- a/futatabi/player.h +++ b/futatabi/player.h @@ -6,21 +6,31 @@ #include "queue_spot_holder.h" extern "C" { +#include #include } #include #include #include +#include class JPEGFrameView; class VideoStream; class QSurface; class QSurfaceFormat; +double compute_time_left(const std::vector &clips, const std::map &progress); + class Player : public QueueInterface { public: - Player(JPEGFrameView *destination, bool also_output_to_stream); + enum StreamOutput { + NO_STREAM_OUTPUT, + HTTPD_STREAM_OUTPUT, // Output to global_httpd. + FILE_STREAM_OUTPUT // Output to file_avctx. + }; + Player(JPEGFrameView *destination, StreamOutput stream_output, AVFormatContext *file_avctx = nullptr); + ~Player(); void play_clip(const Clip &clip, size_t clip_idx, unsigned stream_idx); void override_angle(unsigned stream_idx); // For the current clip only. @@ -46,7 +56,7 @@ public: void release_queue_spot() override; private: - void thread_func(bool also_output_to_stream); + void thread_func(StreamOutput stream_output, AVFormatContext *file_avctx); 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); @@ -55,6 +65,9 @@ private: // Returns false if pts is after the last frame. bool find_surrounding_frames(int64_t pts, int stream_idx, FrameOnDisk *frame_lower, FrameOnDisk *frame_upper); + std::thread player_thread; + std::atomic should_quit{false}; + JPEGFrameView *destination; done_callback_func done_callback; next_clip_callback_func next_clip_callback; @@ -73,6 +86,16 @@ private: std::unique_ptr video_stream; // Can be nullptr. + std::atomic metric_dropped_interpolated_frame{0}; + std::atomic metric_dropped_unconditional_frame{0}; + std::atomic metric_faded_frame{0}; + std::atomic metric_faded_snapped_frame{0}; + std::atomic metric_original_frame{0}; + std::atomic metric_original_snapped_frame{0}; + std::atomic metric_refresh_frame{0}; + std::atomic metric_interpolated_frame{0}; + std::atomic metric_interpolated_faded_frame{0}; + // 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;