Skip to content

Commit

Permalink
RTCP compound: Properly check if a Sender Report is present
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Oct 24, 2017
1 parent 5be7578 commit dc69b20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion worker/include/RTC/RTCP/CompoundPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions worker/src/RTC/RTCP/CompoundPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand Down Expand Up @@ -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();

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion worker/src/RTC/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc69b20

Please sign in to comment.