Chromium Code Reviews| 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); | |
| 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 { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 } | 240 } |
| 259 | 241 |
| 260 VideoCaptureInput* input_; | 242 VideoCaptureInput* input_; |
| 261 Transport* transport_; | 243 Transport* transport_; |
| 262 PacketReceiver* receiver_; | 244 PacketReceiver* receiver_; |
| 263 VideoSendStream* send_stream_; | 245 VideoSendStream* send_stream_; |
| 264 | 246 |
| 265 private: | 247 private: |
| 266 struct FrameComparison { | 248 struct FrameComparison { |
| 267 FrameComparison() | 249 FrameComparison() |
| 268 : dropped(false), send_time_ms(0), recv_time_ms(0), render_time_ms(0) {} | 250 : dropped(false), |
| 251 send_time_ms(0), | |
| 252 recv_time_ms(0), | |
| 253 render_time_ms(0), | |
| 254 encoded_frame_size(0) {} | |
| 269 | 255 |
| 270 FrameComparison(const VideoFrame& reference, | 256 FrameComparison(const VideoFrame& reference, |
| 271 const VideoFrame& render, | 257 const VideoFrame& render, |
| 272 bool dropped, | 258 bool dropped, |
| 273 int64_t send_time_ms, | 259 int64_t send_time_ms, |
| 274 int64_t recv_time_ms, | 260 int64_t recv_time_ms, |
| 275 int64_t render_time_ms) | 261 int64_t render_time_ms, |
| 262 size_t encoded_frame_size) | |
| 276 : reference(reference), | 263 : reference(reference), |
| 277 render(render), | 264 render(render), |
| 278 dropped(dropped), | 265 dropped(dropped), |
| 279 send_time_ms(send_time_ms), | 266 send_time_ms(send_time_ms), |
| 280 recv_time_ms(recv_time_ms), | 267 recv_time_ms(recv_time_ms), |
| 281 render_time_ms(render_time_ms) {} | 268 render_time_ms(render_time_ms), |
| 269 encoded_frame_size(encoded_frame_size) {} | |
| 282 | 270 |
| 283 VideoFrame reference; | 271 VideoFrame reference; |
| 284 VideoFrame render; | 272 VideoFrame render; |
| 285 bool dropped; | 273 bool dropped; |
| 286 int64_t send_time_ms; | 274 int64_t send_time_ms; |
| 287 int64_t recv_time_ms; | 275 int64_t recv_time_ms; |
| 288 int64_t render_time_ms; | 276 int64_t render_time_ms; |
| 277 size_t encoded_frame_size; | |
| 278 }; | |
| 279 | |
| 280 struct Sample { | |
| 281 Sample(double dropped, | |
| 282 double input_time_ms, | |
| 283 double send_time_ms, | |
| 284 double recv_time_ms, | |
| 285 double encoded_frame_size, | |
| 286 double psnr, | |
| 287 double ssim, | |
| 288 double render_time_ms) | |
| 289 : dropped(dropped), | |
| 290 input_time_ms(input_time_ms), | |
| 291 send_time_ms(send_time_ms), | |
| 292 recv_time_ms(recv_time_ms), | |
| 293 encoded_frame_size(encoded_frame_size), | |
| 294 psnr(psnr), | |
| 295 ssim(ssim), | |
| 296 render_time_ms(render_time_ms) {} | |
| 297 | |
| 298 double dropped; | |
| 299 double input_time_ms; | |
| 300 double send_time_ms; | |
| 301 double recv_time_ms; | |
| 302 double encoded_frame_size; | |
| 303 double psnr; | |
| 304 double ssim; | |
| 305 double render_time_ms; | |
| 289 }; | 306 }; |
| 290 | 307 |
| 291 void AddFrameComparison(const VideoFrame& reference, | 308 void AddFrameComparison(const VideoFrame& reference, |
| 292 const VideoFrame& render, | 309 const VideoFrame& render, |
| 293 bool dropped, | 310 bool dropped, |
| 294 int64_t render_time_ms) | 311 int64_t render_time_ms) |
| 295 EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 312 EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
| 296 int64_t send_time_ms = send_times_[reference.timestamp()]; | 313 int64_t send_time_ms = send_times_[reference.timestamp()]; |
| 297 send_times_.erase(reference.timestamp()); | 314 send_times_.erase(reference.timestamp()); |
| 298 int64_t recv_time_ms = recv_times_[reference.timestamp()]; | 315 int64_t recv_time_ms = recv_times_[reference.timestamp()]; |
| 299 recv_times_.erase(reference.timestamp()); | 316 recv_times_.erase(reference.timestamp()); |
| 300 | 317 |
| 318 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()]; | |
| 319 encoded_frame_sizes_.erase(reference.timestamp()); | |
| 320 | |
| 321 VideoFrame reference_copy; | |
| 322 VideoFrame render_copy; | |
| 323 reference_copy.CopyFrame(reference); | |
| 324 render_copy.CopyFrame(render); | |
| 325 | |
| 301 rtc::CritScope crit(&comparison_lock_); | 326 rtc::CritScope crit(&comparison_lock_); |
| 302 comparisons_.push_back(FrameComparison(reference, render, dropped, | 327 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, |
| 303 send_time_ms, recv_time_ms, | 328 send_time_ms, recv_time_ms, |
| 304 render_time_ms)); | 329 render_time_ms, encoded_size)); |
| 305 comparison_available_event_->Set(); | 330 comparison_available_event_->Set(); |
| 306 } | 331 } |
| 307 | 332 |
| 308 static bool PollStatsThread(void* obj) { | 333 static bool PollStatsThread(void* obj) { |
| 309 return static_cast<VideoAnalyzer*>(obj)->PollStats(); | 334 return static_cast<VideoAnalyzer*>(obj)->PollStats(); |
| 310 } | 335 } |
| 311 | 336 |
| 312 bool PollStats() { | 337 bool PollStats() { |
| 313 switch (done_->Wait(kSendStatsPollingIntervalMs)) { | 338 switch (done_->Wait(kSendStatsPollingIntervalMs)) { |
| 314 case kEventSignaled: | 339 case kEventSignaled: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 comparison_available_event_->Set(); | 377 comparison_available_event_->Set(); |
| 353 return false; | 378 return false; |
| 354 } | 379 } |
| 355 return true; // Try again. | 380 return true; // Try again. |
| 356 } | 381 } |
| 357 | 382 |
| 358 PerformFrameComparison(comparison); | 383 PerformFrameComparison(comparison); |
| 359 | 384 |
| 360 if (FrameProcessed()) { | 385 if (FrameProcessed()) { |
| 361 PrintResults(); | 386 PrintResults(); |
| 387 if (!stats_output_filename_.empty()) | |
| 388 PrintSamplesToFile(); | |
| 362 done_->Set(); | 389 done_->Set(); |
| 363 comparison_available_event_->Set(); | 390 comparison_available_event_->Set(); |
| 364 return false; | 391 return false; |
| 365 } | 392 } |
| 366 | 393 |
| 367 return true; | 394 return true; |
| 368 } | 395 } |
| 369 | 396 |
| 370 bool PopComparison(FrameComparison* comparison) { | 397 bool PopComparison(FrameComparison* comparison) { |
| 371 rtc::CritScope crit(&comparison_lock_); | 398 rtc::CritScope crit(&comparison_lock_); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 | 451 |
| 425 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); | 452 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); |
| 426 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); | 453 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); |
| 427 } | 454 } |
| 428 | 455 |
| 429 void PerformFrameComparison(const FrameComparison& comparison) { | 456 void PerformFrameComparison(const FrameComparison& comparison) { |
| 430 // Perform expensive psnr and ssim calculations while not holding lock. | 457 // Perform expensive psnr and ssim calculations while not holding lock. |
| 431 double psnr = I420PSNR(&comparison.reference, &comparison.render); | 458 double psnr = I420PSNR(&comparison.reference, &comparison.render); |
| 432 double ssim = I420SSIM(&comparison.reference, &comparison.render); | 459 double ssim = I420SSIM(&comparison.reference, &comparison.render); |
| 433 | 460 |
| 461 int64_t input_time_ms = comparison.reference.ntp_time_ms(); | |
| 462 | |
| 434 rtc::CritScope crit(&comparison_lock_); | 463 rtc::CritScope crit(&comparison_lock_); |
| 464 if (!stats_output_filename_.empty()) { | |
| 465 samples_.push_back(Sample( | |
| 466 comparison.dropped, input_time_ms, comparison.send_time_ms, | |
| 467 comparison.recv_time_ms, comparison.encoded_frame_size, psnr, ssim, | |
| 468 comparison.render_time_ms)); | |
| 469 } | |
| 435 psnr_.AddSample(psnr); | 470 psnr_.AddSample(psnr); |
| 436 ssim_.AddSample(ssim); | 471 ssim_.AddSample(ssim); |
| 472 | |
| 437 if (comparison.dropped) { | 473 if (comparison.dropped) { |
| 438 ++dropped_frames_; | 474 ++dropped_frames_; |
| 439 return; | 475 return; |
| 440 } | 476 } |
| 441 if (last_render_time_ != 0) | 477 if (last_render_time_ != 0) |
| 442 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); | 478 rendered_delta_.AddSample(comparison.render_time_ms - last_render_time_); |
| 443 last_render_time_ = comparison.render_time_ms; | 479 last_render_time_ = comparison.render_time_ms; |
| 444 | 480 |
| 445 int64_t input_time_ms = comparison.reference.ntp_time_ms(); | |
| 446 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); | 481 sender_time_.AddSample(comparison.send_time_ms - input_time_ms); |
| 447 receiver_time_.AddSample(comparison.render_time_ms - | 482 receiver_time_.AddSample(comparison.render_time_ms - |
| 448 comparison.recv_time_ms); | 483 comparison.recv_time_ms); |
| 449 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms); | 484 end_to_end_.AddSample(comparison.render_time_ms - input_time_ms); |
| 485 encoded_frame_size_.AddSample(comparison.encoded_frame_size); | |
| 450 } | 486 } |
| 451 | 487 |
| 452 void PrintResult(const char* result_type, | 488 void PrintResult(const char* result_type, |
| 453 test::Statistics stats, | 489 test::Statistics stats, |
| 454 const char* unit) { | 490 const char* unit) { |
| 455 printf("RESULT %s: %s = {%f, %f}%s\n", | 491 printf("RESULT %s: %s = {%f, %f}%s\n", |
| 456 result_type, | 492 result_type, |
| 457 test_label_, | 493 test_label_, |
| 458 stats.Mean(), | 494 stats.Mean(), |
| 459 stats.StandardDeviation(), | 495 stats.StandardDeviation(), |
| 460 unit); | 496 unit); |
| 461 } | 497 } |
| 462 | 498 |
| 499 void PrintSamplesToFile(void) { | |
| 500 FILE* f = fopen(stats_output_filename_.c_str(), "w"); | |
|
pbos-webrtc
2015/09/03 14:59:27
s/f/out/ or s/f/file/, your choice. Pref first.
ivica
2015/09/03 16:24:23
Done.
| |
| 501 if (f == NULL) { | |
| 502 fprintf(stderr, "Couldn't open file %s\n", | |
| 503 stats_output_filename_.c_str()); | |
| 504 abort(); | |
| 505 } | |
| 506 | |
| 507 rtc::CritScope crit(&comparison_lock_); | |
| 508 std::sort(samples_.begin(), samples_.end(), | |
| 509 [](const Sample& A, const Sample& B) | |
| 510 -> bool { return A.input_time_ms < B.input_time_ms; }); | |
| 511 | |
| 512 fprintf(f, "%s\n", test_label_); | |
| 513 fprintf(f, "%" PRIuS "\n", samples_.size()); | |
| 514 fprintf(f, | |
| 515 "dropped " | |
| 516 "input_time_ms " | |
| 517 "send_time_ms " | |
| 518 "recv_time_ms " | |
| 519 "encoded_frame_size " | |
| 520 "psnr " | |
| 521 "ssim " | |
| 522 "render_time_ms\n"); | |
| 523 for (const Sample& sample : samples_) { | |
| 524 fprintf(f, "%lf %lf %lf %lf %lf %lf %lf %lf\n", sample.dropped, | |
| 525 sample.input_time_ms, sample.send_time_ms, sample.recv_time_ms, | |
| 526 sample.encoded_frame_size, sample.psnr, sample.ssim, | |
| 527 sample.render_time_ms); | |
| 528 } | |
| 529 fclose(f); | |
| 530 } | |
| 531 | |
| 463 const char* const test_label_; | 532 const char* const test_label_; |
| 533 std::string stats_output_filename_; | |
| 534 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); | |
| 464 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); | 535 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); |
| 465 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); | 536 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); |
| 466 test::Statistics psnr_ GUARDED_BY(comparison_lock_); | 537 test::Statistics psnr_ GUARDED_BY(comparison_lock_); |
| 467 test::Statistics ssim_ GUARDED_BY(comparison_lock_); | 538 test::Statistics ssim_ GUARDED_BY(comparison_lock_); |
| 468 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); | 539 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); |
| 469 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); | 540 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); |
| 470 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); | 541 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); |
| 471 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); | 542 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); |
| 472 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_); | 543 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_); |
| 473 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_); | 544 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_); |
| 474 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_); | 545 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_); |
| 475 | 546 |
| 476 const int frames_to_process_; | 547 const int frames_to_process_; |
| 477 int frames_recorded_; | 548 int frames_recorded_; |
| 478 int frames_processed_; | 549 int frames_processed_; |
| 479 int dropped_frames_; | 550 int dropped_frames_; |
| 480 int64_t last_render_time_; | 551 int64_t last_render_time_; |
| 481 uint32_t rtp_timestamp_delta_; | 552 uint32_t rtp_timestamp_delta_; |
| 482 | 553 |
| 483 rtc::CriticalSection crit_; | 554 rtc::CriticalSection crit_; |
| 484 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); | 555 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); |
| 556 std::deque<VideoSendStream::Stats> send_stats_ GUARDED_BY(crit_); | |
| 485 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); | 557 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); |
| 486 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); | 558 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); |
| 487 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); | 559 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); |
| 560 std::map<uint32_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); | |
| 488 VideoFrame first_send_frame_ GUARDED_BY(crit_); | 561 VideoFrame first_send_frame_ GUARDED_BY(crit_); |
| 489 const double avg_psnr_threshold_; | 562 const double avg_psnr_threshold_; |
| 490 const double avg_ssim_threshold_; | 563 const double avg_ssim_threshold_; |
| 491 | 564 |
| 492 rtc::CriticalSection comparison_lock_; | 565 rtc::CriticalSection comparison_lock_; |
| 493 std::vector<ThreadWrapper*> comparison_thread_pool_; | 566 std::vector<ThreadWrapper*> comparison_thread_pool_; |
| 494 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; | 567 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; |
| 495 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; | 568 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; |
| 496 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 569 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); |
| 497 const rtc::scoped_ptr<EventWrapper> done_; | 570 const rtc::scoped_ptr<EventWrapper> done_; |
| 498 }; | 571 }; |
| 499 | 572 |
| 500 void FullStackTest::RunTest(const FullStackTestParams& params) { | 573 void FullStackTest::RunTest(const FullStackTestParams& params) { |
| 574 // TODO(ivica): Add num_temporal_layers as a param. | |
| 575 unsigned char num_temporal_layers = | |
| 576 params.stats_output_filename.empty() ? 2 : 1; | |
| 577 | |
| 501 test::DirectTransport send_transport(params.link); | 578 test::DirectTransport send_transport(params.link); |
| 502 test::DirectTransport recv_transport(params.link); | 579 test::DirectTransport recv_transport(params.link); |
| 503 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label, | 580 VideoAnalyzer analyzer(nullptr, &send_transport, params.test_label, |
| 504 params.avg_psnr_threshold, params.avg_ssim_threshold, | 581 params.avg_psnr_threshold, params.avg_ssim_threshold, |
| 505 params.test_durations_secs * params.clip.fps); | 582 params.test_durations_secs * params.clip.fps, |
| 583 params.stats_output_filename); | |
| 506 | 584 |
| 507 CreateCalls(Call::Config(), Call::Config()); | 585 CreateCalls(Call::Config(), Call::Config()); |
| 508 | 586 |
| 509 analyzer.SetReceiver(receiver_call_->Receiver()); | 587 analyzer.SetReceiver(receiver_call_->Receiver()); |
| 510 send_transport.SetReceiver(&analyzer); | 588 send_transport.SetReceiver(&analyzer); |
| 511 recv_transport.SetReceiver(sender_call_->Receiver()); | 589 recv_transport.SetReceiver(sender_call_->Receiver()); |
| 512 | 590 |
| 513 CreateSendConfig(1, &analyzer); | 591 CreateSendConfig(1, &analyzer); |
| 514 | 592 |
| 515 rtc::scoped_ptr<VideoEncoder> encoder; | 593 rtc::scoped_ptr<VideoEncoder> encoder; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 543 | 621 |
| 544 VideoCodecVP8 vp8_settings; | 622 VideoCodecVP8 vp8_settings; |
| 545 VideoCodecVP9 vp9_settings; | 623 VideoCodecVP9 vp9_settings; |
| 546 if (params.screenshare) { | 624 if (params.screenshare) { |
| 547 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 625 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 548 encoder_config_.min_transmit_bitrate_bps = 400 * 1000; | 626 encoder_config_.min_transmit_bitrate_bps = 400 * 1000; |
| 549 if (params.codec == "VP8") { | 627 if (params.codec == "VP8") { |
| 550 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); | 628 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
| 551 vp8_settings.denoisingOn = false; | 629 vp8_settings.denoisingOn = false; |
| 552 vp8_settings.frameDroppingOn = false; | 630 vp8_settings.frameDroppingOn = false; |
| 553 vp8_settings.numberOfTemporalLayers = 2; | 631 vp8_settings.numberOfTemporalLayers = num_temporal_layers; |
| 554 encoder_config_.encoder_specific_settings = &vp8_settings; | 632 encoder_config_.encoder_specific_settings = &vp8_settings; |
| 555 } else if (params.codec == "VP9") { | 633 } else if (params.codec == "VP9") { |
| 556 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); | 634 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
| 557 vp9_settings.denoisingOn = false; | 635 vp9_settings.denoisingOn = false; |
| 558 vp9_settings.frameDroppingOn = false; | 636 vp9_settings.frameDroppingOn = false; |
| 559 vp9_settings.numberOfTemporalLayers = 2; | 637 vp9_settings.numberOfTemporalLayers = num_temporal_layers; |
| 560 encoder_config_.encoder_specific_settings = &vp9_settings; | 638 encoder_config_.encoder_specific_settings = &vp9_settings; |
| 561 } | 639 } |
| 562 | 640 |
| 563 stream->temporal_layer_thresholds_bps.clear(); | 641 stream->temporal_layer_thresholds_bps.clear(); |
| 564 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps); | 642 if (num_temporal_layers > 1) { |
| 643 stream->temporal_layer_thresholds_bps.push_back( | |
| 644 stream->target_bitrate_bps); | |
| 645 } | |
| 565 } | 646 } |
| 566 | 647 |
| 567 CreateMatchingReceiveConfigs(&recv_transport); | 648 CreateMatchingReceiveConfigs(&recv_transport); |
| 568 receive_configs_[0].renderer = &analyzer; | 649 receive_configs_[0].renderer = &analyzer; |
| 569 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 650 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 570 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; | 651 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; |
| 571 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = | 652 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = |
| 572 kSendRtxPayloadType; | 653 kSendRtxPayloadType; |
| 573 | 654 |
| 574 for (auto& config : receive_configs_) | 655 for (auto& config : receive_configs_) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 50000, | 855 50000, |
| 775 200000, | 856 200000, |
| 776 2000000, | 857 2000000, |
| 777 0.0, | 858 0.0, |
| 778 0.0, | 859 0.0, |
| 779 kFullStackTestDurationSecs, | 860 kFullStackTestDurationSecs, |
| 780 "VP9"}; | 861 "VP9"}; |
| 781 RunTest(screenshare_params); | 862 RunTest(screenshare_params); |
| 782 } | 863 } |
| 783 } // namespace webrtc | 864 } // namespace webrtc |
| OLD | NEW |