]> git.sesse.net Git - nageru/blobdiff - nageru/mixer.h
Export SRT statistics as Prometheus metrics.
[nageru] / nageru / mixer.h
index 235dd8da3fba1bf1b9c4325f89c7bf0a6c11b130..af07f8896665044291a281918af5bbd51961cd0a 100644 (file)
@@ -445,7 +445,7 @@ private:
                FFMPEG_INPUT,
                CEF_INPUT,
        };
-       void configure_card(unsigned card_index, bmusb::CaptureInterface *capture, CardType card_type, DeckLinkOutput *output, bool override_ffmpeg_to_live = false);
+       void configure_card(unsigned card_index, bmusb::CaptureInterface *capture, CardType card_type, DeckLinkOutput *output, bool is_srt_card = false);
        void set_output_card_internal(int card_index);  // Should only be called from the mixer thread.
        void bm_frame(unsigned card_index, uint16_t timecode,
                bmusb::FrameAllocator::Frame video_frame, size_t video_offset, bmusb::VideoFormat video_format,
@@ -590,6 +590,53 @@ private:
                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};
+
+               // SRT metrics.
+               std::atomic<double> metric_srt_uptime_seconds{0.0 / 0.0};
+               std::atomic<double> metric_srt_send_duration_seconds{0.0 / 0.0};
+               std::atomic<int64_t> metric_srt_sent_bytes{-1};
+               std::atomic<int64_t> metric_srt_received_bytes{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_normal{-1};
+               std::atomic<int64_t> metric_srt_received_packets_normal{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_lost{-1};
+               std::atomic<int64_t> metric_srt_received_packets_lost{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_retransmitted{-1};
+               std::atomic<int64_t> metric_srt_sent_bytes_retransmitted{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_ack{-1};
+               std::atomic<int64_t> metric_srt_received_packets_ack{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_nak{-1};
+               std::atomic<int64_t> metric_srt_received_packets_nak{-1};
+               std::atomic<int64_t> metric_srt_sent_packets_dropped{-1};
+               std::atomic<int64_t> metric_srt_received_packets_dropped{-1};
+               std::atomic<int64_t> metric_srt_sent_bytes_dropped{-1};
+               std::atomic<int64_t> metric_srt_received_bytes_dropped{-1};
+               std::atomic<int64_t> metric_srt_received_packets_undecryptable{-1};
+               std::atomic<int64_t> metric_srt_received_bytes_undecryptable{-1};
+
+               std::atomic<int64_t> metric_srt_filter_received_extra_packets{-1};
+               std::atomic<int64_t> metric_srt_filter_received_rebuilt_packets{-1};
+               std::atomic<int64_t> metric_srt_filter_received_lost_packets{-1};
+
+               std::atomic<double> metric_srt_packet_sending_period_seconds{0.0 / 0.0};
+               std::atomic<int64_t> metric_srt_flow_window_packets{-1};
+               std::atomic<int64_t> metric_srt_congestion_window_packets{-1};
+               std::atomic<int64_t> metric_srt_flight_size_packets{-1};
+               std::atomic<double> metric_srt_rtt_seconds{0.0 / 0.0};
+               std::atomic<double> metric_srt_estimated_bandwidth_bits_per_second{0.0 / 0.0};
+               std::atomic<double> metric_srt_bandwidth_ceiling_bits_per_second{0.0 / 0.0};
+               std::atomic<int64_t> metric_srt_send_buffer_available_bytes{-1};
+               std::atomic<int64_t> metric_srt_receive_buffer_available_bytes{-1};
+               std::atomic<int64_t> metric_srt_mss_bytes{-1};
+               std::atomic<int64_t> metric_srt_sender_unacked_packets{-1};
+               std::atomic<int64_t> metric_srt_sender_unacked_bytes{-1};
+               std::atomic<double> metric_srt_sender_unacked_timespan_seconds{0.0 / 0.0};
+               std::atomic<double> metric_srt_sender_delivery_delay_seconds{0.0 / 0.0};
+               std::atomic<int64_t> metric_srt_receiver_unacked_packets{-1};
+               std::atomic<int64_t> metric_srt_receiver_unacked_bytes{-1};
+               std::atomic<double> metric_srt_receiver_unacked_timespan_seconds{0.0 / 0.0};
+               std::atomic<double> metric_srt_receiver_delivery_delay_seconds{0.0 / 0.0};
+               std::atomic<int64_t> metric_srt_filter_sent_packets{-1};
+
        };
        JitterHistory output_jitter_history;
        CaptureCard cards[MAX_VIDEO_CARDS];  // Protected by <card_mutex>.
@@ -606,6 +653,10 @@ private:
        };
        OutputFrameInfo get_one_frame_from_each_card(unsigned master_card_index, bool master_card_is_output, CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS], bool has_new_frame[MAX_VIDEO_CARDS], std::vector<int32_t> raw_audio[MAX_VIDEO_CARDS]);
 
+#ifdef HAVE_SRT
+       void update_srt_stats(int srt_sock, Mixer::CaptureCard *card);
+#endif
+
        InputState input_state;
 
        // Cards we have been noticed about being hotplugged, but haven't tried adding yet.