Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: webrtc/video/end_to_end_tests.cc

Issue 2420443002: Fix for flaky test: EndToEndTest.VerifyHistogramStatsWithRtx (Closed)
Patch Set: start counting frames when ntp time is valid Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <algorithm> 10 #include <algorithm>
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 : EndToEndTest(kLongTimeoutMs), 2118 : EndToEndTest(kLongTimeoutMs),
2119 use_rtx_(use_rtx), 2119 use_rtx_(use_rtx),
2120 use_red_(use_red), 2120 use_red_(use_red),
2121 screenshare_(screenshare), 2121 screenshare_(screenshare),
2122 // This test uses NACK, so to send FEC we can't use a fake encoder. 2122 // This test uses NACK, so to send FEC we can't use a fake encoder.
2123 vp8_encoder_( 2123 vp8_encoder_(
2124 use_red ? VideoEncoder::Create(VideoEncoder::EncoderType::kVp8) 2124 use_red ? VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)
2125 : nullptr), 2125 : nullptr),
2126 sender_call_(nullptr), 2126 sender_call_(nullptr),
2127 receiver_call_(nullptr), 2127 receiver_call_(nullptr),
2128 start_runtime_ms_(-1) {} 2128 start_runtime_ms_(-1),
2129 num_frames_received_(0) {}
2129 2130
2130 private: 2131 private:
2131 void OnFrame(const VideoFrame& video_frame) override {} 2132 void OnFrame(const VideoFrame& video_frame) override {
2133 // The RTT is needed to estimate |ntp_time_ms| which is used by
2134 // end-to-end delay stats. Therefore, start counting received frames once
2135 // |ntp_time_ms| is valid.
2136 if (video_frame.ntp_time_ms() > 0 &&
2137 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() >=
2138 video_frame.ntp_time_ms()) {
2139 rtc::CritScope lock(&crit_);
2140 ++num_frames_received_;
2141 }
2142 }
2132 2143
2133 Action OnSendRtp(const uint8_t* packet, size_t length) override { 2144 Action OnSendRtp(const uint8_t* packet, size_t length) override {
2134 if (MinMetricRunTimePassed()) 2145 if (MinMetricRunTimePassed() && MinNumberOfFramesReceived())
2135 observation_complete_.Set(); 2146 observation_complete_.Set();
2136 2147
2137 return SEND_PACKET; 2148 return SEND_PACKET;
2138 } 2149 }
2139 2150
2140 bool MinMetricRunTimePassed() { 2151 bool MinMetricRunTimePassed() {
2141 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); 2152 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds();
2142 if (start_runtime_ms_ == -1) { 2153 if (start_runtime_ms_ == -1) {
2143 start_runtime_ms_ = now; 2154 start_runtime_ms_ = now;
2144 return false; 2155 return false;
2145 } 2156 }
2146 int64_t elapsed_sec = (now - start_runtime_ms_) / 1000; 2157 int64_t elapsed_sec = (now - start_runtime_ms_) / 1000;
2147 return elapsed_sec > metrics::kMinRunTimeInSeconds * 2; 2158 return elapsed_sec > metrics::kMinRunTimeInSeconds * 2;
2148 } 2159 }
2149 2160
2161 bool MinNumberOfFramesReceived() const {
2162 const int kMinRequiredHistogramSamples = 200;
2163 rtc::CritScope lock(&crit_);
2164 return num_frames_received_ > kMinRequiredHistogramSamples;
2165 }
2166
2150 void ModifyVideoConfigs( 2167 void ModifyVideoConfigs(
2151 VideoSendStream::Config* send_config, 2168 VideoSendStream::Config* send_config,
2152 std::vector<VideoReceiveStream::Config>* receive_configs, 2169 std::vector<VideoReceiveStream::Config>* receive_configs,
2153 VideoEncoderConfig* encoder_config) override { 2170 VideoEncoderConfig* encoder_config) override {
2154 static const int kExtensionId = 8; 2171 static const int kExtensionId = 8;
2155 send_config->rtp.extensions.push_back(RtpExtension( 2172 send_config->rtp.extensions.push_back(RtpExtension(
2156 RtpExtension::kTransportSequenceNumberUri, kExtensionId)); 2173 RtpExtension::kTransportSequenceNumberUri, kExtensionId));
2157 (*receive_configs)[0].rtp.extensions.push_back(RtpExtension( 2174 (*receive_configs)[0].rtp.extensions.push_back(RtpExtension(
2158 RtpExtension::kTransportSequenceNumberUri, kExtensionId)); 2175 RtpExtension::kTransportSequenceNumberUri, kExtensionId));
2159 // NACK 2176 // NACK
(...skipping 29 matching lines...) Expand all
2189 2206
2190 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { 2207 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
2191 sender_call_ = sender_call; 2208 sender_call_ = sender_call;
2192 receiver_call_ = receiver_call; 2209 receiver_call_ = receiver_call;
2193 } 2210 }
2194 2211
2195 void PerformTest() override { 2212 void PerformTest() override {
2196 EXPECT_TRUE(Wait()) << "Timed out waiting for packet to be NACKed."; 2213 EXPECT_TRUE(Wait()) << "Timed out waiting for packet to be NACKed.";
2197 } 2214 }
2198 2215
2216 rtc::CriticalSection crit_;
2199 const bool use_rtx_; 2217 const bool use_rtx_;
2200 const bool use_red_; 2218 const bool use_red_;
2201 const bool screenshare_; 2219 const bool screenshare_;
2202 const std::unique_ptr<VideoEncoder> vp8_encoder_; 2220 const std::unique_ptr<VideoEncoder> vp8_encoder_;
2203 Call* sender_call_; 2221 Call* sender_call_;
2204 Call* receiver_call_; 2222 Call* receiver_call_;
2205 int64_t start_runtime_ms_; 2223 int64_t start_runtime_ms_;
2224 int num_frames_received_ GUARDED_BY(&crit_);
2206 } test(use_rtx, use_red, screenshare); 2225 } test(use_rtx, use_red, screenshare);
2207 2226
2208 metrics::Reset(); 2227 metrics::Reset();
2209 RunBaseTest(&test); 2228 RunBaseTest(&test);
2210 2229
2211 // Delete the call for Call stats to be reported. 2230 // Delete the call for Call stats to be reported.
2212 sender_call_.reset(); 2231 sender_call_.reset();
2213 receiver_call_.reset(); 2232 receiver_call_.reset();
2214 2233
2215 std::string video_prefix = 2234 std::string video_prefix =
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3923 std::unique_ptr<VideoEncoder> encoder_; 3942 std::unique_ptr<VideoEncoder> encoder_;
3924 std::unique_ptr<VideoDecoder> decoder_; 3943 std::unique_ptr<VideoDecoder> decoder_;
3925 rtc::CriticalSection crit_; 3944 rtc::CriticalSection crit_;
3926 int recorded_frames_ GUARDED_BY(crit_); 3945 int recorded_frames_ GUARDED_BY(crit_);
3927 } test(this); 3946 } test(this);
3928 3947
3929 RunBaseTest(&test); 3948 RunBaseTest(&test);
3930 } 3949 }
3931 3950
3932 } // namespace webrtc 3951 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698