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

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

Issue 2946893003: What can't loopback test be more like full stack test? (Closed)
Patch Set: Explicit cast to make win happy Created 3 years, 6 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') | no next file » | 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 constexpr int kPayloadTypeVP9 = 124; 57 constexpr int kPayloadTypeVP9 = 124;
58 58
59 constexpr size_t kMaxComparisons = 10; 59 constexpr size_t kMaxComparisons = 10;
60 constexpr char kSyncGroup[] = "av_sync"; 60 constexpr char kSyncGroup[] = "av_sync";
61 constexpr int kOpusMinBitrateBps = 6000; 61 constexpr int kOpusMinBitrateBps = 6000;
62 constexpr int kOpusBitrateFbBps = 32000; 62 constexpr int kOpusBitrateFbBps = 32000;
63 constexpr int kFramesSentInQuickTest = 1; 63 constexpr int kFramesSentInQuickTest = 1;
64 constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000; 64 constexpr uint32_t kThumbnailSendSsrcStart = 0xE0000;
65 constexpr uint32_t kThumbnailRtxSsrcStart = 0xF0000; 65 constexpr uint32_t kThumbnailRtxSsrcStart = 0xF0000;
66 66
67 constexpr int kDefaultMaxQp = cricket::WebRtcVideoChannel::kDefaultQpMax;
68
67 struct VoiceEngineState { 69 struct VoiceEngineState {
68 VoiceEngineState() 70 VoiceEngineState()
69 : voice_engine(nullptr), 71 : voice_engine(nullptr),
70 base(nullptr), 72 base(nullptr),
71 send_channel_id(-1), 73 send_channel_id(-1),
72 receive_channel_id(-1) {} 74 receive_channel_id(-1) {}
73 75
74 webrtc::VoiceEngine* voice_engine; 76 webrtc::VoiceEngine* voice_engine;
75 webrtc::VoEBase* base; 77 webrtc::VoEBase* base;
76 int send_channel_id; 78 int send_channel_id;
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 RTC_CHECK(params_.video.selected_tl == -1 || 1119 RTC_CHECK(params_.video.selected_tl == -1 ||
1118 params_.video.selected_tl == 1120 params_.video.selected_tl ==
1119 params_.video.num_temporal_layers - 1); 1121 params_.video.num_temporal_layers - 1);
1120 } 1122 }
1121 1123
1122 // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as it 1124 // TODO(ivica): Should max_bitrate_bps == -1 represent inf max bitrate, as it
1123 // does in some parts of the code? 1125 // does in some parts of the code?
1124 RTC_CHECK_GE(params_.video.max_bitrate_bps, params_.video.target_bitrate_bps); 1126 RTC_CHECK_GE(params_.video.max_bitrate_bps, params_.video.target_bitrate_bps);
1125 RTC_CHECK_GE(params_.video.target_bitrate_bps, params_.video.min_bitrate_bps); 1127 RTC_CHECK_GE(params_.video.target_bitrate_bps, params_.video.min_bitrate_bps);
1126 RTC_CHECK_LT(params_.video.selected_tl, params_.video.num_temporal_layers); 1128 RTC_CHECK_LT(params_.video.selected_tl, params_.video.num_temporal_layers);
1127 RTC_CHECK_LT(params_.ss.selected_stream, params_.ss.streams.size()); 1129 RTC_CHECK_LE(params_.ss.selected_stream, params_.ss.streams.size());
1128 for (const VideoStream& stream : params_.ss.streams) { 1130 for (const VideoStream& stream : params_.ss.streams) {
1129 RTC_CHECK_GE(stream.min_bitrate_bps, 0); 1131 RTC_CHECK_GE(stream.min_bitrate_bps, 0);
1130 RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps); 1132 RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps);
1131 RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps); 1133 RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps);
1132 RTC_CHECK_LE(stream.temporal_layer_thresholds_bps.size(),
1133 params_.video.num_temporal_layers - 1);
1134 } 1134 }
1135 // TODO(ivica): Should we check if the sum of all streams/layers is equal to 1135 // TODO(ivica): Should we check if the sum of all streams/layers is equal to
1136 // the total bitrate? We anyway have to update them in the case bitrate 1136 // the total bitrate? We anyway have to update them in the case bitrate
1137 // estimator changes the total bitrates. 1137 // estimator changes the total bitrates.
1138 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1); 1138 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1);
1139 RTC_CHECK_LE(params_.ss.selected_sl, params_.ss.num_spatial_layers); 1139 RTC_CHECK_LE(params_.ss.selected_sl, params_.ss.num_spatial_layers);
1140 RTC_CHECK(params_.ss.spatial_layers.empty() || 1140 RTC_CHECK(params_.ss.spatial_layers.empty() ||
1141 params_.ss.spatial_layers.size() == 1141 params_.ss.spatial_layers.size() ==
1142 static_cast<size_t>(params_.ss.num_spatial_layers)); 1142 static_cast<size_t>(params_.ss.num_spatial_layers));
1143 if (params_.video.codec == "VP8") { 1143 if (params_.video.codec == "VP8") {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1184
1185 // Static. 1185 // Static.
1186 VideoStream VideoQualityTest::DefaultVideoStream(const Params& params) { 1186 VideoStream VideoQualityTest::DefaultVideoStream(const Params& params) {
1187 VideoStream stream; 1187 VideoStream stream;
1188 stream.width = params.video.width; 1188 stream.width = params.video.width;
1189 stream.height = params.video.height; 1189 stream.height = params.video.height;
1190 stream.max_framerate = params.video.fps; 1190 stream.max_framerate = params.video.fps;
1191 stream.min_bitrate_bps = params.video.min_bitrate_bps; 1191 stream.min_bitrate_bps = params.video.min_bitrate_bps;
1192 stream.target_bitrate_bps = params.video.target_bitrate_bps; 1192 stream.target_bitrate_bps = params.video.target_bitrate_bps;
1193 stream.max_bitrate_bps = params.video.max_bitrate_bps; 1193 stream.max_bitrate_bps = params.video.max_bitrate_bps;
1194 stream.max_qp = cricket::WebRtcVideoChannel::kDefaultQpMax; 1194 stream.max_qp = kDefaultMaxQp;
1195 // TODO(sprang): Can we make this less of a hack? 1195 // TODO(sprang): Can we make this less of a hack?
1196 if (params.video.num_temporal_layers == 2) { 1196 if (params.video.num_temporal_layers == 2) {
1197 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps); 1197 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps);
1198 } else if (params.video.num_temporal_layers == 3) { 1198 } else if (params.video.num_temporal_layers == 3) {
1199 stream.temporal_layer_thresholds_bps.push_back(stream.max_bitrate_bps / 4); 1199 stream.temporal_layer_thresholds_bps.push_back(stream.max_bitrate_bps / 4);
1200 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps); 1200 stream.temporal_layer_thresholds_bps.push_back(stream.target_bitrate_bps);
1201 } 1201 }
1202 return stream; 1202 return stream;
1203 } 1203 }
1204 1204
1205 // Static. 1205 // Static.
1206 VideoStream VideoQualityTest::DefaultThumbnailStream() { 1206 VideoStream VideoQualityTest::DefaultThumbnailStream() {
1207 VideoStream stream; 1207 VideoStream stream;
1208 stream.width = 320; 1208 stream.width = 320;
1209 stream.height = 180; 1209 stream.height = 180;
1210 stream.max_framerate = 7; 1210 stream.max_framerate = 7;
1211 stream.min_bitrate_bps = 7500; 1211 stream.min_bitrate_bps = 7500;
1212 stream.target_bitrate_bps = 37500; 1212 stream.target_bitrate_bps = 37500;
1213 stream.max_bitrate_bps = 50000; 1213 stream.max_bitrate_bps = 50000;
1214 stream.max_qp = cricket::WebRtcVideoChannel::kDefaultQpMax; 1214 stream.max_qp = kDefaultMaxQp;
1215 return stream; 1215 return stream;
1216 } 1216 }
1217 1217
1218 // Static. 1218 // Static.
1219 void VideoQualityTest::FillScalabilitySettings( 1219 void VideoQualityTest::FillScalabilitySettings(
1220 Params* params, 1220 Params* params,
1221 const std::vector<std::string>& stream_descriptors, 1221 const std::vector<std::string>& stream_descriptors,
1222 int num_streams,
1222 size_t selected_stream, 1223 size_t selected_stream,
1223 int num_spatial_layers, 1224 int num_spatial_layers,
1224 int selected_sl, 1225 int selected_sl,
1225 const std::vector<std::string>& sl_descriptors) { 1226 const std::vector<std::string>& sl_descriptors) {
1226 // Read VideoStream and SpatialLayer elements from a list of comma separated 1227 if (params->ss.streams.empty() && params->ss.infer_streams) {
1227 // lists. To use a default value for an element, use -1 or leave empty. 1228 webrtc::VideoEncoderConfig encoder_config;
1228 // Validity checks performed in CheckParams. 1229 encoder_config.content_type =
1230 params->screenshare.enabled
1231 ? webrtc::VideoEncoderConfig::ContentType::kScreen
1232 : webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;
1233 encoder_config.max_bitrate_bps = params->video.max_bitrate_bps;
1234 encoder_config.min_transmit_bitrate_bps = params->video.min_transmit_bps;
1235 encoder_config.number_of_streams = num_streams;
1236 encoder_config.spatial_layers = params->ss.spatial_layers;
1237 encoder_config.video_stream_factory =
1238 new rtc::RefCountedObject<cricket::EncoderStreamFactory>(
1239 params->video.codec, kDefaultMaxQp, params->video.fps,
1240 params->screenshare.enabled, true);
1241 params->ss.streams =
1242 encoder_config.video_stream_factory->CreateEncoderStreams(
1243 static_cast<int>(params->video.width),
1244 static_cast<int>(params->video.height), encoder_config);
1245 } else {
1246 // Read VideoStream and SpatialLayer elements from a list of comma separated
1247 // lists. To use a default value for an element, use -1 or leave empty.
1248 // Validity checks performed in CheckParams.
1249 RTC_CHECK(params->ss.streams.empty());
1250 for (auto descriptor : stream_descriptors) {
1251 if (descriptor.empty())
1252 continue;
1253 VideoStream stream = VideoQualityTest::DefaultVideoStream(*params);
1254 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor);
1255 if (v[0] != -1)
1256 stream.width = static_cast<size_t>(v[0]);
1257 if (v[1] != -1)
1258 stream.height = static_cast<size_t>(v[1]);
1259 if (v[2] != -1)
1260 stream.max_framerate = v[2];
1261 if (v[3] != -1)
1262 stream.min_bitrate_bps = v[3];
1263 if (v[4] != -1)
1264 stream.target_bitrate_bps = v[4];
1265 if (v[5] != -1)
1266 stream.max_bitrate_bps = v[5];
1267 if (v.size() > 6 && v[6] != -1)
1268 stream.max_qp = v[6];
1269 if (v.size() > 7) {
1270 stream.temporal_layer_thresholds_bps.clear();
1271 stream.temporal_layer_thresholds_bps.insert(
1272 stream.temporal_layer_thresholds_bps.end(), v.begin() + 7, v.end());
1273 } else {
1274 // Automatic TL thresholds for more than two layers not supported.
1275 RTC_CHECK_LE(params->video.num_temporal_layers, 2);
1276 }
1277 params->ss.streams.push_back(stream);
1278 }
1279 }
1229 1280
1230 RTC_CHECK(params->ss.streams.empty()); 1281 params->ss.num_spatial_layers = std::max(1, num_spatial_layers);
1231 for (auto descriptor : stream_descriptors) {
1232 if (descriptor.empty())
1233 continue;
1234 VideoStream stream = VideoQualityTest::DefaultVideoStream(*params);
1235 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor);
1236 if (v[0] != -1)
1237 stream.width = static_cast<size_t>(v[0]);
1238 if (v[1] != -1)
1239 stream.height = static_cast<size_t>(v[1]);
1240 if (v[2] != -1)
1241 stream.max_framerate = v[2];
1242 if (v[3] != -1)
1243 stream.min_bitrate_bps = v[3];
1244 if (v[4] != -1)
1245 stream.target_bitrate_bps = v[4];
1246 if (v[5] != -1)
1247 stream.max_bitrate_bps = v[5];
1248 if (v.size() > 6 && v[6] != -1)
1249 stream.max_qp = v[6];
1250 if (v.size() > 7) {
1251 stream.temporal_layer_thresholds_bps.clear();
1252 stream.temporal_layer_thresholds_bps.insert(
1253 stream.temporal_layer_thresholds_bps.end(), v.begin() + 7, v.end());
1254 } else {
1255 // Automatic TL thresholds for more than two layers not supported.
1256 RTC_CHECK_LE(params->video.num_temporal_layers, 2);
1257 }
1258 params->ss.streams.push_back(stream);
1259 }
1260 params->ss.selected_stream = selected_stream; 1282 params->ss.selected_stream = selected_stream;
1261 params->ss.infer_streams = false;
1262 1283
1263 params->ss.num_spatial_layers = num_spatial_layers ? num_spatial_layers : 1;
1264 params->ss.selected_sl = selected_sl; 1284 params->ss.selected_sl = selected_sl;
1265 RTC_CHECK(params->ss.spatial_layers.empty()); 1285 RTC_CHECK(params->ss.spatial_layers.empty());
1266 for (auto descriptor : sl_descriptors) { 1286 for (auto descriptor : sl_descriptors) {
1267 if (descriptor.empty()) 1287 if (descriptor.empty())
1268 continue; 1288 continue;
1269 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor); 1289 std::vector<int> v = VideoQualityTest::ParseCSV(descriptor);
1270 RTC_CHECK_GT(v[2], 0); 1290 RTC_CHECK_GT(v[2], 0);
1271 1291
1272 SpatialLayer layer; 1292 SpatialLayer layer;
1273 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0]; 1293 layer.scaling_factor_num = v[0] == -1 ? 1 : v[0];
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 params_.video.fps, params_.screenshare.enabled, true); 1369 params_.video.fps, params_.screenshare.enabled, true);
1350 } else { 1370 } else {
1351 video_encoder_config_.video_stream_factory = 1371 video_encoder_config_.video_stream_factory =
1352 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams); 1372 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams);
1353 } 1373 }
1354 1374
1355 video_encoder_config_.spatial_layers = params_.ss.spatial_layers; 1375 video_encoder_config_.spatial_layers = params_.ss.spatial_layers;
1356 1376
1357 CreateMatchingReceiveConfigs(recv_transport); 1377 CreateMatchingReceiveConfigs(recv_transport);
1358 1378
1379 const bool decode_all_receive_streams =
1380 params_.ss.selected_stream == params_.ss.streams.size();
1381
1359 for (size_t i = 0; i < num_video_streams; ++i) { 1382 for (size_t i = 0; i < num_video_streams; ++i) {
1360 video_receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; 1383 video_receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
1361 video_receive_configs_[i].rtp.rtx_ssrc = kSendRtxSsrcs[i]; 1384 video_receive_configs_[i].rtp.rtx_ssrc = kSendRtxSsrcs[i];
1362 video_receive_configs_[i].rtp.rtx_payload_types[payload_type] = 1385 video_receive_configs_[i].rtp.rtx_payload_types[payload_type] =
1363 kSendRtxPayloadType; 1386 kSendRtxPayloadType;
1364 video_receive_configs_[i].rtp.transport_cc = params_.call.send_side_bwe; 1387 video_receive_configs_[i].rtp.transport_cc = params_.call.send_side_bwe;
1365 video_receive_configs_[i].rtp.remb = !params_.call.send_side_bwe; 1388 video_receive_configs_[i].rtp.remb = !params_.call.send_side_bwe;
1366 // Enable RTT calculation so NTP time estimator will work. 1389 // Enable RTT calculation so NTP time estimator will work.
1367 video_receive_configs_[i].rtp.rtcp_xr.receiver_reference_time_report = true; 1390 video_receive_configs_[i].rtp.rtcp_xr.receiver_reference_time_report = true;
1368 // Force fake decoders on non-selected simulcast streams. 1391 // Force fake decoders on non-selected simulcast streams.
1369 if (i != params_.ss.selected_stream) { 1392 if (!decode_all_receive_streams && i != params_.ss.selected_stream) {
1370 VideoReceiveStream::Decoder decoder; 1393 VideoReceiveStream::Decoder decoder;
1371 decoder.decoder = new test::FakeDecoder(); 1394 decoder.decoder = new test::FakeDecoder();
1372 decoder.payload_type = video_send_config_.encoder_settings.payload_type; 1395 decoder.payload_type = video_send_config_.encoder_settings.payload_type;
1373 decoder.payload_name = video_send_config_.encoder_settings.payload_name; 1396 decoder.payload_name = video_send_config_.encoder_settings.payload_name;
1374 video_receive_configs_[i].decoders.clear(); 1397 video_receive_configs_[i].decoders.clear();
1375 allocated_decoders_.emplace_back(decoder.decoder); 1398 allocated_decoders_.emplace_back(decoder.decoder);
1376 video_receive_configs_[i].decoders.push_back(decoder); 1399 video_receive_configs_[i].decoders.push_back(decoder);
1377 } 1400 }
1378 } 1401 }
1379 1402
1380 if (params_.video.flexfec) { 1403 if (params_.video.flexfec) {
1381 // Override send config constructed by CreateSendConfig. 1404 // Override send config constructed by CreateSendConfig.
1382 video_send_config_.rtp.flexfec.protected_media_ssrcs = { 1405 if (decode_all_receive_streams) {
1383 kVideoSendSsrcs[params_.ss.selected_stream]}; 1406 for (uint32_t media_ssrc : video_send_config_.rtp.ssrcs) {
1407 video_send_config_.rtp.flexfec.protected_media_ssrcs.push_back(
1408 media_ssrc);
1409 }
1410 } else {
1411 video_send_config_.rtp.flexfec.protected_media_ssrcs = {
1412 kVideoSendSsrcs[params_.ss.selected_stream]};
1413 }
1384 1414
1385 // The matching receive config is _not_ created by 1415 // The matching receive config is _not_ created by
1386 // CreateMatchingReceiveConfigs, since VideoQualityTest is not a BaseTest. 1416 // CreateMatchingReceiveConfigs, since VideoQualityTest is not a BaseTest.
1387 // Set up the receive config manually instead. 1417 // Set up the receive config manually instead.
1388 FlexfecReceiveStream::Config flexfec_receive_config(recv_transport); 1418 FlexfecReceiveStream::Config flexfec_receive_config(recv_transport);
1389 flexfec_receive_config.payload_type = 1419 flexfec_receive_config.payload_type =
1390 video_send_config_.rtp.flexfec.payload_type; 1420 video_send_config_.rtp.flexfec.payload_type;
1391 flexfec_receive_config.remote_ssrc = video_send_config_.rtp.flexfec.ssrc; 1421 flexfec_receive_config.remote_ssrc = video_send_config_.rtp.flexfec.ssrc;
1392 flexfec_receive_config.protected_media_ssrcs = 1422 flexfec_receive_config.protected_media_ssrcs =
1393 video_send_config_.rtp.flexfec.protected_media_ssrcs; 1423 video_send_config_.rtp.flexfec.protected_media_ssrcs;
1394 flexfec_receive_config.local_ssrc = kReceiverLocalVideoSsrc; 1424 flexfec_receive_config.local_ssrc = kReceiverLocalVideoSsrc;
1395 flexfec_receive_config.transport_cc = params_.call.send_side_bwe; 1425 flexfec_receive_config.transport_cc = params_.call.send_side_bwe;
1396 if (params_.call.send_side_bwe) { 1426 if (params_.call.send_side_bwe) {
1397 flexfec_receive_config.rtp_header_extensions.push_back( 1427 flexfec_receive_config.rtp_header_extensions.push_back(
1398 RtpExtension(RtpExtension::kTransportSequenceNumberUri, 1428 RtpExtension(RtpExtension::kTransportSequenceNumberUri,
1399 test::kTransportSequenceNumberExtensionId)); 1429 test::kTransportSequenceNumberExtensionId));
1400 } else { 1430 } else {
1401 flexfec_receive_config.rtp_header_extensions.push_back(RtpExtension( 1431 flexfec_receive_config.rtp_header_extensions.push_back(RtpExtension(
1402 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); 1432 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
1403 } 1433 }
1404 flexfec_receive_configs_.push_back(flexfec_receive_config); 1434 flexfec_receive_configs_.push_back(flexfec_receive_config);
1405 } 1435 }
1406 1436
1407 if (params_.video.ulpfec) { 1437 if (params_.video.ulpfec) {
1408 video_send_config_.rtp.ulpfec.red_payload_type = kRedPayloadType; 1438 video_send_config_.rtp.ulpfec.red_payload_type = kRedPayloadType;
1409 video_send_config_.rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; 1439 video_send_config_.rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType;
1410 video_send_config_.rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType; 1440 video_send_config_.rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType;
1411 1441
1412 video_receive_configs_[params_.ss.selected_stream] 1442 if (decode_all_receive_streams) {
1413 .rtp.ulpfec.red_payload_type = 1443 for (auto it = video_receive_configs_.begin();
1414 video_send_config_.rtp.ulpfec.red_payload_type; 1444 it != video_receive_configs_.end(); ++it) {
1415 video_receive_configs_[params_.ss.selected_stream] 1445 it->rtp.ulpfec.red_payload_type =
1416 .rtp.ulpfec.ulpfec_payload_type = 1446 video_send_config_.rtp.ulpfec.red_payload_type;
1417 video_send_config_.rtp.ulpfec.ulpfec_payload_type; 1447 it->rtp.ulpfec.ulpfec_payload_type =
1418 video_receive_configs_[params_.ss.selected_stream] 1448 video_send_config_.rtp.ulpfec.ulpfec_payload_type;
1419 .rtp.ulpfec.red_rtx_payload_type = 1449 it->rtp.ulpfec.red_rtx_payload_type =
1420 video_send_config_.rtp.ulpfec.red_rtx_payload_type; 1450 video_send_config_.rtp.ulpfec.red_rtx_payload_type;
1451 }
1452 } else {
1453 video_receive_configs_[params_.ss.selected_stream]
1454 .rtp.ulpfec.red_payload_type =
1455 video_send_config_.rtp.ulpfec.red_payload_type;
1456 video_receive_configs_[params_.ss.selected_stream]
1457 .rtp.ulpfec.ulpfec_payload_type =
1458 video_send_config_.rtp.ulpfec.ulpfec_payload_type;
1459 video_receive_configs_[params_.ss.selected_stream]
1460 .rtp.ulpfec.red_rtx_payload_type =
1461 video_send_config_.rtp.ulpfec.red_rtx_payload_type;
1462 }
1421 } 1463 }
1422 } 1464 }
1423 1465
1424 void VideoQualityTest::SetupThumbnails(Transport* send_transport, 1466 void VideoQualityTest::SetupThumbnails(Transport* send_transport,
1425 Transport* recv_transport) { 1467 Transport* recv_transport) {
1426 for (int i = 0; i < params_.num_thumbnails; ++i) { 1468 for (int i = 0; i < params_.num_thumbnails; ++i) {
1427 thumbnail_encoders_.emplace_back(VP8Encoder::Create()); 1469 thumbnail_encoders_.emplace_back(VP8Encoder::Create());
1428 1470
1429 // Thumbnails will be send in the other way: from receiver_call to 1471 // Thumbnails will be send in the other way: from receiver_call to
1430 // sender_call. 1472 // sender_call.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 1789
1748 DestroyStreams(); 1790 DestroyStreams();
1749 DestroyThumbnailStreams(); 1791 DestroyThumbnailStreams();
1750 1792
1751 if (graph_data_output_file) 1793 if (graph_data_output_file)
1752 fclose(graph_data_output_file); 1794 fclose(graph_data_output_file);
1753 } 1795 }
1754 1796
1755 void VideoQualityTest::SetupAudio(int send_channel_id, 1797 void VideoQualityTest::SetupAudio(int send_channel_id,
1756 int receive_channel_id, 1798 int receive_channel_id,
1757 Call* call,
1758 Transport* transport, 1799 Transport* transport,
1759 AudioReceiveStream** audio_receive_stream) { 1800 AudioReceiveStream** audio_receive_stream) {
1760 audio_send_config_ = AudioSendStream::Config(transport); 1801 audio_send_config_ = AudioSendStream::Config(transport);
1761 audio_send_config_.voe_channel_id = send_channel_id; 1802 audio_send_config_.voe_channel_id = send_channel_id;
1762 audio_send_config_.rtp.ssrc = kAudioSendSsrc; 1803 audio_send_config_.rtp.ssrc = kAudioSendSsrc;
1763 1804
1764 // Add extension to enable audio send side BWE, and allow audio bit rate 1805 // Add extension to enable audio send side BWE, and allow audio bit rate
1765 // adaptation. 1806 // adaptation.
1766 audio_send_config_.rtp.extensions.clear(); 1807 audio_send_config_.rtp.extensions.clear();
1767 if (params_.call.send_side_bwe) { 1808 if (params_.call.send_side_bwe) {
1768 audio_send_config_.rtp.extensions.push_back( 1809 audio_send_config_.rtp.extensions.push_back(
1769 webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUri, 1810 webrtc::RtpExtension(webrtc::RtpExtension::kTransportSequenceNumberUri,
1770 test::kTransportSequenceNumberExtensionId)); 1811 test::kTransportSequenceNumberExtensionId));
1771 audio_send_config_.min_bitrate_bps = kOpusMinBitrateBps; 1812 audio_send_config_.min_bitrate_bps = kOpusMinBitrateBps;
1772 audio_send_config_.max_bitrate_bps = kOpusBitrateFbBps; 1813 audio_send_config_.max_bitrate_bps = kOpusBitrateFbBps;
1773 } 1814 }
1774 audio_send_config_.send_codec_spec = 1815 audio_send_config_.send_codec_spec =
1775 rtc::Optional<AudioSendStream::Config::SendCodecSpec>( 1816 rtc::Optional<AudioSendStream::Config::SendCodecSpec>(
1776 {kAudioSendPayloadType, 1817 {kAudioSendPayloadType,
1777 {"OPUS", 48000, 2, 1818 {"OPUS", 48000, 2,
1778 {{"usedtx", (params_.audio.dtx ? "1" : "0")}, 1819 {{"usedtx", (params_.audio.dtx ? "1" : "0")},
1779 {"stereo", "1"}}}}); 1820 {"stereo", "1"}}}});
1780 audio_send_config_.encoder_factory = encoder_factory_; 1821 audio_send_config_.encoder_factory = encoder_factory_;
1781 audio_send_stream_ = call->CreateAudioSendStream(audio_send_config_); 1822 audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_);
1782 1823
1783 AudioReceiveStream::Config audio_config; 1824 AudioReceiveStream::Config audio_config;
1784 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; 1825 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc;
1785 audio_config.rtcp_send_transport = transport; 1826 audio_config.rtcp_send_transport = transport;
1786 audio_config.voe_channel_id = receive_channel_id; 1827 audio_config.voe_channel_id = receive_channel_id;
1787 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; 1828 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc;
1788 audio_config.rtp.transport_cc = params_.call.send_side_bwe; 1829 audio_config.rtp.transport_cc = params_.call.send_side_bwe;
1789 audio_config.rtp.extensions = audio_send_config_.rtp.extensions; 1830 audio_config.rtp.extensions = audio_send_config_.rtp.extensions;
1790 audio_config.decoder_factory = decoder_factory_; 1831 audio_config.decoder_factory = decoder_factory_;
1791 audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}}; 1832 audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}};
1792 if (params_.video.enabled && params_.audio.sync_video) 1833 if (params_.video.enabled && params_.audio.sync_video)
1793 audio_config.sync_group = kSyncGroup; 1834 audio_config.sync_group = kSyncGroup;
1794 1835
1795 *audio_receive_stream = call->CreateAudioReceiveStream(audio_config); 1836 *audio_receive_stream =
1837 receiver_call_->CreateAudioReceiveStream(audio_config);
1796 } 1838 }
1797 1839
1798 void VideoQualityTest::RunWithRenderers(const Params& params) { 1840 void VideoQualityTest::RunWithRenderers(const Params& params) {
1799 params_ = params; 1841 params_ = params;
1800 CheckParams(); 1842 CheckParams();
1801 1843
1802 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to 1844 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to
1803 // match the full stack tests. 1845 // match the full stack tests.
1804 Call::Config call_config(event_log_.get()); 1846 Call::Config call_config(event_log_.get());
1805 call_config.bitrate_config = params_.call.call_bitrate_config; 1847 call_config.bitrate_config = params_.call.call_bitrate_config;
1806 1848
1807 ::VoiceEngineState voe; 1849 ::VoiceEngineState voe;
1808 if (params_.audio.enabled) { 1850 if (params_.audio.enabled) {
1809 CreateVoiceEngine(&voe, decoder_factory_); 1851 CreateVoiceEngine(&voe, decoder_factory_);
1810 AudioState::Config audio_state_config; 1852 AudioState::Config audio_state_config;
1811 audio_state_config.voice_engine = voe.voice_engine; 1853 audio_state_config.voice_engine = voe.voice_engine;
1812 audio_state_config.audio_mixer = AudioMixerImpl::Create(); 1854 audio_state_config.audio_mixer = AudioMixerImpl::Create();
1813 call_config.audio_state = AudioState::Create(audio_state_config); 1855 call_config.audio_state = AudioState::Create(audio_state_config);
1814 } 1856 }
1815 1857
1816 std::unique_ptr<Call> call(Call::Create(call_config)); 1858 CreateCalls(call_config, call_config);
1817 1859
1818 // TODO(minyue): consider if this is a good transport even for audio only 1860 // TODO(minyue): consider if this is a good transport even for audio only
1819 // calls. 1861 // calls.
1820 test::LayerFilteringTransport transport( 1862 test::LayerFilteringTransport send_transport(
1821 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, 1863 params.pipe, sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9,
1822 params.video.selected_tl, params_.ss.selected_sl, payload_type_map_); 1864 params.video.selected_tl, params_.ss.selected_sl, payload_type_map_);
1823 1865
1866 test::DirectTransport recv_transport(params_.pipe, receiver_call_.get(),
1867 payload_type_map_);
1868
1824 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at 1869 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at
1825 // least share as much code as possible. That way this test would also match 1870 // least share as much code as possible. That way this test would also match
1826 // the full stack tests better. 1871 // the full stack tests better.
1827 transport.SetReceiver(call->Receiver()); 1872 send_transport.SetReceiver(receiver_call_->Receiver());
1873 recv_transport.SetReceiver(sender_call_->Receiver());
1828 1874
1829 VideoReceiveStream* video_receive_stream = nullptr;
1830 FlexfecReceiveStream* flexfec_receive_stream = nullptr; 1875 FlexfecReceiveStream* flexfec_receive_stream = nullptr;
1831 std::unique_ptr<test::VideoRenderer> local_preview; 1876 std::unique_ptr<test::VideoRenderer> local_preview;
1832 std::unique_ptr<test::VideoRenderer> loopback_video; 1877 std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers_;
1833 if (params_.video.enabled) { 1878 if (params_.video.enabled) {
1834 // Create video renderers. 1879 // Create video renderers.
1835 local_preview.reset(test::VideoRenderer::Create( 1880 local_preview.reset(test::VideoRenderer::Create(
1836 "Local Preview", params_.video.width, params_.video.height)); 1881 "Local Preview", params_.video.width, params_.video.height));
1837 1882
1838 size_t stream_id = params_.ss.selected_stream; 1883 const size_t selected_stream_id = params_.ss.selected_stream;
1839 std::string title = "Loopback Video"; 1884 const size_t num_streams = params_.ss.streams.size();
1840 if (params_.ss.streams.size() > 1) { 1885
1841 std::ostringstream s; 1886 if (selected_stream_id == num_streams) {
1842 s << stream_id; 1887 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) {
1843 title += " - Stream #" + s.str(); 1888 std::ostringstream oss;
1889 oss << "Loopback Video - Stream #" << static_cast<int>(stream_id);
1890 loopback_renderers_.emplace_back(test::VideoRenderer::Create(
1891 oss.str().c_str(), params_.ss.streams[stream_id].width,
1892 params_.ss.streams[stream_id].height));
1893 }
1894 } else {
1895 loopback_renderers_.emplace_back(test::VideoRenderer::Create(
1896 "Loopback Video", params_.ss.streams[selected_stream_id].width,
1897 params_.ss.streams[selected_stream_id].height));
1844 } 1898 }
1845 1899
1846 loopback_video.reset(test::VideoRenderer::Create( 1900 SetupVideo(&send_transport, &recv_transport);
1847 title.c_str(), params_.ss.streams[stream_id].width,
1848 params_.ss.streams[stream_id].height));
1849 1901
1850 SetupVideo(&transport, &transport);
1851 video_send_config_.pre_encode_callback = local_preview.get(); 1902 video_send_config_.pre_encode_callback = local_preview.get();
1852 video_receive_configs_[stream_id].renderer = loopback_video.get(); 1903 if (selected_stream_id == num_streams) {
1853 if (params_.audio.enabled && params_.audio.sync_video) 1904 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) {
1854 video_receive_configs_[stream_id].sync_group = kSyncGroup; 1905 video_receive_configs_[stream_id].renderer =
1906 loopback_renderers_[stream_id].get();
1907 if (params_.audio.enabled && params_.audio.sync_video)
1908 video_receive_configs_[stream_id].sync_group = kSyncGroup;
1909 }
1910 } else {
1911 video_receive_configs_[selected_stream_id].renderer =
1912 loopback_renderers_.back().get();
1913 if (params_.audio.enabled && params_.audio.sync_video)
1914 video_receive_configs_[selected_stream_id].sync_group = kSyncGroup;
1915 }
1855 1916
1856 if (params_.screenshare.enabled) 1917 if (params_.screenshare.enabled)
1857 SetupScreenshareOrSVC(); 1918 SetupScreenshareOrSVC();
1858 1919
1859 video_send_stream_ = call->CreateVideoSendStream( 1920 CreateFlexfecStreams();
1860 video_send_config_.Copy(), video_encoder_config_.Copy()); 1921 CreateVideoStreams();
1861 if (params_.video.flexfec) { 1922
1862 RTC_DCHECK(!flexfec_receive_configs_.empty());
1863 flexfec_receive_stream =
1864 call->CreateFlexfecReceiveStream(flexfec_receive_configs_[0]);
1865 }
1866 video_receive_stream = call->CreateVideoReceiveStream(
1867 video_receive_configs_[stream_id].Copy());
1868 CreateCapturer(); 1923 CreateCapturer();
1869 video_send_stream_->SetSource(video_capturer_.get(), 1924 video_send_stream_->SetSource(video_capturer_.get(),
1870 degradation_preference_); 1925 degradation_preference_);
1871 } 1926 }
1872 1927
1873 AudioReceiveStream* audio_receive_stream = nullptr; 1928 AudioReceiveStream* audio_receive_stream = nullptr;
1874 if (params_.audio.enabled) { 1929 if (params_.audio.enabled) {
1875 SetupAudio(voe.send_channel_id, voe.receive_channel_id, call.get(), 1930 SetupAudio(voe.send_channel_id, voe.receive_channel_id, &send_transport,
1876 &transport, &audio_receive_stream); 1931 &audio_receive_stream);
1877 } 1932 }
1878 1933
1879 StartEncodedFrameLogs(video_receive_stream); 1934 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1935 StartEncodedFrameLogs(receive_stream);
1880 StartEncodedFrameLogs(video_send_stream_); 1936 StartEncodedFrameLogs(video_send_stream_);
1881 1937
1882 // Start sending and receiving video. 1938 // Start sending and receiving video.
1883 if (params_.video.enabled) { 1939 if (params_.video.enabled) {
1884 if (flexfec_receive_stream) 1940 if (flexfec_receive_stream)
1885 flexfec_receive_stream->Start(); 1941 flexfec_receive_stream->Start();
1886 video_receive_stream->Start(); 1942 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1943 receive_stream->Start();
1887 video_send_stream_->Start(); 1944 video_send_stream_->Start();
1888 video_capturer_->Start(); 1945 video_capturer_->Start();
1889 } 1946 }
1890 1947
1891 if (params_.audio.enabled) { 1948 if (params_.audio.enabled) {
1892 // Start receiving audio. 1949 // Start receiving audio.
1893 audio_receive_stream->Start(); 1950 audio_receive_stream->Start();
1894 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); 1951 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id));
1895 1952
1896 // Start sending audio. 1953 // Start sending audio.
1897 audio_send_stream_->Start(); 1954 audio_send_stream_->Start();
1898 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id)); 1955 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id));
1899 } 1956 }
1900 1957
1901 test::PressEnterToContinue(); 1958 test::PressEnterToContinue();
1902 1959
1903 if (params_.audio.enabled) { 1960 if (params_.audio.enabled) {
1904 // Stop sending audio. 1961 // Stop sending audio.
1905 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id)); 1962 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id));
1906 audio_send_stream_->Stop(); 1963 audio_send_stream_->Stop();
1907 1964
1908 // Stop receiving audio. 1965 // Stop receiving audio.
1909 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id)); 1966 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id));
1910 audio_receive_stream->Stop(); 1967 audio_receive_stream->Stop();
1911 call->DestroyAudioSendStream(audio_send_stream_); 1968 sender_call_->DestroyAudioSendStream(audio_send_stream_);
1912 call->DestroyAudioReceiveStream(audio_receive_stream); 1969 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream);
1913 } 1970 }
1914 1971
1915 // Stop receiving and sending video. 1972 // Stop receiving and sending video.
1916 if (params_.video.enabled) { 1973 if (params_.video.enabled) {
1917 video_capturer_->Stop(); 1974 video_capturer_->Stop();
1918 video_send_stream_->Stop(); 1975 video_send_stream_->Stop();
1919 video_receive_stream->Stop(); 1976 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1977 receive_stream->Stop();
1920 if (flexfec_receive_stream) { 1978 if (flexfec_receive_stream) {
1921 flexfec_receive_stream->Stop(); 1979 flexfec_receive_stream->Stop();
1922 call->DestroyFlexfecReceiveStream(flexfec_receive_stream); 1980 receiver_call_->DestroyFlexfecReceiveStream(flexfec_receive_stream);
1923 } 1981 }
1924 call->DestroyVideoReceiveStream(video_receive_stream); 1982 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1925 call->DestroyVideoSendStream(video_send_stream_); 1983 receiver_call_->DestroyVideoReceiveStream(receive_stream);
1984 sender_call_->DestroyVideoSendStream(video_send_stream_);
1926 } 1985 }
1927 1986
1928 transport.StopSending(); 1987 send_transport.StopSending();
1988 recv_transport.StopSending();
1989
1929 if (params_.audio.enabled) 1990 if (params_.audio.enabled)
1930 DestroyVoiceEngine(&voe); 1991 DestroyVoiceEngine(&voe);
1931 } 1992 }
1932 1993
1933 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { 1994 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) {
1934 if (!params_.video.encoded_frame_base_path.empty()) { 1995 if (!params_.video.encoded_frame_base_path.empty()) {
1935 std::ostringstream str; 1996 std::ostringstream str;
1936 str << send_logs_++; 1997 str << send_logs_++;
1937 std::string prefix = 1998 std::string prefix =
1938 params_.video.encoded_frame_base_path + "." + str.str() + ".send."; 1999 params_.video.encoded_frame_base_path + "." + str.str() + ".send.";
(...skipping 10 matching lines...) Expand all
1949 if (!params_.video.encoded_frame_base_path.empty()) { 2010 if (!params_.video.encoded_frame_base_path.empty()) {
1950 std::ostringstream str; 2011 std::ostringstream str;
1951 str << receive_logs_++; 2012 str << receive_logs_++;
1952 std::string path = 2013 std::string path =
1953 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; 2014 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
1954 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), 2015 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path),
1955 10000000); 2016 10000000);
1956 } 2017 }
1957 } 2018 }
1958 } // namespace webrtc 2019 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_quality_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698