Skip to main content

Module playback_session

Module playback_session 

Source
Expand description

Segment-spanning HLS playback sessions: interactive review of recorded footage over a time range, with native seek. A session concatenates the segments overlapping the requested window, trims to the exact offsets, and remuxes (-c copy, no re-encode) into a self-contained HLS VOD playlist under playback_dir/{session_id}/. HLS players seek freely within a VOD playlist.

The source segments are read-locked (repo::set_segments_locked) for the session lifetime so the retention sweeper cannot prune footage that is being reviewed; the lock is released when the session is deleted or expires. Sessions are tracked entirely on the filesystem (a session.json per dir) so the background cleanup sweeper needs no shared in-memory state — and a crash leaves no dangling locks (startup crate::db::clear_segment_read_locks clears every transient read-lock).

Structs§

PlaybackSession
A live playback session over a recorded time range. Returned to clients (Serialize); the durable metadata sidecar carries the extra bookkeeping fields the cleanup sweeper needs.

Functions§

create_session
Create a playback session for camera_id over [from, to): read-lock the overlapping segments and generate a trimmed HLS VOD playlist from them. Rejects (400) a range longer than HELDAR_MAX_PLAYBACK_SECONDS, an empty/reversed range, or a range with no recorded footage (404).
delete_session
Delete a playback session: release its segment read-locks and remove its HLS dir. Idempotent in the locks (best-effort); 404 if the session does not exist.
run
Background sweeper: remove session dirs older than the TTL and release their read-locks. Spawned (supervised) from main.