ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #include "video/video_quality_test.h" |
perkj | 9fdbda6 | 2016-09-15 09:19:20 -0700 | [diff] [blame] | 11 | |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 12 | #include <stdio.h> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 13 | #include <algorithm> |
| 14 | #include <deque> |
| 15 | #include <map> |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 16 | #include <sstream> |
mflodman | d1590b2 | 2015-12-09 07:07:59 -0800 | [diff] [blame] | 17 | #include <string> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 20 | #include "call/fake_network_pipe.h" |
| 21 | #include "call/simulated_network.h" |
Elad Alon | 83ccca1 | 2017-10-04 13:18:26 +0200 | [diff] [blame] | 22 | #include "logging/rtc_event_log/output/rtc_event_log_output_file.h" |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 23 | #include "media/engine/adm_helpers.h" |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 24 | #include "media/engine/internalencoderfactory.h" |
Niels Möller | 19a68d4 | 2018-04-13 13:37:52 +0200 | [diff] [blame] | 25 | #include "media/engine/vp8_encoder_simulcast_proxy.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #include "media/engine/webrtcvideoengine.h" |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 27 | #include "modules/audio_device/include/audio_device.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 28 | #include "modules/audio_mixer/audio_mixer_impl.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 29 | #include "modules/video_coding/codecs/h264/include/h264.h" |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 30 | #include "modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h" |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 31 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 32 | #include "modules/video_coding/codecs/vp9/include/vp9.h" |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 33 | #include "modules/video_coding/utility/ivf_file_writer.h" |
| 34 | #include "rtc_base/strings/string_builder.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 35 | #include "test/run_loop.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 36 | #include "test/testsupport/fileutils.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 37 | #include "test/video_renderer.h" |
Sebastian Jansson | d4c5d63 | 2018-07-10 12:57:37 +0200 | [diff] [blame] | 38 | #include "video/video_analyzer.h" |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 39 | #ifdef WEBRTC_WIN |
| 40 | #include "modules/audio_device/include/audio_device_factory.h" |
| 41 | #endif |
ilnik | ee42d19 | 2017-08-22 07:16:20 -0700 | [diff] [blame] | 42 | |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 43 | namespace webrtc { |
| 44 | |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 45 | namespace { |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 46 | constexpr char kSyncGroup[] = "av_sync"; |
minyue | 10cbb46 | 2016-11-07 09:29:22 -0800 | [diff] [blame] | 47 | constexpr int kOpusMinBitrateBps = 6000; |
| 48 | constexpr int kOpusBitrateFbBps = 32000; |
ilnik | 9ae0d76 | 2017-02-15 00:53:12 -0800 | [diff] [blame] | 49 | constexpr int kFramesSentInQuickTest = 1; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 50 | constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000; |
| 51 | constexpr uint32_t kThumbnailRtxSsrcStart = 0xF0000; |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 52 | |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 53 | constexpr int kDefaultMaxQp = cricket::WebRtcVideoChannel::kDefaultQpMax; |
| 54 | |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 55 | class VideoStreamFactory |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 56 | : public VideoEncoderConfig::VideoStreamFactoryInterface { |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 57 | public: |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 58 | explicit VideoStreamFactory(const std::vector<VideoStream>& streams) |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 59 | : streams_(streams) {} |
| 60 | |
| 61 | private: |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 62 | std::vector<VideoStream> CreateEncoderStreams( |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 63 | int width, |
| 64 | int height, |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 65 | const VideoEncoderConfig& encoder_config) override { |
mflodman | d79f97b | 2016-12-15 07:24:33 -0800 | [diff] [blame] | 66 | // The highest layer must match the incoming resolution. |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 67 | std::vector<VideoStream> streams = streams_; |
mflodman | d79f97b | 2016-12-15 07:24:33 -0800 | [diff] [blame] | 68 | streams[streams_.size() - 1].height = height; |
| 69 | streams[streams_.size() - 1].width = width; |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 70 | |
| 71 | streams[0].bitrate_priority = encoder_config.bitrate_priority; |
mflodman | d79f97b | 2016-12-15 07:24:33 -0800 | [diff] [blame] | 72 | return streams; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 75 | std::vector<VideoStream> streams_; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 76 | }; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 77 | |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 78 | // An encoder wrapper that writes the encoded frames to file, one per simulcast |
| 79 | // layer. |
| 80 | class FrameDumpingEncoder : public VideoEncoder, private EncodedImageCallback { |
| 81 | public: |
| 82 | FrameDumpingEncoder(std::unique_ptr<VideoEncoder> encoder, |
| 83 | std::vector<rtc::PlatformFile> files) |
| 84 | : encoder_(std::move(encoder)) { |
| 85 | for (rtc::PlatformFile file : files) { |
| 86 | writers_.push_back( |
| 87 | IvfFileWriter::Wrap(rtc::File(file), 100000000 /* byte_limit */)); |
| 88 | } |
| 89 | } |
| 90 | // Implement VideoEncoder |
| 91 | int32_t InitEncode(const VideoCodec* codec_settings, |
| 92 | int32_t number_of_cores, |
| 93 | size_t max_payload_size) override { |
| 94 | return encoder_->InitEncode(codec_settings, number_of_cores, |
| 95 | max_payload_size); |
| 96 | } |
| 97 | int32_t RegisterEncodeCompleteCallback( |
| 98 | EncodedImageCallback* callback) override { |
| 99 | callback_ = callback; |
| 100 | return encoder_->RegisterEncodeCompleteCallback(this); |
| 101 | } |
| 102 | int32_t Release() override { return encoder_->Release(); } |
| 103 | int32_t Encode(const VideoFrame& frame, |
| 104 | const CodecSpecificInfo* codec_specific_info, |
| 105 | const std::vector<FrameType>* frame_types) { |
| 106 | return encoder_->Encode(frame, codec_specific_info, frame_types); |
| 107 | } |
| 108 | int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override { |
| 109 | return encoder_->SetChannelParameters(packet_loss, rtt); |
| 110 | } |
| 111 | int32_t SetRates(uint32_t bitrate, uint32_t framerate) override { |
| 112 | return encoder_->SetRates(bitrate, framerate); |
| 113 | } |
| 114 | int32_t SetRateAllocation(const VideoBitrateAllocation& allocation, |
| 115 | uint32_t framerate) override { |
| 116 | return encoder_->SetRateAllocation(allocation, framerate); |
| 117 | } |
| 118 | ScalingSettings GetScalingSettings() const override { |
| 119 | return encoder_->GetScalingSettings(); |
| 120 | } |
| 121 | bool SupportsNativeHandle() const override { |
| 122 | return encoder_->SupportsNativeHandle(); |
| 123 | } |
| 124 | const char* ImplementationName() const override { |
| 125 | return encoder_->ImplementationName(); |
| 126 | } |
| 127 | |
| 128 | private: |
| 129 | // Implement EncodedImageCallback |
| 130 | Result OnEncodedImage(const EncodedImage& encoded_image, |
| 131 | const CodecSpecificInfo* codec_specific_info, |
| 132 | const RTPFragmentationHeader* fragmentation) override { |
| 133 | if (codec_specific_info) { |
| 134 | int simulcast_index; |
| 135 | if (codec_specific_info->codecType == kVideoCodecVP9) { |
| 136 | simulcast_index = 0; |
| 137 | } else { |
| 138 | simulcast_index = encoded_image.SpatialIndex().value_or(0); |
| 139 | } |
| 140 | RTC_DCHECK_GE(simulcast_index, 0); |
| 141 | if (static_cast<size_t>(simulcast_index) < writers_.size()) { |
| 142 | writers_[simulcast_index]->WriteFrame(encoded_image, |
| 143 | codec_specific_info->codecType); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | return callback_->OnEncodedImage(encoded_image, codec_specific_info, |
| 148 | fragmentation); |
| 149 | } |
| 150 | |
| 151 | void OnDroppedFrame(DropReason reason) override { |
| 152 | callback_->OnDroppedFrame(reason); |
| 153 | } |
| 154 | |
| 155 | std::unique_ptr<VideoEncoder> encoder_; |
| 156 | EncodedImageCallback* callback_ = nullptr; |
| 157 | std::vector<std::unique_ptr<IvfFileWriter>> writers_; |
| 158 | }; |
| 159 | |
| 160 | } // namespace |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 161 | |
Sebastian Jansson | e6d7c3e | 2018-07-11 15:00:41 +0200 | [diff] [blame] | 162 | std::unique_ptr<VideoEncoder> VideoQualityTest::CreateVideoEncoder( |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 163 | const SdpVideoFormat& format) { |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 164 | std::unique_ptr<VideoEncoder> encoder; |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 165 | if (format.name == "VP8") { |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 166 | encoder = absl::make_unique<VP8EncoderSimulcastProxy>( |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 167 | &internal_encoder_factory_, format); |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 168 | } else if (format.name == "multiplex") { |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 169 | encoder = absl::make_unique<MultiplexEncoderAdapter>( |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 170 | &internal_encoder_factory_, SdpVideoFormat(cricket::kVp9CodecName)); |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 171 | } else { |
| 172 | encoder = internal_encoder_factory_.CreateVideoEncoder(format); |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 173 | } |
Niels Möller | 1beef1a | 2018-09-03 14:21:44 +0200 | [diff] [blame^] | 174 | if (!params_.logging.encoded_frame_base_path.empty()) { |
| 175 | char ss_buf[100]; |
| 176 | rtc::SimpleStringBuilder sb(ss_buf); |
| 177 | sb << send_logs_++; |
| 178 | std::string prefix = |
| 179 | params_.logging.encoded_frame_base_path + "." + sb.str() + ".send."; |
| 180 | encoder = absl::make_unique<FrameDumpingEncoder>( |
| 181 | std::move(encoder), std::vector<rtc::PlatformFile>( |
| 182 | {rtc::CreatePlatformFile(prefix + "1.ivf"), |
| 183 | rtc::CreatePlatformFile(prefix + "2.ivf"), |
| 184 | rtc::CreatePlatformFile(prefix + "3.ivf")})); |
| 185 | } |
| 186 | return encoder; |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 187 | } |
| 188 | |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 189 | VideoQualityTest::VideoQualityTest( |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 190 | std::unique_ptr<InjectionComponents> injection_components) |
Sebastian Jansson | e6d7c3e | 2018-07-11 15:00:41 +0200 | [diff] [blame] | 191 | : clock_(Clock::GetRealTimeClock()), |
| 192 | video_encoder_factory_([this](const SdpVideoFormat& format) { |
| 193 | return this->CreateVideoEncoder(format); |
| 194 | }), |
| 195 | receive_logs_(0), |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 196 | send_logs_(0), |
| 197 | injection_components_(std::move(injection_components)) { |
| 198 | if (injection_components_ == nullptr) { |
| 199 | injection_components_ = absl::make_unique<InjectionComponents>(); |
| 200 | } |
| 201 | |
minyue | 20c84cc | 2017-04-10 16:57:57 -0700 | [diff] [blame] | 202 | payload_type_map_ = test::CallTest::payload_type_map_; |
| 203 | RTC_DCHECK(payload_type_map_.find(kPayloadTypeH264) == |
| 204 | payload_type_map_.end()); |
| 205 | RTC_DCHECK(payload_type_map_.find(kPayloadTypeVP8) == |
| 206 | payload_type_map_.end()); |
| 207 | RTC_DCHECK(payload_type_map_.find(kPayloadTypeVP9) == |
| 208 | payload_type_map_.end()); |
| 209 | payload_type_map_[kPayloadTypeH264] = webrtc::MediaType::VIDEO; |
| 210 | payload_type_map_[kPayloadTypeVP8] = webrtc::MediaType::VIDEO; |
| 211 | payload_type_map_[kPayloadTypeVP9] = webrtc::MediaType::VIDEO; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 212 | |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 213 | fec_controller_factory_ = |
| 214 | std::move(injection_components_->fec_controller_factory); |
Ying Wang | 3b790f3 | 2018-01-19 17:58:57 +0100 | [diff] [blame] | 215 | } |
| 216 | |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 217 | VideoQualityTest::Params::Params() |
Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 218 | : call({false, BitrateConstraints(), 0}), |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 219 | video{{false, 640, 480, 30, 50, 800, 800, false, "VP8", 1, -1, 0, false, |
Niels Möller | 6aa415e | 2018-06-07 11:14:13 +0200 | [diff] [blame] | 220 | false, false, ""}, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 221 | {false, 640, 480, 30, 50, 800, 800, false, "VP8", 1, -1, 0, false, |
Niels Möller | 6aa415e | 2018-06-07 11:14:13 +0200 | [diff] [blame] | 222 | false, false, ""}}, |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 223 | audio({false, false, false, false}), |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 224 | screenshare{{false, false, 10, 0}, {false, false, 10, 0}}, |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 225 | analyzer({"", 0.0, 0.0, 0, "", ""}), |
| 226 | pipe(), |
Artem Titov | f18b352 | 2018-08-28 16:54:24 +0200 | [diff] [blame] | 227 | config(absl::nullopt), |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 228 | ss{{std::vector<VideoStream>(), 0, 0, -1, InterLayerPredMode::kOn, |
| 229 | std::vector<SpatialLayer>()}, |
| 230 | {std::vector<VideoStream>(), 0, 0, -1, InterLayerPredMode::kOn, |
| 231 | std::vector<SpatialLayer>()}}, |
Mirko Bonadei | 45a4c41 | 2018-07-31 15:07:28 +0200 | [diff] [blame] | 232 | logging({"", "", ""}) {} |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 233 | |
| 234 | VideoQualityTest::Params::~Params() = default; |
| 235 | |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 236 | VideoQualityTest::InjectionComponents::InjectionComponents() = default; |
| 237 | |
| 238 | VideoQualityTest::InjectionComponents::~InjectionComponents() = default; |
| 239 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 240 | void VideoQualityTest::TestBody() {} |
| 241 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 242 | std::string VideoQualityTest::GenerateGraphTitle() const { |
| 243 | std::stringstream ss; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 244 | ss << params_.video[0].codec; |
| 245 | ss << " (" << params_.video[0].target_bitrate_bps / 1000 << "kbps"; |
| 246 | ss << ", " << params_.video[0].fps << " FPS"; |
| 247 | if (params_.screenshare[0].scroll_duration) |
| 248 | ss << ", " << params_.screenshare[0].scroll_duration << "s scroll"; |
| 249 | if (params_.ss[0].streams.size() > 1) |
| 250 | ss << ", Stream #" << params_.ss[0].selected_stream; |
| 251 | if (params_.ss[0].num_spatial_layers > 1) |
| 252 | ss << ", Layer #" << params_.ss[0].selected_sl; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 253 | ss << ")"; |
| 254 | return ss.str(); |
| 255 | } |
| 256 | |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 257 | void VideoQualityTest::CheckParamsAndInjectionComponents() { |
| 258 | if (injection_components_ == nullptr) { |
| 259 | injection_components_ = absl::make_unique<InjectionComponents>(); |
| 260 | } |
| 261 | if (!params_.config && injection_components_->sender_network == nullptr && |
| 262 | injection_components_->receiver_network == nullptr) { |
Artem Titov | f18b352 | 2018-08-28 16:54:24 +0200 | [diff] [blame] | 263 | // TODO(titovartem) replace with default config creation when removing |
| 264 | // pipe. |
| 265 | params_.config = params_.pipe; |
| 266 | } |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 267 | RTC_CHECK( |
| 268 | (params_.config && injection_components_->sender_network == nullptr && |
| 269 | injection_components_->receiver_network == nullptr) || |
| 270 | (!params_.config && injection_components_->sender_network != nullptr && |
| 271 | injection_components_->receiver_network != nullptr)); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 272 | for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { |
| 273 | // Iterate over primary and secondary video streams. |
| 274 | if (!params_.video[video_idx].enabled) |
| 275 | return; |
| 276 | // Add a default stream in none specified. |
| 277 | if (params_.ss[video_idx].streams.empty()) |
| 278 | params_.ss[video_idx].streams.push_back( |
| 279 | VideoQualityTest::DefaultVideoStream(params_, video_idx)); |
| 280 | if (params_.ss[video_idx].num_spatial_layers == 0) |
| 281 | params_.ss[video_idx].num_spatial_layers = 1; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 282 | |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 283 | if (params_.config) { |
| 284 | if (params_.config->loss_percent != 0 || |
| 285 | params_.config->queue_length_packets != 0) { |
| 286 | // Since LayerFilteringTransport changes the sequence numbers, we can't |
| 287 | // use that feature with pack loss, since the NACK request would end up |
| 288 | // retransmitting the wrong packets. |
| 289 | RTC_CHECK(params_.ss[video_idx].selected_sl == -1 || |
| 290 | params_.ss[video_idx].selected_sl == |
| 291 | params_.ss[video_idx].num_spatial_layers - 1); |
| 292 | RTC_CHECK(params_.video[video_idx].selected_tl == -1 || |
| 293 | params_.video[video_idx].selected_tl == |
| 294 | params_.video[video_idx].num_temporal_layers - 1); |
| 295 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 296 | } |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 297 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 298 | // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as |
| 299 | // it does in some parts of the code? |
| 300 | RTC_CHECK_GE(params_.video[video_idx].max_bitrate_bps, |
| 301 | params_.video[video_idx].target_bitrate_bps); |
| 302 | RTC_CHECK_GE(params_.video[video_idx].target_bitrate_bps, |
| 303 | params_.video[video_idx].min_bitrate_bps); |
| 304 | RTC_CHECK_LT(params_.video[video_idx].selected_tl, |
| 305 | params_.video[video_idx].num_temporal_layers); |
| 306 | RTC_CHECK_LE(params_.ss[video_idx].selected_stream, |
| 307 | params_.ss[video_idx].streams.size()); |
| 308 | for (const VideoStream& stream : params_.ss[video_idx].streams) { |
| 309 | RTC_CHECK_GE(stream.min_bitrate_bps, 0); |
| 310 | RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps); |
| 311 | RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps); |
| 312 | } |
| 313 | // TODO(ivica): Should we check if the sum of all streams/layers is equal to |
| 314 | // the total bitrate? We anyway have to update them in the case bitrate |
| 315 | // estimator changes the total bitrates. |
| 316 | RTC_CHECK_GE(params_.ss[video_idx].num_spatial_layers, 1); |
| 317 | RTC_CHECK_LE(params_.ss[video_idx].selected_sl, |
| 318 | params_.ss[video_idx].num_spatial_layers); |
| 319 | RTC_CHECK( |
| 320 | params_.ss[video_idx].spatial_layers.empty() || |
| 321 | params_.ss[video_idx].spatial_layers.size() == |
| 322 | static_cast<size_t>(params_.ss[video_idx].num_spatial_layers)); |
| 323 | if (params_.video[video_idx].codec == "VP8") { |
| 324 | RTC_CHECK_EQ(params_.ss[video_idx].num_spatial_layers, 1); |
| 325 | } else if (params_.video[video_idx].codec == "VP9") { |
| 326 | RTC_CHECK_EQ(params_.ss[video_idx].streams.size(), 1); |
| 327 | } |
| 328 | RTC_CHECK_GE(params_.call.num_thumbnails, 0); |
| 329 | if (params_.call.num_thumbnails > 0) { |
| 330 | RTC_CHECK_EQ(params_.ss[video_idx].num_spatial_layers, 1); |
| 331 | RTC_CHECK_EQ(params_.ss[video_idx].streams.size(), 3); |
| 332 | RTC_CHECK_EQ(params_.video[video_idx].num_temporal_layers, 3); |
| 333 | RTC_CHECK_EQ(params_.video[video_idx].codec, "VP8"); |
| 334 | } |
| 335 | // Dual streams with FEC not supported in tests yet. |
| 336 | RTC_CHECK(!params_.video[video_idx].flexfec || num_video_streams_ == 1); |
| 337 | RTC_CHECK(!params_.video[video_idx].ulpfec || num_video_streams_ == 1); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 338 | } |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | // Static. |
| 342 | std::vector<int> VideoQualityTest::ParseCSV(const std::string& str) { |
| 343 | // Parse comma separated nonnegative integers, where some elements may be |
| 344 | // empty. The empty values are replaced with -1. |
| 345 | // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40} |
| 346 | // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1} |
| 347 | std::vector<int> result; |
| 348 | if (str.empty()) |
| 349 | return result; |
| 350 | |
| 351 | const char* p = str.c_str(); |
| 352 | int value = -1; |
| 353 | int pos; |
| 354 | while (*p) { |
| 355 | if (*p == ',') { |
| 356 | result.push_back(value); |
| 357 | value = -1; |
| 358 | ++p; |
| 359 | continue; |
| 360 | } |
| 361 | RTC_CHECK_EQ(sscanf(p, "%d%n", &value, &pos), 1) |
| 362 | << "Unexpected non-number value."; |
| 363 | p += pos; |
| 364 | } |
| 365 | result.push_back(value); |
| 366 | return result; |
| 367 | } |
| 368 | |
| 369 | // Static. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 370 | VideoStream VideoQualityTest::DefaultVideoStream(const Params& params, |
| 371 | size_t video_idx) { |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 372 | VideoStream stream; |
Danil Chapovalov | 350531e | 2018-06-08 11:04:04 +0000 | [diff] [blame] | 373 | stream.width = params.video[video_idx].width; |
| 374 | stream.height = params.video[video_idx].height; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 375 | stream.max_framerate = params.video[video_idx].fps; |
| 376 | stream.min_bitrate_bps = params.video[video_idx].min_bitrate_bps; |
| 377 | stream.target_bitrate_bps = params.video[video_idx].target_bitrate_bps; |
| 378 | stream.max_bitrate_bps = params.video[video_idx].max_bitrate_bps; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 379 | stream.max_qp = kDefaultMaxQp; |
Sergey Silkin | a796a7e | 2018-03-01 15:11:29 +0100 | [diff] [blame] | 380 | stream.num_temporal_layers = params.video[video_idx].num_temporal_layers; |
Seth Hampson | 46e31ba | 2018-01-18 10:39:54 -0800 | [diff] [blame] | 381 | stream.active = true; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 382 | return stream; |
| 383 | } |
| 384 | |
| 385 | // Static. |
| 386 | VideoStream VideoQualityTest::DefaultThumbnailStream() { |
| 387 | VideoStream stream; |
| 388 | stream.width = 320; |
| 389 | stream.height = 180; |
| 390 | stream.max_framerate = 7; |
| 391 | stream.min_bitrate_bps = 7500; |
| 392 | stream.target_bitrate_bps = 37500; |
| 393 | stream.max_bitrate_bps = 50000; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 394 | stream.max_qp = kDefaultMaxQp; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 395 | return stream; |
| 396 | } |
| 397 | |
| 398 | // Static. |
| 399 | void VideoQualityTest::FillScalabilitySettings( |
| 400 | Params* params, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 401 | size_t video_idx, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 402 | const std::vector<std::string>& stream_descriptors, |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 403 | int num_streams, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 404 | size_t selected_stream, |
| 405 | int num_spatial_layers, |
| 406 | int selected_sl, |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 407 | InterLayerPredMode inter_layer_pred, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 408 | const std::vector<std::string>& sl_descriptors) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 409 | if (params->ss[video_idx].streams.empty() && |
| 410 | params->ss[video_idx].infer_streams) { |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 411 | webrtc::VideoEncoderConfig encoder_config; |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 412 | encoder_config.codec_type = |
| 413 | PayloadStringToCodecType(params->video[video_idx].codec); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 414 | encoder_config.content_type = |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 415 | params->screenshare[video_idx].enabled |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 416 | ? webrtc::VideoEncoderConfig::ContentType::kScreen |
| 417 | : webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 418 | encoder_config.max_bitrate_bps = params->video[video_idx].max_bitrate_bps; |
| 419 | encoder_config.min_transmit_bitrate_bps = |
| 420 | params->video[video_idx].min_transmit_bps; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 421 | encoder_config.number_of_streams = num_streams; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 422 | encoder_config.spatial_layers = params->ss[video_idx].spatial_layers; |
Seth Hampson | 8234ead | 2018-02-02 15:16:24 -0800 | [diff] [blame] | 423 | encoder_config.simulcast_layers = std::vector<VideoStream>(num_streams); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 424 | encoder_config.video_stream_factory = |
| 425 | new rtc::RefCountedObject<cricket::EncoderStreamFactory>( |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 426 | params->video[video_idx].codec, kDefaultMaxQp, |
Mirko Bonadei | 948b7e3 | 2018-08-14 07:23:21 +0000 | [diff] [blame] | 427 | params->video[video_idx].fps, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 428 | params->screenshare[video_idx].enabled, true); |
| 429 | params->ss[video_idx].streams = |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 430 | encoder_config.video_stream_factory->CreateEncoderStreams( |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 431 | static_cast<int>(params->video[video_idx].width), |
| 432 | static_cast<int>(params->video[video_idx].height), encoder_config); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 433 | } else { |
| 434 | // Read VideoStream and SpatialLayer elements from a list of comma separated |
| 435 | // lists. To use a default value for an element, use -1 or leave empty. |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 436 | // Validity checks performed in CheckParamsAndInjectionComponents. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 437 | RTC_CHECK(params->ss[video_idx].streams.empty()); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 438 | for (auto descriptor : stream_descriptors) { |
| 439 | if (descriptor.empty()) |
| 440 | continue; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 441 | VideoStream stream = |
| 442 | VideoQualityTest::DefaultVideoStream(*params, video_idx); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 443 | std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); |
| 444 | if (v[0] != -1) |
| 445 | stream.width = static_cast<size_t>(v[0]); |
| 446 | if (v[1] != -1) |
| 447 | stream.height = static_cast<size_t>(v[1]); |
| 448 | if (v[2] != -1) |
| 449 | stream.max_framerate = v[2]; |
| 450 | if (v[3] != -1) |
| 451 | stream.min_bitrate_bps = v[3]; |
| 452 | if (v[4] != -1) |
| 453 | stream.target_bitrate_bps = v[4]; |
| 454 | if (v[5] != -1) |
| 455 | stream.max_bitrate_bps = v[5]; |
| 456 | if (v.size() > 6 && v[6] != -1) |
| 457 | stream.max_qp = v[6]; |
Sergey Silkin | a796a7e | 2018-03-01 15:11:29 +0100 | [diff] [blame] | 458 | if (v.size() > 7 && v[7] != -1) { |
| 459 | stream.num_temporal_layers = v[7]; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 460 | } else { |
| 461 | // Automatic TL thresholds for more than two layers not supported. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 462 | RTC_CHECK_LE(params->video[video_idx].num_temporal_layers, 2); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 463 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 464 | params->ss[video_idx].streams.push_back(stream); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 465 | } |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 466 | } |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 467 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 468 | params->ss[video_idx].num_spatial_layers = std::max(1, num_spatial_layers); |
| 469 | params->ss[video_idx].selected_stream = selected_stream; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 470 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 471 | params->ss[video_idx].selected_sl = selected_sl; |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 472 | params->ss[video_idx].inter_layer_pred = inter_layer_pred; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 473 | RTC_CHECK(params->ss[video_idx].spatial_layers.empty()); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 474 | for (auto descriptor : sl_descriptors) { |
| 475 | if (descriptor.empty()) |
| 476 | continue; |
| 477 | std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 478 | RTC_CHECK_EQ(v.size(), 7); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 479 | |
Sergey Silkin | 13e7434 | 2018-03-02 12:28:00 +0100 | [diff] [blame] | 480 | SpatialLayer layer = {0}; |
| 481 | layer.width = v[0]; |
| 482 | layer.height = v[1]; |
| 483 | layer.numberOfTemporalLayers = v[2]; |
| 484 | layer.maxBitrate = v[3]; |
| 485 | layer.minBitrate = v[4]; |
| 486 | layer.targetBitrate = v[5]; |
| 487 | layer.qpMax = v[6]; |
| 488 | layer.active = true; |
| 489 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 490 | params->ss[video_idx].spatial_layers.push_back(layer); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 494 | void VideoQualityTest::SetupVideo(Transport* send_transport, |
| 495 | Transport* recv_transport) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 496 | size_t total_streams_used = 0; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 497 | video_receive_configs_.clear(); |
| 498 | video_send_configs_.clear(); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 499 | video_encoder_configs_.clear(); |
| 500 | allocated_decoders_.clear(); |
| 501 | bool decode_all_receive_streams = true; |
| 502 | size_t num_video_substreams = params_.ss[0].streams.size(); |
| 503 | RTC_CHECK(num_video_streams_ > 0); |
| 504 | video_encoder_configs_.resize(num_video_streams_); |
| 505 | for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { |
| 506 | video_send_configs_.push_back(VideoSendStream::Config(send_transport)); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 507 | video_encoder_configs_.push_back(VideoEncoderConfig()); |
| 508 | num_video_substreams = params_.ss[video_idx].streams.size(); |
| 509 | RTC_CHECK_GT(num_video_substreams, 0); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 510 | for (size_t i = 0; i < num_video_substreams; ++i) |
| 511 | video_send_configs_[video_idx].rtp.ssrcs.push_back( |
| 512 | kVideoSendSsrcs[total_streams_used + i]); |
Qingsi Wang | 2d82ade | 2018-07-11 06:04:44 +0000 | [diff] [blame] | 513 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 514 | int payload_type; |
| 515 | if (params_.video[video_idx].codec == "H264") { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 516 | payload_type = kPayloadTypeH264; |
| 517 | } else if (params_.video[video_idx].codec == "VP8") { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 518 | payload_type = kPayloadTypeVP8; |
| 519 | } else if (params_.video[video_idx].codec == "VP9") { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 520 | payload_type = kPayloadTypeVP9; |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 521 | } else if (params_.video[video_idx].codec == "multiplex") { |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 522 | payload_type = kPayloadTypeVP9; |
ilnik | cb8c146 | 2017-03-09 09:23:30 -0800 | [diff] [blame] | 523 | } else { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 524 | RTC_NOTREACHED() << "Codec not supported!"; |
| 525 | return; |
ilnik | cb8c146 | 2017-03-09 09:23:30 -0800 | [diff] [blame] | 526 | } |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 527 | video_send_configs_[video_idx].encoder_settings.encoder_factory = |
| 528 | &video_encoder_factory_; |
| 529 | |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 530 | video_send_configs_[video_idx].rtp.payload_name = |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 531 | params_.video[video_idx].codec; |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 532 | video_send_configs_[video_idx].rtp.payload_type = payload_type; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 533 | video_send_configs_[video_idx].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 534 | video_send_configs_[video_idx].rtp.rtx.payload_type = kSendRtxPayloadType; |
| 535 | for (size_t i = 0; i < num_video_substreams; ++i) { |
| 536 | video_send_configs_[video_idx].rtp.rtx.ssrcs.push_back( |
| 537 | kSendRtxSsrcs[i + total_streams_used]); |
ilnik | 9fd9f6c | 2017-03-02 08:10:10 -0800 | [diff] [blame] | 538 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 539 | video_send_configs_[video_idx].rtp.extensions.clear(); |
| 540 | if (params_.call.send_side_bwe) { |
| 541 | video_send_configs_[video_idx].rtp.extensions.push_back( |
| 542 | RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
| 543 | test::kTransportSequenceNumberExtensionId)); |
| 544 | } else { |
| 545 | video_send_configs_[video_idx].rtp.extensions.push_back(RtpExtension( |
| 546 | RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); |
| 547 | } |
| 548 | video_send_configs_[video_idx].rtp.extensions.push_back( |
| 549 | RtpExtension(RtpExtension::kVideoContentTypeUri, |
| 550 | test::kVideoContentTypeExtensionId)); |
| 551 | video_send_configs_[video_idx].rtp.extensions.push_back(RtpExtension( |
| 552 | RtpExtension::kVideoTimingUri, test::kVideoTimingExtensionId)); |
| 553 | |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 554 | video_encoder_configs_[video_idx].video_format.name = |
| 555 | params_.video[video_idx].codec; |
| 556 | |
Emircan Uysaler | 0823eec | 2018-07-13 17:10:00 -0700 | [diff] [blame] | 557 | video_encoder_configs_[video_idx].video_format.parameters = |
| 558 | params_.video[video_idx].sdp_params; |
| 559 | |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 560 | video_encoder_configs_[video_idx].codec_type = |
| 561 | PayloadStringToCodecType(params_.video[video_idx].codec); |
| 562 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 563 | video_encoder_configs_[video_idx].min_transmit_bitrate_bps = |
| 564 | params_.video[video_idx].min_transmit_bps; |
| 565 | |
| 566 | video_send_configs_[video_idx].suspend_below_min_bitrate = |
| 567 | params_.video[video_idx].suspend_below_min_bitrate; |
| 568 | |
| 569 | video_encoder_configs_[video_idx].number_of_streams = |
| 570 | params_.ss[video_idx].streams.size(); |
| 571 | video_encoder_configs_[video_idx].max_bitrate_bps = 0; |
| 572 | for (size_t i = 0; i < params_.ss[video_idx].streams.size(); ++i) { |
| 573 | video_encoder_configs_[video_idx].max_bitrate_bps += |
| 574 | params_.ss[video_idx].streams[i].max_bitrate_bps; |
| 575 | } |
| 576 | if (params_.ss[video_idx].infer_streams) { |
Seth Hampson | 8234ead | 2018-02-02 15:16:24 -0800 | [diff] [blame] | 577 | video_encoder_configs_[video_idx].simulcast_layers = |
| 578 | std::vector<VideoStream>(params_.ss[video_idx].streams.size()); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 579 | video_encoder_configs_[video_idx].video_stream_factory = |
| 580 | new rtc::RefCountedObject<cricket::EncoderStreamFactory>( |
| 581 | params_.video[video_idx].codec, |
| 582 | params_.ss[video_idx].streams[0].max_qp, |
Mirko Bonadei | 948b7e3 | 2018-08-14 07:23:21 +0000 | [diff] [blame] | 583 | params_.video[video_idx].fps, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 584 | params_.screenshare[video_idx].enabled, true); |
| 585 | } else { |
| 586 | video_encoder_configs_[video_idx].video_stream_factory = |
| 587 | new rtc::RefCountedObject<VideoStreamFactory>( |
| 588 | params_.ss[video_idx].streams); |
| 589 | } |
| 590 | |
| 591 | video_encoder_configs_[video_idx].spatial_layers = |
| 592 | params_.ss[video_idx].spatial_layers; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 593 | decode_all_receive_streams = params_.ss[video_idx].selected_stream == |
| 594 | params_.ss[video_idx].streams.size(); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 595 | absl::optional<int> decode_sub_stream; |
| 596 | if (!decode_all_receive_streams) |
| 597 | decode_sub_stream = params_.ss[video_idx].selected_stream; |
| 598 | CreateMatchingVideoReceiveConfigs( |
| 599 | video_send_configs_[video_idx], recv_transport, |
| 600 | params_.call.send_side_bwe, decode_sub_stream, true, kNackRtpHistoryMs); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 601 | |
| 602 | if (params_.screenshare[video_idx].enabled) { |
| 603 | // Fill out codec settings. |
| 604 | video_encoder_configs_[video_idx].content_type = |
| 605 | VideoEncoderConfig::ContentType::kScreen; |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 606 | degradation_preference_ = DegradationPreference::MAINTAIN_RESOLUTION; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 607 | if (params_.video[video_idx].codec == "VP8") { |
| 608 | VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
| 609 | vp8_settings.denoisingOn = false; |
| 610 | vp8_settings.frameDroppingOn = false; |
| 611 | vp8_settings.numberOfTemporalLayers = static_cast<unsigned char>( |
| 612 | params_.video[video_idx].num_temporal_layers); |
| 613 | video_encoder_configs_[video_idx].encoder_specific_settings = |
| 614 | new rtc::RefCountedObject< |
| 615 | VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); |
| 616 | } else if (params_.video[video_idx].codec == "VP9") { |
| 617 | VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
| 618 | vp9_settings.denoisingOn = false; |
| 619 | vp9_settings.frameDroppingOn = false; |
| 620 | vp9_settings.numberOfTemporalLayers = static_cast<unsigned char>( |
| 621 | params_.video[video_idx].num_temporal_layers); |
| 622 | vp9_settings.numberOfSpatialLayers = static_cast<unsigned char>( |
| 623 | params_.ss[video_idx].num_spatial_layers); |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 624 | vp9_settings.interLayerPred = params_.ss[video_idx].inter_layer_pred; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 625 | video_encoder_configs_[video_idx].encoder_specific_settings = |
| 626 | new rtc::RefCountedObject< |
| 627 | VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); |
| 628 | } |
| 629 | } else if (params_.ss[video_idx].num_spatial_layers > 1) { |
| 630 | // If SVC mode without screenshare, still need to set codec specifics. |
| 631 | RTC_CHECK(params_.video[video_idx].codec == "VP9"); |
| 632 | VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
| 633 | vp9_settings.numberOfTemporalLayers = static_cast<unsigned char>( |
| 634 | params_.video[video_idx].num_temporal_layers); |
| 635 | vp9_settings.numberOfSpatialLayers = |
| 636 | static_cast<unsigned char>(params_.ss[video_idx].num_spatial_layers); |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 637 | vp9_settings.interLayerPred = params_.ss[video_idx].inter_layer_pred; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 638 | video_encoder_configs_[video_idx].encoder_specific_settings = |
| 639 | new rtc::RefCountedObject< |
| 640 | VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); |
Niels Möller | 6aa415e | 2018-06-07 11:14:13 +0200 | [diff] [blame] | 641 | } else if (params_.video[video_idx].automatic_scaling) { |
| 642 | if (params_.video[video_idx].codec == "VP8") { |
| 643 | VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
| 644 | vp8_settings.automaticResizeOn = true; |
| 645 | video_encoder_configs_[video_idx].encoder_specific_settings = |
| 646 | new rtc::RefCountedObject< |
| 647 | VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); |
| 648 | } else if (params_.video[video_idx].codec == "VP9") { |
| 649 | VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
| 650 | vp9_settings.automaticResizeOn = true; |
| 651 | video_encoder_configs_[video_idx].encoder_specific_settings = |
| 652 | new rtc::RefCountedObject< |
| 653 | VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); |
| 654 | } else { |
| 655 | RTC_NOTREACHED() << "Automatic scaling not supported for codec " |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 656 | << params_.video[video_idx].codec << ", stream " |
| 657 | << video_idx; |
Niels Möller | 6aa415e | 2018-06-07 11:14:13 +0200 | [diff] [blame] | 658 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 659 | } |
| 660 | total_streams_used += num_video_substreams; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 661 | } |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 662 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 663 | // FEC supported only for single video stream mode yet. |
| 664 | if (params_.video[0].flexfec) { |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 665 | if (decode_all_receive_streams) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 666 | SetSendFecConfig(GetVideoSendConfig()->rtp.ssrcs); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 667 | } else { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 668 | SetSendFecConfig({kVideoSendSsrcs[params_.ss[0].selected_stream]}); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 669 | } |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 670 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 671 | CreateMatchingFecConfig(recv_transport, *GetVideoSendConfig()); |
| 672 | GetFlexFecConfig()->transport_cc = params_.call.send_side_bwe; |
brandtr | b29e652 | 2016-12-21 06:37:18 -0800 | [diff] [blame] | 673 | if (params_.call.send_side_bwe) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 674 | GetFlexFecConfig()->rtp_header_extensions.push_back( |
brandtr | b29e652 | 2016-12-21 06:37:18 -0800 | [diff] [blame] | 675 | RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
| 676 | test::kTransportSequenceNumberExtensionId)); |
| 677 | } else { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 678 | GetFlexFecConfig()->rtp_header_extensions.push_back(RtpExtension( |
brandtr | b29e652 | 2016-12-21 06:37:18 -0800 | [diff] [blame] | 679 | RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); |
| 680 | } |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 681 | } |
| 682 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 683 | if (params_.video[0].ulpfec) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 684 | SetSendUlpFecConfig(GetVideoSendConfig()); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 685 | if (decode_all_receive_streams) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 686 | for (auto& receive_config : video_receive_configs_) { |
| 687 | SetReceiveUlpFecConfig(&receive_config); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 688 | } |
| 689 | } else { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 690 | SetReceiveUlpFecConfig( |
| 691 | &video_receive_configs_[params_.ss[0].selected_stream]); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 692 | } |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 693 | } |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 694 | } |
| 695 | |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 696 | void VideoQualityTest::SetupThumbnails(Transport* send_transport, |
| 697 | Transport* recv_transport) { |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 698 | for (int i = 0; i < params_.call.num_thumbnails; ++i) { |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 699 | // Thumbnails will be send in the other way: from receiver_call to |
| 700 | // sender_call. |
| 701 | VideoSendStream::Config thumbnail_send_config(recv_transport); |
| 702 | thumbnail_send_config.rtp.ssrcs.push_back(kThumbnailSendSsrcStart + i); |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 703 | // TODO(nisse): Could use a simpler VP8-only encoder factory. |
| 704 | thumbnail_send_config.encoder_settings.encoder_factory = |
| 705 | &video_encoder_factory_; |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 706 | thumbnail_send_config.rtp.payload_name = params_.video[0].codec; |
| 707 | thumbnail_send_config.rtp.payload_type = kPayloadTypeVP8; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 708 | thumbnail_send_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 709 | thumbnail_send_config.rtp.rtx.payload_type = kSendRtxPayloadType; |
| 710 | thumbnail_send_config.rtp.rtx.ssrcs.push_back(kThumbnailRtxSsrcStart + i); |
| 711 | thumbnail_send_config.rtp.extensions.clear(); |
| 712 | if (params_.call.send_side_bwe) { |
| 713 | thumbnail_send_config.rtp.extensions.push_back( |
| 714 | RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
| 715 | test::kTransportSequenceNumberExtensionId)); |
| 716 | } else { |
| 717 | thumbnail_send_config.rtp.extensions.push_back(RtpExtension( |
| 718 | RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); |
| 719 | } |
| 720 | |
| 721 | VideoEncoderConfig thumbnail_encoder_config; |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 722 | thumbnail_encoder_config.codec_type = kVideoCodecVP8; |
Niels Möller | 4db138e | 2018-04-19 09:04:13 +0200 | [diff] [blame] | 723 | thumbnail_encoder_config.video_format.name = "VP8"; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 724 | thumbnail_encoder_config.min_transmit_bitrate_bps = 7500; |
| 725 | thumbnail_send_config.suspend_below_min_bitrate = |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 726 | params_.video[0].suspend_below_min_bitrate; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 727 | thumbnail_encoder_config.number_of_streams = 1; |
| 728 | thumbnail_encoder_config.max_bitrate_bps = 50000; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 729 | if (params_.ss[0].infer_streams) { |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 730 | thumbnail_encoder_config.video_stream_factory = |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 731 | new rtc::RefCountedObject<VideoStreamFactory>(params_.ss[0].streams); |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 732 | } else { |
Seth Hampson | 8234ead | 2018-02-02 15:16:24 -0800 | [diff] [blame] | 733 | thumbnail_encoder_config.simulcast_layers = std::vector<VideoStream>(1); |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 734 | thumbnail_encoder_config.video_stream_factory = |
| 735 | new rtc::RefCountedObject<cricket::EncoderStreamFactory>( |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 736 | params_.video[0].codec, params_.ss[0].streams[0].max_qp, |
Mirko Bonadei | 948b7e3 | 2018-08-14 07:23:21 +0000 | [diff] [blame] | 737 | params_.video[0].fps, params_.screenshare[0].enabled, true); |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 738 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 739 | thumbnail_encoder_config.spatial_layers = params_.ss[0].spatial_layers; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 740 | |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 741 | thumbnail_encoder_configs_.push_back(thumbnail_encoder_config.Copy()); |
| 742 | thumbnail_send_configs_.push_back(thumbnail_send_config.Copy()); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 743 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 744 | AddMatchingVideoReceiveConfigs( |
| 745 | &thumbnail_receive_configs_, thumbnail_send_config, send_transport, |
| 746 | params_.call.send_side_bwe, absl::nullopt, false, kNackRtpHistoryMs); |
| 747 | } |
| 748 | for (size_t i = 0; i < thumbnail_send_configs_.size(); ++i) { |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 749 | thumbnail_send_streams_.push_back(receiver_call_->CreateVideoSendStream( |
| 750 | thumbnail_send_configs_[i].Copy(), |
| 751 | thumbnail_encoder_configs_[i].Copy())); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 752 | } |
| 753 | for (size_t i = 0; i < thumbnail_receive_configs_.size(); ++i) { |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 754 | thumbnail_receive_streams_.push_back(sender_call_->CreateVideoReceiveStream( |
| 755 | thumbnail_receive_configs_[i].Copy())); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | void VideoQualityTest::DestroyThumbnailStreams() { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 760 | for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) { |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 761 | receiver_call_->DestroyVideoSendStream(thumbnail_send_stream); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 762 | } |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 763 | thumbnail_send_streams_.clear(); |
| 764 | for (VideoReceiveStream* thumbnail_receive_stream : |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 765 | thumbnail_receive_streams_) { |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 766 | sender_call_->DestroyVideoReceiveStream(thumbnail_receive_stream); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 767 | } |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 768 | thumbnail_send_streams_.clear(); |
| 769 | thumbnail_receive_streams_.clear(); |
Sebastian Jansson | f1f363f | 2018-08-13 14:24:58 +0200 | [diff] [blame] | 770 | for (std::unique_ptr<test::TestVideoCapturer>& video_caputurer : |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 771 | thumbnail_capturers_) { |
| 772 | video_caputurer.reset(); |
| 773 | } |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 774 | } |
| 775 | |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 776 | void VideoQualityTest::SetupThumbnailCapturers(size_t num_thumbnail_streams) { |
| 777 | VideoStream thumbnail = DefaultThumbnailStream(); |
| 778 | for (size_t i = 0; i < num_thumbnail_streams; ++i) { |
| 779 | thumbnail_capturers_.emplace_back(test::FrameGeneratorCapturer::Create( |
| 780 | static_cast<int>(thumbnail.width), static_cast<int>(thumbnail.height), |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 781 | absl::nullopt, absl::nullopt, thumbnail.max_framerate, clock_)); |
ilnik | f89a738 | 2017-03-07 06:15:27 -0800 | [diff] [blame] | 782 | RTC_DCHECK(thumbnail_capturers_.back()); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 786 | std::unique_ptr<test::FrameGenerator> VideoQualityTest::CreateFrameGenerator( |
| 787 | size_t video_idx) { |
| 788 | // Setup frame generator. |
| 789 | const size_t kWidth = 1850; |
| 790 | const size_t kHeight = 1110; |
| 791 | std::unique_ptr<test::FrameGenerator> frame_generator; |
| 792 | if (params_.screenshare[video_idx].generate_slides) { |
| 793 | frame_generator = test::FrameGenerator::CreateSlideGenerator( |
| 794 | kWidth, kHeight, |
| 795 | params_.screenshare[video_idx].slide_change_interval * |
| 796 | params_.video[video_idx].fps); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 797 | } else { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 798 | std::vector<std::string> slides = params_.screenshare[video_idx].slides; |
| 799 | if (slides.size() == 0) { |
| 800 | slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); |
| 801 | slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); |
| 802 | slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); |
| 803 | slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); |
| 804 | } |
| 805 | if (params_.screenshare[video_idx].scroll_duration == 0) { |
| 806 | // Cycle image every slide_change_interval seconds. |
| 807 | frame_generator = test::FrameGenerator::CreateFromYuvFile( |
| 808 | slides, kWidth, kHeight, |
| 809 | params_.screenshare[video_idx].slide_change_interval * |
| 810 | params_.video[video_idx].fps); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 811 | } else { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 812 | RTC_CHECK_LE(params_.video[video_idx].width, kWidth); |
| 813 | RTC_CHECK_LE(params_.video[video_idx].height, kHeight); |
| 814 | RTC_CHECK_GT(params_.screenshare[video_idx].slide_change_interval, 0); |
| 815 | const int kPauseDurationMs = |
| 816 | (params_.screenshare[video_idx].slide_change_interval - |
| 817 | params_.screenshare[video_idx].scroll_duration) * |
| 818 | 1000; |
| 819 | RTC_CHECK_LE(params_.screenshare[video_idx].scroll_duration, |
| 820 | params_.screenshare[video_idx].slide_change_interval); |
| 821 | |
| 822 | frame_generator = test::FrameGenerator::CreateScrollingInputFromYuvFiles( |
| 823 | clock_, slides, kWidth, kHeight, params_.video[video_idx].width, |
| 824 | params_.video[video_idx].height, |
| 825 | params_.screenshare[video_idx].scroll_duration * 1000, |
| 826 | kPauseDurationMs); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 827 | } |
| 828 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 829 | return frame_generator; |
| 830 | } |
| 831 | |
| 832 | void VideoQualityTest::CreateCapturers() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 833 | RTC_DCHECK(video_sources_.empty()); |
| 834 | RTC_DCHECK(video_capturers_.empty()); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 835 | video_capturers_.resize(num_video_streams_); |
| 836 | for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { |
| 837 | if (params_.screenshare[video_idx].enabled) { |
| 838 | std::unique_ptr<test::FrameGenerator> frame_generator = |
| 839 | CreateFrameGenerator(video_idx); |
| 840 | test::FrameGeneratorCapturer* frame_generator_capturer = |
| 841 | new test::FrameGeneratorCapturer(clock_, std::move(frame_generator), |
| 842 | params_.video[video_idx].fps); |
| 843 | EXPECT_TRUE(frame_generator_capturer->Init()); |
| 844 | video_capturers_[video_idx].reset(frame_generator_capturer); |
| 845 | } else { |
| 846 | if (params_.video[video_idx].clip_name == "Generator") { |
| 847 | video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( |
| 848 | static_cast<int>(params_.video[video_idx].width), |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 849 | static_cast<int>(params_.video[video_idx].height), absl::nullopt, |
| 850 | absl::nullopt, params_.video[video_idx].fps, clock_)); |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 851 | } else if (params_.video[video_idx].clip_name == "GeneratorI420A") { |
| 852 | video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( |
| 853 | static_cast<int>(params_.video[video_idx].width), |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 854 | static_cast<int>(params_.video[video_idx].height), |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 855 | test::FrameGenerator::OutputType::I420A, absl::nullopt, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 856 | params_.video[video_idx].fps, clock_)); |
Emircan Uysaler | 0823eec | 2018-07-13 17:10:00 -0700 | [diff] [blame] | 857 | } else if (params_.video[video_idx].clip_name == "GeneratorI010") { |
| 858 | video_capturers_[video_idx].reset(test::FrameGeneratorCapturer::Create( |
| 859 | static_cast<int>(params_.video[video_idx].width), |
| 860 | static_cast<int>(params_.video[video_idx].height), |
| 861 | test::FrameGenerator::OutputType::I010, absl::nullopt, |
| 862 | params_.video[video_idx].fps, clock_)); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 863 | } else if (params_.video[video_idx].clip_name.empty()) { |
| 864 | video_capturers_[video_idx].reset(test::VcmCapturer::Create( |
| 865 | params_.video[video_idx].width, params_.video[video_idx].height, |
| 866 | params_.video[video_idx].fps, |
| 867 | params_.video[video_idx].capture_device_index)); |
| 868 | if (!video_capturers_[video_idx]) { |
| 869 | // Failed to get actual camera, use chroma generator as backup. |
| 870 | video_capturers_[video_idx].reset( |
| 871 | test::FrameGeneratorCapturer::Create( |
| 872 | static_cast<int>(params_.video[video_idx].width), |
| 873 | static_cast<int>(params_.video[video_idx].height), |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 874 | absl::nullopt, absl::nullopt, params_.video[video_idx].fps, |
Emircan Uysaler | 03e6ec9 | 2018-03-09 15:03:26 -0800 | [diff] [blame] | 875 | clock_)); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 876 | } |
| 877 | } else { |
| 878 | video_capturers_[video_idx].reset( |
| 879 | test::FrameGeneratorCapturer::CreateFromYuvFile( |
| 880 | test::ResourcePath(params_.video[video_idx].clip_name, "yuv"), |
| 881 | params_.video[video_idx].width, params_.video[video_idx].height, |
| 882 | params_.video[video_idx].fps, clock_)); |
| 883 | ASSERT_TRUE(video_capturers_[video_idx]) |
| 884 | << "Could not create capturer for " |
| 885 | << params_.video[video_idx].clip_name |
| 886 | << ".yuv. Is this resource file present?"; |
| 887 | } |
| 888 | } |
| 889 | RTC_DCHECK(video_capturers_[video_idx].get()); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 890 | video_sources_.push_back(video_capturers_[video_idx].get()); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 891 | } |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 892 | } |
| 893 | |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 894 | void VideoQualityTest::StartAudioStreams() { |
| 895 | audio_send_stream_->Start(); |
| 896 | for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) |
| 897 | audio_recv_stream->Start(); |
| 898 | } |
| 899 | |
| 900 | void VideoQualityTest::StartThumbnailCapture() { |
Sebastian Jansson | f1f363f | 2018-08-13 14:24:58 +0200 | [diff] [blame] | 901 | for (std::unique_ptr<test::TestVideoCapturer>& capturer : |
| 902 | thumbnail_capturers_) |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 903 | capturer->Start(); |
| 904 | } |
| 905 | |
| 906 | void VideoQualityTest::StopThumbnailCapture() { |
Sebastian Jansson | f1f363f | 2018-08-13 14:24:58 +0200 | [diff] [blame] | 907 | for (std::unique_ptr<test::TestVideoCapturer>& capturer : |
| 908 | thumbnail_capturers_) |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 909 | capturer->Stop(); |
| 910 | } |
| 911 | |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 912 | void VideoQualityTest::StartThumbnails() { |
| 913 | for (VideoSendStream* send_stream : thumbnail_send_streams_) |
| 914 | send_stream->Start(); |
| 915 | for (VideoReceiveStream* receive_stream : thumbnail_receive_streams_) |
| 916 | receive_stream->Start(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | void VideoQualityTest::StopThumbnails() { |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 920 | for (VideoReceiveStream* receive_stream : thumbnail_receive_streams_) |
| 921 | receive_stream->Stop(); |
| 922 | for (VideoSendStream* send_stream : thumbnail_send_streams_) |
| 923 | send_stream->Stop(); |
| 924 | } |
| 925 | |
Christoffer Rodbro | b4bb4eb | 2017-11-13 13:03:52 +0100 | [diff] [blame] | 926 | std::unique_ptr<test::LayerFilteringTransport> |
| 927 | VideoQualityTest::CreateSendTransport() { |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 928 | std::unique_ptr<NetworkSimulationInterface> simulated_network = nullptr; |
| 929 | if (injection_components_->sender_network == nullptr) { |
| 930 | simulated_network = absl::make_unique<SimulatedNetwork>(*params_.config); |
| 931 | } else { |
| 932 | simulated_network = std::move(injection_components_->sender_network); |
| 933 | } |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 934 | return absl::make_unique<test::LayerFilteringTransport>( |
Artem Titov | 4e199e9 | 2018-08-20 13:30:39 +0200 | [diff] [blame] | 935 | &task_queue_, |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 936 | absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(), |
| 937 | std::move(simulated_network)), |
Artem Titov | 4e199e9 | 2018-08-20 13:30:39 +0200 | [diff] [blame] | 938 | sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9, |
| 939 | params_.video[0].selected_tl, params_.ss[0].selected_sl, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 940 | payload_type_map_, kVideoSendSsrcs[0], |
| 941 | static_cast<uint32_t>(kVideoSendSsrcs[0] + params_.ss[0].streams.size() - |
| 942 | 1)); |
Christoffer Rodbro | b4bb4eb | 2017-11-13 13:03:52 +0100 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | std::unique_ptr<test::DirectTransport> |
| 946 | VideoQualityTest::CreateReceiveTransport() { |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 947 | std::unique_ptr<NetworkSimulationInterface> simulated_network = nullptr; |
| 948 | if (injection_components_->receiver_network == nullptr) { |
| 949 | simulated_network = absl::make_unique<SimulatedNetwork>(*params_.config); |
| 950 | } else { |
| 951 | simulated_network = std::move(injection_components_->receiver_network); |
| 952 | } |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 953 | return absl::make_unique<test::DirectTransport>( |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 954 | &task_queue_, |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 955 | absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(), |
| 956 | std::move(simulated_network)), |
Artem Titov | dd2eebe | 2018-08-20 13:27:45 +0200 | [diff] [blame] | 957 | receiver_call_.get(), payload_type_map_); |
Christoffer Rodbro | b4bb4eb | 2017-11-13 13:03:52 +0100 | [diff] [blame] | 958 | } |
| 959 | |
sprang | 7a975f7 | 2015-10-12 06:33:21 -0700 | [diff] [blame] | 960 | void VideoQualityTest::RunWithAnalyzer(const Params& params) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 961 | num_video_streams_ = params.call.dual_video ? 2 : 1; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 962 | std::unique_ptr<test::LayerFilteringTransport> send_transport; |
| 963 | std::unique_ptr<test::DirectTransport> recv_transport; |
| 964 | FILE* graph_data_output_file = nullptr; |
| 965 | std::unique_ptr<VideoAnalyzer> analyzer; |
| 966 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 967 | params_ = params; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 968 | // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to |
| 969 | // differentiate between the analyzer and the renderer case. |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 970 | CheckParamsAndInjectionComponents(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 971 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 972 | if (!params_.analyzer.graph_data_output_filename.empty()) { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 973 | graph_data_output_file = |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 974 | fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); |
Peter Boström | 74f6e9e | 2016-04-04 17:56:10 +0200 | [diff] [blame] | 975 | RTC_CHECK(graph_data_output_file) |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 976 | << "Can't open the file " << params_.analyzer.graph_data_output_filename |
| 977 | << "!"; |
ivica | 87f83a9 | 2015-10-08 05:13:32 -0700 | [diff] [blame] | 978 | } |
sprang | 7a975f7 | 2015-10-12 06:33:21 -0700 | [diff] [blame] | 979 | |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 980 | if (!params.logging.rtc_event_log_name.empty()) { |
Bjorn Terelius | 0a6a2b7 | 2018-01-19 17:52:38 +0100 | [diff] [blame] | 981 | send_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); |
| 982 | recv_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 983 | std::unique_ptr<RtcEventLogOutputFile> send_output( |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 984 | absl::make_unique<RtcEventLogOutputFile>( |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 985 | params.logging.rtc_event_log_name + "_send", |
| 986 | RtcEventLog::kUnlimitedOutput)); |
| 987 | std::unique_ptr<RtcEventLogOutputFile> recv_output( |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 988 | absl::make_unique<RtcEventLogOutputFile>( |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 989 | params.logging.rtc_event_log_name + "_recv", |
| 990 | RtcEventLog::kUnlimitedOutput)); |
| 991 | bool event_log_started = |
| 992 | send_event_log_->StartLogging(std::move(send_output), |
| 993 | RtcEventLog::kImmediateOutput) && |
| 994 | recv_event_log_->StartLogging(std::move(recv_output), |
| 995 | RtcEventLog::kImmediateOutput); |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 996 | RTC_DCHECK(event_log_started); |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 997 | } else { |
| 998 | send_event_log_ = RtcEventLog::CreateNull(); |
| 999 | recv_event_log_ = RtcEventLog::CreateNull(); |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 1002 | Call::Config send_call_config(send_event_log_.get()); |
| 1003 | Call::Config recv_call_config(recv_event_log_.get()); |
| 1004 | send_call_config.bitrate_config = params.call.call_bitrate_config; |
| 1005 | recv_call_config.bitrate_config = params.call.call_bitrate_config; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 1006 | |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 1007 | task_queue_.SendTask([this, &send_call_config, &recv_call_config, |
| 1008 | &send_transport, &recv_transport]() { |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1009 | if (params_.audio.enabled) |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1010 | InitializeAudioDevice( |
| 1011 | &send_call_config, &recv_call_config, params_.audio.use_real_adm); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1012 | |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 1013 | CreateCalls(send_call_config, recv_call_config); |
| 1014 | send_transport = CreateSendTransport(); |
| 1015 | recv_transport = CreateReceiveTransport(); |
| 1016 | }); |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 1017 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 1018 | std::string graph_title = params_.analyzer.graph_title; |
| 1019 | if (graph_title.empty()) |
| 1020 | graph_title = VideoQualityTest::GenerateGraphTitle(); |
sprang | c1b57a1 | 2017-02-28 08:50:47 -0800 | [diff] [blame] | 1021 | bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest"); |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 1022 | analyzer = absl::make_unique<VideoAnalyzer>( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1023 | send_transport.get(), params_.analyzer.test_label, |
ilnik | 2a8c2f5 | 2017-02-15 02:23:28 -0800 | [diff] [blame] | 1024 | params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold, |
ilnik | 9ae0d76 | 2017-02-15 00:53:12 -0800 | [diff] [blame] | 1025 | is_quick_test_enabled |
| 1026 | ? kFramesSentInQuickTest |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1027 | : params_.analyzer.test_durations_secs * params_.video[0].fps, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 1028 | graph_data_output_file, graph_title, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1029 | kVideoSendSsrcs[params_.ss[0].selected_stream], |
| 1030 | kSendRtxSsrcs[params_.ss[0].selected_stream], |
| 1031 | static_cast<size_t>(params_.ss[0].selected_stream), |
| 1032 | params.ss[0].selected_sl, params_.video[0].selected_tl, |
| 1033 | is_quick_test_enabled, clock_, params_.logging.rtp_dump_name); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1034 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1035 | task_queue_.SendTask([&]() { |
| 1036 | analyzer->SetCall(sender_call_.get()); |
| 1037 | analyzer->SetReceiver(receiver_call_->Receiver()); |
| 1038 | send_transport->SetReceiver(analyzer.get()); |
| 1039 | recv_transport->SetReceiver(sender_call_->Receiver()); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1040 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1041 | SetupVideo(analyzer.get(), recv_transport.get()); |
| 1042 | SetupThumbnails(analyzer.get(), recv_transport.get()); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1043 | video_receive_configs_[params_.ss[0].selected_stream].renderer = |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1044 | analyzer.get(); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1045 | GetVideoSendConfig()->pre_encode_callback = analyzer->pre_encode_proxy(); |
| 1046 | RTC_DCHECK(!GetVideoSendConfig()->post_encode_callback); |
| 1047 | GetVideoSendConfig()->post_encode_callback = analyzer.get(); |
kthelgason | 2bc6864 | 2017-02-07 07:02:22 -0800 | [diff] [blame] | 1048 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1049 | CreateFlexfecStreams(); |
| 1050 | CreateVideoStreams(); |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1051 | analyzer->SetSendStream(video_send_streams_[0]); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1052 | if (video_receive_streams_.size() == 1) |
| 1053 | analyzer->SetReceiveStream(video_receive_streams_[0]); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1054 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1055 | GetVideoSendStream()->SetSource(analyzer->OutputInterface(), |
| 1056 | degradation_preference_); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1057 | SetupThumbnailCapturers(params_.call.num_thumbnails); |
| 1058 | for (size_t i = 0; i < thumbnail_send_streams_.size(); ++i) { |
| 1059 | thumbnail_send_streams_[i]->SetSource(thumbnail_capturers_[i].get(), |
| 1060 | degradation_preference_); |
| 1061 | } |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 1062 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1063 | CreateCapturers(); |
ivica | c1cc854 | 2015-10-08 03:44:06 -0700 | [diff] [blame] | 1064 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1065 | analyzer->SetSource(video_capturers_[0].get(), params_.ss[0].infer_streams); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 1066 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1067 | for (size_t video_idx = 1; video_idx < num_video_streams_; ++video_idx) { |
| 1068 | video_send_streams_[video_idx]->SetSource( |
| 1069 | video_capturers_[video_idx].get(), degradation_preference_); |
| 1070 | } |
| 1071 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1072 | StartEncodedFrameLogs( |
| 1073 | video_receive_streams_[params_.ss[0].selected_stream]); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 1074 | |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1075 | if (params_.audio.enabled) { |
| 1076 | SetupAudio(send_transport.get()); |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1077 | StartAudioStreams(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1078 | analyzer->SetAudioReceiveStream(audio_receive_streams_[0]); |
| 1079 | } |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1080 | StartVideoStreams(); |
| 1081 | StartThumbnails(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1082 | analyzer->StartMeasuringCpuProcessTime(); |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1083 | StartVideoCapture(); |
| 1084 | StartThumbnailCapture(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1085 | }); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1086 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1087 | analyzer->Wait(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1088 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1089 | task_queue_.SendTask([&]() { |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1090 | StopThumbnailCapture(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1091 | StopThumbnails(); |
| 1092 | Stop(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1093 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1094 | DestroyStreams(); |
| 1095 | DestroyThumbnailStreams(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1096 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1097 | if (graph_data_output_file) |
| 1098 | fclose(graph_data_output_file); |
| 1099 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1100 | video_capturers_.clear(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1101 | send_transport.reset(); |
| 1102 | recv_transport.reset(); |
| 1103 | |
| 1104 | DestroyCalls(); |
| 1105 | }); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1106 | } |
| 1107 | |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1108 | rtc::scoped_refptr<AudioDeviceModule> VideoQualityTest::CreateAudioDevice() { |
| 1109 | #ifdef WEBRTC_WIN |
| 1110 | RTC_LOG(INFO) << "Using latest version of ADM on Windows"; |
| 1111 | // We must initialize the COM library on a thread before we calling any of |
| 1112 | // the library functions. All COM functions in the ADM will return |
| 1113 | // CO_E_NOTINITIALIZED otherwise. The legacy ADM for Windows used internal |
| 1114 | // COM initialization but the new ADM requires COM to be initialized |
| 1115 | // externally. |
| 1116 | com_initializer_ = absl::make_unique<webrtc_win::ScopedCOMInitializer>( |
| 1117 | webrtc_win::ScopedCOMInitializer::kMTA); |
| 1118 | RTC_CHECK(com_initializer_->Succeeded()); |
| 1119 | RTC_CHECK(webrtc_win::core_audio_utility::IsSupported()); |
| 1120 | RTC_CHECK(webrtc_win::core_audio_utility::IsMMCSSSupported()); |
| 1121 | return CreateWindowsCoreAudioAudioDeviceModule(); |
| 1122 | #else |
| 1123 | // Use legacy factory method on all platforms except Windows. |
| 1124 | return AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio); |
| 1125 | #endif |
| 1126 | } |
| 1127 | |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1128 | void VideoQualityTest::InitializeAudioDevice(Call::Config* send_call_config, |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1129 | Call::Config* recv_call_config, |
| 1130 | bool use_real_adm) { |
| 1131 | rtc::scoped_refptr<AudioDeviceModule> audio_device; |
| 1132 | if (use_real_adm) { |
| 1133 | // Run test with real ADM (using default audio devices) if user has |
| 1134 | // explicitly set the --audio and --use_real_adm command-line flags. |
| 1135 | audio_device = CreateAudioDevice(); |
| 1136 | } else { |
| 1137 | // By default, create a test ADM which fakes audio. |
| 1138 | audio_device = TestAudioDeviceModule::CreateTestAudioDeviceModule( |
| 1139 | TestAudioDeviceModule::CreatePulsedNoiseCapturer(32000, 48000), |
| 1140 | TestAudioDeviceModule::CreateDiscardRenderer(48000), 1.f); |
| 1141 | } |
| 1142 | RTC_CHECK(audio_device); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1143 | |
| 1144 | AudioState::Config audio_state_config; |
| 1145 | audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
| 1146 | audio_state_config.audio_processing = AudioProcessingBuilder().Create(); |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1147 | audio_state_config.audio_device_module = audio_device; |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1148 | send_call_config->audio_state = AudioState::Create(audio_state_config); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1149 | recv_call_config->audio_state = AudioState::Create(audio_state_config); |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1150 | if (use_real_adm) { |
| 1151 | // The real ADM requires extra initialization: setting default devices, |
| 1152 | // setting up number of channels etc. Helper class also calls |
| 1153 | // AudioDeviceModule::Init(). |
| 1154 | webrtc::adm_helpers::Init(audio_device.get()); |
| 1155 | } else { |
| 1156 | audio_device->Init(); |
| 1157 | } |
| 1158 | // Always initialize the ADM before injecting a valid audio transport. |
| 1159 | RTC_CHECK(audio_device->RegisterAudioCallback( |
| 1160 | send_call_config->audio_state->audio_transport()) == 0); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1161 | } |
| 1162 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1163 | void VideoQualityTest::SetupAudio(Transport* transport) { |
| 1164 | AudioSendStream::Config audio_send_config(transport); |
| 1165 | audio_send_config.rtp.ssrc = kAudioSendSsrc; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 1166 | |
| 1167 | // Add extension to enable audio send side BWE, and allow audio bit rate |
| 1168 | // adaptation. |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1169 | audio_send_config.rtp.extensions.clear(); |
| 1170 | audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec( |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 1171 | kAudioSendPayloadType, |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1172 | {"OPUS", |
| 1173 | 48000, |
| 1174 | 2, |
| 1175 | {{"usedtx", (params_.audio.dtx ? "1" : "0")}, {"stereo", "1"}}}); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 1176 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1177 | if (params_.call.send_side_bwe) { |
| 1178 | audio_send_config.rtp.extensions.push_back( |
| 1179 | webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUri, |
| 1180 | test::kTransportSequenceNumberExtensionId)); |
| 1181 | audio_send_config.min_bitrate_bps = kOpusMinBitrateBps; |
| 1182 | audio_send_config.max_bitrate_bps = kOpusBitrateFbBps; |
| 1183 | audio_send_config.send_codec_spec->transport_cc_enabled = true; |
| 1184 | } |
| 1185 | audio_send_config.encoder_factory = audio_encoder_factory_; |
| 1186 | SetAudioConfig(audio_send_config); |
| 1187 | |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1188 | std::string sync_group; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1189 | if (params_.video[0].enabled && params_.audio.sync_video) |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1190 | sync_group = kSyncGroup; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 1191 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1192 | CreateMatchingAudioConfigs(transport, sync_group); |
| 1193 | CreateAudioStreams(); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 1196 | void VideoQualityTest::RunWithRenderers(const Params& params) { |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1197 | RTC_LOG(INFO) << __FUNCTION__; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1198 | num_video_streams_ = params.call.dual_video ? 2 : 1; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1199 | std::unique_ptr<test::LayerFilteringTransport> send_transport; |
| 1200 | std::unique_ptr<test::DirectTransport> recv_transport; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 1201 | std::unique_ptr<test::VideoRenderer> local_preview; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1202 | std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers; |
Sebastian Jansson | 8e6602f | 2018-07-13 10:43:20 +0200 | [diff] [blame] | 1203 | RtcEventLogNullImpl null_event_log; |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 1204 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1205 | task_queue_.SendTask([&]() { |
| 1206 | params_ = params; |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 1207 | CheckParamsAndInjectionComponents(); |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 1208 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1209 | // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to |
| 1210 | // match the full stack tests. |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1211 | Call::Config send_call_config(&null_event_log); |
| 1212 | send_call_config.bitrate_config = params_.call.call_bitrate_config; |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 1213 | Call::Config recv_call_config(&null_event_log); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1214 | |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1215 | if (params_.audio.enabled) |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 1216 | InitializeAudioDevice( |
| 1217 | &send_call_config, &recv_call_config, params_.audio.use_real_adm); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 1218 | |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 1219 | CreateCalls(send_call_config, recv_call_config); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1220 | |
| 1221 | // TODO(minyue): consider if this is a good transport even for audio only |
| 1222 | // calls. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1223 | send_transport = CreateSendTransport(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1224 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1225 | recv_transport = CreateReceiveTransport(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1226 | |
| 1227 | // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at |
| 1228 | // least share as much code as possible. That way this test would also match |
| 1229 | // the full stack tests better. |
| 1230 | send_transport->SetReceiver(receiver_call_->Receiver()); |
| 1231 | recv_transport->SetReceiver(sender_call_->Receiver()); |
| 1232 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1233 | if (params_.video[0].enabled) { |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1234 | // Create video renderers. |
| 1235 | local_preview.reset(test::VideoRenderer::Create( |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1236 | "Local Preview", params_.video[0].width, params_.video[0].height)); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1237 | |
| 1238 | SetupVideo(send_transport.get(), recv_transport.get()); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1239 | GetVideoSendConfig()->pre_encode_callback = local_preview.get(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1240 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1241 | size_t num_streams_processed = 0; |
| 1242 | for (size_t video_idx = 0; video_idx < num_video_streams_; ++video_idx) { |
| 1243 | const size_t selected_stream_id = params_.ss[video_idx].selected_stream; |
| 1244 | const size_t num_streams = params_.ss[video_idx].streams.size(); |
| 1245 | if (selected_stream_id == num_streams) { |
| 1246 | for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { |
| 1247 | std::ostringstream oss; |
| 1248 | oss << "Loopback Video #" << video_idx << " - Stream #" |
| 1249 | << static_cast<int>(stream_id); |
| 1250 | loopback_renderers.emplace_back(test::VideoRenderer::Create( |
| 1251 | oss.str().c_str(), |
| 1252 | params_.ss[video_idx].streams[stream_id].width, |
| 1253 | params_.ss[video_idx].streams[stream_id].height)); |
| 1254 | video_receive_configs_[stream_id + num_streams_processed].renderer = |
| 1255 | loopback_renderers.back().get(); |
| 1256 | if (params_.audio.enabled && params_.audio.sync_video) |
| 1257 | video_receive_configs_[stream_id + num_streams_processed] |
| 1258 | .sync_group = kSyncGroup; |
| 1259 | } |
| 1260 | } else { |
| 1261 | std::ostringstream oss; |
| 1262 | oss << "Loopback Video #" << video_idx; |
| 1263 | loopback_renderers.emplace_back(test::VideoRenderer::Create( |
| 1264 | oss.str().c_str(), |
| 1265 | params_.ss[video_idx].streams[selected_stream_id].width, |
| 1266 | params_.ss[video_idx].streams[selected_stream_id].height)); |
| 1267 | video_receive_configs_[selected_stream_id + num_streams_processed] |
| 1268 | .renderer = loopback_renderers.back().get(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1269 | if (params_.audio.enabled && params_.audio.sync_video) |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1270 | video_receive_configs_[num_streams_processed + selected_stream_id] |
| 1271 | .sync_group = kSyncGroup; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1272 | } |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1273 | num_streams_processed += num_streams; |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1274 | } |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1275 | CreateFlexfecStreams(); |
| 1276 | CreateVideoStreams(); |
| 1277 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1278 | CreateCapturers(); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1279 | ConnectVideoSourcesToStreams(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | if (params_.audio.enabled) { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1283 | SetupAudio(send_transport.get()); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | for (VideoReceiveStream* receive_stream : video_receive_streams_) |
| 1287 | StartEncodedFrameLogs(receive_stream); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1288 | Start(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1289 | }); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 1290 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1291 | test::PressEnterToContinue(); |
| 1292 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1293 | task_queue_.SendTask([&]() { |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 1294 | Stop(); |
| 1295 | DestroyStreams(); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 1296 | |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 1297 | video_capturers_.clear(); |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1298 | send_transport.reset(); |
| 1299 | recv_transport.reset(); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 1300 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 1301 | local_preview.reset(); |
| 1302 | loopback_renderers.clear(); |
| 1303 | |
| 1304 | DestroyCalls(); |
| 1305 | }); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 1308 | void VideoQualityTest::StartEncodedFrameLogs(VideoReceiveStream* stream) { |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 1309 | if (!params_.logging.encoded_frame_base_path.empty()) { |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 1310 | std::ostringstream str; |
| 1311 | str << receive_logs_++; |
| 1312 | std::string path = |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 1313 | params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 1314 | stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 1315 | 100000000); |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 1316 | } |
| 1317 | } |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1318 | } // namespace webrtc |