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, RtcTcpConfig, RtcUdpIoBackend,
14 SessionBitrateLimits, 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 pub rtc_tcp_config: Option<RtcTcpConfig>,
41 /// UDP I/O implementation used by RTC packet-loop workers.
42 pub rtc_udp_io_backend: RtcUdpIoBackend,
43 /// Enabled codec set for offer generation and capability projection.
44 pub codec_flags: MediaCodecFlags,
45 /// Codec preference order preserved while constructing router capabilities.
46 pub codec_preferences: CodecPreferences,
47 /// str0m stats interval for transport-quality events, at most 24 hours.
48 ///
49 /// `None` or zero disables sampling. Construction rejects larger intervals.
50 pub media_quality_interval: Option<Duration>,
51}
52
53impl MediaTransportConfig {
54 /// Largest sampling interval accepted before constructing str0m timers.
55 pub const MAX_MEDIA_QUALITY_INTERVAL: Duration = Duration::from_hours(24);
56}
57
58/// Long-lived services injected into media transport construction.
59///
60/// # Resource split
61///
62/// The transport owns no global telemetry registry or recording service by
63/// itself. It receives handles to the process stores it must update while
64/// executing media work.
65#[derive(Debug, Clone)]
66pub struct MediaTransportDeps {
67 /// Room packet-sink registry used by the packet path to fan out recording
68 /// and non-local destinations.
69 pub packet_sink_registry: Arc<RoomPacketSinkRegistry>,
70 /// Process-local metrics catalog updated by transport lifecycle and media
71 /// counters.
72 pub metrics: Arc<RuntimeMetrics>,
73}