Skip to main content

o_sfu_core/engine/director/
mod.rs

1//! Receiver media policy: decides which audio and which video encoding each
2//! receiver gets within its bandwidth and when to decide again.
3//!
4//! Director reads committed room facts, worker observations (active speakers,
5//! receiver bandwidth and source bitrate) and the time. It decides audio
6//! admission, the encoding each video route forwards, route pauses, receiver
7//! BWE targets, the room's featured user and the next decision deadline. It
8//! never changes membership or publications, never creates or removes routes
9//! and never handles packets.
10//!
11//! Director owns the values it decides into. Room records embed them and hand
12//! `&mut` to Director, which alone changes their fields:
13//! [`RouteAllocation`] per consumer, [`ReceiverAllocation`] per receiver and
14//! [`PendingUpgrade`] per committed consumer.
15//!
16//! A [`SourcePolicyTurn`] runs in workflow order:
17//!
18//! ```text
19//! capture  room facts and observations, under the read guard
20//! planner  pure: facts and time in, allocations and wakeups out
21//! turn     transport controls, after the guard is released
22//! commit   accepted allocations, under the write lock
23//! ```
24//!
25//! Turns serialize with publication activity so their transport effects cannot
26//! overtake each other. Gate and activity controls must be accepted before the
27//! matching allocation commits. Each turn replaces or cancels its earliest
28//! receiver-pressure or exact-target upgrade deadline.
29
30mod action;
31mod allocation;
32#[cfg(feature = "internal-benchmarks")]
33#[path = "TESTS/benchmark_support.rs"]
34pub mod benchmark_support;
35mod capture;
36mod commit;
37mod layout;
38mod planner;
39#[cfg(test)]
40#[path = "TESTS/test_support.rs"]
41pub(super) mod test_support;
42mod turn;
43
44pub(super) use self::{
45    action::ConsumerPacketSelectionUpdate,
46    allocation::{
47        PendingUpgrade, ReceiverAllocation, ReceiverVideoBudgetDiagnostics, RouteAllocation,
48    },
49    layout::{diagnostics_video_layout_role, initial_video_admission_rank},
50    turn::{SourcePolicyTurn, policy_worker_indices},
51};