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_session.h>
00039
00040 #include <list>
00041
00042 class RTP_Session;
00043 class RTP_DataFrame;
00044
00046
00047
00051 class RTCP_XR_Metrics : public PObject
00052 {
00053 PCLASSINFO(RTCP_XR_Metrics, PObject);
00054 protected:
00055 RTCP_XR_Metrics(
00056 float Ie,
00057 float Bpl,
00058 float lookAheadTime,
00059 PINDEX payloadSize,
00060 unsigned payloadBitrate
00061 );
00062
00063 public:
00064 static RTCP_XR_Metrics * Create(const RTP_DataFrame & frame);
00065
00066 ~RTCP_XR_Metrics();
00067
00068 enum PacketEvent {
00069 PACKET_RECEIVED,
00070 PACKET_DISCARDED,
00071 PACKET_LOST
00072 };
00073
00074 enum PeriodType {
00075 GAP,
00076 BURST,
00077 };
00078
00079
00080 typedef struct TimePeriod {
00081 PeriodType type;
00082 PTimeInterval duration;
00083 } TimePeriod;
00084
00088 typedef struct IdPeriod {
00089 PTimeInterval duration;
00090 float Id;
00091 } IdPeriod;
00092
00096 typedef struct IePeriod {
00097 PeriodType type;
00098 PTimeInterval duration;
00099 float Ieff;
00100 } IePeriod;
00101
00102 enum QualityType {
00103 LQ,
00104 CQ
00105 };
00106
00110 void SetJitterDelay(
00111 DWORD delay
00112 );
00113
00116 void OnPacketReceived();
00117
00120 void OnPacketDiscarded();
00121
00124 void OnPacketLost();
00125
00128 void OnPacketLost(
00129 DWORD dropped
00130 );
00131
00134 void OnRxSenderReport(
00135 PUInt32b lsr,
00136 PUInt32b dlsr
00137 );
00138
00141 BYTE GetLossRate();
00142
00145 BYTE GetDiscardRate();
00146
00150 BYTE GetBurstDensity();
00151
00155 BYTE GetGapDensity();
00156
00160 PUInt16b GetBurstDuration();
00161
00165 PUInt16b GetGapDuration();
00166
00170 PUInt16b GetRoundTripDelay ();
00171
00174 PUInt16b GetEndSystemDelay();
00175
00178 BYTE RFactor();
00179
00184 BYTE MOS_LQ();
00185
00190 BYTE MOS_CQ();
00191
00192
00193 void InsertExtendedReportPacket(
00194 unsigned sessionID,
00195 DWORD syncSourceOut,
00196 OpalRTPSession::JitterBufferPtr jitter,
00197 RTP_ControlFrame & report
00198 );
00199
00200 static OpalRTPSession::ExtendedReportArray
00201 BuildExtendedReportArray(const RTP_ControlFrame & frame, PINDEX offset);
00202
00203
00204 protected:
00213 void markov(
00214 PacketEvent event
00215 );
00216
00219 void ResetCounters();
00220
00223 BYTE RFactor(
00224 QualityType qt
00225 );
00226
00229 BYTE EndOfCallRFactor();
00230
00234 float MOS(
00235 QualityType qt
00236 );
00237
00241 float EndOfCallMOS();
00242
00245 float IdFactor();
00246
00249 float GetPonderateId();
00250
00253 float Ieff(
00254 PeriodType type
00255 );
00256
00259 float GetEndOfCallIe();
00260
00263 float GetPonderateIe();
00264
00267 TimePeriod createTimePeriod(
00268 PeriodType type,
00269 PTime beginTimestamp,
00270 PTime endTimestamp
00271 );
00272
00275 IdPeriod createIdPeriod(
00276 PTime beginTimestamp,
00277 PTime endTimestamp
00278 );
00279
00282 IePeriod createIePeriod(
00283 TimePeriod timePeriod
00284 );
00285
00286
00287 float m_Ie;
00288 float m_Bpl;
00289 float m_lookAheadTime;
00290 PINDEX m_payloadSize;
00291 unsigned m_payloadBitrate;
00292
00293 DWORD m_gmin;
00294 DWORD m_lostInBurst;
00295 DWORD m_packetsReceived;
00296 DWORD m_packetsSinceLastLoss;
00297 DWORD m_packetsLost;
00298 DWORD m_packetsDiscarded;
00299 DWORD m_srPacketsReceived;
00300
00301 DWORD m_packetsReceivedInGap;
00302 DWORD m_packetsLostInGap;
00303
00304 DWORD m_packetsReceivedInBurst;
00305 DWORD m_packetsLostInBurst;
00306
00316 DWORD c5;
00317 DWORD c11;
00318 DWORD c13;
00319 DWORD c14;
00320 DWORD c22;
00321 DWORD c23;
00322 DWORD c31;
00323 DWORD c32;
00324 DWORD c33;
00325
00326
00327 PTime m_lsrTime;
00328 PTimeInterval m_dlsrTime;
00329 PTime m_arrivalTime;
00330
00331 DWORD m_jitterDelay;
00332 float m_lastId;
00333 float m_lastIe;
00334
00335 std::list<TimePeriod> m_timePeriods;
00336 std::list<IePeriod> m_iePeriods;
00337 std::list<IdPeriod> m_idPeriods;
00338
00339 PeriodType m_currentPeriodType;
00340 PTime m_periodBeginTimestamp;
00341 PTime m_lastLossTimestamp;
00342 PTime m_lastLossInBurstTimestamp;
00343 PTime m_lastJitterBufferChangeTimestamp;
00344
00345 };
00346
00347
00348 #endif // OPAL_RTCP_XR
00349
00350 #endif // OPAL_METRICS_H
00351
00352