Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Side by Side Diff: webrtc/video/video_quality_test.cc

Issue 1353263005: Adding support for simulcast and spatial layers into VideoQualityTest (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase master, includes the perf regression fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_quality_test.h ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 EncodingTimeObserver { 47 public EncodingTimeObserver {
47 public: 48 public:
48 VideoAnalyzer(Transport* transport, 49 VideoAnalyzer(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_(nullptr), 57 : input_(nullptr),
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 input_->IncomingCapturedFrame(video_frame); 149 input_->IncomingCapturedFrame(video_frame);
145 } 150 }
146 151
147 bool SendRtp(const uint8_t* packet, 152 bool SendRtp(const uint8_t* packet,
148 size_t length, 153 size_t length,
149 const PacketOptions& options) override { 154 const PacketOptions& options) override {
150 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); 155 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
151 RTPHeader header; 156 RTPHeader header;
152 parser->Parse(packet, length, &header); 157 parser->Parse(packet, length, &header);
153 158
159 int64_t current_time =
160 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
161 bool result = transport_->SendRtp(packet, length, options);
154 { 162 {
155 rtc::CritScope lock(&crit_); 163 rtc::CritScope lock(&crit_);
156 if (rtp_timestamp_delta_ == 0) { 164 if (rtp_timestamp_delta_ == 0) {
157 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp(); 165 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp();
158 first_send_frame_.Reset(); 166 first_send_frame_.Reset();
159 } 167 }
160 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_; 168 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_;
161 send_times_[timestamp] = 169 send_times_[timestamp] = current_time;
162 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); 170 if (!transport_->DiscardedLastPacket() &&
163 encoded_frame_sizes_[timestamp] += 171 header.ssrc == ssrc_to_analyze_) {
164 length - (header.headerLength + header.paddingLength); 172 encoded_frame_sizes_[timestamp] +=
173 length - (header.headerLength + header.paddingLength);
174 }
165 } 175 }
166 176 return result;
167 return transport_->SendRtp(packet, length, options);
168 } 177 }
169 178
170 bool SendRtcp(const uint8_t* packet, size_t length) override { 179 bool SendRtcp(const uint8_t* packet, size_t length) override {
171 return transport_->SendRtcp(packet, length); 180 return transport_->SendRtcp(packet, length);
172 } 181 }
173 182
174 void EncodedFrameCallback(const EncodedFrame& frame) override { 183 void EncodedFrameCallback(const EncodedFrame& frame) override {
175 rtc::CritScope lock(&comparison_lock_); 184 rtc::CritScope lock(&comparison_lock_);
176 if (frames_recorded_ < frames_to_process_) 185 if (frames_recorded_ < frames_to_process_)
177 encoded_frame_size_.AddSample(frame.length_); 186 encoded_frame_size_.AddSample(frame.length_);
178 } 187 }
179 188
180 void RenderFrame(const VideoFrame& video_frame, 189 void RenderFrame(const VideoFrame& video_frame,
181 int time_to_render_ms) override { 190 int time_to_render_ms) override {
182 int64_t render_time_ms = 191 int64_t render_time_ms =
183 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); 192 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
184 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; 193 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_;
185 194
186 rtc::CritScope lock(&crit_); 195 rtc::CritScope lock(&crit_);
187 196
188 while (frames_.front().timestamp() < send_timestamp) { 197 while (frames_.front().timestamp() < send_timestamp) {
189 AddFrameComparison(frames_.front(), last_rendered_frame_, true, 198 AddFrameComparison(frames_.front(), last_rendered_frame_, true,
190 render_time_ms); 199 render_time_ms);
191 frames_.pop_front(); 200 frames_.pop_front();
192 } 201 }
193 202
194 VideoFrame reference_frame = frames_.front(); 203 VideoFrame reference_frame = frames_.front();
195 frames_.pop_front(); 204 frames_.pop_front();
196 assert(!reference_frame.IsZeroSize()); 205 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 }
197 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); 211 EXPECT_EQ(reference_frame.timestamp(), send_timestamp);
198 assert(reference_frame.timestamp() == send_timestamp); 212 assert(reference_frame.timestamp() == send_timestamp);
199 213
200 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); 214 AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
201 215
202 last_rendered_frame_ = video_frame; 216 last_rendered_frame_ = video_frame;
203 } 217 }
204 218
205 bool IsTextureSupported() const override { return false; } 219 bool IsTextureSupported() const override { return false; }
206 220
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 printf("- Farewell, sweet Concorde!\n"); 254 printf("- Farewell, sweet Concorde!\n");
241 255
242 // Signal stats polling thread if that is still waiting and stop it now, 256 // Signal stats polling thread if that is still waiting and stop it now,
243 // since it uses the send_stream_ reference that might be reclaimed after 257 // since it uses the send_stream_ reference that might be reclaimed after
244 // returning from this method. 258 // returning from this method.
245 done_->Set(); 259 done_->Set();
246 EXPECT_TRUE(stats_polling_thread_->Stop()); 260 EXPECT_TRUE(stats_polling_thread_->Stop());
247 } 261 }
248 262
249 VideoCaptureInput* input_; 263 VideoCaptureInput* input_;
250 Transport* transport_; 264 test::LayerFilteringTransport* transport_;
251 PacketReceiver* receiver_; 265 PacketReceiver* receiver_;
252 VideoSendStream* send_stream_; 266 VideoSendStream* send_stream_;
253 267
254 private: 268 private:
255 struct FrameComparison { 269 struct FrameComparison {
256 FrameComparison() 270 FrameComparison()
257 : dropped(false), 271 : dropped(false),
258 send_time_ms(0), 272 send_time_ms(0),
259 recv_time_ms(0), 273 recv_time_ms(0),
260 render_time_ms(0), 274 render_time_ms(0),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void AddFrameComparison(const VideoFrame& reference, 329 void AddFrameComparison(const VideoFrame& reference,
316 const VideoFrame& render, 330 const VideoFrame& render,
317 bool dropped, 331 bool dropped,
318 int64_t render_time_ms) 332 int64_t render_time_ms)
319 EXCLUSIVE_LOCKS_REQUIRED(crit_) { 333 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
320 int64_t send_time_ms = send_times_[reference.timestamp()]; 334 int64_t send_time_ms = send_times_[reference.timestamp()];
321 send_times_.erase(reference.timestamp()); 335 send_times_.erase(reference.timestamp());
322 int64_t recv_time_ms = recv_times_[reference.timestamp()]; 336 int64_t recv_time_ms = recv_times_[reference.timestamp()];
323 recv_times_.erase(reference.timestamp()); 337 recv_times_.erase(reference.timestamp());
324 338
325 size_t encoded_size = encoded_frame_sizes_[reference.timestamp()]; 339 // TODO(ivica): Make this work for > 2 streams.
326 encoded_frame_sizes_.erase(reference.timestamp()); 340 auto it = encoded_frame_sizes_.find(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);
327 346
328 VideoFrame reference_copy; 347 VideoFrame reference_copy;
329 VideoFrame render_copy; 348 VideoFrame render_copy;
330 reference_copy.CopyFrame(reference); 349 reference_copy.CopyFrame(reference);
331 render_copy.CopyFrame(render); 350 render_copy.CopyFrame(render);
332 351
333 rtc::CritScope crit(&comparison_lock_); 352 rtc::CritScope crit(&comparison_lock_);
334 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped, 353 comparisons_.push_back(FrameComparison(reference_copy, render_copy, dropped,
335 send_time_ms, recv_time_ms, 354 send_time_ms, recv_time_ms,
336 render_time_ms, encoded_size)); 355 render_time_ms, encoded_size));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 523 }
505 524
506 void PrintSamplesToFile(void) { 525 void PrintSamplesToFile(void) {
507 FILE* out = graph_data_output_file_; 526 FILE* out = graph_data_output_file_;
508 rtc::CritScope crit(&comparison_lock_); 527 rtc::CritScope crit(&comparison_lock_);
509 std::sort(samples_.begin(), samples_.end(), 528 std::sort(samples_.begin(), samples_.end(),
510 [](const Sample& A, const Sample& B) -> bool { 529 [](const Sample& A, const Sample& B) -> bool {
511 return A.input_time_ms < B.input_time_ms; 530 return A.input_time_ms < B.input_time_ms;
512 }); 531 });
513 532
514 fprintf(out, "%s\n", test_label_.c_str()); 533 fprintf(out, "%s\n", graph_title_.c_str());
515 fprintf(out, "%" PRIuS "\n", samples_.size()); 534 fprintf(out, "%" PRIuS "\n", samples_.size());
516 fprintf(out, 535 fprintf(out,
517 "dropped " 536 "dropped "
518 "input_time_ms " 537 "input_time_ms "
519 "send_time_ms " 538 "send_time_ms "
520 "recv_time_ms " 539 "recv_time_ms "
521 "render_time_ms " 540 "render_time_ms "
522 "encoded_frame_size " 541 "encoded_frame_size "
523 "psnr " 542 "psnr "
524 "ssim " 543 "ssim "
(...skipping 17 matching lines...) Expand all
542 } 561 }
543 if (missing_encode_time_samples) { 562 if (missing_encode_time_samples) {
544 fprintf(stderr, 563 fprintf(stderr,
545 "Warning: Missing encode_time_ms samples for %d frame(s).\n", 564 "Warning: Missing encode_time_ms samples for %d frame(s).\n",
546 missing_encode_time_samples); 565 missing_encode_time_samples);
547 } 566 }
548 } 567 }
549 568
550 const std::string test_label_; 569 const std::string test_label_;
551 FILE* const graph_data_output_file_; 570 FILE* const graph_data_output_file_;
571 const std::string graph_title_;
572 const uint32_t ssrc_to_analyze_;
552 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); 573 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_);
553 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); 574 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_);
554 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); 575 test::Statistics sender_time_ GUARDED_BY(comparison_lock_);
555 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); 576 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_);
556 test::Statistics psnr_ GUARDED_BY(comparison_lock_); 577 test::Statistics psnr_ GUARDED_BY(comparison_lock_);
557 test::Statistics ssim_ GUARDED_BY(comparison_lock_); 578 test::Statistics ssim_ GUARDED_BY(comparison_lock_);
558 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); 579 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_);
559 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); 580 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_);
560 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); 581 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_);
561 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); 582 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_);
(...skipping 19 matching lines...) Expand all
581 const double avg_ssim_threshold_; 602 const double avg_ssim_threshold_;
582 603
583 rtc::CriticalSection comparison_lock_; 604 rtc::CriticalSection comparison_lock_;
584 std::vector<ThreadWrapper*> comparison_thread_pool_; 605 std::vector<ThreadWrapper*> comparison_thread_pool_;
585 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_; 606 rtc::scoped_ptr<ThreadWrapper> stats_polling_thread_;
586 const rtc::scoped_ptr<EventWrapper> comparison_available_event_; 607 const rtc::scoped_ptr<EventWrapper> comparison_available_event_;
587 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); 608 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
588 const rtc::scoped_ptr<EventWrapper> done_; 609 const rtc::scoped_ptr<EventWrapper> done_;
589 }; 610 };
590 611
612
591 VideoQualityTest::VideoQualityTest() : clock_(Clock::GetRealTimeClock()) {} 613 VideoQualityTest::VideoQualityTest() : clock_(Clock::GetRealTimeClock()) {}
592 614
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 }
599
600 void VideoQualityTest::TestBody() {} 615 void VideoQualityTest::TestBody() {}
601 616
602 void VideoQualityTest::SetupFullStack(const Params& params, 617 std::string VideoQualityTest::GenerateGraphTitle() const {
603 Transport* send_transport, 618 std::stringstream ss;
604 Transport* recv_transport) { 619 ss << params_.common.codec;
605 if (params.logs) 620 ss << " (" << params_.common.target_bitrate_bps / 1000 << "kbps";
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)
606 trace_to_stderr_.reset(new test::TraceToStderr); 769 trace_to_stderr_.reset(new test::TraceToStderr);
607 770
608 CreateSendConfig(1, send_transport); 771 size_t num_streams = params_.ss.streams.size();
772 CreateSendConfig(num_streams, send_transport);
609 773
610 int payload_type; 774 int payload_type;
611 if (params.common.codec == "VP8") { 775 if (params_.common.codec == "VP8") {
612 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8)); 776 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8));
613 payload_type = kPayloadTypeVP8; 777 payload_type = kPayloadTypeVP8;
614 } else if (params.common.codec == "VP9") { 778 } else if (params_.common.codec == "VP9") {
615 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9)); 779 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9));
616 payload_type = kPayloadTypeVP9; 780 payload_type = kPayloadTypeVP9;
617 } else { 781 } else {
618 RTC_NOTREACHED() << "Codec not supported!"; 782 RTC_NOTREACHED() << "Codec not supported!";
619 return; 783 return;
620 } 784 }
621 send_config_.encoder_settings.encoder = encoder_.get(); 785 send_config_.encoder_settings.encoder = encoder_.get();
622 send_config_.encoder_settings.payload_name = params.common.codec; 786 send_config_.encoder_settings.payload_name = params_.common.codec;
623 send_config_.encoder_settings.payload_type = payload_type; 787 send_config_.encoder_settings.payload_type = payload_type;
624
625 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 788 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
626 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[0]);
627 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; 789 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]);
628 792
629 send_config_.rtp.extensions.clear(); 793 send_config_.rtp.extensions.clear();
630 if (params.common.send_side_bwe) { 794 if (params_.common.send_side_bwe) {
631 send_config_.rtp.extensions.push_back(RtpExtension( 795 send_config_.rtp.extensions.push_back(RtpExtension(
632 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId)); 796 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId));
633 } else { 797 } else {
634 send_config_.rtp.extensions.push_back( 798 send_config_.rtp.extensions.push_back(
635 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); 799 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId));
636 } 800 }
637 801
638 // Automatically fill out streams[0] with params. 802 encoder_config_.min_transmit_bitrate_bps = params_.common.min_transmit_bps;
639 VideoStream* stream = &encoder_config_.streams[0]; 803 encoder_config_.streams = params_.ss.streams;
640 stream->width = params.common.width; 804 encoder_config_.spatial_layers = params_.ss.spatial_layers;
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 }
651 805
652 CreateMatchingReceiveConfigs(recv_transport); 806 CreateMatchingReceiveConfigs(recv_transport);
653 807
654 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 808 for (size_t i = 0; i < num_streams; ++i) {
655 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; 809 receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
656 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = 810 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[i];
657 kSendRtxPayloadType; 811 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].payload_type =
658 812 kSendRtxPayloadType;
659 encoder_config_.min_transmit_bitrate_bps = params.common.min_transmit_bps; 813 }
660 } 814 }
661 815
662 void VideoQualityTest::SetupScreenshare(const Params& params) { 816 void VideoQualityTest::SetupScreenshare() {
663 RTC_CHECK(params.screenshare.enabled); 817 RTC_CHECK(params_.screenshare.enabled);
664 818
665 // Fill out codec settings. 819 // Fill out codec settings.
666 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; 820 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen;
667 if (params.common.codec == "VP8") { 821 if (params_.common.codec == "VP8") {
668 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings(); 822 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings();
669 codec_settings_.VP8.denoisingOn = false; 823 codec_settings_.VP8.denoisingOn = false;
670 codec_settings_.VP8.frameDroppingOn = false; 824 codec_settings_.VP8.frameDroppingOn = false;
671 codec_settings_.VP8.numberOfTemporalLayers = 825 codec_settings_.VP8.numberOfTemporalLayers =
672 static_cast<unsigned char>(params.common.num_temporal_layers); 826 static_cast<unsigned char>(params_.common.num_temporal_layers);
673 encoder_config_.encoder_specific_settings = &codec_settings_.VP8; 827 encoder_config_.encoder_specific_settings = &codec_settings_.VP8;
674 } else if (params.common.codec == "VP9") { 828 } else if (params_.common.codec == "VP9") {
675 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings(); 829 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings();
676 codec_settings_.VP9.denoisingOn = false; 830 codec_settings_.VP9.denoisingOn = false;
677 codec_settings_.VP9.frameDroppingOn = false; 831 codec_settings_.VP9.frameDroppingOn = false;
678 codec_settings_.VP9.numberOfTemporalLayers = 832 codec_settings_.VP9.numberOfTemporalLayers =
679 static_cast<unsigned char>(params.common.num_temporal_layers); 833 static_cast<unsigned char>(params_.common.num_temporal_layers);
680 encoder_config_.encoder_specific_settings = &codec_settings_.VP9; 834 encoder_config_.encoder_specific_settings = &codec_settings_.VP9;
835 codec_settings_.VP9.numberOfSpatialLayers =
836 static_cast<unsigned char>(params_.ss.num_spatial_layers);
681 } 837 }
682 838
683 // Setup frame generator. 839 // Setup frame generator.
684 const size_t kWidth = 1850; 840 const size_t kWidth = 1850;
685 const size_t kHeight = 1110; 841 const size_t kHeight = 1110;
686 std::vector<std::string> slides; 842 std::vector<std::string> slides;
687 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); 843 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
688 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); 844 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
689 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); 845 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
690 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); 846 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
691 847
692 if (params.screenshare.scroll_duration == 0) { 848 if (params_.screenshare.scroll_duration == 0) {
693 // Cycle image every slide_change_interval seconds. 849 // Cycle image every slide_change_interval seconds.
694 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( 850 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile(
695 slides, kWidth, kHeight, 851 slides, kWidth, kHeight,
696 params.screenshare.slide_change_interval * params.common.fps)); 852 params_.screenshare.slide_change_interval * params_.common.fps));
697 } else { 853 } else {
698 RTC_CHECK_LE(params.common.width, kWidth); 854 RTC_CHECK_LE(params_.common.width, kWidth);
699 RTC_CHECK_LE(params.common.height, kHeight); 855 RTC_CHECK_LE(params_.common.height, kHeight);
700 RTC_CHECK_GT(params.screenshare.slide_change_interval, 0); 856 RTC_CHECK_GT(params_.screenshare.slide_change_interval, 0);
701 const int kPauseDurationMs = (params.screenshare.slide_change_interval - 857 const int kPauseDurationMs = (params_.screenshare.slide_change_interval -
702 params.screenshare.scroll_duration) * 1000; 858 params_.screenshare.scroll_duration) * 1000;
703 RTC_CHECK_LE(params.screenshare.scroll_duration, 859 RTC_CHECK_LE(params_.screenshare.scroll_duration,
704 params.screenshare.slide_change_interval); 860 params_.screenshare.slide_change_interval);
705 861
706 if (params.screenshare.scroll_duration) { 862 frame_generator_.reset(
707 frame_generator_.reset( 863 test::FrameGenerator::CreateScrollingInputFromYuvFiles(
708 test::FrameGenerator::CreateScrollingInputFromYuvFiles( 864 clock_, slides, kWidth, kHeight, params_.common.width,
709 clock_, slides, kWidth, kHeight, params.common.width, 865 params_.common.height, params_.screenshare.scroll_duration * 1000,
710 params.common.height, params.screenshare.scroll_duration * 1000, 866 kPauseDurationMs));
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 }
717 } 867 }
718 } 868 }
719 869
720 void VideoQualityTest::CreateCapturer(const Params& params, 870 void VideoQualityTest::CreateCapturer(VideoCaptureInput* input) {
721 VideoCaptureInput* input) { 871 if (params_.screenshare.enabled) {
722 if (params.screenshare.enabled) {
723 test::FrameGeneratorCapturer *frame_generator_capturer = 872 test::FrameGeneratorCapturer *frame_generator_capturer =
724 new test::FrameGeneratorCapturer( 873 new test::FrameGeneratorCapturer(
725 clock_, input, frame_generator_.release(), params.common.fps); 874 clock_, input, frame_generator_.release(), params_.common.fps);
726 EXPECT_TRUE(frame_generator_capturer->Init()); 875 EXPECT_TRUE(frame_generator_capturer->Init());
727 capturer_.reset(frame_generator_capturer); 876 capturer_.reset(frame_generator_capturer);
728 } else { 877 } else {
729 if (params.video.clip_name.empty()) { 878 if (params_.video.clip_name.empty()) {
730 capturer_.reset(test::VideoCapturer::Create( 879 capturer_.reset(test::VideoCapturer::Create(
731 input, params.common.width, params.common.height, params.common.fps, 880 input, params_.common.width, params_.common.height,
732 clock_)); 881 params_.common.fps, clock_));
733 } else { 882 } else {
734 capturer_.reset(test::FrameGeneratorCapturer::CreateFromYuvFile( 883 capturer_.reset(test::FrameGeneratorCapturer::CreateFromYuvFile(
735 input, test::ResourcePath(params.video.clip_name, "yuv"), 884 input, test::ResourcePath(params_.video.clip_name, "yuv"),
736 params.common.width, params.common.height, params.common.fps, 885 params_.common.width, params_.common.height, params_.common.fps,
737 clock_)); 886 clock_));
738 ASSERT_TRUE(capturer_.get() != nullptr) 887 ASSERT_TRUE(capturer_.get() != nullptr)
739 << "Could not create capturer for " << params.video.clip_name 888 << "Could not create capturer for " << params_.video.clip_name
740 << ".yuv. Is this resource file present?"; 889 << ".yuv. Is this resource file present?";
741 } 890 }
742 } 891 }
743 } 892 }
744 893
745 void VideoQualityTest::RunWithAnalyzer(const Params& params) { 894 void VideoQualityTest::RunWithAnalyzer(const Params& _params) {
895 params_ = _params;
896
746 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to 897 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to
747 // differentiate between the analyzer and the renderer case. 898 // differentiate between the analyzer and the renderer case.
748 ValidateParams(params); 899 CheckParams();
749 900
750 FILE* graph_data_output_file = nullptr; 901 FILE* graph_data_output_file = nullptr;
751 if (!params.analyzer.graph_data_output_filename.empty()) { 902 if (!params_.analyzer.graph_data_output_filename.empty()) {
752 graph_data_output_file = 903 graph_data_output_file =
753 fopen(params.analyzer.graph_data_output_filename.c_str(), "w"); 904 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w");
754 RTC_CHECK(graph_data_output_file != nullptr) 905 RTC_CHECK(graph_data_output_file != nullptr)
755 << "Can't open the file " 906 << "Can't open the file "
756 << params.analyzer.graph_data_output_filename << "!"; 907 << 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!");
757 } 937 }
758 938
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);
763 VideoAnalyzer analyzer( 939 VideoAnalyzer analyzer(
764 &send_transport, params.analyzer.test_label, 940 &send_transport, params_.analyzer.test_label,
765 params.analyzer.avg_psnr_threshold, params.analyzer.avg_ssim_threshold, 941 disable_quality_check ? -1.1 : params_.analyzer.avg_psnr_threshold,
766 params.analyzer.test_durations_secs * params.common.fps, 942 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold,
767 graph_data_output_file); 943 params_.analyzer.test_durations_secs * params_.common.fps,
944 graph_data_output_file, graph_title,
945 kSendSsrcs[params_.ss.selected_stream]);
768 946
769 Call::Config call_config; 947 Call::Config call_config;
770 call_config.bitrate_config = params.common.call_bitrate_config; 948 call_config.bitrate_config = params_.common.call_bitrate_config;
771 CreateCalls(call_config, call_config); 949 CreateCalls(call_config, call_config);
772 950
773 analyzer.SetReceiver(receiver_call_->Receiver()); 951 analyzer.SetReceiver(receiver_call_->Receiver());
774 send_transport.SetReceiver(&analyzer); 952 send_transport.SetReceiver(&analyzer);
775 recv_transport.SetReceiver(sender_call_->Receiver()); 953 recv_transport.SetReceiver(sender_call_->Receiver());
776 954
777 SetupFullStack(params, &analyzer, &recv_transport); 955 SetupCommon(&analyzer, &recv_transport);
778 send_config_.encoding_time_observer = &analyzer; 956 send_config_.encoding_time_observer = &analyzer;
779 receive_configs_[0].renderer = &analyzer; 957 receive_configs_[params_.ss.selected_stream].renderer = &analyzer;
780 for (auto& config : receive_configs_) 958 for (auto& config : receive_configs_)
781 config.pre_decode_callback = &analyzer; 959 config.pre_decode_callback = &analyzer;
782 960
783 if (params.screenshare.enabled) 961 if (params_.screenshare.enabled)
784 SetupScreenshare(params); 962 SetupScreenshare();
785 963
786 CreateStreams(); 964 CreateStreams();
787 analyzer.input_ = send_stream_->Input(); 965 analyzer.input_ = send_stream_->Input();
788 analyzer.send_stream_ = send_stream_; 966 analyzer.send_stream_ = send_stream_;
789 967
790 CreateCapturer(params, &analyzer); 968 CreateCapturer(&analyzer);
791 969
792 send_stream_->Start(); 970 send_stream_->Start();
793 for (size_t i = 0; i < receive_streams_.size(); ++i) 971 for (size_t i = 0; i < receive_streams_.size(); ++i)
794 receive_streams_[i]->Start(); 972 receive_streams_[i]->Start();
795 capturer_->Start(); 973 capturer_->Start();
796 974
797 analyzer.Wait(); 975 analyzer.Wait();
798 976
799 send_transport.StopSending(); 977 send_transport.StopSending();
800 recv_transport.StopSending(); 978 recv_transport.StopSending();
801 979
802 capturer_->Stop(); 980 capturer_->Stop();
803 for (size_t i = 0; i < receive_streams_.size(); ++i) 981 for (size_t i = 0; i < receive_streams_.size(); ++i)
804 receive_streams_[i]->Stop(); 982 receive_streams_[i]->Stop();
805 send_stream_->Stop(); 983 send_stream_->Stop();
806 984
807 DestroyStreams(); 985 DestroyStreams();
808 986
809 if (graph_data_output_file) 987 if (graph_data_output_file)
810 fclose(graph_data_output_file); 988 fclose(graph_data_output_file);
811 } 989 }
812 990
813 void VideoQualityTest::RunWithVideoRenderer(const Params& params) { 991 void VideoQualityTest::RunWithVideoRenderer(const Params& _params) {
814 ValidateParams(params); 992 params_ = _params;
993 CheckParams();
815 994
816 rtc::scoped_ptr<test::VideoRenderer> local_preview( 995 rtc::scoped_ptr<test::VideoRenderer> local_preview(
817 test::VideoRenderer::Create("Local Preview", params.common.width, 996 test::VideoRenderer::Create("Local Preview", params_.common.width,
818 params.common.height)); 997 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 }
819 rtc::scoped_ptr<test::VideoRenderer> loopback_video( 1005 rtc::scoped_ptr<test::VideoRenderer> loopback_video(
820 test::VideoRenderer::Create("Loopback Video", params.common.width, 1006 test::VideoRenderer::Create(
821 params.common.height)); 1007 title, params_.ss.streams[stream_id].width,
1008 params_.ss.streams[stream_id].height));
822 1009
823 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to 1010 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to
824 // match the full stack tests. 1011 // match the full stack tests.
825 Call::Config call_config; 1012 Call::Config call_config;
826 call_config.bitrate_config = params.common.call_bitrate_config; 1013 call_config.bitrate_config = params_.common.call_bitrate_config;
827 rtc::scoped_ptr<Call> call(Call::Create(call_config)); 1014 rtc::scoped_ptr<Call> call(Call::Create(call_config));
828 1015
829 test::LayerFilteringTransport transport( 1016 test::LayerFilteringTransport transport(
830 params.pipe, kPayloadTypeVP8, kPayloadTypeVP9, 1017 params_.pipe, kPayloadTypeVP8, kPayloadTypeVP9,
831 static_cast<uint8_t>(params.common.tl_discard_threshold), 0); 1018 params_.common.selected_tl, params_.ss.selected_sl);
1019
832 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at 1020 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at
833 // least share as much code as possible. That way this test would also match 1021 // least share as much code as possible. That way this test would also match
834 // the full stack tests better. 1022 // the full stack tests better.
835 transport.SetReceiver(call->Receiver()); 1023 transport.SetReceiver(call->Receiver());
836 1024
837 SetupFullStack(params, &transport, &transport); 1025 SetupCommon(&transport, &transport);
1026
838 send_config_.local_renderer = local_preview.get(); 1027 send_config_.local_renderer = local_preview.get();
839 receive_configs_[0].renderer = loopback_video.get(); 1028 receive_configs_[stream_id].renderer = loopback_video.get();
840 1029
841 if (params.screenshare.enabled) 1030 if (params_.screenshare.enabled)
842 SetupScreenshare(params); 1031 SetupScreenshare();
843 1032
844 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_); 1033 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_);
845 VideoReceiveStream* receive_stream = 1034 VideoReceiveStream* receive_stream =
846 call->CreateVideoReceiveStream(receive_configs_[0]); 1035 call->CreateVideoReceiveStream(receive_configs_[stream_id]);
847 CreateCapturer(params, send_stream_->Input()); 1036 CreateCapturer(send_stream_->Input());
848 1037
849 receive_stream->Start(); 1038 receive_stream->Start();
850 send_stream_->Start(); 1039 send_stream_->Start();
851 capturer_->Start(); 1040 capturer_->Start();
852 1041
853 test::PressEnterToContinue(); 1042 test::PressEnterToContinue();
854 1043
855 capturer_->Stop(); 1044 capturer_->Stop();
856 send_stream_->Stop(); 1045 send_stream_->Stop();
857 receive_stream->Stop(); 1046 receive_stream->Stop();
858 1047
859 call->DestroyVideoReceiveStream(receive_stream); 1048 call->DestroyVideoReceiveStream(receive_stream);
860 call->DestroyVideoSendStream(send_stream_); 1049 call->DestroyVideoSendStream(send_stream_);
861 1050
862 transport.StopSending(); 1051 transport.StopSending();
863 } 1052 }
864 1053
865 } // namespace webrtc 1054 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_quality_test.h ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698