Skip to main content

o_sfu_core/engine/media_transport/
config.rs

1//! Construction inputs for the media transport boundary.
2//!
3//! These types are cold-path configuration and dependency carriers. They are
4//! consumed when the runtime builds the transport service and must not be
5//! consulted by packet-loop code after startup. The split keeps startup policy
6//! separate from long-lived service handles:
7//! transport config describes operator policy, while transport deps describe
8//! process services shared with metrics and recording.
9
10use std::{net::IpAddr, sync::Arc, time::Duration};
11
12use crate::{
13    CodecPreferences, MediaCodecFlags, RtcPortRange, RtcUdpIoBackend, SessionBitrateLimits,
14    VideoBitrateLimits,
15    engine::{metrics::RuntimeMetrics, packet_sink_registry::RoomPacketSinkRegistry},
16};
17
18/// operator-facing RTC transport policy used to build each RTC worker
19///
20/// values are immutable after construction with each worker receiving only its
21/// UDP sub-range while sharing bitrate, codec and announced IP policy
22#[derive(Copy, Clone, Debug)]
23pub struct MediaTransportConfig {
24    /// number of process-local RTC workers owned by this transport
25    pub worker_count: usize,
26    /// client-routable address advertised in ICE candidates
27    ///
28    /// This is deployment policy, not a local bind address. A wrong value can
29    /// make otherwise valid sessions unreachable from browsers.
30    pub announced_ip: IpAddr,
31    /// Per-user ingress and egress bitrate ceilings enforced by the transport.
32    pub bitrate_limits: SessionBitrateLimits,
33    /// Default video bitrate policy used while building negotiated offers.
34    pub video_bitrate_limits: VideoBitrateLimits,
35    /// UDP port range available to this transport config.
36    ///
37    /// The top-level config covers the whole process. Worker configs carry only
38    /// the sub-range assigned to one media worker.
39    pub rtc_port_range: RtcPortRange,
40    /// UDP I/O implementation used by RTC packet-loop workers.
41    pub rtc_udp_io_backend: RtcUdpIoBackend,
42    /// Enabled codec set for offer generation and capability projection.
43    pub codec_flags: MediaCodecFlags,
44    /// Codec preference order preserved while constructing router capabilities.
45    pub codec_preferences: CodecPreferences,
46    /// str0m stats interval used for sampled transport-quality events.
47    pub media_quality_interval: Option<Duration>,
48}
49
50/// Long-lived services injected into media transport construction.
51///
52/// # Resource split
53///
54/// The transport owns no global telemetry registry or recording service by
55/// itself. It receives handles to the process stores it must update while
56/// executing media work.
57#[derive(Debug, Clone)]
58pub struct MediaTransportDeps {
59    /// Room packet-sink registry used by the packet path to fan out recording
60    /// and non-local destinations.
61    pub packet_sink_registry: Arc<RoomPacketSinkRegistry>,
62    /// Process-local metrics catalog updated by transport lifecycle and media
63    /// counters.
64    pub metrics: Arc<RuntimeMetrics>,
65}