metrics.h
Go to the documentation of this file.
/*
* metrics.h
*
* E-Model implementation
*
* Open Phone Abstraction Library (OPAL)
*
* Copyright (c) 2010 Universidade Federal do Amazonas
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27699 $
* $Author: rjongbloed $
* $Date: 2012-05-24 20:35:37 -0500 (Thu, 24 May 2012) $
*/
#ifndef OPAL_RTP_METRICS_H
#define OPAL_RTP_METRICS_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#if OPAL_RTCP_XR
#include <rtp/rtp.h>
#include <list>
class RTP_Session;
class RTP_DataFrame;
// RTCP-XR - VoIP Metrics Report Block
class RTCP_XR_Metrics
{
protected:
RTCP_XR_Metrics(
float Ie,
float Bpl,
float lookAheadTime,
PINDEX payloadSize,
unsigned payloadBitrate
);
public:
static RTCP_XR_Metrics * Create(const RTP_DataFrame & frame);
~RTCP_XR_Metrics();
enum PacketEvent {
PACKET_RECEIVED,
PACKET_DISCARDED,
PACKET_LOST
};
enum PeriodType {
GAP, /* a period of low packet losses and/or discards */
BURST, /* a period of a high proportion of packet losses and/or discards */
};
/* A period of time, which can be a burst or a gap */
typedef struct TimePeriod {
PeriodType type;
PTimeInterval duration;
} TimePeriod;
typedef struct IdPeriod {
PTimeInterval duration;
float Id;
} IdPeriod;
typedef struct IePeriod {
PeriodType type;
PTimeInterval duration;
float Ieff;
} IePeriod;
enum QualityType {
LQ, /* Listening Quality, not include the effects of delay */
CQ /* Conversational Quality, include the effects of delay */
};
void SetJitterDelay(
DWORD delay
);
void OnPacketReceived();
void OnPacketDiscarded();
void OnPacketLost();
void OnPacketLost(
DWORD dropped
);
void OnRxSenderReport(
PUInt32b lsr,
PUInt32b dlsr
);
BYTE GetLossRate();
BYTE GetDiscardRate();
BYTE GetBurstDensity();
BYTE GetGapDensity();
PUInt16b GetBurstDuration();
PUInt16b GetGapDuration();
PUInt16b GetRoundTripDelay ();
PUInt16b GetEndSystemDelay();
BYTE RFactor();
BYTE MOS_LQ();
BYTE MOS_CQ();
// Internal functions
void InsertExtendedReportPacket(
unsigned sessionID,
DWORD syncSourceOut,
RTP_Session::JitterBufferPtr jitter, // Note do not make JitterBufferPtr a reference, needs to be a copy
RTP_ControlFrame & report
);
static RTP_Session::ExtendedReportArray
BuildExtendedReportArray(const RTP_ControlFrame & frame, PINDEX offset);
protected:
void markov(
PacketEvent event
);
void ResetCounters();
BYTE RFactor(
QualityType qt
);
BYTE EndOfCallRFactor();
float MOS(
QualityType qt
);
float EndOfCallMOS();
float IdFactor();
float GetPonderateId();
float Ieff(
PeriodType type
);
float GetEndOfCallIe();
float GetPonderateIe();
TimePeriod createTimePeriod(
PeriodType type,
PTime beginTimestamp,
PTime endTimestamp
);
IdPeriod createIdPeriod(
PTime beginTimestamp,
PTime endTimestamp
);
IePeriod createIePeriod(
TimePeriod timePeriod
);
/* data associated with the payload */
float m_Ie; /* equipment impairment factor for the codec utilized */
float m_Bpl; /* robustness factor for the codec utilized */
float m_lookAheadTime; /* codec lookahead time */
PINDEX m_payloadSize;
unsigned m_payloadBitrate;
DWORD m_gmin; /* gap threshold */
DWORD m_lostInBurst; /* number of lost packets within the current burst */
DWORD m_packetsReceived; /* packets received since the beggining of the reception */
DWORD m_packetsSinceLastLoss; /* packets received since the last loss or discard event */
DWORD m_packetsLost; /* packets lost since the beggining of the reception */
DWORD m_packetsDiscarded; /* packets discarded since the beggining of the receptions */
DWORD m_srPacketsReceived; /* count of SR packets received */
DWORD m_packetsReceivedInGap; /* packets received within gap periods */
DWORD m_packetsLostInGap; /* packets lost within gap periods */
DWORD m_packetsReceivedInBurst; /* packets received within burst periods */
DWORD m_packetsLostInBurst; /* packets lost within burst periods */
DWORD c5;
DWORD c11;
DWORD c13;
DWORD c14;
DWORD c22;
DWORD c23;
DWORD c31;
DWORD c32;
DWORD c33;
/* variables to calculate round trip delay */
PTime m_lsrTime;
PTimeInterval m_dlsrTime;
PTime m_arrivalTime;
DWORD m_jitterDelay; /* jitter buffer delay, in milliseconds */
float m_lastId; /* last Id calculated */
float m_lastIe; /* last Ie calculated */
std::list<TimePeriod> m_timePeriods;
std::list<IePeriod> m_iePeriods;
std::list<IdPeriod> m_idPeriods;
PeriodType m_currentPeriodType; /* indicates if we are within a gap or burst */
PTime m_periodBeginTimestamp; /* timestamp of the beginning of the gap or burst period */
PTime m_lastLossTimestamp; /* timestamp of the last loss */
PTime m_lastLossInBurstTimestamp; /* timestamp of the last loss within a burst period */
PTime m_lastJitterBufferChangeTimestamp; /* timestamp of the last change in jitter buffer size */
};
#endif // OPAL_RTCP_XR
#endif // OPAL_METRICS_H
RTP_Session
Definition: rtp.h:502
buildopts.h
RTP_DataFrame
Definition: rtp.h:71
RTP_Session::JitterBufferPtr
PSafePtr< RTP_JitterBuffer, PSafePtrMultiThreaded > JitterBufferPtr
Definition: rtp.h:1005
rtp.h
RTP_ControlFrame
Definition: rtp.h:190