OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include <stdio.h> | 10 #include <stdio.h> |
11 | 11 |
12 #include <deque> | 12 #include <deque> |
13 #include <map> | 13 #include <map> |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 #include "webrtc/base/format_macros.h" | |
17 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
19 #include "webrtc/call.h" | 20 #include "webrtc/call.h" |
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
21 #include "webrtc/frame_callback.h" | 22 #include "webrtc/frame_callback.h" |
22 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" | 23 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" |
23 #include "webrtc/system_wrappers/interface/clock.h" | 24 #include "webrtc/system_wrappers/interface/clock.h" |
24 #include "webrtc/system_wrappers/interface/cpu_info.h" | 25 #include "webrtc/system_wrappers/interface/cpu_info.h" |
25 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 26 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
26 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 27 #include "webrtc/system_wrappers/interface/event_wrapper.h" |
27 #include "webrtc/system_wrappers/interface/sleep.h" | 28 #include "webrtc/system_wrappers/interface/sleep.h" |
28 #include "webrtc/test/call_test.h" | |
29 #include "webrtc/test/direct_transport.h" | |
30 #include "webrtc/test/encoder_settings.h" | 29 #include "webrtc/test/encoder_settings.h" |
31 #include "webrtc/test/fake_encoder.h" | 30 #include "webrtc/test/fake_encoder.h" |
32 #include "webrtc/test/frame_generator.h" | 31 #include "webrtc/test/frame_generator.h" |
33 #include "webrtc/test/frame_generator_capturer.h" | 32 #include "webrtc/test/frame_generator_capturer.h" |
34 #include "webrtc/test/statistics.h" | 33 #include "webrtc/test/statistics.h" |
35 #include "webrtc/test/testsupport/fileutils.h" | 34 #include "webrtc/test/testsupport/fileutils.h" |
36 #include "webrtc/typedefs.h" | 35 #include "webrtc/typedefs.h" |
36 #include "webrtc/video/full_stack.h" | |
37 | 37 |
38 namespace webrtc { | 38 namespace webrtc { |
39 | 39 |
40 static const int kFullStackTestDurationSecs = 60; | 40 static const int kFullStackTestDurationSecs = 60; |
41 static const int kSendStatsPollingIntervalMs = 1000; | 41 static const int kSendStatsPollingIntervalMs = 1000; |
42 | 42 |
43 struct FullStackTestParams { | |
44 const char* test_label; | |
45 struct { | |
46 const char* name; | |
47 size_t width, height; | |
48 int fps; | |
49 } clip; | |
50 bool screenshare; | |
51 int min_bitrate_bps; | |
52 int target_bitrate_bps; | |
53 int max_bitrate_bps; | |
54 double avg_psnr_threshold; | |
55 double avg_ssim_threshold; | |
56 int test_durations_secs; | |
57 std::string codec; | |
58 FakeNetworkPipe::Config link; | |
59 }; | |
60 | |
61 class FullStackTest : public test::CallTest { | |
62 protected: | |
63 void RunTest(const FullStackTestParams& params); | |
64 }; | |
65 | |
66 class VideoAnalyzer : public PacketReceiver, | 43 class VideoAnalyzer : public PacketReceiver, |
67 public newapi::Transport, | 44 public newapi::Transport, |
68 public VideoRenderer, | 45 public VideoRenderer, |
69 public VideoCaptureInput, | 46 public VideoCaptureInput, |
70 public EncodedFrameObserver { | 47 public EncodedFrameObserver { |
71 public: | 48 public: |
72 VideoAnalyzer(VideoCaptureInput* input, | 49 VideoAnalyzer(VideoCaptureInput* input, |
73 Transport* transport, | 50 Transport* transport, |
74 const char* test_label, | 51 const char* test_label, |
75 double avg_psnr_threshold, | 52 double avg_psnr_threshold, |
76 double avg_ssim_threshold, | 53 double avg_ssim_threshold, |
77 int duration_frames) | 54 int duration_frames, |
55 const std::string& stats_output_filename) | |
78 : input_(input), | 56 : input_(input), |
79 transport_(transport), | 57 transport_(transport), |
80 receiver_(nullptr), | 58 receiver_(nullptr), |
81 send_stream_(nullptr), | 59 send_stream_(nullptr), |
82 test_label_(test_label), | 60 test_label_(test_label), |
61 stats_output_filename_(stats_output_filename), | |
83 frames_to_process_(duration_frames), | 62 frames_to_process_(duration_frames), |
84 frames_recorded_(0), | 63 frames_recorded_(0), |
85 frames_processed_(0), | 64 frames_processed_(0), |
86 dropped_frames_(0), | 65 dropped_frames_(0), |
87 last_render_time_(0), | 66 last_render_time_(0), |
88 rtp_timestamp_delta_(0), | 67 rtp_timestamp_delta_(0), |
89 avg_psnr_threshold_(avg_psnr_threshold), | 68 avg_psnr_threshold_(avg_psnr_threshold), |
90 avg_ssim_threshold_(avg_ssim_threshold), | 69 avg_ssim_threshold_(avg_ssim_threshold), |
91 comparison_available_event_(EventWrapper::Create()), | 70 comparison_available_event_(EventWrapper::Create()), |
92 done_(EventWrapper::Create()) { | 71 done_(EventWrapper::Create()) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 RTPHeader header; | 143 RTPHeader header; |
165 parser->Parse(packet, length, &header); | 144 parser->Parse(packet, length, &header); |
166 | 145 |
167 { | 146 { |
168 rtc::CritScope lock(&crit_); | 147 rtc::CritScope lock(&crit_); |
169 if (rtp_timestamp_delta_ == 0) { | 148 if (rtp_timestamp_delta_ == 0) { |
170 rtp_timestamp_delta_ = | 149 rtp_timestamp_delta_ = |
171 header.timestamp - first_send_frame_.timestamp(); | 150 header.timestamp - first_send_frame_.timestamp(); |
172 first_send_frame_.Reset(); | 151 first_send_frame_.Reset(); |
173 } | 152 } |
174 send_times_[header.timestamp - rtp_timestamp_delta_] = | 153 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_; |
154 send_times_[timestamp] = | |
175 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 155 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
156 encoded_frame_sizes_[timestamp] += | |
157 length - (header.headerLength + header.paddingLength); | |
sprang_webrtc
2015/09/03 08:59:39
Do we ever use simulcast in these tests? Then this
ivica
2015/09/03 09:30:34
Simulcast is not supported here yet. That will be
sprang_webrtc
2015/09/03 11:53:22
Acknowledged.
| |
176 } | 158 } |
177 | 159 |
178 return transport_->SendRtp(packet, length); | 160 return transport_->SendRtp(packet, length); |
179 } | 161 } |
180 | 162 |
181 bool SendRtcp(const uint8_t* packet, size_t length) override { | 163 bool SendRtcp(const uint8_t* packet, size_t length) override { |
182 return transport_->SendRtcp(packet, length); | 164 return transport_->SendRtcp(packet, length); |
183 } | 165 } |
184 | 166 |
185 void EncodedFrameCallback(const EncodedFrame& frame) override { | 167 void EncodedFrameCallback(const EncodedFrame& frame) override { |
186 rtc::CritScope lock(&comparison_lock_); | 168 rtc::CritScope lock(&comparison_lock_); |
187 if (frames_recorded_ < frames_to_process_) | 169 if (frames_recorded_ < frames_to_process_) { |
188 encoded_frame_size_.AddSample(frame.length_); | 170 encoded_frame_size_.AddSample(frame.length_); |
171 } | |
sprang_webrtc
2015/09/03 08:59:39
Don't think you need these extra {}
ivica
2015/09/03 09:30:34
Done.
| |
189 } | 172 } |
190 | 173 |
191 void RenderFrame(const VideoFrame& video_frame, | 174 void RenderFrame(const VideoFrame& video_frame, |
192 int time_to_render_ms) override { | 175 int time_to_render_ms) override { |
193 int64_t render_time_ms = | 176 int64_t render_time_ms = |
194 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 177 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
195 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; | 178 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; |
196 | 179 |
197 rtc::CritScope lock(&crit_); | 180 rtc::CritScope lock(&crit_); |
198 | 181 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 } | 229 } |
247 | 230 |
248 VideoCaptureInput* input_; | 231 VideoCaptureInput* input_; |
249 Transport* transport_; | 232 Transport* transport_; |
250 PacketReceiver* receiver_; | 233 PacketReceiver* receiver_; |
251 VideoSendStream* send_stream_; | 234 VideoSendStream* send_stream_; |
252 | 235 |
253 private: | 236 private: |
254 struct FrameComparison { | 237 struct FrameComparison { |
255 FrameComparison() | 238 FrameComparison() |
256 : dropped(false), send_time_ms(0), recv_time_ms(0), render_time_ms(0) {} | 239 : dropped(false), |
240 send_time_ms(0), | |
241 recv_time_ms(0), | |
242 render_time_ms(0), | |
243 encoded_frame_size(0) {} | |
257 | 244 |
258 FrameComparison(const VideoFrame& reference, | 245 FrameComparison(const VideoFrame& reference, |
259 const VideoFrame& render, | 246 const VideoFrame& render, |
260 bool dropped, | 247 bool dropped, |
261 int64_t send_time_ms, | 248 int64_t send_time_ms, |
262 int64_t recv_time_ms, | 249 int64_t recv_time_ms, |
263 int64_t render_time_ms) | 250 int64_t render_time_ms, |
251 size_t encoded_frame_size) | |
264 : reference(reference), | 252 : reference(reference), |
265 render(render), | 253 render(render), |
266 dropped(dropped), | 254 dropped(dropped), |
267 send_time_ms(send_time_ms), | 255 send_time_ms(send_time_ms), |
268 recv_time_ms(recv_time_ms), | 256 recv_time_ms(recv_time_ms), |
269 render_time_ms(render_time_ms) {} | 257 render_time_ms(render_time_ms), |
258 encoded_frame_size(encoded_frame_size) {} | |
270 | 259 |
271 VideoFrame reference; | 260 VideoFrame reference; |
272 VideoFrame render; | 261 VideoFrame render; |
273 bool dropped; | 262 bool dropped; |
274 int64_t send_time_ms; | 263 int64_t send_time_ms; |
275 int64_t recv_time_ms; | 264 int64_t recv_time_ms; |
276 int64_t render_time_ms; | 265 int64_t render_time_ms; |
266 size_t encoded_frame_size; | |
267 }; | |
268 | |
269 struct Sample { | |
270 Sample(double dropped, | |
271 double input_time_ms, | |
272 double send_time_ms, | |
273 double recv_time_ms, | |
274 double encoded_frame_size, | |
275 double psnr, | |
276 double ssim, | |
277 double decoded_time_ms) | |
278 : dropped(dropped), | |
279 input_time_ms(input_time_ms), | |
280 send_time_ms(send_time_ms), | |
281 recv_time_ms(recv_time_ms), | |
282 encoded_frame_size(encoded_frame_size), | |
283 psnr(psnr), | |
284 ssim(ssim), | |
285 decoded_time_ms(decoded_time_ms) {} | |
286 | |
287 double dropped; | |
288 double input_time_ms; | |
289 double send_time_ms; | |
290 double recv_time_ms; | |
291 double encoded_frame_size; | |
292 double psnr; | |
293 double ssim; | |
294 double decoded_time_ms; | |
277 }; | 295 }; |
278 | 296 |
279 void AddFrameComparison(const VideoFrame& reference, | 297 void AddFrameComparison(const VideoFrame& reference, |
280 const VideoFrame& render, | 298 const VideoFrame& render, |
281 bool dropped, | 299 bool dropped, |
282 int64_t render_time_ms) | 300 int64_t render_time_ms) |
283 EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 301 EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
284 int64_t send_time_ms = send_times_[reference.timestamp()]; | 302 int64_t send_time_ms = send_times_[reference.timestamp()]; |
285 send_times_.erase(reference.timestamp()); | 303 send_times_.erase(reference.timestamp()); |
286 int64_t recv_time_ms = recv_times_[reference.timestamp()]; | 304 int64_t recv_time_ms = recv_times_[reference.timestamp()]; |
287 recv_times_.erase(reference.timestamp()); | 305 recv_times_.erase(reference.timestamp()); |
288 | 306 |
307 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()]; | |
308 encoded_frame_sizes_.erase(reference.timestamp()); | |
309 | |
310 VideoFrame reference_copy; | |
311 VideoFrame render_copy; | |
312 reference_copy.CopyFrame(reference); | |
313 render_copy.CopyFrame(render); | |
314 | |
289 rtc::CritScope crit(&comparison_lock_); | 315 rtc::CritScope crit(&comparison_lock_); |
290 comparisons_.push_back(FrameComparison(reference, render, dropped, | 316 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, |
291 send_time_ms, recv_time_ms, | 317 send_time_ms, recv_time_ms, |
292 render_time_ms)); | 318 render_time_ms, encoded_size)); |
293 comparison_available_event_->Set(); | 319 comparison_available_event_->Set(); |
294 } | 320 } |
295 | 321 |
296 static bool PollStatsThread(void* obj) { | 322 static bool PollStatsThread(void* obj) { |
297 return static_cast<VideoAnalyzer*>(obj)->PollStats(); | 323 return static_cast<VideoAnalyzer*>(obj)->PollStats(); |
298 } | 324 } |
299 | 325 |
300 bool PollStats() { | 326 bool PollStats() { |
301 switch (done_->Wait(kSendStatsPollingIntervalMs)) { | 327 switch (done_->Wait(kSendStatsPollingIntervalMs)) { |
302 case kEventSignaled: | 328 case kEventSignaled: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 comparison_available_event_->Set(); | 366 comparison_available_event_->Set(); |
341 return false; | 367 return false; |
342 } | 368 } |
343 return true; // Try again. | 369 return true; // Try again. |
344 } | 370 } |
345 | 371 |
346 PerformFrameComparison(comparison); | 372 PerformFrameComparison(comparison); |
347 | 373 |
348 if (FrameProcessed()) { | 374 if (FrameProcessed()) { |
349 PrintResults(); | 375 PrintResults(); |
376 if (!stats_output_filename_.empty()) | |
377 PrintSamplesToFile(); | |
350 done_->Set(); | 378 done_->Set(); |
351 comparison_available_event_->Set(); | 379 comparison_available_event_->Set(); |
352 return false; | 380 return false; |
353 } | 381 } |
354 | 382 |
355 return true; | 383 return true; |
356 } | 384 } |
357 | 385 |
358 bool PopComparison(FrameComparison* comparison) { | 386 bool PopComparison(FrameComparison* comparison) { |
359 rtc::CritScope crit(&comparison_lock_); | 387 rtc::CritScope crit(&comparison_lock_); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 | 440 |
413 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); | 441 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); |
414 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); | 442 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); |
415 } | 443 } |
416 | 444 |
417 void PerformFrameComparison(const FrameComparison& comparison) { | 445 void PerformFrameComparison(const FrameComparison& comparison) { |
418 // Perform expensive psnr and ssim calculations while not holding lock. | 446 // Perform expensive psnr and ssim calculations while not holding lock. |
419 double psnr = I420PSNR(&comparison.reference, &comparison.render); | 447 double psnr = I420PSNR(&comparison.reference, &comparison.render); |
420 double ssim = I420SSIM(&comparison.reference, &comparison.render); | 448 double ssim = I420SSIM(&comparison.reference, &comparison.render); |
421 | 449 |
450 int64_t input_time_ms = comparison.reference.ntp_time_ms(); | |
451 Sample sample(comparison.dropped, input_time_ms, comparison.send_time_ms, | |
452 comparison.recv_time_ms, comparison.encoded_frame_size, psnr, | |
453 ssim, | |
454 comparison.render_time_ms); // decoded_time_ms | |
sprang_webrtc
2015/09/03 08:59:39
Why use a temporary?
ivica
2015/09/03 09:30:34
Done.
| |
455 | |
422 rtc::CritScope crit(&comparison_lock_); | 456 rtc::CritScope crit(&comparison_lock_); |
457 if (!stats_output_filename_.empty()) | |
458 samples_.push_back(sample); | |
423 psnr_.AddSample(psnr); | 459 psnr_.AddSample(psnr); |
424 ssim_.AddSample(ssim); | 460 ssim_.AddSample(ssim); |
461 | |
425 if (comparison.dropped) { | 462 if (comparison.dropped) { |
426 ++dropped_frames_; | 463 ++dropped_frames_; |
427 return; | 464 return; |
428 } | 465 } |
429 if (last_render_time_ != 0) | 466 if (last_render_time_ != 0) |
430 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); | 467 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); |
431 last_render_time_ = comparison.render_time_ms; | 468 last_render_time_ = comparison.render_time_ms; |
432 | 469 |
433 int64_t input_time_ms = comparison.reference.ntp_time_ms(); | |
434 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); | 470 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); |
435 receiver_time_.AddSample(comparison.render_time_ms - | 471 receiver_time_.AddSample(comparison.render_time_ms - |
436 comparison.recv_time_ms); | 472 comparison.recv_time_ms); |
437 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms); | 473 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms); |
474 encoded_frame_size_.AddSample(comparison.encoded_frame_size); | |
438 } | 475 } |
439 | 476 |
440 void PrintResult(const char* result_type, | 477 void PrintResult(const char* result_type, |
441 test::Statistics stats, | 478 test::Statistics stats, |
442 const char* unit) { | 479 const char* unit) { |
443 printf("RESULT %s: %s = {%f, %f}%s\n", | 480 printf("RESULT %s: %s = {%f, %f}%s\n", |
444 result_type, | 481 result_type, |
445 test_label_, | 482 test_label_, |
446 stats.Mean(), | 483 stats.Mean(), |
447 stats.StandardDeviation(), | 484 stats.StandardDeviation(), |
448 unit); | 485 unit); |
449 } | 486 } |
450 | 487 |
488 void PrintSamplesToFile(void) { | |
489 FILE* f = fopen(stats_output_filename_.c_str(), "w"); | |
490 if (f == NULL) { | |
491 fprintf(stderr, "Couldn't open file %s\n", | |
492 stats_output_filename_.c_str()); | |
493 abort(); | |
494 } | |
495 | |
496 rtc::CritScope crit(&comparison_lock_); | |
497 std::sort(samples_.begin(), samples_.end(), | |
498 [](const Sample& A, const Sample& B) | |
499 -> bool { return A.input_time_ms < B.input_time_ms; }); | |
500 | |
501 fprintf(f, "%s\n", test_label_); | |
502 fprintf(f, "%" PRIuS "\n", samples_.size()); | |
503 fprintf(f, | |
504 "dropped " | |
505 "input_time_ms " | |
506 "send_time_ms " | |
507 "recv_time_ms " | |
508 "encoded_frame_size " | |
509 "psnr " | |
510 "ssim " | |
511 "decoded_time_ms\n"); | |
512 for (Sample& sample : samples_) { | |
sprang_webrtc
2015/09/03 08:59:39
const Sample&
ivica
2015/09/03 09:30:34
Done.
| |
513 fprintf(f, "%lf %lf %lf %lf %lf %lf %lf %lf\n", sample.dropped, | |
514 sample.input_time_ms, sample.send_time_ms, sample.recv_time_ms, | |
515 sample.encoded_frame_size, sample.psnr, sample.ssim, | |
516 sample.decoded_time_ms); | |
517 } | |
518 fclose(f); | |
519 } | |
520 | |
451 const char* const test_label_; | 521 const char* const test_label_; |
522 std::string stats_output_filename_; | |
523 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); | |
452 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); | 524 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); |
453 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); | 525 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); |
454 test::Statistics psnr_ GUARDED_BY(comparison_lock_); | 526 test::Statistics psnr_ GUARDED_BY(comparison_lock_); |
455 test::Statistics ssim_ GUARDED_BY(comparison_lock_); | 527 test::Statistics ssim_ GUARDED_BY(comparison_lock_); |
456 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); | 528 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); |
457 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); | 529 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); |
458 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); | 530 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); |
459 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); | 531 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); |
460 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_); | 532 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_); |
461 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_); | 533 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_); |
462 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_); | 534 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_); |
463 | 535 |
464 const int frames_to_process_; | 536 const int frames_to_process_; |
465 int frames_recorded_; | 537 int frames_recorded_; |
466 int frames_processed_; | 538 int frames_processed_; |
467 int dropped_frames_; | 539 int dropped_frames_; |
468 int64_t last_render_time_; | 540 int64_t last_render_time_; |
469 uint32_t rtp_timestamp_delta_; | 541 uint32_t rtp_timestamp_delta_; |
470 | 542 |
471 rtc::CriticalSection crit_; | 543 rtc::CriticalSection crit_; |
472 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); | 544 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); |
545 std::deque<VideoSendStream::Stats> send_stats_ GUARDED_BY(crit_); | |
473 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); | 546 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); |
474 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); | 547 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); |
475 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); | 548 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); |
549 std::map<uint32_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); | |
476 VideoFrame first_send_frame_ GUARDED_BY(crit_); | 550 VideoFrame first_send_frame_ GUARDED_BY(crit_); |
477 const double avg_psnr_threshold_; | 551 const double avg_psnr_threshold_; |
478 const double avg_ssim_threshold_; | 552 const double avg_ssim_threshold_; |
479 | 553 |
480 rtc::CriticalSection comparison_lock_; | 554 rtc::CriticalSection comparison_lock_; |
481 std::vector<ThreadWrapper*> comparison_thread_pool_; | 555 std::vector<ThreadWrapper*> comparison_thread_pool_; |
482 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; | 556 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; |
483 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; | 557 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; |
484 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 558 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); |
485 const rtc::scoped_ptr<EventWrapper> done_; | 559 const rtc::scoped_ptr<EventWrapper> done_; |
486 }; | 560 }; |
487 | 561 |
488 void FullStackTest::RunTest(const FullStackTestParams& params) { | 562 void FullStackTest::RunTest(const FullStackTestParams& params) { |
563 // TODO(ivica): Add num_temporal_layers as a param. | |
564 unsigned char num_temporal_layers = | |
565 params.stats_output_filename.empty() ? 2 : 1; | |
566 | |
489 test::DirectTransport send_transport(params.link); | 567 test::DirectTransport send_transport(params.link); |
490 test::DirectTransport recv_transport(params.link); | 568 test::DirectTransport recv_transport(params.link); |
491 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label, | 569 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label, |
492 params.avg_psnr_threshold, params.avg_ssim_threshold, | 570 params.avg_psnr_threshold, params.avg_ssim_threshold, |
493 params.test_durations_secs * params.clip.fps); | 571 params.test_durations_secs * params.clip.fps, |
572 params.stats_output_filename); | |
494 | 573 |
495 CreateCalls(Call::Config(&analyzer), Call::Config(&recv_transport)); | 574 CreateCalls(Call::Config(&analyzer), Call::Config(&recv_transport)); |
496 | 575 |
497 analyzer.SetReceiver(receiver_call_->Receiver()); | 576 analyzer.SetReceiver(receiver_call_->Receiver()); |
498 send_transport.SetReceiver(&analyzer); | 577 send_transport.SetReceiver(&analyzer); |
499 recv_transport.SetReceiver(sender_call_->Receiver()); | 578 recv_transport.SetReceiver(sender_call_->Receiver()); |
500 | 579 |
501 CreateSendConfig(1); | 580 CreateSendConfig(1); |
502 | 581 |
503 rtc::scoped_ptr<VideoEncoder> encoder; | 582 rtc::scoped_ptr<VideoEncoder> encoder; |
(...skipping 27 matching lines...) Expand all Loading... | |
531 | 610 |
532 VideoCodecVP8 vp8_settings; | 611 VideoCodecVP8 vp8_settings; |
533 VideoCodecVP9 vp9_settings; | 612 VideoCodecVP9 vp9_settings; |
534 if (params.screenshare) { | 613 if (params.screenshare) { |
535 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 614 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
536 encoder_config_.min_transmit_bitrate_bps = 400 * 1000; | 615 encoder_config_.min_transmit_bitrate_bps = 400 * 1000; |
537 if (params.codec == "VP8") { | 616 if (params.codec == "VP8") { |
538 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); | 617 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
539 vp8_settings.denoisingOn = false; | 618 vp8_settings.denoisingOn = false; |
540 vp8_settings.frameDroppingOn = false; | 619 vp8_settings.frameDroppingOn = false; |
541 vp8_settings.numberOfTemporalLayers = 2; | 620 vp8_settings.numberOfTemporalLayers = num_temporal_layers; |
542 encoder_config_.encoder_specific_settings = &vp8_settings; | 621 encoder_config_.encoder_specific_settings = &vp8_settings; |
543 } else if (params.codec == "VP9") { | 622 } else if (params.codec == "VP9") { |
544 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); | 623 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
545 vp9_settings.denoisingOn = false; | 624 vp9_settings.denoisingOn = false; |
546 vp9_settings.frameDroppingOn = false; | 625 vp9_settings.frameDroppingOn = false; |
547 vp9_settings.numberOfTemporalLayers = 2; | 626 vp9_settings.numberOfTemporalLayers = num_temporal_layers; |
548 encoder_config_.encoder_specific_settings = &vp9_settings; | 627 encoder_config_.encoder_specific_settings = &vp9_settings; |
549 } | 628 } |
550 | 629 |
551 stream->temporal_layer_thresholds_bps.clear(); | 630 stream->temporal_layer_thresholds_bps.clear(); |
552 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps); | 631 if (num_temporal_layers > 1) { |
632 stream->temporal_layer_thresholds_bps.push_back( | |
633 stream->target_bitrate_bps); | |
634 } | |
553 } | 635 } |
554 | 636 |
555 CreateMatchingReceiveConfigs(); | 637 CreateMatchingReceiveConfigs(); |
556 receive_configs_[0].renderer = &analyzer; | 638 receive_configs_[0].renderer = &analyzer; |
557 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 639 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
558 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; | 640 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; |
559 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = | 641 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = |
560 kSendRtxPayloadType; | 642 kSendRtxPayloadType; |
561 | 643 |
562 for (auto& config : receive_configs_) | 644 for (auto& config : receive_configs_) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 50000, | 844 50000, |
763 200000, | 845 200000, |
764 2000000, | 846 2000000, |
765 0.0, | 847 0.0, |
766 0.0, | 848 0.0, |
767 kFullStackTestDurationSecs, | 849 kFullStackTestDurationSecs, |
768 "VP9"}; | 850 "VP9"}; |
769 RunTest(screenshare_params); | 851 RunTest(screenshare_params); |
770 } | 852 } |
771 } // namespace webrtc | 853 } // namespace webrtc |
OLD | NEW |