00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 <opal/buildopts.h>
00035
00036 #if OPAL_RTCP_XR
00037
00038 #include <rtp/rtp.h>
00039
00040 #include <list>
00041
00042 class RTP_Session;
00043 class RTP_DataFrame;
00044
00046
00047
00051 class RTCP_XR_Metrics
00052 {
00053 protected:
00054 RTCP_XR_Metrics(
00055 float Ie,
00056 float Bpl,
00057 float lookAheadTime,
00058 PINDEX payloadSize,
00059 unsigned payloadBitrate
00060 );
00061
00062 public:
00063 static RTCP_XR_Metrics * Create(const RTP_DataFrame & frame);
00064
00065 ~RTCP_XR_Metrics();
00066
00067 enum PacketEvent {
00068 PACKET_RECEIVED,
00069 PACKET_DISCARDED,
00070 PACKET_LOST
00071 };
00072
00073 enum PeriodType {
00074 GAP,
00075 BURST,
00076 };
00077
00078
00079 typedef struct TimePeriod {
00080 PeriodType type;
00081 PTimeInterval duration;
00082 } TimePeriod;
00083
00087 typedef struct IdPeriod {
00088 PTimeInterval duration;
00089 float Id;
00090 } IdPeriod;
00091
00095 typedef struct IePeriod {
00096 PeriodType type;
00097 PTimeInterval duration;
00098 float Ieff;
00099 } IePeriod;
00100
00101 enum QualityType {
00102 LQ,
00103 CQ
00104 };
00105
00109 void SetJitterDelay(
00110 DWORD delay
00111 );
00112
00115 void OnPacketReceived();
00116
00119 void OnPacketDiscarded();
00120
00123 void OnPacketLost();
00124
00127 void OnPacketLost(
00128 DWORD dropped
00129 );
00130
00133 void OnRxSenderReport(
00134 PUInt32b lsr,
00135 PUInt32b dlsr
00136 );
00137
00140 BYTE GetLossRate();
00141
00144 BYTE GetDiscardRate();
00145
00149 BYTE GetBurstDensity();
00150
00154 BYTE GetGapDensity();
00155
00159 PUInt16b GetBurstDuration();
00160
00164 PUInt16b GetGapDuration();
00165
00169 PUInt16b GetRoundTripDelay ();
00170
00173 PUInt16b GetEndSystemDelay();
00174
00177 BYTE RFactor();
00178
00183 BYTE MOS_LQ();
00184
00189 BYTE MOS_CQ();
00190
00191
00192 void InsertExtendedReportPacket(
00193 unsigned sessionID,
00194 DWORD syncSourceOut,
00195 RTP_Session::JitterBufferPtr jitter,
00196 RTP_ControlFrame & report
00197 );
00198
00199 static RTP_Session::ExtendedReportArray
00200 BuildExtendedReportArray(const RTP_ControlFrame & frame, PINDEX offset);
00201
00202
00203 protected:
00212 void markov(
00213 PacketEvent event
00214 );
00215
00218 void ResetCounters();
00219
00222 BYTE RFactor(
00223 QualityType qt
00224 );
00225
00228 BYTE EndOfCallRFactor();
00229
00233 float MOS(
00234 QualityType qt
00235 );
00236
00240 float EndOfCallMOS();
00241
00244 float IdFactor();
00245
00248 float GetPonderateId();
00249
00252 float Ieff(
00253 PeriodType type
00254 );
00255
00258 float GetEndOfCallIe();
00259
00262 float GetPonderateIe();
00263
00266 TimePeriod createTimePeriod(
00267 PeriodType type,
00268 PTime beginTimestamp,
00269 PTime endTimestamp
00270 );
00271
00274 IdPeriod createIdPeriod(
00275 PTime beginTimestamp,
00276 PTime endTimestamp
00277 );
00278
00281 IePeriod createIePeriod(
00282 TimePeriod timePeriod
00283 );
00284
00285
00286 float m_Ie;
00287 float m_Bpl;
00288 float m_lookAheadTime;
00289 PINDEX m_payloadSize;
00290 unsigned m_payloadBitrate;
00291
00292 DWORD m_gmin;
00293 DWORD m_lostInBurst;
00294 DWORD m_packetsReceived;
00295 DWORD m_packetsSinceLastLoss;
00296 DWORD m_packetsLost;
00297 DWORD m_packetsDiscarded;
00298 DWORD m_srPacketsReceived;
00299
00300 DWORD m_packetsReceivedInGap;
00301 DWORD m_packetsLostInGap;
00302
00303 DWORD m_packetsReceivedInBurst;
00304 DWORD m_packetsLostInBurst;
00305
00315 DWORD c5;
00316 DWORD c11;
00317 DWORD c13;
00318 DWORD c14;
00319 DWORD c22;
00320 DWORD c23;
00321 DWORD c31;
00322 DWORD c32;
00323 DWORD c33;
00324
00325
00326 PTime m_lsrTime;
00327 PTimeInterval m_dlsrTime;
00328 PTime m_arrivalTime;
00329
00330 DWORD m_jitterDelay;
00331 float m_lastId;
00332 float m_lastIe;
00333
00334 std::list<TimePeriod> m_timePeriods;
00335 std::list<IePeriod> m_iePeriods;
00336 std::list<IdPeriod> m_idPeriods;
00337
00338 PeriodType m_currentPeriodType;
00339 PTime m_periodBeginTimestamp;
00340 PTime m_lastLossTimestamp;
00341 PTime m_lastLossInBurstTimestamp;
00342 PTime m_lastJitterBufferChangeTimestamp;
00343
00344 };
00345
00346
00347 #endif // OPAL_RTCP_XR
00348
00349 #endif // OPAL_METRICS_H
00350
00351