]> git.sesse.net Git - bmusb/blobdiff - fake_capture.cpp
Add timestamps on each received frame.
[bmusb] / fake_capture.cpp
index 5f53e95079db2553f39d6472afaf59c3e81980b0..fbcfeddbf14bffc9b020a41772db44eb0e629561 100644 (file)
@@ -13,6 +13,7 @@
 #if __SSE2__
 #include <immintrin.h>
 #endif
+#include <chrono>
 #include <cstddef>
 
 #include "bmusb/bmusb.h"
@@ -26,6 +27,7 @@ constexpr uint8_t cbs[NUM_COLORS] = { 90, 54, 240, 128 };
 constexpr uint8_t crs[NUM_COLORS] = { 240, 34, 110, 128 };
 
 using namespace std;
+using namespace std::chrono;
 
 namespace bmusb {
 namespace {
@@ -255,6 +257,7 @@ void FakeCapture::producer_thread_func()
                                memset4(video_frame.data, ycbcr, width * height / 2);
                        }
                        video_frame.len = width * height * 2;
+                       video_frame.received_timestamp = steady_clock::now();
                }
 
                AudioFormat audio_format;
@@ -266,6 +269,7 @@ void FakeCapture::producer_thread_func()
                        const unsigned num_stereo_samples = audio_sample_frequency / fps;
                        assert(audio_frame.size >= audio_format.num_channels * sizeof(int32_t) * num_stereo_samples);
                        audio_frame.len = audio_format.num_channels * sizeof(int32_t) * num_stereo_samples;
+                       audio_frame.received_timestamp = steady_clock::now();
 
                        if (audio_sin == 0.0f) {
                                // Silence.