Unify helpers IsRtpPacket and IsRtcpPacket

Bug: None
Change-Id: Ibe942de433435d256cd6827440136936d4b274d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225022
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34419}
This commit is contained in:
Danil Chapovalov 2021-07-05 19:06:17 +02:00 committed by WebRTC LUCI CQ
parent 93ce46fc63
commit 00ca0044d4
23 changed files with 208 additions and 110 deletions

View file

@ -47,7 +47,7 @@
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/utility/include/process_thread.h"
#include "modules/video_coding/fec_controller_default.h"
#include "rtc_base/checks.h"
@ -144,11 +144,6 @@ std::unique_ptr<rtclog::StreamConfig> CreateRtcLogStreamConfig(
return rtclog_config;
}
bool IsRtcp(const uint8_t* packet, size_t length) {
RtpUtility::RtpHeaderParser rtp_parser(packet, length);
return rtp_parser.RTCP();
}
TaskQueueBase* GetCurrentTaskQueueOrThread() {
TaskQueueBase* current = TaskQueueBase::Current();
if (!current)
@ -1606,7 +1601,7 @@ PacketReceiver::DeliveryStatus Call::DeliverPacket(
MediaType media_type,
rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) {
if (IsRtcp(packet.cdata(), packet.size())) {
if (IsRtcpPacket(packet)) {
RTC_DCHECK_RUN_ON(network_thread_);
DeliverRtcp(media_type, std::move(packet));
return DELIVERY_OK;

View file

@ -17,6 +17,7 @@
// PacketTimeUpdateParams is defined in asyncpacketsocket.h.
// TODO(sergeyu): Find more appropriate place for PacketTimeUpdateParams.
#include "media/base/turn_utils.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/byte_order.h"
#include "rtc_base/checks.h"
@ -279,29 +280,6 @@ bool SetRtpHeader(void* data, size_t len, const RtpHeader& header) {
SetRtpSsrc(data, len, header.ssrc));
}
static bool HasCorrectRtpVersion(rtc::ArrayView<const uint8_t> packet) {
return packet.data()[0] >> 6 == kRtpVersion;
}
bool IsRtpPacket(rtc::ArrayView<const char> packet) {
return packet.size() >= kMinRtpPacketLen &&
HasCorrectRtpVersion(
rtc::reinterpret_array_view<const uint8_t>(packet));
}
// Check the RTP payload type. If 63 < payload type < 96, it's RTCP.
// For additional details, see http://tools.ietf.org/html/rfc5761.
bool IsRtcpPacket(rtc::ArrayView<const char> packet) {
if (packet.size() < kMinRtcpPacketLen ||
!HasCorrectRtpVersion(
rtc::reinterpret_array_view<const uint8_t>(packet))) {
return false;
}
char pt = packet[1] & 0x7F;
return (63 < pt) && (pt < 96);
}
bool IsValidRtpPayloadType(int payload_type) {
return payload_type >= 0 && payload_type <= 127;
}
@ -327,11 +305,11 @@ absl::string_view RtpPacketTypeToString(RtpPacketType packet_type) {
}
RtpPacketType InferRtpPacketType(rtc::ArrayView<const char> packet) {
// RTCP packets are RTP packets so must check that first.
if (IsRtcpPacket(packet)) {
if (webrtc::IsRtcpPacket(
rtc::reinterpret_array_view<const uint8_t>(packet))) {
return RtpPacketType::kRtcp;
}
if (IsRtpPacket(packet)) {
if (webrtc::IsRtpPacket(rtc::reinterpret_array_view<const uint8_t>(packet))) {
return RtpPacketType::kRtp;
}
return RtpPacketType::kUnknown;
@ -532,7 +510,7 @@ bool ApplyPacketOptions(uint8_t* data,
// Making sure we have a valid RTP packet at the end.
auto packet = rtc::MakeArrayView(data + rtp_start_pos, rtp_length);
if (!IsRtpPacket(rtc::reinterpret_array_view<const char>(packet)) ||
if (!webrtc::IsRtpPacket(packet) ||
!ValidateRtpHeader(data + rtp_start_pos, rtp_length, nullptr)) {
RTC_NOTREACHED();
return false;

View file

@ -62,9 +62,6 @@ bool SetRtpSsrc(void* data, size_t len, uint32_t value);
// Assumes version 2, no padding, no extensions, no csrcs.
bool SetRtpHeader(void* data, size_t len, const RtpHeader& header);
bool IsRtpPacket(rtc::ArrayView<const char> packet);
bool IsRtcpPacket(rtc::ArrayView<const char> packet);
// Checks the packet header to determine if it can be an RTP or RTCP packet.
RtpPacketType InferRtpPacketType(rtc::ArrayView<const char> packet);
// True if |payload type| is 0-127.

View file

@ -102,8 +102,6 @@ static const rtc::ArrayView<const char> kInvalidPacketArrayView =
sizeof(kInvalidPacket));
TEST(RtpUtilsTest, GetRtp) {
EXPECT_TRUE(IsRtpPacket(kPcmuFrameArrayView));
int pt;
EXPECT_TRUE(GetRtpPayloadType(kPcmuFrame, sizeof(kPcmuFrame), &pt));
EXPECT_EQ(0, pt);

View file

@ -52,6 +52,7 @@ rtc_library("rtp_rtcp_format") {
"source/rtp_packet.h",
"source/rtp_packet_received.h",
"source/rtp_packet_to_send.h",
"source/rtp_util.h",
"source/rtp_video_layers_allocation_extension.h",
]
sources = [
@ -96,6 +97,7 @@ rtc_library("rtp_rtcp_format") {
"source/rtp_packet.cc",
"source/rtp_packet_received.cc",
"source/rtp_packet_to_send.cc",
"source/rtp_util.cc",
"source/rtp_video_layers_allocation_extension.cc",
]
@ -548,6 +550,7 @@ if (rtc_include_tests) {
"source/rtp_sender_unittest.cc",
"source/rtp_sender_video_unittest.cc",
"source/rtp_sequence_number_map_unittest.cc",
"source/rtp_util_unittest.cc",
"source/rtp_utility_unittest.cc",
"source/rtp_video_layers_allocation_extension_unittest.cc",
"source/source_tracker_unittest.cc",

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2021 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 "modules/rtp_rtcp/source/rtp_util.h"
#include <cstddef>
#include <cstdint>
#include "api/array_view.h"
namespace webrtc {
namespace {
constexpr uint8_t kRtpVersion = 2;
constexpr size_t kMinRtpPacketLen = 12;
constexpr size_t kMinRtcpPacketLen = 4;
bool HasCorrectRtpVersion(rtc::ArrayView<const uint8_t> packet) {
return packet[0] >> 6 == kRtpVersion;
}
// For additional details, see http://tools.ietf.org/html/rfc5761#section-4
bool PayloadTypeIsReservedForRtcp(uint8_t payload_type) {
return 64 <= payload_type && payload_type < 96;
}
} // namespace
bool IsRtpPacket(rtc::ArrayView<const uint8_t> packet) {
return packet.size() >= kMinRtpPacketLen && HasCorrectRtpVersion(packet) &&
!PayloadTypeIsReservedForRtcp(packet[1] & 0x7F);
}
bool IsRtcpPacket(rtc::ArrayView<const uint8_t> packet) {
return packet.size() >= kMinRtcpPacketLen && HasCorrectRtpVersion(packet) &&
PayloadTypeIsReservedForRtcp(packet[1] & 0x7F);
}
} // namespace webrtc

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 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.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_UTIL_H_
#define MODULES_RTP_RTCP_SOURCE_RTP_UTIL_H_
#include <cstdint>
#include "api/array_view.h"
namespace webrtc {
bool IsRtcpPacket(rtc::ArrayView<const uint8_t> packet);
bool IsRtpPacket(rtc::ArrayView<const uint8_t> packet);
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_RTP_UTIL_H_

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 2021 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 "modules/rtp_rtcp/source/rtp_util.h"
#include "test/gmock.h"
namespace webrtc {
namespace {
TEST(RtpUtil, IsRtpPacket) {
constexpr uint8_t kMinimalisticRtpPacket[] = {0x80, 97, 0, 0, //
0, 0, 0, 0, //
0, 0, 0, 0};
EXPECT_TRUE(IsRtpPacket(kMinimalisticRtpPacket));
constexpr uint8_t kWrongRtpVersion[] = {0xc0, 97, 0, 0, //
0, 0, 0, 0, //
0, 0, 0, 0};
EXPECT_FALSE(IsRtpPacket(kWrongRtpVersion));
constexpr uint8_t kPacketWithPayloadForRtcp[] = {0x80, 200, 0, 0, //
0, 0, 0, 0, //
0, 0, 0, 0};
EXPECT_FALSE(IsRtpPacket(kPacketWithPayloadForRtcp));
constexpr uint8_t kTooSmallRtpPacket[] = {0x80, 97, 0, 0, //
0, 0, 0, 0, //
0, 0, 0};
EXPECT_FALSE(IsRtpPacket(kTooSmallRtpPacket));
EXPECT_FALSE(IsRtpPacket({}));
}
TEST(RtpUtil, IsRtcpPacket) {
constexpr uint8_t kMinimalisticRtcpPacket[] = {0x80, 202, 0, 0};
EXPECT_TRUE(IsRtcpPacket(kMinimalisticRtcpPacket));
constexpr uint8_t kWrongRtpVersion[] = {0xc0, 202, 0, 0};
EXPECT_FALSE(IsRtcpPacket(kWrongRtpVersion));
constexpr uint8_t kPacketWithPayloadForRtp[] = {0x80, 225, 0, 0};
EXPECT_FALSE(IsRtcpPacket(kPacketWithPayloadForRtp));
constexpr uint8_t kTooSmallRtcpPacket[] = {0x80, 202, 0};
EXPECT_FALSE(IsRtcpPacket(kTooSmallRtcpPacket));
EXPECT_FALSE(IsRtcpPacket({}));
}
} // namespace
} // namespace webrtc

View file

@ -15,6 +15,7 @@
#include <algorithm>
#include "absl/base/attributes.h"
#include "absl/strings/string_view.h"
#include "api/rtp_headers.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
@ -34,6 +35,7 @@ class RtpHeaderParser {
RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength);
~RtpHeaderParser();
ABSL_DEPRECATED("Use IsRtpPacket or IsRtcpPacket")
bool RTCP() const;
bool ParseRtcp(RTPHeader* header) const;
bool Parse(RTPHeader* parsedPacket,

View file

@ -736,7 +736,6 @@ rtc_library("direct_transport") {
"direct_transport.h",
]
deps = [
":rtp_test_utils",
"../api:sequence_checker",
"../api:simulated_network_api",
"../api:transport_api",
@ -744,6 +743,7 @@ rtc_library("direct_transport") {
"../api/units:time_delta",
"../call:call_interfaces",
"../call:simulated_packet_receiver",
"../modules/rtp_rtcp:rtp_rtcp_format",
"../rtc_base:macromagic",
"../rtc_base:timeutils",
"../rtc_base/synchronization:mutex",
@ -848,9 +848,9 @@ rtc_library("test_common") {
":fake_video_codecs",
":fileutils",
":mock_transport",
":rtp_test_utils",
":test_support",
":video_test_common",
"../api:array_view",
"../api:create_frame_generator",
"../api:frame_generator_api",
"../api:rtp_headers",

View file

@ -14,9 +14,9 @@
#include "api/units/time_delta.h"
#include "call/call.h"
#include "call/fake_network_pipe.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/time_utils.h"
#include "test/rtp_header_parser.h"
namespace webrtc {
namespace test {
@ -26,7 +26,7 @@ Demuxer::Demuxer(const std::map<uint8_t, MediaType>& payload_type_map)
MediaType Demuxer::GetMediaType(const uint8_t* packet_data,
const size_t packet_length) const {
if (!RtpHeaderParser::IsRtcp(packet_data, packet_length)) {
if (IsRtpPacket(rtc::MakeArrayView(packet_data, packet_length))) {
RTC_CHECK_GE(packet_length, 2);
const uint8_t payload_type = packet_data[1] & 0x7f;
std::map<uint8_t, MediaType>::const_iterator it =

View file

@ -18,12 +18,13 @@ namespace test {
TEST(DemuxerTest, Demuxing) {
constexpr uint8_t kVideoPayloadType = 100;
constexpr uint8_t kAudioPayloadType = 101;
constexpr size_t kPacketSize = 10;
constexpr size_t kPacketSize = 12;
Demuxer demuxer({{kVideoPayloadType, MediaType::VIDEO},
{kAudioPayloadType, MediaType::AUDIO}});
uint8_t data[kPacketSize];
memset(data, 0, kPacketSize);
data[0] = 0x80;
data[1] = kVideoPayloadType;
EXPECT_EQ(demuxer.GetMediaType(data, kPacketSize), MediaType::VIDEO);
data[1] = kAudioPayloadType;

View file

@ -20,7 +20,6 @@
namespace webrtc {
void FuzzOneInput(const uint8_t* data, size_t size) {
RtpHeaderParser::IsRtcp(data, size);
RtpHeaderParser::GetSsrc(data, size);
}

View file

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "pc/media_session.h"
#include "pc/session_description.h"
@ -29,7 +30,7 @@ absl::optional<RTPHeaderExtension> GetRtpPacketExtensions(
const rtc::ArrayView<const uint8_t> packet,
const RtpHeaderExtensionMap& extension_map) {
RtpUtility::RtpHeaderParser rtp_parser(packet.data(), packet.size());
if (!rtp_parser.RTCP()) {
if (IsRtpPacket(packet)) {
RTPHeader header;
if (rtp_parser.Parse(&header, &extension_map, true)) {
return header.extension;

View file

@ -10,15 +10,14 @@
#include "media/base/stream_params.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "pc/media_session.h"
#include "pc/session_description.h"
#include "test/field_trial.h"
#include "test/peer_scenario/peer_scenario.h"
#include "test/rtp_header_parser.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/peer_scenario/peer_scenario.h"
#include "test/rtp_header_parser.h"
namespace webrtc {
namespace test {
@ -184,51 +183,48 @@ TEST_P(UnsignaledStreamTest, ReplacesUnsignaledStreamOnCompletedSignaling) {
second_ssrc = first_ssrc + 1;
send_node->router()->SetWatcher([&](const EmulatedIpPacket& packet) {
if (packet.size() > 1 && packet.cdata()[0] >> 6 == 2 &&
!RtpHeaderParser::IsRtcp(packet.data.cdata(),
packet.data.size())) {
if (ByteReader<uint32_t>::ReadBigEndian(&(packet.cdata()[8])) ==
first_ssrc &&
!got_unsignaled_packet) {
// Parse packet and modify the SSRC to simulate a second m=
// section that has not been negotiated yet.
std::vector<RtpExtension> extensions;
extensions.emplace_back(RtpExtension::kMidUri,
mid_header_extension_id.value());
RtpHeaderExtensionMap extensions_map(extensions);
RtpPacket parsed_packet;
parsed_packet.IdentifyExtensions(extensions_map);
ASSERT_TRUE(parsed_packet.Parse(packet.data));
parsed_packet.SetSsrc(second_ssrc);
// The MID extension is present if and only if it was negotiated.
// If present, we either want to remove it or modify it depending
// on setup.
switch (kMidTestConfiguration) {
case MidTestConfiguration::kMidNotNegotiated:
EXPECT_FALSE(parsed_packet.HasExtension<RtpMid>());
break;
case MidTestConfiguration::kMidNegotiatedButMissingFromPackets:
EXPECT_TRUE(parsed_packet.HasExtension<RtpMid>());
ASSERT_TRUE(parsed_packet.RemoveExtension(RtpMid::kId));
break;
case MidTestConfiguration::kMidNegotiatedAndPresentInPackets:
EXPECT_TRUE(parsed_packet.HasExtension<RtpMid>());
// The simulated second m= section would have a different MID.
// If we don't modify it here then |second_ssrc| would end up
// being mapped to the first m= section which would cause SSRC
// conflicts if we later add the same SSRC to a second m=
// section. Hidden assumption: first m= section does not use
// MID:1.
ASSERT_TRUE(parsed_packet.SetExtension<RtpMid>("1"));
break;
}
// Inject the modified packet.
rtc::CopyOnWriteBuffer updated_buffer = parsed_packet.Buffer();
EmulatedIpPacket updated_packet(
packet.from, packet.to, updated_buffer, packet.arrival_time);
send_node->OnPacketReceived(std::move(updated_packet));
got_unsignaled_packet = true;
if (IsRtpPacket(packet.data) &&
ByteReader<uint32_t>::ReadBigEndian(&(packet.cdata()[8])) ==
first_ssrc &&
!got_unsignaled_packet) {
// Parse packet and modify the SSRC to simulate a second m=
// section that has not been negotiated yet.
std::vector<RtpExtension> extensions;
extensions.emplace_back(RtpExtension::kMidUri,
mid_header_extension_id.value());
RtpHeaderExtensionMap extensions_map(extensions);
RtpPacket parsed_packet;
parsed_packet.IdentifyExtensions(extensions_map);
ASSERT_TRUE(parsed_packet.Parse(packet.data));
parsed_packet.SetSsrc(second_ssrc);
// The MID extension is present if and only if it was negotiated.
// If present, we either want to remove it or modify it depending
// on setup.
switch (kMidTestConfiguration) {
case MidTestConfiguration::kMidNotNegotiated:
EXPECT_FALSE(parsed_packet.HasExtension<RtpMid>());
break;
case MidTestConfiguration::kMidNegotiatedButMissingFromPackets:
EXPECT_TRUE(parsed_packet.HasExtension<RtpMid>());
ASSERT_TRUE(parsed_packet.RemoveExtension(RtpMid::kId));
break;
case MidTestConfiguration::kMidNegotiatedAndPresentInPackets:
EXPECT_TRUE(parsed_packet.HasExtension<RtpMid>());
// The simulated second m= section would have a different MID.
// If we don't modify it here then |second_ssrc| would end up
// being mapped to the first m= section which would cause SSRC
// conflicts if we later add the same SSRC to a second m=
// section. Hidden assumption: first m= section does not use
// MID:1.
ASSERT_TRUE(parsed_packet.SetExtension<RtpMid>("1"));
break;
}
// Inject the modified packet.
rtc::CopyOnWriteBuffer updated_buffer = parsed_packet.Buffer();
EmulatedIpPacket updated_packet(
packet.from, packet.to, updated_buffer, packet.arrival_time);
send_node->OnPacketReceived(std::move(updated_packet));
got_unsignaled_packet = true;
}
});
},

View file

@ -17,6 +17,7 @@
#include <string>
#include <vector>
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
@ -434,7 +435,7 @@ class PcapReader : public RtpFileReaderImpl {
TRY_PCAP(Read(read_buffer_, marker.payload_length));
RtpUtility::RtpHeaderParser rtp_parser(read_buffer_, marker.payload_length);
if (rtp_parser.RTCP()) {
if (IsRtcpPacket(rtc::MakeArrayView(read_buffer_, marker.payload_length))) {
rtp_parser.ParseRtcp(&marker.rtp_header);
packets_.push_back(marker);
} else {

View file

@ -13,11 +13,6 @@
namespace webrtc {
bool RtpHeaderParser::IsRtcp(const uint8_t* packet, size_t length) {
RtpUtility::RtpHeaderParser rtp_parser(packet, length);
return rtp_parser.RTCP();
}
absl::optional<uint32_t> RtpHeaderParser::GetSsrc(const uint8_t* packet,
size_t length) {
RtpUtility::RtpHeaderParser rtp_parser(packet, length);

View file

@ -19,8 +19,6 @@ namespace webrtc {
class RtpHeaderParser {
public:
// Returns true if the packet is an RTCP packet, false otherwise.
static bool IsRtcp(const uint8_t* packet, size_t length);
static absl::optional<uint32_t> GetSsrc(const uint8_t* packet, size_t length);
};
} // namespace webrtc

View file

@ -15,14 +15,15 @@
#include <utility>
#include <vector>
#include "api/array_view.h"
#include "api/test/simulated_network.h"
#include "call/simulated_packet_receiver.h"
#include "call/video_send_stream.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/event.h"
#include "system_wrappers/include/field_trial.h"
#include "test/direct_transport.h"
#include "test/gtest.h"
#include "test/rtp_header_parser.h"
namespace {
const int kShortTimeoutMs = 500;
@ -98,7 +99,7 @@ class PacketTransport : public test::DirectTransport {
bool SendRtp(const uint8_t* packet,
size_t length,
const PacketOptions& options) override {
EXPECT_FALSE(RtpHeaderParser::IsRtcp(packet, length));
EXPECT_TRUE(IsRtpPacket(rtc::MakeArrayView(packet, length)));
RtpRtcpObserver::Action action;
{
if (transport_type_ == kSender) {
@ -118,7 +119,7 @@ class PacketTransport : public test::DirectTransport {
}
bool SendRtcp(const uint8_t* packet, size_t length) override {
EXPECT_TRUE(RtpHeaderParser::IsRtcp(packet, length));
EXPECT_TRUE(IsRtcpPacket(rtc::MakeArrayView(packet, length)));
RtpRtcpObserver::Action action;
{
if (transport_type_ == kSender) {

View file

@ -17,6 +17,7 @@
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/transport/network_types.h"
#include "modules/audio_mixer/audio_mixer_impl.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "test/rtp_header_parser.h"
namespace webrtc {
@ -293,7 +294,7 @@ void CallClient::UpdateBitrateConstraints(
void CallClient::OnPacketReceived(EmulatedIpPacket packet) {
MediaType media_type = MediaType::ANY;
if (!RtpHeaderParser::IsRtcp(packet.cdata(), packet.data.size())) {
if (IsRtpPacket(packet.data)) {
auto ssrc = RtpHeaderParser::GetSsrc(packet.cdata(), packet.data.size());
RTC_CHECK(ssrc.has_value());
media_type = ssrc_media_types_[*ssrc];

View file

@ -14,6 +14,7 @@
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/task_queue_for_test.h"
#include "test/call_test.h"
#include "test/gtest.h"
@ -60,7 +61,7 @@ TEST_F(SsrcEndToEndTest, UnknownRtpPacketGivesUnknownSsrcReturnCode) {
DeliveryStatus DeliverPacket(MediaType media_type,
rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) override {
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size())) {
if (IsRtcpPacket(packet)) {
return receiver_->DeliverPacket(media_type, std::move(packet),
packet_time_us);
}

View file

@ -18,6 +18,7 @@
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/cpu_time.h"
#include "rtc_base/format_macros.h"
#include "rtc_base/memory_usage.h"
@ -212,7 +213,7 @@ PacketReceiver::DeliveryStatus VideoAnalyzer::DeliverPacket(
int64_t packet_time_us) {
// Ignore timestamps of RTCP packets. They're not synchronized with
// RTP packet timestamps and so they would confuse wrap_handler_.
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size())) {
if (IsRtcpPacket(packet)) {
return receiver_->DeliverPacket(media_type, std::move(packet),
packet_time_us);
}

View file

@ -30,6 +30,7 @@
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h"
@ -57,7 +58,6 @@
#include "test/gtest.h"
#include "test/null_transport.h"
#include "test/rtcp_packet_parser.h"
#include "test/rtp_header_parser.h"
#include "test/testsupport/perf_test.h"
#include "test/video_encoder_proxy_factory.h"
#include "video/send_statistics_proxy.h"
@ -1467,7 +1467,7 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) {
private:
Action OnSendRtp(const uint8_t* packet, size_t length) override {
if (RtpHeaderParser::IsRtcp(packet, length))
if (IsRtcpPacket(rtc::MakeArrayView(packet, length)))
return DROP_PACKET;
RtpPacket rtp_packet;