Cleanup RtcpReceiver tests
update MOCK_METHODs to use new syntax recommended in go/totw/164 Replace fixture with struct of mocks. Use main method under test (IncomingPacket) directly rather than through fixture helpers minor cleanup of the RtcReceiver itself: make IncomingPacket function more friendly to containers, mark class as final to verify ability to inherit from it is not used and thus destructor doesn't need to be virtual. Bug: None Change-Id: I346e7dc513b1fbe663ebe5858dec7df0520416a7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170226 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30765}
This commit is contained in:

committed by
Commit Bot

parent
3bc8123247
commit
443f26695f
@ -172,14 +172,14 @@ RTCPReceiver::RTCPReceiver(const RtpRtcp::Configuration& config,
|
||||
|
||||
RTCPReceiver::~RTCPReceiver() {}
|
||||
|
||||
void RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) {
|
||||
if (packet_size == 0) {
|
||||
void RTCPReceiver::IncomingPacket(rtc::ArrayView<const uint8_t> packet) {
|
||||
if (packet.empty()) {
|
||||
RTC_LOG(LS_WARNING) << "Incoming empty RTCP packet";
|
||||
return;
|
||||
}
|
||||
|
||||
PacketInformation packet_information;
|
||||
if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information))
|
||||
if (!ParseCompoundPacket(packet, &packet_information))
|
||||
return;
|
||||
TriggerCallbacksFromRtcpPacket(packet_information);
|
||||
}
|
||||
@ -325,18 +325,17 @@ std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RTCPReceiver::ParseCompoundPacket(const uint8_t* packet_begin,
|
||||
const uint8_t* packet_end,
|
||||
bool RTCPReceiver::ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
|
||||
PacketInformation* packet_information) {
|
||||
rtc::CritScope lock(&rtcp_receiver_lock_);
|
||||
|
||||
CommonHeader rtcp_block;
|
||||
for (const uint8_t* next_block = packet_begin; next_block != packet_end;
|
||||
for (const uint8_t* next_block = packet.begin(); next_block != packet.end();
|
||||
next_block = rtcp_block.NextPacket()) {
|
||||
ptrdiff_t remaining_blocks_size = packet_end - next_block;
|
||||
ptrdiff_t remaining_blocks_size = packet.end() - next_block;
|
||||
RTC_DCHECK_GT(remaining_blocks_size, 0);
|
||||
if (!rtcp_block.Parse(next_block, remaining_blocks_size)) {
|
||||
if (next_block == packet_begin) {
|
||||
if (next_block == packet.begin()) {
|
||||
// Failed to parse 1st header, nothing was extracted from this packet.
|
||||
RTC_LOG(LS_WARNING) << "Incoming invalid RTCP packet";
|
||||
return false;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "modules/rtp_rtcp/include/report_block_data.h"
|
||||
#include "modules/rtp_rtcp/include/rtcp_statistics.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
@ -37,7 +38,7 @@ class TargetBitrate;
|
||||
class TmmbItem;
|
||||
} // namespace rtcp
|
||||
|
||||
class RTCPReceiver {
|
||||
class RTCPReceiver final {
|
||||
public:
|
||||
class ModuleRtpRtcp {
|
||||
public:
|
||||
@ -53,9 +54,12 @@ class RTCPReceiver {
|
||||
};
|
||||
|
||||
RTCPReceiver(const RtpRtcp::Configuration& config, ModuleRtpRtcp* owner);
|
||||
virtual ~RTCPReceiver();
|
||||
~RTCPReceiver();
|
||||
|
||||
void IncomingPacket(const uint8_t* packet, size_t packet_size);
|
||||
void IncomingPacket(const uint8_t* packet, size_t packet_size) {
|
||||
IncomingPacket(rtc::MakeArrayView(packet, packet_size));
|
||||
}
|
||||
void IncomingPacket(rtc::ArrayView<const uint8_t> packet);
|
||||
|
||||
int64_t LastReceivedReportBlockMs() const;
|
||||
|
||||
@ -124,8 +128,7 @@ class RTCPReceiver {
|
||||
// RTCP report blocks map mapped by source SSRC.
|
||||
using ReportBlockMap = std::map<uint32_t, ReportBlockDataMap>;
|
||||
|
||||
bool ParseCompoundPacket(const uint8_t* packet_begin,
|
||||
const uint8_t* packet_end,
|
||||
bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
|
||||
PacketInformation* packet_information);
|
||||
|
||||
void TriggerCallbacksFromRtcpPacket(
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user