blob: cb97cd85bbcfc79a5847ef97968834d7a931e7f0 [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 SwapFrame(I420VideoFrame* video_frame) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000129 I420VideoFrame* copy = NULL;
130 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000131 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000132 if (frame_pool_.size() > 0) {
133 copy = frame_pool_.front();
134 frame_pool_.pop_front();
135 }
136 }
137 if (copy == NULL)
138 copy = new I420VideoFrame();
139
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000140 copy->CopyFrame(*video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000141 copy->set_timestamp(copy->render_time_ms() * 90);
142
143 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000144 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000145 if (first_send_frame_ == NULL && rtp_timestamp_delta_ == 0)
146 first_send_frame_ = copy;
147
148 frames_.push_back(copy);
149 }
150
pbos@webrtc.org724947b2013-12-11 16:26:16 +0000151 input_->SwapFrame(video_frame);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000152 }
153
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000154 virtual bool SendRtp(const uint8_t* packet, size_t length) OVERRIDE {
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000155 scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
156 RTPHeader header;
157 parser->Parse(packet, static_cast<int>(length), &header);
158
159 {
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000160 CriticalSectionScoped lock(crit_.get());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000161 if (rtp_timestamp_delta_ == 0) {
162 rtp_timestamp_delta_ =
163 header.timestamp - first_send_frame_->timestamp();
164 first_send_frame_ = NULL;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000165 }
pbos@webrtc.org7fb9ce02013-08-05 09:29:50 +0000166 send_times_[header.timestamp - rtp_timestamp_delta_] =
167 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000168 }
169
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000170 return transport_->SendRtp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000171 }
172
pbos@webrtc.org27326b62013-11-20 12:17:04 +0000173 virtual bool SendRtcp(const uint8_t* packet, size_t length) OVERRIDE {
174 return transport_->SendRtcp(packet, length);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000175 }
176
177 virtual void RenderFrame(const I420VideoFrame& video_frame,
178 int time_to_render_ms) OVERRIDE {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000179 int64_t render_time_ms =
180 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000181 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
182
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000183 CriticalSectionScoped lock(crit_.get());
184 while (frames_.front()->timestamp() < send_timestamp) {
185 AddFrameComparison(
186 frames_.front(), &last_rendered_frame_, true, render_time_ms);
187 frame_pool_.push_back(frames_.front());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000188 frames_.pop_front();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000189 }
190
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000191 I420VideoFrame* reference_frame = frames_.front();
192 frames_.pop_front();
193 assert(reference_frame != NULL);
194 EXPECT_EQ(reference_frame->timestamp(), send_timestamp);
195 assert(reference_frame->timestamp() == send_timestamp);
196
197 AddFrameComparison(reference_frame, &video_frame, false, render_time_ms);
198 frame_pool_.push_back(reference_frame);
199
pbos@webrtc.org94015242013-10-16 11:05:37 +0000200 last_rendered_frame_.CopyFrame(video_frame);
201 }
202
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000203 void Wait() { done_->Wait(120 * 1000); }
pbos@webrtc.org94015242013-10-16 11:05:37 +0000204
205 VideoSendStreamInput* input_;
206 Transport* transport_;
207 PacketReceiver* receiver_;
208
209 private:
210 struct FrameComparison {
211 FrameComparison(const I420VideoFrame* reference,
212 const I420VideoFrame* render,
213 bool dropped,
214 int64_t send_time_ms,
215 int64_t recv_time_ms,
216 int64_t render_time_ms)
217 : dropped(dropped),
218 send_time_ms(send_time_ms),
219 recv_time_ms(recv_time_ms),
220 render_time_ms(render_time_ms) {
221 this->reference.CopyFrame(*reference);
222 this->render.CopyFrame(*render);
223 }
224
225 FrameComparison(const FrameComparison& compare)
226 : dropped(compare.dropped),
227 send_time_ms(compare.send_time_ms),
228 recv_time_ms(compare.recv_time_ms),
229 render_time_ms(compare.render_time_ms) {
230 this->reference.CopyFrame(compare.reference);
231 this->render.CopyFrame(compare.render);
232 }
233
234 ~FrameComparison() {}
235
236 I420VideoFrame reference;
237 I420VideoFrame render;
238 bool dropped;
239 int64_t send_time_ms;
240 int64_t recv_time_ms;
241 int64_t render_time_ms;
242 };
243
244 void AddFrameComparison(const I420VideoFrame* reference,
245 const I420VideoFrame* render,
246 bool dropped,
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000247 int64_t render_time_ms)
248 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
pbos@webrtc.org94015242013-10-16 11:05:37 +0000249 int64_t send_time_ms = send_times_[reference->timestamp()];
250 send_times_.erase(reference->timestamp());
251 int64_t recv_time_ms = recv_times_[reference->timestamp()];
252 recv_times_.erase(reference->timestamp());
253
254 CriticalSectionScoped crit(comparison_lock_.get());
255 comparisons_.push_back(FrameComparison(reference,
256 render,
257 dropped,
258 send_time_ms,
259 recv_time_ms,
260 render_time_ms));
261 }
262
263 static bool FrameComparisonThread(void* obj) {
264 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
265 }
266
267 bool CompareFrames() {
268 assert(frames_left_ > 0);
269
270 I420VideoFrame reference;
271 I420VideoFrame render;
272 bool dropped;
273 int64_t send_time_ms;
274 int64_t recv_time_ms;
275 int64_t render_time_ms;
276
277 SleepMs(10);
278
279 while (true) {
280 {
281 CriticalSectionScoped crit(comparison_lock_.get());
282 if (comparisons_.empty())
283 return true;
284 reference.SwapFrame(&comparisons_.front().reference);
285 render.SwapFrame(&comparisons_.front().render);
286 dropped = comparisons_.front().dropped;
287 send_time_ms = comparisons_.front().send_time_ms;
288 recv_time_ms = comparisons_.front().recv_time_ms;
289 render_time_ms = comparisons_.front().render_time_ms;
290 comparisons_.pop_front();
291 }
292
293 PerformFrameComparison(&reference,
294 &render,
295 dropped,
296 send_time_ms,
297 recv_time_ms,
298 render_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000299
300 if (--frames_left_ == 0) {
301 PrintResult("psnr", psnr_, " dB");
302 PrintResult("ssim", ssim_, "");
303 PrintResult("sender_time", sender_time_, " ms");
pbos@webrtc.org94015242013-10-16 11:05:37 +0000304 printf(
305 "RESULT dropped_frames: %s = %d\n", test_label_, dropped_frames_);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000306 PrintResult("receiver_time", receiver_time_, " ms");
307 PrintResult("total_delay_incl_network", end_to_end_, " ms");
308 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
309 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
310 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000311 done_->Set();
pbos@webrtc.org94015242013-10-16 11:05:37 +0000312
313 return false;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000314 }
315 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000316 }
317
pbos@webrtc.org94015242013-10-16 11:05:37 +0000318 void PerformFrameComparison(const I420VideoFrame* reference,
319 const I420VideoFrame* render,
320 bool dropped,
321 int64_t send_time_ms,
322 int64_t recv_time_ms,
323 int64_t render_time_ms) {
324 psnr_.AddSample(I420PSNR(reference, render));
325 ssim_.AddSample(I420SSIM(reference, render));
326 if (dropped) {
327 ++dropped_frames_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000328 return;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000329 }
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000330 if (last_render_time_ != 0)
pbos@webrtc.org94015242013-10-16 11:05:37 +0000331 rendered_delta_.AddSample(render_time_ms - last_render_time_);
332 last_render_time_ = render_time_ms;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000333
pbos@webrtc.org94015242013-10-16 11:05:37 +0000334 int64_t input_time_ms = reference->render_time_ms();
335 sender_time_.AddSample(send_time_ms - input_time_ms);
336 receiver_time_.AddSample(render_time_ms - recv_time_ms);
337 end_to_end_.AddSample(render_time_ms - input_time_ms);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000338 }
339
340 void PrintResult(const char* result_type,
341 test::Statistics stats,
342 const char* unit) {
343 printf("RESULT %s: %s = {%f, %f}%s\n",
344 result_type,
345 test_label_,
346 stats.Mean(),
347 stats.StandardDeviation(),
348 unit);
349 }
350
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000351 const char* const test_label_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000352 test::Statistics sender_time_;
353 test::Statistics receiver_time_;
354 test::Statistics psnr_;
355 test::Statistics ssim_;
356 test::Statistics end_to_end_;
357 test::Statistics rendered_delta_;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000358 int frames_left_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000359 int dropped_frames_;
360 int64_t last_render_time_;
361 uint32_t rtp_timestamp_delta_;
362
363 const scoped_ptr<CriticalSectionWrapper> crit_;
364 std::deque<I420VideoFrame*> frames_ GUARDED_BY(crit_);
365 std::deque<I420VideoFrame*> frame_pool_ GUARDED_BY(crit_);
366 I420VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
367 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_);
368 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_);
369 I420VideoFrame* first_send_frame_ GUARDED_BY(crit_);
370 double avg_psnr_threshold_ GUARDED_BY(crit_);
371 double avg_ssim_threshold_ GUARDED_BY(crit_);
372
373 const scoped_ptr<CriticalSectionWrapper> comparison_lock_;
374 const scoped_ptr<ThreadWrapper> comparison_thread_;
375 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
376 const scoped_ptr<EventWrapper> done_;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000377};
378
pbos@webrtc.org94015242013-10-16 11:05:37 +0000379TEST_P(FullStackTest, NoPacketLoss) {
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000380 static const uint32_t kReceiverLocalSsrc = 0x123456;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000381 FullStackTestParams params = GetParam();
382
pbos@webrtc.org96684672013-08-12 12:59:04 +0000383 test::DirectTransport transport;
pbos@webrtc.org94015242013-10-16 11:05:37 +0000384 VideoAnalyzer analyzer(NULL,
385 &transport,
386 params.test_label,
387 params.avg_psnr_threshold,
388 params.avg_ssim_threshold,
pbos@webrtc.org023b1012014-05-13 11:26:40 +0000389 kFullStackTestDurationSecs * params.clip.fps);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000390
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000391 Call::Config call_config(&analyzer);
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +0000392
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000393 scoped_ptr<Call> call(Call::Create(call_config));
pbos@webrtc.org94015242013-10-16 11:05:37 +0000394 analyzer.SetReceiver(call->Receiver());
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000395 transport.SetReceiver(&analyzer);
396
pbos@webrtc.org74fa4892013-08-23 09:19:30 +0000397 VideoSendStream::Config send_config = call->GetDefaultSendConfig();
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000398 send_config.rtp.ssrcs.push_back(kSendSsrc);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000399
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000400 scoped_ptr<VP8Encoder> encoder(VP8Encoder::Create());
401 send_config.encoder_settings =
402 test::CreateEncoderSettings(encoder.get(), "VP8", 124, 1);
403 VideoStream* stream = &send_config.encoder_settings.streams[0];
404 stream->width = params.clip.width;
405 stream->height = params.clip.height;
406 stream->min_bitrate_bps = stream->target_bitrate_bps =
407 stream->max_bitrate_bps = params.bitrate * 1000;
408 stream->max_framerate = params.clip.fps;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000409
pbos@webrtc.org5a636552013-11-20 10:40:25 +0000410 VideoSendStream* send_stream = call->CreateVideoSendStream(send_config);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000411 analyzer.input_ = send_stream->Input();
412
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000413 scoped_ptr<test::FrameGeneratorCapturer> file_capturer(
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000414 test::FrameGeneratorCapturer::CreateFromYuvFile(
pbos@webrtc.org4c966012013-08-21 12:07:37 +0000415 &analyzer,
andresp@webrtc.orgab654952013-09-19 12:14:03 +0000416 test::ResourcePath(params.clip.name, "yuv").c_str(),
417 params.clip.width,
418 params.clip.height,
419 params.clip.fps,
420 Clock::GetRealTimeClock()));
pbos@webrtc.org94015242013-10-16 11:05:37 +0000421 ASSERT_TRUE(file_capturer.get() != NULL)
422 << "Could not create capturer for " << params.clip.name
423 << ".yuv. Is this resource file present?";
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000424
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000425 VideoReceiveStream::Config receive_config = call->GetDefaultReceiveConfig();
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000426 VideoCodec codec =
427 test::CreateDecoderVideoCodec(send_config.encoder_settings);
428 receive_config.codecs.push_back(codec);
pbos@webrtc.orgb613b5a2013-12-03 10:13:04 +0000429 receive_config.rtp.remote_ssrc = send_config.rtp.ssrcs[0];
430 receive_config.rtp.local_ssrc = kReceiverLocalSsrc;
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000431 receive_config.renderer = &analyzer;
432
pbos@webrtc.org74fa4892013-08-23 09:19:30 +0000433 VideoReceiveStream* receive_stream =
pbos@webrtc.org5a636552013-11-20 10:40:25 +0000434 call->CreateVideoReceiveStream(receive_config);
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000435
pbos@webrtc.orga5c8d2c2014-04-24 11:13:21 +0000436 receive_stream->Start();
437 send_stream->Start();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000438 file_capturer->Start();
439
440 analyzer.Wait();
441
442 file_capturer->Stop();
pbos@webrtc.orga5c8d2c2014-04-24 11:13:21 +0000443 send_stream->Stop();
444 receive_stream->Stop();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000445
pbos@webrtc.org2c46f8d2013-11-21 13:49:43 +0000446 call->DestroyVideoReceiveStream(receive_stream);
447 call->DestroyVideoSendStream(send_stream);
pbos@webrtc.org96684672013-08-12 12:59:04 +0000448
449 transport.StopSending();
pbos@webrtc.orgaf8d5af2013-07-09 08:02:33 +0000450}
451
452INSTANTIATE_TEST_CASE_P(FullStack,
453 FullStackTest,
454 ::testing::Values(paris_qcif, foreman_cif));
455
456} // namespace webrtc