Note that this breaks the ABI.
PREFIX := /usr/local
LIB := libbmusb.a
SODEV := libbmusb.so
-SONAME := libbmusb.so.1
-SOLIB := libbmusb.so.1.0.0
+SONAME := libbmusb.so.2
+SOLIB := libbmusb.so.2.0.0
all: $(LIB) $(SOLIB) main
#include <algorithm>
#include <atomic>
+#include <chrono>
#include <condition_variable>
#include <cstddef>
#include <cstdint>
#include <thread>
using namespace std;
+using namespace std::chrono;
using namespace std::placeholders;
#define USB_VENDOR_BLACKMAGIC 0x1edb
uint16_t timecode = (start[1] << 8) | start[0];
if (current_video_frame.len > 0) {
+ current_video_frame.received_timestamp = steady_clock::now();
+
// If format is 0x0800 (no signal), add a fake (empty) audio
// frame to get it out of the queue.
// TODO: Figure out if there are other formats that come with
uint16_t format = (start[3] << 8) | start[2];
uint16_t timecode = (start[1] << 8) | start[0];
if (current_audio_frame.len > 0) {
+ current_audio_frame.received_timestamp = steady_clock::now();
//dump_audio_block();
queue_frame(format, timecode, current_audio_frame, &pending_audio_frames);
}
#include <libusb.h>
#include <stdint.h>
#include <atomic>
+#include <chrono>
#include <condition_variable>
#include <deque>
#include <functional>
// 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();
#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 {
memset4(video_frame.data, ycbcr, width * height / 2);
}
video_frame.len = width * height * 2;
+ video_frame.received_timestamp = steady_clock::now();
}
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 = steady_clock::now();
if (audio_sin == 0.0f) {
// Silence.