o_sfu_core/engine/source_model/selection.rs
1use super::SourceEncodingId;
2
3/// Resolved packet-selection command for one consumer/source route.
4///
5/// The budget planner writes selectors into room state. A later projection step
6/// turns them into transport packet gates such as "open" or "forward this RID".
7/// # Example situations
8///
9/// [`Self::Open`] means the route has no source-level packet gate.
10/// [`Self::Encoding`] means "forward the negotiated RID for this encoding".
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
12pub enum SourceSelector {
13 /// Forward the source without a source-level packet gate.
14 ///
15 /// This is the default for sources that are not controlled by receiver-video
16 /// adaptation or when the planner has not selected a narrower gate.
17 #[default]
18 Open,
19 /// Forward only one advertised source encoding.
20 ///
21 /// Projection maps the encoding id to its negotiated RID. If the encoding
22 /// has no RID, projection fails rather than guessing at packet identity.
23 Encoding(SourceEncodingId),
24}
25
26impl SourceSelector {
27 #[must_use]
28 pub const fn selected_encoding(self) -> Option<SourceEncodingId> {
29 match self {
30 Self::Encoding(encoding_id) => Some(encoding_id),
31 Self::Open => None,
32 }
33 }
34}