- cleanups
This commit is contained in:
parent
4e00f659e3
commit
eec5aabc42
|
|
@ -481,41 +481,6 @@ void AgentImpl::processWaitForEvent(JsonCpp::Value &request, JsonCpp::Value &ans
|
|||
answer["status"] = Status_Ok;
|
||||
}
|
||||
|
||||
#if defined(USE_PVQA_LIBRARY)
|
||||
/*static JsonCpp::Value CsvReportToJson(const std::string& report)
|
||||
{
|
||||
JsonCpp::Value detectorValues;
|
||||
std::istringstream iss(report);
|
||||
CsvReader reader(iss);
|
||||
std::vector<std::string> cells;
|
||||
if (reader.readLine(cells))
|
||||
{
|
||||
JsonCpp::Value detectorNames;
|
||||
for (size_t nameIndex = 0; nameIndex < cells.size(); nameIndex++)
|
||||
detectorNames[static_cast<int>(nameIndex)] = strx::trim(cells[nameIndex]);
|
||||
// Put first line name of columns
|
||||
detectorValues[0] = detectorNames;
|
||||
|
||||
int rowIndex = 1;
|
||||
while (reader.readLine(cells))
|
||||
{
|
||||
// Skip last column for now
|
||||
JsonCpp::Value row;
|
||||
for (size_t valueIndex = 0; valueIndex < cells.size(); valueIndex++)
|
||||
{
|
||||
bool isFloat = true;
|
||||
float v = strx::toFloat(cells[valueIndex], 0.0, &isFloat);
|
||||
if (isFloat)
|
||||
row[static_cast<int>(valueIndex)] = static_cast<double>(v);
|
||||
else
|
||||
row[static_cast<int>(valueIndex)] = cells[valueIndex];
|
||||
}
|
||||
detectorValues[rowIndex++] = row;
|
||||
}
|
||||
}
|
||||
return detectorValues;
|
||||
}*/
|
||||
#endif
|
||||
|
||||
void AgentImpl::processGetMediaStats(JsonCpp::Value& request, JsonCpp::Value& answer)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -445,7 +445,6 @@ void Session::getSessionInfo(Session::InfoOptions options, VariantMap& info)
|
|||
MT::Statistics stat;
|
||||
|
||||
// Iterate all session providers
|
||||
stat.reset();
|
||||
Stream* media = nullptr;
|
||||
for (Stream& stream: mStreamList)
|
||||
{
|
||||
|
|
@ -469,7 +468,7 @@ void Session::getSessionInfo(Session::InfoOptions options, VariantMap& info)
|
|||
info[SessionInfo_SentRtp] = static_cast<int>(stat.mSentRtp);
|
||||
info[SessionInfo_SentRtcp] = static_cast<int>(stat.mSentRtcp);
|
||||
if (stat.mFirstRtpTime)
|
||||
info[SessionInfo_Duration] = static_cast<int>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - *(stat.mFirstRtpTime)).count());
|
||||
info[SessionInfo_Duration] = static_cast<int>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - *(stat.mFirstRtpTime)).count());
|
||||
else
|
||||
info[SessionInfo_Duration] = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -157,4 +157,8 @@ private:
|
|||
std::unordered_map<V, K, HashV, EqV> reverse_;
|
||||
};
|
||||
|
||||
#include <chrono>
|
||||
typedef std::chrono::steady_clock::time_point timepoint_t;
|
||||
typedef std::chrono::steady_clock monoclock_t;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -347,8 +347,8 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
|
|||
mStat.mReceived += length;
|
||||
if (RtpHelper::isRtp(mReceiveBuffer, receiveLength))
|
||||
{
|
||||
if (!mStat.mFirstRtpTime.is_initialized())
|
||||
mStat.mFirstRtpTime = std::chrono::system_clock::now();
|
||||
if (!mStat.mFirstRtpTime)
|
||||
mStat.mFirstRtpTime = std::chrono::steady_clock::now();
|
||||
mStat.mReceivedRtp++;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#include "MT_Statistics.h"
|
||||
#include "audio/Audio_Interface.h"
|
||||
#include "helper/HL_Log.h"
|
||||
#define LOG_SUBSYSTEM "Statistics"
|
||||
|
||||
using namespace MT;
|
||||
|
|
@ -14,7 +12,7 @@ void JitterStatistics::process(jrtplib::RTPPacket* packet, int rate)
|
|||
uint32_t timestamp = packet->GetTimestamp();
|
||||
jrtplib::RTPTime receiveTime = packet->GetReceiveTime();
|
||||
|
||||
if (!mLastJitter.is_initialized())
|
||||
if (!mLastJitter)
|
||||
{
|
||||
// First packet
|
||||
mReceiveTime = receiveTime;
|
||||
|
|
@ -69,40 +67,10 @@ void JitterStatistics::process(jrtplib::RTPPacket* packet, int rate)
|
|||
|
||||
|
||||
Statistics::Statistics()
|
||||
:mReceived(0), mSent(0), mReceivedRtp(0), mSentRtp(0),
|
||||
mReceivedRtcp(0), mSentRtcp(0), mDuplicatedRtp(0), mOldRtp(0), mIllegalRtp(0),
|
||||
mPacketLoss(0), mJitter(0.0), mAudioTime(0), mDecodedSize(0), mSsrc(0), mPacketDropped(0)
|
||||
{
|
||||
mBitrateSwitchCounter = 0;
|
||||
memset(mLoss, 0, sizeof mLoss);
|
||||
|
||||
// It is to keep track of statistics instance via grep | wc -l
|
||||
//ICELogDebug(<< "Create statistics instance.");
|
||||
}
|
||||
{}
|
||||
|
||||
Statistics::~Statistics()
|
||||
{
|
||||
}
|
||||
|
||||
void Statistics::reset()
|
||||
{
|
||||
mReceived = 0;
|
||||
mSent = 0;
|
||||
mReceivedRtp = 0;
|
||||
mSentRtp = 0;
|
||||
mReceivedRtcp = 0;
|
||||
mSentRtcp = 0;
|
||||
mDuplicatedRtp = 0;
|
||||
mOldRtp = 0;
|
||||
mPacketLoss = 0;
|
||||
mIllegalRtp = 0;
|
||||
mJitter = 0.0;
|
||||
mAudioTime = 0;
|
||||
mPacketDropped = 0;
|
||||
mDecodedSize = 0;
|
||||
|
||||
memset(mLoss, 0, sizeof mLoss);
|
||||
}
|
||||
{}
|
||||
|
||||
void Statistics::calculateBurstr(double* burstr, double* lossr) const
|
||||
{
|
||||
|
|
@ -131,7 +99,7 @@ void Statistics::calculateBurstr(double* burstr, double* lossr) const
|
|||
}
|
||||
else
|
||||
*burstr = 0;
|
||||
//printf("total loss: %d\n", lost);
|
||||
|
||||
if (mReceivedRtp > 0)
|
||||
*lossr = (double)((double)lost / (double)mReceivedRtp);
|
||||
else
|
||||
|
|
@ -203,16 +171,16 @@ Statistics& Statistics::operator += (const Statistics& src)
|
|||
mCodecName = src.mCodecName;
|
||||
|
||||
// Find minimal
|
||||
if (mFirstRtpTime.is_initialized())
|
||||
if (mFirstRtpTime)
|
||||
{
|
||||
if (src.mFirstRtpTime.is_initialized())
|
||||
if (src.mFirstRtpTime)
|
||||
{
|
||||
if (mFirstRtpTime.value() > src.mFirstRtpTime.value())
|
||||
mFirstRtpTime = src.mFirstRtpTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (src.mFirstRtpTime.is_initialized())
|
||||
if (src.mFirstRtpTime)
|
||||
mFirstRtpTime = src.mFirstRtpTime;
|
||||
|
||||
mBitrateSwitchCounter += src.mBitrateSwitchCounter;
|
||||
|
|
@ -235,8 +203,8 @@ Statistics& Statistics::operator -= (const Statistics& src)
|
|||
mOldRtp -= src.mOldRtp;
|
||||
mPacketLoss -= src.mPacketLoss;
|
||||
mPacketDropped -= src.mPacketDropped;
|
||||
|
||||
mAudioTime -= src.mAudioTime;
|
||||
|
||||
for (auto codecStat: src.mCodecCount)
|
||||
{
|
||||
if (mCodecCount.find(codecStat.first) != mCodecCount.end())
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -39,7 +41,7 @@ protected:
|
|||
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;
|
||||
|
|
@ -67,7 +69,7 @@ public:
|
|||
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
|
||||
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
|
||||
|
|
@ -75,15 +77,12 @@ public:
|
|||
|
||||
// AMR codec bitrate switch counter
|
||||
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
|
||||
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue