session — functions
Several cameras on one clock, written and replayed.
A session is one file holding several cameras' frames on a single clock, so that "what did the plant look like at 14:03" has one answer instead of one answer per camera. The flat C ABI has carried the whole surface for several releases; this package had none of it -- 45 entry points, reachable from C# and from nothing else -- so a Python caller could record one camera and could not record a plant.
Two halves, mirroring the ABI and the .NET binding:
Writing is RecordingSession. Frames in, not cameras in:
you declare the sources, open the file, and hand over the frames you
already have from wherever you got them. The SDK does not reach into
your cameras.
Replaying is SessionPlayer. One seek moves every
source, which is the whole point of a session, and frames arrive in
session order across sources rather than per camera.
Three phases, and the order is not advice
create -> add_source -> open -> write_frame ->
stop. A source cannot join after the file is open: every track
of a Matroska file is declared in its header, so a camera that arrives
later cannot go into this file. RecordingSession.add_source
raises after RecordingSession.open rather than silently
dropping the camera.
Call RecordingSession.open yourself rather than letting the
first frame do it. Until the file is open an unwritable path is
indistinguishable from a good one, and by the first frame the caller
who could have been told has gone.
Seconds, not microseconds
The ABI spells session time in microseconds, one field in whole
seconds and one in milliseconds -- three units on one surface. None of
them appears here: every duration on this surface is seconds, as a
float, matching connect_timeout_s and
optris_sdk.recording.RecordingOptions elsewhere in the
package. The conversions happen at the boundary, once, through
optris_sdk._durations, so the rounding is the rounding every
other binding uses and is held to the shared expectation in
tests/data/binding_agreement.
That matters more here than it reads. The .NET binding converted
max_segment_duration with a truncating cast, and zero is the
sentinel this field documents as "no segmentation" -- so a 500 ms
segment length silently switched segmenting off. This module uses
optris_sdk._durations.to_seconds, which rounds and floors at
one, so a sub-second request becomes one second rather than "never".
Two clocks, and they are not interchangeable
RecordingSession.elapsed_s and every *_s position are the
session clock: a stopwatch from the moment the file opened,
monotonic, zero before that. RecordingSession.started_at and
SessionPlayer.started_at are the host clock: a
datetime.datetime, read once when the session opened, and
not monotonic -- NTP can step it. Measure with the first and say
when with the second. They are different types here so they cannot
be confused.
A held last frame reads as a live scene
The reason SessionPresentationChange exists. When playback
crosses a hole where a camera was disconnected, a viewer that keeps
showing that camera's last frame is showing a still picture of a scene
nobody is watching, with nothing on it to say so. Register
SessionPlayer.on_presentation and show a disconnected panel
instead; or ask SessionPlayer.presentation_at while scrubbing,
which reads the same recorded spans and so cannot disagree with it.
session_source_kind_name(kind)
What a source carries, spelled out rather than as an ordinal.
session_source_state_name(state)
Where a source stands, spelled out.
session_presentation_name(presentation)
What to show, spelled out.