Skip to main content

rtflow_mount/
config.rs

1use super::*;
2
3// ---------------------------------------------------------------------------
4// MountConfig
5// ---------------------------------------------------------------------------
6
7#[derive(Clone)]
8pub enum MountConfig {
9    Local {
10        description: MediaDescription,
11    },
12    Publisher {
13        description: MediaDescription,
14        allow_replace_after_disconnect: bool,
15    },
16    Proxy {
17        upstream: Box<UpstreamConfig>,
18    },
19    Vod {
20        source: Arc<dyn rtflow_media::vod::VodSource>,
21    },
22}
23
24// ---------------------------------------------------------------------------
25// PushResult / StreamStats / MountSnapshot
26// ---------------------------------------------------------------------------
27
28#[derive(Clone, Copy, Debug, Eq, PartialEq)]
29pub enum PushResult {
30    Accepted,
31    /// No active subscriber/broadcast receiver; the frame was cached only.
32    DroppedNoSubscribers,
33    /// The mount rejected the frame (unregistered/session closed) or a
34    /// consumer could not keep up.
35    Dropped,
36}
37
38// ---------------------------------------------------------------------------
39// description_for helper
40// ---------------------------------------------------------------------------
41
42#[doc(hidden)]
43pub fn description_for(config: &MountConfig) -> Result<MediaDescription> {
44    match config {
45        MountConfig::Local { description } | MountConfig::Publisher { description, .. } => {
46            Ok(description.clone())
47        }
48        MountConfig::Proxy { upstream } => upstream
49            .cached_description
50            .as_deref()
51            .cloned()
52            .ok_or_else(|| {
53                Error::Rtsp("proxy mount requires cached SDP description before serving".into())
54            }),
55        MountConfig::Vod { source } => Ok(source.description().clone()),
56    }
57}