SessionPlayer
pub struct SessionPlayer
An opened session recording.
Stopped and freed when dropped.
Also opens an ordinary single-camera recording, as a session of
one source. That is deliberate: an application that has moved to
this API does not need two code paths, and every file the
single-camera recorder has ever written stays readable. Ask
SessionPlayer::is_session which kind you have.
Threading
Send but deliberately not Sync, like crate::Camera: the
C's blanket rule is that one handle must not be used concurrently
from more than one thread, and the player's own calls carry no
exception to it.
SessionPlayer — methods
pub fn open(path: &str) -> Result<Self>
Open a session recording.
The file is scanned once here, which is what fills in the
per-source frame counts, spans, gaps and outages, so
SessionPlayer::source_info and SessionPlayer::outages
answer before anything has been played.
Errors
Returns Status::Io if the file cannot be opened, and
Status::InvalidArgument if path contains an interior NUL
byte.
pub fn source_count(&self) -> Result<i32>
How many sources the file holds.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn source_info(&self, source: i32) -> Result<SessionSourceInfo>
What the file says about one source, and what the scan found.
Errors
Returns Status::NotFound for an index past
SessionPlayer::source_count.
pub fn sources(&self) -> Result<Vec<SessionSourceInfo>>
Every source, in index order.
Errors
As SessionPlayer::source_info.
pub fn is_session(&self) -> Result<bool>
Whether the file carries a session document.
false for a single-camera recording opened through this API,
which still plays; the names and identities are simply the
ones the ordinary file metadata carries, or empty.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn is_at_end(&self) -> Result<bool>
Whether a non-looping session has handed over its last frame.
Ask this rather than comparing the position with the duration, which never becomes equal on a correct file: the position is the last delivered frame's session time and the duration counts that frame's own length as well, so the two stand one frame period apart.
false again after SessionPlayer::play,
SessionPlayer::stop and SessionPlayer::seek_to_us, so a
transport that has run out can be restarted or dragged back. A
looping session never reports an end, because it does not have
one. Note that a play does not rewind: a session sitting at
the end reads end of file and says so again.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn duration_us(&self) -> Result<u64>
How long the session is, in microseconds: the end of whichever source ran longest.
The end of its last frame, not the position of it; that frame's own duration is included. A source that ended early does not shorten the session.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn position_us(&self) -> Result<u64>
Current position in session microseconds.
Not how to see that a session has played out, see
SessionPlayer::is_at_end.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn started_at_us(&self) -> Result<Option<u64>>
When the session started, as a date: microseconds since the
Unix epoch. None for a file that did not record one.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn outage_count(&self, source: i32) -> Result<usize>
How many outages the file recorded for one source.
Zero for a source that was never away, and for a file written before outages were recorded, so a zero is not proof the camera never dropped.
Errors
Returns Status::NotFound for an unknown source.
pub fn outage(&self, source: i32, index: usize) -> Result<SessionOutage>
One recorded outage, earliest first.
Available the moment the file is open, before anything is played, so an application can draw the holes onto its transport bar rather than discovering them by playing through.
Errors
Returns Status::OutOfRange for an index past
SessionPlayer::outage_count.
pub fn outages(&self, source: i32) -> Result<Vec<SessionOutage>>
Every recorded outage for one source, earliest first.
Errors
pub fn presentation_at(&self, source: i32, session_us: u64) -> Result<SessionPresentation>
What a player should be showing for one source at a session time, without playing anything.
The scrubbing answer: an application that jumps the transport
bar to 4 min 12 s asks this per source and knows what to draw
before a single frame has been decoded. Consistent with what
SessionPlayer::on_presentation reports while playing,
because both read the same recorded spans.
Errors
Returns Status::NotFound for an unknown source.
pub fn statistics(&self) -> Result<SessionPlaybackStats>
What this playback run has done.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn clear_frame_callback(&mut self) -> Result<()>
Stop delivering thermal frames.
Errors
pub fn clear_color_frame_callback(&mut self) -> Result<()>
Stop delivering visual pictures.
Errors
As SessionPlayer::on_color_frame.
pub fn clear_presentation_callback(&mut self) -> Result<()>
Stop delivering presentation changes.
Errors
As SessionPlayer::on_presentation.
pub fn play(&mut self) -> Result<()>
Start playback on a background thread.
Errors
Returns Status::InvalidHandle if the player has been
closed.
pub fn pause(&mut self) -> Result<()>
Stop advancing and hold the position.
Errors
pub fn stop(&mut self) -> Result<()>
Stop and rewind to the start of the session.
Errors
pub fn seek_to_us(&mut self, timestamp_us: u64) -> Result<()>
Move every source to a session timestamp, in microseconds.
One call, all sources: that is what makes a session a
session. Each source resumes at its first frame at or after
timestamp_us, so a source that was mid-gap at that moment
delivers nothing until its next real frame rather than
back-filling one.
Errors
pub fn set_speed(&mut self, speed: f32) -> Result<()>
Playback speed multiplier. 1.0 is real time.
Errors
Returns Status::InvalidArgument for a speed the SDK will
not take.
pub fn set_loop(&mut self, looping: bool) -> Result<()>
Restart from the beginning at the end of the session.