blob: 3fb1db66a5eb740c71009470984adb8a1c686cdc [file] [log] [blame]
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include <stdio.h>
11
12#include <deque>
13#include <map>
14
pbos@webrtc.org69215d82013-07-10 15:02:02 +000015#include "testing/gtest/include/gtest/gtest.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000016
ivica05cfcd32015-09-07 06:04:16 -070017#include "webrtc/base/format_macros.h"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000018#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org38344ed2014-09-24 06:05:00 +000019#include "webrtc/base/thread_annotations.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000020#include "webrtc/call.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000021#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
Erik Språng085856c2015-07-22 17:17:58 +020022#include "webrtc/frame_callback.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000023#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
24#include "webrtc/system_wrappers/interface/clock.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000025#include "webrtc/system_wrappers/interface/cpu_info.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000026#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
27#include "webrtc/system_wrappers/interface/event_wrapper.h"
pbos@webrtc.org94015242013-10-16 11:05:37 +000028#include "webrtc/system_wrappers/interface/sleep.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000029#include "webrtc/test/encoder_settings.h"
30#include "webrtc/test/fake_encoder.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000031#include "webrtc/test/frame_generator.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000032#include "webrtc/test/frame_generator_capturer.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000033#include "webrtc/test/statistics.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000034#include "webrtc/test/testsupport/fileutils.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000035#include "webrtc/typedefs.h"
ivica05cfcd32015-09-07 06:04:16 -070036#include "webrtc/video/full_stack.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000037
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000038namespace webrtc {
39
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000040static const int kFullStackTestDurationSecs = 60;
Erik Språng085856c2015-07-22 17:17:58 +020041static const int kSendStatsPollingIntervalMs = 1000;
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000042
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000043class VideoAnalyzer : public PacketReceiver,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000044 public newapi::Transport,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000045 public VideoRenderer,
Erik Språng085856c2015-07-22 17:17:58 +020046 public VideoCaptureInput,
47 public EncodedFrameObserver {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000048 public:
Peter Boström4b91bd02015-06-26 06:58:16 +020049 VideoAnalyzer(VideoCaptureInput* input,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000050 Transport* transport,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000051 const char* test_label,
52 double avg_psnr_threshold,
53 double avg_ssim_threshold,
ivica05cfcd32015-09-07 06:04:16 -070054 int duration_frames,
55 const std::string& graph_data_output_filename)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000056 : input_(input),
57 transport_(transport),
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +000058 receiver_(nullptr),
Erik Språng085856c2015-07-22 17:17:58 +020059 send_stream_(nullptr),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000060 test_label_(test_label),
ivica05cfcd32015-09-07 06:04:16 -070061 graph_data_output_filename_(graph_data_output_filename),
sprang@webrtc.org131bea82015-02-18 12:46:06 +000062 frames_to_process_(duration_frames),
63 frames_recorded_(0),
64 frames_processed_(0),
pbos@webrtc.org94015242013-10-16 11:05:37 +000065 dropped_frames_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000066 last_render_time_(0),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000067 rtp_timestamp_delta_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000068 avg_psnr_threshold_(avg_psnr_threshold),
69 avg_ssim_threshold_(avg_ssim_threshold),
sprang@webrtc.org131bea82015-02-18 12:46:06 +000070 comparison_available_event_(EventWrapper::Create()),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000071 done_(EventWrapper::Create()) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000072 // Create thread pool for CPU-expensive PSNR/SSIM calculations.
73
74 // Try to use about as many threads as cores, but leave kMinCoresLeft alone,
75 // so that we don't accidentally starve "real" worker threads (codec etc).
76 // Also, don't allocate more than kMaxComparisonThreads, even if there are
77 // spare cores.
78
79 uint32_t num_cores = CpuInfo::DetectNumberOfCores();
henrikg91d6ede2015-09-17 00:24:34 -070080 RTC_DCHECK_GE(num_cores, 1u);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000081 static const uint32_t kMinCoresLeft = 4;
sprang@webrtc.org343096a2015-02-23 08:34:17 +000082 static const uint32_t kMaxComparisonThreads = 8;
sprang@webrtc.org131bea82015-02-18 12:46:06 +000083
84 if (num_cores <= kMinCoresLeft) {
85 num_cores = 1;
86 } else {
87 num_cores -= kMinCoresLeft;
88 num_cores = std::min(num_cores, kMaxComparisonThreads);
89 }
90
91 for (uint32_t i = 0; i < num_cores; ++i) {
tommi@webrtc.org361981f2015-03-19 14:44:18 +000092 rtc::scoped_ptr<ThreadWrapper> thread =
tommi@webrtc.org38492c52015-03-22 14:41:46 +000093 ThreadWrapper::CreateThread(&FrameComparisonThread, this, "Analyzer");
pbos@webrtc.org86639732015-03-13 00:06:21 +000094 EXPECT_TRUE(thread->Start());
tommi@webrtc.org361981f2015-03-19 14:44:18 +000095 comparison_thread_pool_.push_back(thread.release());
sprang@webrtc.org131bea82015-02-18 12:46:06 +000096 }
Erik Språng085856c2015-07-22 17:17:58 +020097
98 stats_polling_thread_ =
99 ThreadWrapper::CreateThread(&PollStatsThread, this, "StatsPoller");
100 EXPECT_TRUE(stats_polling_thread_->Start());
pbos@webrtc.org94015242013-10-16 11:05:37 +0000101 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000102
103 ~VideoAnalyzer() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000104 for (ThreadWrapper* thread : comparison_thread_pool_) {
105 EXPECT_TRUE(thread->Stop());
106 delete thread;
107 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000108 }
109
pbos@webrtc.org94015242013-10-16 11:05:37 +0000110 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
111
stefan68786d22015-09-08 05:36:15 -0700112 DeliveryStatus DeliverPacket(MediaType media_type,
113 const uint8_t* packet,
114 size_t length,
115 const PacketTime& packet_time) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000116 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000117 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000118 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000119 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200120 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000121 recv_times_[header.timestamp - rtp_timestamp_delta_] =
122 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
123 }
124
stefan68786d22015-09-08 05:36:15 -0700125 return receiver_->DeliverPacket(media_type, packet, length, packet_time);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000126 }
127
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700128 void IncomingCapturedFrame(const VideoFrame& video_frame) override {
129 VideoFrame copy = video_frame;
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000130 copy.set_timestamp(copy.ntp_time_ms() * 90);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000131
132 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200133 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000134 if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000135 first_send_frame_ = copy;
136
137 frames_.push_back(copy);
138 }
139
perkj@webrtc.orgaf612d52015-03-18 09:51:05 +0000140 input_->IncomingCapturedFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000141 }
142
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000143 bool SendRtp(const uint8_t* packet, size_t length) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000144 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000145 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000146 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000147
148 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200149 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000150 if (rtp_timestamp_delta_ == 0) {
151 rtp_timestamp_delta_ =
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000152 header.timestamp - first_send_frame_.timestamp();
153 first_send_frame_.Reset();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000154 }
ivica05cfcd32015-09-07 06:04:16 -0700155 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_;
156 send_times_[timestamp] =
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000157 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
ivica05cfcd32015-09-07 06:04:16 -0700158 encoded_frame_sizes_[timestamp] +=
159 length - (header.headerLength + header.paddingLength);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000160 }
161
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000162 return transport_->SendRtp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000163 }
164
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000165 bool SendRtcp(const uint8_t* packet, size_t length) override {
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000166 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000167 }
168
Erik Språng085856c2015-07-22 17:17:58 +0200169 void EncodedFrameCallback(const EncodedFrame& frame) override {
170 rtc::CritScope lock(&comparison_lock_);
171 if (frames_recorded_ < frames_to_process_)
172 encoded_frame_size_.AddSample(frame.length_);
173 }
174
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700175 void RenderFrame(const VideoFrame& video_frame,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000176 int time_to_render_ms) override {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000177 int64_t render_time_ms =
178 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000179 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
180
Peter Boströmf2f82832015-05-01 13:00:41 +0200181 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000182
183 while (frames_.front().timestamp() < send_timestamp) {
184 AddFrameComparison(frames_.front(), last_rendered_frame_, true,
185 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000186 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000187 }
188
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700189 VideoFrame reference_frame = frames_.front();
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000190 frames_.pop_front();
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000191 assert(!reference_frame.IsZeroSize());
192 EXPECT_EQ(reference_frame.timestamp(), send_timestamp);
193 assert(reference_frame.timestamp() == send_timestamp);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000194
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000195 AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000196
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000197 last_rendered_frame_ = video_frame;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000198 }
199
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000200 bool IsTextureSupported() const override { return false; }
pbos@webrtc.org0d852d52015-02-09 15:14:36 +0000201
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000202 void Wait() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000203 // Frame comparisons can be very expensive. Wait for test to be done, but
204 // at time-out check if frames_processed is going up. If so, give it more
205 // time, otherwise fail. Hopefully this will reduce test flakiness.
206
207 int last_frames_processed = -1;
208 EventTypeWrapper eventType;
Erik Språng2c274302015-08-31 17:21:14 +0200209 int iteration = 0;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000210 while ((eventType = done_->Wait(FullStackTest::kDefaultTimeoutMs)) !=
211 kEventSignaled) {
212 int frames_processed;
213 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200214 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000215 frames_processed = frames_processed_;
216 }
Erik Språng2c274302015-08-31 17:21:14 +0200217
218 // Print some output so test infrastructure won't think we've crashed.
219 const char* kKeepAliveMessages[3] = {
220 "Uh, I'm-I'm not quite dead, sir.",
221 "Uh, I-I think uh, I could pull through, sir.",
222 "Actually, I think I'm all right to come with you--"};
223 printf("- %s\n", kKeepAliveMessages[iteration++ % 3]);
224
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000225 if (last_frames_processed == -1) {
226 last_frames_processed = frames_processed;
227 continue;
228 }
229 ASSERT_GT(frames_processed, last_frames_processed)
230 << "Analyzer stalled while waiting for test to finish.";
231 last_frames_processed = frames_processed;
232 }
Erik Språng085856c2015-07-22 17:17:58 +0200233
Erik Språng2c274302015-08-31 17:21:14 +0200234 if (iteration > 0)
235 printf("- Farewell, sweet Concorde!\n");
236
Erik Språng085856c2015-07-22 17:17:58 +0200237 // Signal stats polling thread if that is still waiting and stop it now,
238 // since it uses the send_stream_ reference that might be reclaimed after
239 // returning from this method.
240 done_->Set();
241 EXPECT_TRUE(stats_polling_thread_->Stop());
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000242 }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000243
Peter Boström4b91bd02015-06-26 06:58:16 +0200244 VideoCaptureInput* input_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000245 Transport* transport_;
246 PacketReceiver* receiver_;
Erik Språng085856c2015-07-22 17:17:58 +0200247 VideoSendStream* send_stream_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000248
249 private:
250 struct FrameComparison {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000251 FrameComparison()
ivica05cfcd32015-09-07 06:04:16 -0700252 : dropped(false),
253 send_time_ms(0),
254 recv_time_ms(0),
255 render_time_ms(0),
256 encoded_frame_size(0) {}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000257
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700258 FrameComparison(const VideoFrame& reference,
259 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000260 bool dropped,
261 int64_t send_time_ms,
262 int64_t recv_time_ms,
ivica05cfcd32015-09-07 06:04:16 -0700263 int64_t render_time_ms,
264 size_t encoded_frame_size)
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000265 : reference(reference),
266 render(render),
267 dropped(dropped),
pbos@webrtc.org94015242013-10-16 11:05:37 +0000268 send_time_ms(send_time_ms),
269 recv_time_ms(recv_time_ms),
ivica05cfcd32015-09-07 06:04:16 -0700270 render_time_ms(render_time_ms),
271 encoded_frame_size(encoded_frame_size) {}
pbos@webrtc.org94015242013-10-16 11:05:37 +0000272
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700273 VideoFrame reference;
274 VideoFrame render;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000275 bool dropped;
276 int64_t send_time_ms;
277 int64_t recv_time_ms;
278 int64_t render_time_ms;
ivica05cfcd32015-09-07 06:04:16 -0700279 size_t encoded_frame_size;
280 };
281
282 struct Sample {
283 Sample(double dropped,
284 double input_time_ms,
285 double send_time_ms,
286 double recv_time_ms,
287 double encoded_frame_size,
288 double psnr,
289 double ssim,
290 double render_time_ms)
291 : dropped(dropped),
292 input_time_ms(input_time_ms),
293 send_time_ms(send_time_ms),
294 recv_time_ms(recv_time_ms),
295 encoded_frame_size(encoded_frame_size),
296 psnr(psnr),
297 ssim(ssim),
298 render_time_ms(render_time_ms) {}
299
300 double dropped;
301 double input_time_ms;
302 double send_time_ms;
303 double recv_time_ms;
304 double encoded_frame_size;
305 double psnr;
306 double ssim;
307 double render_time_ms;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000308 };
309
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700310 void AddFrameComparison(const VideoFrame& reference,
311 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000312 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000313 int64_t render_time_ms)
314 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000315 int64_t send_time_ms = send_times_[reference.timestamp()];
316 send_times_.erase(reference.timestamp());
317 int64_t recv_time_ms = recv_times_[reference.timestamp()];
318 recv_times_.erase(reference.timestamp());
pbos@webrtc.org94015242013-10-16 11:05:37 +0000319
ivica05cfcd32015-09-07 06:04:16 -0700320 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()];
321 encoded_frame_sizes_.erase(reference.timestamp());
322
323 VideoFrame reference_copy;
324 VideoFrame render_copy;
325 reference_copy.CopyFrame(reference);
326 render_copy.CopyFrame(render);
327
Peter Boströmf2f82832015-05-01 13:00:41 +0200328 rtc::CritScope crit(&comparison_lock_);
ivica05cfcd32015-09-07 06:04:16 -0700329 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped,
Erik Språng085856c2015-07-22 17:17:58 +0200330 send_time_ms, recv_time_ms,
ivica05cfcd32015-09-07 06:04:16 -0700331 render_time_ms, encoded_size));
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000332 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000333 }
334
Erik Språng085856c2015-07-22 17:17:58 +0200335 static bool PollStatsThread(void* obj) {
336 return static_cast<VideoAnalyzer*>(obj)->PollStats();
337 }
338
339 bool PollStats() {
340 switch (done_->Wait(kSendStatsPollingIntervalMs)) {
341 case kEventSignaled:
342 case kEventError:
343 done_->Set(); // Make sure main thread is also signaled.
344 return false;
345 case kEventTimeout:
346 break;
347 default:
348 RTC_NOTREACHED();
349 }
350
351 VideoSendStream::Stats stats = send_stream_->GetStats();
352
353 rtc::CritScope crit(&comparison_lock_);
354 encode_frame_rate_.AddSample(stats.encode_frame_rate);
355 encode_time_ms.AddSample(stats.avg_encode_time_ms);
356 encode_usage_percent.AddSample(stats.encode_usage_percent);
357 media_bitrate_bps.AddSample(stats.media_bitrate_bps);
358
359 return true;
360 }
361
pbos@webrtc.org94015242013-10-16 11:05:37 +0000362 static bool FrameComparisonThread(void* obj) {
363 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
364 }
365
366 bool CompareFrames() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000367 if (AllFramesRecorded())
368 return false;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000369
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700370 VideoFrame reference;
371 VideoFrame render;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000372 FrameComparison comparison;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000373
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000374 if (!PopComparison(&comparison)) {
375 // Wait until new comparison task is available, or test is done.
376 // If done, wake up remaining threads waiting.
377 comparison_available_event_->Wait(1000);
378 if (AllFramesRecorded()) {
379 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000380 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000381 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000382 return true; // Try again.
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000383 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000384
385 PerformFrameComparison(comparison);
386
387 if (FrameProcessed()) {
388 PrintResults();
ivica05cfcd32015-09-07 06:04:16 -0700389 if (!graph_data_output_filename_.empty())
390 PrintSamplesToFile();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000391 done_->Set();
392 comparison_available_event_->Set();
393 return false;
394 }
395
396 return true;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000397 }
398
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000399 bool PopComparison(FrameComparison* comparison) {
Peter Boströmf2f82832015-05-01 13:00:41 +0200400 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000401 // If AllFramesRecorded() is true, it means we have already popped
402 // frames_to_process_ frames from comparisons_, so there is no more work
403 // for this thread to be done. frames_processed_ might still be lower if
404 // all comparisons are not done, but those frames are currently being
405 // worked on by other threads.
406 if (comparisons_.empty() || AllFramesRecorded())
407 return false;
408
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000409 *comparison = comparisons_.front();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000410 comparisons_.pop_front();
411
412 FrameRecorded();
413 return true;
414 }
415
416 // Increment counter for number of frames received for comparison.
417 void FrameRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200418 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000419 ++frames_recorded_;
420 }
421
422 // Returns true if all frames to be compared have been taken from the queue.
423 bool AllFramesRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200424 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000425 assert(frames_recorded_ <= frames_to_process_);
426 return frames_recorded_ == frames_to_process_;
427 }
428
429 // Increase count of number of frames processed. Returns true if this was the
430 // last frame to be processed.
431 bool FrameProcessed() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200432 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000433 ++frames_processed_;
434 assert(frames_processed_ <= frames_to_process_);
435 return frames_processed_ == frames_to_process_;
436 }
437
438 void PrintResults() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200439 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000440 PrintResult("psnr", psnr_, " dB");
441 PrintResult("ssim", ssim_, "");
442 PrintResult("sender_time", sender_time_, " ms");
443 printf("RESULT dropped_frames: %s = %d frames\n", test_label_,
444 dropped_frames_);
445 PrintResult("receiver_time", receiver_time_, " ms");
446 PrintResult("total_delay_incl_network", end_to_end_, " ms");
447 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
Erik Språng085856c2015-07-22 17:17:58 +0200448 PrintResult("encoded_frame_size", encoded_frame_size_, " bytes");
449 PrintResult("encode_frame_rate", encode_frame_rate_, " fps");
450 PrintResult("encode_time", encode_time_ms, " ms");
451 PrintResult("encode_usage_percent", encode_usage_percent, " percent");
452 PrintResult("media_bitrate", media_bitrate_bps, " bps");
453
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000454 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
455 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
456 }
457
458 void PerformFrameComparison(const FrameComparison& comparison) {
459 // Perform expensive psnr and ssim calculations while not holding lock.
magjed@webrtc.org2056ee32015-03-16 13:46:52 +0000460 double psnr = I420PSNR(&comparison.reference, &comparison.render);
461 double ssim = I420SSIM(&comparison.reference, &comparison.render);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000462
ivica05cfcd32015-09-07 06:04:16 -0700463 int64_t input_time_ms = comparison.reference.ntp_time_ms();
464
Peter Boströmf2f82832015-05-01 13:00:41 +0200465 rtc::CritScope crit(&comparison_lock_);
ivica05cfcd32015-09-07 06:04:16 -0700466 if (!graph_data_output_filename_.empty()) {
467 samples_.push_back(Sample(
468 comparison.dropped, input_time_ms, comparison.send_time_ms,
469 comparison.recv_time_ms, comparison.encoded_frame_size, psnr, ssim,
470 comparison.render_time_ms));
471 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000472 psnr_.AddSample(psnr);
473 ssim_.AddSample(ssim);
ivica05cfcd32015-09-07 06:04:16 -0700474
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000475 if (comparison.dropped) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000476 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000477 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000478 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000479 if (last_render_time_ != 0)
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000480 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_);
481 last_render_time_ = comparison.render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000482
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000483 sender_time_.AddSample(comparison.send_time_ms - input_time_ms);
484 receiver_time_.AddSample(comparison.render_time_ms -
485 comparison.recv_time_ms);
486 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms);
ivica05cfcd32015-09-07 06:04:16 -0700487 encoded_frame_size_.AddSample(comparison.encoded_frame_size);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000488 }
489
490 void PrintResult(const char* result_type,
491 test::Statistics stats,
492 const char* unit) {
493 printf("RESULT %s: %s = {%f, %f}%s\n",
494 result_type,
495 test_label_,
496 stats.Mean(),
497 stats.StandardDeviation(),
498 unit);
499 }
500
ivica05cfcd32015-09-07 06:04:16 -0700501 void PrintSamplesToFile(void) {
502 FILE* out = fopen(graph_data_output_filename_.c_str(), "w");
henrikg91d6ede2015-09-17 00:24:34 -0700503 RTC_CHECK(out != nullptr) << "Couldn't open file: "
504 << graph_data_output_filename_;
ivica05cfcd32015-09-07 06:04:16 -0700505
506 rtc::CritScope crit(&comparison_lock_);
507 std::sort(samples_.begin(), samples_.end(),
508 [](const Sample& A, const Sample& B)
509 -> bool { return A.input_time_ms < B.input_time_ms; });
510
511 fprintf(out, "%s\n", test_label_);
512 fprintf(out, "%" PRIuS "\n", samples_.size());
513 fprintf(out,
514 "dropped "
515 "input_time_ms "
516 "send_time_ms "
517 "recv_time_ms "
518 "encoded_frame_size "
519 "psnr "
520 "ssim "
521 "render_time_ms\n");
522 for (const Sample& sample : samples_) {
523 fprintf(out, "%lf %lf %lf %lf %lf %lf %lf %lf\n", sample.dropped,
524 sample.input_time_ms, sample.send_time_ms, sample.recv_time_ms,
525 sample.encoded_frame_size, sample.psnr, sample.ssim,
526 sample.render_time_ms);
527 }
528 fclose(out);
529 }
530
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000531 const char* const test_label_;
ivica05cfcd32015-09-07 06:04:16 -0700532 std::string graph_data_output_filename_;
533 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_);
Erik Språng085856c2015-07-22 17:17:58 +0200534 test::Statistics sender_time_ GUARDED_BY(comparison_lock_);
535 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_);
536 test::Statistics psnr_ GUARDED_BY(comparison_lock_);
537 test::Statistics ssim_ GUARDED_BY(comparison_lock_);
538 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_);
539 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_);
540 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_);
541 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_);
542 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_);
543 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_);
544 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_);
545
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000546 const int frames_to_process_;
547 int frames_recorded_;
548 int frames_processed_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000549 int dropped_frames_;
550 int64_t last_render_time_;
551 uint32_t rtp_timestamp_delta_;
552
Peter Boströmf2f82832015-05-01 13:00:41 +0200553 rtc::CriticalSection crit_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700554 std::deque<VideoFrame> frames_ GUARDED_BY(crit_);
ivica05cfcd32015-09-07 06:04:16 -0700555 std::deque<VideoSendStream::Stats> send_stats_ GUARDED_BY(crit_);
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700556 VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000557 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
558 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
ivica05cfcd32015-09-07 06:04:16 -0700559 std::map<uint32_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_);
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700560 VideoFrame first_send_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgb35b1362014-10-20 09:14:38 +0000561 const double avg_psnr_threshold_;
562 const double avg_ssim_threshold_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000563
Peter Boströmf2f82832015-05-01 13:00:41 +0200564 rtc::CriticalSection comparison_lock_;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000565 std::vector<ThreadWrapper*> comparison_thread_pool_;
Erik Språng085856c2015-07-22 17:17:58 +0200566 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000567 const rtc::scoped_ptr<EventWrapper> comparison_available_event_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000568 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000569 const rtc::scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000570};
571
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000572void FullStackTest::RunTest(const FullStackTestParams& params) {
ivica05cfcd32015-09-07 06:04:16 -0700573 // TODO(ivica): Add num_temporal_layers as a param.
574 unsigned char num_temporal_layers =
575 params.graph_data_output_filename.empty() ? 2 : 1;
576
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000577 test::DirectTransport send_transport(params.link);
578 test::DirectTransport recv_transport(params.link);
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000579 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000580 params.avg_psnr_threshold, params.avg_ssim_threshold,
ivica05cfcd32015-09-07 06:04:16 -0700581 params.test_durations_secs * params.clip.fps,
582 params.graph_data_output_filename);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000583
solenberg4fbae2b2015-08-28 04:07:10 -0700584 CreateCalls(Call::Config(), Call::Config());
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000585
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000586 analyzer.SetReceiver(receiver_call_->Receiver());
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000587 send_transport.SetReceiver(&analyzer);
588 recv_transport.SetReceiver(sender_call_->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000589
solenberg4fbae2b2015-08-28 04:07:10 -0700590 CreateSendConfig(1, &analyzer);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000591
ivica028cf482015-07-30 02:15:56 -0700592 rtc::scoped_ptr<VideoEncoder> encoder;
593 if (params.codec == "VP8") {
594 encoder =
595 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp8));
596 send_config_.encoder_settings.encoder = encoder.get();
597 send_config_.encoder_settings.payload_name = "VP8";
598 } else if (params.codec == "VP9") {
599 encoder =
600 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp9));
601 send_config_.encoder_settings.encoder = encoder.get();
602 send_config_.encoder_settings.payload_name = "VP9";
603 } else {
604 RTC_NOTREACHED() << "Codec not supported!";
605 return;
606 }
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000607 send_config_.encoder_settings.payload_type = 124;
ivica028cf482015-07-30 02:15:56 -0700608
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000609 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000610 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]);
611 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000612
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000613 VideoStream* stream = &encoder_config_.streams[0];
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000614 stream->width = params.clip.width;
615 stream->height = params.clip.height;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000616 stream->min_bitrate_bps = params.min_bitrate_bps;
617 stream->target_bitrate_bps = params.target_bitrate_bps;
618 stream->max_bitrate_bps = params.max_bitrate_bps;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000619 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000620
ivica028cf482015-07-30 02:15:56 -0700621 VideoCodecVP8 vp8_settings;
622 VideoCodecVP9 vp9_settings;
Erik Språng6ee69aa2015-09-03 15:58:05 +0200623 if (params.mode == ContentMode::kScreensharingStaticImage ||
624 params.mode == ContentMode::kScreensharingScrollingImage) {
Erik Språng143cec12015-04-28 10:01:41 +0200625 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000626 encoder_config_.min_transmit_bitrate_bps = 400 * 1000;
ivica028cf482015-07-30 02:15:56 -0700627 if (params.codec == "VP8") {
628 vp8_settings = VideoEncoder::GetDefaultVp8Settings();
629 vp8_settings.denoisingOn = false;
630 vp8_settings.frameDroppingOn = false;
ivica05cfcd32015-09-07 06:04:16 -0700631 vp8_settings.numberOfTemporalLayers = num_temporal_layers;
ivica028cf482015-07-30 02:15:56 -0700632 encoder_config_.encoder_specific_settings = &vp8_settings;
633 } else if (params.codec == "VP9") {
634 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
635 vp9_settings.denoisingOn = false;
636 vp9_settings.frameDroppingOn = false;
ivica05cfcd32015-09-07 06:04:16 -0700637 vp9_settings.numberOfTemporalLayers = num_temporal_layers;
ivica028cf482015-07-30 02:15:56 -0700638 encoder_config_.encoder_specific_settings = &vp9_settings;
639 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000640
641 stream->temporal_layer_thresholds_bps.clear();
ivica05cfcd32015-09-07 06:04:16 -0700642 if (num_temporal_layers > 1) {
643 stream->temporal_layer_thresholds_bps.push_back(
644 stream->target_bitrate_bps);
645 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000646 }
647
solenberg4fbae2b2015-08-28 04:07:10 -0700648 CreateMatchingReceiveConfigs(&recv_transport);
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000649 receive_configs_[0].renderer = &analyzer;
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000650 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000651 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0];
652 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type =
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000653 kSendRtxPayloadType;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000654
Erik Språng085856c2015-07-22 17:17:58 +0200655 for (auto& config : receive_configs_)
656 config.pre_decode_callback = &analyzer;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000657 CreateStreams();
658 analyzer.input_ = send_stream_->Input();
Erik Språng085856c2015-07-22 17:17:58 +0200659 analyzer.send_stream_ = send_stream_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000660
Erik Språng6ee69aa2015-09-03 15:58:05 +0200661 std::vector<std::string> slides;
662 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
663 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
664 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
665 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
666 size_t kSlidesWidth = 1850;
667 size_t kSlidesHeight = 1110;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000668
Erik Språng6ee69aa2015-09-03 15:58:05 +0200669 Clock* clock = Clock::GetRealTimeClock();
670 rtc::scoped_ptr<test::FrameGenerator> frame_generator;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000671
Erik Språng6ee69aa2015-09-03 15:58:05 +0200672 switch (params.mode) {
673 case ContentMode::kRealTimeVideo:
674 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
675 std::vector<std::string>(1,
676 test::ResourcePath(params.clip.name, "yuv")),
677 params.clip.width, params.clip.height, 1));
678 break;
679 case ContentMode::kScreensharingScrollingImage:
680 frame_generator.reset(
681 test::FrameGenerator::CreateScrollingInputFromYuvFiles(
682 clock, slides, kSlidesWidth, kSlidesHeight, params.clip.width,
683 params.clip.height, 2000,
684 8000)); // Scroll for 2 seconds, then pause for 8.
685 break;
686 case ContentMode::kScreensharingStaticImage:
687 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
688 slides, kSlidesWidth, kSlidesHeight,
689 10 * params.clip.fps)); // Cycle image every 10 seconds.
690 break;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000691 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000692
Erik Språng6ee69aa2015-09-03 15:58:05 +0200693 ASSERT_TRUE(frame_generator.get() != nullptr);
694 frame_generator_capturer_.reset(new test::FrameGeneratorCapturer(
695 clock, &analyzer, frame_generator.release(), params.clip.fps));
696 ASSERT_TRUE(frame_generator_capturer_->Init());
697
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000698 Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000699
700 analyzer.Wait();
701
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000702 send_transport.StopSending();
703 recv_transport.StopSending();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000704
705 Stop();
706
707 DestroyStreams();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000708}
709
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000710TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000711 FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
712 {"paris_qcif", 176, 144, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200713 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000714 300000,
715 300000,
716 300000,
717 36.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000718 0.96,
ivica028cf482015-07-30 02:15:56 -0700719 kFullStackTestDurationSecs,
720 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000721 RunTest(paris_qcif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000722}
723
724TEST_F(FullStackTest, ForemanCifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000725 // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
726 FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
727 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200728 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000729 700000,
730 700000,
731 700000,
732 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000733 0.0,
ivica028cf482015-07-30 02:15:56 -0700734 kFullStackTestDurationSecs,
735 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000736 RunTest(foreman_cif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000737}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000738
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000739TEST_F(FullStackTest, ForemanCifPlr5) {
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000740 FullStackTestParams foreman_cif = {"foreman_cif_delay_50_0_plr_5",
741 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200742 ContentMode::kRealTimeVideo,
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000743 30000,
744 500000,
745 2000000,
746 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000747 0.0,
ivica028cf482015-07-30 02:15:56 -0700748 kFullStackTestDurationSecs,
749 "VP8"};
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000750 foreman_cif.link.loss_percent = 5;
751 foreman_cif.link.queue_delay_ms = 50;
752 RunTest(foreman_cif);
753}
754
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000755TEST_F(FullStackTest, ForemanCif500kbps) {
756 FullStackTestParams foreman_cif = {"foreman_cif_500kbps",
757 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200758 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000759 30000,
760 500000,
761 2000000,
762 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000763 0.0,
ivica028cf482015-07-30 02:15:56 -0700764 kFullStackTestDurationSecs,
765 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000766 foreman_cif.link.queue_length_packets = 0;
767 foreman_cif.link.queue_delay_ms = 0;
768 foreman_cif.link.link_capacity_kbps = 500;
769 RunTest(foreman_cif);
770}
771
772TEST_F(FullStackTest, ForemanCif500kbpsLimitedQueue) {
773 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_32pkts_queue",
774 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200775 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000776 30000,
777 500000,
778 2000000,
779 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000780 0.0,
ivica028cf482015-07-30 02:15:56 -0700781 kFullStackTestDurationSecs,
782 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000783 foreman_cif.link.queue_length_packets = 32;
784 foreman_cif.link.queue_delay_ms = 0;
785 foreman_cif.link.link_capacity_kbps = 500;
786 RunTest(foreman_cif);
787}
788
789TEST_F(FullStackTest, ForemanCif500kbps100ms) {
790 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms",
791 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200792 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000793 30000,
794 500000,
795 2000000,
796 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000797 0.0,
ivica028cf482015-07-30 02:15:56 -0700798 kFullStackTestDurationSecs,
799 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000800 foreman_cif.link.queue_length_packets = 0;
801 foreman_cif.link.queue_delay_ms = 100;
802 foreman_cif.link.link_capacity_kbps = 500;
803 RunTest(foreman_cif);
804}
805
806TEST_F(FullStackTest, ForemanCif500kbps100msLimitedQueue) {
807 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms_32pkts_queue",
808 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200809 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000810 30000,
811 500000,
812 2000000,
813 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000814 0.0,
ivica028cf482015-07-30 02:15:56 -0700815 kFullStackTestDurationSecs,
816 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000817 foreman_cif.link.queue_length_packets = 32;
818 foreman_cif.link.queue_delay_ms = 100;
819 foreman_cif.link.link_capacity_kbps = 500;
820 RunTest(foreman_cif);
821}
822
823TEST_F(FullStackTest, ForemanCif1000kbps100msLimitedQueue) {
824 FullStackTestParams foreman_cif = {"foreman_cif_1000kbps_100ms_32pkts_queue",
825 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200826 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000827 30000,
828 2000000,
829 2000000,
830 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000831 0.0,
ivica028cf482015-07-30 02:15:56 -0700832 kFullStackTestDurationSecs,
833 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000834 foreman_cif.link.queue_length_packets = 32;
835 foreman_cif.link.queue_delay_ms = 100;
836 foreman_cif.link.link_capacity_kbps = 1000;
837 RunTest(foreman_cif);
838}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000839
Peter Boströmb21fd942015-07-23 13:14:20 +0200840// Temporarily disabled on Android due to low test timeouts.
841// https://code.google.com/p/chromium/issues/detail?id=513170
842#include "webrtc/test/testsupport/gtest_disable.h"
ivica028cf482015-07-30 02:15:56 -0700843TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL)) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000844 FullStackTestParams screenshare_params = {
845 "screenshare_slides",
846 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200847 ContentMode::kScreensharingStaticImage,
848 50000,
849 200000,
850 2000000,
851 0.0,
852 0.0,
853 kFullStackTestDurationSecs,
854 "VP8"};
855 RunTest(screenshare_params);
856}
857
858TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL_Scroll)) {
859 FullStackTestParams screenshare_params = {
860 "screenshare_slides_scrolling",
861 // Crop height by two, scrolling vertically only.
862 {"screenshare_slides_scrolling", 1850, 1110 / 2, 5},
863 ContentMode::kScreensharingScrollingImage,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000864 50000,
Erik Språng2c4c9142015-06-24 11:24:44 +0200865 200000,
866 2000000,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000867 0.0,
868 0.0,
ivica028cf482015-07-30 02:15:56 -0700869 kFullStackTestDurationSecs,
870 "VP8"};
871 RunTest(screenshare_params);
872}
873
ivicad6b243f2015-08-11 10:43:02 -0700874// Disabled on Android along with VP8 screenshare above.
875TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP9_2TL)) {
ivica028cf482015-07-30 02:15:56 -0700876 FullStackTestParams screenshare_params = {
877 "screenshare_slides_vp9_2tl",
878 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200879 ContentMode::kScreensharingStaticImage,
ivica028cf482015-07-30 02:15:56 -0700880 50000,
881 200000,
882 2000000,
883 0.0,
884 0.0,
885 kFullStackTestDurationSecs,
886 "VP9"};
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000887 RunTest(screenshare_params);
888}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000889} // namespace webrtc