1use util::replay_detector::*;
2
3pub type ContextOption = Box<dyn (Fn() -> Box<dyn ReplayDetector + Send + 'static>) + Send + Sync>;
4
5pub(crate) const MAX_SEQUENCE_NUMBER: u16 = 65535;
6pub(crate) const MAX_SRTCP_INDEX: usize = 0x7FFFFFFF;
7
8pub fn srtp_replay_protection(window_size: usize) -> ContextOption {
10 Box::new(move || -> Box<dyn ReplayDetector + Send> {
11 Box::new(WrappedSlidingWindowDetector::new(
12 window_size,
13 MAX_SEQUENCE_NUMBER as u64,
14 ))
15 })
16}
17
18pub fn srtcp_replay_protection(window_size: usize) -> ContextOption {
20 Box::new(move || -> Box<dyn ReplayDetector + Send> {
21 Box::new(WrappedSlidingWindowDetector::new(
22 window_size,
23 MAX_SRTCP_INDEX as u64,
24 ))
25 })
26}
27
28pub fn srtp_no_replay_protection() -> ContextOption {
30 Box::new(|| -> Box<dyn ReplayDetector + Send> { Box::<NoOpReplayDetector>::default() })
31}
32
33pub fn srtcp_no_replay_protection() -> ContextOption {
35 Box::new(|| -> Box<dyn ReplayDetector + Send> { Box::<NoOpReplayDetector>::default() })
36}