2 * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __RTP_STATS_H__
21 #define __RTP_STATS_H__
24 #include <gst/netbuffer/gstnetbuffer.h>
29 * A sender report structure.
43 * A receiver report structure.
47 guint32 ssrc; /* who the report is from */
50 guint32 exthighestseq;
59 * @time: arrival time of a packet
60 * @address: address of the sender of the packet
61 * @bytes: bytes of the packet including lowlevel overhead
62 * @payload_len: bytes of the RTP payload
64 * Structure holding information about the arrival stats of a packet.
69 gboolean have_address;
70 GstNetAddress address;
77 * @packetsreceived: number of received packets in total
78 * @prevpacketsreceived: number of packets received in previous reporting
80 * @octetsreceived: number of payload bytes received
81 * @bytesreceived: number of total bytes received including headers and lower
82 * protocol level overhead
83 * @max_seqnr: highest sequence number received
84 * @transit: previous transit time used for calculating @jitter
85 * @jitter: current jitter
86 * @prev_rtptime: previous time when an RTP packet was received
87 * @prev_rtcptime: previous time when an RTCP packet was received
88 * @last_rtptime: time when last RTP packet received
89 * @last_rtcptime: time when last RTCP packet received
90 * @curr_rr: index of current @rr block
91 * @rr: previous and current receiver report block
92 * @curr_sr: index of current @sr block
93 * @sr: previous and current sender report block
95 * Stats about a source.
98 guint64 packets_received;
99 guint64 octets_received;
100 guint64 bytes_received;
102 guint32 prev_expected;
103 guint32 prev_received;
112 guint64 packets_sent;
115 /* when we received stuff */
116 GstClockTime prev_rtptime;
117 GstClockTime prev_rtcptime;
118 GstClockTime last_rtptime;
119 GstClockTime last_rtcptime;
121 /* sender and receiver reports */
123 RTPReceiverReport rr[2];
125 RTPSenderReport sr[2];
128 #define RTP_STATS_BANDWIDTH 64000.0
129 #define RTP_STATS_RTCP_BANDWIDTH 3000.0
131 * Minimum average time between RTCP packets from this site (in
132 * seconds). This time prevents the reports from `clumping' when
133 * sessions are small and the law of large numbers isn't helping
134 * to smooth out the traffic. It also keeps the report interval
135 * from becoming ridiculously small during transient outages like
136 * a network partition.
138 #define RTP_STATS_MIN_INTERVAL 5.0
140 * Fraction of the RTCP bandwidth to be shared among active
141 * senders. (This fraction was chosen so that in a typical
142 * session with one or two active senders, the computed report
143 * time would be roughly equal to the minimum report time so that
144 * we don't unnecessarily slow down receiver reports.) The
145 * receiver fraction must be 1 - the sender fraction.
147 #define RTP_STATS_SENDER_FRACTION (0.25)
148 #define RTP_STATS_RECEIVER_FRACTION (1.0 - RTP_STATS_SENDER_FRACTION)
151 * When receiving a BYE from a source, remove the source fomr the database
152 * after this timeout.
154 #define RTP_STATS_BYE_TIMEOUT (2 * GST_SECOND)
159 * Stats kept for a session and used to produce RTCP packet timeouts.
163 gdouble sender_fraction;
164 gdouble receiver_fraction;
165 gdouble rtcp_bandwidth;
166 gdouble min_interval;
167 GstClockTime bye_timeout;
168 guint sender_sources;
169 guint active_sources;
170 guint avg_rtcp_packet_size;
174 void rtp_stats_init_defaults (RTPSessionStats *stats);
176 GstClockTime rtp_stats_calculate_rtcp_interval (RTPSessionStats *stats, gboolean sender, gboolean first);
177 GstClockTime rtp_stats_add_rtcp_jitter (RTPSessionStats *stats, GstClockTime interval);
178 GstClockTime rtp_stats_calculate_bye_interval (RTPSessionStats *stats);
180 #endif /* __RTP_STATS_H__ */