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 newapi::Transport, | 43 public newapi::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): Will 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): Will this work for > 2 streams? |
sprang_webrtc
2015/09/29 14:19:33
No, right? :)
Just change it to something like
//
ivica
2015/09/29 15:14:51
Done.
| |
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 newapi::Transport* send_transport, | 593 std::stringstream ss; |
578 newapi::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 part 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; | |
654 while (*p) { | |
655 if (*p == ',') { | |
656 result.push_back(value); | |
657 value = -1; | |
658 ++p; | |
659 continue; | |
660 } | |
661 sscanf(p, "%d%n", &value, &pos); | |
sprang_webrtc
2015/09/29 14:19:33
Do you need to detect error from string->int parsi
ivica
2015/09/29 15:14:51
Added a RTC_CHECK_EQ to 1.
| |
662 p += pos; | |
663 } | |
664 result.push_back(value); | |
665 return result; | |
666 } | |
667 | |
668 // Static. | |
669 VideoStream VideoQualityTest::DefaultVideoStream(const Params& params) { | |
670 VideoStream stream; | |
671 stream.width = params.common.width; | |
672 stream.height = params.common.height; | |
673 stream.max_framerate = params.common.fps; | |
674 stream.min_bitrate_bps = params.common.min_bitrate_bps; | |
675 stream.target_bitrate_bps = params.common.target_bitrate_bps; | |
676 stream.max_bitrate_bps = params.common.max_bitrate_bps; | |
677 stream.max_qp = 52; | |
678 if (params.common.num_temporal_layers == 2) | |
679 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps); | |
680 return stream; | |
681 } | |
682 | |
683 // Static. | |
684 void VideoQualityTest::FillScalabilitySettings( | |
685 Params* params, | |
686 const std::vector<std::string>& stream_descriptors, | |
687 size_t selected_stream, | |
688 int num_spatial_layers, | |
689 int selected_sl, | |
690 const std::vector<std::string>& sl_descriptors) { | |
691 // Read VideoStream and SpatialLayer elements from a list of comma separated | |
692 // lists. To use a default value for an element, use -1 or leave empty. | |
693 // Validity checks performed in CheckParams. | |
694 | |
695 RTC_CHECK(params->ss.streams.empty()); | |
696 for (auto descriptor : stream_descriptors) { | |
697 if (descriptor.empty()) | |
698 continue; | |
699 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); | |
700 VideoStream stream(VideoQualityTest::DefaultVideoStream(*params)); | |
701 if (v[0] != -1) stream.width = static_cast<size_t>(v[0]); | |
702 if (v[1] != -1) stream.height = static_cast<size_t>(v[1]); | |
703 if (v[2] != -1) stream.max_framerate = v[2]; | |
704 if (v[3] != -1) stream.min_bitrate_bps = v[3]; | |
705 if (v[4] != -1) stream.target_bitrate_bps = v[4]; | |
706 if (v[5] != -1) stream.max_bitrate_bps = v[5]; | |
707 if (v[6] != -1) stream.max_qp = v[6]; | |
708 if (v.size() > 7) { | |
709 stream.temporal_layer_thresholds_bps.clear(); | |
710 stream.temporal_layer_thresholds_bps.insert( | |
711 stream.temporal_layer_thresholds_bps.end(), v.begin() + 7, v.end()); | |
712 } else { | |
713 // Automatic TL thresholds for more than two layers not supported. | |
714 RTC_CHECK_LE(params->common.num_temporal_layers, 2); | |
715 } | |
716 params->ss.streams.push_back(stream); | |
717 } | |
718 params->ss.selected_stream = selected_stream; | |
719 | |
720 params->ss.num_spatial_layers = num_spatial_layers ? num_spatial_layers : 1; | |
721 params->ss.selected_sl = selected_sl; | |
722 RTC_CHECK(params->ss.spatial_layers.empty()); | |
723 for (auto descriptor : sl_descriptors) { | |
724 if (descriptor.empty()) | |
725 continue; | |
726 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); | |
727 RTC_CHECK_GT(v[2], 0); | |
728 | |
729 SpatialLayer layer; | |
730 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0]; | |
731 layer.scaling_factor_den = v[1] == -1 ? 1 : v[1]; | |
732 layer.target_bitrate_bps = v[2]; | |
733 params->ss.spatial_layers.push_back(layer); | |
734 } | |
735 } | |
736 | |
737 void VideoQualityTest::SetupCommon(newapi::Transport* send_transport, | |
738 newapi::Transport* recv_transport) { | |
739 if (params_.logs) | |
580 trace_to_stderr_.reset(new test::TraceToStderr); | 740 trace_to_stderr_.reset(new test::TraceToStderr); |
581 | 741 |
582 CreateSendConfig(1, send_transport); | 742 size_t num_streams = params_.ss.streams.size(); |
743 CreateSendConfig(num_streams, send_transport); | |
583 | 744 |
584 int payload_type; | 745 int payload_type; |
585 if (params.common.codec == "VP8") { | 746 if (params_.common.codec == "VP8") { |
586 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8)); | 747 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8)); |
587 payload_type = kPayloadTypeVP8; | 748 payload_type = kPayloadTypeVP8; |
588 } else if (params.common.codec == "VP9") { | 749 } else if (params_.common.codec == "VP9") { |
589 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9)); | 750 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp9)); |
590 payload_type = kPayloadTypeVP9; | 751 payload_type = kPayloadTypeVP9; |
591 } else { | 752 } else { |
592 RTC_NOTREACHED() << "Codec not supported!"; | 753 RTC_NOTREACHED() << "Codec not supported!"; |
593 return; | 754 return; |
594 } | 755 } |
595 send_config_.encoder_settings.encoder = encoder_.get(); | 756 send_config_.encoder_settings.encoder = encoder_.get(); |
596 send_config_.encoder_settings.payload_name = params.common.codec; | 757 send_config_.encoder_settings.payload_name = params_.common.codec; |
597 send_config_.encoder_settings.payload_type = payload_type; | 758 send_config_.encoder_settings.payload_type = payload_type; |
598 | |
599 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 759 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; | 760 send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; |
761 for (size_t i = 0; i < num_streams; ++i) | |
762 send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); | |
602 | 763 |
603 send_config_.rtp.extensions.clear(); | 764 send_config_.rtp.extensions.clear(); |
604 if (params.common.send_side_bwe) { | 765 if (params_.common.send_side_bwe) { |
605 send_config_.rtp.extensions.push_back(RtpExtension( | 766 send_config_.rtp.extensions.push_back(RtpExtension( |
606 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId)); | 767 RtpExtension::kTransportSequenceNumber, kTransportSeqExtensionId)); |
607 } else { | 768 } else { |
608 send_config_.rtp.extensions.push_back( | 769 send_config_.rtp.extensions.push_back( |
609 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); | 770 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); |
610 } | 771 } |
611 | 772 |
612 // Automatically fill out streams[0] with params. | 773 encoder_config_.min_transmit_bitrate_bps = params_.common.min_transmit_bps; |
613 VideoStream* stream = &encoder_config_.streams[0]; | 774 encoder_config_.streams = params_.ss.streams; |
614 stream->width = params.common.width; | 775 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 | 776 |
626 CreateMatchingReceiveConfigs(recv_transport); | 777 CreateMatchingReceiveConfigs(recv_transport); |
627 | 778 |
628 receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 779 for (size_t i = 0; i < num_streams; ++i) { |
629 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[0]; | 780 receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
630 receive_configs_[0].rtp.rtx[kSendRtxPayloadType].payload_type = | 781 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].ssrc = kSendRtxSsrcs[i]; |
631 kSendRtxPayloadType; | 782 receive_configs_[i].rtp.rtx[kSendRtxPayloadType].payload_type = |
632 | 783 kSendRtxPayloadType; |
633 encoder_config_.min_transmit_bitrate_bps = params.common.min_transmit_bps; | 784 } |
634 } | 785 } |
635 | 786 |
636 void VideoQualityTest::SetupScreenshare(const Params& params) { | 787 void VideoQualityTest::SetupScreenshare() { |
637 RTC_CHECK(params.screenshare.enabled); | 788 RTC_CHECK(params_.screenshare.enabled); |
638 | 789 |
639 // Fill out codec settings. | 790 // Fill out codec settings. |
640 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 791 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
641 if (params.common.codec == "VP8") { | 792 if (params_.common.codec == "VP8") { |
642 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings(); | 793 codec_settings_.VP8 = VideoEncoder::GetDefaultVp8Settings(); |
643 codec_settings_.VP8.denoisingOn = false; | 794 codec_settings_.VP8.denoisingOn = false; |
644 codec_settings_.VP8.frameDroppingOn = false; | 795 codec_settings_.VP8.frameDroppingOn = false; |
645 codec_settings_.VP8.numberOfTemporalLayers = | 796 codec_settings_.VP8.numberOfTemporalLayers = |
646 static_cast<unsigned char>(params.common.num_temporal_layers); | 797 static_cast<unsigned char>(params_.common.num_temporal_layers); |
647 encoder_config_.encoder_specific_settings = &codec_settings_.VP8; | 798 encoder_config_.encoder_specific_settings = &codec_settings_.VP8; |
648 } else if (params.common.codec == "VP9") { | 799 } else if (params_.common.codec == "VP9") { |
649 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings(); | 800 codec_settings_.VP9 = VideoEncoder::GetDefaultVp9Settings(); |
650 codec_settings_.VP9.denoisingOn = false; | 801 codec_settings_.VP9.denoisingOn = false; |
651 codec_settings_.VP9.frameDroppingOn = false; | 802 codec_settings_.VP9.frameDroppingOn = false; |
652 codec_settings_.VP9.numberOfTemporalLayers = | 803 codec_settings_.VP9.numberOfTemporalLayers = |
653 static_cast<unsigned char>(params.common.num_temporal_layers); | 804 static_cast<unsigned char>(params_.common.num_temporal_layers); |
654 encoder_config_.encoder_specific_settings = &codec_settings_.VP9; | 805 encoder_config_.encoder_specific_settings = &codec_settings_.VP9; |
806 codec_settings_.VP9.numberOfSpatialLayers = | |
807 static_cast<unsigned char>(params_.ss.num_spatial_layers); | |
655 } | 808 } |
656 | 809 |
657 // Setup frame generator. | 810 // Setup frame generator. |
658 const size_t kWidth = 1850; | 811 const size_t kWidth = 1850; |
659 const size_t kHeight = 1110; | 812 const size_t kHeight = 1110; |
660 std::vector<std::string> slides; | 813 std::vector<std::string> slides; |
661 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); | 814 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
662 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); | 815 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
663 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); | 816 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
664 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); | 817 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
665 | 818 |
666 if (params.screenshare.scroll_duration == 0) { | 819 if (params_.screenshare.scroll_duration == 0) { |
667 // Cycle image every slide_change_interval seconds. | 820 // Cycle image every slide_change_interval seconds. |
668 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( | 821 frame_generator_.reset(test::FrameGenerator::CreateFromYuvFile( |
669 slides, kWidth, kHeight, | 822 slides, kWidth, kHeight, |
670 params.screenshare.slide_change_interval * params.common.fps)); | 823 params_.screenshare.slide_change_interval * params_.common.fps)); |
671 } else { | 824 } else { |
672 RTC_CHECK_LE(params.common.width, kWidth); | 825 RTC_CHECK_LE(params_.common.width, kWidth); |
673 RTC_CHECK_LE(params.common.height, kHeight); | 826 RTC_CHECK_LE(params_.common.height, kHeight); |
674 RTC_CHECK_GT(params.screenshare.slide_change_interval, 0); | 827 RTC_CHECK_GT(params_.screenshare.slide_change_interval, 0); |
675 const int kPauseDurationMs = (params.screenshare.slide_change_interval - | 828 const int kPauseDurationMs = (params_.screenshare.slide_change_interval - |
676 params.screenshare.scroll_duration) * 1000; | 829 params_.screenshare.scroll_duration) * 1000; |
677 RTC_CHECK_LE(params.screenshare.scroll_duration, | 830 RTC_CHECK_LE(params_.screenshare.scroll_duration, |
678 params.screenshare.slide_change_interval); | 831 params_.screenshare.slide_change_interval); |
679 | 832 |
680 frame_generator_.reset( | 833 frame_generator_.reset( |
681 test::FrameGenerator::CreateScrollingInputFromYuvFiles( | 834 test::FrameGenerator::CreateScrollingInputFromYuvFiles( |
682 clock_, slides, kWidth, kHeight, params.common.width, | 835 clock_, slides, kWidth, kHeight, params_.common.width, |
683 params.common.height, params.screenshare.scroll_duration * 1000, | 836 params_.common.height, params_.screenshare.scroll_duration * 1000, |
684 kPauseDurationMs)); | 837 kPauseDurationMs)); |
685 } | 838 } |
686 } | 839 } |
687 | 840 |
688 void VideoQualityTest::CreateCapturer(const Params& params, | 841 void VideoQualityTest::CreateCapturer(VideoCaptureInput* input) { |
689 VideoCaptureInput* input) { | 842 if (params_.screenshare.enabled) { |
690 if (params.screenshare.enabled) { | |
691 frame_generator_capturer_.reset(new test::FrameGeneratorCapturer( | 843 frame_generator_capturer_.reset(new test::FrameGeneratorCapturer( |
692 clock_, input, frame_generator_.release(), params.common.fps)); | 844 clock_, input, frame_generator_.release(), params_.common.fps)); |
693 EXPECT_TRUE(frame_generator_capturer_->Init()); | 845 EXPECT_TRUE(frame_generator_capturer_->Init()); |
694 } else { | 846 } else { |
695 if (params.video.clip_name.empty()) { | 847 if (params_.video.clip_name.empty()) { |
696 frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( | 848 frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( |
697 input, params.common.width, params.common.height, params.common.fps, | 849 input, params_.common.width, params_.common.height, |
698 clock_)); | 850 params_.common.fps, clock_)); |
699 EXPECT_TRUE(frame_generator_capturer_->Init()); | 851 EXPECT_TRUE(frame_generator_capturer_->Init()); |
700 } else { | 852 } else { |
701 frame_generator_capturer_.reset( | 853 frame_generator_capturer_.reset( |
702 test::FrameGeneratorCapturer::CreateFromYuvFile( | 854 test::FrameGeneratorCapturer::CreateFromYuvFile( |
703 input, test::ResourcePath(params.video.clip_name, "yuv"), | 855 input, test::ResourcePath(params_.video.clip_name, "yuv"), |
704 params.common.width, params.common.height, params.common.fps, | 856 params_.common.width, params_.common.height, params_.common.fps, |
705 clock_)); | 857 clock_)); |
706 ASSERT_TRUE(frame_generator_capturer_.get() != nullptr) | 858 ASSERT_TRUE(frame_generator_capturer_.get() != nullptr) |
707 << "Could not create capturer for " << params.video.clip_name | 859 << "Could not create capturer for " << params_.video.clip_name |
708 << ".yuv. Is this resource file present?"; | 860 << ".yuv. Is this resource file present?"; |
709 } | 861 } |
710 } | 862 } |
711 } | 863 } |
712 | 864 |
713 void VideoQualityTest::RunWithAnalyzer(const Params& params) { | 865 void VideoQualityTest::RunWithAnalyzer(const Params& _params) { |
866 params_ = _params; | |
867 | |
714 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to | 868 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to |
715 // differentiate between the analyzer and the renderer case. | 869 // differentiate between the analyzer and the renderer case. |
716 ValidateParams(params); | 870 CheckParams(); |
717 | 871 |
718 FILE* graph_data_output_file = nullptr; | 872 FILE* graph_data_output_file = nullptr; |
719 if (!params.analyzer.graph_data_output_filename.empty()) { | 873 if (!params_.analyzer.graph_data_output_filename.empty()) { |
720 graph_data_output_file = | 874 graph_data_output_file = |
721 fopen(params.analyzer.graph_data_output_filename.c_str(), "w"); | 875 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); |
722 RTC_CHECK(graph_data_output_file != nullptr) | 876 RTC_CHECK(graph_data_output_file != nullptr) |
723 << "Can't open the file " | 877 << "Can't open the file " |
724 << params.analyzer.graph_data_output_filename << "!"; | 878 << params_.analyzer.graph_data_output_filename << "!"; |
879 } | |
880 test::LayerFilteringTransport send_transport( | |
881 params_.pipe, kPayloadTypeVP8, kPayloadTypeVP9, | |
882 params_.common.selected_tl, params_.ss.selected_sl); | |
883 test::DirectTransport recv_transport(params_.pipe); | |
884 | |
885 std::string graph_title = params_.analyzer.graph_title; | |
886 if (graph_title == AUTO_GRAPH_TITLE) | |
887 graph_title = VideoQualityTest::GenerateGraphTitle(); | |
888 | |
889 // In the case of different resolutions, the functions calculating PSNR and | |
890 // SSIM return -1.0, instead of a positive value as usual. VideoAnalyzer | |
891 // aborts if the average psnr/ssim are below the given threshold, which is | |
892 // 0.0 by default. Setting the thresholds to -1.1 prevents the unnecessary | |
893 // abort. | |
894 VideoStream& selected_stream = | |
895 params_.ss.streams[params_.ss.selected_stream]; | |
896 int selected_sl = params_.ss.selected_sl != -1 | |
897 ? params_.ss.selected_sl : params_.ss.num_spatial_layers - 1; | |
898 bool disable_quality_check = | |
899 selected_stream.width != params_.common.width || | |
900 selected_stream.height != params_.common.height || | |
901 (!params_.ss.spatial_layers.empty() && | |
902 params_.ss.spatial_layers[selected_sl].scaling_factor_num != | |
903 params_.ss.spatial_layers[selected_sl].scaling_factor_den); | |
904 if (disable_quality_check) { | |
905 fprintf(stderr, | |
906 "Warning: Calculating PSNR and SSIM for downsized resolution " | |
907 "not implemented yet! Skipping PSNR and SSIM calculations!"); | |
725 } | 908 } |
726 | 909 |
727 test::LayerFilteringTransport send_transport( | |
728 params.pipe, kPayloadTypeVP8, kPayloadTypeVP9, | |
729 static_cast<uint8_t>(params.common.tl_discard_threshold), 0); | |
730 test::DirectTransport recv_transport(params.pipe); | |
731 VideoAnalyzer analyzer( | 910 VideoAnalyzer analyzer( |
732 nullptr, &send_transport, params.analyzer.test_label, | 911 nullptr, &send_transport, params_.analyzer.test_label, |
733 params.analyzer.avg_psnr_threshold, params.analyzer.avg_ssim_threshold, | 912 disable_quality_check ? -1.1 : params_.analyzer.avg_psnr_threshold, |
734 params.analyzer.test_durations_secs * params.common.fps, | 913 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, |
735 graph_data_output_file); | 914 params_.analyzer.test_durations_secs * params_.common.fps, |
915 graph_data_output_file, graph_title, | |
916 kSendSsrcs[params_.ss.selected_stream]); | |
736 | 917 |
737 Call::Config call_config; | 918 Call::Config call_config; |
738 call_config.bitrate_config = params.common.call_bitrate_config; | 919 call_config.bitrate_config = params_.common.call_bitrate_config; |
739 CreateCalls(call_config, call_config); | 920 CreateCalls(call_config, call_config); |
740 | 921 |
741 analyzer.SetReceiver(receiver_call_->Receiver()); | 922 analyzer.SetReceiver(receiver_call_->Receiver()); |
742 send_transport.SetReceiver(&analyzer); | 923 send_transport.SetReceiver(&analyzer); |
743 recv_transport.SetReceiver(sender_call_->Receiver()); | 924 recv_transport.SetReceiver(sender_call_->Receiver()); |
744 | 925 |
745 SetupFullStack(params, &analyzer, &recv_transport); | 926 SetupCommon(&analyzer, &recv_transport); |
746 receive_configs_[0].renderer = &analyzer; | 927 receive_configs_[params_.ss.selected_stream].renderer = &analyzer; |
747 for (auto& config : receive_configs_) | 928 for (auto& config : receive_configs_) |
748 config.pre_decode_callback = &analyzer; | 929 config.pre_decode_callback = &analyzer; |
749 | 930 |
750 if (params.screenshare.enabled) | 931 if (params_.screenshare.enabled) |
751 SetupScreenshare(params); | 932 SetupScreenshare(); |
752 | 933 |
753 CreateCapturer(params, &analyzer); | 934 CreateCapturer(&analyzer); |
754 | 935 |
755 CreateStreams(); | 936 CreateStreams(); |
756 analyzer.input_ = send_stream_->Input(); | 937 analyzer.input_ = send_stream_->Input(); |
757 analyzer.send_stream_ = send_stream_; | 938 analyzer.send_stream_ = send_stream_; |
758 | 939 |
759 Start(); | 940 Start(); |
760 | 941 |
761 analyzer.Wait(); | 942 analyzer.Wait(); |
762 | 943 |
763 send_transport.StopSending(); | 944 send_transport.StopSending(); |
764 recv_transport.StopSending(); | 945 recv_transport.StopSending(); |
765 | 946 |
766 Stop(); | 947 Stop(); |
767 | 948 |
768 DestroyStreams(); | 949 DestroyStreams(); |
769 | 950 |
770 if (graph_data_output_file) | 951 if (graph_data_output_file) |
771 fclose(graph_data_output_file); | 952 fclose(graph_data_output_file); |
772 } | 953 } |
773 | 954 |
774 void VideoQualityTest::RunWithVideoRenderer(const Params& params) { | 955 void VideoQualityTest::RunWithVideoRenderer(const Params& _params) { |
775 ValidateParams(params); | 956 params_ = _params; |
957 CheckParams(); | |
776 | 958 |
777 rtc::scoped_ptr<test::VideoRenderer> local_preview( | 959 rtc::scoped_ptr<test::VideoRenderer> local_preview( |
778 test::VideoRenderer::Create("Local Preview", params.common.width, | 960 test::VideoRenderer::Create("Local Preview", params_.common.width, |
779 params.common.height)); | 961 params_.common.height)); |
962 size_t stream_id = params_.ss.selected_stream; | |
963 char title[32]; | |
964 if (params_.ss.streams.size() == 1) | |
965 sprintf(title, "Loopback Video"); | |
966 else | |
967 sprintf(title, "Loopback Video - Stream #%" PRIuS, stream_id); | |
780 rtc::scoped_ptr<test::VideoRenderer> loopback_video( | 968 rtc::scoped_ptr<test::VideoRenderer> loopback_video( |
781 test::VideoRenderer::Create("Loopback Video", params.common.width, | 969 test::VideoRenderer::Create( |
782 params.common.height)); | 970 title, params_.ss.streams[stream_id].width, |
971 params_.ss.streams[stream_id].height)); | |
783 | 972 |
784 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to | 973 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to |
785 // match the full stack tests. | 974 // match the full stack tests. |
786 Call::Config call_config; | 975 Call::Config call_config; |
787 call_config.bitrate_config = params.common.call_bitrate_config; | 976 call_config.bitrate_config = params_.common.call_bitrate_config; |
788 rtc::scoped_ptr<Call> call(Call::Create(call_config)); | 977 rtc::scoped_ptr<Call> call(Call::Create(call_config)); |
789 | 978 |
790 test::LayerFilteringTransport transport( | 979 test::LayerFilteringTransport transport( |
791 params.pipe, kPayloadTypeVP8, kPayloadTypeVP9, | 980 params_.pipe, kPayloadTypeVP8, kPayloadTypeVP9, |
792 static_cast<uint8_t>(params.common.tl_discard_threshold), 0); | 981 params_.common.selected_tl, params_.ss.selected_sl); |
982 | |
793 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at | 983 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at |
794 // least share as much code as possible. That way this test would also match | 984 // least share as much code as possible. That way this test would also match |
795 // the full stack tests better. | 985 // the full stack tests better. |
796 transport.SetReceiver(call->Receiver()); | 986 transport.SetReceiver(call->Receiver()); |
797 | 987 |
798 SetupFullStack(params, &transport, &transport); | 988 SetupCommon(&transport, &transport); |
989 | |
799 send_config_.local_renderer = local_preview.get(); | 990 send_config_.local_renderer = local_preview.get(); |
800 receive_configs_[0].renderer = loopback_video.get(); | 991 receive_configs_[stream_id].renderer = loopback_video.get(); |
801 | 992 |
802 if (params.screenshare.enabled) | 993 if (params_.screenshare.enabled) |
803 SetupScreenshare(params); | 994 SetupScreenshare(); |
804 | 995 |
805 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_); | 996 send_stream_ = call->CreateVideoSendStream(send_config_, encoder_config_); |
806 CreateCapturer(params, send_stream_->Input()); | 997 CreateCapturer(send_stream_->Input()); |
807 | 998 |
808 VideoReceiveStream* receive_stream = | 999 VideoReceiveStream* receive_stream = |
809 call->CreateVideoReceiveStream(receive_configs_[0]); | 1000 call->CreateVideoReceiveStream(receive_configs_[stream_id]); |
810 | 1001 |
811 receive_stream->Start(); | 1002 receive_stream->Start(); |
812 send_stream_->Start(); | 1003 send_stream_->Start(); |
813 frame_generator_capturer_->Start(); | 1004 frame_generator_capturer_->Start(); |
814 | 1005 |
815 test::PressEnterToContinue(); | 1006 test::PressEnterToContinue(); |
816 | 1007 |
817 frame_generator_capturer_->Stop(); | 1008 frame_generator_capturer_->Stop(); |
818 send_stream_->Stop(); | 1009 send_stream_->Stop(); |
819 receive_stream->Stop(); | 1010 receive_stream->Stop(); |
820 | 1011 |
821 call->DestroyVideoReceiveStream(receive_stream); | 1012 call->DestroyVideoReceiveStream(receive_stream); |
822 call->DestroyVideoSendStream(send_stream_); | 1013 call->DestroyVideoSendStream(send_stream_); |
823 | 1014 |
824 transport.StopSending(); | 1015 transport.StopSending(); |
825 } | 1016 } |
826 | 1017 |
827 } // namespace webrtc | 1018 } // namespace webrtc |
OLD | NEW |