Skip to content

Commit 11642b5

Browse files
committed
handle stream pausing due to sender overload
1 parent d4ab95a commit 11642b5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pulsebeam/src/rtp/monitor.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tokio::time::Instant;
1111
use crate::rtp::PacketTiming;
1212

1313
/// Defines the wall-clock duration without packets after which a stream is considered inactive.
14-
const INACTIVE_TIMEOUT: Duration = Duration::from_secs(2);
14+
const INACTIVE_TIMEOUT: Duration = Duration::from_millis(500);
1515
const DELTA_DELTA_WINDOW_SIZE: usize = 128;
1616

1717
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -94,7 +94,7 @@ impl StreamMonitor {
9494
let was_inactive = self.shared_state.is_inactive();
9595
let is_inactive = self.determine_inactive_state(now);
9696
if is_inactive && !was_inactive {
97-
self.reset();
97+
self.reset(now);
9898
}
9999
self.shared_state
100100
.inactive
@@ -131,11 +131,18 @@ impl StreamMonitor {
131131
}
132132
}
133133

134-
fn reset(&mut self) {
134+
fn reset(&mut self, now: Instant) {
135+
tracing::info!(
136+
stream_id = %self.stream_id,
137+
"Stream inactive, resetting all metrics. Quality was: {:?}", self.current_quality);
138+
self.delta_delta = DeltaDeltaState::new(DELTA_DELTA_WINDOW_SIZE);
139+
self.bwe = BitrateEstimate::new(now);
135140
self.current_quality = StreamQuality::Good;
136141
self.shared_state
137142
.quality
138143
.store(StreamQuality::Good as u8, Ordering::Relaxed);
144+
145+
self.shared_state.bitrate_bps.store(0, Ordering::Relaxed);
139146
}
140147

141148
pub fn set_manual_pause(&mut self, paused: bool) {

0 commit comments

Comments
 (0)