rtpmanager: provide additional statistics

This commit is contained in:
Havard Graff 2009-08-31 18:34:08 +02:00 committed by Wim Taymans
parent d32d596b2e
commit 0fa589a3dd
3 changed files with 49 additions and 19 deletions

View File

@ -209,7 +209,9 @@ rtp_source_create_stats (RTPSource * src)
"validated", G_TYPE_BOOLEAN, src->validated, "validated", G_TYPE_BOOLEAN, src->validated,
"received-bye", G_TYPE_BOOLEAN, src->received_bye, "received-bye", G_TYPE_BOOLEAN, src->received_bye,
"is-csrc", G_TYPE_BOOLEAN, src->is_csrc, "is-csrc", G_TYPE_BOOLEAN, src->is_csrc,
"is-sender", G_TYPE_BOOLEAN, is_sender, NULL); "is-sender", G_TYPE_BOOLEAN, is_sender,
"seqnum-base", G_TYPE_INT, src->seqnum_base,
"clock-rate", G_TYPE_INT, src->clock_rate, NULL);
/* add address and port */ /* add address and port */
if (src->have_rtp_from) { if (src->have_rtp_from) {
@ -225,17 +227,18 @@ rtp_source_create_stats (RTPSource * src)
if (internal) { if (internal) {
/* our internal source */ /* our internal source */
if (is_sender) {
/* if we are sending, report about how much we sent, other sources will /* report accumulated send statistics, other sources will have a RB with
* have a RB with info on reception. */ * info on reception. */
gst_structure_set (s, gst_structure_set (s,
"octets-sent", G_TYPE_UINT64, src->stats.octets_sent, "octets-sent", G_TYPE_UINT64, src->stats.octets_sent,
"packets-sent", G_TYPE_UINT64, src->stats.packets_sent, "packets-sent", G_TYPE_UINT64, src->stats.packets_sent, NULL);
"bitrate", G_TYPE_UINT64, src->bitrate, NULL);
} else { if (is_sender)
/* if we are not sending we have nothing more to report */ gst_structure_set (s, "bitrate", G_TYPE_UINT64, src->bitrate, NULL);
}
} else { } else {
/* other sources */
gboolean have_rb; gboolean have_rb;
guint8 fractionlost = 0; guint8 fractionlost = 0;
gint32 packetslost = 0; gint32 packetslost = 0;
@ -245,7 +248,13 @@ rtp_source_create_stats (RTPSource * src)
guint32 dlsr = 0; guint32 dlsr = 0;
guint32 round_trip = 0; guint32 round_trip = 0;
/* other sources */ gst_structure_set (s,
"octets-received", G_TYPE_UINT64, src->stats.octets_received,
"packets-received", G_TYPE_UINT64, src->stats.packets_received,
"bitrate", G_TYPE_UINT64, src->bitrate,
"packets-lost", G_TYPE_INT, (gint) rtp_stats_get_packets_lost (&src->stats),
"jitter", G_TYPE_UINT, (guint) (src->stats.jitter >> 4), NULL);
if (is_sender) { if (is_sender) {
gboolean have_sr; gboolean have_sr;
GstClockTime time = 0; GstClockTime time = 0;
@ -258,9 +267,6 @@ rtp_source_create_stats (RTPSource * src)
have_sr = rtp_source_get_last_sr (src, &time, &ntptime, &rtptime, have_sr = rtp_source_get_last_sr (src, &time, &ntptime, &rtptime,
&packet_count, &octet_count); &packet_count, &octet_count);
gst_structure_set (s, gst_structure_set (s,
"octets-received", G_TYPE_UINT64, src->stats.octets_received,
"packets-received", G_TYPE_UINT64, src->stats.packets_received,
"bitrate", G_TYPE_UINT64, src->bitrate,
"have-sr", G_TYPE_BOOLEAN, have_sr, "have-sr", G_TYPE_BOOLEAN, have_sr,
"sr-ntptime", G_TYPE_UINT64, ntptime, "sr-ntptime", G_TYPE_UINT64, ntptime,
"sr-rtptime", G_TYPE_UINT, (guint) rtptime, "sr-rtptime", G_TYPE_UINT, (guint) rtptime,
@ -899,11 +905,11 @@ do_bitrate_estimation (RTPSource * src, GstClockTime running_time,
elapsed = running_time - src->prev_rtime; elapsed = running_time - src->prev_rtime;
if (elapsed > (G_GINT64_CONSTANT (1) << 31)) { if (elapsed > (G_GINT64_CONSTANT (1) << 31)) {
const guint64 bits_per_byte = G_GUINT64_CONSTANT (8);
guint64 rate; guint64 rate;
rate = rate = gst_util_uint64_scale (*bytes_handled,
gst_util_uint64_scale (*bytes_handled, elapsed, bits_per_byte * GST_SECOND, elapsed);
(G_GINT64_CONSTANT (1) << 29));
GST_LOG ("Elapsed %" G_GUINT64_FORMAT ", bytes %" G_GUINT64_FORMAT GST_LOG ("Elapsed %" G_GUINT64_FORMAT ", bytes %" G_GUINT64_FORMAT
", rate %" G_GUINT64_FORMAT, elapsed, *bytes_handled, rate); ", rate %" G_GUINT64_FORMAT, elapsed, *bytes_handled, rate);

View File

@ -261,3 +261,27 @@ rtp_stats_calculate_bye_interval (RTPSessionStats * stats)
return interval * GST_SECOND; return interval * GST_SECOND;
} }
/**
* rtp_stats_get_packets_lost:
* @stats: an #RTPSourceStats struct
*
* Calculate the total number of RTP packets lost since beginning of
* reception. Packets that arrive late are not considered lost, and
* duplicates are not taken into account. Hence, the loss may be negative
* if there are duplicates.
*
* Returns: total RTP packets lost.
*/
gint64
rtp_stats_get_packets_lost (const RTPSourceStats *stats)
{
gint64 lost;
guint64 extended_max, expected;
extended_max = stats->cycles + stats->max_seq;
expected = extended_max - stats->base_seq + 1;
lost = expected - stats->packets_received;
return lost;
}

View File

@ -194,5 +194,5 @@ void rtp_stats_set_bandwidths (RTPSessionStats *stats,
GstClockTime rtp_stats_calculate_rtcp_interval (RTPSessionStats *stats, gboolean sender, gboolean first); GstClockTime rtp_stats_calculate_rtcp_interval (RTPSessionStats *stats, gboolean sender, gboolean first);
GstClockTime rtp_stats_add_rtcp_jitter (RTPSessionStats *stats, GstClockTime interval); GstClockTime rtp_stats_add_rtcp_jitter (RTPSessionStats *stats, GstClockTime interval);
GstClockTime rtp_stats_calculate_bye_interval (RTPSessionStats *stats); GstClockTime rtp_stats_calculate_bye_interval (RTPSessionStats *stats);
gint64 rtp_stats_get_packets_lost (const RTPSourceStats *stats);
#endif /* __RTP_STATS_H__ */ #endif /* __RTP_STATS_H__ */