From 02c8e66ff1d3e5f72436222459b4aecc439fbe73 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 6 May 2020 15:36:19 +1000 Subject: [PATCH] webrtc: fix an off-by-one calculating low-threshold We were not signalling low-threshold when the previous amount was at exactly the low-threshold mark. Part-of: --- ext/webrtc/webrtcdatachannel.c | 8 +++++++- tests/check/elements/webrtcbin.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/webrtc/webrtcdatachannel.c b/ext/webrtc/webrtcdatachannel.c index 9e1e3ef..0eb9f85 100644 --- a/ext/webrtc/webrtcdatachannel.c +++ b/ext/webrtc/webrtcdatachannel.c @@ -527,7 +527,9 @@ _parse_control_packet (GstWebRTCDataChannel * channel, guint8 * data, g_set_error (error, GST_WEBRTC_BIN_ERROR, GST_WEBRTC_BIN_ERROR_DATA_CHANNEL_FAILURE, "Could not send ack packet"); + return ret; } + return ret; } else { g_set_error (error, GST_WEBRTC_BIN_ERROR, @@ -1042,7 +1044,11 @@ on_appsrc_data (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) CHANNEL_LOCK (channel); prev_amount = channel->buffered_amount; channel->buffered_amount -= size; - if (prev_amount > channel->buffered_amount_low_threshold && + GST_TRACE_OBJECT (channel, "checking low-threshold: prev %" + G_GUINT64_FORMAT " low-threshold %" G_GUINT64_FORMAT " buffered %" + G_GUINT64_FORMAT, prev_amount, channel->buffered_amount_low_threshold, + channel->buffered_amount); + if (prev_amount >= channel->buffered_amount_low_threshold && channel->buffered_amount < channel->buffered_amount_low_threshold) { _channel_enqueue_task (channel, (ChannelTask) _emit_low_threshold, NULL, NULL); diff --git a/tests/check/elements/webrtcbin.c b/tests/check/elements/webrtcbin.c index eeb733d..27da1d5 100644 --- a/tests/check/elements/webrtcbin.c +++ b/tests/check/elements/webrtcbin.c @@ -1846,7 +1846,7 @@ have_data_channel_check_low_threshold_emitted (struct test_webrtc *t, g_signal_connect (our, "on-error", G_CALLBACK (on_channel_error_not_reached), NULL); - g_signal_emit_by_name (our, "send-string", "DATA"); + g_signal_emit_by_name (our, "send-string", "A"); } GST_START_TEST (test_data_channel_low_threshold) -- 2.7.4