#include "bmusb/fake_capture.h"
#include <assert.h>
+#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#if __SSE2__
#include <immintrin.h>
#endif
+#include <chrono>
#include <cstddef>
#include "bmusb/bmusb.h"
constexpr uint8_t crs[NUM_COLORS] = { 240, 34, 110, 128 };
using namespace std;
+using namespace std::chrono;
namespace bmusb {
namespace {
} // namespace
FakeCapture::FakeCapture(unsigned width, unsigned height, unsigned fps, unsigned audio_sample_frequency, int card_index, bool has_audio)
- : width(width), height(height), fps(fps), audio_sample_frequency(audio_sample_frequency)
+ : width(width), height(height), fps(fps), audio_sample_frequency(audio_sample_frequency), card_index(card_index)
{
char buf[256];
snprintf(buf, sizeof(buf), "Fake card %d", card_index + 1);
void FakeCapture::producer_thread_func()
{
+ char thread_name[16];
+ snprintf(thread_name, sizeof(thread_name), "FakeCapture_%d", card_index);
+ pthread_setname_np(pthread_self(), thread_name);
+
uint16_t timecode = 0;
if (has_dequeue_callbacks) {
next_frame = now;
}
}
+ steady_clock::time_point timestamp = steady_clock::now();
// Figure out when the next frame is to be, then compute the current one.
add_time(1.0 / fps, &next_frame);
memset4(video_frame.data, ycbcr, width * height / 2);
}
video_frame.len = width * height * 2;
+ video_frame.received_timestamp = timestamp;
}
AudioFormat audio_format;
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 = timestamp;
if (audio_sin == 0.0f) {
// Silence.