Reason for revert: About to fix problem and reland. Original issue's description: > Revert of Create RtcpDemuxer (patchset #13 id:240001 of https://codereview.webrtc.org/2943693003/ ) > > Reason for revert: > Breaks Chromium FYI bots. > > The problem is in the BUILD.gn file. > > Sample failure: > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/17829 > > Sample logs: > use_goma = true > """ to /b/c/b/Linux_Builder/src/out/Release/args.gn. > > /b/c/b/Linux_Builder/src/buildtools/linux64/gn gen //out/Release --check > -> returned 1 > ERROR at //third_party/webrtc/call/BUILD.gn:46:5: Can't load input file. > "//webrtc/base:rtc_base_approved", > ^-------------------------------- > > Original issue's description: > > Create RtcpDemuxer. Capabilities: > > 1. Demux RTCP messages according to the sender-SSRC. > > 2. Demux RTCP messages according to the RSID (resolved to an SSRC, then compared to the sender-RTCP). > > 3. Allow listening in on all RTCP messages passing through the demuxer ("broadcast sinks"). > > > > BUG=webrtc:7135 > > > > Review-Url: https://codereview.webrtc.org/2943693003 > > Cr-Commit-Position: refs/heads/master@{#18763} > > Committed:cb83bdf01f> > BUG=webrtc:7135 > > Review-Url: https://codereview.webrtc.org/2957763002 > Cr-Commit-Position: refs/heads/master@{#18764} > Committed:0e7e7869e7BUG=webrtc:7135 Review-Url: https://codereview.webrtc.org/2960623002 Cr-Commit-Position: refs/heads/master@{#18768}
120 lines
4.0 KiB
C++
120 lines
4.0 KiB
C++
/*
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include <cstdio>
|
|
|
|
#include "webrtc/call/rtp_rtcp_demuxer_helper.h"
|
|
|
|
#include "webrtc/base/arraysize.h"
|
|
#include "webrtc/base/basictypes.h"
|
|
#include "webrtc/base/buffer.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
|
|
#include "webrtc/test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
|
|
namespace {
|
|
constexpr uint32_t kSsrc = 8374;
|
|
} // namespace
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ByePacket) {
|
|
webrtc::rtcp::Bye rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest,
|
|
ParseRtcpPacketSenderSsrc_ExtendedReportsPacket) {
|
|
webrtc::rtcp::ExtendedReports rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_PsfbPacket) {
|
|
webrtc::rtcp::Pli rtcp_packet; // Psfb is abstract; use a subclass.
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ReceiverReportPacket) {
|
|
webrtc::rtcp::ReceiverReport rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_RtpfbPacket) {
|
|
// Rtpfb is abstract; use a subclass.
|
|
webrtc::rtcp::RapidResyncRequest rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_SenderReportPacket) {
|
|
webrtc::rtcp::SenderReport rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_EQ(ssrc, kSsrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_MalformedRtcpPacket) {
|
|
uint8_t garbage[100];
|
|
memset(&garbage[0], 0, arraysize(garbage));
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(garbage);
|
|
EXPECT_FALSE(ssrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest,
|
|
ParseRtcpPacketSenderSsrc_RtcpMessageWithoutSenderSsrc) {
|
|
webrtc::rtcp::ExtendedJitterReport rtcp_packet; // Has no sender SSRC.
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
|
|
EXPECT_FALSE(ssrc);
|
|
}
|
|
|
|
TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_TruncatedRtcpMessage) {
|
|
webrtc::rtcp::Bye rtcp_packet;
|
|
rtcp_packet.SetSenderSsrc(kSsrc);
|
|
rtc::Buffer raw_packet = rtcp_packet.Build();
|
|
|
|
constexpr size_t rtcp_length_bytes = 8;
|
|
ASSERT_EQ(rtcp_length_bytes, raw_packet.size());
|
|
|
|
rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(
|
|
rtc::ArrayView<const uint8_t>(raw_packet.data(), rtcp_length_bytes - 1));
|
|
EXPECT_FALSE(ssrc);
|
|
}
|
|
|
|
} // namespace webrtc
|