optris::sdk::rec::RetentionPolicy
The configuration and readback of an always-on recording. The recorder itself is ContinuousRecorder, in optris/sdk/rec/continuous.h -- these live here, beside StreamConfig and RecordingStats, because they are named on optris::sdk::Recorder's own signatures and the facade's types belong in the single-include header. How much history to keep, and how much of the volume to leave alone.
Why three bounds and not one: Why three bounds and not one Because they answer three different people's questions and any one of them alone is wrong.
- Time is what an operator thinks in. "I want to be able to look at yesterday" is a duration, and it is the only one of the three that can be promised to a user.
- Bytes is what an administrator provisions. Time alone cannot be held to: the same camera writes 3.1 GB/h on a calm scene and 7.4 GB/h on a hot noisy one, a factor of 2.4 on content the operator does not control, so a disk sized for eight hours of one holds three of the other.
- Free space is what keeps the rest of the machine alive. A history that is allowed to fill the volume takes the application's logs, its database and the operating system's ability to write a file down with it, and none of those failures look like a recording problem.
Whichever bites first wins, and ContinuousStats::last_prune_reason says which one did -- so "my history is shorter than I asked for" has an answer that does not require guessing.
Public attributes
max_duration
std::chrono::seconds max_duration {0}
Keep at most this much history, measured from the oldest frame still on disk to the newest. Zero means time does not bound it.
max_bytes
uint64_t max_bytes = 0
Keep at most this many bytes of segment files. Zero means size does not bound it.
Counted over the segments this directory holds, including ones adopted from an earlier run, and not including the segment currently open -- a segment is pruned when it is closed, and the open one is the only thing standing between the camera and nothing.
min_free_bytes
uint64_t min_free_bytes = 0
Never let the volume's free space fall below this. Zero means it is not watched, which is only reasonable on a disk nothing else writes to.
This is the bound that fires when something else fills the disk, and it is the one worth setting even when the other two are generous. What happens when it cannot be honoured is ContinuousConfig::on_disk_full.