OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = | 1981 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = |
1982 callee()->NewGetStats(); | 1982 callee()->NewGetStats(); |
1983 ASSERT_NE(nullptr, report); | 1983 ASSERT_NE(nullptr, report); |
1984 | 1984 |
1985 auto media_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); | 1985 auto media_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); |
1986 auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats); | 1986 auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats); |
1987 ASSERT_GE(audio_index, 0); | 1987 ASSERT_GE(audio_index, 0); |
1988 EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined()); | 1988 EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined()); |
1989 } | 1989 } |
1990 | 1990 |
| 1991 // Helper for test below. |
| 1992 void ModifySsrcs(cricket::SessionDescription* desc) { |
| 1993 for (ContentInfo& content : desc->contents()) { |
| 1994 MediaContentDescription* media_desc = |
| 1995 static_cast<MediaContentDescription*>(content.description); |
| 1996 for (cricket::StreamParams& stream : media_desc->mutable_streams()) { |
| 1997 for (uint32_t& ssrc : stream.ssrcs) { |
| 1998 ssrc = rtc::CreateRandomId(); |
| 1999 } |
| 2000 } |
| 2001 } |
| 2002 } |
| 2003 |
| 2004 // Test that the "RTCMediaSteamTrackStats" object is updated correctly when |
| 2005 // SSRCs are unsignaled, and the SSRC of the received (audio) stream changes. |
| 2006 // This should result in two "RTCInboundRTPStreamStats", but only one |
| 2007 // "RTCMediaStreamTrackStats", whose counters go up continuously rather than |
| 2008 // being reset to 0 once the SSRC change occurs. |
| 2009 // |
| 2010 // Regression test for this bug: |
| 2011 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8158 |
| 2012 // |
| 2013 // The bug causes the track stats to only represent one of the two streams: |
| 2014 // whichever one has the higher SSRC. So with this bug, there was a 50% chance |
| 2015 // that the track stat counters would reset to 0 when the new stream is |
| 2016 // received, and a 50% chance that they'll stop updating (while |
| 2017 // "concealed_samples" continues increasing, due to silence being generated for |
| 2018 // the inactive stream). |
| 2019 TEST_F(PeerConnectionIntegrationTest, |
| 2020 TrackStatsUpdatedCorrectlyWhenUnsignaledSsrcChanges) { |
| 2021 ASSERT_TRUE(CreatePeerConnectionWrappers()); |
| 2022 ConnectFakeSignaling(); |
| 2023 caller()->AddAudioOnlyMediaStream(); |
| 2024 // Remove SSRCs and MSIDs from the received offer SDP, simulating an endpoint |
| 2025 // that doesn't signal SSRCs (from the callee's perspective). |
| 2026 callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); |
| 2027 caller()->CreateAndSetAndSignalOffer(); |
| 2028 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
| 2029 // Wait for 50 audio frames (500ms of audio) to be received by the callee. |
| 2030 ExpectNewFramesReceivedWithWait(0, 0, 25, 0, kMaxWaitForFramesMs); |
| 2031 |
| 2032 // Some audio frames were received, so we should have nonzero "samples |
| 2033 // received" for the track. |
| 2034 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = |
| 2035 callee()->NewGetStats(); |
| 2036 ASSERT_NE(nullptr, report); |
| 2037 auto track_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); |
| 2038 ASSERT_EQ(1U, track_stats.size()); |
| 2039 ASSERT_TRUE(track_stats[0]->total_samples_received.is_defined()); |
| 2040 ASSERT_GT(*track_stats[0]->total_samples_received, 0U); |
| 2041 // uint64_t prev_samples_received = *track_stats[0]->total_samples_received; |
| 2042 |
| 2043 // Create a new offer and munge it to cause the caller to use a new SSRC. |
| 2044 caller()->SetGeneratedSdpMunger(ModifySsrcs); |
| 2045 caller()->CreateAndSetAndSignalOffer(); |
| 2046 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
| 2047 // Wait for 25 more audio frames (250ms of audio) to be received, from the new |
| 2048 // SSRC. |
| 2049 ExpectNewFramesReceivedWithWait(0, 0, 25, 0, kMaxWaitForFramesMs); |
| 2050 |
| 2051 report = callee()->NewGetStats(); |
| 2052 ASSERT_NE(nullptr, report); |
| 2053 track_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); |
| 2054 ASSERT_EQ(1U, track_stats.size()); |
| 2055 ASSERT_TRUE(track_stats[0]->total_samples_received.is_defined()); |
| 2056 // The "total samples received" stat should only be greater than it was |
| 2057 // before. |
| 2058 // TODO(deadbeef): Uncomment this assertion once the bug is completely fixed. |
| 2059 // Right now, the new SSRC will cause the counters to reset to 0. |
| 2060 // EXPECT_GT(*track_stats[0]->total_samples_received, prev_samples_received); |
| 2061 |
| 2062 // Additionally, the percentage of concealed samples (samples generated to |
| 2063 // conceal packet loss) should be less than 25%%. If it's greater, that's a |
| 2064 // good sign that we're seeing stats from the old stream that's no longer |
| 2065 // receiving packets, and is generating concealed samples of silence. |
| 2066 constexpr double kAcceptableConcealedSamplesPercentage = 0.25; |
| 2067 ASSERT_TRUE(track_stats[0]->concealed_samples.is_defined()); |
| 2068 EXPECT_LT(*track_stats[0]->concealed_samples, |
| 2069 *track_stats[0]->total_samples_received * |
| 2070 kAcceptableConcealedSamplesPercentage); |
| 2071 |
| 2072 // Also ensure that we have two "RTCInboundRTPStreamStats" as expected, as a |
| 2073 // sanity check that the SSRC really changed. |
| 2074 // TODO(deadbeef): This isn't working right now, because we're not returning |
| 2075 // *any* stats for the inactive stream. Uncomment when the bug is completely |
| 2076 // fixed. |
| 2077 // auto inbound_stream_stats = |
| 2078 // report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>(); |
| 2079 // ASSERT_EQ(2U, inbound_stream_stats.size()); |
| 2080 } |
| 2081 |
1991 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. | 2082 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. |
1992 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { | 2083 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { |
1993 PeerConnectionFactory::Options dtls_10_options; | 2084 PeerConnectionFactory::Options dtls_10_options; |
1994 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 2085 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1995 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, | 2086 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, |
1996 dtls_10_options)); | 2087 dtls_10_options)); |
1997 ConnectFakeSignaling(); | 2088 ConnectFakeSignaling(); |
1998 // Do normal offer/answer and wait for some frames to be received in each | 2089 // Do normal offer/answer and wait for some frames to be received in each |
1999 // direction. | 2090 // direction. |
2000 caller()->AddAudioVideoMediaStream(); | 2091 caller()->AddAudioVideoMediaStream(); |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 caller()->CreateAndSetAndSignalOffer(); | 3084 caller()->CreateAndSetAndSignalOffer(); |
2994 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 3085 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
2995 // Wait for additional audio frames to be received by the callee. | 3086 // Wait for additional audio frames to be received by the callee. |
2996 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, | 3087 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, |
2997 kMaxWaitForFramesMs); | 3088 kMaxWaitForFramesMs); |
2998 } | 3089 } |
2999 | 3090 |
3000 } // namespace | 3091 } // namespace |
3001 | 3092 |
3002 #endif // if !defined(THREAD_SANITIZER) | 3093 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |