Unverified 提交 e952f34f authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

RTCP `CompoundPacket`: Use a single DLRR block to hold all ssrc infos (#1237)

上级 1ed3a247
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
### NEXT ### NEXT
* Fix RTCP SDES packet size calculation ([PR #1236](https://github.com/versatica/mediasoup/pull/1236) based on PR [PR #1234](https://github.com/versatica/mediasoup/pull/1234) by @ybybwdwd). * Fix RTCP SDES packet size calculation ([PR #1236](https://github.com/versatica/mediasoup/pull/1236) based on PR [PR #1234](https://github.com/versatica/mediasoup/pull/1234) by @ybybwdwd).
* RTCP Compound Packet: Use a single DLRR report to hold all ssrc info sub-blocks ([PR #1237](https://github.com/versatica/mediasoup/pull/1237)).
### 3.13.4 ### 3.13.4
......
...@@ -48,14 +48,16 @@ namespace RTC ...@@ -48,14 +48,16 @@ namespace RTC
// Adds the given data and returns true if there is enough space to hold it, // Adds the given data and returns true if there is enough space to hold it,
// false otherwise. // false otherwise.
bool Add( bool Add(
SenderReport* senderReport, SdesChunk* sdesChunk, DelaySinceLastRr* delaySinceLastRrReport); SenderReport* senderReport,
SdesChunk* sdesChunk,
DelaySinceLastRr::SsrcInfo* delaySinceLastRrSsrcInfo);
// RTCP additions per Consumer (pipe). // RTCP additions per Consumer (pipe).
// Adds the given data and returns true if there is enough space to hold it, // Adds the given data and returns true if there is enough space to hold it,
// false otherwise. // false otherwise.
bool Add( bool Add(
std::vector<SenderReport*>& senderReports, std::vector<SenderReport*>& senderReports,
std::vector<SdesChunk*>& sdesChunks, std::vector<SdesChunk*>& sdesChunks,
std::vector<DelaySinceLastRr*>& delaySinceLastRrReports); std::vector<DelaySinceLastRr::SsrcInfo*>& delaySinceLastRrSsrcInfos);
// RTCP additions per Producer. // RTCP additions per Producer.
// Adds the given data and returns true if there is enough space to hold it, // Adds the given data and returns true if there is enough space to hold it,
// false otherwise. // false otherwise.
...@@ -63,8 +65,6 @@ namespace RTC ...@@ -63,8 +65,6 @@ namespace RTC
void AddSenderReport(SenderReport* report); void AddSenderReport(SenderReport* report);
void AddReceiverReport(ReceiverReport* report); void AddReceiverReport(ReceiverReport* report);
void AddSdesChunk(SdesChunk* chunk); void AddSdesChunk(SdesChunk* chunk);
void AddReceiverReferenceTime(ReceiverReferenceTime* report);
void AddDelaySinceLastRr(DelaySinceLastRr* report);
bool HasSenderReport() bool HasSenderReport()
{ {
return this->senderReportPacket.Begin() != this->senderReportPacket.End(); return this->senderReportPacket.Begin() != this->senderReportPacket.End();
...@@ -77,6 +77,14 @@ namespace RTC ...@@ -77,6 +77,14 @@ namespace RTC
[](const ExtendedReportBlock* report) [](const ExtendedReportBlock* report)
{ return report->GetType() == ExtendedReportBlock::Type::RRT; }); { return report->GetType() == ExtendedReportBlock::Type::RRT; });
} }
bool HasDelaySinceLastRr()
{
return std::any_of(
this->xrPacket.Begin(),
this->xrPacket.End(),
[](const ExtendedReportBlock* report)
{ return report->GetType() == ExtendedReportBlock::Type::DLRR; });
}
void Serialize(uint8_t* data); void Serialize(uint8_t* data);
private: private:
...@@ -85,6 +93,7 @@ namespace RTC ...@@ -85,6 +93,7 @@ namespace RTC
ReceiverReportPacket receiverReportPacket; ReceiverReportPacket receiverReportPacket;
SdesPacket sdesPacket; SdesPacket sdesPacket;
ExtendedReportPacket xrPacket; ExtendedReportPacket xrPacket;
DelaySinceLastRr* delaySinceLastRr{ nullptr };
}; };
} // namespace RTCP } // namespace RTCP
} // namespace RTC } // namespace RTC
......
...@@ -119,6 +119,19 @@ namespace RTC ...@@ -119,6 +119,19 @@ namespace RTC
{ {
this->ssrcInfos.push_back(ssrcInfo); this->ssrcInfos.push_back(ssrcInfo);
} }
// NOTE: This method not only removes given number of ssrc info sub-blocks
// but also deletes their SsrcInfo instances.
void RemoveLastSsrcInfos(size_t number)
{
while (!this->ssrcInfos.empty() && number-- > 0)
{
auto* ssrcInfo = this->ssrcInfos.back();
this->ssrcInfos.pop_back();
delete ssrcInfo;
}
}
Iterator Begin() Iterator Begin()
{ {
return this->ssrcInfos.begin(); return this->ssrcInfos.begin();
......
...@@ -37,7 +37,7 @@ namespace RTC ...@@ -37,7 +37,7 @@ namespace RTC
void ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report); void ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report);
void ReceiveRtcpXrReceiverReferenceTime(RTC::RTCP::ReceiverReferenceTime* report); void ReceiveRtcpXrReceiverReferenceTime(RTC::RTCP::ReceiverReferenceTime* report);
RTC::RTCP::SenderReport* GetRtcpSenderReport(uint64_t nowMs); RTC::RTCP::SenderReport* GetRtcpSenderReport(uint64_t nowMs);
RTC::RTCP::DelaySinceLastRr::SsrcInfo* GetRtcpXrDelaySinceLastRr(uint64_t nowMs); RTC::RTCP::DelaySinceLastRr::SsrcInfo* GetRtcpXrDelaySinceLastRrSsrcInfo(uint64_t nowMs);
RTC::RTCP::SdesChunk* GetRtcpSdesChunk(); RTC::RTCP::SdesChunk* GetRtcpSdesChunk();
void Pause() override; void Pause() override;
void Resume() override; void Resume() override;
......
...@@ -345,7 +345,7 @@ namespace RTC ...@@ -345,7 +345,7 @@ namespace RTC
std::vector<RTCP::SenderReport*> senderReports; std::vector<RTCP::SenderReport*> senderReports;
std::vector<RTCP::SdesChunk*> sdesChunks; std::vector<RTCP::SdesChunk*> sdesChunks;
std::vector<RTCP::DelaySinceLastRr*> xrReports; std::vector<RTCP::DelaySinceLastRr::SsrcInfo*> delaySinceLastRrSsrcInfos;
for (auto* rtpStream : this->rtpStreams) for (auto* rtpStream : this->rtpStreams)
{ {
...@@ -362,19 +362,16 @@ namespace RTC ...@@ -362,19 +362,16 @@ namespace RTC
auto* sdesChunk = rtpStream->GetRtcpSdesChunk(); auto* sdesChunk = rtpStream->GetRtcpSdesChunk();
sdesChunks.push_back(sdesChunk); sdesChunks.push_back(sdesChunk);
auto* dlrr = rtpStream->GetRtcpXrDelaySinceLastRr(nowMs); auto* delaySinceLastRrSsrcInfo = rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
if (dlrr) if (delaySinceLastRrSsrcInfo)
{ {
auto* report = new RTC::RTCP::DelaySinceLastRr(); delaySinceLastRrSsrcInfos.push_back(delaySinceLastRrSsrcInfo);
report->AddSsrcInfo(dlrr);
xrReports.push_back(report);
} }
} }
// RTCP Compound packet buffer cannot hold the data. // RTCP Compound packet buffer cannot hold the data.
if (!packet->Add(senderReports, sdesChunks, xrReports)) if (!packet->Add(senderReports, sdesChunks, delaySinceLastRrSsrcInfos))
{ {
return false; return false;
} }
......
...@@ -72,7 +72,9 @@ namespace RTC ...@@ -72,7 +72,9 @@ namespace RTC
} }
bool CompoundPacket::Add( bool CompoundPacket::Add(
SenderReport* senderReport, SdesChunk* sdesChunk, DelaySinceLastRr* delaySinceLastRrReport) SenderReport* senderReport,
SdesChunk* sdesChunk,
DelaySinceLastRr::SsrcInfo* delaySinceLastRrSsrcInfo)
{ {
// Add the items into the packet. // Add the items into the packet.
...@@ -86,9 +88,16 @@ namespace RTC ...@@ -86,9 +88,16 @@ namespace RTC
this->sdesPacket.AddChunk(sdesChunk); this->sdesPacket.AddChunk(sdesChunk);
} }
if (delaySinceLastRrReport) if (delaySinceLastRrSsrcInfo)
{ {
this->xrPacket.AddReport(delaySinceLastRrReport); // Add a DLRR block into the XR packet if no present.
if (!this->delaySinceLastRr)
{
this->delaySinceLastRr = new RTC::RTCP::DelaySinceLastRr();
this->xrPacket.AddReport(this->delaySinceLastRr);
}
this->delaySinceLastRr->AddSsrcInfo(delaySinceLastRrSsrcInfo);
} }
// New items can hold in the packet, report it. // New items can hold in the packet, report it.
...@@ -112,10 +121,10 @@ namespace RTC ...@@ -112,10 +121,10 @@ namespace RTC
delete sdesChunk; delete sdesChunk;
} }
if (delaySinceLastRrReport) if (delaySinceLastRrSsrcInfo)
{ {
this->xrPacket.RemoveReport(delaySinceLastRrReport); // NOTE: This method deletes the removed instances in place.
delete delaySinceLastRrReport; this->delaySinceLastRr->RemoveLastSsrcInfos(1);
} }
return false; return false;
...@@ -124,7 +133,7 @@ namespace RTC ...@@ -124,7 +133,7 @@ namespace RTC
bool CompoundPacket::Add( bool CompoundPacket::Add(
std::vector<SenderReport*>& senderReports, std::vector<SenderReport*>& senderReports,
std::vector<SdesChunk*>& sdesChunks, std::vector<SdesChunk*>& sdesChunks,
std::vector<DelaySinceLastRr*>& delaySinceLastRrReports) std::vector<DelaySinceLastRr::SsrcInfo*>& delaySinceLastRrSsrcInfos)
{ {
// Add the items into the packet. // Add the items into the packet.
...@@ -138,9 +147,16 @@ namespace RTC ...@@ -138,9 +147,16 @@ namespace RTC
this->sdesPacket.AddChunk(chunk); this->sdesPacket.AddChunk(chunk);
} }
for (auto* report : delaySinceLastRrReports) // Add a DLRR block into the XR packet if no present.
if (!delaySinceLastRrSsrcInfos.empty() && !this->delaySinceLastRr)
{ {
this->xrPacket.AddReport(report); this->delaySinceLastRr = new RTC::RTCP::DelaySinceLastRr();
this->xrPacket.AddReport(this->delaySinceLastRr);
}
for (auto* ssrcInfo : delaySinceLastRrSsrcInfos)
{
this->delaySinceLastRr->AddSsrcInfo(ssrcInfo);
} }
// New items can hold in the packet, report it. // New items can hold in the packet, report it.
...@@ -164,10 +180,10 @@ namespace RTC ...@@ -164,10 +180,10 @@ namespace RTC
delete chunk; delete chunk;
} }
for (auto* report : delaySinceLastRrReports) if (!delaySinceLastRrSsrcInfos.empty())
{ {
this->xrPacket.RemoveReport(report); // NOTE: This method deletes the instances in place.
delete report; this->delaySinceLastRr->RemoveLastSsrcInfos(delaySinceLastRrSsrcInfos.size());
} }
return false; return false;
...@@ -266,19 +282,5 @@ namespace RTC ...@@ -266,19 +282,5 @@ namespace RTC
this->sdesPacket.AddChunk(chunk); this->sdesPacket.AddChunk(chunk);
} }
void CompoundPacket::AddReceiverReferenceTime(ReceiverReferenceTime* report)
{
MS_TRACE();
this->xrPacket.AddReport(report);
}
void CompoundPacket::AddDelaySinceLastRr(DelaySinceLastRr* report)
{
MS_TRACE();
this->xrPacket.AddReport(report);
}
} // namespace RTCP } // namespace RTCP
} // namespace RTC } // namespace RTC
...@@ -274,7 +274,7 @@ namespace RTC ...@@ -274,7 +274,7 @@ namespace RTC
return report; return report;
} }
RTC::RTCP::DelaySinceLastRr::SsrcInfo* RtpStreamSend::GetRtcpXrDelaySinceLastRr(uint64_t nowMs) RTC::RTCP::DelaySinceLastRr::SsrcInfo* RtpStreamSend::GetRtcpXrDelaySinceLastRrSsrcInfo(uint64_t nowMs)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -439,18 +439,10 @@ namespace RTC ...@@ -439,18 +439,10 @@ namespace RTC
// Build SDES chunk for this sender. // Build SDES chunk for this sender.
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk(); auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
RTC::RTCP::DelaySinceLastRr* delaySinceLastRrReport{ nullptr }; auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
if (dlrr)
{
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
delaySinceLastRrReport->AddSsrcInfo(dlrr);
}
// RTCP Compound packet buffer cannot hold the data. // RTCP Compound packet buffer cannot hold the data.
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrReport)) if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
{ {
return false; return false;
} }
......
...@@ -1081,18 +1081,10 @@ namespace RTC ...@@ -1081,18 +1081,10 @@ namespace RTC
// Build SDES chunk for this sender. // Build SDES chunk for this sender.
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk(); auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
RTC::RTCP::DelaySinceLastRr* delaySinceLastRrReport{ nullptr }; auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
if (dlrr)
{
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
delaySinceLastRrReport->AddSsrcInfo(dlrr);
}
// RTCP Compound packet buffer cannot hold the data. // RTCP Compound packet buffer cannot hold the data.
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrReport)) if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
{ {
return false; return false;
} }
......
...@@ -795,18 +795,10 @@ namespace RTC ...@@ -795,18 +795,10 @@ namespace RTC
// Build SDES chunk for this sender. // Build SDES chunk for this sender.
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk(); auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
RTC::RTCP::DelaySinceLastRr* delaySinceLastRrReport{ nullptr }; auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
if (dlrr)
{
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
delaySinceLastRrReport->AddSsrcInfo(dlrr);
}
// RTCP Compound packet buffer cannot hold the data. // RTCP Compound packet buffer cannot hold the data.
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrReport)) if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
{ {
return false; return false;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论