~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to gst/rtpmanager/rtpstats.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2007-05-03 19:52:54 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20070503195254-4dovmz251nut3yrt
Tags: 0.10.4+cvs20070502-1
* New CVS snapshot.
* debian/rules,
  debian/build-deps.in:
  + Update build dependencies.
* debian/gstreamer-plugins-bad-multiverse.install:
  + Add x264 plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GStreamer
 
2
 * Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 */
 
19
 
 
20
#ifndef __RTP_STATS_H__
 
21
#define __RTP_STATS_H__
 
22
 
 
23
#include <gst/gst.h>
 
24
#include <gst/netbuffer/gstnetbuffer.h>
 
25
 
 
26
/**
 
27
 * RTPSenderReport:
 
28
 *
 
29
 * A sender report structure.
 
30
 */
 
31
typedef struct {
 
32
  gboolean is_valid;
 
33
  guint64 ntptime;
 
34
  guint32 rtptime;
 
35
  guint32 packet_count;
 
36
  guint32 octet_count;
 
37
  GstClockTime time;
 
38
} RTPSenderReport;
 
39
 
 
40
/**
 
41
 * RTPReceiverReport:
 
42
 *
 
43
 * A receiver report structure.
 
44
 */
 
45
typedef struct {
 
46
  gboolean is_valid;
 
47
  guint32 ssrc; /* who the report is from */
 
48
  guint8  fractionlost;
 
49
  guint32 packetslost;
 
50
  guint32 exthighestseq;
 
51
  guint32 jitter;
 
52
  guint32 lsr;
 
53
  guint32 dlsr;
 
54
} RTPReceiverReport;
 
55
 
 
56
/**
 
57
 * RTPArrivalStats:
 
58
 * @time: arrival time of a packet
 
59
 * @address: address of the sender of the packet
 
60
 * @bytes: bytes of the packet including lowlevel overhead
 
61
 * @payload_len: bytes of the RTP payload
 
62
 *
 
63
 * Structure holding information about the arrival stats of a packet.
 
64
 */
 
65
typedef struct {
 
66
  GstClockTime  time;
 
67
  gboolean      have_address;
 
68
  GstNetAddress address;
 
69
  guint         bytes;
 
70
  guint         payload_len;
 
71
} RTPArrivalStats;
 
72
 
 
73
/**
 
74
 * RTPSourceStats:
 
75
 * @packetsreceived: number of received packets in total
 
76
 * @prevpacketsreceived: number of packets received in previous reporting
 
77
 *                       interval
 
78
 * @octetsreceived: number of payload bytes received
 
79
 * @bytesreceived: number of total bytes received including headers and lower
 
80
 *                 protocol level overhead
 
81
 * @max_seqnr: highest sequence number received
 
82
 * @transit: previous transit time used for calculating @jitter
 
83
 * @jitter: current jitter
 
84
 * @prev_rtptime: previous time when an RTP packet was received
 
85
 * @prev_rtcptime: previous time when an RTCP packet was received
 
86
 * @last_rtptime: time when last RTP packet received
 
87
 * @last_rtcptime: time when last RTCP packet received
 
88
 * @curr_rr: index of current @rr block
 
89
 * @rr: previous and current receiver report block
 
90
 * @curr_sr: index of current @sr block
 
91
 * @sr: previous and current sender report block
 
92
 *
 
93
 * Stats about a source.
 
94
 */
 
95
typedef struct {
 
96
  guint64      packets_received;
 
97
  guint64      octets_received;
 
98
  guint64      bytes_received;
 
99
 
 
100
  guint32      prev_expected;
 
101
  guint32      prev_received;
 
102
 
 
103
  guint16      max_seq;
 
104
  guint64      cycles;
 
105
  guint32      base_seq;
 
106
  guint32      bad_seq;
 
107
  guint32      transit;
 
108
  guint32      jitter;
 
109
 
 
110
  guint64      packets_sent;
 
111
  guint64      octets_sent;
 
112
 
 
113
  /* when we received stuff */
 
114
  GstClockTime prev_rtptime;
 
115
  GstClockTime prev_rtcptime;
 
116
  GstClockTime last_rtptime;
 
117
  GstClockTime last_rtcptime;
 
118
 
 
119
  /* sender and receiver reports */
 
120
  gint              curr_rr;
 
121
  RTPReceiverReport rr[2];
 
122
  gint              curr_sr;
 
123
  RTPSenderReport   sr[2];
 
124
} RTPSourceStats;
 
125
 
 
126
#define RTP_STATS_BANDWIDTH           64000.0
 
127
#define RTP_STATS_RTCP_BANDWIDTH      3000.0
 
128
/*
 
129
 * Minimum average time between RTCP packets from this site (in
 
130
 * seconds).  This time prevents the reports from `clumping' when
 
131
 * sessions are small and the law of large numbers isn't helping
 
132
 * to smooth out the traffic.  It also keeps the report interval
 
133
 * from becoming ridiculously small during transient outages like
 
134
 * a network partition.
 
135
 */
 
136
#define RTP_STATS_MIN_INTERVAL      5.0
 
137
/*
 
138
 * Fraction of the RTCP bandwidth to be shared among active
 
139
 * senders.  (This fraction was chosen so that in a typical
 
140
 * session with one or two active senders, the computed report
 
141
 * time would be roughly equal to the minimum report time so that
 
142
 * we don't unnecessarily slow down receiver reports.) The
 
143
 * receiver fraction must be 1 - the sender fraction.
 
144
 */
 
145
#define RTP_STATS_SENDER_FRACTION       (0.25)
 
146
#define RTP_STATS_RECEIVER_FRACTION     (1.0 - RTP_STATS_SENDER_FRACTION)
 
147
 
 
148
/*
 
149
 * When receiving a BYE from a source, remove the source fomr the database
 
150
 * after this timeout.
 
151
 */
 
152
#define RTP_STATS_BYE_TIMEOUT           (2 * GST_SECOND)
 
153
 
 
154
/**
 
155
 * RTPSessionStats:
 
156
 *
 
157
 * Stats kept for a session and used to produce RTCP packet timeouts.
 
158
 */
 
159
typedef struct {
 
160
  gdouble       bandwidth;
 
161
  gdouble       sender_fraction;
 
162
  gdouble       receiver_fraction;
 
163
  gdouble       rtcp_bandwidth;
 
164
  gdouble       min_interval;
 
165
  GstClockTime  bye_timeout;
 
166
  guint         sender_sources;
 
167
  guint         active_sources;
 
168
  guint         avg_rtcp_packet_size;
 
169
  guint         bye_members;
 
170
} RTPSessionStats;
 
171
 
 
172
void           rtp_stats_init_defaults               (RTPSessionStats *stats);
 
173
 
 
174
GstClockTime   rtp_stats_calculate_rtcp_interval    (RTPSessionStats *stats, gboolean sender, gboolean first);
 
175
GstClockTime   rtp_stats_add_rtcp_jitter            (RTPSessionStats *stats, GstClockTime interval);
 
176
GstClockTime   rtp_stats_calculate_bye_interval     (RTPSessionStats *stats);
 
177
 
 
178
#endif /* __RTP_STATS_H__ */