- fixed problem with loss packet counter (it was higher than real value)

This commit is contained in:
dmytro.bogovych 2019-03-08 13:01:24 +02:00
parent dca4551222
commit 8e4f2152d2
4 changed files with 31 additions and 6 deletions

View File

@ -79,6 +79,14 @@ int RtpHelper::findPtype(const void* buffer, size_t length)
return -1;
}
int RtpHelper::findPacketNo(const void *buffer, size_t length)
{
if (isRtp(buffer, length))
return ntohs(reinterpret_cast<const RtpHeader*>(buffer)->seq);
else
return -1;
}
int RtpHelper::findPayloadLength(const void* buffer, size_t length)
{
if (isRtp(buffer, length))

View File

@ -35,6 +35,7 @@ class RtpHelper
public:
static bool isRtp(const void* buffer, size_t length);
static int findPtype(const void* buffer, size_t length);
static int findPacketNo(const void* buffer, size_t length);
static bool isRtpOrRtcp(const void* buffer, size_t length);
static bool isRtcp(const void* buffer, size_t length);
static unsigned findSsrc(const void* buffer, size_t length);

View File

@ -108,7 +108,7 @@ bool RtpBuffer::add(std::shared_ptr<jrtplib::RTPPacket> packet, int timelength,
Lock l(mGuard);
// Update statistics
mStat.mSsrc = packet->GetSSRC();
mStat.mSsrc = static_cast<uint16_t>(packet->GetSSRC());
// Update jitter
ICELogMedia(<< "Adding new packet into jitter buffer");
@ -149,12 +149,14 @@ bool RtpBuffer::add(std::shared_ptr<jrtplib::RTPPacket> packet, int timelength,
// Limit by max timelength
available = findTimelength();
while (available > mHigh && mPacketList.size())
if (available > mHigh)
ICELogMedia(<< "Available " << available << "ms with limit " << mHigh << "ms");
/*while (available > mHigh && mPacketList.size())
{
//ICELogMedia( << "Dropping RTP packet from jitter");
ICELogDebug( << "Dropping RTP packet from jitter buffer");
available -= mPacketList.front().timelength();
mPacketList.erase(mPacketList.begin());
}
}*/
}
else
{
@ -176,6 +178,18 @@ RtpBuffer::FetchResult RtpBuffer::fetch(ResultList& rl)
// See if there is enough information in buffer
int total = findTimelength();
while (total > mHigh && mPacketList.size())
{
ICELogMedia( << "Dropping RTP packets from jitter buffer");
total -= mPacketList.front().timelength();
// Save it as last packet however - to not confuse loss packet counter
mFetchedPacket = mPacketList.front();
// Erase from packet list
mPacketList.erase(mPacketList.begin());
}
if (total < mLow)
result = FetchResult::NoPacket;
else

View File

@ -313,7 +313,9 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
return;
}
}
//ICELogDebug(<< "Packet no: " << RtpHelper::findPacketNo(mReceiveBuffer, receiveLength));
switch (source.family())
{
case AF_INET:
@ -362,7 +364,7 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
// Process incoming data packet
rtpStream->process(packet);
double rtt = mRtpSession.GetCurrentSourceInfo()->INF_GetRoundtripTime().GetDouble();
if (rtt > 0)
mStat.mRttDelay.process(rtt);