From 3d6e7f8a3a08edd6f2a79e1f0472cf3b5b0fae87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Tue, 28 Feb 2023 15:38:57 +0100 Subject: [PATCH] Add simulcast test coverage for H264. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test only exists #if defined(WEBRTC_USE_H264) because H264 is not available in all testing environments (e.g. Android bots fail without these guards). Bug: webrtc:14884 Change-Id: Ic1ff6b16f49f6666df042304ee98d826778da122 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295508 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Henrik Boström Reviewed-by: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#39424} --- pc/peer_connection_simulcast_unittest.cc | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index af0c8c0f71..c1ac00a5a9 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -1112,6 +1112,56 @@ TEST_F(PeerConnectionSimulcastWithMediaFlowTests, EXPECT_THAT(*outbound_rtps[2]->scalability_mode, StartsWith("L1T")); } +#if defined(WEBRTC_USE_H264) + +TEST_F(PeerConnectionSimulcastWithMediaFlowTests, + SendingThreeEncodings_H264_Simulcast) { + rtc::scoped_refptr local_pc_wrapper = CreatePc(); + rtc::scoped_refptr remote_pc_wrapper = CreatePc(); + ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); + + std::vector layers = + CreateLayers({"f", "h", "q"}, /*active=*/true); + rtc::scoped_refptr transceiver = + AddTransceiverWithSimulcastLayers(local_pc_wrapper, remote_pc_wrapper, + layers); + std::vector codecs = + GetCapabilitiesAndRestrictToCodec(local_pc_wrapper, "H264"); + transceiver->SetCodecPreferences(codecs); + + NegotiateWithSimulcastTweaks(local_pc_wrapper, remote_pc_wrapper, layers); + local_pc_wrapper->WaitForConnection(); + remote_pc_wrapper->WaitForConnection(); + + // Wait until media is flowing on all three layers. + // Ramp up time is needed before all three layers are sending. + EXPECT_TRUE_WAIT(HasOutboundRtpBytesSent(local_pc_wrapper, 3u), + kLongTimeoutForRampingUp.ms()); + // No significant additional ramp up time should be needed so we use + // `kDefaultTimeout` and `log_during_ramp_up`. + EXPECT_TRUE_WAIT(HasOutboundRtpExpectedResolutions( + local_pc_wrapper, + {{"f", 320, 180}, {"h", 640, 360}, {"q", 1280, 720}}, + /*log_during_ramp_up=*/true), + kDefaultTimeout.ms()); + // Verify codec and scalability mode. + rtc::scoped_refptr report = GetStats(local_pc_wrapper); + std::vector outbound_rtps = + report->GetStatsOfType(); + ASSERT_THAT(outbound_rtps, SizeIs(3u)); + EXPECT_THAT(GetCurrentCodecMimeType(report, *outbound_rtps[0]), + StrCaseEq("video/H264")); + EXPECT_THAT(GetCurrentCodecMimeType(report, *outbound_rtps[1]), + StrCaseEq("video/H264")); + EXPECT_THAT(GetCurrentCodecMimeType(report, *outbound_rtps[2]), + StrCaseEq("video/H264")); + EXPECT_THAT(*outbound_rtps[0]->scalability_mode, StartsWith("L1T")); + EXPECT_THAT(*outbound_rtps[1]->scalability_mode, StartsWith("L1T")); + EXPECT_THAT(*outbound_rtps[2]->scalability_mode, StartsWith("L1T")); +} + +#endif // defined(WEBRTC_USE_H264) + // The legacy SVC path is triggered when VP9 us used, but `scalability_mode` has // not been specified. // TODO(https://crbug.com/webrtc/14889): When legacy VP9 SVC path has been