rtpgccbwe: Don't process empty lists

The structure parsing could result in an empty vector. Don't do any processing
since the loss code assumes it's non-empty for average estimates which would
result in weird/invalid results.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1181>
This commit is contained in:
Edward Hervey 2023-04-15 08:17:09 +02:00 committed by Edward Hervey
parent dbdb9bc164
commit 721d17e181

View file

@ -1184,19 +1184,22 @@ impl ObjectSubclass for BandwidthEstimator {
})
.collect::<Vec<Packet>>();
let bitrate_changed = {
let mut state = this.state.lock().unwrap();
// The list of packets could be empty once parsed
if !packets.is_empty() {
let bitrate_changed = {
let mut state = this.state.lock().unwrap();
state.detector.update(&mut packets);
if !state.delay_control(&bwe) {
state.loss_control(&bwe)
} else {
true
state.detector.update(&mut packets);
if !state.delay_control(&bwe) {
state.loss_control(&bwe)
} else {
true
}
};
if bitrate_changed {
bwe.notify("estimated-bitrate")
}
};
if bitrate_changed {
bwe.notify("estimated-bitrate")
}
}
}