rtpbin: correctly calculate RTCP packet size

This commit is contained in:
Wim Taymans 2010-12-14 17:15:23 +01:00
parent 957eac9579
commit 7ebd374766
2 changed files with 16 additions and 13 deletions

View file

@ -74,13 +74,14 @@ enum
PROP_LAST
};
/* update average packet size, we keep this scaled by 16 to keep enough
* precision. */
/* update average packet size */
#define INIT_AVG(avg, val) \
(avg) = (val);
#define UPDATE_AVG(avg, val) \
if ((avg) == 0) \
(avg) = (val) << 4; \
(avg) = (val); \
else \
(avg) = ((val) + (15 * (avg)));
(avg) = ((val) + (15 * (val))) >> 4;
/* The number RTCP intervals after which to timeout entries in the
* collision table
@ -2169,8 +2170,7 @@ rtp_session_schedule_bye_locked (RTPSession * sess, const gchar * reason,
/* at least one member wants to send a BYE */
g_free (sess->bye_reason);
sess->bye_reason = g_strdup (reason);
/* The avg packet size is kept scaled by 16 */
sess->stats.avg_rtcp_packet_size = 100 * 16;
INIT_AVG (sess->stats.avg_rtcp_packet_size, 100);
sess->stats.bye_members = 1;
sess->first_rtcp = TRUE;
sess->sent_bye = FALSE;
@ -2692,12 +2692,14 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime current_time,
/* close the RTCP packet */
gst_rtcp_buffer_end (data.rtcp);
GST_DEBUG ("sending packet");
if (sess->callbacks.send_rtcp) {
UPDATE_AVG (sess->stats.avg_rtcp_packet_size,
GST_BUFFER_SIZE (data.rtcp));
result = sess->callbacks.send_rtcp (sess, own, data.rtcp,
sess->sent_bye, sess->send_rtcp_user_data);
GST_DEBUG ("sending RTCP packet, avg size %u",
sess->stats.avg_rtcp_packet_size);
result =
sess->callbacks.send_rtcp (sess, own, data.rtcp, sess->sent_bye,
sess->send_rtcp_user_data);
} else {
GST_DEBUG ("freeing packet");
gst_buffer_unref (data.rtcp);

View file

@ -166,7 +166,7 @@ rtp_stats_calculate_rtcp_interval (RTPSessionStats * stats, gboolean we_send,
if (rtcp_bw <= 0.00001)
return GST_CLOCK_TIME_NONE;
avg_rtcp_size = stats->avg_rtcp_packet_size / 16.0;
avg_rtcp_size = stats->avg_rtcp_packet_size;
/*
* The effective number of sites times the average packet size is
* the total number of octets sent when each site sends a report.
@ -176,6 +176,7 @@ rtp_stats_calculate_rtcp_interval (RTPSessionStats * stats, gboolean we_send,
* time interval we send one report so this time is also our
* average time between reports.
*/
GST_DEBUG ("avg size %f, n %f, rtcp_bw %f", avg_rtcp_size, n, rtcp_bw);
interval = avg_rtcp_size * n / rtcp_bw;
if (interval < rtcp_min_time)
interval = rtcp_min_time;
@ -245,7 +246,7 @@ rtp_stats_calculate_bye_interval (RTPSessionStats * stats)
if (rtcp_bw <= 0.0001)
return GST_CLOCK_TIME_NONE;
avg_rtcp_size = stats->avg_rtcp_packet_size / 16.0;
avg_rtcp_size = stats->avg_rtcp_packet_size;
/*
* The effective number of sites times the average packet size is
* the total number of octets sent when each site sends a report.