提交 b9a26d80 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

NackGenerator: upon key frame receipt remove older items in the NACK list.

上级 0fdd6356
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/Codecs/VP8.hpp" #include "RTC/Codecs/VP8.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpDictionaries.hpp" #include "RTC/RtpDictionaries.hpp"
#include "RTC/RtpPacket.hpp"
namespace RTC namespace RTC
{ {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define MS_RTC_CODECS_VP8_HPP #define MS_RTC_CODECS_VP8_HPP
#include "common.hpp" #include "common.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpDictionaries.hpp" #include "RTC/RtpDictionaries.hpp"
#include "RTC/RtpPacket.hpp"
namespace RTC namespace RTC
{ {
......
...@@ -45,6 +45,7 @@ namespace RTC ...@@ -45,6 +45,7 @@ namespace RTC
private: private:
void AddPacketsToNackList(uint32_t seq32Start, uint32_t seq32End); void AddPacketsToNackList(uint32_t seq32Start, uint32_t seq32End);
void RemoveFromNackListOlderThan(uint32_t seq32);
std::vector<uint16_t> GetNackBatch(NackFilter filter); std::vector<uint16_t> GetNackBatch(NackFilter filter);
void MayRunTimer() const; void MayRunTimer() const;
......
...@@ -38,6 +38,7 @@ namespace RTC ...@@ -38,6 +38,7 @@ namespace RTC
virtual Json::Value ToJson() = 0; virtual Json::Value ToJson() = 0;
virtual bool ReceivePacket(RTC::RtpPacket* packet); virtual bool ReceivePacket(RTC::RtpPacket* packet);
uint32_t GetSsrc(); uint32_t GetSsrc();
uint8_t GetPayloadType();
const RTC::RtpCodecMimeType& GetMimeType() const; const RTC::RtpCodecMimeType& GetMimeType() const;
bool IsHealthy(); bool IsHealthy();
...@@ -83,6 +84,11 @@ namespace RTC ...@@ -83,6 +84,11 @@ namespace RTC
return this->params.ssrc; return this->params.ssrc;
} }
inline uint8_t RtpStream::GetPayloadType()
{
return this->params.payloadType;
}
inline const RTC::RtpCodecMimeType& RtpStream::GetMimeType() const inline const RTC::RtpCodecMimeType& RtpStream::GetMimeType() const
{ {
return this->params.mime; return this->params.mime;
......
...@@ -22,8 +22,7 @@ namespace RTC ...@@ -22,8 +22,7 @@ namespace RTC
break; break;
} }
default: default:;
;
} }
} }
} // namespace Codecs } // namespace Codecs
......
...@@ -47,6 +47,10 @@ namespace RTC ...@@ -47,6 +47,10 @@ namespace RTC
return; return;
} }
// If a key frame remove all the items in the nack list older than this seq.
if (packet->IsKeyFrame())
RemoveFromNackListOlderThan(seq32);
// Obviously never nacked, so ignore. // Obviously never nacked, so ignore.
if (seq32 == this->lastSeq32) if (seq32 == this->lastSeq32)
{ {
...@@ -141,8 +145,26 @@ namespace RTC ...@@ -141,8 +145,26 @@ namespace RTC
} }
} }
void NackGenerator::RemoveFromNackListOlderThan(uint32_t seq32)
{
MS_TRACE();
// Delete all the entries in the NACK list whose key (seq32) is older than
// the given one.
MS_ERROR("---- PRE, nackList.size:%zu", this->nackList.size());
auto it = this->nackList.lower_bound(seq32);
this->nackList.erase(this->nackList.begin(), it);
MS_ERROR("---- POST, nackList.size:%zu", this->nackList.size());
}
std::vector<uint16_t> NackGenerator::GetNackBatch(NackFilter filter) std::vector<uint16_t> NackGenerator::GetNackBatch(NackFilter filter)
{ {
MS_TRACE();
uint64_t now = DepLibUV::GetTime(); uint64_t now = DepLibUV::GetTime();
std::vector<uint16_t> nackBatch; std::vector<uint16_t> nackBatch;
auto it = this->nackList.begin(); auto it = this->nackList.begin();
......
...@@ -270,6 +270,10 @@ namespace RTC ...@@ -270,6 +270,10 @@ namespace RTC
{ {
rtpStream = this->rtpStreams[ssrc]; rtpStream = this->rtpStreams[ssrc];
// Process the packet at codec level.
if (packet->GetPayloadType() == rtpStream->GetPayloadType())
Codecs::ProcessRtpPacket(packet, rtpStream->GetMimeType());
// Process the packet. // Process the packet.
if (!rtpStream->ReceivePacket(packet)) if (!rtpStream->ReceivePacket(packet))
return; return;
...@@ -278,6 +282,10 @@ namespace RTC ...@@ -278,6 +282,10 @@ namespace RTC
{ {
rtpStream = this->mapRtxStreams[ssrc]; rtpStream = this->mapRtxStreams[ssrc];
// Process the packet at codec level.
if (packet->GetPayloadType() == rtpStream->GetPayloadType())
Codecs::ProcessRtpPacket(packet, rtpStream->GetMimeType());
// Process the packet. // Process the packet.
if (!rtpStream->ReceiveRtxPacket(packet)) if (!rtpStream->ReceiveRtxPacket(packet))
return; return;
...@@ -300,9 +308,6 @@ namespace RTC ...@@ -300,9 +308,6 @@ namespace RTC
return; return;
} }
// Process the packet at codec level.
Codecs::ProcessRtpPacket(packet, rtpStream->GetMimeType());
if (packet->IsKeyFrame()) if (packet->IsKeyFrame())
{ {
MS_DEBUG_TAG( MS_DEBUG_TAG(
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论