rtflow-mount 0.7.0

Stream mount registry, publisher handles and broadcast bus for rtflow
Documentation
use super::*;

// ---------------------------------------------------------------------------
// MountConfig
// ---------------------------------------------------------------------------

#[derive(Clone)]
pub enum MountConfig {
    Local {
        description: MediaDescription,
    },
    Publisher {
        description: MediaDescription,
        allow_replace_after_disconnect: bool,
    },
    Proxy {
        upstream: Box<UpstreamConfig>,
    },
    Vod {
        source: Arc<dyn rtflow_media::vod::VodSource>,
    },
}

// ---------------------------------------------------------------------------
// PushResult / StreamStats / MountSnapshot
// ---------------------------------------------------------------------------

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PushResult {
    Accepted,
    /// No active subscriber/broadcast receiver; the frame was cached only.
    DroppedNoSubscribers,
    /// The mount rejected the frame (unregistered/session closed) or a
    /// consumer could not keep up.
    Dropped,
}

// ---------------------------------------------------------------------------
// description_for helper
// ---------------------------------------------------------------------------

#[doc(hidden)]
pub fn description_for(config: &MountConfig) -> Result<MediaDescription> {
    match config {
        MountConfig::Local { description } | MountConfig::Publisher { description, .. } => {
            Ok(description.clone())
        }
        MountConfig::Proxy { upstream } => upstream
            .cached_description
            .as_deref()
            .cloned()
            .ok_or_else(|| {
                Error::Rtsp("proxy mount requires cached SDP description before serving".into())
            }),
        MountConfig::Vod { source } => Ok(source.description().clone()),
    }
}