recorder_for_jetkvm/lib.rs
1pub mod auth;
2pub mod config;
3pub mod detector;
4pub mod h264;
5pub mod paths;
6pub mod recorder;
7pub mod screenshot;
8pub mod session;
9pub mod signaling;
10
11use anyhow::Result;
12use h264::NalUnit;
13use tokio::sync::{broadcast, watch};
14
15/// A source of H.264 NAL units.
16///
17/// Implementations produce NAL units from different transports (WebRTC, RTSP,
18/// file, etc.) and send them on a broadcast channel until the source is
19/// exhausted or a shutdown signal is received.
20///
21/// # Example
22///
23/// The JetKVM WebRTC session implements this trait by authenticating with the
24/// device, establishing a WebRTC peer connection, depacketizing RTP packets
25/// into NAL units, and forwarding them to `nal_tx`.
26pub trait VideoSource {
27 /// Start producing NAL units.
28 ///
29 /// Implementations should send [`NalUnit`]s on `nal_tx` until:
30 /// - The underlying transport closes (return `Ok(())`),
31 /// - A shutdown signal is received on `shutdown` (return `Ok(())`), or
32 /// - An unrecoverable error occurs (return `Err(...)`).
33 fn run(
34 &self,
35 nal_tx: broadcast::Sender<NalUnit>,
36 shutdown: watch::Receiver<bool>,
37 ) -> impl std::future::Future<Output = Result<()>> + Send;
38}