1use shared::replay_detector::*;
2
3pub type ContextOption = Box<dyn Fn() -> Box<dyn ReplayDetector> + Send + Sync>;
10
11pub(crate) const MAX_SEQUENCE_NUMBER: u16 = 65535;
12pub(crate) const MAX_SRTCP_INDEX: usize = 0x7FFFFFFF;
13
14pub fn srtp_replay_protection(window_size: usize) -> ContextOption {
16 Box::new(move || -> Box<dyn ReplayDetector> {
17 Box::new(WrappedSlidingWindowDetector::new(
18 window_size,
19 MAX_SEQUENCE_NUMBER as u64,
20 ))
21 })
22}
23
24pub fn srtcp_replay_protection(window_size: usize) -> ContextOption {
26 Box::new(move || -> Box<dyn ReplayDetector> {
27 Box::new(WrappedSlidingWindowDetector::new(
28 window_size,
29 MAX_SRTCP_INDEX as u64,
30 ))
31 })
32}
33
34pub fn srtp_no_replay_protection() -> ContextOption {
36 Box::new(|| -> Box<dyn ReplayDetector> { Box::<NoOpReplayDetector>::default() })
37}
38
39pub fn srtcp_no_replay_protection() -> ContextOption {
41 Box::new(|| -> Box<dyn ReplayDetector> { Box::<NoOpReplayDetector>::default() })
42}