rtpgccbwe: Log delay and loss target bitrates separately

When debugging rtpgccbwe it is helpful to know if it is
delay based or loss based band-width estimation that puts a
bound on the current target bitrate, so add logs for that.

To minimize the time we need to hold the state lock, perform
the logging after we have released the state lock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1561>
This commit is contained in:
Martin Nordholts 2024-05-02 11:07:57 +02:00 committed by GStreamer Marge Bot
parent b4576a0074
commit 2b7488a4c8

View file

@ -1187,15 +1187,37 @@ impl ObjectSubclass for BandwidthEstimator {
// The list of packets could be empty once parsed
if !packets.is_empty() {
let mut logged_bitrates = None;
let bitrate_changed = {
let mut state = this.state.lock().unwrap();
state.detector.update(&mut packets);
let bitrate_updated_by_delay = state.delay_control(&bwe);
let bitrate_updated_by_loss = state.loss_control(&bwe);
bitrate_updated_by_delay || bitrate_updated_by_loss
let bitrate_changed = bitrate_updated_by_delay || bitrate_updated_by_loss;
if bitrate_changed {
// So we don't have to hold the state mutex while logging.
logged_bitrates = Some((
state.target_bitrate_on_delay,
state.target_bitrate_on_loss,
));
}
bitrate_changed
};
if let Some(bitrates) = logged_bitrates {
gst::log!(
CAT,
obj: bwe,
"target bitrate on delay: {}ps - target bitrate on loss: {}ps",
human_kbits(bitrates.0),
human_kbits(bitrates.1),
);
}
if bitrate_changed {
bwe.notify("estimated-bitrate")
}