Skip to content

Commit dc69b20

Browse files
committed
RTCP compound: Properly check if a Sender Report is present
1 parent 5be7578 commit dc69b20

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

worker/include/RTC/RTCP/CompoundPacket.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ namespace RTC
2121
size_t GetSize() const;
2222
size_t GetSenderReportCount() const;
2323
size_t GetReceiverReportCount() const;
24-
void Dump() const;
24+
void Dump();
2525
void AddSenderReport(SenderReport* report);
2626
void AddReceiverReport(ReceiverReport* report);
2727
void AddSdesChunk(SdesChunk* chunk);
28+
bool HasSenderReport();
2829
void Serialize(uint8_t* data);
2930

3031
private:
@@ -66,6 +67,11 @@ namespace RTC
6667
{
6768
this->sdesPacket.AddChunk(chunk);
6869
}
70+
71+
inline bool CompoundPacket::HasSenderReport()
72+
{
73+
return this->senderReportPacket.Begin() != this->senderReportPacket.End();
74+
}
6975
} // namespace RTCP
7076
} // namespace RTC
7177

worker/src/RTC/RTCP/CompoundPacket.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace RTC
1717
this->header = data;
1818

1919
// Calculate the total required size for the entire message.
20-
if (this->senderReportPacket.GetCount() != 0u)
20+
if (HasSenderReport())
2121
{
2222
this->size = this->senderReportPacket.GetSize();
2323

@@ -39,7 +39,7 @@ namespace RTC
3939
// Fill it.
4040
size_t offset{ 0 };
4141

42-
if (this->senderReportPacket.GetCount() != 0u)
42+
if (HasSenderReport())
4343
{
4444
this->senderReportPacket.Serialize(this->header);
4545
offset = this->senderReportPacket.GetSize();
@@ -81,13 +81,13 @@ namespace RTC
8181
this->sdesPacket.Serialize(this->header + offset);
8282
}
8383

84-
void CompoundPacket::Dump() const
84+
void CompoundPacket::Dump()
8585
{
8686
MS_TRACE();
8787

8888
MS_DUMP("<CompoundPacket>");
8989

90-
if (this->senderReportPacket.GetCount() != 0u)
90+
if (HasSenderReport())
9191
{
9292
this->senderReportPacket.Dump();
9393

@@ -105,7 +105,7 @@ namespace RTC
105105

106106
void CompoundPacket::AddSenderReport(SenderReport* report)
107107
{
108-
MS_ASSERT(this->senderReportPacket.GetCount() == 0, "a sender report is already present");
108+
MS_ASSERT(!HasSenderReport(), "a sender report is already present");
109109

110110
this->senderReportPacket.AddReport(report);
111111
}

worker/src/RTC/Transport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ namespace RTC
442442
consumer->GetRtcp(packet.get(), now);
443443

444444
// Send the RTCP compound packet if there is a sender report.
445-
if (packet->GetSenderReportCount() != 0u)
445+
if (packet->HasSenderReport())
446446
{
447447
// Ensure that the RTCP packet fits into the RTCP buffer.
448448
if (packet->GetSize() > RTC::RTCP::BufferSize)

0 commit comments

Comments
 (0)