From bce135a4a7440d1ba7dde569dbd83172b7f54942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 8 Feb 2023 15:23:27 +0100 Subject: [PATCH] Add test coverage for legacy VP9 SVC with media flow. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When asking for 3 encodings of VP9, which the spec says is simulcast, you don't get simulcast but instead you get one RTP stream sending SVC. This results in a single "outbound-rtp" but GetParameters() still says 3 encodings are used. We know we get SVC because the scalabilityMode from getStats() says "L3T3_KEY". In a future CL we will add simulcast VP9 support when `scalability_mode` is specified in the API but we'll need to continue to support the legacy SVC code paths until that has been deprecated and removed (https://crbug.com/webrtc/14889). Bug: webrtc:14884 Change-Id: Ibeca44b7a0b93097ad9525e45ebbca3b7663c686 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/292581 Reviewed-by: Harald Alvestrand Reviewed-by: Evan Shrubsole Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39278} --- pc/peer_connection_simulcast_unittest.cc | 56 ++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index 71b36029d3..4625f68f02 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -1011,10 +1011,8 @@ class PeerConnectionSimulcastWithMediaFlowTests std::unique_ptr background_thread_; }; -// TODO(https://crbug.com/webrtc/14884): When VP9 simulast is supported, use -// SetCodecPreferences() and pass a test like this with VP9. TEST_F(PeerConnectionSimulcastWithMediaFlowTests, - SimulcastSendsAllLayersWithVP8) { + SendingThreeEncodings_VP8_Simulcast) { rtc::scoped_refptr local_pc_wrapper = CreatePc(); rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); @@ -1050,4 +1048,56 @@ TEST_F(PeerConnectionSimulcastWithMediaFlowTests, EXPECT_THAT(*outbound_rtps[2]->scalability_mode, StartsWith("L1T")); } +// 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 +// deprecated and removed, update this test to assert that simulcast is used +// (i.e. VP9 is not treated differently than VP8). +TEST_F(PeerConnectionSimulcastWithMediaFlowTests, + SendingThreeEncodings_VP9_LegacySVC) { + 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"}, true); + rtc::scoped_refptr transceiver = + AddTransceiverWithSimulcastLayers(local_pc_wrapper, remote_pc_wrapper, + layers); + std::vector codecs = + GetCapabilitiesAndRestrictToCodec(local_pc_wrapper, "VP9"); + transceiver->SetCodecPreferences(codecs); + + NegotiateWithSimulcastTweaks(local_pc_wrapper, remote_pc_wrapper, layers); + local_pc_wrapper->WaitForConnection(); + remote_pc_wrapper->WaitForConnection(); + + // Wait until media is flowing. We only expect a single RTP stream. + EXPECT_TRUE_WAIT(HasOutboundRtpBytesSent(local_pc_wrapper, 1u), + kLongTimeoutForRampingUp.ms()); + // Verify codec and scalability mode. + 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")); + + // Despite SVC being used on a single RTP stream, GetParameters() returns the + // three encodings that we configured earlier (this is not spec-compliant but + // it is how legacy SVC behaves). + rtc::scoped_refptr sender = transceiver->sender(); + std::vector encodings = + sender->GetParameters().encodings; + ASSERT_EQ(encodings.size(), 3u); + // When legacy SVC is used, `scalability_mode` is not specified. + EXPECT_FALSE(encodings[0].scalability_mode.has_value()); + EXPECT_FALSE(encodings[1].scalability_mode.has_value()); + 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). + } // namespace webrtc