+ReceivedTimestamps find_received_timestamp(const vector<RefCountedFrame> &input_frames)
+{
+ // Find min and max timestamp of all input frames that have a timestamp.
+ steady_clock::time_point min_ts = steady_clock::time_point::max(), max_ts = steady_clock::time_point::min();
+ for (const RefCountedFrame &input_frame : input_frames) {
+ if (input_frame && input_frame->received_timestamp > steady_clock::time_point::min()) {
+ min_ts = min(min_ts, input_frame->received_timestamp);
+ max_ts = max(max_ts, input_frame->received_timestamp);
+ }
+ }
+ return { min_ts, max_ts };
+}
+
+void LatencyHistogram::init(const string &measuring_point)
+{
+ histogram_lowest_latency_input.init_geometric(0.001, 10.0, 30);
+ histogram_highest_latency_input.init_geometric(0.001, 10.0, 30);
+ histogram_lowest_latency_input_bframe.init_geometric(0.001, 10.0, 30);
+ histogram_highest_latency_input_bframe.init_geometric(0.001, 10.0, 30);
+
+ global_metrics.add("latency_seconds",
+ {{ "measuring_point", measuring_point }, { "input", "lowest_latency" }, { "frame_type", "i/p" }},
+ &histogram_lowest_latency_input);
+ global_metrics.add("latency_seconds",
+ {{ "measuring_point", measuring_point }, { "input", "highest_latency" }, { "frame_type", "i/p" }},
+ &histogram_highest_latency_input);
+ global_metrics.add("latency_seconds",
+ {{ "measuring_point", measuring_point }, { "input", "lowest_latency" }, { "frame_type", "b" }},
+ &histogram_lowest_latency_input_bframe);
+ global_metrics.add("latency_seconds",
+ {{ "measuring_point", measuring_point }, { "input", "highest_latency" }, { "frame_type", "b" }},
+ &histogram_highest_latency_input_bframe);
+}
+
+void print_latency(const string &header, const ReceivedTimestamps &received_ts, bool is_b_frame, int *frameno, LatencyHistogram *histogram)