- report packet loss timeline
This commit is contained in:
@@ -224,11 +224,6 @@ RtpBuffer::FetchResult RtpBuffer::fetch(ResultList& rl)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Did we fetch any packet before ?
|
||||
bool is_fetched_packet = mFetchedPacket.get() != nullptr;
|
||||
if (is_fetched_packet)
|
||||
is_fetched_packet &= mFetchedPacket->rtp().get() != nullptr;
|
||||
|
||||
if (mLastSeqno.has_value())
|
||||
{
|
||||
if (mPacketList.empty())
|
||||
@@ -239,7 +234,8 @@ RtpBuffer::FetchResult RtpBuffer::fetch(ResultList& rl)
|
||||
else
|
||||
{
|
||||
// Current sequence number ?
|
||||
uint32_t seqno = mPacketList.front()->rtp()->GetExtendedSequenceNumber();
|
||||
auto& packet = *mPacketList.front();
|
||||
uint32_t seqno = packet.rtp()->GetExtendedSequenceNumber();
|
||||
|
||||
// Gap between new packet and previous on
|
||||
int gap = (int64_t)seqno - (int64_t)*mLastSeqno - 1;
|
||||
@@ -248,7 +244,8 @@ RtpBuffer::FetchResult RtpBuffer::fetch(ResultList& rl)
|
||||
{
|
||||
// std::cout << "Increase the packet loss for SSRC " << std::hex << mSsrc << std::endl;
|
||||
mStat.mPacketLoss++;
|
||||
//mStat.mLoss[gap]++;
|
||||
auto currentTimestamp = uint64_t(packet.rtp()->GetReceiveTime().GetDouble() * 1000000);
|
||||
mStat.mPacketLossTimeline.push_back({gap, std::chrono::microseconds(currentTimestamp)});
|
||||
mLastSeqno = *mLastSeqno + 1;
|
||||
result = FetchResult::Gap;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "../audio/Audio_Resampler.h"
|
||||
|
||||
#include <optional>
|
||||
#include <chrono>
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace MT
|
||||
{
|
||||
@@ -45,10 +47,15 @@ namespace MT
|
||||
const std::vector<short>& pcm() const;
|
||||
std::vector<short>& pcm();
|
||||
|
||||
const std::chrono::microseconds& timestamp() const;
|
||||
std::chrono::microseconds& timestamp();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<RTPPacket> mRtp;
|
||||
int mTimelength = 0, mRate = 0;
|
||||
int mTimelength = 0,
|
||||
mRate = 0;
|
||||
std::vector<short> mPcm;
|
||||
std::chrono::microseconds mTimestamp = 0us;
|
||||
};
|
||||
|
||||
RtpBuffer(Statistics& stat);
|
||||
|
||||
@@ -50,6 +50,12 @@ protected:
|
||||
float mMaxDelta = 0.0f;
|
||||
};
|
||||
|
||||
struct PacketLossEvent
|
||||
{
|
||||
int mGap = 0;
|
||||
std::chrono::microseconds mTimestamp;
|
||||
};
|
||||
|
||||
class Statistics
|
||||
{
|
||||
public:
|
||||
@@ -86,6 +92,8 @@ public:
|
||||
|
||||
std::map<int, int> mCodecCount; // Stats on used codecs
|
||||
|
||||
std::vector<PacketLossEvent> mPacketLossTimeline; // Packet loss timeline
|
||||
|
||||
// It is to calculate network MOS
|
||||
void calculateBurstr(double* burstr, double* loss) const;
|
||||
double calculateMos(double maximalMos) const;
|
||||
|
||||
Reference in New Issue
Block a user