OPAL
Version 3.10.4
|
00001 /* 00002 * metrics.h 00003 * 00004 * E-Model implementation 00005 * 00006 * Open Phone Abstraction Library (OPAL) 00007 * 00008 * Copyright (c) 2010 Universidade Federal do Amazonas 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * Contributor(s): ______________________________________. 00021 * 00022 * $Revision: 25550 $ 00023 * $Author: rjongbloed $ 00024 * $Date: 2011-04-12 01:56:22 -0500 (Tue, 12 Apr 2011) $ 00025 */ 00026 00027 #ifndef OPAL_RTP_METRICS_H 00028 #define OPAL_RTP_METRICS_H 00029 00030 #ifdef P_USE_PRAGMA 00031 #pragma interface 00032 #endif 00033 00034 #include <rtp/rtp.h> 00035 00036 #if OPAL_RTCP_XR 00037 00038 #include <list> 00039 00040 class RTP_Session; 00041 class RTP_DataFrame; 00042 00044 // RTCP-XR - VoIP Metrics Report Block 00045 00049 class RTCP_XR_Metrics 00050 { 00051 public: 00052 RTCP_XR_Metrics(); 00053 ~RTCP_XR_Metrics(); 00054 00055 enum PacketEvent { 00056 PACKET_RECEIVED, 00057 PACKET_DISCARDED, 00058 PACKET_LOST 00059 }; 00060 00061 enum PeriodType { 00062 GAP, /* a period of low packet losses and/or discards */ 00063 BURST, /* a period of a high proportion of packet losses and/or discards */ 00064 }; 00065 00066 /* A period of time, which can be a burst or a gap */ 00067 typedef struct TimePeriod { 00068 PeriodType type; 00069 PTimeInterval duration; 00070 } TimePeriod; 00071 00075 typedef struct IdPeriod { 00076 PTimeInterval duration; 00077 float Id; 00078 } IdPeriod; 00079 00083 typedef struct IePeriod { 00084 PeriodType type; 00085 PTimeInterval duration; 00086 float Ieff; 00087 } IePeriod; 00088 00089 enum QualityType { 00090 LQ, /* Listening Quality, not include the effects of delay */ 00091 CQ /* Conversational Quality, include the effects of delay */ 00092 }; 00093 00094 std::list<TimePeriod> timePeriods; 00095 std::list<IePeriod> iePeriods; 00096 std::list<IdPeriod> idPeriods; 00097 00101 void SetPayloadInfo( 00102 RTP_DataFrame frame 00103 ); 00104 00108 void SetJitterDelay( 00109 DWORD delay 00110 ); 00111 00114 void OnPacketReceived(); 00115 00118 void OnPacketDiscarded(); 00119 00122 void OnPacketLost(); 00123 00126 void OnPacketLost( 00127 DWORD dropped 00128 ); 00129 00132 void OnRxSenderReport( 00133 PUInt32b lsr, 00134 PUInt32b dlsr 00135 ); 00136 00139 BYTE GetLossRate(); 00140 00143 BYTE GetDiscardRate(); 00144 00148 BYTE GetBurstDensity(); 00149 00153 BYTE GetGapDensity(); 00154 00158 PUInt16b GetBurstDuration(); 00159 00163 PUInt16b GetGapDuration(); 00164 00168 PUInt16b GetRoundTripDelay (); 00169 00172 PUInt16b GetEndSystemDelay(); 00173 00176 BYTE RFactor(); 00177 00182 BYTE MOS_LQ(); 00183 00188 BYTE MOS_CQ(); 00189 00190 private: 00199 void markov( 00200 PacketEvent event 00201 ); 00202 00205 void ResetCounters(); 00206 00209 BYTE RFactor( 00210 QualityType qt 00211 ); 00212 00215 BYTE EndOfCallRFactor(); 00216 00220 float MOS( 00221 QualityType qt 00222 ); 00223 00227 float EndOfCallMOS(); 00228 00231 float IdFactor(); 00232 00235 float GetPonderateId(); 00236 00239 float Ieff( 00240 PeriodType type 00241 ); 00242 00245 float GetEndOfCallIe(); 00246 00249 float GetPonderateIe(); 00250 00253 TimePeriod createTimePeriod( 00254 PeriodType type, 00255 PTime beginTimestamp, 00256 PTime endTimestamp 00257 ); 00258 00261 IdPeriod createIdPeriod( 00262 PTime beginTimestamp, 00263 PTime endTimestamp 00264 ); 00265 00268 IePeriod createIePeriod( 00269 TimePeriod timePeriod 00270 ); 00271 00272 DWORD gmin; /* gap threshold */ 00273 DWORD lost; /* number of lost packets within the current burst */ 00274 DWORD packetsReceived; /* packets received since the beggining of the reception */ 00275 DWORD packetsSinceLastLoss; /* packets received since the last loss or discard event */ 00276 DWORD packetsLost; /* packets lost since the beggining of the reception */ 00277 DWORD packetsDiscarded; /* packets discarded since the beggining of the receptions */ 00278 DWORD srPacketsReceived; /* count of SR packets received */ 00279 00280 DWORD packetsReceivedInGap; /* packets received within gap periods */ 00281 DWORD packetsLostInGap; /* packets lost within gap periods */ 00282 00283 DWORD packetsReceivedInBurst; /* packets received within burst periods */ 00284 DWORD packetsLostInBurst; /* packets lost within burst periods */ 00285 00295 DWORD c5; 00296 DWORD c11; 00297 DWORD c13; 00298 DWORD c14; 00299 DWORD c22; 00300 DWORD c23; 00301 DWORD c31; 00302 DWORD c32; 00303 DWORD c33; 00304 00305 /* variables to calculate round trip delay */ 00306 PTime lsrTime; 00307 PTimeInterval dlsrTime; 00308 PTime arrivalTime; 00309 00310 /* data associated with the payload */ 00311 float Ie; /* equipment impairment factor for the codec utilized */ 00312 float Bpl; /* robustness factor for the codec utilized */ 00313 unsigned payloadBitrate; 00314 PINDEX payloadSize; 00315 float lookAheadTime; /* codec lookahead time */ 00316 00317 bool isPayloadTypeOK; 00318 00319 DWORD jitterDelay; /* jitter buffer delay, in milliseconds */ 00320 float lastId; /* last Id calculated */ 00321 float lastIe; /* last Ie calculated */ 00322 00323 PeriodType currentPeriodType; /* indicates if we are within a gap or burst */ 00324 PTime periodBeginTimestamp; /* timestamp of the beginning of the gap or burst period */ 00325 PTime lastLossTimestamp; /* timestamp of the last loss */ 00326 PTime lastLossInBurstTimestamp; /* timestamp of the last loss within a burst period */ 00327 PTime lastJitterBufferChangeTimestamp; /* timestamp of the last change in jitter buffer size */ 00328 00329 }; 00330 00331 00332 #endif // OPAL_RTCP_XR 00333 00334 #endif // OPAL_METRICS_H 00335 00336