blob: 3995f8a0c043eece619d8e3c3ec16b2fc90bcbd9 [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
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000017#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org38344ed2014-09-24 06:05:00 +000018#include "webrtc/base/thread_annotations.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000019#include "webrtc/call.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000020#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
Erik Språng085856c2015-07-22 17:17:58 +020021#include "webrtc/frame_callback.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000022#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
23#include "webrtc/system_wrappers/interface/clock.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000024#include "webrtc/system_wrappers/interface/cpu_info.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000025#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
26#include "webrtc/system_wrappers/interface/event_wrapper.h"
pbos@webrtc.org94015242013-10-16 11:05:37 +000027#include "webrtc/system_wrappers/interface/sleep.h"
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000028#include "webrtc/test/call_test.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000029#include "webrtc/test/direct_transport.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000030#include "webrtc/test/encoder_settings.h"
31#include "webrtc/test/fake_encoder.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000032#include "webrtc/test/frame_generator.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000033#include "webrtc/test/frame_generator_capturer.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000034#include "webrtc/test/statistics.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000035#include "webrtc/test/testsupport/fileutils.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000036#include "webrtc/typedefs.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
Erik Språng6ee69aa2015-09-03 15:58:05 +020043enum class ContentMode {
44 kRealTimeVideo,
45 kScreensharingStaticImage,
46 kScreensharingScrollingImage,
47};
48
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000049struct FullStackTestParams {
50 const char* test_label;
51 struct {
52 const char* name;
pbos@webrtc.orgf3f13582013-07-09 14:04:46 +000053 size_t width, height;
54 int fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000055 } clip;
Erik Språng6ee69aa2015-09-03 15:58:05 +020056 ContentMode mode;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000057 int min_bitrate_bps;
58 int target_bitrate_bps;
59 int max_bitrate_bps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000060 double avg_psnr_threshold;
61 double avg_ssim_threshold;
sprang@webrtc.org131bea82015-02-18 12:46:06 +000062 int test_durations_secs;
ivica028cf482015-07-30 02:15:56 -070063 std::string codec;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000064 FakeNetworkPipe::Config link;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000065};
66
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000067class FullStackTest : public test::CallTest {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000068 protected:
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000069 void RunTest(const FullStackTestParams& params);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000070};
71
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000072class VideoAnalyzer : public PacketReceiver,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000073 public newapi::Transport,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000074 public VideoRenderer,
Erik Språng085856c2015-07-22 17:17:58 +020075 public VideoCaptureInput,
76 public EncodedFrameObserver {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000077 public:
Peter Boström4b91bd02015-06-26 06:58:16 +020078 VideoAnalyzer(VideoCaptureInput* input,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000079 Transport* transport,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000080 const char* test_label,
81 double avg_psnr_threshold,
82 double avg_ssim_threshold,
pbos@webrtc.org94015242013-10-16 11:05:37 +000083 int duration_frames)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000084 : input_(input),
85 transport_(transport),
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +000086 receiver_(nullptr),
Erik Språng085856c2015-07-22 17:17:58 +020087 send_stream_(nullptr),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000088 test_label_(test_label),
sprang@webrtc.org131bea82015-02-18 12:46:06 +000089 frames_to_process_(duration_frames),
90 frames_recorded_(0),
91 frames_processed_(0),
pbos@webrtc.org94015242013-10-16 11:05:37 +000092 dropped_frames_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000093 last_render_time_(0),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000094 rtp_timestamp_delta_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000095 avg_psnr_threshold_(avg_psnr_threshold),
96 avg_ssim_threshold_(avg_ssim_threshold),
sprang@webrtc.org131bea82015-02-18 12:46:06 +000097 comparison_available_event_(EventWrapper::Create()),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000098 done_(EventWrapper::Create()) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000099 // Create thread pool for CPU-expensive PSNR/SSIM calculations.
100
101 // Try to use about as many threads as cores, but leave kMinCoresLeft alone,
102 // so that we don't accidentally starve "real" worker threads (codec etc).
103 // Also, don't allocate more than kMaxComparisonThreads, even if there are
104 // spare cores.
105
106 uint32_t num_cores = CpuInfo::DetectNumberOfCores();
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000107 DCHECK_GE(num_cores, 1u);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000108 static const uint32_t kMinCoresLeft = 4;
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000109 static const uint32_t kMaxComparisonThreads = 8;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000110
111 if (num_cores <= kMinCoresLeft) {
112 num_cores = 1;
113 } else {
114 num_cores -= kMinCoresLeft;
115 num_cores = std::min(num_cores, kMaxComparisonThreads);
116 }
117
118 for (uint32_t i = 0; i < num_cores; ++i) {
tommi@webrtc.org361981f2015-03-19 14:44:18 +0000119 rtc::scoped_ptr<ThreadWrapper> thread =
tommi@webrtc.org38492c52015-03-22 14:41:46 +0000120 ThreadWrapper::CreateThread(&FrameComparisonThread, this, "Analyzer");
pbos@webrtc.org86639732015-03-13 00:06:21 +0000121 EXPECT_TRUE(thread->Start());
tommi@webrtc.org361981f2015-03-19 14:44:18 +0000122 comparison_thread_pool_.push_back(thread.release());
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000123 }
Erik Språng085856c2015-07-22 17:17:58 +0200124
125 stats_polling_thread_ =
126 ThreadWrapper::CreateThread(&PollStatsThread, this, "StatsPoller");
127 EXPECT_TRUE(stats_polling_thread_->Start());
pbos@webrtc.org94015242013-10-16 11:05:37 +0000128 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000129
130 ~VideoAnalyzer() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000131 for (ThreadWrapper* thread : comparison_thread_pool_) {
132 EXPECT_TRUE(thread->Stop());
133 delete thread;
134 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000135 }
136
pbos@webrtc.org94015242013-10-16 11:05:37 +0000137 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
138
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200139 DeliveryStatus DeliverPacket(MediaType media_type, const uint8_t* packet,
140 size_t length) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000141 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000142 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000143 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000144 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200145 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000146 recv_times_[header.timestamp - rtp_timestamp_delta_] =
147 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
148 }
149
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200150 return receiver_->DeliverPacket(media_type, packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000151 }
152
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700153 void IncomingCapturedFrame(const VideoFrame& video_frame) override {
154 VideoFrame copy = video_frame;
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000155 copy.set_timestamp(copy.ntp_time_ms() * 90);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000156
157 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200158 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000159 if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000160 first_send_frame_ = copy;
161
162 frames_.push_back(copy);
163 }
164
perkj@webrtc.orgaf612d52015-03-18 09:51:05 +0000165 input_->IncomingCapturedFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000166 }
167
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000168 bool SendRtp(const uint8_t* packet, size_t length) override {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000169 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000170 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000171 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000172
173 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200174 rtc::CritScope lock(&crit_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000175 if (rtp_timestamp_delta_ == 0) {
176 rtp_timestamp_delta_ =
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000177 header.timestamp - first_send_frame_.timestamp();
178 first_send_frame_.Reset();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000179 }
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000180 send_times_[header.timestamp - rtp_timestamp_delta_] =
181 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000182 }
183
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000184 return transport_->SendRtp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000185 }
186
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000187 bool SendRtcp(const uint8_t* packet, size_t length) override {
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000188 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000189 }
190
Erik Språng085856c2015-07-22 17:17:58 +0200191 void EncodedFrameCallback(const EncodedFrame& frame) override {
192 rtc::CritScope lock(&comparison_lock_);
193 if (frames_recorded_ < frames_to_process_)
194 encoded_frame_size_.AddSample(frame.length_);
195 }
196
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700197 void RenderFrame(const VideoFrame& video_frame,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000198 int time_to_render_ms) override {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000199 int64_t render_time_ms =
200 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000201 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
202
Peter Boströmf2f82832015-05-01 13:00:41 +0200203 rtc::CritScope lock(&crit_);
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000204
205 while (frames_.front().timestamp() < send_timestamp) {
206 AddFrameComparison(frames_.front(), last_rendered_frame_, true,
207 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000208 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000209 }
210
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700211 VideoFrame reference_frame = frames_.front();
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000212 frames_.pop_front();
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000213 assert(!reference_frame.IsZeroSize());
214 EXPECT_EQ(reference_frame.timestamp(), send_timestamp);
215 assert(reference_frame.timestamp() == send_timestamp);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000216
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000217 AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000218
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000219 last_rendered_frame_ = video_frame;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000220 }
221
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000222 bool IsTextureSupported() const override { return false; }
pbos@webrtc.org0d852d52015-02-09 15:14:36 +0000223
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000224 void Wait() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000225 // Frame comparisons can be very expensive. Wait for test to be done, but
226 // at time-out check if frames_processed is going up. If so, give it more
227 // time, otherwise fail. Hopefully this will reduce test flakiness.
228
229 int last_frames_processed = -1;
230 EventTypeWrapper eventType;
Erik Språng2c274302015-08-31 17:21:14 +0200231 int iteration = 0;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000232 while ((eventType = done_->Wait(FullStackTest::kDefaultTimeoutMs)) !=
233 kEventSignaled) {
234 int frames_processed;
235 {
Peter Boströmf2f82832015-05-01 13:00:41 +0200236 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000237 frames_processed = frames_processed_;
238 }
Erik Språng2c274302015-08-31 17:21:14 +0200239
240 // Print some output so test infrastructure won't think we've crashed.
241 const char* kKeepAliveMessages[3] = {
242 "Uh, I'm-I'm not quite dead, sir.",
243 "Uh, I-I think uh, I could pull through, sir.",
244 "Actually, I think I'm all right to come with you--"};
245 printf("- %s\n", kKeepAliveMessages[iteration++ % 3]);
246
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000247 if (last_frames_processed == -1) {
248 last_frames_processed = frames_processed;
249 continue;
250 }
251 ASSERT_GT(frames_processed, last_frames_processed)
252 << "Analyzer stalled while waiting for test to finish.";
253 last_frames_processed = frames_processed;
254 }
Erik Språng085856c2015-07-22 17:17:58 +0200255
Erik Språng2c274302015-08-31 17:21:14 +0200256 if (iteration > 0)
257 printf("- Farewell, sweet Concorde!\n");
258
Erik Språng085856c2015-07-22 17:17:58 +0200259 // Signal stats polling thread if that is still waiting and stop it now,
260 // since it uses the send_stream_ reference that might be reclaimed after
261 // returning from this method.
262 done_->Set();
263 EXPECT_TRUE(stats_polling_thread_->Stop());
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000264 }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000265
Peter Boström4b91bd02015-06-26 06:58:16 +0200266 VideoCaptureInput* input_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000267 Transport* transport_;
268 PacketReceiver* receiver_;
Erik Språng085856c2015-07-22 17:17:58 +0200269 VideoSendStream* send_stream_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000270
271 private:
272 struct FrameComparison {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000273 FrameComparison()
274 : dropped(false), send_time_ms(0), recv_time_ms(0), render_time_ms(0) {}
275
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700276 FrameComparison(const VideoFrame& reference,
277 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000278 bool dropped,
279 int64_t send_time_ms,
280 int64_t recv_time_ms,
281 int64_t render_time_ms)
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000282 : reference(reference),
283 render(render),
284 dropped(dropped),
pbos@webrtc.org94015242013-10-16 11:05:37 +0000285 send_time_ms(send_time_ms),
286 recv_time_ms(recv_time_ms),
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000287 render_time_ms(render_time_ms) {}
pbos@webrtc.org94015242013-10-16 11:05:37 +0000288
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700289 VideoFrame reference;
290 VideoFrame render;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000291 bool dropped;
292 int64_t send_time_ms;
293 int64_t recv_time_ms;
294 int64_t render_time_ms;
295 };
296
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700297 void AddFrameComparison(const VideoFrame& reference,
298 const VideoFrame& render,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000299 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000300 int64_t render_time_ms)
301 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000302 int64_t send_time_ms = send_times_[reference.timestamp()];
303 send_times_.erase(reference.timestamp());
304 int64_t recv_time_ms = recv_times_[reference.timestamp()];
305 recv_times_.erase(reference.timestamp());
pbos@webrtc.org94015242013-10-16 11:05:37 +0000306
Peter Boströmf2f82832015-05-01 13:00:41 +0200307 rtc::CritScope crit(&comparison_lock_);
Erik Språng085856c2015-07-22 17:17:58 +0200308 comparisons_.push_back(FrameComparison(reference, render, dropped,
309 send_time_ms, recv_time_ms,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000310 render_time_ms));
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000311 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000312 }
313
Erik Språng085856c2015-07-22 17:17:58 +0200314 static bool PollStatsThread(void* obj) {
315 return static_cast<VideoAnalyzer*>(obj)->PollStats();
316 }
317
318 bool PollStats() {
319 switch (done_->Wait(kSendStatsPollingIntervalMs)) {
320 case kEventSignaled:
321 case kEventError:
322 done_->Set(); // Make sure main thread is also signaled.
323 return false;
324 case kEventTimeout:
325 break;
326 default:
327 RTC_NOTREACHED();
328 }
329
330 VideoSendStream::Stats stats = send_stream_->GetStats();
331
332 rtc::CritScope crit(&comparison_lock_);
333 encode_frame_rate_.AddSample(stats.encode_frame_rate);
334 encode_time_ms.AddSample(stats.avg_encode_time_ms);
335 encode_usage_percent.AddSample(stats.encode_usage_percent);
336 media_bitrate_bps.AddSample(stats.media_bitrate_bps);
337
338 return true;
339 }
340
pbos@webrtc.org94015242013-10-16 11:05:37 +0000341 static bool FrameComparisonThread(void* obj) {
342 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
343 }
344
345 bool CompareFrames() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000346 if (AllFramesRecorded())
347 return false;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000348
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700349 VideoFrame reference;
350 VideoFrame render;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000351 FrameComparison comparison;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000352
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000353 if (!PopComparison(&comparison)) {
354 // Wait until new comparison task is available, or test is done.
355 // If done, wake up remaining threads waiting.
356 comparison_available_event_->Wait(1000);
357 if (AllFramesRecorded()) {
358 comparison_available_event_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000359 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000360 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000361 return true; // Try again.
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000362 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000363
364 PerformFrameComparison(comparison);
365
366 if (FrameProcessed()) {
367 PrintResults();
368 done_->Set();
369 comparison_available_event_->Set();
370 return false;
371 }
372
373 return true;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000374 }
375
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000376 bool PopComparison(FrameComparison* comparison) {
Peter Boströmf2f82832015-05-01 13:00:41 +0200377 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000378 // If AllFramesRecorded() is true, it means we have already popped
379 // frames_to_process_ frames from comparisons_, so there is no more work
380 // for this thread to be done. frames_processed_ might still be lower if
381 // all comparisons are not done, but those frames are currently being
382 // worked on by other threads.
383 if (comparisons_.empty() || AllFramesRecorded())
384 return false;
385
pbos@webrtc.org443ad402015-03-20 07:34:28 +0000386 *comparison = comparisons_.front();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000387 comparisons_.pop_front();
388
389 FrameRecorded();
390 return true;
391 }
392
393 // Increment counter for number of frames received for comparison.
394 void FrameRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200395 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000396 ++frames_recorded_;
397 }
398
399 // Returns true if all frames to be compared have been taken from the queue.
400 bool AllFramesRecorded() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200401 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000402 assert(frames_recorded_ <= frames_to_process_);
403 return frames_recorded_ == frames_to_process_;
404 }
405
406 // Increase count of number of frames processed. Returns true if this was the
407 // last frame to be processed.
408 bool FrameProcessed() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200409 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000410 ++frames_processed_;
411 assert(frames_processed_ <= frames_to_process_);
412 return frames_processed_ == frames_to_process_;
413 }
414
415 void PrintResults() {
Peter Boströmf2f82832015-05-01 13:00:41 +0200416 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000417 PrintResult("psnr", psnr_, " dB");
418 PrintResult("ssim", ssim_, "");
419 PrintResult("sender_time", sender_time_, " ms");
420 printf("RESULT dropped_frames: %s = %d frames\n", test_label_,
421 dropped_frames_);
422 PrintResult("receiver_time", receiver_time_, " ms");
423 PrintResult("total_delay_incl_network", end_to_end_, " ms");
424 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
Erik Språng085856c2015-07-22 17:17:58 +0200425 PrintResult("encoded_frame_size", encoded_frame_size_, " bytes");
426 PrintResult("encode_frame_rate", encode_frame_rate_, " fps");
427 PrintResult("encode_time", encode_time_ms, " ms");
428 PrintResult("encode_usage_percent", encode_usage_percent, " percent");
429 PrintResult("media_bitrate", media_bitrate_bps, " bps");
430
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000431 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
432 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
433 }
434
435 void PerformFrameComparison(const FrameComparison& comparison) {
436 // Perform expensive psnr and ssim calculations while not holding lock.
magjed@webrtc.org2056ee32015-03-16 13:46:52 +0000437 double psnr = I420PSNR(&comparison.reference, &comparison.render);
438 double ssim = I420SSIM(&comparison.reference, &comparison.render);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000439
Peter Boströmf2f82832015-05-01 13:00:41 +0200440 rtc::CritScope crit(&comparison_lock_);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000441 psnr_.AddSample(psnr);
442 ssim_.AddSample(ssim);
443 if (comparison.dropped) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000444 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000445 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000446 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000447 if (last_render_time_ != 0)
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000448 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_);
449 last_render_time_ = comparison.render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000450
perkj@webrtc.orgaf612d52015-03-18 09:51:05 +0000451 int64_t input_time_ms = comparison.reference.ntp_time_ms();
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000452 sender_time_.AddSample(comparison.send_time_ms - input_time_ms);
453 receiver_time_.AddSample(comparison.render_time_ms -
454 comparison.recv_time_ms);
455 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000456 }
457
458 void PrintResult(const char* result_type,
459 test::Statistics stats,
460 const char* unit) {
461 printf("RESULT %s: %s = {%f, %f}%s\n",
462 result_type,
463 test_label_,
464 stats.Mean(),
465 stats.StandardDeviation(),
466 unit);
467 }
468
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000469 const char* const test_label_;
Erik Språng085856c2015-07-22 17:17:58 +0200470 test::Statistics sender_time_ GUARDED_BY(comparison_lock_);
471 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_);
472 test::Statistics psnr_ GUARDED_BY(comparison_lock_);
473 test::Statistics ssim_ GUARDED_BY(comparison_lock_);
474 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_);
475 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_);
476 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_);
477 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_);
478 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_);
479 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_);
480 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_);
481
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000482 const int frames_to_process_;
483 int frames_recorded_;
484 int frames_processed_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000485 int dropped_frames_;
486 int64_t last_render_time_;
487 uint32_t rtp_timestamp_delta_;
488
Peter Boströmf2f82832015-05-01 13:00:41 +0200489 rtc::CriticalSection crit_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700490 std::deque<VideoFrame> frames_ GUARDED_BY(crit_);
491 VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000492 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
493 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -0700494 VideoFrame first_send_frame_ GUARDED_BY(crit_);
pbos@webrtc.orgb35b1362014-10-20 09:14:38 +0000495 const double avg_psnr_threshold_;
496 const double avg_ssim_threshold_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000497
Peter Boströmf2f82832015-05-01 13:00:41 +0200498 rtc::CriticalSection comparison_lock_;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000499 std::vector<ThreadWrapper*> comparison_thread_pool_;
Erik Språng085856c2015-07-22 17:17:58 +0200500 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000501 const rtc::scoped_ptr<EventWrapper> comparison_available_event_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000502 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000503 const rtc::scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000504};
505
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000506void FullStackTest::RunTest(const FullStackTestParams& params) {
507 test::DirectTransport send_transport(params.link);
508 test::DirectTransport recv_transport(params.link);
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000509 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000510 params.avg_psnr_threshold, params.avg_ssim_threshold,
511 params.test_durations_secs * params.clip.fps);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000512
solenberg4fbae2b2015-08-28 04:07:10 -0700513 CreateCalls(Call::Config(), Call::Config());
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000514
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000515 analyzer.SetReceiver(receiver_call_->Receiver());
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000516 send_transport.SetReceiver(&analyzer);
517 recv_transport.SetReceiver(sender_call_->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000518
solenberg4fbae2b2015-08-28 04:07:10 -0700519 CreateSendConfig(1, &analyzer);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000520
ivica028cf482015-07-30 02:15:56 -0700521 rtc::scoped_ptr<VideoEncoder> encoder;
522 if (params.codec == "VP8") {
523 encoder =
524 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp8));
525 send_config_.encoder_settings.encoder = encoder.get();
526 send_config_.encoder_settings.payload_name = "VP8";
527 } else if (params.codec == "VP9") {
528 encoder =
529 rtc::scoped_ptr<VideoEncoder>(VideoEncoder::Create(VideoEncoder::kVp9));
530 send_config_.encoder_settings.encoder = encoder.get();
531 send_config_.encoder_settings.payload_name = "VP9";
532 } else {
533 RTC_NOTREACHED() << "Codec not supported!";
534 return;
535 }
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000536 send_config_.encoder_settings.payload_type = 124;
ivica028cf482015-07-30 02:15:56 -0700537
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000538 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000539 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]);
540 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000541
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000542 VideoStream* stream = &encoder_config_.streams[0];
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000543 stream->width = params.clip.width;
544 stream->height = params.clip.height;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000545 stream->min_bitrate_bps = params.min_bitrate_bps;
546 stream->target_bitrate_bps = params.target_bitrate_bps;
547 stream->max_bitrate_bps = params.max_bitrate_bps;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000548 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000549
ivica028cf482015-07-30 02:15:56 -0700550 VideoCodecVP8 vp8_settings;
551 VideoCodecVP9 vp9_settings;
Erik Språng6ee69aa2015-09-03 15:58:05 +0200552 if (params.mode == ContentMode::kScreensharingStaticImage ||
553 params.mode == ContentMode::kScreensharingScrollingImage) {
Erik Språng143cec12015-04-28 10:01:41 +0200554 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000555 encoder_config_.min_transmit_bitrate_bps = 400 * 1000;
ivica028cf482015-07-30 02:15:56 -0700556 if (params.codec == "VP8") {
557 vp8_settings = VideoEncoder::GetDefaultVp8Settings();
558 vp8_settings.denoisingOn = false;
559 vp8_settings.frameDroppingOn = false;
560 vp8_settings.numberOfTemporalLayers = 2;
561 encoder_config_.encoder_specific_settings = &vp8_settings;
562 } else if (params.codec == "VP9") {
563 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
564 vp9_settings.denoisingOn = false;
565 vp9_settings.frameDroppingOn = false;
566 vp9_settings.numberOfTemporalLayers = 2;
567 encoder_config_.encoder_specific_settings = &vp9_settings;
568 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000569
570 stream->temporal_layer_thresholds_bps.clear();
571 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps);
572 }
573
solenberg4fbae2b2015-08-28 04:07:10 -0700574 CreateMatchingReceiveConfigs(&recv_transport);
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000575 receive_configs_[0].renderer = &analyzer;
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000576 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000577 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0];
578 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type =
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000579 kSendRtxPayloadType;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000580
Erik Språng085856c2015-07-22 17:17:58 +0200581 for (auto& config : receive_configs_)
582 config.pre_decode_callback = &analyzer;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000583 CreateStreams();
584 analyzer.input_ = send_stream_->Input();
Erik Språng085856c2015-07-22 17:17:58 +0200585 analyzer.send_stream_ = send_stream_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000586
Erik Språng6ee69aa2015-09-03 15:58:05 +0200587 std::vector<std::string> slides;
588 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
589 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
590 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
591 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
592 size_t kSlidesWidth = 1850;
593 size_t kSlidesHeight = 1110;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000594
Erik Språng6ee69aa2015-09-03 15:58:05 +0200595 Clock* clock = Clock::GetRealTimeClock();
596 rtc::scoped_ptr<test::FrameGenerator> frame_generator;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000597
Erik Språng6ee69aa2015-09-03 15:58:05 +0200598 switch (params.mode) {
599 case ContentMode::kRealTimeVideo:
600 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
601 std::vector<std::string>(1,
602 test::ResourcePath(params.clip.name, "yuv")),
603 params.clip.width, params.clip.height, 1));
604 break;
605 case ContentMode::kScreensharingScrollingImage:
606 frame_generator.reset(
607 test::FrameGenerator::CreateScrollingInputFromYuvFiles(
608 clock, slides, kSlidesWidth, kSlidesHeight, params.clip.width,
609 params.clip.height, 2000,
610 8000)); // Scroll for 2 seconds, then pause for 8.
611 break;
612 case ContentMode::kScreensharingStaticImage:
613 frame_generator.reset(test::FrameGenerator::CreateFromYuvFile(
614 slides, kSlidesWidth, kSlidesHeight,
615 10 * params.clip.fps)); // Cycle image every 10 seconds.
616 break;
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000617 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000618
Erik Språng6ee69aa2015-09-03 15:58:05 +0200619 ASSERT_TRUE(frame_generator.get() != nullptr);
620 frame_generator_capturer_.reset(new test::FrameGeneratorCapturer(
621 clock, &analyzer, frame_generator.release(), params.clip.fps));
622 ASSERT_TRUE(frame_generator_capturer_->Init());
623
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000624 Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000625
626 analyzer.Wait();
627
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000628 send_transport.StopSending();
629 recv_transport.StopSending();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000630
631 Stop();
632
633 DestroyStreams();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000634}
635
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000636TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000637 FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
638 {"paris_qcif", 176, 144, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200639 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000640 300000,
641 300000,
642 300000,
643 36.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000644 0.96,
ivica028cf482015-07-30 02:15:56 -0700645 kFullStackTestDurationSecs,
646 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000647 RunTest(paris_qcif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000648}
649
650TEST_F(FullStackTest, ForemanCifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000651 // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
652 FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
653 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200654 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000655 700000,
656 700000,
657 700000,
658 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000659 0.0,
ivica028cf482015-07-30 02:15:56 -0700660 kFullStackTestDurationSecs,
661 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000662 RunTest(foreman_cif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000663}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000664
sprang@webrtc.org343096a2015-02-23 08:34:17 +0000665TEST_F(FullStackTest, ForemanCifPlr5) {
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000666 FullStackTestParams foreman_cif = {"foreman_cif_delay_50_0_plr_5",
667 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200668 ContentMode::kRealTimeVideo,
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000669 30000,
670 500000,
671 2000000,
672 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000673 0.0,
ivica028cf482015-07-30 02:15:56 -0700674 kFullStackTestDurationSecs,
675 "VP8"};
stefan@webrtc.orgc216b9a2014-10-14 10:38:49 +0000676 foreman_cif.link.loss_percent = 5;
677 foreman_cif.link.queue_delay_ms = 50;
678 RunTest(foreman_cif);
679}
680
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000681TEST_F(FullStackTest, ForemanCif500kbps) {
682 FullStackTestParams foreman_cif = {"foreman_cif_500kbps",
683 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200684 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000685 30000,
686 500000,
687 2000000,
688 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000689 0.0,
ivica028cf482015-07-30 02:15:56 -0700690 kFullStackTestDurationSecs,
691 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000692 foreman_cif.link.queue_length_packets = 0;
693 foreman_cif.link.queue_delay_ms = 0;
694 foreman_cif.link.link_capacity_kbps = 500;
695 RunTest(foreman_cif);
696}
697
698TEST_F(FullStackTest, ForemanCif500kbpsLimitedQueue) {
699 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_32pkts_queue",
700 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200701 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000702 30000,
703 500000,
704 2000000,
705 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000706 0.0,
ivica028cf482015-07-30 02:15:56 -0700707 kFullStackTestDurationSecs,
708 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000709 foreman_cif.link.queue_length_packets = 32;
710 foreman_cif.link.queue_delay_ms = 0;
711 foreman_cif.link.link_capacity_kbps = 500;
712 RunTest(foreman_cif);
713}
714
715TEST_F(FullStackTest, ForemanCif500kbps100ms) {
716 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms",
717 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200718 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000719 30000,
720 500000,
721 2000000,
722 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000723 0.0,
ivica028cf482015-07-30 02:15:56 -0700724 kFullStackTestDurationSecs,
725 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000726 foreman_cif.link.queue_length_packets = 0;
727 foreman_cif.link.queue_delay_ms = 100;
728 foreman_cif.link.link_capacity_kbps = 500;
729 RunTest(foreman_cif);
730}
731
732TEST_F(FullStackTest, ForemanCif500kbps100msLimitedQueue) {
733 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms_32pkts_queue",
734 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200735 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000736 30000,
737 500000,
738 2000000,
739 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000740 0.0,
ivica028cf482015-07-30 02:15:56 -0700741 kFullStackTestDurationSecs,
742 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000743 foreman_cif.link.queue_length_packets = 32;
744 foreman_cif.link.queue_delay_ms = 100;
745 foreman_cif.link.link_capacity_kbps = 500;
746 RunTest(foreman_cif);
747}
748
749TEST_F(FullStackTest, ForemanCif1000kbps100msLimitedQueue) {
750 FullStackTestParams foreman_cif = {"foreman_cif_1000kbps_100ms_32pkts_queue",
751 {"foreman_cif", 352, 288, 30},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200752 ContentMode::kRealTimeVideo,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000753 30000,
754 2000000,
755 2000000,
756 0.0,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000757 0.0,
ivica028cf482015-07-30 02:15:56 -0700758 kFullStackTestDurationSecs,
759 "VP8"};
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000760 foreman_cif.link.queue_length_packets = 32;
761 foreman_cif.link.queue_delay_ms = 100;
762 foreman_cif.link.link_capacity_kbps = 1000;
763 RunTest(foreman_cif);
764}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000765
Peter Boströmb21fd942015-07-23 13:14:20 +0200766// Temporarily disabled on Android due to low test timeouts.
767// https://code.google.com/p/chromium/issues/detail?id=513170
768#include "webrtc/test/testsupport/gtest_disable.h"
ivica028cf482015-07-30 02:15:56 -0700769TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL)) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000770 FullStackTestParams screenshare_params = {
771 "screenshare_slides",
772 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200773 ContentMode::kScreensharingStaticImage,
774 50000,
775 200000,
776 2000000,
777 0.0,
778 0.0,
779 kFullStackTestDurationSecs,
780 "VP8"};
781 RunTest(screenshare_params);
782}
783
784TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP8_2TL_Scroll)) {
785 FullStackTestParams screenshare_params = {
786 "screenshare_slides_scrolling",
787 // Crop height by two, scrolling vertically only.
788 {"screenshare_slides_scrolling", 1850, 1110 / 2, 5},
789 ContentMode::kScreensharingScrollingImage,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000790 50000,
Erik Språng2c4c9142015-06-24 11:24:44 +0200791 200000,
792 2000000,
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000793 0.0,
794 0.0,
ivica028cf482015-07-30 02:15:56 -0700795 kFullStackTestDurationSecs,
796 "VP8"};
797 RunTest(screenshare_params);
798}
799
ivicad6b243f2015-08-11 10:43:02 -0700800// Disabled on Android along with VP8 screenshare above.
801TEST_F(FullStackTest, DISABLED_ON_ANDROID(ScreenshareSlidesVP9_2TL)) {
ivica028cf482015-07-30 02:15:56 -0700802 FullStackTestParams screenshare_params = {
803 "screenshare_slides_vp9_2tl",
804 {"screenshare_slides", 1850, 1110, 5},
Erik Språng6ee69aa2015-09-03 15:58:05 +0200805 ContentMode::kScreensharingStaticImage,
ivica028cf482015-07-30 02:15:56 -0700806 50000,
807 200000,
808 2000000,
809 0.0,
810 0.0,
811 kFullStackTestDurationSecs,
812 "VP9"};
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000813 RunTest(screenshare_params);
814}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000815} // namespace webrtc