blob: 45c28ad6235c1956a074bc76ede7307b265dbe7e [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();
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +000080 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
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200112 DeliveryStatus DeliverPacket(MediaType media_type, const uint8_t* packet,
113 size_t length) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000114 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000115 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000116 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000117 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200118 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000119 recv_times_[header.timestamp - rtp_timestamp_delta_] =
120 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
121 }
122
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200123 return receiver_->DeliverPacket(media_type, packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000124 }
125
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700126 void IncomingCapturedFrame(const VideoFrame& video_frame) override {
127 VideoFrame copy = video_frame;
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000128 copy.set_timestamp(copy.ntp_time_ms() * 90);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000129
130 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200131 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000132 if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000133 first_send_frame_ = copy;
134
135 frames_.push_back(copy);
136 }
137
perkj@webrtc.orgaf612d52015-03-18 09:51:05 +0000138 input_->IncomingCapturedFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000139 }
140
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000141 bool SendRtp(const uint8_t* packet, size_t length) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000142 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000143 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000144 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000145
146 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200147 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000148 if (rtp_timestamp_delta_ == 0) {
149 rtp_timestamp_delta_ =
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000150 header.timestamp - first_send_frame_.timestamp();
151 first_send_frame_.Reset();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000152 }
ivica05cfcd32015-09-07 06:04:16 -0700153 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_;
154 send_times_[timestamp] =
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000155 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
ivica05cfcd32015-09-07 06:04:16 -0700156 encoded_frame_sizes_[timestamp] +=
157 length - (header.headerLength + header.paddingLength);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000158 }
159
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000160 return transport_->SendRtp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000161 }
162
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000163 bool SendRtcp(const uint8_t* packet, size_t length) override {
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000164 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000165 }
166
Erik Språng085856c2015-07-22 17:17:58 +0200167 void EncodedFrameCallback(const EncodedFrame& frame) override {
168 rtc::CritScope lock(&comparison_lock_);
169 if (frames_recorded_ < frames_to_process_)
170 encoded_frame_size_.AddSample(frame.length_);
171 }
172
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700173 void RenderFrame(const VideoFrame& video_frame,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000174 int time_to_render_ms) override {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000175 int64_t render_time_ms =
176 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000177 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
178
Peter Boströmf2f82832015-05-01 13:00:41 +0200179 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000180
181 while (frames_.front().timestamp() < send_timestamp) {
182 AddFrameComparison(frames_.front(), last_rendered_frame_, true,
183 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000184 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000185 }
186
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700187 VideoFrame reference_frame = frames_.front();
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000188 frames_.pop_front();
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000189 assert(!reference_frame.IsZeroSize());
190 EXPECT_EQ(reference_frame.timestamp(), send_timestamp);
191 assert(reference_frame.timestamp() == send_timestamp);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000192
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000193 AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000194
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000195 last_rendered_frame_ = video_frame;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000196 }
197
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000198 bool IsTextureSupported() const override { return false; }
pbos@webrtc.org0d852d52015-02-09 15:14:36 +0000199
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000200 void Wait() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000201 // Frame comparisons can be very expensive. Wait for test to be done, but
202 // at time-out check if frames_processed is going up. If so, give it more
203 // time, otherwise fail. Hopefully this will reduce test flakiness.
204
205 int last_frames_processed = -1;
206 EventTypeWrapper eventType;
Erik Språng2c274302015-08-31 17:21:14 +0200207 int iteration = 0;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000208 while ((eventType = done_->Wait(FullStackTest::kDefaultTimeoutMs)) !=
209 kEventSignaled) {
210 int frames_processed;
211 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200212 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000213 frames_processed = frames_processed_;
214 }
Erik Språng2c274302015-08-31 17:21:14 +0200215
216 // Print some output so test infrastructure won't think we've crashed.
217 const char* kKeepAliveMessages[3] = {
218 "Uh, I'm-I'm not quite dead, sir.",
219 "Uh, I-I think uh, I could pull through, sir.",
220 "Actually, I think I'm all right to come with you--"};
221 printf("- %s\n", kKeepAliveMessages[iteration++ % 3]);
222
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000223 if (last_frames_processed == -1) {
224 last_frames_processed = frames_processed;
225 continue;
226 }
227 ASSERT_GT(frames_processed, last_frames_processed)
228 << "Analyzer stalled while waiting for test to finish.";
229 last_frames_processed = frames_processed;
230 }
Erik Språng085856c2015-07-22 17:17:58 +0200231
Erik Språng2c274302015-08-31 17:21:14 +0200232 if (iteration > 0)
233 printf("- Farewell, sweet Concorde!\n");
234
Erik Språng085856c2015-07-22 17:17:58 +0200235 // Signal stats polling thread if that is still waiting and stop it now,
236 // since it uses the send_stream_ reference that might be reclaimed after
237 // returning from this method.
238 done_->Set();
239 EXPECT_TRUE(stats_polling_thread_->Stop());
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000240 }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000241
Peter Boström4b91bd02015-06-26 06:58:16 +0200242 VideoCaptureInput* input_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000243 Transport* transport_;
244 PacketReceiver* receiver_;
Erik Språng085856c2015-07-22 17:17:58 +0200245 VideoSendStream* send_stream_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000246
247 private:
248 struct FrameComparison {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000249 FrameComparison()
ivica05cfcd32015-09-07 06:04:16 -0700250 : dropped(false),
251 send_time_ms(0),
252 recv_time_ms(0),
253 render_time_ms(0),
254 encoded_frame_size(0) {}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000255
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700256 FrameComparison(const VideoFrame& reference,
257 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000258 bool dropped,
259 int64_t send_time_ms,
260 int64_t recv_time_ms,
ivica05cfcd32015-09-07 06:04:16 -0700261 int64_t render_time_ms,
262 size_t encoded_frame_size)
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000263 : reference(reference),
264 render(render),
265 dropped(dropped),
pbos@webrtc.org94015242013-10-16 11:05:37 +0000266 send_time_ms(send_time_ms),
267 recv_time_ms(recv_time_ms),
ivica05cfcd32015-09-07 06:04:16 -0700268 render_time_ms(render_time_ms),
269 encoded_frame_size(encoded_frame_size) {}
pbos@webrtc.org94015242013-10-16 11:05:37 +0000270
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700271 VideoFrame reference;
272 VideoFrame render;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000273 bool dropped;
274 int64_t send_time_ms;
275 int64_t recv_time_ms;
276 int64_t render_time_ms;
ivica05cfcd32015-09-07 06:04:16 -0700277 size_t encoded_frame_size;
278 };
279
280 struct Sample {
281 Sample(double dropped,
282 double input_time_ms,
283 double send_time_ms,
284 double recv_time_ms,
285 double encoded_frame_size,
286 double psnr,
287 double ssim,
288 double render_time_ms)
289 : dropped(dropped),
290 input_time_ms(input_time_ms),
291 send_time_ms(send_time_ms),
292 recv_time_ms(recv_time_ms),
293 encoded_frame_size(encoded_frame_size),
294 psnr(psnr),
295 ssim(ssim),
296 render_time_ms(render_time_ms) {}
297
298 double dropped;
299 double input_time_ms;
300 double send_time_ms;
301 double recv_time_ms;
302 double encoded_frame_size;
303 double psnr;
304 double ssim;
305 double render_time_ms;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000306 };
307
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700308 void AddFrameComparison(const VideoFrame& reference,
309 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000310 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000311 int64_t render_time_ms)
312 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000313 int64_t send_time_ms = send_times_[reference.timestamp()];
314 send_times_.erase(reference.timestamp());
315 int64_t recv_time_ms = recv_times_[reference.timestamp()];
316 recv_times_.erase(reference.timestamp());
pbos@webrtc.org94015242013-10-16 11:05:37 +0000317
ivica05cfcd32015-09-07 06:04:16 -0700318 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()];
319 encoded_frame_sizes_.erase(reference.timestamp());
320
321 VideoFrame reference_copy;
322 VideoFrame render_copy;
323 reference_copy.CopyFrame(reference);
324 render_copy.CopyFrame(render);
325
Peter Boströmf2f82832015-05-01 13:00:41 +0200326 rtc::CritScope crit(&comparison_lock_);
ivica05cfcd32015-09-07 06:04:16 -0700327 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped,
Erik Språng085856c2015-07-22 17:17:58 +0200328 send_time_ms, recv_time_ms,
ivica05cfcd32015-09-07 06:04:16 -0700329 render_time_ms, encoded_size));
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000330 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000331 }
332
Erik Språng085856c2015-07-22 17:17:58 +0200333 static bool PollStatsThread(void* obj) {
334 return static_cast<VideoAnalyzer*>(obj)->PollStats();
335 }
336
337 bool PollStats() {
338 switch (done_->Wait(kSendStatsPollingIntervalMs)) {
339 case kEventSignaled:
340 case kEventError:
341 done_->Set(); // Make sure main thread is also signaled.
342 return false;
343 case kEventTimeout:
344 break;
345 default:
346 RTC_NOTREACHED();
347 }
348
349 VideoSendStream::Stats stats = send_stream_->GetStats();
350
351 rtc::CritScope crit(&comparison_lock_);
352 encode_frame_rate_.AddSample(stats.encode_frame_rate);
353 encode_time_ms.AddSample(stats.avg_encode_time_ms);
354 encode_usage_percent.AddSample(stats.encode_usage_percent);
355 media_bitrate_bps.AddSample(stats.media_bitrate_bps);
356
357 return true;
358 }
359
pbos@webrtc.org94015242013-10-16 11:05:37 +0000360 static bool FrameComparisonThread(void* obj) {
361 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
362 }
363
364 bool CompareFrames() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000365 if (AllFramesRecorded())
366 return false;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000367
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700368 VideoFrame reference;
369 VideoFrame render;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000370 FrameComparison comparison;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000371
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000372 if (!PopComparison(&comparison)) {
373 // Wait until new comparison task is available, or test is done.
374 // If done, wake up remaining threads waiting.
375 comparison_available_event_->Wait(1000);
376 if (AllFramesRecorded()) {
377 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000378 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000379 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000380 return true; // Try again.
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000381 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000382
383 PerformFrameComparison(comparison);
384
385 if (FrameProcessed()) {
386 PrintResults();
ivica05cfcd32015-09-07 06:04:16 -0700387 if (!graph_data_output_filename_.empty())
388 PrintSamplesToFile();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000389 done_->Set();
390 comparison_available_event_->Set();
391 return false;
392 }
393
394 return true;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000395 }
396
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000397 bool PopComparison(FrameComparison* comparison) {
Peter Boströmf2f82832015-05-01 13:00:41 +0200398 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000399 // If AllFramesRecorded() is true, it means we have already popped
400 // frames_to_process_ frames from comparisons_, so there is no more work
401 // for this thread to be done. frames_processed_ might still be lower if
402 // all comparisons are not done, but those frames are currently being
403 // worked on by other threads.
404 if (comparisons_.empty() || AllFramesRecorded())
405 return false;
406
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000407 *comparison = comparisons_.front();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000408 comparisons_.pop_front();
409
410 FrameRecorded();
411 return true;
412 }
413
414 // Increment counter for number of frames received for comparison.
415 void FrameRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200416 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000417 ++frames_recorded_;
418 }
419
420 // Returns true if all frames to be compared have been taken from the queue.
421 bool AllFramesRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200422 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000423 assert(frames_recorded_ <= frames_to_process_);
424 return frames_recorded_ == frames_to_process_;
425 }
426
427 // Increase count of number of frames processed. Returns true if this was the
428 // last frame to be processed.
429 bool FrameProcessed() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200430 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000431 ++frames_processed_;
432 assert(frames_processed_ <= frames_to_process_);
433 return frames_processed_ == frames_to_process_;
434 }
435
436 void PrintResults() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200437 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000438 PrintResult("psnr", psnr_, " dB");
439 PrintResult("ssim", ssim_, "");
440 PrintResult("sender_time", sender_time_, " ms");
441 printf("RESULT dropped_frames: %s = %d frames\n", test_label_,
442 dropped_frames_);
443 PrintResult("receiver_time", receiver_time_, " ms");
444 PrintResult("total_delay_incl_network", end_to_end_, " ms");
445 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
Erik Språng085856c2015-07-22 17:17:58 +0200446 PrintResult("encoded_frame_size", encoded_frame_size_, " bytes");
447 PrintResult("encode_frame_rate", encode_frame_rate_, " fps");
448 PrintResult("encode_time", encode_time_ms, " ms");
449 PrintResult("encode_usage_percent", encode_usage_percent, " percent");
450 PrintResult("media_bitrate", media_bitrate_bps, " bps");
451
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000452 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
453 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
454 }
455
456 void PerformFrameComparison(const FrameComparison& comparison) {
457 // Perform expensive psnr and ssim calculations while not holding lock.
magjed@webrtc.org2056ee32015-03-16 13:46:52 +0000458 double psnr = I420PSNR(&comparison.reference, &comparison.render);
459 double ssim = I420SSIM(&comparison.reference, &comparison.render);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000460
ivica05cfcd32015-09-07 06:04:16 -0700461 int64_t input_time_ms = comparison.reference.ntp_time_ms();
462
Peter Boströmf2f82832015-05-01 13:00:41 +0200463 rtc::CritScope crit(&comparison_lock_);
ivica05cfcd32015-09-07 06:04:16 -0700464 if (!graph_data_output_filename_.empty()) {
465 samples_.push_back(Sample(
466 comparison.dropped, input_time_ms, comparison.send_time_ms,
467 comparison.recv_time_ms, comparison.encoded_frame_size, psnr, ssim,
468 comparison.render_time_ms));
469 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000470 psnr_.AddSample(psnr);
471 ssim_.AddSample(ssim);
ivica05cfcd32015-09-07 06:04:16 -0700472
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000473 if (comparison.dropped) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000474 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000475 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000476 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000477 if (last_render_time_ != 0)
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000478 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_);
479 last_render_time_ = comparison.render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000480
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000481 sender_time_.AddSample(comparison.send_time_ms - input_time_ms);
482 receiver_time_.AddSample(comparison.render_time_ms -
483 comparison.recv_time_ms);
484 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms);
ivica05cfcd32015-09-07 06:04:16 -0700485 encoded_frame_size_.AddSample(comparison.encoded_frame_size);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000486 }
487
488 void PrintResult(const char* result_type,
489 test::Statistics stats,
490 const char* unit) {
491 printf("RESULT %s: %s = {%f, %f}%s\n",
492 result_type,
493 test_label_,
494 stats.Mean(),
495 stats.StandardDeviation(),
496 unit);
497 }
498
ivica05cfcd32015-09-07 06:04:16 -0700499 void PrintSamplesToFile(void) {
500 FILE* out = fopen(graph_data_output_filename_.c_str(), "w");
501 CHECK(out != nullptr)
502 << "Couldn't open file: " << graph_data_output_filename_;
503
504 rtc::CritScope crit(&comparison_lock_);
505 std::sort(samples_.begin(), samples_.end(),
506 [](const Sample& A, const Sample& B)
507 -> bool { return A.input_time_ms < B.input_time_ms; });
508
509 fprintf(out, "%s\n", test_label_);
510 fprintf(out, "%" PRIuS "\n", samples_.size());
511 fprintf(out,
512 "dropped "
513 "input_time_ms "
514 "send_time_ms "
515 "recv_time_ms "
516 "encoded_frame_size "
517 "psnr "
518 "ssim "
519 "render_time_ms\n");
520 for (const Sample& sample : samples_) {
521 fprintf(out, "%lf %lf %lf %lf %lf %lf %lf %lf\n", sample.dropped,
522 sample.input_time_ms, sample.send_time_ms, sample.recv_time_ms,
523 sample.encoded_frame_size, sample.psnr, sample.ssim,
524 sample.render_time_ms);
525 }
526 fclose(out);
527 }
528
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000529 const char* const test_label_;
ivica05cfcd32015-09-07 06:04:16 -0700530 std::string graph_data_output_filename_;
531 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_);
Erik Språng085856c2015-07-22 17:17:58 +0200532 test::Statistics sender_time_ GUARDED_BY(comparison_lock_);
533 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_);
534 test::Statistics psnr_ GUARDED_BY(comparison_lock_);
535 test::Statistics ssim_ GUARDED_BY(comparison_lock_);
536 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_);
537 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_);
538 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_);
539 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_);
540 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_);
541 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_);
542 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_);
543
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000544 const int frames_to_process_;
545 int frames_recorded_;
546 int frames_processed_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000547 int dropped_frames_;
548 int64_t last_render_time_;
549 uint32_t rtp_timestamp_delta_;
550
Peter Boströmf2f82832015-05-01 13:00:41 +0200551 rtc::CriticalSection crit_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700552 std::deque<VideoFrame> frames_ GUARDED_BY(crit_);
ivica05cfcd32015-09-07 06:04:16 -0700553 std::deque<VideoSendStream::Stats> send_stats_ GUARDED_BY(crit_);
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700554 VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000555 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
556 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
ivica05cfcd32015-09-07 06:04:16 -0700557 std::map<uint32_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_);
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700558 VideoFrame first_send_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgb35b1362014-10-20 09:14:38 +0000559 const double avg_psnr_threshold_;
560 const double avg_ssim_threshold_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000561
Peter Boströmf2f82832015-05-01 13:00:41 +0200562 rtc::CriticalSection comparison_lock_;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000563 std::vector<ThreadWrapper*> comparison_thread_pool_;
Erik Språng085856c2015-07-22 17:17:58 +0200564 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000565 const rtc::scoped_ptr<EventWrapper> comparison_available_event_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000566 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000567 const rtc::scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000568};
569
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000570void FullStackTest::RunTest(const FullStackTestParams& params) {
ivica05cfcd32015-09-07 06:04:16 -0700571 // TODO(ivica): Add num_temporal_layers as a param.
572 unsigned char num_temporal_layers =
573 params.graph_data_output_filename.empty() ? 2 : 1;
574
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000575 test::DirectTransport send_transport(params.link);
576 test::DirectTransport recv_transport(params.link);
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000577 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000578 params.avg_psnr_threshold, params.avg_ssim_threshold,
ivica05cfcd32015-09-07 06:04:16 -0700579 params.test_durations_secs * params.clip.fps,
580 params.graph_data_output_filename);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000581
solenberg4fbae2b2015-08-28 04:07:10 -0700582 CreateCalls(Call::Config(), Call::Config());
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000583
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000584 analyzer.SetReceiver(receiver_call_->Receiver());
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000585 send_transport.SetReceiver(&analyzer);
586 recv_transport.SetReceiver(sender_call_->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000587
solenberg4fbae2b2015-08-28 04:07:10 -0700588 CreateSendConfig(1, &analyzer);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000589
ivica028cf482015-07-30 02:15:56 -0700590 rtc::scoped_ptr<VideoEncoder> encoder;
591 if (params.codec == "VP8") {
592 encoder =
593 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp8));
594 send_config_.encoder_settings.encoder = encoder.get();
595 send_config_.encoder_settings.payload_name = "VP8";
596 } else if (params.codec == "VP9") {
597 encoder =
598 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp9));
599 send_config_.encoder_settings.encoder = encoder.get();
600 send_config_.encoder_settings.payload_name = "VP9";
601 } else {
602 RTC_NOTREACHED() << "Codec not supported!";
603 return;
604 }
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000605 send_config_.encoder_settings.payload_type = 124;
ivica028cf482015-07-30 02:15:56 -0700606
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000607 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000608 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]);
609 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000610
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000611 VideoStream* stream = &encoder_config_.streams[0];
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000612 stream->width = params.clip.width;
613 stream->height = params.clip.height;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000614 stream->min_bitrate_bps = params.min_bitrate_bps;
615 stream->target_bitrate_bps = params.target_bitrate_bps;
616 stream->max_bitrate_bps = params.max_bitrate_bps;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000617 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000618
ivica028cf482015-07-30 02:15:56 -0700619 VideoCodecVP8 vp8_settings;
620 VideoCodecVP9 vp9_settings;
Erik Språng6ee69aa2015-09-03 15:58:05 +0200621 if (params.mode == ContentMode::kScreensharingStaticImage ||
622 params.mode == ContentMode::kScreensharingScrollingImage) {
Erik Språng143cec12015-04-28 10:01:41 +0200623 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000624 encoder_config_.min_transmit_bitrate_bps = 400 * 1000;
ivica028cf482015-07-30 02:15:56 -0700625 if (params.codec == "VP8") {
626 vp8_settings = VideoEncoder::GetDefaultVp8Settings();
627 vp8_settings.denoisingOn = false;
628 vp8_settings.frameDroppingOn = false;
ivica05cfcd32015-09-07 06:04:16 -0700629 vp8_settings.numberOfTemporalLayers = num_temporal_layers;
ivica028cf482015-07-30 02:15:56 -0700630 encoder_config_.encoder_specific_settings = &vp8_settings;
631 } else if (params.codec == "VP9") {
632 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
633 vp9_settings.denoisingOn = false;
634 vp9_settings.frameDroppingOn = false;
ivica05cfcd32015-09-07 06:04:16 -0700635 vp9_settings.numberOfTemporalLayers = num_temporal_layers;
ivica028cf482015-07-30 02:15:56 -0700636 encoder_config_.encoder_specific_settings = &vp9_settings;
637 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000638
639 stream->temporal_layer_thresholds_bps.clear();
ivica05cfcd32015-09-07 06:04:16 -0700640 if (num_temporal_layers > 1) {
641 stream->temporal_layer_thresholds_bps.push_back(
642 stream->target_bitrate_bps);
643 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000644 }
645
solenberg4fbae2b2015-08-28 04:07:10 -0700646 CreateMatchingReceiveConfigs(&recv_transport);
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000647 receive_configs_[0].renderer = &analyzer;
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000648 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000649 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0];
650 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type =
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000651 kSendRtxPayloadType;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000652
Erik Språng085856c2015-07-22 17:17:58 +0200653 for (auto& config : receive_configs_)
654 config.pre_decode_callback = &analyzer;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000655 CreateStreams();
656 analyzer.input_ = send_stream_->Input();
Erik Språng085856c2015-07-22 17:17:58 +0200657 analyzer.send_stream_ = send_stream_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000658
Erik Språng6ee69aa2015-09-03 15:58:05 +0200659 std::vector<std::string> slides;
660 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
661 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
662 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
663 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
664 size_t kSlidesWidth = 1850;
665 size_t kSlidesHeight = 1110;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000666
Erik Språng6ee69aa2015-09-03 15:58:05 +0200667 Clock* clock = Clock::GetRealTimeClock();
668 rtc::scoped_ptr<test::FrameGenerator> frame_generator;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000669
Erik Språng6ee69aa2015-09-03 15:58:05 +0200670 switch (params.mode) {
671 case ContentMode::kRealTimeVideo:
672 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
673 std::vector<std::string>(1,
674 test::ResourcePath(params.clip.name, "yuv")),
675 params.clip.width, params.clip.height, 1));
676 break;
677 case ContentMode::kScreensharingScrollingImage:
678 frame_generator.reset(
679 test::FrameGenerator::CreateScrollingInputFromYuvFiles(
680 clock, slides, kSlidesWidth, kSlidesHeight, params.clip.width,
681 params.clip.height, 2000,
682 8000)); // Scroll for 2 seconds, then pause for 8.
683 break;
684 case ContentMode::kScreensharingStaticImage:
685 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
686 slides, kSlidesWidth, kSlidesHeight,
687 10 * params.clip.fps)); // Cycle image every 10 seconds.
688 break;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000689 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000690
Erik Språng6ee69aa2015-09-03 15:58:05 +0200691 ASSERT_TRUE(frame_generator.get() != nullptr);
692 frame_generator_capturer_.reset(new test::FrameGeneratorCapturer(
693 clock, &analyzer, frame_generator.release(), params.clip.fps));
694 ASSERT_TRUE(frame_generator_capturer_->Init());
695
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000696 Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000697
698 analyzer.Wait();
699
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000700 send_transport.StopSending();
701 recv_transport.StopSending();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000702
703 Stop();
704
705 DestroyStreams();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000706}
707
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000708TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000709 FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
710 {"paris_qcif", 176, 144, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200711 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000712 300000,
713 300000,
714 300000,
715 36.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000716 0.96,
ivica028cf482015-07-30 02:15:56 -0700717 kFullStackTestDurationSecs,
718 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000719 RunTest(paris_qcif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000720}
721
722TEST_F(FullStackTest, ForemanCifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000723 // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
724 FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
725 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200726 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000727 700000,
728 700000,
729 700000,
730 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000731 0.0,
ivica028cf482015-07-30 02:15:56 -0700732 kFullStackTestDurationSecs,
733 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000734 RunTest(foreman_cif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000735}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000736
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000737TEST_F(FullStackTest, ForemanCifPlr5) {
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000738 FullStackTestParams foreman_cif = {"foreman_cif_delay_50_0_plr_5",
739 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200740 ContentMode::kRealTimeVideo,
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000741 30000,
742 500000,
743 2000000,
744 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000745 0.0,
ivica028cf482015-07-30 02:15:56 -0700746 kFullStackTestDurationSecs,
747 "VP8"};
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000748 foreman_cif.link.loss_percent = 5;
749 foreman_cif.link.queue_delay_ms = 50;
750 RunTest(foreman_cif);
751}
752
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000753TEST_F(FullStackTest, ForemanCif500kbps) {
754 FullStackTestParams foreman_cif = {"foreman_cif_500kbps",
755 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200756 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000757 30000,
758 500000,
759 2000000,
760 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000761 0.0,
ivica028cf482015-07-30 02:15:56 -0700762 kFullStackTestDurationSecs,
763 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000764 foreman_cif.link.queue_length_packets = 0;
765 foreman_cif.link.queue_delay_ms = 0;
766 foreman_cif.link.link_capacity_kbps = 500;
767 RunTest(foreman_cif);
768}
769
770TEST_F(FullStackTest, ForemanCif500kbpsLimitedQueue) {
771 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_32pkts_queue",
772 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200773 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000774 30000,
775 500000,
776 2000000,
777 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000778 0.0,
ivica028cf482015-07-30 02:15:56 -0700779 kFullStackTestDurationSecs,
780 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000781 foreman_cif.link.queue_length_packets = 32;
782 foreman_cif.link.queue_delay_ms = 0;
783 foreman_cif.link.link_capacity_kbps = 500;
784 RunTest(foreman_cif);
785}
786
787TEST_F(FullStackTest, ForemanCif500kbps100ms) {
788 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms",
789 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200790 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000791 30000,
792 500000,
793 2000000,
794 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000795 0.0,
ivica028cf482015-07-30 02:15:56 -0700796 kFullStackTestDurationSecs,
797 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000798 foreman_cif.link.queue_length_packets = 0;
799 foreman_cif.link.queue_delay_ms = 100;
800 foreman_cif.link.link_capacity_kbps = 500;
801 RunTest(foreman_cif);
802}
803
804TEST_F(FullStackTest, ForemanCif500kbps100msLimitedQueue) {
805 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms_32pkts_queue",
806 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200807 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000808 30000,
809 500000,
810 2000000,
811 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000812 0.0,
ivica028cf482015-07-30 02:15:56 -0700813 kFullStackTestDurationSecs,
814 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000815 foreman_cif.link.queue_length_packets = 32;
816 foreman_cif.link.queue_delay_ms = 100;
817 foreman_cif.link.link_capacity_kbps = 500;
818 RunTest(foreman_cif);
819}
820
821TEST_F(FullStackTest, ForemanCif1000kbps100msLimitedQueue) {
822 FullStackTestParams foreman_cif = {"foreman_cif_1000kbps_100ms_32pkts_queue",
823 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200824 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000825 30000,
826 2000000,
827 2000000,
828 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000829 0.0,
ivica028cf482015-07-30 02:15:56 -0700830 kFullStackTestDurationSecs,
831 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000832 foreman_cif.link.queue_length_packets = 32;
833 foreman_cif.link.queue_delay_ms = 100;
834 foreman_cif.link.link_capacity_kbps = 1000;
835 RunTest(foreman_cif);
836}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000837
Peter Boströmb21fd942015-07-23 13:14:20 +0200838// Temporarily disabled on Android due to low test timeouts.
839// https://code.google.com/p/chromium/issues/detail?id=513170
840#include "webrtc/test/testsupport/gtest_disable.h"
ivica028cf482015-07-30 02:15:56 -0700841TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL)) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000842 FullStackTestParams screenshare_params = {
843 "screenshare_slides",
844 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200845 ContentMode::kScreensharingStaticImage,
846 50000,
847 200000,
848 2000000,
849 0.0,
850 0.0,
851 kFullStackTestDurationSecs,
852 "VP8"};
853 RunTest(screenshare_params);
854}
855
856TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL_Scroll)) {
857 FullStackTestParams screenshare_params = {
858 "screenshare_slides_scrolling",
859 // Crop height by two, scrolling vertically only.
860 {"screenshare_slides_scrolling", 1850, 1110 / 2, 5},
861 ContentMode::kScreensharingScrollingImage,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000862 50000,
Erik Språng2c4c9142015-06-24 11:24:44 +0200863 200000,
864 2000000,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000865 0.0,
866 0.0,
ivica028cf482015-07-30 02:15:56 -0700867 kFullStackTestDurationSecs,
868 "VP8"};
869 RunTest(screenshare_params);
870}
871
ivicad6b243f2015-08-11 10:43:02 -0700872// Disabled on Android along with VP8 screenshare above.
873TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP9_2TL)) {
ivica028cf482015-07-30 02:15:56 -0700874 FullStackTestParams screenshare_params = {
875 "screenshare_slides_vp9_2tl",
876 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200877 ContentMode::kScreensharingStaticImage,
ivica028cf482015-07-30 02:15:56 -0700878 50000,
879 200000,
880 2000000,
881 0.0,
882 0.0,
883 kFullStackTestDurationSecs,
884 "VP9"};
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000885 RunTest(screenshare_params);
886}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000887} // namespace webrtc