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