Skip to main content

o_sfu_core/engine/media_transport/rtc/
mod.rs

1//! Private WebRTC backend below [`MediaTransport`](super::MediaTransport).
2//!
3//! Each [`RtcWorker`] runs one packet loop for its assigned `str0m` sessions,
4//! one UDP socket shared by those sessions and command plus relay mailboxes.
5//! [`MediaTransport`](super::MediaTransport) routes sessions to the workers
6//! named by their transport keys and coordinates relay routes between workers.
7//!
8//! Main boundaries:
9//!
10//! - [`worker`], [`commands`] and [`state`] cover worker startup, mailbox control
11//!   and packet-loop state.
12//! - [`bootstrap`] creates worker sockets and session-local `str0m` state.
13//! - [`codec`] centralizes RTP profiles, negotiated capabilities, negotiated RID
14//!   handling and codec-specific packet inspection plus rewriting.
15//! - [`packet_loop`] owns UDP routing and `str0m` polling. [`demux`] provides
16//!   recovery indexes and [`routing_miss`] bounds repeated fallback work while
17//!   `Rtc::accepts()` remains the session authority.
18//! - [`route_table`], [`source_route`], [`route_control`] and
19//!   [`keyframe_tracker`] keep forwarding routes, packet gates, activity ranking
20//!   and keyframe retry state.
21//! - [`forwarded_packet`], [`forwarding_planner`],
22//!   [`forwarding_destination`], [`local_forwarding`] and [`local_send_rewrite`]
23//!   share payloads across sinks, relays and local RTC destinations. Local RTC
24//!   egress projects receiver RTP identity.
25//! - [`media_registry`], [`relay_registry`] and [`bitrate`] keep media handles,
26//!   relay targets and bitrate observations.
27
28use std::{sync::Arc, time::Duration};
29
30use crate::{SessionBitrateLimits, VideoBitrateLimits};
31
32#[cfg(test)]
33#[allow(non_snake_case, reason = "test modules map to local TESTS directories")]
34mod TESTS;
35#[cfg(feature = "internal-benchmarks")]
36#[path = "TESTS/benchmark_support/mod.rs"]
37pub mod benchmark_support;
38mod bitrate;
39mod bootstrap;
40mod codec;
41mod commands;
42mod demux;
43mod forwarded_packet;
44mod forwarding_destination;
45mod forwarding_planner;
46#[cfg(any(test, fuzzing))]
47#[path = "TESTS/fuzz_support/mod.rs"]
48pub(crate) mod fuzz_support;
49mod keyframe_tracker;
50mod local_forwarding;
51mod local_send_rewrite;
52mod media_registry;
53mod packet_loop;
54mod relay_registry;
55mod route_control;
56mod route_table;
57mod routing_miss;
58mod slots;
59mod source_route;
60mod state;
61#[cfg(any(test, feature = "testing-transport", feature = "internal-benchmarks"))]
62#[path = "TESTS/test_support/mod.rs"]
63pub mod test_support;
64mod worker;
65
66pub(super) use codec::RtpProfile;
67#[cfg(any(test, fuzzing))]
68pub use codec::client_rtp_capabilities_from_answer;
69pub(super) use commands::{ParsedSessionAnswer, RtcSessionOffer};
70pub use commands::{
71    RtcWorkerCommand, RtcWorkerResponse, WorkerMediaControlBatch, WorkerMediaControlBatchOutcome,
72};
73#[cfg(any(test, feature = "testing-transport"))]
74pub use forwarded_packet::ForwardedPacket;
75pub(super) use route_control::PacketLayerGate;
76pub use worker::RtcWorker;
77
78#[derive(Clone, Debug)]
79struct RtcWorkerConfig {
80    bitrate_limits: SessionBitrateLimits,
81    video_bitrate_limits: VideoBitrateLimits,
82    profile: Arc<RtpProfile>,
83    media_quality_interval: Option<Duration>,
84    media_id_base: u64,
85}