- cleanups

This commit is contained in:
2025-09-26 12:55:19 +03:00
parent 4e00f659e3
commit eec5aabc42
6 changed files with 87 additions and 156 deletions
+34 -39
View File
@@ -3,15 +3,17 @@
#include <chrono>
#include <map>
#include <optional>
#include <array>
#include "audio/Audio_DataWindow.h"
#include "helper/HL_Optional.hpp"
#include "helper/HL_Statistics.h"
#include "helper/HL_Types.h"
#include "jrtplib/src/rtptimeutilities.h"
#include "jrtplib/src/rtppacket.h"
using std::experimental::optional;
namespace MT
{
@@ -33,59 +35,56 @@ public:
protected:
// Jitter calculation
jrtplib::RTPTime mReceiveTime = jrtplib::RTPTime(0,0);
jrtplib::RTPTime mReceiveTime = jrtplib::RTPTime(0,0);
// Last timestamp from packet in units
uint32_t mReceiveTimestamp = 0;
uint32_t mReceiveTimestamp = 0;
// It is classic jitter value in units
optional<float> mLastJitter;
std::optional<float> mLastJitter;
// Some statistics for jitter value in seconds
TestResult<float> mJitter;
TestResult<float> mJitter;
// Maximal delta in seconds
float mMaxDelta = 0.0f;
float mMaxDelta = 0.0f;
};
class Statistics
{
public:
size_t mReceived = 0, // Received traffic in bytes
mSent = 0, // Sent traffic in bytes
mReceivedRtp = 0, // Number of received rtp packets
mSentRtp = 0, // Number of sent rtp packets
mReceivedRtcp = 0, // Number of received rtcp packets
mSentRtcp = 0, // Number of sent rtcp packets
mDuplicatedRtp = 0, // Number of received duplicated rtp packets
mOldRtp = 0, // Number of late rtp packets
mPacketLoss = 0, // Number of lost packets
mPacketDropped = 0, // Number of dropped packets (due to time unsync when playing)б
mIllegalRtp = 0; // Number of rtp packets with bad payload type
size_t mReceived = 0, // Received traffic in bytes
mSent = 0, // Sent traffic in bytes
mReceivedRtp = 0, // Number of received rtp packets
mSentRtp = 0, // Number of sent rtp packets
mReceivedRtcp = 0, // Number of received rtcp packets
mSentRtcp = 0, // Number of sent rtcp packets
mDuplicatedRtp = 0, // Number of received duplicated rtp packets
mOldRtp = 0, // Number of late rtp packets
mPacketLoss = 0, // Number of lost packets
mPacketDropped = 0, // Number of dropped packets (due to time unsync when playing)б
mIllegalRtp = 0; // Number of rtp packets with bad payload type
TestResult<float> mDecodingInterval, // Average interval on call to packet decode
mDecodeRequested, // Average amount of requested audio frames to play
mPacketInterval; // Average interval between packet adding to jitter buffer
TestResult<float> mDecodingInterval, // Average interval on call to packet decode
mDecodeRequested, // Average amount of requested audio frames to play
mPacketInterval; // Average interval between packet adding to jitter buffer
int mLoss[128] = {0}; // Every item is number of loss of corresping length
size_t mAudioTime = 0; // Decoded/found time in milliseconds
size_t mDecodedSize = 0; // Number of decoded bytes
uint16_t mSsrc = 0; // Last known SSRC ID in a RTP stream
ice::NetworkAddress mRemotePeer; // Last known remote RTP address
std::array<float, 128> mLoss = {0}; // Every item is number of loss of corresping length
size_t mAudioTime = 0; // Decoded/found time in milliseconds
size_t mDecodedSize = 0; // Number of decoded bytes
uint16_t mSsrc = 0; // Last known SSRC ID in a RTP stream
ice::NetworkAddress mRemotePeer; // Last known remote RTP address
// AMR codec bitrate switch counter
int mBitrateSwitchCounter = 0;
std::string mCodecName;
float mJitter = 0.0f; // Jitter
TestResult<float> mRttDelay; // RTT delay
int mBitrateSwitchCounter = 0;
std::string mCodecName;
float mJitter = 0.0f; // Jitter
TestResult<float> mRttDelay; // RTT delay
// Timestamp when first RTP packet has arrived
optional<std::chrono::system_clock::time_point> mFirstRtpTime;
std::optional<timepoint_t> mFirstRtpTime;
std::map<int, int> mCodecCount; // Stats on used codecs
std::map<int, int> mCodecCount; // Stats on used codecs
// It is to calculate network MOS
void calculateBurstr(double* burstr, double* loss) const;
@@ -98,11 +97,7 @@ public:
Statistics& operator += (const Statistics& src);
Statistics& operator -= (const Statistics& src);
float mNetworkMos = 0.0;
#if defined(USE_PVQA_LIBRARY) && !defined(PVQA_SERVER)
float mPvqaMos = 0.0;
std::string mPvqaReport;
#endif
float mNetworkMos = 0.0f;
std::string toString() const;
};