From 39dab96b98d2edf637c1bfc76b28497c0ef7e2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 22 Feb 2023 10:30:19 +0100 Subject: [PATCH] Verify GetSources is not flaky for unsignaled SSRCs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test verifies perkj's fixes in https://crbug.com/webrtc/14817. I ran the test 6000 times locally and it didn't fail once. Bug: webrtc:14817 Change-Id: I3f78f3ae2ca09b328cbfa12a89ad228d3de899c2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294522 Reviewed-by: Per Kjellander Commit-Queue: Per Kjellander Auto-Submit: Henrik Boström Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39365} --- pc/peer_connection_integrationtest.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 220415baf2..5d1820d6c9 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -2794,6 +2794,31 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesVideo) { EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type()); } +// Similar to the above test, except instead of waiting until GetSources() is +// non-empty we wait until media is flowing and then assert that GetSources() +// is not empty. This provides test coverage for https://crbug.com/webrtc/14817 +// where a race due to the re-creationg of the unsignaled ssrc stream would +// clear the GetSources() history. This test not flaking confirms the bug fix. +TEST_P(PeerConnectionIntegrationTest, + UnsignaledSsrcGetSourcesNonEmptyIfMediaFlowing) { + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->AddVideoTrack(); + callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); + // Wait for one video frame to be received by the callee. + MediaExpectations media_expectations; + media_expectations.CalleeExpectsSomeVideo(1); + ASSERT_TRUE(ExpectNewFrames(media_expectations)); + ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u); + auto receiver = callee()->pc()->GetReceivers()[0]; + std::vector sources = receiver->GetSources(); + // SSRC history must not be cleared since the reception of the first frame. + ASSERT_GT(sources.size(), 0u); + EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type()); +} + TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersAudio) { ASSERT_TRUE(CreatePeerConnectionWrappers()); ConnectFakeSignaling();