- 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; 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) int RtpHelper::findPayloadLength(const void* buffer, size_t length)
{ {
if (isRtp(buffer, length)) if (isRtp(buffer, length))

View File

@ -35,6 +35,7 @@ class RtpHelper
public: public:
static bool isRtp(const void* buffer, size_t length); static bool isRtp(const void* buffer, size_t length);
static int findPtype(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 isRtpOrRtcp(const void* buffer, size_t length);
static bool isRtcp(const void* buffer, size_t length); static bool isRtcp(const void* buffer, size_t length);
static unsigned findSsrc(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); Lock l(mGuard);
// Update statistics // Update statistics
mStat.mSsrc = packet->GetSSRC(); mStat.mSsrc = static_cast<uint16_t>(packet->GetSSRC());
// Update jitter // Update jitter
ICELogMedia(<< "Adding new packet into jitter buffer"); 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 // Limit by max timelength
available = findTimelength(); 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(); available -= mPacketList.front().timelength();
mPacketList.erase(mPacketList.begin()); mPacketList.erase(mPacketList.begin());
} }*/
} }
else else
{ {
@ -176,6 +178,18 @@ RtpBuffer::FetchResult RtpBuffer::fetch(ResultList& rl)
// See if there is enough information in buffer // See if there is enough information in buffer
int total = findTimelength(); 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) if (total < mLow)
result = FetchResult::NoPacket; result = FetchResult::NoPacket;
else else

View File

@ -314,6 +314,8 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
} }
} }
//ICELogDebug(<< "Packet no: " << RtpHelper::findPacketNo(mReceiveBuffer, receiveLength));
switch (source.family()) switch (source.family())
{ {
case AF_INET: case AF_INET: