From 24f7b2fb320064bd7f2f002f057ee55edf382fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Thu, 9 Feb 2023 10:22:26 +0100 Subject: [PATCH] Test what happens when asking for simulcast VP9 (not yet supported). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Today the default 3 encodings path for VP9 is to trigger legacy SVC, which is tested by "SendingThreeEncodings_VP9_LegacySVC". This CL adds another test that does not rely on the default `scalability_mode` and instead explicitly asks for simulcast (3 x L1T3). When VP9 simulcast is supported (https://crbug.com/webrtc/14884), this API pattern will allow the app to ask for standard behavior while the default path still exists for backwards-compatibility. Because we don't support VP9 simulcast yet, this test still triggers legacy fallback which is wrong so this test mostly serves to document current behavior, but see Patch Set 1 for side-by-side comparison of what we want to EXPECT and what we currently EXPECT. In the meantime, this CL helps exercise code paths that are possible to trigger as of M111. The TODOs will be addressed as part of https://crbug.com/webrtc/14884. Bug: webrtc:14884 Change-Id: Id901eea8f399223afd5a1731a3323e5134686134 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/292720 Reviewed-by: Harald Alvestrand Reviewed-by: Evan Shrubsole Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39281} --- pc/peer_connection_simulcast_unittest.cc | 64 ++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index 4625f68f02..54b49309bb 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -1017,7 +1017,8 @@ TEST_F(PeerConnectionSimulcastWithMediaFlowTests, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - std::vector layers = CreateLayers({"f", "h", "q"}, true); + std::vector layers = + CreateLayers({"f", "h", "q"}, /*active=*/true); rtc::scoped_refptr transceiver = AddTransceiverWithSimulcastLayers(local_pc_wrapper, remote_pc_wrapper, layers); @@ -1059,7 +1060,8 @@ TEST_F(PeerConnectionSimulcastWithMediaFlowTests, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - std::vector layers = CreateLayers({"f", "h", "q"}, true); + std::vector layers = + CreateLayers({"f", "h", "q"}, /*active=*/true); rtc::scoped_refptr transceiver = AddTransceiverWithSimulcastLayers(local_pc_wrapper, remote_pc_wrapper, layers); @@ -1096,8 +1098,60 @@ TEST_F(PeerConnectionSimulcastWithMediaFlowTests, EXPECT_FALSE(encodings[2].scalability_mode.has_value()); } -// TODO(https://crbug.com/webrtc/14884): Add support for VP9 simulcast and test -// this using a similar test to the above but specifying and verifying -// `scalability_mode` (e.g. L1Tx). +// TODO(https://crbug.com/webrtc/14884): Support VP9 simulcast and update this +// test to EXPECT three encodings of L1T3, not the VP9 SVC legacy fallback path +// that happens today which is wrong. +TEST_F(PeerConnectionSimulcastWithMediaFlowTests, + SendingThreeEncodings_VP9_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, "VP9"); + transceiver->SetCodecPreferences(codecs); + + // Opt-in to spec-compliant simulcast by explicitly setting the + // `scalability_mode`. + rtc::scoped_refptr sender = transceiver->sender(); + RtpParameters parameters = sender->GetParameters(); + std::vector encodings = parameters.encodings; + ASSERT_EQ(encodings.size(), 3u); + encodings[0].scalability_mode = "L1T3"; + encodings[1].scalability_mode = "L1T3"; + encodings[2].scalability_mode = "L1T3"; + sender->SetParameters(parameters); + + NegotiateWithSimulcastTweaks(local_pc_wrapper, remote_pc_wrapper, layers); + local_pc_wrapper->WaitForConnection(); + remote_pc_wrapper->WaitForConnection(); + + // We want to EXPECT to get 3 "outbound-rtps" using L1T3 and that + // GetParameters() reflects what was set, but because this is not supported + // yet (webrtc:14884), we expect legacy SVC fallback for now... + + // Legacy SVC fallback only has a single RTP stream. + EXPECT_TRUE_WAIT(HasOutboundRtpBytesSent(local_pc_wrapper, 1u), + kLongTimeoutForRampingUp.ms()); + // Legacy SVC fallback uses L3T3_KEY. + rtc::scoped_refptr report = GetStats(local_pc_wrapper); + std::vector outbound_rtps = + report->GetStatsOfType(); + ASSERT_EQ(outbound_rtps.size(), 1u); + EXPECT_TRUE(absl::EqualsIgnoreCase( + GetCurrentCodecMimeType(report, *outbound_rtps[0]), "video/VP9")); + EXPECT_THAT(*outbound_rtps[0]->scalability_mode, StartsWith("L3T3_KEY")); + // Legacy SVC fallback sets `scalability_mode` to absl::nullopt. + encodings = sender->GetParameters().encodings; + ASSERT_EQ(encodings.size(), 3u); + EXPECT_FALSE(encodings[0].scalability_mode.has_value()); + EXPECT_FALSE(encodings[1].scalability_mode.has_value()); + EXPECT_FALSE(encodings[2].scalability_mode.has_value()); +} } // namespace webrtc