OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <algorithm> | 12 #include <algorithm> |
13 #include <deque> | 13 #include <deque> |
14 #include <map> | 14 #include <map> |
15 #include <sstream> | |
16 #include <vector> | 15 #include <vector> |
17 | 16 |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/format_macros.h" | 20 #include "webrtc/base/format_macros.h" |
22 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" |
23 #include "webrtc/call.h" | 22 #include "webrtc/call.h" |
24 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 23 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
25 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" | 24 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" |
(...skipping 13 matching lines...) Expand all Loading... |
39 static const int kPayloadTypeVP8 = 123; | 38 static const int kPayloadTypeVP8 = 123; |
40 static const int kPayloadTypeVP9 = 124; | 39 static const int kPayloadTypeVP9 = 124; |
41 | 40 |
42 class VideoAnalyzer : public PacketReceiver, | 41 class VideoAnalyzer : public PacketReceiver, |
43 public Transport, | 42 public Transport, |
44 public VideoRenderer, | 43 public VideoRenderer, |
45 public VideoCaptureInput, | 44 public VideoCaptureInput, |
46 public EncodedFrameObserver, | 45 public EncodedFrameObserver, |
47 public EncodingTimeObserver { | 46 public EncodingTimeObserver { |
48 public: | 47 public: |
49 VideoAnalyzer(test::LayerFilteringTransport* transport, | 48 VideoAnalyzer(Transport* transport, |
50 const std::string& test_label, | 49 const std::string& test_label, |
51 double avg_psnr_threshold, | 50 double avg_psnr_threshold, |
52 double avg_ssim_threshold, | 51 double avg_ssim_threshold, |
53 int duration_frames, | 52 int duration_frames, |
54 FILE* graph_data_output_file, | 53 FILE* graph_data_output_file) |
55 const std::string &graph_title, | |
56 uint32_t ssrc_to_analyze) | |
57 : input_(nullptr), | 54 : input_(nullptr), |
58 transport_(transport), | 55 transport_(transport), |
59 receiver_(nullptr), | 56 receiver_(nullptr), |
60 send_stream_(nullptr), | 57 send_stream_(nullptr), |
61 test_label_(test_label), | 58 test_label_(test_label), |
62 graph_data_output_file_(graph_data_output_file), | 59 graph_data_output_file_(graph_data_output_file), |
63 graph_title_(graph_title), | |
64 ssrc_to_analyze_(ssrc_to_analyze), | |
65 frames_to_process_(duration_frames), | 60 frames_to_process_(duration_frames), |
66 frames_recorded_(0), | 61 frames_recorded_(0), |
67 frames_processed_(0), | 62 frames_processed_(0), |
68 dropped_frames_(0), | 63 dropped_frames_(0), |
69 last_render_time_(0), | 64 last_render_time_(0), |
70 rtp_timestamp_delta_(0), | 65 rtp_timestamp_delta_(0), |
71 avg_psnr_threshold_(avg_psnr_threshold), | 66 avg_psnr_threshold_(avg_psnr_threshold), |
72 avg_ssim_threshold_(avg_ssim_threshold), | 67 avg_ssim_threshold_(avg_ssim_threshold), |
73 comparison_available_event_(EventWrapper::Create()), | 68 comparison_available_event_(EventWrapper::Create()), |
74 done_(EventWrapper::Create()) { | 69 done_(EventWrapper::Create()) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 input_->IncomingCapturedFrame(video_frame); | 144 input_->IncomingCapturedFrame(video_frame); |
150 } | 145 } |
151 | 146 |
152 bool SendRtp(const uint8_t* packet, | 147 bool SendRtp(const uint8_t* packet, |
153 size_t length, | 148 size_t length, |
154 const PacketOptions& options) override { | 149 const PacketOptions& options) override { |
155 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 150 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
156 RTPHeader header; | 151 RTPHeader header; |
157 parser->Parse(packet, length, &header); | 152 parser->Parse(packet, length, &header); |
158 | 153 |
159 int64_t current_time = | |
160 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | |
161 bool result = transport_->SendRtp(packet, length, options); | |
162 { | 154 { |
163 rtc::CritScope lock(&crit_); | 155 rtc::CritScope lock(&crit_); |
164 if (rtp_timestamp_delta_ == 0) { | 156 if (rtp_timestamp_delta_ == 0) { |
165 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp(); | 157 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp(); |
166 first_send_frame_.Reset(); | 158 first_send_frame_.Reset(); |
167 } | 159 } |
168 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_; | 160 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_; |
169 send_times_[timestamp] = current_time; | 161 send_times_[timestamp] = |
170 if (!transport_->DiscardedLastPacket() && | 162 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
171 header.ssrc == ssrc_to_analyze_) { | 163 encoded_frame_sizes_[timestamp] += |
172 encoded_frame_sizes_[timestamp] += | 164 length - (header.headerLength + header.paddingLength); |
173 length - (header.headerLength + header.paddingLength); | |
174 } | |
175 } | 165 } |
176 return result; | 166 |
| 167 return transport_->SendRtp(packet, length, options); |
177 } | 168 } |
178 | 169 |
179 bool SendRtcp(const uint8_t* packet, size_t length) override { | 170 bool SendRtcp(const uint8_t* packet, size_t length) override { |
180 return transport_->SendRtcp(packet, length); | 171 return transport_->SendRtcp(packet, length); |
181 } | 172 } |
182 | 173 |
183 void EncodedFrameCallback(const EncodedFrame& frame) override { | 174 void EncodedFrameCallback(const EncodedFrame& frame) override { |
184 rtc::CritScope lock(&comparison_lock_); | 175 rtc::CritScope lock(&comparison_lock_); |
185 if (frames_recorded_ < frames_to_process_) | 176 if (frames_recorded_ < frames_to_process_) |
186 encoded_frame_size_.AddSample(frame.length_); | 177 encoded_frame_size_.AddSample(frame.length_); |
187 } | 178 } |
188 | 179 |
189 void RenderFrame(const VideoFrame& video_frame, | 180 void RenderFrame(const VideoFrame& video_frame, |
190 int time_to_render_ms) override { | 181 int time_to_render_ms) override { |
191 int64_t render_time_ms = | 182 int64_t render_time_ms = |
192 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 183 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
193 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; | 184 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; |
194 | 185 |
195 rtc::CritScope lock(&crit_); | 186 rtc::CritScope lock(&crit_); |
196 | 187 |
197 while (frames_.front().timestamp() < send_timestamp) { | 188 while (frames_.front().timestamp() < send_timestamp) { |
198 AddFrameComparison(frames_.front(), last_rendered_frame_, true, | 189 AddFrameComparison(frames_.front(), last_rendered_frame_, true, |
199 render_time_ms); | 190 render_time_ms); |
200 frames_.pop_front(); | 191 frames_.pop_front(); |
201 } | 192 } |
202 | 193 |
203 VideoFrame reference_frame = frames_.front(); | 194 VideoFrame reference_frame = frames_.front(); |
204 frames_.pop_front(); | 195 frames_.pop_front(); |
205 assert(!reference_frame.IsZeroSize()); | 196 assert(!reference_frame.IsZeroSize()); |
206 if (send_timestamp == reference_frame.timestamp() - 1) { | |
207 // TODO(ivica): Make this work for > 2 streams. | |
208 // Look at rtp_sender.c:RTPSender::BuildRTPHeader. | |
209 ++send_timestamp; | |
210 } | |
211 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); | 197 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); |
212 assert(reference_frame.timestamp() == send_timestamp); | 198 assert(reference_frame.timestamp() == send_timestamp); |
213 | 199 |
214 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); | 200 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); |
215 | 201 |
216 last_rendered_frame_ = video_frame; | 202 last_rendered_frame_ = video_frame; |
217 } | 203 } |
218 | 204 |
219 bool IsTextureSupported() const override { return false; } | 205 bool IsTextureSupported() const override { return false; } |
220 | 206 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 printf("- Farewell, sweet Concorde!\n"); | 240 printf("- Farewell, sweet Concorde!\n"); |
255 | 241 |
256 // Signal stats polling thread if that is still waiting and stop it now, | 242 // Signal stats polling thread if that is still waiting and stop it now, |
257 // since it uses the send_stream_ reference that might be reclaimed after | 243 // since it uses the send_stream_ reference that might be reclaimed after |
258 // returning from this method. | 244 // returning from this method. |
259 done_->Set(); | 245 done_->Set(); |
260 EXPECT_TRUE(stats_polling_thread_->Stop()); | 246 EXPECT_TRUE(stats_polling_thread_->Stop()); |
261 } | 247 } |
262 | 248 |
263 VideoCaptureInput* input_; | 249 VideoCaptureInput* input_; |
264 test::LayerFilteringTransport* transport_; | 250 Transport* transport_; |
265 PacketReceiver* receiver_; | 251 PacketReceiver* receiver_; |
266 VideoSendStream* send_stream_; | 252 VideoSendStream* send_stream_; |
267 | 253 |
268 private: | 254 private: |
269 struct FrameComparison { | 255 struct FrameComparison { |
270 FrameComparison() | 256 FrameComparison() |
271 : dropped(false), | 257 : dropped(false), |
272 send_time_ms(0), | 258 send_time_ms(0), |
273 recv_time_ms(0), | 259 recv_time_ms(0), |
274 render_time_ms(0), | 260 render_time_ms(0), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void AddFrameComparison(const VideoFrame& reference, | 315 void AddFrameComparison(const VideoFrame& reference, |
330 const VideoFrame& render, | 316 const VideoFrame& render, |
331 bool dropped, | 317 bool dropped, |
332 int64_t render_time_ms) | 318 int64_t render_time_ms) |
333 EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 319 EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
334 int64_t send_time_ms = send_times_[reference.timestamp()]; | 320 int64_t send_time_ms = send_times_[reference.timestamp()]; |
335 send_times_.erase(reference.timestamp()); | 321 send_times_.erase(reference.timestamp()); |
336 int64_t recv_time_ms = recv_times_[reference.timestamp()]; | 322 int64_t recv_time_ms = recv_times_[reference.timestamp()]; |
337 recv_times_.erase(reference.timestamp()); | 323 recv_times_.erase(reference.timestamp()); |
338 | 324 |
339 // TODO(ivica): Make this work for > 2 streams. | 325 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()]; |
340 auto it = encoded_frame_sizes_.find(reference.timestamp()); | 326 encoded_frame_sizes_.erase(reference.timestamp()); |
341 if (it == encoded_frame_sizes_.end()) | |
342 it = encoded_frame_sizes_.find(reference.timestamp() - 1); | |
343 size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second; | |
344 if (it != encoded_frame_sizes_.end()) | |
345 encoded_frame_sizes_.erase(it); | |
346 | 327 |
347 VideoFrame reference_copy; | 328 VideoFrame reference_copy; |
348 VideoFrame render_copy; | 329 VideoFrame render_copy; |
349 reference_copy.CopyFrame(reference); | 330 reference_copy.CopyFrame(reference); |
350 render_copy.CopyFrame(render); | 331 render_copy.CopyFrame(render); |
351 | 332 |
352 rtc::CritScope crit(&comparison_lock_); | 333 rtc::CritScope crit(&comparison_lock_); |
353 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, | 334 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, |
354 send_time_ms, recv_time_ms, | 335 send_time_ms, recv_time_ms, |
355 render_time_ms, encoded_size)); | 336 render_time_ms, encoded_size)); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 504 } |
524 | 505 |
525 void PrintSamplesToFile(void) { | 506 void PrintSamplesToFile(void) { |
526 FILE* out = graph_data_output_file_; | 507 FILE* out = graph_data_output_file_; |
527 rtc::CritScope crit(&comparison_lock_); | 508 rtc::CritScope crit(&comparison_lock_); |
528 std::sort(samples_.begin(), samples_.end(), | 509 std::sort(samples_.begin(), samples_.end(), |
529 [](const Sample& A, const Sample& B) -> bool { | 510 [](const Sample& A, const Sample& B) -> bool { |
530 return A.input_time_ms < B.input_time_ms; | 511 return A.input_time_ms < B.input_time_ms; |
531 }); | 512 }); |
532 | 513 |
533 fprintf(out, "%s\n", graph_title_.c_str()); | 514 fprintf(out, "%s\n", test_label_.c_str()); |
534 fprintf(out, "%" PRIuS "\n", samples_.size()); | 515 fprintf(out, "%" PRIuS "\n", samples_.size()); |
535 fprintf(out, | 516 fprintf(out, |
536 "dropped " | 517 "dropped " |
537 "input_time_ms " | 518 "input_time_ms " |
538 "send_time_ms " | 519 "send_time_ms " |
539 "recv_time_ms " | 520 "recv_time_ms " |
540 "render_time_ms " | 521 "render_time_ms " |
541 "encoded_frame_size " | 522 "encoded_frame_size " |
542 "psnr " | 523 "psnr " |
543 "ssim " | 524 "ssim " |
(...skipping 17 matching lines...) Expand all Loading... |
561 } | 542 } |
562 if (missing_encode_time_samples) { | 543 if (missing_encode_time_samples) { |
563 fprintf(stderr, | 544 fprintf(stderr, |
564 "Warning: Missing encode_time_ms samples for %d frame(s).\n", | 545 "Warning: Missing encode_time_ms samples for %d frame(s).\n", |
565 missing_encode_time_samples); | 546 missing_encode_time_samples); |
566 } | 547 } |
567 } | 548 } |
568 | 549 |
569 const std::string test_label_; | 550 const std::string test_label_; |
570 FILE* const graph_data_output_file_; | 551 FILE* const graph_data_output_file_; |
571 const std::string graph_title_; | |
572 const uint32_t ssrc_to_analyze_; | |
573 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); | 552 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); |
574 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); | 553 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); |
575 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); | 554 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); |
576 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); | 555 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); |
577 test::Statistics psnr_ GUARDED_BY(comparison_lock_); | 556 test::Statistics psnr_ GUARDED_BY(comparison_lock_); |
578 test::Statistics ssim_ GUARDED_BY(comparison_lock_); | 557 test::Statistics ssim_ GUARDED_BY(comparison_lock_); |
579 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); | 558 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); |
580 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); | 559 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); |
581 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); | 560 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); |
582 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); | 561 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); |
(...skipping 19 matching lines...) Expand all Loading... |
602 const double avg_ssim_threshold_; | 581 const double avg_ssim_threshold_; |
603 | 582 |
604 rtc::CriticalSection comparison_lock_; | 583 rtc::CriticalSection comparison_lock_; |
605 std::vector<ThreadWrapper*> comparison_thread_pool_; | 584 std::vector<ThreadWrapper*> comparison_thread_pool_; |
606 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; | 585 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; |
607 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; | 586 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; |
608 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 587 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); |
609 const rtc::scoped_ptr<EventWrapper> done_; | 588 const rtc::scoped_ptr<EventWrapper> done_; |
610 }; | 589 }; |
611 | 590 |
| 591 VideoQualityTest::VideoQualityTest() : clock_(Clock::GetRealTimeClock()) {} |
612 | 592 |
613 VideoQualityTest::VideoQualityTest() : clock_(Clock::GetRealTimeClock()) {} | 593 void VideoQualityTest::ValidateParams(const Params& params) { |
| 594 RTC_CHECK_GE(params.common.max_bitrate_bps, params.common.target_bitrate_bps); |
| 595 RTC_CHECK_GE(params.common.target_bitrate_bps, params.common.min_bitrate_bps); |
| 596 RTC_CHECK_LT(params.common.tl_discard_threshold, |
| 597 params.common.num_temporal_layers); |
| 598 } |
614 | 599 |
615 void VideoQualityTest::TestBody() {} | 600 void VideoQualityTest::TestBody() {} |
616 | 601 |
617 std::string VideoQualityTest::GenerateGraphTitle() const { | 602 void VideoQualityTest::SetupFullStack(const Params& params, |
618 std::stringstream ss; | 603 Transport* send_transport, |
619 ss << params_.common.codec; | 604 Transport* recv_transport) { |
620 ss << " (" << params_.common.target_bitrate_bps / 1000 << "kbps"; | 605 if (params.logs) |
621 ss << ", " << params_.common.fps << " FPS"; | |
622 if (params_.screenshare.scroll_duration) | |
623 ss << ", " << params_.screenshare.scroll_duration << "s scroll"; | |
624 if (params_.ss.streams.size() > 1) | |
625 ss << ", Stream #" << params_.ss.selected_stream; | |
626 if (params_.ss.num_spatial_layers > 1) | |
627 ss << ", Layer #" << params_.ss.selected_sl; | |
628 ss << ")"; | |
629 return ss.str(); | |
630 } | |
631 | |
632 void VideoQualityTest::CheckParams() { | |
633 // Add a default stream in none specified. | |
634 if (params_.ss.streams.empty()) | |
635 params_.ss.streams.push_back(VideoQualityTest::DefaultVideoStream(params_)); | |
636 if (params_.ss.num_spatial_layers == 0) | |
637 params_.ss.num_spatial_layers = 1; | |
638 | |
639 // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as it | |
640 // does in some parts of the code? | |
641 RTC_CHECK_GE(params_.common.max_bitrate_bps, | |
642 params_.common.target_bitrate_bps); | |
643 RTC_CHECK_GE(params_.common.target_bitrate_bps, | |
644 params_.common.min_bitrate_bps); | |
645 RTC_CHECK_LT(params_.common.selected_tl, | |
646 params_.common.num_temporal_layers); | |
647 RTC_CHECK_LT(params_.ss.selected_stream, params_.ss.streams.size()); | |
648 for (const VideoStream& stream : params_.ss.streams) { | |
649 RTC_CHECK_GE(stream.min_bitrate_bps, 0); | |
650 RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps); | |
651 RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps); | |
652 RTC_CHECK_EQ(static_cast<int>(stream.temporal_layer_thresholds_bps.size()), | |
653 params_.common.num_temporal_layers - 1); | |
654 } | |
655 // TODO(ivica): Should we check if the sum of all streams/layers is equal to | |
656 // the total bitrate? We anyway have to update them in the case bitrate | |
657 // estimator changes the total bitrates. | |
658 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1); | |
659 RTC_CHECK_LT(params_.ss.selected_sl, params_.ss.num_spatial_layers); | |
660 RTC_CHECK(params_.ss.spatial_layers.empty() || | |
661 params_.ss.spatial_layers.size() == | |
662 static_cast<size_t>(params_.ss.num_spatial_layers)); | |
663 if (params_.common.codec == "VP8") { | |
664 RTC_CHECK_EQ(params_.ss.num_spatial_layers, 1); | |
665 } else if (params_.common.codec == "VP9") { | |
666 RTC_CHECK_EQ(params_.ss.streams.size(), 1u); | |
667 } | |
668 } | |
669 | |
670 // Static. | |
671 std::vector<int> VideoQualityTest::ParseCSV(const std::string &str) { | |
672 // Parse comma separated nonnegative integers, where some elements may be | |
673 // empty. The empty values are replaced with -1. | |
674 // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40} | |
675 // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1} | |
676 std::vector<int> result; | |
677 if (str.empty()) return result; | |
678 | |
679 const char* p = str.c_str(); | |
680 int value = -1; | |
681 int pos; | |
682 while (*p) { | |
683 if (*p == ',') { | |
684 result.push_back(value); | |
685 value = -1; | |
686 ++p; | |
687 continue; | |
688 } | |
689 RTC_CHECK_EQ(sscanf(p, "%d%n", &value, &pos), 1) | |
690 << "Unexpected non-number value."; | |
691 p += pos; | |
692 } | |
693 result.push_back(value); | |
694 return result; | |
695 } | |
696 | |
697 // Static. | |
698 VideoStream VideoQualityTest::DefaultVideoStream(const Params& params) { | |
699 VideoStream stream; | |
700 stream.width = params.common.width; | |
701 stream.height = params.common.height; | |
702 stream.max_framerate = params.common.fps; | |
703 stream.min_bitrate_bps = params.common.min_bitrate_bps; | |
704 stream.target_bitrate_bps = params.common.target_bitrate_bps; | |
705 stream.max_bitrate_bps = params.common.max_bitrate_bps; | |
706 stream.max_qp = 52; | |
707 if (params.common.num_temporal_layers == 2) | |
708 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps); | |
709 return stream; | |
710 } | |
711 | |
712 // Static. | |
713 void VideoQualityTest::FillScalabilitySettings( | |
714 Params* params, | |
715 const std::vector<std::string>& stream_descriptors, | |
716 size_t selected_stream, | |
717 int num_spatial_layers, | |
718 int selected_sl, | |
719 const std::vector<std::string>& sl_descriptors) { | |
720 // Read VideoStream and SpatialLayer elements from a list of comma separated | |
721 // lists. To use a default value for an element, use -1 or leave empty. | |
722 // Validity checks performed in CheckParams. | |
723 | |
724 RTC_CHECK(params->ss.streams.empty()); | |
725 for (auto descriptor : stream_descriptors) { | |
726 if (descriptor.empty()) | |
727 continue; | |
728 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); | |
729 VideoStream stream(VideoQualityTest::DefaultVideoStream(*params)); | |
730 if (v[0] != -1) stream.width = static_cast<size_t>(v[0]); | |
731 if (v[1] != -1) stream.height = static_cast<size_t>(v[1]); | |
732 if (v[2] != -1) stream.max_framerate = v[2]; | |
733 if (v[3] != -1) stream.min_bitrate_bps = v[3]; | |
734 if (v[4] != -1) stream.target_bitrate_bps = v[4]; | |
735 if (v[5] != -1) stream.max_bitrate_bps = v[5]; | |
736 if (v.size() > 6 && v[6] != -1) stream.max_qp = v[6]; | |
737 if (v.size() > 7) { | |
738 stream.temporal_layer_thresholds_bps.clear(); | |
739 stream.temporal_layer_thresholds_bps.insert( | |
740 stream.temporal_layer_thresholds_bps.end(), v.begin() + 7, v.end()); | |
741 } else { | |
742 // Automatic TL thresholds for more than two layers not supported. | |
743 RTC_CHECK_LE(params->common.num_temporal_layers, 2); | |
744 } | |
745 params->ss.streams.push_back(stream); | |
746 } | |
747 params->ss.selected_stream = selected_stream; | |
748 | |
749 params->ss.num_spatial_layers = num_spatial_layers ? num_spatial_layers : 1; | |
750 params->ss.selected_sl = selected_sl; | |
751 RTC_CHECK(params->ss.spatial_layers.empty()); | |
752 for (auto descriptor : sl_descriptors) { | |
753 if (descriptor.empty()) | |
754 continue; | |
755 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); | |
756 RTC_CHECK_GT(v[2], 0); | |
757 | |
758 SpatialLayer layer; | |
759 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0]; | |
760 layer.scaling_factor_den = v[1] == -1 ? 1 : v[1]; | |
761 layer.target_bitrate_bps = v[2]; | |
762 params->ss.spatial_layers.push_back(layer); | |
763 } | |
764 } | |
765 | |
766 void VideoQualityTest::SetupCommon(Transport* send_transport, | |
767 Transport* recv_transport) { | |
768 if (params_.logs) | |
769 trace_to_stderr_.reset(new test::TraceToStderr); | 606 trace_to_stderr_.reset(new test::TraceToStderr); |
770 | 607 |
771 size_t num_streams = params_.ss.streams.size(); | 608 CreateSendConfig(1, send_transport); |
772 CreateSendConfig(num_streams, send_transport); | |
773 | 609 |
774 int payload_type; | 610 int payload_type; |
775 if (params_.common.codec == "VP8") { | 611 if (params.common.codec == "VP8") { |
776 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8)); | 612 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8)); |
777 payload_type = kPayloadTypeVP8; | 613 payload_type = kPayloadTypeVP8; |
778 } else if (params_.common.codec == "VP9") { | 614 } else if (params.common.codec == "VP9") { |
779 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9)); | 615 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9)); |
780 payload_type = kPayloadTypeVP9; | 616 payload_type = kPayloadTypeVP9; |
781 } else { | 617 } else { |
782 RTC_NOTREACHED() << "Codec not supported!"; | 618 RTC_NOTREACHED() << "Codec not supported!"; |
783 return; | 619 return; |
784 } | 620 } |
785 send_config_.encoder_settings.encoder = encoder_.get(); | 621 send_config_.encoder_settings.encoder = encoder_.get(); |
786 send_config_.encoder_settings.payload_name = params_.common.codec; | 622 send_config_.encoder_settings.payload_name = params.common.codec; |
787 send_config_.encoder_settings.payload_type = payload_type; | 623 send_config_.encoder_settings.payload_type = payload_type; |
| 624 |
788 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 625 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 626 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]); |
789 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; | 627 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; |
790 for (size_t i = 0; i < num_streams; ++i) | |
791 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); | |
792 | 628 |
793 send_config_.rtp.extensions.clear(); | 629 send_config_.rtp.extensions.clear(); |
794 if (params_.common.send_side_bwe) { | 630 if (params.common.send_side_bwe) { |
795 send_config_.rtp.extensions.push_back(RtpExtension( | 631 send_config_.rtp.extensions.push_back(RtpExtension( |
796 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId)); | 632 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId)); |
797 } else { | 633 } else { |
798 send_config_.rtp.extensions.push_back( | 634 send_config_.rtp.extensions.push_back( |
799 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); | 635 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); |
800 } | 636 } |
801 | 637 |
802 encoder_config_.min_transmit_bitrate_bps = params_.common.min_transmit_bps; | 638 // Automatically fill out streams[0] with params. |
803 encoder_config_.streams = params_.ss.streams; | 639 VideoStream* stream = &encoder_config_.streams[0]; |
804 encoder_config_.spatial_layers = params_.ss.spatial_layers; | 640 stream->width = params.common.width; |
| 641 stream->height = params.common.height; |
| 642 stream->min_bitrate_bps = params.common.min_bitrate_bps; |
| 643 stream->target_bitrate_bps = params.common.target_bitrate_bps; |
| 644 stream->max_bitrate_bps = params.common.max_bitrate_bps; |
| 645 stream->max_framerate = static_cast<int>(params.common.fps); |
| 646 |
| 647 stream->temporal_layer_thresholds_bps.clear(); |
| 648 if (params.common.num_temporal_layers > 1) { |
| 649 stream->temporal_layer_thresholds_bps.push_back(stream->target_bitrate_bps); |
| 650 } |
805 | 651 |
806 CreateMatchingReceiveConfigs(recv_transport); | 652 CreateMatchingReceiveConfigs(recv_transport); |
807 | 653 |
808 for (size_t i = 0; i < num_streams; ++i) { | 654 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
809 receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 655 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; |
810 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[i]; | 656 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = |
811 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].payload_type = | 657 kSendRtxPayloadType; |
812 kSendRtxPayloadType; | 658 |
813 } | 659 encoder_config_.min_transmit_bitrate_bps = params.common.min_transmit_bps; |
814 } | 660 } |
815 | 661 |
816 void VideoQualityTest::SetupScreenshare() { | 662 void VideoQualityTest::SetupScreenshare(const Params& params) { |
817 RTC_CHECK(params_.screenshare.enabled); | 663 RTC_CHECK(params.screenshare.enabled); |
818 | 664 |
819 // Fill out codec settings. | 665 // Fill out codec settings. |
820 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 666 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
821 if (params_.common.codec == "VP8") { | 667 if (params.common.codec == "VP8") { |
822 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings(); | 668 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings(); |
823 codec_settings_.VP8.denoisingOn = false; | 669 codec_settings_.VP8.denoisingOn = false; |
824 codec_settings_.VP8.frameDroppingOn = false; | 670 codec_settings_.VP8.frameDroppingOn = false; |
825 codec_settings_.VP8.numberOfTemporalLayers = | 671 codec_settings_.VP8.numberOfTemporalLayers = |
826 static_cast<unsigned char>(params_.common.num_temporal_layers); | 672 static_cast<unsigned char>(params.common.num_temporal_layers); |
827 encoder_config_.encoder_specific_settings = &codec_settings_.VP8; | 673 encoder_config_.encoder_specific_settings = &codec_settings_.VP8; |
828 } else if (params_.common.codec == "VP9") { | 674 } else if (params.common.codec == "VP9") { |
829 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings(); | 675 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings(); |
830 codec_settings_.VP9.denoisingOn = false; | 676 codec_settings_.VP9.denoisingOn = false; |
831 codec_settings_.VP9.frameDroppingOn = false; | 677 codec_settings_.VP9.frameDroppingOn = false; |
832 codec_settings_.VP9.numberOfTemporalLayers = | 678 codec_settings_.VP9.numberOfTemporalLayers = |
833 static_cast<unsigned char>(params_.common.num_temporal_layers); | 679 static_cast<unsigned char>(params.common.num_temporal_layers); |
834 encoder_config_.encoder_specific_settings = &codec_settings_.VP9; | 680 encoder_config_.encoder_specific_settings = &codec_settings_.VP9; |
835 codec_settings_.VP9.numberOfSpatialLayers = | |
836 static_cast<unsigned char>(params_.ss.num_spatial_layers); | |
837 } | 681 } |
838 | 682 |
839 // Setup frame generator. | 683 // Setup frame generator. |
840 const size_t kWidth = 1850; | 684 const size_t kWidth = 1850; |
841 const size_t kHeight = 1110; | 685 const size_t kHeight = 1110; |
842 std::vector<std::string> slides; | 686 std::vector<std::string> slides; |
843 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); | 687 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
844 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); | 688 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
845 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); | 689 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
846 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); | 690 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
847 | 691 |
848 if (params_.screenshare.scroll_duration == 0) { | 692 if (params.screenshare.scroll_duration == 0) { |
849 // Cycle image every slide_change_interval seconds. | 693 // Cycle image every slide_change_interval seconds. |
850 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( | 694 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( |
851 slides, kWidth, kHeight, | 695 slides, kWidth, kHeight, |
852 params_.screenshare.slide_change_interval * params_.common.fps)); | 696 params.screenshare.slide_change_interval * params.common.fps)); |
853 } else { | 697 } else { |
854 RTC_CHECK_LE(params_.common.width, kWidth); | 698 RTC_CHECK_LE(params.common.width, kWidth); |
855 RTC_CHECK_LE(params_.common.height, kHeight); | 699 RTC_CHECK_LE(params.common.height, kHeight); |
856 RTC_CHECK_GT(params_.screenshare.slide_change_interval, 0); | 700 RTC_CHECK_GT(params.screenshare.slide_change_interval, 0); |
857 const int kPauseDurationMs = (params_.screenshare.slide_change_interval - | 701 const int kPauseDurationMs = (params.screenshare.slide_change_interval - |
858 params_.screenshare.scroll_duration) * 1000; | 702 params.screenshare.scroll_duration) * 1000; |
859 RTC_CHECK_LE(params_.screenshare.scroll_duration, | 703 RTC_CHECK_LE(params.screenshare.scroll_duration, |
860 params_.screenshare.slide_change_interval); | 704 params.screenshare.slide_change_interval); |
861 | 705 |
862 frame_generator_.reset( | 706 if (params.screenshare.scroll_duration) { |
863 test::FrameGenerator::CreateScrollingInputFromYuvFiles( | 707 frame_generator_.reset( |
864 clock_, slides, kWidth, kHeight, params_.common.width, | 708 test::FrameGenerator::CreateScrollingInputFromYuvFiles( |
865 params_.common.height, params_.screenshare.scroll_duration * 1000, | 709 clock_, slides, kWidth, kHeight, params.common.width, |
866 kPauseDurationMs)); | 710 params.common.height, params.screenshare.scroll_duration * 1000, |
| 711 kPauseDurationMs)); |
| 712 } else { |
| 713 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( |
| 714 slides, kWidth, kHeight, |
| 715 params.screenshare.slide_change_interval * params.common.fps)); |
| 716 } |
867 } | 717 } |
868 } | 718 } |
869 | 719 |
870 void VideoQualityTest::CreateCapturer(VideoCaptureInput* input) { | 720 void VideoQualityTest::CreateCapturer(const Params& params, |
871 if (params_.screenshare.enabled) { | 721 VideoCaptureInput* input) { |
| 722 if (params.screenshare.enabled) { |
872 test::FrameGeneratorCapturer *frame_generator_capturer = | 723 test::FrameGeneratorCapturer *frame_generator_capturer = |
873 new test::FrameGeneratorCapturer( | 724 new test::FrameGeneratorCapturer( |
874 clock_, input, frame_generator_.release(), params_.common.fps); | 725 clock_, input, frame_generator_.release(), params.common.fps); |
875 EXPECT_TRUE(frame_generator_capturer->Init()); | 726 EXPECT_TRUE(frame_generator_capturer->Init()); |
876 capturer_.reset(frame_generator_capturer); | 727 capturer_.reset(frame_generator_capturer); |
877 } else { | 728 } else { |
878 if (params_.video.clip_name.empty()) { | 729 if (params.video.clip_name.empty()) { |
879 capturer_.reset(test::VideoCapturer::Create( | 730 capturer_.reset(test::VideoCapturer::Create( |
880 input, params_.common.width, params_.common.height, | 731 input, params.common.width, params.common.height, params.common.fps, |
881 params_.common.fps, clock_)); | 732 clock_)); |
882 } else { | 733 } else { |
883 capturer_.reset(test::FrameGeneratorCapturer::CreateFromYuvFile( | 734 capturer_.reset(test::FrameGeneratorCapturer::CreateFromYuvFile( |
884 input, test::ResourcePath(params_.video.clip_name, "yuv"), | 735 input, test::ResourcePath(params.video.clip_name, "yuv"), |
885 params_.common.width, params_.common.height, params_.common.fps, | 736 params.common.width, params.common.height, params.common.fps, |
886 clock_)); | 737 clock_)); |
887 ASSERT_TRUE(capturer_.get() != nullptr) | 738 ASSERT_TRUE(capturer_.get() != nullptr) |
888 << "Could not create capturer for " << params_.video.clip_name | 739 << "Could not create capturer for " << params.video.clip_name |
889 << ".yuv. Is this resource file present?"; | 740 << ".yuv. Is this resource file present?"; |
890 } | 741 } |
891 } | 742 } |
892 } | 743 } |
893 | 744 |
894 void VideoQualityTest::RunWithAnalyzer(const Params& _params) { | 745 void VideoQualityTest::RunWithAnalyzer(const Params& params) { |
895 params_ = _params; | |
896 | |
897 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to | 746 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to |
898 // differentiate between the analyzer and the renderer case. | 747 // differentiate between the analyzer and the renderer case. |
899 CheckParams(); | 748 ValidateParams(params); |
900 | 749 |
901 FILE* graph_data_output_file = nullptr; | 750 FILE* graph_data_output_file = nullptr; |
902 if (!params_.analyzer.graph_data_output_filename.empty()) { | 751 if (!params.analyzer.graph_data_output_filename.empty()) { |
903 graph_data_output_file = | 752 graph_data_output_file = |
904 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); | 753 fopen(params.analyzer.graph_data_output_filename.c_str(), "w"); |
905 RTC_CHECK(graph_data_output_file != nullptr) | 754 RTC_CHECK(graph_data_output_file != nullptr) |
906 << "Can't open the file " | 755 << "Can't open the file " |
907 << params_.analyzer.graph_data_output_filename << "!"; | 756 << params.analyzer.graph_data_output_filename << "!"; |
908 } | |
909 test::LayerFilteringTransport send_transport( | |
910 params_.pipe, kPayloadTypeVP8, kPayloadTypeVP9, | |
911 params_.common.selected_tl, params_.ss.selected_sl); | |
912 test::DirectTransport recv_transport(params_.pipe); | |
913 | |
914 std::string graph_title = params_.analyzer.graph_title; | |
915 if (graph_title.empty()) | |
916 graph_title = VideoQualityTest::GenerateGraphTitle(); | |
917 | |
918 // In the case of different resolutions, the functions calculating PSNR and | |
919 // SSIM return -1.0, instead of a positive value as usual. VideoAnalyzer | |
920 // aborts if the average psnr/ssim are below the given threshold, which is | |
921 // 0.0 by default. Setting the thresholds to -1.1 prevents the unnecessary | |
922 // abort. | |
923 VideoStream& selected_stream = | |
924 params_.ss.streams[params_.ss.selected_stream]; | |
925 int selected_sl = params_.ss.selected_sl != -1 | |
926 ? params_.ss.selected_sl : params_.ss.num_spatial_layers - 1; | |
927 bool disable_quality_check = | |
928 selected_stream.width != params_.common.width || | |
929 selected_stream.height != params_.common.height || | |
930 (!params_.ss.spatial_layers.empty() && | |
931 params_.ss.spatial_layers[selected_sl].scaling_factor_num != | |
932 params_.ss.spatial_layers[selected_sl].scaling_factor_den); | |
933 if (disable_quality_check) { | |
934 fprintf(stderr, | |
935 "Warning: Calculating PSNR and SSIM for downsized resolution " | |
936 "not implemented yet! Skipping PSNR and SSIM calculations!"); | |
937 } | 757 } |
938 | 758 |
| 759 test::LayerFilteringTransport send_transport( |
| 760 params.pipe, kPayloadTypeVP8, kPayloadTypeVP9, |
| 761 static_cast<uint8_t>(params.common.tl_discard_threshold), 0); |
| 762 test::DirectTransport recv_transport(params.pipe); |
939 VideoAnalyzer analyzer( | 763 VideoAnalyzer analyzer( |
940 &send_transport, params_.analyzer.test_label, | 764 &send_transport, params.analyzer.test_label, |
941 disable_quality_check ? -1.1 : params_.analyzer.avg_psnr_threshold, | 765 params.analyzer.avg_psnr_threshold, params.analyzer.avg_ssim_threshold, |
942 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, | 766 params.analyzer.test_durations_secs * params.common.fps, |
943 params_.analyzer.test_durations_secs * params_.common.fps, | 767 graph_data_output_file); |
944 graph_data_output_file, graph_title, | |
945 kSendSsrcs[params_.ss.selected_stream]); | |
946 | 768 |
947 Call::Config call_config; | 769 Call::Config call_config; |
948 call_config.bitrate_config = params_.common.call_bitrate_config; | 770 call_config.bitrate_config = params.common.call_bitrate_config; |
949 CreateCalls(call_config, call_config); | 771 CreateCalls(call_config, call_config); |
950 | 772 |
951 analyzer.SetReceiver(receiver_call_->Receiver()); | 773 analyzer.SetReceiver(receiver_call_->Receiver()); |
952 send_transport.SetReceiver(&analyzer); | 774 send_transport.SetReceiver(&analyzer); |
953 recv_transport.SetReceiver(sender_call_->Receiver()); | 775 recv_transport.SetReceiver(sender_call_->Receiver()); |
954 | 776 |
955 SetupCommon(&analyzer, &recv_transport); | 777 SetupFullStack(params, &analyzer, &recv_transport); |
956 send_config_.encoding_time_observer = &analyzer; | 778 send_config_.encoding_time_observer = &analyzer; |
957 receive_configs_[params_.ss.selected_stream].renderer = &analyzer; | 779 receive_configs_[0].renderer = &analyzer; |
958 for (auto& config : receive_configs_) | 780 for (auto& config : receive_configs_) |
959 config.pre_decode_callback = &analyzer; | 781 config.pre_decode_callback = &analyzer; |
960 | 782 |
961 if (params_.screenshare.enabled) | 783 if (params.screenshare.enabled) |
962 SetupScreenshare(); | 784 SetupScreenshare(params); |
963 | 785 |
964 CreateStreams(); | 786 CreateStreams(); |
965 analyzer.input_ = send_stream_->Input(); | 787 analyzer.input_ = send_stream_->Input(); |
966 analyzer.send_stream_ = send_stream_; | 788 analyzer.send_stream_ = send_stream_; |
967 | 789 |
968 CreateCapturer(&analyzer); | 790 CreateCapturer(params, &analyzer); |
969 | 791 |
970 send_stream_->Start(); | 792 send_stream_->Start(); |
971 for (size_t i = 0; i < receive_streams_.size(); ++i) | 793 for (size_t i = 0; i < receive_streams_.size(); ++i) |
972 receive_streams_[i]->Start(); | 794 receive_streams_[i]->Start(); |
973 capturer_->Start(); | 795 capturer_->Start(); |
974 | 796 |
975 analyzer.Wait(); | 797 analyzer.Wait(); |
976 | 798 |
977 send_transport.StopSending(); | 799 send_transport.StopSending(); |
978 recv_transport.StopSending(); | 800 recv_transport.StopSending(); |
979 | 801 |
980 capturer_->Stop(); | 802 capturer_->Stop(); |
981 for (size_t i = 0; i < receive_streams_.size(); ++i) | 803 for (size_t i = 0; i < receive_streams_.size(); ++i) |
982 receive_streams_[i]->Stop(); | 804 receive_streams_[i]->Stop(); |
983 send_stream_->Stop(); | 805 send_stream_->Stop(); |
984 | 806 |
985 DestroyStreams(); | 807 DestroyStreams(); |
986 | 808 |
987 if (graph_data_output_file) | 809 if (graph_data_output_file) |
988 fclose(graph_data_output_file); | 810 fclose(graph_data_output_file); |
989 } | 811 } |
990 | 812 |
991 void VideoQualityTest::RunWithVideoRenderer(const Params& _params) { | 813 void VideoQualityTest::RunWithVideoRenderer(const Params& params) { |
992 params_ = _params; | 814 ValidateParams(params); |
993 CheckParams(); | |
994 | 815 |
995 rtc::scoped_ptr<test::VideoRenderer> local_preview( | 816 rtc::scoped_ptr<test::VideoRenderer> local_preview( |
996 test::VideoRenderer::Create("Local Preview", params_.common.width, | 817 test::VideoRenderer::Create("Local Preview", params.common.width, |
997 params_.common.height)); | 818 params.common.height)); |
998 size_t stream_id = params_.ss.selected_stream; | |
999 char title[32]; | |
1000 if (params_.ss.streams.size() == 1) { | |
1001 sprintf(title, "Loopback Video"); | |
1002 } else { | |
1003 sprintf(title, "Loopback Video - Stream #%" PRIuS, stream_id); | |
1004 } | |
1005 rtc::scoped_ptr<test::VideoRenderer> loopback_video( | 819 rtc::scoped_ptr<test::VideoRenderer> loopback_video( |
1006 test::VideoRenderer::Create( | 820 test::VideoRenderer::Create("Loopback Video", params.common.width, |
1007 title, params_.ss.streams[stream_id].width, | 821 params.common.height)); |
1008 params_.ss.streams[stream_id].height)); | |
1009 | 822 |
1010 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to | 823 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to |
1011 // match the full stack tests. | 824 // match the full stack tests. |
1012 Call::Config call_config; | 825 Call::Config call_config; |
1013 call_config.bitrate_config = params_.common.call_bitrate_config; | 826 call_config.bitrate_config = params.common.call_bitrate_config; |
1014 rtc::scoped_ptr<Call> call(Call::Create(call_config)); | 827 rtc::scoped_ptr<Call> call(Call::Create(call_config)); |
1015 | 828 |
1016 test::LayerFilteringTransport transport( | 829 test::LayerFilteringTransport transport( |
1017 params_.pipe, kPayloadTypeVP8, kPayloadTypeVP9, | 830 params.pipe, kPayloadTypeVP8, kPayloadTypeVP9, |
1018 params_.common.selected_tl, params_.ss.selected_sl); | 831 static_cast<uint8_t>(params.common.tl_discard_threshold), 0); |
1019 | |
1020 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at | 832 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at |
1021 // least share as much code as possible. That way this test would also match | 833 // least share as much code as possible. That way this test would also match |
1022 // the full stack tests better. | 834 // the full stack tests better. |
1023 transport.SetReceiver(call->Receiver()); | 835 transport.SetReceiver(call->Receiver()); |
1024 | 836 |
1025 SetupCommon(&transport, &transport); | 837 SetupFullStack(params, &transport, &transport); |
| 838 send_config_.local_renderer = local_preview.get(); |
| 839 receive_configs_[0].renderer = loopback_video.get(); |
1026 | 840 |
1027 send_config_.local_renderer = local_preview.get(); | 841 if (params.screenshare.enabled) |
1028 receive_configs_[stream_id].renderer = loopback_video.get(); | 842 SetupScreenshare(params); |
1029 | |
1030 if (params_.screenshare.enabled) | |
1031 SetupScreenshare(); | |
1032 | 843 |
1033 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_); | 844 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_); |
1034 VideoReceiveStream* receive_stream = | 845 VideoReceiveStream* receive_stream = |
1035 call->CreateVideoReceiveStream(receive_configs_[stream_id]); | 846 call->CreateVideoReceiveStream(receive_configs_[0]); |
1036 CreateCapturer(send_stream_->Input()); | 847 CreateCapturer(params, send_stream_->Input()); |
1037 | 848 |
1038 receive_stream->Start(); | 849 receive_stream->Start(); |
1039 send_stream_->Start(); | 850 send_stream_->Start(); |
1040 capturer_->Start(); | 851 capturer_->Start(); |
1041 | 852 |
1042 test::PressEnterToContinue(); | 853 test::PressEnterToContinue(); |
1043 | 854 |
1044 capturer_->Stop(); | 855 capturer_->Stop(); |
1045 send_stream_->Stop(); | 856 send_stream_->Stop(); |
1046 receive_stream->Stop(); | 857 receive_stream->Stop(); |
1047 | 858 |
1048 call->DestroyVideoReceiveStream(receive_stream); | 859 call->DestroyVideoReceiveStream(receive_stream); |
1049 call->DestroyVideoSendStream(send_stream_); | 860 call->DestroyVideoSendStream(send_stream_); |
1050 | 861 |
1051 transport.StopSending(); | 862 transport.StopSending(); |
1052 } | 863 } |
1053 | 864 |
1054 } // namespace webrtc | 865 } // namespace webrtc |
OLD | NEW |