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

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

Powered by Google App Engine
This is Rietveld 408576698