o_sfu_core/options/
routing.rs1use std::num::{NonZeroU64, NonZeroUsize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct RoomWorkerPolicy {
14 max_local_routers: usize,
15 packet_loop_delay_threshold_ms: u64,
16}
17
18impl RoomWorkerPolicy {
19 pub const DEFAULT_PACKET_LOOP_DELAY_THRESHOLD_MS: u64 = 20;
20
21 #[must_use]
22 pub const fn strict_single_router() -> Self {
23 Self {
24 max_local_routers: 1,
25 packet_loop_delay_threshold_ms: Self::DEFAULT_PACKET_LOOP_DELAY_THRESHOLD_MS,
26 }
27 }
28
29 #[must_use]
30 pub const fn new(
31 max_local_routers: NonZeroUsize,
32 packet_loop_delay_threshold_ms: NonZeroU64,
33 ) -> Self {
34 Self {
35 max_local_routers: max_local_routers.get(),
36 packet_loop_delay_threshold_ms: packet_loop_delay_threshold_ms.get(),
37 }
38 }
39
40 #[must_use]
41 pub const fn max_local_routers(self) -> usize {
42 self.max_local_routers
43 }
44
45 #[must_use]
46 pub const fn packet_loop_delay_threshold_ms(self) -> u64 {
47 self.packet_loop_delay_threshold_ms
48 }
49}
50
51impl Default for RoomWorkerPolicy {
52 fn default() -> Self {
53 Self::strict_single_router()
54 }
55}