From 0044e7a1ba6b02094a8aa5ec7c91d27d1688f6ba Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 14 Feb 2020 11:49:23 +0100 Subject: [PATCH] rtmp2: Count in_bytes_acked instead of in_bytes_unacked This is nicer for statistics. --- gst/rtmp2/rtmp/rtmpconnection.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gst/rtmp2/rtmp/rtmpconnection.c b/gst/rtmp2/rtmp/rtmpconnection.c index 8863d32..b438658 100644 --- a/gst/rtmp2/rtmp/rtmpconnection.c +++ b/gst/rtmp2/rtmp/rtmpconnection.c @@ -80,7 +80,7 @@ struct _GstRtmpConnection guint32 out_window_ack_size; guint64 in_bytes_total; - guint64 in_bytes_unacked; + guint64 in_bytes_acked; }; @@ -409,6 +409,7 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data) gssize ret; guint oldsize; GError *error = NULL; + guint64 bytes_since_ack; GST_TRACE_OBJECT (sc, "input ready"); @@ -446,8 +447,8 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data) GST_TRACE_OBJECT (sc, "read %" G_GSIZE_FORMAT " bytes", ret); sc->in_bytes_total += ret; - sc->in_bytes_unacked += ret; - if (sc->in_bytes_unacked >= sc->in_window_ack_size) { + bytes_since_ack = sc->in_bytes_total - sc->in_bytes_acked; + if (sc->in_window_ack_size && bytes_since_ack >= sc->in_window_ack_size) { gst_rtmp_connection_send_ack (sc); } @@ -988,15 +989,16 @@ gst_rtmp_connection_expect_command (GstRtmpConnection * connection, static void gst_rtmp_connection_send_ack (GstRtmpConnection * connection) { + guint64 in_bytes_total = connection->in_bytes_total; GstRtmpProtocolControl pc = { .type = GST_RTMP_MESSAGE_TYPE_ACKNOWLEDGEMENT, - .param = (guint32) connection->in_bytes_total, + .param = (guint32) in_bytes_total, }; gst_rtmp_connection_queue_message (connection, gst_rtmp_message_new_protocol_control (&pc)); - connection->in_bytes_unacked = 0; + connection->in_bytes_acked = in_bytes_total; } static void -- 2.7.4