blob: cb0ba55a3879378024b6647fbf50a33326134de7 [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.org16e03b72013-10-28 16:32:01 +000027#include "webrtc/test/direct_transport.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000028#include "webrtc/test/encoder_settings.h"
29#include "webrtc/test/fake_encoder.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000030#include "webrtc/test/frame_generator_capturer.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000031#include "webrtc/test/statistics.h"
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +000032#include "webrtc/test/testsupport/fileutils.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000033#include "webrtc/typedefs.h"
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000034
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000035namespace webrtc {
36
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +000037static const uint32_t kSendSsrc = 0x654321;
pbos@webrtc.org023b1012014-05-13 11:26:40 +000038static const int kFullStackTestDurationSecs = 10;
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;
pbos@webrtc.orgf3f13582013-07-09 14:04:46 +000047 unsigned int bitrate;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000048 double avg_psnr_threshold;
49 double avg_ssim_threshold;
50};
51
pbos@webrtc.org841c8a42013-09-09 15:04:25 +000052FullStackTestParams paris_qcif = {
53 "net_delay_0_0_plr_0", {"paris_qcif", 176, 144, 30}, 300, 36.0, 0.96};
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000054
55// TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
pbos@webrtc.org841c8a42013-09-09 15:04:25 +000056FullStackTestParams foreman_cif = {
57 "foreman_cif_net_delay_0_0_plr_0",
58 {"foreman_cif", 352, 288, 30},
59 700,
60 0.0,
61 0.0};
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000062
63class FullStackTest : public ::testing::TestWithParam<FullStackTestParams> {
64 protected:
65 std::map<uint32_t, bool> reserved_ssrcs_;
66};
67
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000068class VideoAnalyzer : public PacketReceiver,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000069 public newapi::Transport,
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000070 public VideoRenderer,
71 public VideoSendStreamInput {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000072 public:
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000073 VideoAnalyzer(VideoSendStreamInput* input,
74 Transport* transport,
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000075 const char* test_label,
76 double avg_psnr_threshold,
77 double avg_ssim_threshold,
pbos@webrtc.org94015242013-10-16 11:05:37 +000078 int duration_frames)
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000079 : input_(input),
80 transport_(transport),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000081 receiver_(NULL),
82 test_label_(test_label),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000083 frames_left_(duration_frames),
pbos@webrtc.org94015242013-10-16 11:05:37 +000084 dropped_frames_(0),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000085 last_render_time_(0),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000086 rtp_timestamp_delta_(0),
87 crit_(CriticalSectionWrapper::CreateCriticalSection()),
88 first_send_frame_(NULL),
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000089 avg_psnr_threshold_(avg_psnr_threshold),
90 avg_ssim_threshold_(avg_ssim_threshold),
pbos@webrtc.org94015242013-10-16 11:05:37 +000091 comparison_lock_(CriticalSectionWrapper::CreateCriticalSection()),
92 comparison_thread_(ThreadWrapper::CreateThread(&FrameComparisonThread,
93 this)),
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000094 done_(EventWrapper::Create()) {
pbos@webrtc.org94015242013-10-16 11:05:37 +000095 unsigned int id;
96 EXPECT_TRUE(comparison_thread_->Start(id));
97 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +000098
99 ~VideoAnalyzer() {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000100 EXPECT_TRUE(comparison_thread_->Stop());
101
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000102 while (!frames_.empty()) {
103 delete frames_.back();
104 frames_.pop_back();
105 }
106 while (!frame_pool_.empty()) {
107 delete frame_pool_.back();
108 frame_pool_.pop_back();
109 }
110 }
111
pbos@webrtc.org94015242013-10-16 11:05:37 +0000112 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
113
pbos@webrtc.orgcaba2d22014-05-14 13:57:12 +0000114 virtual DeliveryStatus DeliverPacket(const uint8_t* packet,
115 size_t length) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000116 scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
117 RTPHeader header;
pbos@webrtc.org40523702013-08-05 12:49:22 +0000118 parser->Parse(packet, static_cast<int>(length), &header);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000119 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000120 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000121 recv_times_[header.timestamp - rtp_timestamp_delta_] =
122 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
123 }
124
125 return receiver_->DeliverPacket(packet, length);
126 }
127
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000128 virtual void PutFrame(const I420VideoFrame& video_frame) OVERRIDE {
129 ADD_FAILURE() << "PutFrame() should not have been called in this test.";
130 }
131
132 virtual void SwapFrame(I420VideoFrame* video_frame) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000133 I420VideoFrame* copy = NULL;
134 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000135 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000136 if (frame_pool_.size() > 0) {
137 copy = frame_pool_.front();
138 frame_pool_.pop_front();
139 }
140 }
141 if (copy == NULL)
142 copy = new I420VideoFrame();
143
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000144 copy->CopyFrame(*video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000145 copy->set_timestamp(copy->render_time_ms() * 90);
146
147 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000148 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000149 if (first_send_frame_ == NULL && rtp_timestamp_delta_ == 0)
150 first_send_frame_ = copy;
151
152 frames_.push_back(copy);
153 }
154
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000155 input_->SwapFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000156 }
157
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000158 virtual bool SendRtp(const uint8_t* packet, size_t length) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000159 scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
160 RTPHeader header;
161 parser->Parse(packet, static_cast<int>(length), &header);
162
163 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000164 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000165 if (rtp_timestamp_delta_ == 0) {
166 rtp_timestamp_delta_ =
167 header.timestamp - first_send_frame_->timestamp();
168 first_send_frame_ = NULL;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000169 }
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000170 send_times_[header.timestamp - rtp_timestamp_delta_] =
171 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000172 }
173
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000174 return transport_->SendRtp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000175 }
176
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000177 virtual bool SendRtcp(const uint8_t* packet, size_t length) OVERRIDE {
178 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000179 }
180
181 virtual void RenderFrame(const I420VideoFrame& video_frame,
182 int time_to_render_ms) OVERRIDE {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000183 int64_t render_time_ms =
184 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000185 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
186
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000187 CriticalSectionScoped lock(crit_.get());
188 while (frames_.front()->timestamp() < send_timestamp) {
189 AddFrameComparison(
190 frames_.front(), &last_rendered_frame_, true, render_time_ms);
191 frame_pool_.push_back(frames_.front());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000192 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000193 }
194
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000195 I420VideoFrame* reference_frame = frames_.front();
196 frames_.pop_front();
197 assert(reference_frame != NULL);
198 EXPECT_EQ(reference_frame->timestamp(), send_timestamp);
199 assert(reference_frame->timestamp() == send_timestamp);
200
201 AddFrameComparison(reference_frame, &video_frame, false, render_time_ms);
202 frame_pool_.push_back(reference_frame);
203
pbos@webrtc.org94015242013-10-16 11:05:37 +0000204 last_rendered_frame_.CopyFrame(video_frame);
205 }
206
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000207 void Wait() { done_->Wait(120 * 1000); }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000208
209 VideoSendStreamInput* input_;
210 Transport* transport_;
211 PacketReceiver* receiver_;
212
213 private:
214 struct FrameComparison {
215 FrameComparison(const I420VideoFrame* reference,
216 const I420VideoFrame* render,
217 bool dropped,
218 int64_t send_time_ms,
219 int64_t recv_time_ms,
220 int64_t render_time_ms)
221 : dropped(dropped),
222 send_time_ms(send_time_ms),
223 recv_time_ms(recv_time_ms),
224 render_time_ms(render_time_ms) {
225 this->reference.CopyFrame(*reference);
226 this->render.CopyFrame(*render);
227 }
228
229 FrameComparison(const FrameComparison& compare)
230 : dropped(compare.dropped),
231 send_time_ms(compare.send_time_ms),
232 recv_time_ms(compare.recv_time_ms),
233 render_time_ms(compare.render_time_ms) {
234 this->reference.CopyFrame(compare.reference);
235 this->render.CopyFrame(compare.render);
236 }
237
238 ~FrameComparison() {}
239
240 I420VideoFrame reference;
241 I420VideoFrame render;
242 bool dropped;
243 int64_t send_time_ms;
244 int64_t recv_time_ms;
245 int64_t render_time_ms;
246 };
247
248 void AddFrameComparison(const I420VideoFrame* reference,
249 const I420VideoFrame* render,
250 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000251 int64_t render_time_ms)
252 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000253 int64_t send_time_ms = send_times_[reference->timestamp()];
254 send_times_.erase(reference->timestamp());
255 int64_t recv_time_ms = recv_times_[reference->timestamp()];
256 recv_times_.erase(reference->timestamp());
257
258 CriticalSectionScoped crit(comparison_lock_.get());
259 comparisons_.push_back(FrameComparison(reference,
260 render,
261 dropped,
262 send_time_ms,
263 recv_time_ms,
264 render_time_ms));
265 }
266
267 static bool FrameComparisonThread(void* obj) {
268 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
269 }
270
271 bool CompareFrames() {
272 assert(frames_left_ > 0);
273
274 I420VideoFrame reference;
275 I420VideoFrame render;
276 bool dropped;
277 int64_t send_time_ms;
278 int64_t recv_time_ms;
279 int64_t render_time_ms;
280
281 SleepMs(10);
282
283 while (true) {
284 {
285 CriticalSectionScoped crit(comparison_lock_.get());
286 if (comparisons_.empty())
287 return true;
288 reference.SwapFrame(&comparisons_.front().reference);
289 render.SwapFrame(&comparisons_.front().render);
290 dropped = comparisons_.front().dropped;
291 send_time_ms = comparisons_.front().send_time_ms;
292 recv_time_ms = comparisons_.front().recv_time_ms;
293 render_time_ms = comparisons_.front().render_time_ms;
294 comparisons_.pop_front();
295 }
296
297 PerformFrameComparison(&reference,
298 &render,
299 dropped,
300 send_time_ms,
301 recv_time_ms,
302 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000303
304 if (--frames_left_ == 0) {
305 PrintResult("psnr", psnr_, " dB");
306 PrintResult("ssim", ssim_, "");
307 PrintResult("sender_time", sender_time_, " ms");
pbos@webrtc.org94015242013-10-16 11:05:37 +0000308 printf(
309 "RESULT dropped_frames: %s = %d\n", test_label_, dropped_frames_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000310 PrintResult("receiver_time", receiver_time_, " ms");
311 PrintResult("total_delay_incl_network", end_to_end_, " ms");
312 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
313 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
314 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000315 done_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000316
317 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000318 }
319 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000320 }
321
pbos@webrtc.org94015242013-10-16 11:05:37 +0000322 void PerformFrameComparison(const I420VideoFrame* reference,
323 const I420VideoFrame* render,
324 bool dropped,
325 int64_t send_time_ms,
326 int64_t recv_time_ms,
327 int64_t render_time_ms) {
328 psnr_.AddSample(I420PSNR(reference, render));
329 ssim_.AddSample(I420SSIM(reference, render));
330 if (dropped) {
331 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000332 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000333 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000334 if (last_render_time_ != 0)
pbos@webrtc.org94015242013-10-16 11:05:37 +0000335 rendered_delta_.AddSample(render_time_ms - last_render_time_);
336 last_render_time_ = render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000337
pbos@webrtc.org94015242013-10-16 11:05:37 +0000338 int64_t input_time_ms = reference->render_time_ms();
339 sender_time_.AddSample(send_time_ms - input_time_ms);
340 receiver_time_.AddSample(render_time_ms - recv_time_ms);
341 end_to_end_.AddSample(render_time_ms - input_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000342 }
343
344 void PrintResult(const char* result_type,
345 test::Statistics stats,
346 const char* unit) {
347 printf("RESULT %s: %s = {%f, %f}%s\n",
348 result_type,
349 test_label_,
350 stats.Mean(),
351 stats.StandardDeviation(),
352 unit);
353 }
354
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000355 const char* const test_label_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000356 test::Statistics sender_time_;
357 test::Statistics receiver_time_;
358 test::Statistics psnr_;
359 test::Statistics ssim_;
360 test::Statistics end_to_end_;
361 test::Statistics rendered_delta_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000362 int frames_left_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000363 int dropped_frames_;
364 int64_t last_render_time_;
365 uint32_t rtp_timestamp_delta_;
366
367 const scoped_ptr<CriticalSectionWrapper> crit_;
368 std::deque<I420VideoFrame*> frames_ GUARDED_BY(crit_);
369 std::deque<I420VideoFrame*> frame_pool_ GUARDED_BY(crit_);
370 I420VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
371 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
372 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
373 I420VideoFrame* first_send_frame_ GUARDED_BY(crit_);
374 double avg_psnr_threshold_ GUARDED_BY(crit_);
375 double avg_ssim_threshold_ GUARDED_BY(crit_);
376
377 const scoped_ptr<CriticalSectionWrapper> comparison_lock_;
378 const scoped_ptr<ThreadWrapper> comparison_thread_;
379 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
380 const scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000381};
382
pbos@webrtc.org94015242013-10-16 11:05:37 +0000383TEST_P(FullStackTest, NoPacketLoss) {
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000384 static const uint32_t kReceiverLocalSsrc = 0x123456;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000385 FullStackTestParams params = GetParam();
386
pbos@webrtc.org96684672013-08-12 12:59:04 +0000387 test::DirectTransport transport;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000388 VideoAnalyzer analyzer(NULL,
389 &transport,
390 params.test_label,
391 params.avg_psnr_threshold,
392 params.avg_ssim_threshold,
pbos@webrtc.org023b1012014-05-13 11:26:40 +0000393 kFullStackTestDurationSecs * params.clip.fps);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000394
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000395 Call::Config call_config(&analyzer);
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000396
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000397 scoped_ptr<Call> call(Call::Create(call_config));
pbos@webrtc.org94015242013-10-16 11:05:37 +0000398 analyzer.SetReceiver(call->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000399 transport.SetReceiver(&analyzer);
400
pbos@webrtc.org74fa4892013-08-23 09:19:30 +0000401 VideoSendStream::Config send_config = call->GetDefaultSendConfig();
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000402 send_config.rtp.ssrcs.push_back(kSendSsrc);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000403
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000404 scoped_ptr<VP8Encoder> encoder(VP8Encoder::Create());
405 send_config.encoder_settings =
406 test::CreateEncoderSettings(encoder.get(), "VP8", 124, 1);
407 VideoStream* stream = &send_config.encoder_settings.streams[0];
408 stream->width = params.clip.width;
409 stream->height = params.clip.height;
410 stream->min_bitrate_bps = stream->target_bitrate_bps =
411 stream->max_bitrate_bps = params.bitrate * 1000;
412 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000413
pbos@webrtc.org5a636552013-11-20 10:40:25 +0000414 VideoSendStream* send_stream = call->CreateVideoSendStream(send_config);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000415 analyzer.input_ = send_stream->Input();
416
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000417 scoped_ptr<test::FrameGeneratorCapturer> file_capturer(
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000418 test::FrameGeneratorCapturer::CreateFromYuvFile(
pbos@webrtc.org4c966012013-08-21 12:07:37 +0000419 &analyzer,
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000420 test::ResourcePath(params.clip.name, "yuv").c_str(),
421 params.clip.width,
422 params.clip.height,
423 params.clip.fps,
424 Clock::GetRealTimeClock()));
pbos@webrtc.org94015242013-10-16 11:05:37 +0000425 ASSERT_TRUE(file_capturer.get() != NULL)
426 << "Could not create capturer for " << params.clip.name
427 << ".yuv. Is this resource file present?";
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000428
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000429 VideoReceiveStream::Config receive_config = call->GetDefaultReceiveConfig();
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000430 VideoCodec codec =
431 test::CreateDecoderVideoCodec(send_config.encoder_settings);
432 receive_config.codecs.push_back(codec);
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000433 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0];
434 receive_config.rtp.local_ssrc = kReceiverLocalSsrc;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000435 receive_config.renderer = &analyzer;
436
pbos@webrtc.org74fa4892013-08-23 09:19:30 +0000437 VideoReceiveStream* receive_stream =
pbos@webrtc.org5a636552013-11-20 10:40:25 +0000438 call->CreateVideoReceiveStream(receive_config);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000439
pbos@webrtc.orga5c8d2c2014-04-24 11:13:21 +0000440 receive_stream->Start();
441 send_stream->Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000442 file_capturer->Start();
443
444 analyzer.Wait();
445
446 file_capturer->Stop();
pbos@webrtc.orga5c8d2c2014-04-24 11:13:21 +0000447 send_stream->Stop();
448 receive_stream->Stop();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000449
pbos@webrtc.org2c46f8d2013-11-21 13:49:43 +0000450 call->DestroyVideoReceiveStream(receive_stream);
451 call->DestroyVideoSendStream(send_stream);
pbos@webrtc.org96684672013-08-12 12:59:04 +0000452
453 transport.StopSending();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000454}
455
456INSTANTIATE_TEST_CASE_P(FullStack,
457 FullStackTest,
458 ::testing::Values(paris_qcif, foreman_cif));
459
460} // namespace webrtc