OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Rust API referencev12.0

RecordingStats

pub struct RecordingStats

What the current, or last, recording did with its frames.

Reset when a recording starts and kept after it stops, so the totals are still readable once the file is closed. Without this, a recording that has silently stopped growing looks exactly like a healthy one, because crate::Camera::start_recording cannot report a failure that happens after it returns.

The accounting rule. Every frame the recording was offered is either in exactly one of the three loss counters, written, or still in the queue:

offered == frames_written + frames_lost() + queue_depth

A recording ended at its limit by crate::SegmentLimitAction::StopRecording (12.0.28) ends with the frame that reached the limit: that frame, and any already queued behind it, arrived after the file was finished and, like a frame that arrives after a stop, are in none of the counters.

RecordingStats — fields

frames_written: u64

Frames the recording has taken into the file.

A frame counts here once the container has accepted it, which is a moment before its bytes are necessarily on the disk: the container holds packets back so that it can interleave the file's streams. So this answers "did the recording get my frame" and is not a statement that a reader opening the file at this instant would find that frame in it. crate::Camera::stop_recording is what makes the file complete, and it is a barrier.

frames_dimension_mismatch: u64

Frames refused because they were not the size the file was opened at. A mode switch mid-recording produces these, and every one is a frame missing from the file while crate::Camera::is_recording still reports true.

frames_write_error: u64

Frames lost to a write or encode failure: a full disk, a removed drive, an encoder error. Includes whatever was still queued when the failure ended the recording.

frames_dropped_backlog: u64

Frames the recording was offered and did not store, because the writer could not keep up with the camera. This is the counter a slow target shows up in. The newest frame is dropped rather than the oldest, which keeps the file contiguous, so a gap in a recording is always a gap in time.

bytes_written: u64

The size of this recording's files so far: every part of a split recording, and each finished part's trailer, included.

The file on disk, not something ahead of it: every write ends in a flush, so read between two writes this equals the files' size exactly. What it lags is RecordingStats::frames_written, by up to one Matroska Cluster. Pair it with RecordingStats::bytes_written_at_us for a rate.

last_error: String

The most recent write failure, or empty. Kept rather than only counted, because "3 frames lost" and "No space left on device" answer different questions.

queue_depth: u32

How many frames are waiting to be written right now.

With a pre-roll, compare the live figures instead: subtract RecordingStats::queue_preroll and compare the remainder against RecordingStats::queue_live_capacity.

queue_peak: u32

The deepest the queue has been during this recording. What RecordingStats::queue_depth cannot tell a caller that polls: a stall of a second at 32 Hz fills and empties the queue between two polls a second apart, and this is the only trace it leaves. Read it with RecordingStats::queue_preroll_peak.

queue_capacity: u32

How deep the queue may get before frames are dropped. Derived from the sensor and the frame rate. Includes the pre-roll a recording was handed at its start, which is why it is not the number to judge a slow drive by.

longest_write_ms: u32

The longest a single frame took to encode and put on disk. On a healthy disk the encode is essentially all of it: 5.4 ms for a 640x480 frame of 78 KB, measured; a figure in the hundreds of milliseconds is the drive. Nothing waits on this.

bytes_written_at_us: u64

When RecordingStats::bytes_written last changed, in microseconds on the SDK's monotonic clock. This is what makes a write rate exact: both fields move only when a Cluster closes, so the ratio of their differences is the rate between two closes whatever the polling rate. Monotonic and not a date.

queue_preroll: u32

How many of the queued frames are the pre-roll this recording was handed at its start. Zero without a pre-roll, and falls to zero as the handover is written out. 30 s of pre-roll on a 640x480 camera at 32 Hz starts at a depth of 960 against a capacity of 1024, 94 % full, on a healthy drive.

queue_live_capacity: u32

The room for live frames: RecordingStats::queue_capacity less the pre-roll handed over. Constant for the life of a recording and the same quantity whatever the pre-roll was, so "half full" means one thing rather than one thing per pre-roll length.

queue_preroll_peak: u32

The most of the queue that was ever the pre-roll handover. A RecordingStats::queue_peak equal to this is fully accounted for by the handover; one well above it had live frames piling up behind one. Not the high-water mark of the live depth.

RecordingStats — methods

pub fn frames_lost(&self) -> u64

Every frame that did not reach the file, however it was lost.

The number worth asserting on after a recording: the three counters behind it have different causes and the same consequence, and a caller that checks only one of them will eventually be surprised by another. A frame still in the queue is not lost and is not here.