Chromium Code Reviews| 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 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = | 1959 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = |
| 1960 callee()->NewGetStats(); | 1960 callee()->NewGetStats(); |
| 1961 ASSERT_NE(nullptr, report); | 1961 ASSERT_NE(nullptr, report); |
| 1962 | 1962 |
| 1963 auto media_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); | 1963 auto media_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); |
| 1964 auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats); | 1964 auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats); |
| 1965 ASSERT_GE(audio_index, 0); | 1965 ASSERT_GE(audio_index, 0); |
| 1966 EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined()); | 1966 EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined()); |
| 1967 } | 1967 } |
| 1968 | 1968 |
| 1969 // Helper for test below. | |
| 1970 void ModifySsrcs(cricket::SessionDescription* desc) { | |
| 1971 for (ContentInfo& content : desc->contents()) { | |
| 1972 MediaContentDescription* media_desc = | |
| 1973 static_cast<MediaContentDescription*>(content.description); | |
| 1974 for (cricket::StreamParams& stream : media_desc->mutable_streams()) { | |
| 1975 for (uint32_t& ssrc : stream.ssrcs) { | |
| 1976 ssrc = rtc::CreateRandomId(); | |
| 1977 } | |
| 1978 } | |
| 1979 } | |
| 1980 } | |
| 1981 | |
| 1982 // Test that the "RTCMediaSteamTrackStats" object is updated correctly when | |
| 1983 // SSRCs are unsignaled, and the SSRC of the received (audio) stream changes. | |
| 1984 // This should result in two "RTCInboundRTPStreamStats", but only one | |
| 1985 // "RTCMediaStreamTrackStats", whose counters go up continuously rather than | |
| 1986 // being reset to 0 once the SSRC change occurs. | |
| 1987 // | |
| 1988 // Regression test for this bug: | |
| 1989 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8158 | |
| 1990 // | |
| 1991 // The bug causes the track stats to only represent one of the two streams: | |
| 1992 // whichever one has the higher SSRC. So with this bug, there was a 50% chance | |
| 1993 // that the track stat counters would reset to 0 when the new stream is | |
| 1994 // received, and a 50% chance that they'll stop updating (while | |
| 1995 // "concealed_samples" continues increasing, due to silence being generated for | |
| 1996 // the inactive stream). | |
| 1997 TEST_F(PeerConnectionIntegrationTest, | |
| 1998 TrackStatsUpdatedCorrectlyWhenUnsignaledSsrcChanges) { | |
| 1999 ASSERT_TRUE(CreatePeerConnectionWrappers()); | |
| 2000 ConnectFakeSignaling(); | |
| 2001 caller()->AddAudioOnlyMediaStream(); | |
| 2002 // Remove SSRCs and MSIDs from the received offer SDP, simulating an endpoint | |
| 2003 // that doesn't signal SSRCs (from the callee's perspective). | |
| 2004 callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids); | |
| 2005 caller()->CreateAndSetAndSignalOffer(); | |
| 2006 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | |
| 2007 // Wait for 20 audio frames (200ms of audio) to be received by the callee. | |
| 2008 ExpectNewFramesReceivedWithWait(0, 0, 20, 0, kMaxWaitForFramesMs); | |
| 2009 | |
| 2010 // Some audio frames were received, so we should have nonzero "samples | |
| 2011 // received" for the track. | |
| 2012 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = | |
| 2013 callee()->NewGetStats(); | |
| 2014 ASSERT_NE(nullptr, report); | |
| 2015 auto track_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); | |
| 2016 ASSERT_EQ(1U, track_stats.size()); | |
| 2017 ASSERT_TRUE(track_stats[0]->total_samples_received.is_defined()); | |
| 2018 ASSERT_GT(*track_stats[0]->total_samples_received, 0U); | |
| 2019 // uint64_t prev_samples_received = *track_stats[0]->total_samples_received; | |
|
the sun
2017/09/18 18:59:35
remove commented-out line
Taylor Brandstetter
2017/09/20 00:19:46
Won't compile if I do (unused variable warning). I
| |
| 2020 | |
| 2021 // Create a new offer and munge it to cause the caller to use a new SSRC. | |
| 2022 caller()->SetGeneratedSdpMunger(ModifySsrcs); | |
| 2023 caller()->CreateAndSetAndSignalOffer(); | |
| 2024 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | |
| 2025 // Wait for 10 more audio frames (100ms of audio) to be received, from the new | |
| 2026 // SSRC. | |
| 2027 ExpectNewFramesReceivedWithWait(0, 0, 10, 0, kMaxWaitForFramesMs); | |
| 2028 | |
| 2029 report = callee()->NewGetStats(); | |
| 2030 ASSERT_NE(nullptr, report); | |
| 2031 track_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>(); | |
| 2032 ASSERT_EQ(1U, track_stats.size()); | |
| 2033 ASSERT_TRUE(track_stats[0]->total_samples_received.is_defined()); | |
| 2034 // The "total samples received" stat should only be greater than it was | |
| 2035 // before. | |
| 2036 // TODO(deadbeef): Uncomment this assertion once the bug is completely fixed. | |
| 2037 // Right now, the new SSRC will cause the counters to reset to 0. | |
| 2038 // EXPECT_GT(*track_stats[0]->total_samples_received, prev_samples_received); | |
| 2039 | |
| 2040 // Additionally, the percentage of concealed samples (samples generated to | |
| 2041 // conceal packet loss) should be less than 10%. If it's greater, that's a | |
| 2042 // good sign that we're seeing stats from the old stream that's no longer | |
| 2043 // receiving packets, and is generating concealed samples of silence. | |
| 2044 constexpr double kAcceptableConcealedSamplesPercentage = 0.1; | |
| 2045 ASSERT_TRUE(track_stats[0]->concealed_samples.is_defined()); | |
| 2046 EXPECT_LT(*track_stats[0]->concealed_samples, | |
| 2047 *track_stats[0]->total_samples_received * | |
| 2048 kAcceptableConcealedSamplesPercentage); | |
| 2049 | |
| 2050 // Also ensure that we have two "RTCInboundRTPStreamStats" as expected, as a | |
| 2051 // sanity check that the SSRC really changed. | |
| 2052 // TODO(deadbeef): This isn't working right now, because we're not returning | |
| 2053 // *any* stats for the inactive stream. Uncomment when the bug is completely | |
| 2054 // fixed. | |
| 2055 // auto inbound_stream_stats = | |
| 2056 // report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>(); | |
| 2057 // ASSERT_EQ(2U, inbound_stream_stats.size()); | |
| 2058 } | |
| 2059 | |
| 1969 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. | 2060 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. |
| 1970 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { | 2061 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { |
| 1971 PeerConnectionFactory::Options dtls_10_options; | 2062 PeerConnectionFactory::Options dtls_10_options; |
| 1972 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 2063 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
| 1973 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, | 2064 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, |
| 1974 dtls_10_options)); | 2065 dtls_10_options)); |
| 1975 ConnectFakeSignaling(); | 2066 ConnectFakeSignaling(); |
| 1976 // Do normal offer/answer and wait for some frames to be received in each | 2067 // Do normal offer/answer and wait for some frames to be received in each |
| 1977 // direction. | 2068 // direction. |
| 1978 caller()->AddAudioVideoMediaStream(); | 2069 caller()->AddAudioVideoMediaStream(); |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2971 caller()->CreateAndSetAndSignalOffer(); | 3062 caller()->CreateAndSetAndSignalOffer(); |
| 2972 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 3063 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
| 2973 // Wait for additional audio frames to be received by the callee. | 3064 // Wait for additional audio frames to be received by the callee. |
| 2974 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, | 3065 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, |
| 2975 kMaxWaitForFramesMs); | 3066 kMaxWaitForFramesMs); |
| 2976 } | 3067 } |
| 2977 | 3068 |
| 2978 } // namespace | 3069 } // namespace |
| 2979 | 3070 |
| 2980 #endif // if !defined(THREAD_SANITIZER) | 3071 #endif // if !defined(THREAD_SANITIZER) |
| OLD | NEW |