]> git.sesse.net Git - bmusb/blobdiff - bmusb/bmusb.h
Add timestamps on each received frame.
[bmusb] / bmusb / bmusb.h
index f4af6aa14b2a1399168d3f75673b1d2215846770..6aabd51fcc39f68c1b0780e24d5451319083b317 100644 (file)
@@ -4,6 +4,7 @@
 #include <libusb.h>
 #include <stdint.h>
 #include <atomic>
+#include <chrono>
 #include <condition_variable>
 #include <deque>
 #include <functional>
@@ -39,6 +40,14 @@ class FrameAllocator {
                // If so, <len> and <size> are still about the number of total bytes
                // so if size == 1024, there's 512 bytes in data and 512 in data2.
                bool interleaved = false;
+
+               // At what point this frame was received. Note that this marks the
+               // _end_ of the frame being received, not the beginning.
+               // Thus, if you want to measure latency, you'll also need to include
+               // the time the frame actually took to transfer (usually 1/fps,
+               // ie., the frames are typically transferred in real time).
+               std::chrono::steady_clock::time_point received_timestamp =
+                       std::chrono::steady_clock::time_point::min();
        };
 
        virtual ~FrameAllocator();