提交 dc69b20c authored 作者: José Luis Millán's avatar José Luis Millán

RTCP compound: Properly check if a Sender Report is present

上级 5be7578a
......@@ -21,10 +21,11 @@ namespace RTC
size_t GetSize() const;
size_t GetSenderReportCount() const;
size_t GetReceiverReportCount() const;
void Dump() const;
void Dump();
void AddSenderReport(SenderReport* report);
void AddReceiverReport(ReceiverReport* report);
void AddSdesChunk(SdesChunk* chunk);
bool HasSenderReport();
void Serialize(uint8_t* data);
private:
......@@ -66,6 +67,11 @@ namespace RTC
{
this->sdesPacket.AddChunk(chunk);
}
inline bool CompoundPacket::HasSenderReport()
{
return this->senderReportPacket.Begin() != this->senderReportPacket.End();
}
} // namespace RTCP
} // namespace RTC
......
......@@ -17,7 +17,7 @@ namespace RTC
this->header = data;
// Calculate the total required size for the entire message.
if (this->senderReportPacket.GetCount() != 0u)
if (HasSenderReport())
{
this->size = this->senderReportPacket.GetSize();
......@@ -39,7 +39,7 @@ namespace RTC
// Fill it.
size_t offset{ 0 };
if (this->senderReportPacket.GetCount() != 0u)
if (HasSenderReport())
{
this->senderReportPacket.Serialize(this->header);
offset = this->senderReportPacket.GetSize();
......@@ -81,13 +81,13 @@ namespace RTC
this->sdesPacket.Serialize(this->header + offset);
}
void CompoundPacket::Dump() const
void CompoundPacket::Dump()
{
MS_TRACE();
MS_DUMP("<CompoundPacket>");
if (this->senderReportPacket.GetCount() != 0u)
if (HasSenderReport())
{
this->senderReportPacket.Dump();
......@@ -105,7 +105,7 @@ namespace RTC
void CompoundPacket::AddSenderReport(SenderReport* report)
{
MS_ASSERT(this->senderReportPacket.GetCount() == 0, "a sender report is already present");
MS_ASSERT(!HasSenderReport(), "a sender report is already present");
this->senderReportPacket.AddReport(report);
}
......
......@@ -442,7 +442,7 @@ namespace RTC
consumer->GetRtcp(packet.get(), now);
// Send the RTCP compound packet if there is a sender report.
if (packet->GetSenderReportCount() != 0u)
if (packet->HasSenderReport())
{
// Ensure that the RTCP packet fits into the RTCP buffer.
if (packet->GetSize() > RTC::RTCP::BufferSize)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论