OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

metrics.h
Go to the documentation of this file.
1 /*
2 * metrics.h
3 *
4 * E-Model implementation
5 *
6 * Open Phone Abstraction Library (OPAL)
7 *
8 * Copyright (c) 2010 Universidade Federal do Amazonas
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * Contributor(s): ______________________________________.
21 *
22 * $Revision: 25550 $
23 * $Author: rjongbloed $
24 * $Date: 2011-04-12 01:56:22 -0500 (Tue, 12 Apr 2011) $
25 */
26
27 #ifndef OPAL_RTP_METRICS_H
28 #define OPAL_RTP_METRICS_H
29
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33
34 #include <rtp/rtp.h>
35
36 #if OPAL_RTCP_XR
37
38 #include <list>
39
40 class RTP_Session;
41 class RTP_DataFrame;
42
44 // RTCP-XR - VoIP Metrics Report Block
45
49 class RTCP_XR_Metrics
50 {
51 public:
52 RTCP_XR_Metrics();
53 ~RTCP_XR_Metrics();
54
55 enum PacketEvent {
56 PACKET_RECEIVED,
57 PACKET_DISCARDED,
58 PACKET_LOST
59 };
60
61 enum PeriodType {
62 GAP, /* a period of low packet losses and/or discards */
63 BURST, /* a period of a high proportion of packet losses and/or discards */
64 };
65
66 /* A period of time, which can be a burst or a gap */
67 typedef struct TimePeriod {
68 PeriodType type;
69 PTimeInterval duration;
70 } TimePeriod;
71
75 typedef struct IdPeriod {
76 PTimeInterval duration;
77 float Id;
78 } IdPeriod;
79
83 typedef struct IePeriod {
84 PeriodType type;
85 PTimeInterval duration;
86 float Ieff;
87 } IePeriod;
88
89 enum QualityType {
90 LQ, /* Listening Quality, not include the effects of delay */
91 CQ /* Conversational Quality, include the effects of delay */
92 };
93
94 std::list<TimePeriod> timePeriods;
95 std::list<IePeriod> iePeriods;
96 std::list<IdPeriod> idPeriods;
97
101 void SetPayloadInfo(
102 RTP_DataFrame frame
103 );
104
108 void SetJitterDelay(
109 DWORD delay
110 );
111
114 void OnPacketReceived();
115
118 void OnPacketDiscarded();
119
122 void OnPacketLost();
123
126 void OnPacketLost(
127 DWORD dropped
128 );
129
132 void OnRxSenderReport(
133 PUInt32b lsr,
134 PUInt32b dlsr
135 );
136
139 BYTE GetLossRate();
140
143 BYTE GetDiscardRate();
144
148 BYTE GetBurstDensity();
149
153 BYTE GetGapDensity();
154
158 PUInt16b GetBurstDuration();
159
163 PUInt16b GetGapDuration();
164
168 PUInt16b GetRoundTripDelay ();
169
172 PUInt16b GetEndSystemDelay();
173
176 BYTE RFactor();
177
182 BYTE MOS_LQ();
183
188 BYTE MOS_CQ();
189
190 private:
199 void markov(
200 PacketEvent event
201 );
202
205 void ResetCounters();
206
209 BYTE RFactor(
210 QualityType qt
211 );
212
215 BYTE EndOfCallRFactor();
216
220 float MOS(
221 QualityType qt
222 );
223
227 float EndOfCallMOS();
228
231 float IdFactor();
232
235 float GetPonderateId();
236
239 float Ieff(
240 PeriodType type
241 );
242
245 float GetEndOfCallIe();
246
249 float GetPonderateIe();
250
253 TimePeriod createTimePeriod(
254 PeriodType type,
255 PTime beginTimestamp,
256 PTime endTimestamp
257 );
258
261 IdPeriod createIdPeriod(
262 PTime beginTimestamp,
263 PTime endTimestamp
264 );
265
268 IePeriod createIePeriod(
269 TimePeriod timePeriod
270 );
271
272 DWORD gmin; /* gap threshold */
273 DWORD lost; /* number of lost packets within the current burst */
274 DWORD packetsReceived; /* packets received since the beggining of the reception */
275 DWORD packetsSinceLastLoss; /* packets received since the last loss or discard event */
276 DWORD packetsLost; /* packets lost since the beggining of the reception */
277 DWORD packetsDiscarded; /* packets discarded since the beggining of the receptions */
278 DWORD srPacketsReceived; /* count of SR packets received */
279
280 DWORD packetsReceivedInGap; /* packets received within gap periods */
281 DWORD packetsLostInGap; /* packets lost within gap periods */
282
283 DWORD packetsReceivedInBurst; /* packets received within burst periods */
284 DWORD packetsLostInBurst; /* packets lost within burst periods */
285
295 DWORD c5;
296 DWORD c11;
297 DWORD c13;
298 DWORD c14;
299 DWORD c22;
300 DWORD c23;
301 DWORD c31;
302 DWORD c32;
303 DWORD c33;
304
305 /* variables to calculate round trip delay */
306 PTime lsrTime;
307 PTimeInterval dlsrTime;
308 PTime arrivalTime;
309
310 /* data associated with the payload */
311 float Ie; /* equipment impairment factor for the codec utilized */
312 float Bpl; /* robustness factor for the codec utilized */
313 unsigned payloadBitrate;
314 PINDEX payloadSize;
315 float lookAheadTime; /* codec lookahead time */
316
317 bool isPayloadTypeOK;
318
319 DWORD jitterDelay; /* jitter buffer delay, in milliseconds */
320 float lastId; /* last Id calculated */
321 float lastIe; /* last Ie calculated */
322
323 PeriodType currentPeriodType; /* indicates if we are within a gap or burst */
324 PTime periodBeginTimestamp; /* timestamp of the beginning of the gap or burst period */
325 PTime lastLossTimestamp; /* timestamp of the last loss */
326 PTime lastLossInBurstTimestamp; /* timestamp of the last loss within a burst period */
327 PTime lastJitterBufferChangeTimestamp; /* timestamp of the last change in jitter buffer size */
328
329 };
330
331
332 #endif // OPAL_RTCP_XR
333
334 #endif // OPAL_METRICS_H
335
336