webrtcsink: tune homegrown CC algorithm

Make control decisions based on packet loss closer in intent to
the algorithm described in gcc section 6., and raise the threshold
for decreasing the bitrate based on delay_factor
This commit is contained in:
Mathieu Duponchelle 2021-12-01 01:53:10 +01:00
parent b12d91775d
commit 7bd7c4e960

View file

@ -548,13 +548,14 @@ impl CongestionController {
twcc_stats twcc_stats
); );
if delay_factor > 0.01 { if delay_factor > 0.1 {
CongestionControlOp::Decrease(if delay_factor < 0.64 { CongestionControlOp::Decrease(if delay_factor < 0.64 {
gst_trace!( gst_trace!(
CAT, CAT,
obj: element, obj: element,
"consumer {}: low delay factor", "consumer {}: low delay factor {}",
self.peer_id self.peer_id,
delay_factor,
); );
0.96 0.96
} else { } else {
@ -566,16 +567,35 @@ impl CongestionController {
); );
delay_factor.sqrt().sqrt().clamp(0.8, 0.96) delay_factor.sqrt().sqrt().clamp(0.8, 0.96)
}) })
} else if delta_of_delta > 1000000 || loss_percentage > 2.0 { } else if delta_of_delta > 1000000 {
CongestionControlOp::Decrease(if loss_percentage > 0. && loss_percentage < 2.0 { CongestionControlOp::Decrease(if loss_percentage < 10. {
gst_trace!(CAT, obj: element, "consumer {}: low loss", self.peer_id); gst_trace!(
CAT,
obj: element,
"consumer {}: moderate loss high delta",
self.peer_id
);
0.97 0.97
} else { } else {
gst_log!(CAT, obj: element, "consumer: {}: high loss", self.peer_id); gst_log!(
CAT,
obj: element,
"consumer: {}: high loss high delta",
self.peer_id
);
((100. - loss_percentage) / 100.).clamp(0.7, 0.98) ((100. - loss_percentage) / 100.).clamp(0.7, 0.98)
}) })
} else if loss_percentage > 0.01 { } else if loss_percentage > 10. {
gst_trace!(CAT, obj: element, "consumer {}: tiny loss", self.peer_id); CongestionControlOp::Decrease(
((100. - (0.5 * loss_percentage)) / 100.).clamp(0.7, 0.98),
)
} else if loss_percentage > 2. {
gst_trace!(
CAT,
obj: element,
"consumer {}: moderate loss",
self.peer_id
);
CongestionControlOp::Hold CongestionControlOp::Hold
} else { } else {
gst_trace!( gst_trace!(