pub struct DetectorConfig {
pub c1: f64,
pub c2: f64,
pub c3: f64,
pub tick_interval: Duration,
pub n1: u8,
pub n2: u8,
pub n3: u8,
}Expand description
Tunable constants for the dominant-speaker election.
Defaults match mediasoup’s production constants exactly.
§Example
use dominant_speaker::{ActiveSpeakerDetector, DetectorConfig};
use core::time::Duration;
// Use defaults (mediasoup-identical behaviour).
let default_detector: ActiveSpeakerDetector<u64> = ActiveSpeakerDetector::new();
// Raise C1/C2 for a low-bitrate / mobile deployment: fewer speaker switches.
let config = DetectorConfig {
c1: 5.0,
c2: 4.0,
tick_interval: Duration::from_millis(500),
..DetectorConfig::default()
};
let tuned_detector: ActiveSpeakerDetector<u64> = ActiveSpeakerDetector::with_config(config);§Serde
Enable the serde feature to serialize/deserialize this struct.
tick_interval is serialized as milliseconds (u64).
ⓘ
// Requires `dominant_speaker` with `serde` feature and `serde_json` dev-dep.
use dominant_speaker::DetectorConfig;
let config = DetectorConfig::default();
let json = serde_json::to_string(&config).unwrap();
let back: DetectorConfig = serde_json::from_str(&json).unwrap();
assert!((back.c1 - config.c1).abs() < f64::EPSILON);Fields§
§c1: f64Immediate-window log-ratio threshold (mediasoup: C1).
c2: f64Medium-window log-ratio threshold (mediasoup: C2).
c3: f64Long-window log-ratio threshold; zero = long window disabled (mediasoup: C3).
tick_interval: DurationEvaluation cadence. Recommend 300 ms.
n1: u8Immediate-window subband count (mediasoup: N1).
The subband width is derived automatically via ceil(128 / n1).
The default of 13 gives a subband width of 10, matching mediasoup.
n2: u8Medium-window subband count (mediasoup: N2).
n3: u8Long-window subband count (mediasoup: N3).
Trait Implementations§
Source§impl Clone for DetectorConfig
impl Clone for DetectorConfig
Source§fn clone(&self) -> DetectorConfig
fn clone(&self) -> DetectorConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DetectorConfig
impl Debug for DetectorConfig
Auto Trait Implementations§
impl Freeze for DetectorConfig
impl RefUnwindSafe for DetectorConfig
impl Send for DetectorConfig
impl Sync for DetectorConfig
impl Unpin for DetectorConfig
impl UnsafeUnpin for DetectorConfig
impl UnwindSafe for DetectorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more