]> git.sesse.net Git - nageru/commitdiff
Add a metric for general Futatabi player health (how much buffer there is left).
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Wed, 4 Mar 2020 23:16:47 +0000 (00:16 +0100)
committerBigscreen user <bigscreen@bigscreen.party.solskogen.no>
Wed, 4 Mar 2020 23:18:51 +0000 (00:18 +0100)
futatabi/player.cpp
futatabi/player.h

index 94438a0c9713dff414bbff2f3594f6666ff38b11..19868f486944fcf51bab9fec200437ab9fe9d88e 100644 (file)
@@ -242,6 +242,7 @@ void Player::play_playlist_once()
                        }
 
                        steady_clock::duration time_behind = steady_clock::now() - next_frame_start;
+                       metric_player_ahead_seconds.count_event(-duration<double>(time_behind).count());
                        if (stream_output != FILE_STREAM_OUTPUT && time_behind >= milliseconds(200)) {
                                fprintf(stderr, "WARNING: %ld ms behind, dropping a frame (no matter the type).\n",
                                        lrint(1e3 * duration<double>(time_behind).count()));
@@ -534,6 +535,10 @@ Player::Player(JPEGFrameView *destination, Player::StreamOutput stream_output, A
                global_metrics.add("http_output_frames", { { "type", "refresh" } }, &metric_refresh_frame);
                global_metrics.add("http_dropped_frames", { { "type", "interpolated" } }, &metric_dropped_interpolated_frame);
                global_metrics.add("http_dropped_frames", { { "type", "unconditional" } }, &metric_dropped_unconditional_frame);
+
+               vector<double> quantiles{ 0.01, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99 };
+               metric_player_ahead_seconds.init(quantiles, 60.0);
+               global_metrics.add("player_ahead_seconds", &metric_player_ahead_seconds);
        }
 }
 
index 597f70209373ae601c6b7d6401d3e53ffb8f88e1..77fb9e29b485a58ffbfbfc37273c9c9ce8e22a52 100644 (file)
@@ -4,6 +4,7 @@
 #include "clip_list.h"
 #include "frame_on_disk.h"
 #include "queue_spot_holder.h"
+#include "shared/metrics.h"
 
 extern "C" {
 #include <libavformat/avformat.h>
@@ -137,6 +138,7 @@ private:
        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 };
+       Summary metric_player_ahead_seconds;
 
        // under queue_state_mu. Part of this instead of VideoStream so that we own
        // its lock and can sleep on it.