Migrate away from legacy rtp parser in test/
Bug: None
Change-Id: I71e4a352b67a304df44454b36352285e8b11e4b5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226742
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34551}
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 9172eb3..d645621 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -517,6 +517,7 @@
":test_support_test_artifacts",
":video_test_common",
":video_test_support",
+ "../api:array_view",
"../api:create_frame_generator",
"../api:create_simulcast_test_fixture_api",
"../api:frame_generator_api",
@@ -530,7 +531,6 @@
"../call:video_stream_api",
"../common_video",
"../media:rtc_media_base",
- "../modules/rtp_rtcp",
"../modules/rtp_rtcp:rtp_rtcp_format",
"../modules/video_coding:simulcast_test_fixture_impl",
"../modules/video_coding:video_codec_interface",
diff --git a/test/peer_scenario/tests/BUILD.gn b/test/peer_scenario/tests/BUILD.gn
index 042b636..dd72473 100644
--- a/test/peer_scenario/tests/BUILD.gn
+++ b/test/peer_scenario/tests/BUILD.gn
@@ -21,7 +21,6 @@
"../../:field_trial",
"../../:test_support",
"../../../media:rtc_media_base",
- "../../../modules/rtp_rtcp:rtp_rtcp",
"../../../modules/rtp_rtcp:rtp_rtcp_format",
"../../../pc:rtc_pc_base",
"../../../pc:session_description",
diff --git a/test/peer_scenario/tests/remote_estimate_test.cc b/test/peer_scenario/tests/remote_estimate_test.cc
index f1d8345..429a5b4 100644
--- a/test/peer_scenario/tests/remote_estimate_test.cc
+++ b/test/peer_scenario/tests/remote_estimate_test.cc
@@ -8,8 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
+#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
+#include "modules/rtp_rtcp/source/rtp_packet.h"
#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"
#include "test/field_trial.h"
@@ -26,19 +28,6 @@
return RtpHeaderExtensionMap(audio_desc->rtp_header_extensions());
}
-absl::optional<RTPHeaderExtension> GetRtpPacketExtensions(
- const rtc::ArrayView<const uint8_t> packet,
- const RtpHeaderExtensionMap& extension_map) {
- RtpUtility::RtpHeaderParser rtp_parser(packet.data(), packet.size());
- if (IsRtpPacket(packet)) {
- RTPHeader header;
- if (rtp_parser.Parse(&header, &extension_map, true)) {
- return header.extension;
- }
- }
- return absl::nullopt;
-}
-
} // namespace
TEST(RemoteEstimateEndToEnd, OfferedCapabilityIsInAnswer) {
@@ -106,13 +95,10 @@
// The dummy packets used by the fake signaling are filled with 0. We
// want to ignore those and we can do that on the basis that the first
// byte of RTP packets are guaranteed to not be 0.
- // TODO(srte): Find a more elegant way to check for RTP traffic.
- if (packet.size() > 1 && packet.cdata()[0] != 0) {
- auto extensions = GetRtpPacketExtensions(packet.data, extension_map);
- if (extensions) {
- EXPECT_TRUE(extensions->hasAbsoluteSendTime);
- received_abs_send_time = true;
- }
+ RtpPacket rtp_packet(&extension_map);
+ if (rtp_packet.Parse(packet.data)) {
+ EXPECT_TRUE(rtp_packet.HasExtension<AbsoluteSendTime>());
+ received_abs_send_time = true;
}
});
RTC_CHECK(s.WaitAndProcess(&received_abs_send_time));
diff --git a/test/rtp_file_reader_unittest.cc b/test/rtp_file_reader_unittest.cc
index 8dc817d..995d9fb 100644
--- a/test/rtp_file_reader_unittest.cc
+++ b/test/rtp_file_reader_unittest.cc
@@ -13,7 +13,8 @@
#include <map>
#include <memory>
-#include "modules/rtp_rtcp/source/rtp_utility.h"
+#include "api/array_view.h"
+#include "modules/rtp_rtcp/source/rtp_util.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
@@ -84,11 +85,9 @@
PacketsPerSsrc pps;
test::RtpPacket packet;
while (rtp_packet_source_->NextPacket(&packet)) {
- RtpUtility::RtpHeaderParser rtp_header_parser(packet.data, packet.length);
- webrtc::RTPHeader header;
- if (!rtp_header_parser.RTCP() &&
- rtp_header_parser.Parse(&header, nullptr)) {
- pps[header.ssrc]++;
+ rtc::ArrayView<const uint8_t> raw(packet.data, packet.length);
+ if (IsRtpPacket(raw)) {
+ pps[ParseRtpSsrc(raw)]++;
}
}
return pps;