Skip to main content

RecorderManager

Struct RecorderManager 

Source
pub struct RecorderManager { /* private fields */ }
Expand description

Owns and supervises the per-camera recorder tasks.

Implementations§

Source§

impl RecorderManager

Source

pub fn new(pool: SqlitePool, cfg: Arc<Config>) -> Arc<Self>

Source

pub async fn start_all(self: &Arc<Self>) -> Result<()>

Start recorders for all cameras that should record.

Source

pub async fn reconcile(self: &Arc<Self>, camera_id: &str)

Reconcile a single camera’s recorder against its current DB state. Starts a recorder when the camera should record AND its schedule says it should be recording now; otherwise stops it and marks it idle. Always restarts a running recorder (config may have changed) — callers that must not churn an actively-recording camera should use Self::reconcile_schedules.

Source

pub async fn eval_schedule(&self, camera_id: &str) -> bool

Whether camera_id should be recording at this instant per its record_mode + schedule, IGNORING event triggers (those are handled by the event supervisor / Self::trigger):

  • continuous is always on.
  • scheduled / scheduled_event are on only inside an enabled time-of-day window for today’s weekday, evaluated against the SERVER’s LOCAL timezone (chrono::Local), with overnight wrap.
  • event (and any unknown mode) has no time-based recording, so it is off here; it records only while a trigger window is active.
Source

pub async fn reconcile_schedules(self: &Arc<Self>)

Reconcile only the pure scheduled cameras whose recording state must change because their window just opened or closed. Called periodically by the schedule watcher. Cameras already in the correct state are left untouched, so an actively-recording camera is never restarted mid-window. scheduled_event is deliberately excluded: those tasks are always ARMED and the event supervisor opens/closes their window itself (so the watcher must not churn them).

Source

pub async fn stop(self: &Arc<Self>, camera_id: &str)

Stop a camera’s recorder task, killing its FFmpeg process. Returns only once the task is actually gone (aborting it if it does not stop promptly).

Source

pub async fn shutdown(self: &Arc<Self>)

Stop all recorder tasks (graceful shutdown).

Source

pub async fn active_ids(&self) -> Vec<String>

Camera ids currently being supervised.

Source

pub async fn trigger( &self, camera_id: &str, reason: &str, ) -> Option<DateTime<Utc>>

Fire an event recording trigger for a camera: extend its trigger window to now + post_roll_seconds (repeated triggers keep the later end). No-op (returns None) for a camera that is not event / scheduled_event, is not recording-enabled, or has no armed task (e.g. the recorder is globally disabled). Returns the resulting window end. Cheap and idempotent — safe to call on every zone/breach event.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more