]> git.sesse.net Git - nageru/blobdiff - mixer.h
Update the queue length metric after trimming, not before.
[nageru] / mixer.h
diff --git a/mixer.h b/mixer.h
index 6828bc66364d27d20d9f0a264816d29d42293882..8504d5eb4bb9d6a56d8b68dd2ab04464b0bcecfd 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -23,6 +23,8 @@
 #include <thread>
 #include <vector>
 
+#include <movit/image_format.h>
+
 #include "audio_mixer.h"
 #include "bmusb/bmusb.h"
 #include "defs.h"
@@ -35,6 +37,7 @@
 #include "theme.h"
 #include "timebase.h"
 #include "video_encoder.h"
+#include "ycbcr_interpretation.h"
 
 class ALSAOutput;
 class ChromaSubsampler;
@@ -85,6 +88,8 @@ public:
                been_at_safe_point_since_last_starvation = false;
        }
 
+       void register_metrics(const std::vector<std::pair<std::string, std::string>> &labels);
+
        void update_policy(unsigned queue_length);  // Call before picking out a frame, so 0 means starvation.
        unsigned get_safe_queue_length() const { return safe_queue_length; }
 
@@ -93,6 +98,11 @@ private:
        unsigned safe_queue_length = 1;  // Called N in the comments. Can never go below 1.
        unsigned frames_with_at_least_one = 0;
        bool been_at_safe_point_since_last_starvation = false;
+
+       // Metrics.
+       std::atomic<int64_t> metric_input_queue_length_frames{0};
+       std::atomic<int64_t> metric_input_queue_safe_length_frames{1};
+       std::atomic<int64_t> metric_input_duped_frames{0};
 };
 
 class Mixer {
@@ -216,6 +226,9 @@ public:
                return theme->set_signal_mapping(signal, card);
        }
 
+       YCbCrInterpretation get_input_ycbcr_interpretation(unsigned card_index) const;
+       void set_input_ycbcr_interpretation(unsigned card_index, const YCbCrInterpretation &interpretation);
+
        bool get_supports_set_wb(unsigned channel) const
        {
                return theme->get_supports_set_wb(channel);
@@ -409,6 +422,7 @@ private:
        struct CaptureCard {
                std::unique_ptr<bmusb::CaptureInterface> capture;
                bool is_fake_capture;
+               CardType type;
                std::unique_ptr<DeckLinkOutput> output;
 
                // If this card is used for output (ie., output_card_index points to it),
@@ -439,8 +453,23 @@ private:
                QueueLengthPolicy queue_length_policy;  // Refers to the "new_frames" queue.
 
                int last_timecode = -1;  // Unwrapped.
+
+               // Metrics.
+               std::atomic<int64_t> metric_input_dropped_frames_jitter{0};
+               std::atomic<int64_t> metric_input_dropped_frames_error{0};
+               std::atomic<int64_t> metric_input_resets{0};
+
+               std::atomic<int64_t> metric_input_has_signal_bool{-1};
+               std::atomic<int64_t> metric_input_is_connected_bool{-1};
+               std::atomic<int64_t> metric_input_interlaced_bool{-1};
+               std::atomic<int64_t> metric_input_width_pixels{-1};
+               std::atomic<int64_t> metric_input_height_pixels{-1};
+               std::atomic<int64_t> metric_input_frame_rate_nom{-1};
+               std::atomic<int64_t> metric_input_frame_rate_den{-1};
+               std::atomic<int64_t> metric_input_sample_rate_hz{-1};
        };
        CaptureCard cards[MAX_VIDEO_CARDS];  // Protected by <card_mutex>.
+       YCbCrInterpretation ycbcr_interpretation[MAX_VIDEO_CARDS];  // Protected by <card_mutex>.
        AudioMixer audio_mixer;  // Same as global_audio_mixer (see audio_mixer.h).
        bool input_card_is_master_clock(unsigned card_index, unsigned master_card_index) const;
        struct OutputFrameInfo {
@@ -510,6 +539,13 @@ private:
        std::vector<uint32_t> mode_scanlist[MAX_VIDEO_CARDS];
        unsigned mode_scanlist_index[MAX_VIDEO_CARDS]{ 0 };
        std::chrono::steady_clock::time_point last_mode_scan_change[MAX_VIDEO_CARDS];
+
+       // Metrics.
+       std::atomic<int64_t> metric_frames_output_total{0};
+       std::atomic<int64_t> metric_frames_output_dropped{0};
+       std::atomic<double> metric_start_time_seconds{0.0 / 0.0};
+       std::atomic<int64_t> metrics_memory_used_bytes{0};
+       std::atomic<double> metrics_memory_locked_limit_bytes{0.0 / 0.0};
 };
 
 extern Mixer *global_mixer;