]> git.sesse.net Git - nageru/blobdiff - futatabi/player.h
Add some metrics for HTTP output.
[nageru] / futatabi / player.h
index b57bada647f2cb48439265cf8e534a6179c4d8f3..33a83e5c550101870036b1e9297202e42cd82958 100644 (file)
@@ -6,6 +6,7 @@
 #include "queue_spot_holder.h"
 
 extern "C" {
+#include <libavformat/avformat.h>
 #include <libavformat/avio.h>
 }
 
@@ -19,9 +20,16 @@ class VideoStream;
 class QSurface;
 class QSurfaceFormat;
 
+double compute_time_left(const std::vector<Clip> &clips, const std::map<size_t, double> &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);
@@ -48,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);
@@ -78,6 +86,16 @@ private:
 
        std::unique_ptr<VideoStream> video_stream;  // Can be nullptr.
 
+       std::atomic<int64_t> metric_dropped_interpolated_frame{0};
+       std::atomic<int64_t> metric_dropped_unconditional_frame{0};
+       std::atomic<int64_t> metric_faded_frame{0};
+       std::atomic<int64_t> metric_faded_snapped_frame{0};
+       std::atomic<int64_t> metric_original_frame{0};
+       std::atomic<int64_t> metric_original_snapped_frame{0};
+       std::atomic<int64_t> metric_refresh_frame{0};
+       std::atomic<int64_t> metric_interpolated_frame{0};
+       std::atomic<int64_t> 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;