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();