optris::sdk::rec::PreRollState
What the pre-roll buffer is actually doing, as opposed to what was asked for.
Both numbers can differ from the request: a duration below the frame period is raised to one frame, and a depth past the memory budget is cut to fit. Without a readback an application has to hold the setting itself and can only hope the SDK agreed.
Public attributes
enabled
bool enabled = false
Whether frames are being buffered at all.
duration
std::chrono::milliseconds duration {0}
The duration in force, after any raise to the frame period and any cut by the memory budget. Zero when disabled.
This is the span the buffer holds, and it used not to be: This is the span the buffer holds, and it used not to be The ring's depth is a frame count derived from the sensor's rate, and frames are not always delivered at that rate: with ProcessingConfig::subsampled_framerate set, a 30 s request on a 382x288 camera at 27 Hz subsampled to 1 Hz kept 810 frames -- 13.5 minutes of history -- while this field still read 30 s. The buffer now evicts by timestamp as well, so the span it holds is the span named here whatever rate frames arrive at.
frames
uint32_t frames = 0
How many frames the ring may hold. This is the honest number: a sixty-second request on a large sensor comes back smaller.
A memory bound, not the history's length. duration is the length; this is the most the ring will ever spend on it, and a source delivering more slowly than the sensor rate reaches duration long before it reaches this.
buffered
uint32_t buffered = 0
How many frames are in it right now.
Warning: Comparing this against frames is not how to tell a full pre-roll. Use holds_duration. See that field for the measurement.
bytes
uint64_t bytes = 0
Roughly how much memory the full ring costs.
held
std::chrono::microseconds held {0}
The span the ring actually holds: its newest frame's timestamp less its oldest. Zero when fewer than two frames are in it.
What this is for: What this is for This is the number to show a user as "the pre-roll holds 4.8 of 5 s". buffered is a frame count against a capacity derived from the sensor's rate, and a camera does not always deliver at that rate -- subsampled through ProcessingConfig::subsampled_framerate, or restricted to 9 fps. A 32 Hz camera delivering 9 fps with 5 s armed holds its whole 5 s in about 45 of its 160 frames, so the counts say 28 % while the buffer is full.
It tops out just under duration rather than at it, because a span is measured between two stamps and so is one delivered frame period short. That is why holds_duration exists: the period the shortfall is measured in is the one number a caller outside the SDK has not got.
holds_duration
bool holds_duration = false
Whether the ring holds all the history it was asked for.
The test to wait on before starting a recording, and the reason it is the SDK's to answer: it is true once either bound has bitten -- a frame evicted for being older than duration, or the frame count at frames -- so it covers a camera delivering below its sensor rate and one delivering above it, with no tolerance to choose.
False while the ring is empty, and false again immediately after a recording starts: the start hands the whole ring to the write queue, so the pre-roll begins refilling from nothing.