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

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

Issue 2997883002: Video/Screenshare loopback tool.
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_quality_test.h ('k') | webrtc/video/vs_loopback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include "webrtc/video/video_quality_test.h" 10 #include "webrtc/video/video_quality_test.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 false, 61 false,
62 "Enable saving a frame with the lowest PSNR to a jpeg file in the " 62 "Enable saving a frame with the lowest PSNR to a jpeg file in the "
63 "test_output_dir"); 63 "test_output_dir");
64 64
65 namespace { 65 namespace {
66 66
67 constexpr int kSendStatsPollingIntervalMs = 1000; 67 constexpr int kSendStatsPollingIntervalMs = 1000;
68 68
69 constexpr size_t kMaxComparisons = 10; 69 constexpr size_t kMaxComparisons = 10;
70 constexpr char kSyncGroup[] = "av_sync"; 70 constexpr char kSyncGroup[] = "av_sync";
71 constexpr int kOpusMinBitrateBps = 6000; 71 // constexpr int kOpusMinBitrateBps = 6000;
72 constexpr int kOpusBitrateFbBps = 32000; 72 // constexpr int kOpusBitrateFbBps = 32000;
73 constexpr int kFramesSentInQuickTest = 1; 73 // constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000;
74 constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000; 74 // constexpr uint32_t kThumbnailRtxSsrcStart = 0xF0000;
75 constexpr uint32_t kThumbnailRtxSsrcStart = 0xF0000;
76 75
77 constexpr int kDefaultMaxQp = cricket::WebRtcVideoChannel::kDefaultQpMax; 76 constexpr int kDefaultMaxQp = cricket::WebRtcVideoChannel::kDefaultQpMax;
78 77
79 struct VoiceEngineState { 78 struct VoiceEngineState {
80 VoiceEngineState() 79 VoiceEngineState()
81 : voice_engine(nullptr), 80 : voice_engine(nullptr),
82 base(nullptr), 81 base(nullptr),
83 send_channel_id(-1), 82 send_channel_id(-1),
84 receive_channel_id(-1) {} 83 receive_channel_id(-1) {}
85 84
86 webrtc::VoiceEngine* voice_engine; 85 webrtc::VoiceEngine* voice_engine;
87 webrtc::VoEBase* base; 86 webrtc::VoEBase* base;
88 int send_channel_id; 87 int send_channel_id;
89 int receive_channel_id; 88 int receive_channel_id;
90 }; 89 };
91 90
92 void CreateVoiceEngine( 91 // void CreateVoiceEngine(
93 VoiceEngineState* voe, 92 // VoiceEngineState* voe,
94 webrtc::AudioProcessing* apm, 93 // webrtc::AudioProcessing* apm,
95 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory) { 94 // rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory) {
96 voe->voice_engine = webrtc::VoiceEngine::Create(); 95 // voe->voice_engine = webrtc::VoiceEngine::Create();
97 voe->base = webrtc::VoEBase::GetInterface(voe->voice_engine); 96 // voe->base = webrtc::VoEBase::GetInterface(voe->voice_engine);
98 EXPECT_EQ(0, voe->base->Init(nullptr, apm, decoder_factory)); 97 // EXPECT_EQ(0, voe->base->Init(nullptr, apm, decoder_factory));
99 webrtc::VoEBase::ChannelConfig config; 98 // webrtc::VoEBase::ChannelConfig config;
100 config.enable_voice_pacing = true; 99 // config.enable_voice_pacing = true;
101 voe->send_channel_id = voe->base->CreateChannel(config); 100 // voe->send_channel_id = voe->base->CreateChannel(config);
102 EXPECT_GE(voe->send_channel_id, 0); 101 // EXPECT_GE(voe->send_channel_id, 0);
103 voe->receive_channel_id = voe->base->CreateChannel(); 102 // voe->receive_channel_id = voe->base->CreateChannel();
104 EXPECT_GE(voe->receive_channel_id, 0); 103 // EXPECT_GE(voe->receive_channel_id, 0);
105 } 104 // }
106 105
107 void DestroyVoiceEngine(VoiceEngineState* voe) { 106 // void DestroyVoiceEngine(VoiceEngineState* voe) {
108 voe->base->DeleteChannel(voe->send_channel_id); 107 // voe->base->DeleteChannel(voe->send_channel_id);
109 voe->send_channel_id = -1; 108 // voe->send_channel_id = -1;
110 voe->base->DeleteChannel(voe->receive_channel_id); 109 // voe->base->DeleteChannel(voe->receive_channel_id);
111 voe->receive_channel_id = -1; 110 // voe->receive_channel_id = -1;
112 voe->base->Release(); 111 // voe->base->Release();
113 voe->base = nullptr; 112 // voe->base = nullptr;
114 113
115 webrtc::VoiceEngine::Delete(voe->voice_engine); 114 // webrtc::VoiceEngine::Delete(voe->voice_engine);
116 voe->voice_engine = nullptr; 115 // voe->voice_engine = nullptr;
117 } 116 // }
118 117
119 class VideoStreamFactory 118 class VideoStreamFactory
120 : public webrtc::VideoEncoderConfig::VideoStreamFactoryInterface { 119 : public webrtc::VideoEncoderConfig::VideoStreamFactoryInterface {
121 public: 120 public:
122 explicit VideoStreamFactory(const std::vector<webrtc::VideoStream>& streams) 121 explicit VideoStreamFactory(const std::vector<webrtc::VideoStream>& streams)
123 : streams_(streams) {} 122 : streams_(streams) {}
124 123
125 private: 124 private:
126 std::vector<webrtc::VideoStream> CreateEncoderStreams( 125 std::vector<webrtc::VideoStream> CreateEncoderStreams(
127 int width, 126 int width,
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 pipe(), 1178 pipe(),
1180 ss({std::vector<VideoStream>(), 0, 0, -1, std::vector<SpatialLayer>()}), 1179 ss({std::vector<VideoStream>(), 0, 0, -1, std::vector<SpatialLayer>()}),
1181 logging({false, "", "", ""}) {} 1180 logging({false, "", "", ""}) {}
1182 1181
1183 VideoQualityTest::Params::~Params() = default; 1182 VideoQualityTest::Params::~Params() = default;
1184 1183
1185 void VideoQualityTest::TestBody() {} 1184 void VideoQualityTest::TestBody() {}
1186 1185
1187 std::string VideoQualityTest::GenerateGraphTitle() const { 1186 std::string VideoQualityTest::GenerateGraphTitle() const {
1188 std::stringstream ss; 1187 std::stringstream ss;
1189 ss << params_.video.codec; 1188 // ss << params_.video.codec;
1190 ss << " (" << params_.video.target_bitrate_bps / 1000 << "kbps"; 1189 // ss << " (" << params_.video.target_bitrate_bps / 1000 << "kbps";
1191 ss << ", " << params_.video.fps << " FPS"; 1190 // ss << ", " << params_.video.fps << " FPS";
1192 if (params_.screenshare.scroll_duration) 1191 // if (params_.screenshare.scroll_duration)
1193 ss << ", " << params_.screenshare.scroll_duration << "s scroll"; 1192 // ss << ", " << params_.screenshare.scroll_duration << "s scroll";
1194 if (params_.ss.streams.size() > 1) 1193 // if (params_.ss.streams.size() > 1)
1195 ss << ", Stream #" << params_.ss.selected_stream; 1194 // ss << ", Stream #" << params_.ss.selected_stream;
1196 if (params_.ss.num_spatial_layers > 1) 1195 // if (params_.ss.num_spatial_layers > 1)
1197 ss << ", Layer #" << params_.ss.selected_sl; 1196 // ss << ", Layer #" << params_.ss.selected_sl;
1198 ss << ")"; 1197 // ss << ")";
1199 return ss.str(); 1198 return ss.str();
1200 } 1199 }
1201 1200
1202 void VideoQualityTest::CheckParams() { 1201 void VideoQualityTest::CheckParams(Params* params) {
1203 if (!params_.video.enabled) 1202 if (!params->video.enabled)
1204 return; 1203 return;
1205 // Add a default stream in none specified. 1204 // Add a default stream in none specified.
1206 if (params_.ss.streams.empty()) 1205 if (params->ss.streams.empty())
1207 params_.ss.streams.push_back(VideoQualityTest::DefaultVideoStream(params_)); 1206 params->ss.streams.push_back(VideoQualityTest::DefaultVideoStream(*params));
1208 if (params_.ss.num_spatial_layers == 0) 1207 if (params->ss.num_spatial_layers == 0)
1209 params_.ss.num_spatial_layers = 1; 1208 params->ss.num_spatial_layers = 1;
1210 1209
1211 if (params_.pipe.loss_percent != 0 || 1210 if (params->pipe.loss_percent != 0 ||
1212 params_.pipe.queue_length_packets != 0) { 1211 params->pipe.queue_length_packets != 0) {
1213 // Since LayerFilteringTransport changes the sequence numbers, we can't 1212 // Since LayerFilteringTransport changes the sequence numbers, we can't
1214 // use that feature with pack loss, since the NACK request would end up 1213 // use that feature with pack loss, since the NACK request would end up
1215 // retransmitting the wrong packets. 1214 // retransmitting the wrong packets.
1216 RTC_CHECK(params_.ss.selected_sl == -1 || 1215 RTC_CHECK(params->ss.selected_sl == -1 ||
1217 params_.ss.selected_sl == params_.ss.num_spatial_layers - 1); 1216 params->ss.selected_sl == params->ss.num_spatial_layers - 1);
1218 RTC_CHECK(params_.video.selected_tl == -1 || 1217 RTC_CHECK(params->video.selected_tl == -1 ||
1219 params_.video.selected_tl == 1218 params->video.selected_tl ==
1220 params_.video.num_temporal_layers - 1); 1219 params->video.num_temporal_layers - 1);
1221 } 1220 }
1222 1221
1223 // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as it 1222 // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as it
1224 // does in some parts of the code? 1223 // does in some parts of the code?
1225 RTC_CHECK_GE(params_.video.max_bitrate_bps, params_.video.target_bitrate_bps); 1224 RTC_CHECK_GE(params->video.max_bitrate_bps, params->video.target_bitrate_bps);
1226 RTC_CHECK_GE(params_.video.target_bitrate_bps, params_.video.min_bitrate_bps); 1225 RTC_CHECK_GE(params->video.target_bitrate_bps, params->video.min_bitrate_bps);
1227 RTC_CHECK_LT(params_.video.selected_tl, params_.video.num_temporal_layers); 1226 RTC_CHECK_LT(params->video.selected_tl, params->video.num_temporal_layers);
1228 RTC_CHECK_LE(params_.ss.selected_stream, params_.ss.streams.size()); 1227 RTC_CHECK_LE(params->ss.selected_stream, params->ss.streams.size());
1229 for (const VideoStream& stream : params_.ss.streams) { 1228 for (const VideoStream& stream : params->ss.streams) {
1230 RTC_CHECK_GE(stream.min_bitrate_bps, 0); 1229 RTC_CHECK_GE(stream.min_bitrate_bps, 0);
1231 RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps); 1230 RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps);
1232 RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps); 1231 RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps);
1233 } 1232 }
1234 // TODO(ivica): Should we check if the sum of all streams/layers is equal to 1233 // TODO(ivica): Should we check if the sum of all streams/layers is equal to
1235 // the total bitrate? We anyway have to update them in the case bitrate 1234 // the total bitrate? We anyway have to update them in the case bitrate
1236 // estimator changes the total bitrates. 1235 // estimator changes the total bitrates.
1237 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1); 1236 RTC_CHECK_GE(params->ss.num_spatial_layers, 1);
1238 RTC_CHECK_LE(params_.ss.selected_sl, params_.ss.num_spatial_layers); 1237 RTC_CHECK_LE(params->ss.selected_sl, params->ss.num_spatial_layers);
1239 RTC_CHECK(params_.ss.spatial_layers.empty() || 1238 RTC_CHECK(params->ss.spatial_layers.empty() ||
1240 params_.ss.spatial_layers.size() == 1239 params->ss.spatial_layers.size() ==
1241 static_cast<size_t>(params_.ss.num_spatial_layers)); 1240 static_cast<size_t>(params->ss.num_spatial_layers));
1242 if (params_.video.codec == "VP8") { 1241 if (params->video.codec == "VP8") {
1243 RTC_CHECK_EQ(params_.ss.num_spatial_layers, 1); 1242 RTC_CHECK_EQ(params->ss.num_spatial_layers, 1);
1244 } else if (params_.video.codec == "VP9") { 1243 } else if (params->video.codec == "VP9") {
1245 RTC_CHECK_EQ(params_.ss.streams.size(), 1); 1244 RTC_CHECK_EQ(params->ss.streams.size(), 1);
1246 } 1245 }
1247 RTC_CHECK_GE(params_.call.num_thumbnails, 0); 1246 RTC_CHECK_GE(params->call.num_thumbnails, 0);
1248 if (params_.call.num_thumbnails > 0) { 1247 if (params->call.num_thumbnails > 0) {
1249 RTC_CHECK_EQ(params_.ss.num_spatial_layers, 1); 1248 RTC_CHECK_EQ(params->ss.num_spatial_layers, 1);
1250 RTC_CHECK_EQ(params_.ss.streams.size(), 3); 1249 RTC_CHECK_EQ(params->ss.streams.size(), 3);
1251 RTC_CHECK_EQ(params_.video.num_temporal_layers, 3); 1250 RTC_CHECK_EQ(params->video.num_temporal_layers, 3);
1252 RTC_CHECK_EQ(params_.video.codec, "VP8"); 1251 RTC_CHECK_EQ(params->video.codec, "VP8");
1253 } 1252 }
1254 } 1253 }
1255 1254
1256 // Static. 1255 // Static.
1257 std::vector<int> VideoQualityTest::ParseCSV(const std::string& str) { 1256 std::vector<int> VideoQualityTest::ParseCSV(const std::string& str) {
1258 // Parse comma separated nonnegative integers, where some elements may be 1257 // Parse comma separated nonnegative integers, where some elements may be
1259 // empty. The empty values are replaced with -1. 1258 // empty. The empty values are replaced with -1.
1260 // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40} 1259 // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40}
1261 // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1} 1260 // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1}
1262 std::vector<int> result; 1261 std::vector<int> result;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 RTC_CHECK_GT(v[2], 0); 1388 RTC_CHECK_GT(v[2], 0);
1390 1389
1391 SpatialLayer layer; 1390 SpatialLayer layer;
1392 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0]; 1391 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0];
1393 layer.scaling_factor_den = v[1] == -1 ? 1 : v[1]; 1392 layer.scaling_factor_den = v[1] == -1 ? 1 : v[1];
1394 layer.target_bitrate_bps = v[2]; 1393 layer.target_bitrate_bps = v[2];
1395 params->ss.spatial_layers.push_back(layer); 1394 params->ss.spatial_layers.push_back(layer);
1396 } 1395 }
1397 } 1396 }
1398 1397
1399 void VideoQualityTest::SetupVideo(Transport* send_transport, 1398 void VideoQualityTest::SetupVideo(
1400 Transport* recv_transport) { 1399 Transport* send_transport,
1401 if (params_.logging.logs) 1400 Transport* recv_transport,
1401 Params* params,
1402 VideoSendStream::Config* video_send_config,
1403 VideoEncoderConfig* video_encoder_config,
1404 std::unique_ptr<VideoEncoder>* video_encoder,
1405 std::vector<VideoReceiveStream::Config>* video_receive_configs,
1406 std::vector<std::unique_ptr<VideoDecoder>>* allocated_decoders,
1407 std::vector<uint32_t>* send_ssrcs,
1408 std::vector<uint32_t>* send_rtx_ssrcs) {
1409 if (params->logging.logs)
1402 trace_to_stderr_.reset(new test::TraceToStderr); 1410 trace_to_stderr_.reset(new test::TraceToStderr);
1403 1411
1404 size_t num_video_streams = params_.ss.streams.size(); 1412 size_t num_video_streams = params->ss.streams.size();
1405 size_t num_flexfec_streams = params_.video.flexfec ? 1 : 0; 1413 size_t num_flexfec_streams = params->video.flexfec ? 1 : 0;
1406 CreateSendConfig(num_video_streams, 0, num_flexfec_streams, send_transport); 1414 CreateSendConfig(num_video_streams, 0, num_flexfec_streams, send_transport,
1415 video_send_config, video_encoder_config, send_ssrcs);
1407 1416
1408 int payload_type; 1417 int payload_type;
1409 if (params_.video.codec == "H264") { 1418 if (params->video.codec == "H264") {
1410 video_encoder_.reset(H264Encoder::Create(cricket::VideoCodec("H264"))); 1419 video_encoder->reset(H264Encoder::Create(cricket::VideoCodec("H264")));
1411 payload_type = kPayloadTypeH264; 1420 payload_type = kPayloadTypeH264;
1412 } else if (params_.video.codec == "VP8") { 1421 } else if (params->video.codec == "VP8") {
1413 if (params_.screenshare.enabled && params_.ss.streams.size() > 1) { 1422 if (params->screenshare.enabled && params->ss.streams.size() > 1) {
1414 // Simulcast screenshare needs a simulcast encoder adapter to work, since 1423 // Simulcast screenshare needs a simulcast encoder adapter to work, since
1415 // encoders usually can't natively do simulcast with different frame rates 1424 // encoders usually can't natively do simulcast with different frame rates
1416 // for the different layers. 1425 // for the different layers.
1417 video_encoder_.reset( 1426 video_encoder->reset(
1418 new SimulcastEncoderAdapter(new Vp8EncoderFactory())); 1427 new SimulcastEncoderAdapter(new Vp8EncoderFactory()));
1419 } else { 1428 } else {
1420 video_encoder_.reset(VP8Encoder::Create()); 1429 video_encoder->reset(VP8Encoder::Create());
1421 } 1430 }
1422 payload_type = kPayloadTypeVP8; 1431 payload_type = kPayloadTypeVP8;
1423 } else if (params_.video.codec == "VP9") { 1432 } else if (params->video.codec == "VP9") {
1424 video_encoder_.reset(VP9Encoder::Create()); 1433 video_encoder->reset(VP9Encoder::Create());
1425 payload_type = kPayloadTypeVP9; 1434 payload_type = kPayloadTypeVP9;
1426 } else { 1435 } else {
1427 RTC_NOTREACHED() << "Codec not supported!"; 1436 RTC_NOTREACHED() << "Codec not supported!";
1428 return; 1437 return;
1429 } 1438 }
1430 video_send_config_.encoder_settings.encoder = video_encoder_.get(); 1439 video_send_config->encoder_settings.encoder = video_encoder->get();
1431 video_send_config_.encoder_settings.payload_name = params_.video.codec; 1440 video_send_config->encoder_settings.payload_name = params->video.codec;
1432 video_send_config_.encoder_settings.payload_type = payload_type; 1441 video_send_config->encoder_settings.payload_type = payload_type;
1433 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 1442 video_send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
1434 video_send_config_.rtp.rtx.payload_type = kSendRtxPayloadType; 1443 video_send_config->rtp.rtx.payload_type = kSendRtxPayloadType;
1435 for (size_t i = 0; i < num_video_streams; ++i) 1444 for (size_t i = 0; i < num_video_streams; ++i)
1436 video_send_config_.rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); 1445 video_send_config->rtp.rtx.ssrcs.push_back(send_rtx_ssrcs->at(i));
1437 1446
1438 video_send_config_.rtp.extensions.clear(); 1447 video_send_config->rtp.extensions.clear();
1439 if (params_.call.send_side_bwe) { 1448 if (params->call.send_side_bwe) {
1440 video_send_config_.rtp.extensions.push_back( 1449 video_send_config->rtp.extensions.push_back(
1441 RtpExtension(RtpExtension::kTransportSequenceNumberUri, 1450 RtpExtension(RtpExtension::kTransportSequenceNumberUri,
1442 test::kTransportSequenceNumberExtensionId)); 1451 test::kTransportSequenceNumberExtensionId));
1443 } else { 1452 } else {
1444 video_send_config_.rtp.extensions.push_back(RtpExtension( 1453 video_send_config->rtp.extensions.push_back(RtpExtension(
1445 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); 1454 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
1446 } 1455 }
1447 video_send_config_.rtp.extensions.push_back(RtpExtension( 1456 video_send_config->rtp.extensions.push_back(RtpExtension(
1448 RtpExtension::kVideoContentTypeUri, test::kVideoContentTypeExtensionId)); 1457 RtpExtension::kVideoContentTypeUri, test::kVideoContentTypeExtensionId));
1449 video_send_config_.rtp.extensions.push_back(RtpExtension( 1458 video_send_config->rtp.extensions.push_back(RtpExtension(
1450 RtpExtension::kVideoTimingUri, test::kVideoTimingExtensionId)); 1459 RtpExtension::kVideoTimingUri, test::kVideoTimingExtensionId));
1451 1460
1452 video_encoder_config_.min_transmit_bitrate_bps = 1461 video_encoder_config->min_transmit_bitrate_bps =
1453 params_.video.min_transmit_bps; 1462 params->video.min_transmit_bps;
1454 1463
1455 video_send_config_.suspend_below_min_bitrate = 1464 video_send_config->suspend_below_min_bitrate =
1456 params_.video.suspend_below_min_bitrate; 1465 params->video.suspend_below_min_bitrate;
1457 1466
1458 video_encoder_config_.number_of_streams = params_.ss.streams.size(); 1467 video_encoder_config->number_of_streams = params->ss.streams.size();
1459 video_encoder_config_.max_bitrate_bps = 0; 1468 video_encoder_config->max_bitrate_bps = 0;
1460 for (size_t i = 0; i < params_.ss.streams.size(); ++i) { 1469 for (size_t i = 0; i < params->ss.streams.size(); ++i) {
1461 video_encoder_config_.max_bitrate_bps += 1470 video_encoder_config->max_bitrate_bps +=
1462 params_.ss.streams[i].max_bitrate_bps; 1471 params->ss.streams[i].max_bitrate_bps;
1463 } 1472 }
1464 if (params_.ss.infer_streams) { 1473 if (params->ss.infer_streams) {
1465 video_encoder_config_.video_stream_factory = 1474 video_encoder_config->video_stream_factory =
1466 new rtc::RefCountedObject<cricket::EncoderStreamFactory>( 1475 new rtc::RefCountedObject<cricket::EncoderStreamFactory>(
1467 params_.video.codec, params_.ss.streams[0].max_qp, 1476 params->video.codec, params->ss.streams[0].max_qp,
1468 params_.video.fps, params_.screenshare.enabled, true); 1477 params->video.fps, params->screenshare.enabled, true);
1469 } else { 1478 } else {
1470 video_encoder_config_.video_stream_factory = 1479 video_encoder_config->video_stream_factory =
1471 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams); 1480 new rtc::RefCountedObject<VideoStreamFactory>(params->ss.streams);
1472 } 1481 }
1473 1482
1474 video_encoder_config_.spatial_layers = params_.ss.spatial_layers; 1483 video_encoder_config->spatial_layers = params->ss.spatial_layers;
1475 1484
1476 CreateMatchingReceiveConfigs(recv_transport); 1485 CreateMatchingReceiveConfigs(recv_transport, video_receive_configs,
1486 allocated_decoders, video_send_config);
1477 1487
1478 const bool decode_all_receive_streams = 1488 const bool decode_all_receive_streams =
1479 params_.ss.selected_stream == params_.ss.streams.size(); 1489 params->ss.selected_stream == params->ss.streams.size();
1480 1490
1481 for (size_t i = 0; i < num_video_streams; ++i) { 1491 for (size_t i = 0; i < num_video_streams; ++i) {
1482 video_receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 1492 video_receive_configs->at(i).rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
1483 video_receive_configs_[i].rtp.rtx_ssrc = kSendRtxSsrcs[i]; 1493 video_receive_configs->at(i).rtp.rtx_ssrc = send_rtx_ssrcs->at(i);
1484 video_receive_configs_[i] 1494 video_receive_configs->at(i)
1485 .rtp.rtx_associated_payload_types[kSendRtxPayloadType] = payload_type; 1495 .rtp.rtx_associated_payload_types[kSendRtxPayloadType] = payload_type;
1486 video_receive_configs_[i].rtp.transport_cc = params_.call.send_side_bwe; 1496 video_receive_configs->at(i).rtp.transport_cc = params->call.send_side_bwe;
1487 video_receive_configs_[i].rtp.remb = !params_.call.send_side_bwe; 1497 video_receive_configs->at(i).rtp.remb = !params->call.send_side_bwe;
1488 // Enable RTT calculation so NTP time estimator will work. 1498 // Enable RTT calculation so NTP time estimator will work.
1489 video_receive_configs_[i].rtp.rtcp_xr.receiver_reference_time_report = true; 1499 video_receive_configs->at(i).rtp.rtcp_xr.receiver_reference_time_report =
1500 true;
1490 // Force fake decoders on non-selected simulcast streams. 1501 // Force fake decoders on non-selected simulcast streams.
1491 if (!decode_all_receive_streams && i != params_.ss.selected_stream) { 1502 if (!decode_all_receive_streams && i != params->ss.selected_stream) {
1492 VideoReceiveStream::Decoder decoder; 1503 VideoReceiveStream::Decoder decoder;
1493 decoder.decoder = new test::FakeDecoder(); 1504 decoder.decoder = new test::FakeDecoder();
1494 decoder.payload_type = video_send_config_.encoder_settings.payload_type; 1505 decoder.payload_type = video_send_config->encoder_settings.payload_type;
1495 decoder.payload_name = video_send_config_.encoder_settings.payload_name; 1506 decoder.payload_name = video_send_config->encoder_settings.payload_name;
1496 video_receive_configs_[i].decoders.clear(); 1507 video_receive_configs->at(i).decoders.clear();
1497 allocated_decoders_.emplace_back(decoder.decoder); 1508 allocated_decoders_.emplace_back(decoder.decoder);
1498 video_receive_configs_[i].decoders.push_back(decoder); 1509 video_receive_configs->at(i).decoders.push_back(decoder);
1499 } 1510 }
1500 } 1511 }
1501 1512
1502 if (params_.video.flexfec) { 1513 RTC_DCHECK(!params->video.flexfec);
1503 // Override send config constructed by CreateSendConfig. 1514 RTC_DCHECK(!params->video.ulpfec);
1504 if (decode_all_receive_streams) {
1505 for (uint32_t media_ssrc : video_send_config_.rtp.ssrcs) {
1506 video_send_config_.rtp.flexfec.protected_media_ssrcs.push_back(
1507 media_ssrc);
1508 }
1509 } else {
1510 video_send_config_.rtp.flexfec.protected_media_ssrcs = {
1511 kVideoSendSsrcs[params_.ss.selected_stream]};
1512 }
1513
1514 // The matching receive config is _not_ created by
1515 // CreateMatchingReceiveConfigs, since VideoQualityTest is not a BaseTest.
1516 // Set up the receive config manually instead.
1517 FlexfecReceiveStream::Config flexfec_receive_config(recv_transport);
1518 flexfec_receive_config.payload_type =
1519 video_send_config_.rtp.flexfec.payload_type;
1520 flexfec_receive_config.remote_ssrc = video_send_config_.rtp.flexfec.ssrc;
1521 flexfec_receive_config.protected_media_ssrcs =
1522 video_send_config_.rtp.flexfec.protected_media_ssrcs;
1523 flexfec_receive_config.local_ssrc = kReceiverLocalVideoSsrc;
1524 flexfec_receive_config.transport_cc = params_.call.send_side_bwe;
1525 if (params_.call.send_side_bwe) {
1526 flexfec_receive_config.rtp_header_extensions.push_back(
1527 RtpExtension(RtpExtension::kTransportSequenceNumberUri,
1528 test::kTransportSequenceNumberExtensionId));
1529 } else {
1530 flexfec_receive_config.rtp_header_extensions.push_back(RtpExtension(
1531 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
1532 }
1533 flexfec_receive_configs_.push_back(flexfec_receive_config);
1534 }
1535
1536 if (params_.video.ulpfec) {
1537 video_send_config_.rtp.ulpfec.red_payload_type = kRedPayloadType;
1538 video_send_config_.rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType;
1539 video_send_config_.rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType;
1540
1541 if (decode_all_receive_streams) {
1542 for (auto it = video_receive_configs_.begin();
1543 it != video_receive_configs_.end(); ++it) {
1544 it->rtp.ulpfec.red_payload_type =
1545 video_send_config_.rtp.ulpfec.red_payload_type;
1546 it->rtp.ulpfec.ulpfec_payload_type =
1547 video_send_config_.rtp.ulpfec.ulpfec_payload_type;
1548 it->rtp.ulpfec.red_rtx_payload_type =
1549 video_send_config_.rtp.ulpfec.red_rtx_payload_type;
1550 }
1551 } else {
1552 video_receive_configs_[params_.ss.selected_stream]
1553 .rtp.ulpfec.red_payload_type =
1554 video_send_config_.rtp.ulpfec.red_payload_type;
1555 video_receive_configs_[params_.ss.selected_stream]
1556 .rtp.ulpfec.ulpfec_payload_type =
1557 video_send_config_.rtp.ulpfec.ulpfec_payload_type;
1558 video_receive_configs_[params_.ss.selected_stream]
1559 .rtp.ulpfec.red_rtx_payload_type =
1560 video_send_config_.rtp.ulpfec.red_rtx_payload_type;
1561 }
1562 }
1563 } 1515 }
1564 1516
1565 void VideoQualityTest::SetupThumbnails(Transport* send_transport, 1517 void VideoQualityTest::SetupThumbnails(Transport* send_transport,
1566 Transport* recv_transport) { 1518 Transport* recv_transport) {
1567 for (int i = 0; i < params_.call.num_thumbnails; ++i) { 1519 // for (int i = 0; i < params_.call.num_thumbnails; ++i) {
1568 thumbnail_encoders_.emplace_back(VP8Encoder::Create()); 1520 // thumbnail_encoders_.emplace_back(VP8Encoder::Create());
1569 1521
1570 // Thumbnails will be send in the other way: from receiver_call to 1522 // // Thumbnails will be send in the other way: from receiver_call to
1571 // sender_call. 1523 // // sender_call.
1572 VideoSendStream::Config thumbnail_send_config(recv_transport); 1524 // VideoSendStream::Config thumbnail_send_config(recv_transport);
1573 thumbnail_send_config.rtp.ssrcs.push_back(kThumbnailSendSsrcStart + i); 1525 // thumbnail_send_config.rtp.ssrcs.push_back(kThumbnailSendSsrcStart + i);
1574 thumbnail_send_config.encoder_settings.encoder = 1526 // thumbnail_send_config.encoder_settings.encoder =
1575 thumbnail_encoders_.back().get(); 1527 // thumbnail_encoders_.back().get();
1576 thumbnail_send_config.encoder_settings.payload_name = params_.video.codec; 1528 // thumbnail_send_config.encoder_settings.payload_name =
1577 thumbnail_send_config.encoder_settings.payload_type = kPayloadTypeVP8; 1529 // params_.video.codec; thumbnail_send_config.encoder_settings.payload_type
1578 thumbnail_send_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 1530 // = kPayloadTypeVP8; thumbnail_send_config.rtp.nack.rtp_history_ms =
1579 thumbnail_send_config.rtp.rtx.payload_type = kSendRtxPayloadType; 1531 // kNackRtpHistoryMs; thumbnail_send_config.rtp.rtx.payload_type =
1580 thumbnail_send_config.rtp.rtx.ssrcs.push_back(kThumbnailRtxSsrcStart + i); 1532 // kSendRtxPayloadType;
1581 thumbnail_send_config.rtp.extensions.clear(); 1533 // thumbnail_send_config.rtp.rtx.ssrcs.push_back(kThumbnailRtxSsrcStart +
1582 if (params_.call.send_side_bwe) { 1534 // i); thumbnail_send_config.rtp.extensions.clear(); if
1583 thumbnail_send_config.rtp.extensions.push_back( 1535 // (params_.call.send_side_bwe) {
1584 RtpExtension(RtpExtension::kTransportSequenceNumberUri, 1536 // thumbnail_send_config.rtp.extensions.push_back(
1585 test::kTransportSequenceNumberExtensionId)); 1537 // RtpExtension(RtpExtension::kTransportSequenceNumberUri,
1586 } else { 1538 // test::kTransportSequenceNumberExtensionId));
1587 thumbnail_send_config.rtp.extensions.push_back(RtpExtension( 1539 // } else {
1588 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); 1540 // thumbnail_send_config.rtp.extensions.push_back(RtpExtension(
1589 } 1541 // RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
1590 1542 // }
1591 VideoEncoderConfig thumbnail_encoder_config; 1543
1592 thumbnail_encoder_config.min_transmit_bitrate_bps = 7500; 1544 // VideoEncoderConfig thumbnail_encoder_config;
1593 thumbnail_send_config.suspend_below_min_bitrate = 1545 // thumbnail_encoder_config.min_transmit_bitrate_bps = 7500;
1594 params_.video.suspend_below_min_bitrate; 1546 // thumbnail_send_config.suspend_below_min_bitrate =
1595 thumbnail_encoder_config.number_of_streams = 1; 1547 // params_.video.suspend_below_min_bitrate;
1596 thumbnail_encoder_config.max_bitrate_bps = 50000; 1548 // thumbnail_encoder_config.number_of_streams = 1;
1597 if (params_.ss.infer_streams) { 1549 // thumbnail_encoder_config.max_bitrate_bps = 50000;
1598 thumbnail_encoder_config.video_stream_factory = 1550 // if (params_.ss.infer_streams) {
1599 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams); 1551 // thumbnail_encoder_config.video_stream_factory =
1600 } else { 1552 // new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams);
1601 thumbnail_encoder_config.video_stream_factory = 1553 // } else {
1602 new rtc::RefCountedObject<cricket::EncoderStreamFactory>( 1554 // thumbnail_encoder_config.video_stream_factory =
1603 params_.video.codec, params_.ss.streams[0].max_qp, 1555 // new rtc::RefCountedObject<cricket::EncoderStreamFactory>(
1604 params_.video.fps, params_.screenshare.enabled, true); 1556 // params_.video.codec, params_.ss.streams[0].max_qp,
1605 } 1557 // params_.video.fps, params_.screenshare.enabled, true);
1606 thumbnail_encoder_config.spatial_layers = params_.ss.spatial_layers; 1558 // }
1607 1559 // thumbnail_encoder_config.spatial_layers = params_.ss.spatial_layers;
1608 VideoReceiveStream::Config thumbnail_receive_config(send_transport); 1560
1609 thumbnail_receive_config.rtp.remb = false; 1561 // VideoReceiveStream::Config thumbnail_receive_config(send_transport);
1610 thumbnail_receive_config.rtp.transport_cc = true; 1562 // thumbnail_receive_config.rtp.remb = false;
1611 thumbnail_receive_config.rtp.local_ssrc = kReceiverLocalVideoSsrc; 1563 // thumbnail_receive_config.rtp.transport_cc = true;
1612 for (const RtpExtension& extension : thumbnail_send_config.rtp.extensions) 1564 // thumbnail_receive_config.rtp.local_ssrc = kReceiverLocalVideoSsrc;
1613 thumbnail_receive_config.rtp.extensions.push_back(extension); 1565 // for (const RtpExtension& extension :
1614 thumbnail_receive_config.renderer = &fake_renderer_; 1566 // thumbnail_send_config.rtp.extensions)
1615 1567 // thumbnail_receive_config.rtp.extensions.push_back(extension);
1616 VideoReceiveStream::Decoder decoder = 1568 // thumbnail_receive_config.renderer = &fake_renderer_;
1617 test::CreateMatchingDecoder(thumbnail_send_config.encoder_settings); 1569
1618 allocated_decoders_.push_back( 1570 // VideoReceiveStream::Decoder decoder =
1619 std::unique_ptr<VideoDecoder>(decoder.decoder)); 1571 // test::CreateMatchingDecoder(thumbnail_send_config.encoder_settings);
1620 thumbnail_receive_config.decoders.clear(); 1572 // allocated_decoders_.push_back(
1621 thumbnail_receive_config.decoders.push_back(decoder); 1573 // std::unique_ptr<VideoDecoder>(decoder.decoder));
1622 thumbnail_receive_config.rtp.remote_ssrc = 1574 // thumbnail_receive_config.decoders.clear();
1623 thumbnail_send_config.rtp.ssrcs[0]; 1575 // thumbnail_receive_config.decoders.push_back(decoder);
1624 1576 // thumbnail_receive_config.rtp.remote_ssrc =
1625 thumbnail_receive_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 1577 // thumbnail_send_config.rtp.ssrcs[0];
1626 thumbnail_receive_config.rtp.rtx_ssrc = kThumbnailRtxSsrcStart + i; 1578
1627 thumbnail_receive_config.rtp 1579 // thumbnail_receive_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
1628 .rtx_associated_payload_types[kSendRtxPayloadType] = kPayloadTypeVP8; 1580 // thumbnail_receive_config.rtp.rtx_ssrc = kThumbnailRtxSsrcStart + i;
1629 thumbnail_receive_config.rtp.transport_cc = params_.call.send_side_bwe; 1581 // thumbnail_receive_config.rtp.rtx_payload_types[kPayloadTypeVP8] =
1630 thumbnail_receive_config.rtp.remb = !params_.call.send_side_bwe; 1582 // kSendRtxPayloadType;
1631 1583 // thumbnail_receive_config.rtp.transport_cc = params_.call.send_side_bwe;
1632 thumbnail_encoder_configs_.push_back(thumbnail_encoder_config.Copy()); 1584 // thumbnail_receive_config.rtp.remb = !params_.call.send_side_bwe;
1633 thumbnail_send_configs_.push_back(thumbnail_send_config.Copy()); 1585
1634 thumbnail_receive_configs_.push_back(thumbnail_receive_config.Copy()); 1586 // thumbnail_encoder_configs_.push_back(thumbnail_encoder_config.Copy());
1635 } 1587 // thumbnail_send_configs_.push_back(thumbnail_send_config.Copy());
1636 1588 // thumbnail_receive_configs_.push_back(thumbnail_receive_config.Copy());
1637 for (int i = 0; i < params_.call.num_thumbnails; ++i) { 1589 // }
1638 thumbnail_send_streams_.push_back(receiver_call_->CreateVideoSendStream( 1590
1639 thumbnail_send_configs_[i].Copy(), 1591 // for (int i = 0; i < params_.call.num_thumbnails; ++i) {
1640 thumbnail_encoder_configs_[i].Copy())); 1592 // thumbnail_send_streams_.push_back(receiver_call_->CreateVideoSendStream(
1641 thumbnail_receive_streams_.push_back(sender_call_->CreateVideoReceiveStream( 1593 // thumbnail_send_configs_[i].Copy(),
1642 thumbnail_receive_configs_[i].Copy())); 1594 // thumbnail_encoder_configs_[i].Copy()));
1643 } 1595 // thumbnail_receive_streams_.push_back(sender_call_->CreateVideoReceiveStre am(
1596 // thumbnail_receive_configs_[i].Copy()));
1597 // }
1644 } 1598 }
1645 1599
1646 void VideoQualityTest::DestroyThumbnailStreams() { 1600 void VideoQualityTest::DestroyThumbnailStreams() {
1647 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) 1601 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_)
1648 receiver_call_->DestroyVideoSendStream(thumbnail_send_stream); 1602 receiver_call_->DestroyVideoSendStream(thumbnail_send_stream);
1649 thumbnail_send_streams_.clear(); 1603 thumbnail_send_streams_.clear();
1650 for (VideoReceiveStream* thumbnail_receive_stream : 1604 for (VideoReceiveStream* thumbnail_receive_stream :
1651 thumbnail_receive_streams_) 1605 thumbnail_receive_streams_)
1652 sender_call_->DestroyVideoReceiveStream(thumbnail_receive_stream); 1606 sender_call_->DestroyVideoReceiveStream(thumbnail_receive_stream);
1653 thumbnail_send_streams_.clear(); 1607 thumbnail_send_streams_.clear();
1654 thumbnail_receive_streams_.clear(); 1608 thumbnail_receive_streams_.clear();
1655 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : 1609 for (std::unique_ptr<test::VideoCapturer>& video_caputurer :
1656 thumbnail_capturers_) { 1610 thumbnail_capturers_) {
1657 video_caputurer.reset(); 1611 video_caputurer.reset();
1658 } 1612 }
1659 } 1613 }
1660 1614
1661 void VideoQualityTest::SetupScreenshareOrSVC() { 1615 void VideoQualityTest::SetupScreenshareOrSVC(
1662 if (params_.screenshare.enabled) { 1616 Params* params,
1617 VideoEncoderConfig* video_encoder_config,
1618 std::unique_ptr<test::FrameGenerator>* frame_generator) {
1619 if (params->screenshare.enabled) {
1663 // Fill out codec settings. 1620 // Fill out codec settings.
1664 video_encoder_config_.content_type = 1621 video_encoder_config->content_type =
1665 VideoEncoderConfig::ContentType::kScreen; 1622 VideoEncoderConfig::ContentType::kScreen;
1666 degradation_preference_ = 1623 degradation_preference_ =
1667 VideoSendStream::DegradationPreference::kMaintainResolution; 1624 VideoSendStream::DegradationPreference::kMaintainResolution;
1668 if (params_.video.codec == "VP8") { 1625 if (params->video.codec == "VP8") {
1669 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); 1626 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings();
1670 vp8_settings.denoisingOn = false; 1627 vp8_settings.denoisingOn = false;
1671 vp8_settings.frameDroppingOn = false; 1628 vp8_settings.frameDroppingOn = false;
1672 vp8_settings.numberOfTemporalLayers = 1629 vp8_settings.numberOfTemporalLayers =
1673 static_cast<unsigned char>(params_.video.num_temporal_layers); 1630 static_cast<unsigned char>(params->video.num_temporal_layers);
1674 video_encoder_config_.encoder_specific_settings = 1631 video_encoder_config->encoder_specific_settings =
1675 new rtc::RefCountedObject< 1632 new rtc::RefCountedObject<
1676 VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); 1633 VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
1677 } else if (params_.video.codec == "VP9") { 1634 } else if (params->video.codec == "VP9") {
1678 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); 1635 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
1679 vp9_settings.denoisingOn = false; 1636 vp9_settings.denoisingOn = false;
1680 vp9_settings.frameDroppingOn = false; 1637 vp9_settings.frameDroppingOn = false;
1681 vp9_settings.numberOfTemporalLayers = 1638 vp9_settings.numberOfTemporalLayers =
1682 static_cast<unsigned char>(params_.video.num_temporal_layers); 1639 static_cast<unsigned char>(params->video.num_temporal_layers);
1683 vp9_settings.numberOfSpatialLayers = 1640 vp9_settings.numberOfSpatialLayers =
1684 static_cast<unsigned char>(params_.ss.num_spatial_layers); 1641 static_cast<unsigned char>(params->ss.num_spatial_layers);
1685 video_encoder_config_.encoder_specific_settings = 1642 video_encoder_config->encoder_specific_settings =
1686 new rtc::RefCountedObject< 1643 new rtc::RefCountedObject<
1687 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); 1644 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
1688 } 1645 }
1689 // Setup frame generator. 1646 // Setup frame generator.
1690 const size_t kWidth = 1850; 1647 const size_t kWidth = 1850;
1691 const size_t kHeight = 1110; 1648 const size_t kHeight = 1110;
1692 std::vector<std::string> slides = params_.screenshare.slides; 1649 std::vector<std::string> slides = params->screenshare.slides;
1693 if (slides.size() == 0) { 1650 if (slides.size() == 0) {
1694 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv")); 1651 slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
1695 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv")); 1652 slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
1696 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv")); 1653 slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
1697 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv")); 1654 slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
1698 } 1655 }
1699 if (params_.screenshare.scroll_duration == 0) { 1656 if (params->screenshare.scroll_duration == 0) {
1700 // Cycle image every slide_change_interval seconds. 1657 // Cycle image every slide_change_interval seconds.
1701 frame_generator_ = test::FrameGenerator::CreateFromYuvFile( 1658 *frame_generator = test::FrameGenerator::CreateFromYuvFile(
1702 slides, kWidth, kHeight, 1659 slides, kWidth, kHeight,
1703 params_.screenshare.slide_change_interval * params_.video.fps); 1660 params->screenshare.slide_change_interval * params->video.fps);
1704 } else { 1661 } else {
1705 RTC_CHECK_LE(params_.video.width, kWidth); 1662 RTC_CHECK_LE(params->video.width, kWidth);
1706 RTC_CHECK_LE(params_.video.height, kHeight); 1663 RTC_CHECK_LE(params->video.height, kHeight);
1707 RTC_CHECK_GT(params_.screenshare.slide_change_interval, 0); 1664 RTC_CHECK_GT(params->screenshare.slide_change_interval, 0);
1708 const int kPauseDurationMs = (params_.screenshare.slide_change_interval - 1665 const int kPauseDurationMs = (params->screenshare.slide_change_interval -
1709 params_.screenshare.scroll_duration) * 1666 params->screenshare.scroll_duration) *
1710 1000; 1667 1000;
1711 RTC_CHECK_LE(params_.screenshare.scroll_duration, 1668 RTC_CHECK_LE(params->screenshare.scroll_duration,
1712 params_.screenshare.slide_change_interval); 1669 params->screenshare.slide_change_interval);
1713 1670
1714 frame_generator_ = test::FrameGenerator::CreateScrollingInputFromYuvFiles( 1671 *frame_generator = test::FrameGenerator::CreateScrollingInputFromYuvFiles(
1715 clock_, slides, kWidth, kHeight, params_.video.width, 1672 clock_, slides, kWidth, kHeight, params->video.width,
1716 params_.video.height, params_.screenshare.scroll_duration * 1000, 1673 params->video.height, params->screenshare.scroll_duration * 1000,
1717 kPauseDurationMs); 1674 kPauseDurationMs);
1718 } 1675 }
1719 } else if (params_.ss.num_spatial_layers > 1) { // For non-screenshare case. 1676 } else if (params->ss.num_spatial_layers > 1) { // For non-screenshare case.
1720 RTC_CHECK(params_.video.codec == "VP9"); 1677 RTC_CHECK(params->video.codec == "VP9");
1721 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); 1678 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
1722 vp9_settings.numberOfTemporalLayers = 1679 vp9_settings.numberOfTemporalLayers =
1723 static_cast<unsigned char>(params_.video.num_temporal_layers); 1680 static_cast<unsigned char>(params->video.num_temporal_layers);
1724 vp9_settings.numberOfSpatialLayers = 1681 vp9_settings.numberOfSpatialLayers =
1725 static_cast<unsigned char>(params_.ss.num_spatial_layers); 1682 static_cast<unsigned char>(params->ss.num_spatial_layers);
1726 video_encoder_config_.encoder_specific_settings = new rtc::RefCountedObject< 1683 video_encoder_config->encoder_specific_settings = new rtc::RefCountedObject<
1727 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); 1684 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
1728 } 1685 }
1729 } 1686 }
1730 1687
1731 void VideoQualityTest::SetupThumbnailCapturers(size_t num_thumbnail_streams) { 1688 void VideoQualityTest::SetupThumbnailCapturers(size_t num_thumbnail_streams) {
1732 VideoStream thumbnail = DefaultThumbnailStream(); 1689 VideoStream thumbnail = DefaultThumbnailStream();
1733 for (size_t i = 0; i < num_thumbnail_streams; ++i) { 1690 for (size_t i = 0; i < num_thumbnail_streams; ++i) {
1734 thumbnail_capturers_.emplace_back(test::FrameGeneratorCapturer::Create( 1691 thumbnail_capturers_.emplace_back(test::FrameGeneratorCapturer::Create(
1735 static_cast<int>(thumbnail.width), static_cast<int>(thumbnail.height), 1692 static_cast<int>(thumbnail.width), static_cast<int>(thumbnail.height),
1736 thumbnail.max_framerate, clock_)); 1693 thumbnail.max_framerate, clock_));
1737 RTC_DCHECK(thumbnail_capturers_.back()); 1694 RTC_DCHECK(thumbnail_capturers_.back());
1738 } 1695 }
1739 } 1696 }
1740 1697
1741 void VideoQualityTest::CreateCapturer() { 1698 void VideoQualityTest::CreateCapturer(
1742 if (params_.screenshare.enabled) { 1699 Params* params,
1700 std::unique_ptr<test::VideoCapturer>* video_capturer) {
1701 if (params->screenshare.enabled) {
1743 test::FrameGeneratorCapturer* frame_generator_capturer = 1702 test::FrameGeneratorCapturer* frame_generator_capturer =
1744 new test::FrameGeneratorCapturer(clock_, std::move(frame_generator_), 1703 new test::FrameGeneratorCapturer(clock_, std::move(frame_generator_),
1745 params_.video.fps); 1704 params->video.fps);
1746 EXPECT_TRUE(frame_generator_capturer->Init()); 1705 EXPECT_TRUE(frame_generator_capturer->Init());
1747 video_capturer_.reset(frame_generator_capturer); 1706 video_capturer->reset(frame_generator_capturer);
1748 } else { 1707 } else {
1749 if (params_.video.clip_name == "Generator") { 1708 if (params->video.clip_name == "Generator") {
1750 video_capturer_.reset(test::FrameGeneratorCapturer::Create( 1709 video_capturer->reset(test::FrameGeneratorCapturer::Create(
1751 static_cast<int>(params_.video.width), 1710 static_cast<int>(params->video.width),
1752 static_cast<int>(params_.video.height), params_.video.fps, clock_)); 1711 static_cast<int>(params->video.height), params->video.fps, clock_));
1753 } else if (params_.video.clip_name.empty()) { 1712 } else if (params->video.clip_name.empty()) {
1754 video_capturer_.reset(test::VcmCapturer::Create( 1713 video_capturer->reset(test::VcmCapturer::Create(
1755 params_.video.width, params_.video.height, params_.video.fps, 1714 params->video.width, params->video.height, params->video.fps,
1756 params_.video.capture_device_index)); 1715 params->video.capture_device_index));
1757 if (!video_capturer_) { 1716 if (!video_capturer) {
1758 // Failed to get actual camera, use chroma generator as backup. 1717 // Failed to get actual camera, use chroma generator as backup.
1759 video_capturer_.reset(test::FrameGeneratorCapturer::Create( 1718 video_capturer->reset(test::FrameGeneratorCapturer::Create(
1760 static_cast<int>(params_.video.width), 1719 static_cast<int>(params->video.width),
1761 static_cast<int>(params_.video.height), params_.video.fps, clock_)); 1720 static_cast<int>(params->video.height), params->video.fps, clock_));
1762 } 1721 }
1763 } else { 1722 } else {
1764 video_capturer_.reset(test::FrameGeneratorCapturer::CreateFromYuvFile( 1723 video_capturer->reset(test::FrameGeneratorCapturer::CreateFromYuvFile(
1765 test::ResourcePath(params_.video.clip_name, "yuv"), 1724 test::ResourcePath(params->video.clip_name, "yuv"),
1766 params_.video.width, params_.video.height, params_.video.fps, 1725 params->video.width, params->video.height, params->video.fps,
1767 clock_)); 1726 clock_));
1768 ASSERT_TRUE(video_capturer_) << "Could not create capturer for " 1727 ASSERT_TRUE(video_capturer)
1769 << params_.video.clip_name 1728 << "Could not create capturer for " << params->video.clip_name
1770 << ".yuv. Is this resource file present?"; 1729 << ".yuv. Is this resource file present?";
1771 } 1730 }
1772 } 1731 }
1773 RTC_DCHECK(video_capturer_.get()); 1732 RTC_DCHECK(video_capturer->get());
1774 }
1775
1776 void VideoQualityTest::RunWithAnalyzer(const Params& params) {
1777 std::unique_ptr<test::LayerFilteringTransport> send_transport;
1778 std::unique_ptr<test::DirectTransport> recv_transport;
1779 FILE* graph_data_output_file = nullptr;
1780 std::unique_ptr<VideoAnalyzer> analyzer;
1781
1782 params_ = params;
1783
1784 RTC_CHECK(!params_.audio.enabled);
1785 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to
1786 // differentiate between the analyzer and the renderer case.
1787 CheckParams();
1788
1789 if (!params_.analyzer.graph_data_output_filename.empty()) {
1790 graph_data_output_file =
1791 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w");
1792 RTC_CHECK(graph_data_output_file)
1793 << "Can't open the file " << params_.analyzer.graph_data_output_filename
1794 << "!";
1795 }
1796
1797 if (!params.logging.rtc_event_log_name.empty()) {
1798 event_log_ = RtcEventLog::Create(clock_);
1799 bool event_log_started =
1800 event_log_->StartLogging(params.logging.rtc_event_log_name, -1);
1801 RTC_DCHECK(event_log_started);
1802 }
1803
1804 Call::Config call_config(event_log_.get());
1805 call_config.bitrate_config = params.call.call_bitrate_config;
1806
1807 task_queue_.SendTask([this, &call_config, &send_transport,
1808 &recv_transport]() {
1809 CreateCalls(call_config, call_config);
1810
1811 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>(
1812 &task_queue_, params_.pipe, sender_call_.get(), kPayloadTypeVP8,
1813 kPayloadTypeVP9, params_.video.selected_tl, params_.ss.selected_sl,
1814 payload_type_map_);
1815
1816 recv_transport = rtc::MakeUnique<test::DirectTransport>(
1817 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_);
1818 });
1819
1820 std::string graph_title = params_.analyzer.graph_title;
1821 if (graph_title.empty())
1822 graph_title = VideoQualityTest::GenerateGraphTitle();
1823 bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest");
1824 analyzer = rtc::MakeUnique<VideoAnalyzer>(
1825 send_transport.get(), params_.analyzer.test_label,
1826 params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold,
1827 is_quick_test_enabled
1828 ? kFramesSentInQuickTest
1829 : params_.analyzer.test_durations_secs * params_.video.fps,
1830 graph_data_output_file, graph_title,
1831 kVideoSendSsrcs[params_.ss.selected_stream],
1832 kSendRtxSsrcs[params_.ss.selected_stream],
1833 static_cast<size_t>(params_.ss.selected_stream), params.ss.selected_sl,
1834 params_.video.selected_tl, is_quick_test_enabled, clock_,
1835 params_.logging.rtp_dump_name);
1836
1837 task_queue_.SendTask([&]() {
1838 analyzer->SetCall(sender_call_.get());
1839 analyzer->SetReceiver(receiver_call_->Receiver());
1840 send_transport->SetReceiver(analyzer.get());
1841 recv_transport->SetReceiver(sender_call_->Receiver());
1842
1843 SetupVideo(analyzer.get(), recv_transport.get());
1844 SetupThumbnails(analyzer.get(), recv_transport.get());
1845 video_receive_configs_[params_.ss.selected_stream].renderer =
1846 analyzer.get();
1847 video_send_config_.pre_encode_callback = analyzer->pre_encode_proxy();
1848 RTC_DCHECK(!video_send_config_.post_encode_callback);
1849 video_send_config_.post_encode_callback = analyzer->encode_timing_proxy();
1850
1851 SetupScreenshareOrSVC();
1852
1853 CreateFlexfecStreams();
1854 CreateVideoStreams();
1855 analyzer->SetSendStream(video_send_stream_);
1856 if (video_receive_streams_.size() == 1)
1857 analyzer->SetReceiveStream(video_receive_streams_[0]);
1858
1859 video_send_stream_->SetSource(analyzer->OutputInterface(),
1860 degradation_preference_);
1861
1862 SetupThumbnailCapturers(params_.call.num_thumbnails);
1863 for (size_t i = 0; i < thumbnail_send_streams_.size(); ++i) {
1864 thumbnail_send_streams_[i]->SetSource(thumbnail_capturers_[i].get(),
1865 degradation_preference_);
1866 }
1867
1868 CreateCapturer();
1869
1870 analyzer->SetSource(video_capturer_.get(), params_.ss.infer_streams);
1871
1872 StartEncodedFrameLogs(video_send_stream_);
1873 StartEncodedFrameLogs(video_receive_streams_[params_.ss.selected_stream]);
1874 video_send_stream_->Start();
1875 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_)
1876 thumbnail_send_stream->Start();
1877 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1878 receive_stream->Start();
1879 for (VideoReceiveStream* thumbnail_receive_stream :
1880 thumbnail_receive_streams_)
1881 thumbnail_receive_stream->Start();
1882
1883 analyzer->StartMeasuringCpuProcessTime();
1884
1885 video_capturer_->Start();
1886 for (std::unique_ptr<test::VideoCapturer>& video_caputurer :
1887 thumbnail_capturers_) {
1888 video_caputurer->Start();
1889 }
1890 });
1891
1892 analyzer->Wait();
1893
1894 task_queue_.SendTask([&]() {
1895 for (std::unique_ptr<test::VideoCapturer>& video_caputurer :
1896 thumbnail_capturers_)
1897 video_caputurer->Stop();
1898 video_capturer_->Stop();
1899 for (VideoReceiveStream* thumbnail_receive_stream :
1900 thumbnail_receive_streams_)
1901 thumbnail_receive_stream->Stop();
1902 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1903 receive_stream->Stop();
1904 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_)
1905 thumbnail_send_stream->Stop();
1906 video_send_stream_->Stop();
1907
1908 DestroyStreams();
1909 DestroyThumbnailStreams();
1910
1911 event_log_->StopLogging();
1912 if (graph_data_output_file)
1913 fclose(graph_data_output_file);
1914
1915 video_capturer_.reset();
1916 send_transport.reset();
1917 recv_transport.reset();
1918
1919 DestroyCalls();
1920 });
1921 } 1733 }
1922 1734
1923 void VideoQualityTest::SetupAudio(int send_channel_id, 1735 void VideoQualityTest::SetupAudio(int send_channel_id,
1924 int receive_channel_id, 1736 int receive_channel_id,
1925 Transport* transport, 1737 Transport* transport,
1926 AudioReceiveStream** audio_receive_stream) { 1738 AudioReceiveStream** audio_receive_stream) {
1927 audio_send_config_ = AudioSendStream::Config(transport); 1739 // audio_send_config_ = AudioSendStream::Config(transport);
1928 audio_send_config_.voe_channel_id = send_channel_id; 1740 // audio_send_config_.voe_channel_id = send_channel_id;
1929 audio_send_config_.rtp.ssrc = kAudioSendSsrc; 1741 // audio_send_config_.rtp.ssrc = kAudioSendSsrc;
1930 1742
1931 // Add extension to enable audio send side BWE, and allow audio bit rate 1743 // // Add extension to enable audio send side BWE, and allow audio bit rate
1932 // adaptation. 1744 // // adaptation.
1933 audio_send_config_.rtp.extensions.clear(); 1745 // audio_send_config_.rtp.extensions.clear();
1934 if (params_.call.send_side_bwe) { 1746 // if (params_.call.send_side_bwe) {
1935 audio_send_config_.rtp.extensions.push_back( 1747 // audio_send_config_.rtp.extensions.push_back(
1936 webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUri, 1748 // webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUr i,
1937 test::kTransportSequenceNumberExtensionId)); 1749 // test::kTransportSequenceNumberExtensionId));
1938 audio_send_config_.min_bitrate_bps = kOpusMinBitrateBps; 1750 // audio_send_config_.min_bitrate_bps = kOpusMinBitrateBps;
1939 audio_send_config_.max_bitrate_bps = kOpusBitrateFbBps; 1751 // audio_send_config_.max_bitrate_bps = kOpusBitrateFbBps;
1940 } 1752 // }
1941 audio_send_config_.send_codec_spec = 1753 // audio_send_config_.send_codec_spec =
1942 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( 1754 // rtc::Optional<AudioSendStream::Config::SendCodecSpec>(
1943 {kAudioSendPayloadType, 1755 // {kAudioSendPayloadType,
1944 {"OPUS", 48000, 2, 1756 // {"OPUS", 48000, 2,
1945 {{"usedtx", (params_.audio.dtx ? "1" : "0")}, 1757 // {{"usedtx", (params_.audio.dtx ? "1" : "0")},
1946 {"stereo", "1"}}}}); 1758 // {"stereo", "1"}}}});
1947 audio_send_config_.encoder_factory = encoder_factory_; 1759 // audio_send_config_.encoder_factory = encoder_factory_;
1948 audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_); 1760 // audio_send_stream_ =
1949 1761 // sender_call_->CreateAudioSendStream(audio_send_config_);
1950 AudioReceiveStream::Config audio_config; 1762
1951 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; 1763 // AudioReceiveStream::Config audio_config;
1952 audio_config.rtcp_send_transport = transport; 1764 // audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc;
1953 audio_config.voe_channel_id = receive_channel_id; 1765 // audio_config.rtcp_send_transport = transport;
1954 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; 1766 // audio_config.voe_channel_id = receive_channel_id;
1955 audio_config.rtp.transport_cc = params_.call.send_side_bwe; 1767 // audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc;
1956 audio_config.rtp.extensions = audio_send_config_.rtp.extensions; 1768 // audio_config.rtp.transport_cc = params_.call.send_side_bwe;
1957 audio_config.decoder_factory = decoder_factory_; 1769 // audio_config.rtp.extensions = audio_send_config_.rtp.extensions;
1958 audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}}; 1770 // audio_config.decoder_factory = decoder_factory_;
1959 if (params_.video.enabled && params_.audio.sync_video) 1771 // audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}};
1960 audio_config.sync_group = kSyncGroup; 1772 // if (params_.video.enabled && params_.audio.sync_video)
1961 1773 // audio_config.sync_group = kSyncGroup;
1962 *audio_receive_stream = 1774
1963 receiver_call_->CreateAudioReceiveStream(audio_config); 1775 // *audio_receive_stream =
1964 } 1776 // receiver_call_->CreateAudioReceiveStream(audio_config);
1965 1777 }
1966 void VideoQualityTest::RunWithRenderers(const Params& params) { 1778
1967 std::unique_ptr<test::LayerFilteringTransport> send_transport; 1779 void VideoQualityTest::RunWithRenderers() {
1968 std::unique_ptr<test::DirectTransport> recv_transport; 1780 std::vector<std::unique_ptr<test::VideoRenderer>> local_renderers;
1969 ::VoiceEngineState voe; 1781 std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers_;
1970 std::unique_ptr<test::VideoRenderer> local_preview; 1782 std::vector<VideoSendStream::Config> video_send_configs;
1971 std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers; 1783 std::vector<VideoEncoderConfig> video_encoder_configs;
1972 AudioReceiveStream* audio_receive_stream = nullptr; 1784 std::vector<std::unique_ptr<VideoEncoder>> video_encoders;
1973 1785 std::vector<std::vector<VideoReceiveStream::Config>>
1786 video_receive_configs_vector;
1787 std::vector<std::vector<std::unique_ptr<VideoDecoder>>>
1788 allocated_decoders_vector;
1789 std::vector<std::vector<VideoReceiveStream*>> video_receive_streams_vector;
1790 std::vector<std::unique_ptr<test::VideoCapturer>> video_capturers;
1791 std::vector<VideoSendStream*> video_send_streams;
1974 task_queue_.SendTask([&]() { 1792 task_queue_.SendTask([&]() {
1975 params_ = params; 1793 int i = 0;
1976 CheckParams(); 1794 for (Params params : params_) {
1977 1795 if (params.video.enabled) {
1978 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to 1796 // Create video renderers.
1979 // match the full stack tests. 1797 std::stringstream preview_ss;
1980 Call::Config call_config(event_log_.get()); 1798 preview_ss << "Local Preview " << i++;
1981 call_config.bitrate_config = params_.call.call_bitrate_config; 1799 local_renderers.emplace_back(test::VideoRenderer::Create(
1982 1800 preview_ss.str().c_str(), params.video.width, params.video.height));
1983 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing( 1801
1984 webrtc::AudioProcessing::Create()); 1802 const size_t selected_stream_id = params.ss.selected_stream;
1985 1803 const size_t num_streams = params.ss.streams.size();
1986 if (params_.audio.enabled) { 1804
1987 CreateVoiceEngine(&voe, audio_processing.get(), decoder_factory_); 1805 if (selected_stream_id == num_streams) {
1988 AudioState::Config audio_state_config; 1806 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) {
1989 audio_state_config.voice_engine = voe.voice_engine; 1807 std::ostringstream oss;
1990 audio_state_config.audio_mixer = AudioMixerImpl::Create(); 1808 oss << "Loopback Video " << i << ", Stream #"
1991 audio_state_config.audio_processing = audio_processing; 1809 << static_cast<int>(stream_id);
1992 call_config.audio_state = AudioState::Create(audio_state_config); 1810 loopback_renderers_.emplace_back(test::VideoRenderer::Create(
1993 } 1811 oss.str().c_str(), params.ss.streams[stream_id].width,
1994 1812 params.ss.streams[stream_id].height));
1995 CreateCalls(call_config, call_config); 1813 }
1996 1814 } else {
1997 // TODO(minyue): consider if this is a good transport even for audio only 1815 std::stringstream loopback_ss;
1998 // calls. 1816 loopback_ss << "Loopback Video " << i;
1999 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>( 1817 loopback_renderers_.emplace_back(test::VideoRenderer::Create(
2000 &task_queue_, params.pipe, sender_call_.get(), kPayloadTypeVP8, 1818 loopback_ss.str().c_str(),
2001 kPayloadTypeVP9, params.video.selected_tl, params_.ss.selected_sl, 1819 params.ss.streams[selected_stream_id].width,
2002 payload_type_map_); 1820 params.ss.streams[selected_stream_id].height));
2003
2004 recv_transport = rtc::MakeUnique<test::DirectTransport>(
2005 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_);
2006
2007 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at
2008 // least share as much code as possible. That way this test would also match
2009 // the full stack tests better.
2010 send_transport->SetReceiver(receiver_call_->Receiver());
2011 recv_transport->SetReceiver(sender_call_->Receiver());
2012
2013 if (params_.video.enabled) {
2014 // Create video renderers.
2015 local_preview.reset(test::VideoRenderer::Create(
2016 "Local Preview", params_.video.width, params_.video.height));
2017
2018 const size_t selected_stream_id = params_.ss.selected_stream;
2019 const size_t num_streams = params_.ss.streams.size();
2020
2021 if (selected_stream_id == num_streams) {
2022 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) {
2023 std::ostringstream oss;
2024 oss << "Loopback Video - Stream #" << static_cast<int>(stream_id);
2025 loopback_renderers.emplace_back(test::VideoRenderer::Create(
2026 oss.str().c_str(), params_.ss.streams[stream_id].width,
2027 params_.ss.streams[stream_id].height));
2028 } 1821 }
2029 } else { 1822
2030 loopback_renderers.emplace_back(test::VideoRenderer::Create( 1823 video_send_configs.emplace_back(nullptr);
2031 "Loopback Video", params_.ss.streams[selected_stream_id].width, 1824 video_send_configs.back().periodic_alr_bandwidth_probing = true;
2032 params_.ss.streams[selected_stream_id].height)); 1825 video_encoder_configs.emplace_back();
2033 } 1826 video_encoders.emplace_back();
2034 1827 video_receive_configs_vector.emplace_back();
2035 SetupVideo(send_transport.get(), recv_transport.get()); 1828 allocated_decoders_vector.emplace_back();
2036 1829 std::vector<uint32_t> send_ssrcs;
2037 video_send_config_.pre_encode_callback = local_preview.get(); 1830 std::vector<uint32_t> send_rtx_ssrcs;
2038 if (selected_stream_id == num_streams) { 1831 for (size_t i = 0; i < params.ss.streams.size(); ++i) {
2039 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { 1832 send_ssrcs.emplace_back(last_ssrc++);
2040 video_receive_configs_[stream_id].renderer = 1833 send_rtx_ssrcs.emplace_back(last_ssrc++);
2041 loopback_renderers[stream_id].get();
2042 if (params_.audio.enabled && params_.audio.sync_video)
2043 video_receive_configs_[stream_id].sync_group = kSyncGroup;
2044 } 1834 }
2045 } else { 1835 SetupVideo(send_transport_.get(), recv_transport_.get(), &params,
2046 video_receive_configs_[selected_stream_id].renderer = 1836 &video_send_configs.back(), &video_encoder_configs.back(),
2047 loopback_renderers.back().get(); 1837 &video_encoders.back(), &video_receive_configs_vector.back(),
2048 if (params_.audio.enabled && params_.audio.sync_video) 1838 &allocated_decoders_vector.back(), &send_ssrcs,
2049 video_receive_configs_[selected_stream_id].sync_group = kSyncGroup; 1839 &send_rtx_ssrcs);
2050 } 1840
2051 1841 video_send_configs.back().pre_encode_callback =
2052 if (params_.screenshare.enabled) 1842 local_renderers.back().get();
2053 SetupScreenshareOrSVC(); 1843 if (selected_stream_id == num_streams) {
2054 1844 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) {
2055 CreateFlexfecStreams(); 1845 video_receive_configs_vector.back()[stream_id].renderer =
2056 CreateVideoStreams(); 1846 loopback_renderers_[stream_id].get();
2057 1847 if (params.audio.enabled && params.audio.sync_video)
2058 CreateCapturer(); 1848 video_receive_configs_vector.back()[stream_id].sync_group =
2059 video_send_stream_->SetSource(video_capturer_.get(), 1849 kSyncGroup;
2060 degradation_preference_); 1850 }
2061 } 1851 } else {
2062 1852 video_receive_configs_vector.back()[selected_stream_id].renderer =
2063 if (params_.audio.enabled) { 1853 loopback_renderers_.back().get();
2064 SetupAudio(voe.send_channel_id, voe.receive_channel_id, 1854 if (params.audio.enabled && params.audio.sync_video)
2065 send_transport.get(), &audio_receive_stream); 1855 video_receive_configs_vector.back()[selected_stream_id].sync_group =
2066 } 1856 kSyncGroup;
2067 1857 }
2068 for (VideoReceiveStream* receive_stream : video_receive_streams_) 1858
2069 StartEncodedFrameLogs(receive_stream); 1859 if (params.screenshare.enabled)
2070 StartEncodedFrameLogs(video_send_stream_); 1860 SetupScreenshareOrSVC(&params, &video_encoder_configs.back(),
2071 1861 &frame_generator_);
2072 // Start sending and receiving video. 1862
2073 if (params_.video.enabled) { 1863 video_receive_streams_vector.emplace_back();
2074 for (VideoReceiveStream* video_receive_stream : video_receive_streams_) 1864
2075 video_receive_stream->Start(); 1865 video_send_streams.emplace_back(CreateVideoStreams(
2076 1866 sender_call_.get(), receiver_call_.get(),
2077 video_send_stream_->Start(); 1867 &video_send_configs.back(), &video_receive_configs_vector.back(),
2078 video_capturer_->Start(); 1868 &video_receive_streams_vector.back(),
2079 } 1869 &video_encoder_configs.back()));
2080 1870
2081 if (params_.audio.enabled) { 1871 video_capturers.emplace_back();
2082 // Start receiving audio. 1872 CreateCapturer(&params, &video_capturers.back());
2083 audio_receive_stream->Start(); 1873 video_send_streams.back()->SetSource(video_capturers.back().get(),
2084 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); 1874 degradation_preference_);
2085 1875 }
2086 // Start sending audio. 1876
2087 audio_send_stream_->Start(); 1877 RTC_CHECK(!params.audio.enabled);
2088 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id)); 1878
1879 for (VideoReceiveStream* receive_stream :
1880 video_receive_streams_vector.back())
1881 StartEncodedFrameLogs(&params, receive_stream);
1882 StartEncodedFrameLogs(&params, video_send_streams.back());
1883
1884 // Start sending and receiving video.
1885 if (params.video.enabled) {
1886 for (VideoReceiveStream* receive_stream :
1887 video_receive_streams_vector.back())
1888 receive_stream->Start();
1889 video_send_streams.back()->Start();
1890 video_capturers.back()->Start();
1891 }
2089 } 1892 }
2090 }); 1893 });
2091 1894
2092 test::PressEnterToContinue(); 1895 test::PressEnterToContinue();
2093 1896
2094 task_queue_.SendTask([&]() { 1897 task_queue_.SendTask([&]() {
2095 if (params_.audio.enabled) { 1898 for (std::unique_ptr<test::VideoCapturer>& capturer : video_capturers)
2096 // Stop sending audio. 1899 capturer->Stop();
2097 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id)); 1900
2098 audio_send_stream_->Stop(); 1901 for (VideoSendStream* video_send_stream : video_send_streams) {
2099 1902 video_send_stream->Stop();
2100 // Stop receiving audio. 1903 sender_call_->DestroyVideoSendStream(video_send_stream);
2101 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id)); 1904 }
2102 audio_receive_stream->Stop(); 1905
2103 sender_call_->DestroyAudioSendStream(audio_send_stream_); 1906 for (std::vector<VideoReceiveStream*> video_receive_streams :
2104 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); 1907 video_receive_streams_vector) {
2105 } 1908 for (VideoReceiveStream* video_receive_stream : video_receive_streams) {
2106 1909 video_receive_stream->Stop();
2107 // Stop receiving and sending video. 1910 receiver_call_->DestroyVideoReceiveStream(video_receive_stream);
2108 if (params_.video.enabled) { 1911 }
2109 video_capturer_->Stop(); 1912 }
2110 video_send_stream_->Stop(); 1913
2111 for (FlexfecReceiveStream* flexfec_receive_stream : 1914 local_renderers.clear();
2112 flexfec_receive_streams_) { 1915 loopback_renderers_.clear();
2113 for (VideoReceiveStream* video_receive_stream : 1916 video_send_configs.clear();
2114 video_receive_streams_) { 1917 video_encoder_configs.clear();
2115 video_receive_stream->RemoveSecondarySink(flexfec_receive_stream); 1918 video_receive_configs_vector.clear();
2116 } 1919 allocated_decoders_vector.clear();
2117 receiver_call_->DestroyFlexfecReceiveStream(flexfec_receive_stream); 1920 video_receive_streams_vector.clear();
2118 } 1921 video_capturers.clear();
2119 for (VideoReceiveStream* receive_stream : video_receive_streams_) { 1922 video_send_streams.clear();
2120 receive_stream->Stop(); 1923 send_transport_.reset();
2121 receiver_call_->DestroyVideoReceiveStream(receive_stream); 1924 receive_transport_.reset();
2122 } 1925 recv_transport_.reset();
2123 sender_call_->DestroyVideoSendStream(video_send_stream_);
2124 }
2125
2126 video_capturer_.reset(); 1926 video_capturer_.reset();
2127 send_transport.reset();
2128 recv_transport.reset();
2129
2130 if (params_.audio.enabled)
2131 DestroyVoiceEngine(&voe);
2132
2133 local_preview.reset();
2134 loopback_renderers.clear();
2135
2136 DestroyCalls(); 1927 DestroyCalls();
2137 }); 1928 });
2138 } 1929 }
2139 1930
2140 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { 1931 void VideoQualityTest::SetupCall(
2141 if (!params_.logging.encoded_frame_base_path.empty()) { 1932 const Call::Config::BitrateConfig& bitrate_config,
1933 const FakeNetworkPipe::Config& pipe_config) {
1934 // TODO(philipel): Validate bitrate/pipe config.
1935 bitrate_config_ = bitrate_config;
1936 pipe_config_ = pipe_config;
1937
1938 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to
1939 // match the full stack tests.
1940 Call::Config sender_config(event_log_.get());
1941 sender_config.bitrate_config = bitrate_config_;
1942 Call::Config receiver_config(RtcEventLog::CreateNull().release());
1943 receiver_config.bitrate_config = bitrate_config_;
1944
1945 task_queue_.SendTask([&]() {
1946 CreateCalls(sender_config, receiver_config);
1947 send_transport_.reset(new test::DirectTransport(
1948 &task_queue_, pipe_config_, sender_call_.get(), payload_type_map_));
1949 recv_transport_.reset(new test::DirectTransport(
1950 &task_queue_, pipe_config_, receiver_call_.get(), payload_type_map_));
1951
1952 send_transport_->SetReceiver(receiver_call_->Receiver());
1953 recv_transport_->SetReceiver(sender_call_->Receiver());
1954 });
1955 }
1956
1957 void VideoQualityTest::AddParams(const Params& p) {
1958 params_.push_back(p);
1959 CheckParams(&params_.back());
1960 }
1961
1962 void VideoQualityTest::StartEncodedFrameLogs(Params* params,
1963 VideoSendStream* stream) {
1964 if (!params->logging.encoded_frame_base_path.empty()) {
2142 std::ostringstream str; 1965 std::ostringstream str;
2143 str << send_logs_++; 1966 str << send_logs_++;
2144 std::string prefix = 1967 std::string prefix =
2145 params_.logging.encoded_frame_base_path + "." + str.str() + ".send."; 1968 params->logging.encoded_frame_base_path + "." + str.str() + ".send.";
2146 stream->EnableEncodedFrameRecording( 1969 stream->EnableEncodedFrameRecording(
2147 std::vector<rtc::PlatformFile>( 1970 std::vector<rtc::PlatformFile>(
2148 {rtc::CreatePlatformFile(prefix + "1.ivf"), 1971 {rtc::CreatePlatformFile(prefix + "1.ivf"),
2149 rtc::CreatePlatformFile(prefix + "2.ivf"), 1972 rtc::CreatePlatformFile(prefix + "2.ivf"),
2150 rtc::CreatePlatformFile(prefix + "3.ivf")}), 1973 rtc::CreatePlatformFile(prefix + "3.ivf")}),
2151 100000000); 1974 100000000);
2152 } 1975 }
2153 } 1976 }
2154 1977
2155 void VideoQualityTest::StartEncodedFrameLogs(VideoReceiveStream* stream) { 1978 void VideoQualityTest::StartEncodedFrameLogs(Params* params,
2156 if (!params_.logging.encoded_frame_base_path.empty()) { 1979 VideoReceiveStream* stream) {
1980 if (!params->logging.encoded_frame_base_path.empty()) {
2157 std::ostringstream str; 1981 std::ostringstream str;
2158 str << receive_logs_++; 1982 str << receive_logs_++;
2159 std::string path = 1983 std::string path =
2160 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; 1984 params->logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
2161 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), 1985 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path),
2162 100000000); 1986 100000000);
2163 } 1987 }
2164 } 1988 }
2165 } // namespace webrtc 1989 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_quality_test.h ('k') | webrtc/video/vs_loopback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698