]> git.sesse.net Git - nageru/blobdiff - print_latency.cpp
Move find_received_timestamp() into print_latency.h, so that multiple consumers can...
[nageru] / print_latency.cpp
index 0b0a1ae483e9bb2ce3ce6df15413942f89870b82..ee9470cc2187a2f39c325ac29def78f7b5b0efac 100644 (file)
@@ -1,4 +1,5 @@
 #include "print_latency.h"
+
 #include "flags.h"
 
 #include <stdio.h>
@@ -8,6 +9,19 @@
 using namespace std;
 using namespace std::chrono;
 
+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 print_latency(const string &header, const ReceivedTimestamps &received_ts, bool is_b_frame, int *frameno)
 {
        if (received_ts.max_ts == steady_clock::time_point::min())