blob: a9ddd2c9ba0b119c3e8ae3389722baaff43e84be [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
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000017#include "webrtc/call.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000018#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
19#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000020#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000021#include "webrtc/system_wrappers/interface/clock.h"
22#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
23#include "webrtc/system_wrappers/interface/event_wrapper.h"
24#include "webrtc/system_wrappers/interface/scoped_ptr.h"
pbos@webrtc.org94015242013-10-16 11:05:37 +000025#include "webrtc/system_wrappers/interface/sleep.h"
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000026#include "webrtc/system_wrappers/interface/thread_annotations.h"
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000027#include "webrtc/test/call_test.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000028#include "webrtc/test/direct_transport.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000029#include "webrtc/test/encoder_settings.h"
30#include "webrtc/test/fake_encoder.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000031#include "webrtc/test/frame_generator_capturer.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000032#include "webrtc/test/statistics.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000033#include "webrtc/test/testsupport/fileutils.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000034#include "webrtc/typedefs.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000035
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000036namespace webrtc {
37
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000038static const int kFullStackTestDurationSecs = 60;
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000039
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000040struct FullStackTestParams {
41 const char* test_label;
42 struct {
43 const char* name;
pbos@webrtc.orgf3f13582013-07-09 14:04:46 +000044 size_t width, height;
45 int fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000046 } clip;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000047 int min_bitrate_bps;
48 int target_bitrate_bps;
49 int max_bitrate_bps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000050 double avg_psnr_threshold;
51 double avg_ssim_threshold;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000052 FakeNetworkPipe::Config link;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000053};
54
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000055class FullStackTest : public test::CallTest {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000056 protected:
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +000057 void RunTest(const FullStackTestParams& params);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000058};
59
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000060class VideoAnalyzer : public PacketReceiver,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000061 public newapi::Transport,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000062 public VideoRenderer,
63 public VideoSendStreamInput {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000064 public:
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000065 VideoAnalyzer(VideoSendStreamInput* input,
66 Transport* transport,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000067 const char* test_label,
68 double avg_psnr_threshold,
69 double avg_ssim_threshold,
pbos@webrtc.org94015242013-10-16 11:05:37 +000070 int duration_frames)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000071 : input_(input),
72 transport_(transport),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000073 receiver_(NULL),
74 test_label_(test_label),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000075 frames_left_(duration_frames),
pbos@webrtc.org94015242013-10-16 11:05:37 +000076 dropped_frames_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000077 last_render_time_(0),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000078 rtp_timestamp_delta_(0),
79 crit_(CriticalSectionWrapper::CreateCriticalSection()),
80 first_send_frame_(NULL),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000081 avg_psnr_threshold_(avg_psnr_threshold),
82 avg_ssim_threshold_(avg_ssim_threshold),
pbos@webrtc.org94015242013-10-16 11:05:37 +000083 comparison_lock_(CriticalSectionWrapper::CreateCriticalSection()),
84 comparison_thread_(ThreadWrapper::CreateThread(&FrameComparisonThread,
85 this)),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000086 done_(EventWrapper::Create()) {
pbos@webrtc.org94015242013-10-16 11:05:37 +000087 unsigned int id;
88 EXPECT_TRUE(comparison_thread_->Start(id));
89 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000090
91 ~VideoAnalyzer() {
pbos@webrtc.org94015242013-10-16 11:05:37 +000092 EXPECT_TRUE(comparison_thread_->Stop());
93
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000094 while (!frames_.empty()) {
95 delete frames_.back();
96 frames_.pop_back();
97 }
98 while (!frame_pool_.empty()) {
99 delete frame_pool_.back();
100 frame_pool_.pop_back();
101 }
102 }
103
pbos@webrtc.org94015242013-10-16 11:05:37 +0000104 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
105
pbos@webrtc.orgcaba2d22014-05-14 13:57:12 +0000106 virtual DeliveryStatus DeliverPacket(const uint8_t* packet,
107 size_t length) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000108 scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
109 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000110 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000111 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000112 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000113 recv_times_[header.timestamp - rtp_timestamp_delta_] =
114 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
115 }
116
117 return receiver_->DeliverPacket(packet, length);
118 }
119
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000120 virtual void SwapFrame(I420VideoFrame* video_frame) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000121 I420VideoFrame* copy = NULL;
122 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000123 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000124 if (frame_pool_.size() > 0) {
125 copy = frame_pool_.front();
126 frame_pool_.pop_front();
127 }
128 }
129 if (copy == NULL)
130 copy = new I420VideoFrame();
131
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000132 copy->CopyFrame(*video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000133 copy->set_timestamp(copy->render_time_ms() * 90);
134
135 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000136 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000137 if (first_send_frame_ == NULL && rtp_timestamp_delta_ == 0)
138 first_send_frame_ = copy;
139
140 frames_.push_back(copy);
141 }
142
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000143 input_->SwapFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000144 }
145
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000146 virtual bool SendRtp(const uint8_t* packet, size_t length) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000147 scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
148 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000149 parser->Parse(packet, length, &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000150
151 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000152 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000153 if (rtp_timestamp_delta_ == 0) {
154 rtp_timestamp_delta_ =
155 header.timestamp - first_send_frame_->timestamp();
156 first_send_frame_ = NULL;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000157 }
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000158 send_times_[header.timestamp - rtp_timestamp_delta_] =
159 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
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
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000165 virtual bool SendRtcp(const uint8_t* packet, size_t length) OVERRIDE {
166 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000167 }
168
169 virtual void RenderFrame(const I420VideoFrame& video_frame,
170 int time_to_render_ms) OVERRIDE {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000171 int64_t render_time_ms =
172 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000173 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
174
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000175 CriticalSectionScoped lock(crit_.get());
176 while (frames_.front()->timestamp() < send_timestamp) {
177 AddFrameComparison(
178 frames_.front(), &last_rendered_frame_, true, render_time_ms);
179 frame_pool_.push_back(frames_.front());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000180 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000181 }
182
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000183 I420VideoFrame* reference_frame = frames_.front();
184 frames_.pop_front();
185 assert(reference_frame != NULL);
186 EXPECT_EQ(reference_frame->timestamp(), send_timestamp);
187 assert(reference_frame->timestamp() == send_timestamp);
188
189 AddFrameComparison(reference_frame, &video_frame, false, render_time_ms);
190 frame_pool_.push_back(reference_frame);
191
pbos@webrtc.org94015242013-10-16 11:05:37 +0000192 last_rendered_frame_.CopyFrame(video_frame);
193 }
194
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000195 void Wait() {
196 EXPECT_EQ(kEventSignaled, done_->Wait(FullStackTest::kLongTimeoutMs));
197 }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000198
199 VideoSendStreamInput* input_;
200 Transport* transport_;
201 PacketReceiver* receiver_;
202
203 private:
204 struct FrameComparison {
205 FrameComparison(const I420VideoFrame* reference,
206 const I420VideoFrame* render,
207 bool dropped,
208 int64_t send_time_ms,
209 int64_t recv_time_ms,
210 int64_t render_time_ms)
211 : dropped(dropped),
212 send_time_ms(send_time_ms),
213 recv_time_ms(recv_time_ms),
214 render_time_ms(render_time_ms) {
215 this->reference.CopyFrame(*reference);
216 this->render.CopyFrame(*render);
217 }
218
219 FrameComparison(const FrameComparison& compare)
220 : dropped(compare.dropped),
221 send_time_ms(compare.send_time_ms),
222 recv_time_ms(compare.recv_time_ms),
223 render_time_ms(compare.render_time_ms) {
224 this->reference.CopyFrame(compare.reference);
225 this->render.CopyFrame(compare.render);
226 }
227
228 ~FrameComparison() {}
229
230 I420VideoFrame reference;
231 I420VideoFrame render;
232 bool dropped;
233 int64_t send_time_ms;
234 int64_t recv_time_ms;
235 int64_t render_time_ms;
236 };
237
238 void AddFrameComparison(const I420VideoFrame* reference,
239 const I420VideoFrame* render,
240 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000241 int64_t render_time_ms)
242 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000243 int64_t send_time_ms = send_times_[reference->timestamp()];
244 send_times_.erase(reference->timestamp());
245 int64_t recv_time_ms = recv_times_[reference->timestamp()];
246 recv_times_.erase(reference->timestamp());
247
248 CriticalSectionScoped crit(comparison_lock_.get());
249 comparisons_.push_back(FrameComparison(reference,
250 render,
251 dropped,
252 send_time_ms,
253 recv_time_ms,
254 render_time_ms));
255 }
256
257 static bool FrameComparisonThread(void* obj) {
258 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
259 }
260
261 bool CompareFrames() {
262 assert(frames_left_ > 0);
263
264 I420VideoFrame reference;
265 I420VideoFrame render;
266 bool dropped;
267 int64_t send_time_ms;
268 int64_t recv_time_ms;
269 int64_t render_time_ms;
270
271 SleepMs(10);
272
273 while (true) {
274 {
275 CriticalSectionScoped crit(comparison_lock_.get());
276 if (comparisons_.empty())
277 return true;
278 reference.SwapFrame(&comparisons_.front().reference);
279 render.SwapFrame(&comparisons_.front().render);
280 dropped = comparisons_.front().dropped;
281 send_time_ms = comparisons_.front().send_time_ms;
282 recv_time_ms = comparisons_.front().recv_time_ms;
283 render_time_ms = comparisons_.front().render_time_ms;
284 comparisons_.pop_front();
285 }
286
287 PerformFrameComparison(&reference,
288 &render,
289 dropped,
290 send_time_ms,
291 recv_time_ms,
292 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000293
294 if (--frames_left_ == 0) {
295 PrintResult("psnr", psnr_, " dB");
296 PrintResult("ssim", ssim_, "");
297 PrintResult("sender_time", sender_time_, " ms");
pbos@webrtc.org94015242013-10-16 11:05:37 +0000298 printf(
299 "RESULT dropped_frames: %s = %d\n", test_label_, dropped_frames_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000300 PrintResult("receiver_time", receiver_time_, " ms");
301 PrintResult("total_delay_incl_network", end_to_end_, " ms");
302 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
303 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
304 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000305 done_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000306
307 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000308 }
309 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000310 }
311
pbos@webrtc.org94015242013-10-16 11:05:37 +0000312 void PerformFrameComparison(const I420VideoFrame* reference,
313 const I420VideoFrame* render,
314 bool dropped,
315 int64_t send_time_ms,
316 int64_t recv_time_ms,
317 int64_t render_time_ms) {
318 psnr_.AddSample(I420PSNR(reference, render));
319 ssim_.AddSample(I420SSIM(reference, render));
320 if (dropped) {
321 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000322 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000323 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000324 if (last_render_time_ != 0)
pbos@webrtc.org94015242013-10-16 11:05:37 +0000325 rendered_delta_.AddSample(render_time_ms - last_render_time_);
326 last_render_time_ = render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000327
pbos@webrtc.org94015242013-10-16 11:05:37 +0000328 int64_t input_time_ms = reference->render_time_ms();
329 sender_time_.AddSample(send_time_ms - input_time_ms);
330 receiver_time_.AddSample(render_time_ms - recv_time_ms);
331 end_to_end_.AddSample(render_time_ms - input_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000332 }
333
334 void PrintResult(const char* result_type,
335 test::Statistics stats,
336 const char* unit) {
337 printf("RESULT %s: %s = {%f, %f}%s\n",
338 result_type,
339 test_label_,
340 stats.Mean(),
341 stats.StandardDeviation(),
342 unit);
343 }
344
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000345 const char* const test_label_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000346 test::Statistics sender_time_;
347 test::Statistics receiver_time_;
348 test::Statistics psnr_;
349 test::Statistics ssim_;
350 test::Statistics end_to_end_;
351 test::Statistics rendered_delta_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000352 int frames_left_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000353 int dropped_frames_;
354 int64_t last_render_time_;
355 uint32_t rtp_timestamp_delta_;
356
357 const scoped_ptr<CriticalSectionWrapper> crit_;
358 std::deque<I420VideoFrame*> frames_ GUARDED_BY(crit_);
359 std::deque<I420VideoFrame*> frame_pool_ GUARDED_BY(crit_);
360 I420VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
361 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
362 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
363 I420VideoFrame* first_send_frame_ GUARDED_BY(crit_);
364 double avg_psnr_threshold_ GUARDED_BY(crit_);
365 double avg_ssim_threshold_ GUARDED_BY(crit_);
366
367 const scoped_ptr<CriticalSectionWrapper> comparison_lock_;
368 const scoped_ptr<ThreadWrapper> comparison_thread_;
369 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
370 const scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000371};
372
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000373void FullStackTest::RunTest(const FullStackTestParams& params) {
374 test::DirectTransport send_transport(params.link);
375 test::DirectTransport recv_transport(params.link);
pbos@webrtc.org94015242013-10-16 11:05:37 +0000376 VideoAnalyzer analyzer(NULL,
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000377 &send_transport,
pbos@webrtc.org94015242013-10-16 11:05:37 +0000378 params.test_label,
379 params.avg_psnr_threshold,
380 params.avg_ssim_threshold,
pbos@webrtc.org023b1012014-05-13 11:26:40 +0000381 kFullStackTestDurationSecs * params.clip.fps);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000382
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000383 CreateCalls(Call::Config(&analyzer), Call::Config(&recv_transport));
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000384
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000385 analyzer.SetReceiver(receiver_call_->Receiver());
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000386 send_transport.SetReceiver(&analyzer);
387 recv_transport.SetReceiver(sender_call_->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000388
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000389 CreateSendConfig(1);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000390
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000391 scoped_ptr<VP8Encoder> encoder(VP8Encoder::Create());
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000392 send_config_.encoder_settings.encoder = encoder.get();
393 send_config_.encoder_settings.payload_name = "VP8";
394 send_config_.encoder_settings.payload_type = 124;
395
396 VideoStream* stream = &video_streams_[0];
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000397 stream->width = params.clip.width;
398 stream->height = params.clip.height;
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000399 stream->min_bitrate_bps = params.min_bitrate_bps;
400 stream->target_bitrate_bps = params.target_bitrate_bps;
401 stream->max_bitrate_bps = params.max_bitrate_bps;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000402 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000403
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000404 CreateMatchingReceiveConfigs();
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000405 receive_configs_[0].renderer = &analyzer;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000406
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000407 CreateStreams();
408 analyzer.input_ = send_stream_->Input();
409
410 frame_generator_capturer_.reset(
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000411 test::FrameGeneratorCapturer::CreateFromYuvFile(
pbos@webrtc.org4c966012013-08-21 12:07:37 +0000412 &analyzer,
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000413 test::ResourcePath(params.clip.name, "yuv").c_str(),
414 params.clip.width,
415 params.clip.height,
416 params.clip.fps,
417 Clock::GetRealTimeClock()));
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000418
419 ASSERT_TRUE(frame_generator_capturer_.get() != NULL)
pbos@webrtc.org94015242013-10-16 11:05:37 +0000420 << "Could not create capturer for " << params.clip.name
421 << ".yuv. Is this resource file present?";
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000422
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000423 Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000424
425 analyzer.Wait();
426
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000427 send_transport.StopSending();
428 recv_transport.StopSending();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000429
430 Stop();
431
432 DestroyStreams();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000433}
434
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000435TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000436 FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
437 {"paris_qcif", 176, 144, 30},
438 300000,
439 300000,
440 300000,
441 36.0,
442 0.96
443 };
444 RunTest(paris_qcif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000445}
446
447TEST_F(FullStackTest, ForemanCifWithoutPacketLoss) {
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000448 // TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
449 FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
450 {"foreman_cif", 352, 288, 30},
451 700000,
452 700000,
453 700000,
454 0.0,
455 0.0
456 };
457 RunTest(foreman_cif);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000458}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000459
stefan@webrtc.orgb8e9e442014-07-09 11:29:06 +0000460TEST_F(FullStackTest, ForemanCif500kbps) {
461 FullStackTestParams foreman_cif = {"foreman_cif_500kbps",
462 {"foreman_cif", 352, 288, 30},
463 30000,
464 500000,
465 2000000,
466 0.0,
467 0.0
468 };
469 foreman_cif.link.queue_length_packets = 0;
470 foreman_cif.link.queue_delay_ms = 0;
471 foreman_cif.link.link_capacity_kbps = 500;
472 RunTest(foreman_cif);
473}
474
475TEST_F(FullStackTest, ForemanCif500kbpsLimitedQueue) {
476 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_32pkts_queue",
477 {"foreman_cif", 352, 288, 30},
478 30000,
479 500000,
480 2000000,
481 0.0,
482 0.0
483 };
484 foreman_cif.link.queue_length_packets = 32;
485 foreman_cif.link.queue_delay_ms = 0;
486 foreman_cif.link.link_capacity_kbps = 500;
487 RunTest(foreman_cif);
488}
489
490TEST_F(FullStackTest, ForemanCif500kbps100ms) {
491 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms",
492 {"foreman_cif", 352, 288, 30},
493 30000,
494 500000,
495 2000000,
496 0.0,
497 0.0
498 };
499 foreman_cif.link.queue_length_packets = 0;
500 foreman_cif.link.queue_delay_ms = 100;
501 foreman_cif.link.link_capacity_kbps = 500;
502 RunTest(foreman_cif);
503}
504
505TEST_F(FullStackTest, ForemanCif500kbps100msLimitedQueue) {
506 FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms_32pkts_queue",
507 {"foreman_cif", 352, 288, 30},
508 30000,
509 500000,
510 2000000,
511 0.0,
512 0.0
513 };
514 foreman_cif.link.queue_length_packets = 32;
515 foreman_cif.link.queue_delay_ms = 100;
516 foreman_cif.link.link_capacity_kbps = 500;
517 RunTest(foreman_cif);
518}
519
520TEST_F(FullStackTest, ForemanCif1000kbps100msLimitedQueue) {
521 FullStackTestParams foreman_cif = {"foreman_cif_1000kbps_100ms_32pkts_queue",
522 {"foreman_cif", 352, 288, 30},
523 30000,
524 2000000,
525 2000000,
526 0.0,
527 0.0
528 };
529 foreman_cif.link.queue_length_packets = 32;
530 foreman_cif.link.queue_delay_ms = 100;
531 foreman_cif.link.link_capacity_kbps = 1000;
532 RunTest(foreman_cif);
533}
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000534} // namespace webrtc