OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/video/video_quality_test.h" | 10 #include "webrtc/video/video_quality_test.h" |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 810 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); |
811 rtc::Event done_; | 811 rtc::Event done_; |
812 }; | 812 }; |
813 | 813 |
814 VideoQualityTest::VideoQualityTest() | 814 VideoQualityTest::VideoQualityTest() |
815 : clock_(Clock::GetRealTimeClock()), receive_logs_(0), send_logs_(0) {} | 815 : clock_(Clock::GetRealTimeClock()), receive_logs_(0), send_logs_(0) {} |
816 | 816 |
817 VideoQualityTest::Params::Params() | 817 VideoQualityTest::Params::Params() |
818 : call({false, Call::Config::BitrateConfig()}), | 818 : call({false, Call::Config::BitrateConfig()}), |
819 video({false, 640, 480, 30, 50, 800, 800, false, "VP8", 1, -1, 0, false, | 819 video({false, 640, 480, 30, 50, 800, 800, false, "VP8", 1, -1, 0, false, |
820 "", ""}), | 820 false, "", ""}), |
821 audio({false, false}), | 821 audio({false, false}), |
822 screenshare({false, 10, 0}), | 822 screenshare({false, 10, 0}), |
823 analyzer({"", 0.0, 0.0, 0, "", ""}), | 823 analyzer({"", 0.0, 0.0, 0, "", ""}), |
824 pipe(), | 824 pipe(), |
825 logs(false), | 825 logs(false), |
826 ss({std::vector<VideoStream>(), 0, 0, -1, std::vector<SpatialLayer>()}) {} | 826 ss({std::vector<VideoStream>(), 0, 0, -1, std::vector<SpatialLayer>()}) {} |
827 | 827 |
828 VideoQualityTest::Params::~Params() = default; | 828 VideoQualityTest::Params::~Params() = default; |
829 | 829 |
830 void VideoQualityTest::TestBody() {} | 830 void VideoQualityTest::TestBody() {} |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 RtpExtension(RtpExtension::kTransportSequenceNumberUri, | 1031 RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
1032 test::kTransportSequenceNumberExtensionId)); | 1032 test::kTransportSequenceNumberExtensionId)); |
1033 } else { | 1033 } else { |
1034 video_send_config_.rtp.extensions.push_back(RtpExtension( | 1034 video_send_config_.rtp.extensions.push_back(RtpExtension( |
1035 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); | 1035 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); |
1036 } | 1036 } |
1037 | 1037 |
1038 video_encoder_config_.min_transmit_bitrate_bps = | 1038 video_encoder_config_.min_transmit_bitrate_bps = |
1039 params_.video.min_transmit_bps; | 1039 params_.video.min_transmit_bps; |
1040 | 1040 |
1041 video_send_config_.suspend_below_min_bitrate = | |
1042 params_.video.suspend_below_min_bitrate; | |
1043 | |
1041 video_encoder_config_.number_of_streams = params_.ss.streams.size(); | 1044 video_encoder_config_.number_of_streams = params_.ss.streams.size(); |
1042 video_encoder_config_.max_bitrate_bps = 0; | 1045 video_encoder_config_.max_bitrate_bps = 0; |
1043 for (size_t i = 0; i < params_.ss.streams.size(); ++i) { | 1046 for (size_t i = 0; i < params_.ss.streams.size(); ++i) { |
1044 video_encoder_config_.max_bitrate_bps += | 1047 video_encoder_config_.max_bitrate_bps += |
1045 params_.ss.streams[i].max_bitrate_bps; | 1048 params_.ss.streams[i].max_bitrate_bps; |
1046 } | 1049 } |
1047 video_encoder_config_.video_stream_factory = | 1050 video_encoder_config_.video_stream_factory = |
1048 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams); | 1051 new rtc::RefCountedObject<VideoStreamFactory>(params_.ss.streams); |
1049 | 1052 |
1050 video_encoder_config_.spatial_layers = params_.ss.spatial_layers; | 1053 video_encoder_config_.spatial_layers = params_.ss.spatial_layers; |
1051 | 1054 |
1052 CreateMatchingReceiveConfigs(recv_transport); | 1055 CreateMatchingReceiveConfigs(recv_transport); |
1053 | 1056 |
1054 for (size_t i = 0; i < num_streams; ++i) { | 1057 for (size_t i = 0; i < num_streams; ++i) { |
1055 video_receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 1058 video_receive_configs_[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
1056 video_receive_configs_[i].rtp.rtx[payload_type].ssrc = kSendRtxSsrcs[i]; | 1059 video_receive_configs_[i].rtp.rtx[payload_type].ssrc = kSendRtxSsrcs[i]; |
1057 video_receive_configs_[i].rtp.rtx[payload_type].payload_type = | 1060 video_receive_configs_[i].rtp.rtx[payload_type].payload_type = |
1058 kSendRtxPayloadType; | 1061 kSendRtxPayloadType; |
1059 video_receive_configs_[i].rtp.transport_cc = params_.call.send_side_bwe; | 1062 video_receive_configs_[i].rtp.transport_cc = params_.call.send_side_bwe; |
1060 } | 1063 } |
1064 | |
1065 if (params_.video.flexfec) { | |
1066 video_send_config_.rtp.flexfec.flexfec_payload_type = kFlexfecPayloadType; | |
1067 video_send_config_.rtp.flexfec.flexfec_ssrc = kFlexfecSendSsrc; | |
1068 video_send_config_.rtp.flexfec.protected_media_ssrcs = { | |
1069 kVideoSendSsrcs[params_.ss.selected_stream]}; | |
1070 | |
1071 FlexfecReceiveStream::Config flexfec_receive_config; | |
1072 flexfec_receive_config.flexfec_payload_type = kFlexfecPayloadType; | |
1073 flexfec_receive_config.flexfec_ssrc = kFlexfecSendSsrc; | |
stefan-webrtc
2016/11/15 11:52:32
Set this to video_send_config_.rtp.flexfec.flexfec
| |
1074 flexfec_receive_config.protected_media_ssrcs = { | |
1075 kVideoSendSsrcs[params_.ss.selected_stream]}; | |
1076 flexfec_receive_configs_.push_back(flexfec_receive_config); | |
1077 } | |
1078 | |
1079 if (params_.video.ulpfec) { | |
1080 video_send_config_.rtp.ulpfec.red_payload_type = kRedPayloadType; | |
1081 video_send_config_.rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; | |
1082 video_send_config_.rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType; | |
1083 video_receive_configs_[params_.ss.selected_stream] | |
1084 .rtp.ulpfec.red_payload_type = kRedPayloadType; | |
1085 video_receive_configs_[params_.ss.selected_stream] | |
1086 .rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; | |
1087 video_receive_configs_[params_.ss.selected_stream] | |
1088 .rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType; | |
1089 } | |
1061 } | 1090 } |
1062 | 1091 |
1063 void VideoQualityTest::SetupScreenshare() { | 1092 void VideoQualityTest::SetupScreenshare() { |
1064 RTC_CHECK(params_.screenshare.enabled); | 1093 RTC_CHECK(params_.screenshare.enabled); |
1065 | 1094 |
1066 // Fill out codec settings. | 1095 // Fill out codec settings. |
1067 video_encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 1096 video_encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
1068 if (params_.video.codec == "VP8") { | 1097 if (params_.video.codec == "VP8") { |
1069 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); | 1098 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
1070 vp8_settings.denoisingOn = false; | 1099 vp8_settings.denoisingOn = false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1208 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; | 1237 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; |
1209 video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); | 1238 video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); |
1210 for (auto& config : video_receive_configs_) | 1239 for (auto& config : video_receive_configs_) |
1211 config.pre_decode_callback = &analyzer; | 1240 config.pre_decode_callback = &analyzer; |
1212 RTC_DCHECK(!video_send_config_.post_encode_callback); | 1241 RTC_DCHECK(!video_send_config_.post_encode_callback); |
1213 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); | 1242 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); |
1214 | 1243 |
1215 if (params_.screenshare.enabled) | 1244 if (params_.screenshare.enabled) |
1216 SetupScreenshare(); | 1245 SetupScreenshare(); |
1217 | 1246 |
1247 CreateFlexfecStreams(); | |
1218 CreateVideoStreams(); | 1248 CreateVideoStreams(); |
1219 analyzer.SetSendStream(video_send_stream_); | 1249 analyzer.SetSendStream(video_send_stream_); |
1220 video_send_stream_->SetSource( | 1250 video_send_stream_->SetSource( |
1221 analyzer.OutputInterface(), | 1251 analyzer.OutputInterface(), |
1222 VideoSendStream::DegradationPreference::kBalanced); | 1252 VideoSendStream::DegradationPreference::kBalanced); |
1223 | 1253 |
1224 CreateCapturer(); | 1254 CreateCapturer(); |
1225 rtc::VideoSinkWants wants; | 1255 rtc::VideoSinkWants wants; |
1226 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants); | 1256 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants); |
1227 | 1257 |
1228 StartEncodedFrameLogs(video_send_stream_); | 1258 StartEncodedFrameLogs(video_send_stream_); |
1229 StartEncodedFrameLogs(video_receive_streams_[0]); | 1259 StartEncodedFrameLogs(video_receive_streams_[0]); |
1230 video_send_stream_->Start(); | 1260 video_send_stream_->Start(); |
1231 for (VideoReceiveStream* receive_stream : video_receive_streams_) | 1261 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
1232 receive_stream->Start(); | 1262 receive_stream->Start(); |
1263 for (FlexfecReceiveStream* receive_stream : flexfec_receive_streams_) | |
1264 receive_stream->Start(); | |
1233 video_capturer_->Start(); | 1265 video_capturer_->Start(); |
1234 | 1266 |
1235 analyzer.Wait(); | 1267 analyzer.Wait(); |
1236 | 1268 |
1237 send_transport.StopSending(); | 1269 send_transport.StopSending(); |
1238 recv_transport.StopSending(); | 1270 recv_transport.StopSending(); |
1239 | 1271 |
1240 video_capturer_->Stop(); | 1272 video_capturer_->Stop(); |
1273 for (FlexfecReceiveStream* receive_stream : flexfec_receive_streams_) | |
1274 receive_stream->Stop(); | |
1241 for (VideoReceiveStream* receive_stream : video_receive_streams_) | 1275 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
1242 receive_stream->Stop(); | 1276 receive_stream->Stop(); |
1243 video_send_stream_->Stop(); | 1277 video_send_stream_->Stop(); |
1244 | 1278 |
1245 DestroyStreams(); | 1279 DestroyStreams(); |
1246 | 1280 |
1247 if (graph_data_output_file) | 1281 if (graph_data_output_file) |
1248 fclose(graph_data_output_file); | 1282 fclose(graph_data_output_file); |
1249 } | 1283 } |
1250 | 1284 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1310 // calls. | 1344 // calls. |
1311 test::LayerFilteringTransport transport( | 1345 test::LayerFilteringTransport transport( |
1312 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, | 1346 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, |
1313 params.video.selected_tl, params_.ss.selected_sl); | 1347 params.video.selected_tl, params_.ss.selected_sl); |
1314 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at | 1348 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at |
1315 // least share as much code as possible. That way this test would also match | 1349 // least share as much code as possible. That way this test would also match |
1316 // the full stack tests better. | 1350 // the full stack tests better. |
1317 transport.SetReceiver(call->Receiver()); | 1351 transport.SetReceiver(call->Receiver()); |
1318 | 1352 |
1319 VideoReceiveStream* video_receive_stream = nullptr; | 1353 VideoReceiveStream* video_receive_stream = nullptr; |
1354 FlexfecReceiveStream* flexfec_receive_stream = nullptr; | |
1320 std::unique_ptr<test::VideoRenderer> local_preview; | 1355 std::unique_ptr<test::VideoRenderer> local_preview; |
1321 std::unique_ptr<test::VideoRenderer> loopback_video; | 1356 std::unique_ptr<test::VideoRenderer> loopback_video; |
1322 if (params_.video.enabled) { | 1357 if (params_.video.enabled) { |
1323 // Create video renderers. | 1358 // Create video renderers. |
1324 local_preview.reset(test::VideoRenderer::Create( | 1359 local_preview.reset(test::VideoRenderer::Create( |
1325 "Local Preview", params_.video.width, params_.video.height)); | 1360 "Local Preview", params_.video.width, params_.video.height)); |
1326 | 1361 |
1327 size_t stream_id = params_.ss.selected_stream; | 1362 size_t stream_id = params_.ss.selected_stream; |
1328 std::string title = "Loopback Video"; | 1363 std::string title = "Loopback Video"; |
1329 if (params_.ss.streams.size() > 1) { | 1364 if (params_.ss.streams.size() > 1) { |
1330 std::ostringstream s; | 1365 std::ostringstream s; |
1331 s << stream_id; | 1366 s << stream_id; |
1332 title += " - Stream #" + s.str(); | 1367 title += " - Stream #" + s.str(); |
1333 } | 1368 } |
1334 | 1369 |
1335 loopback_video.reset(test::VideoRenderer::Create( | 1370 loopback_video.reset(test::VideoRenderer::Create( |
1336 title.c_str(), params_.ss.streams[stream_id].width, | 1371 title.c_str(), params_.ss.streams[stream_id].width, |
1337 params_.ss.streams[stream_id].height)); | 1372 params_.ss.streams[stream_id].height)); |
1338 | 1373 |
1339 SetupVideo(&transport, &transport); | 1374 SetupVideo(&transport, &transport); |
1340 | |
1341 // TODO(minyue): maybe move the following to SetupVideo() to make code | |
1342 // cleaner. Currently, RunWithRenderers() and RunWithAnalyzer() differ in | |
1343 // the way they treat FEC etc., which makes it complicated to put these | |
1344 // additional video setup into SetupVideo(). | |
1345 video_send_config_.pre_encode_callback = local_preview.get(); | 1375 video_send_config_.pre_encode_callback = local_preview.get(); |
1346 video_receive_configs_[stream_id].renderer = loopback_video.get(); | 1376 video_receive_configs_[stream_id].renderer = loopback_video.get(); |
1347 if (params_.audio.enabled && params_.audio.sync_video) | 1377 if (params_.audio.enabled && params_.audio.sync_video) |
1348 video_receive_configs_[stream_id].sync_group = kSyncGroup; | 1378 video_receive_configs_[stream_id].sync_group = kSyncGroup; |
1349 | 1379 |
1350 video_send_config_.suspend_below_min_bitrate = | |
1351 params_.video.suspend_below_min_bitrate; | |
1352 | |
1353 if (params.video.fec) { | |
1354 video_send_config_.rtp.ulpfec.red_payload_type = kRedPayloadType; | |
1355 video_send_config_.rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; | |
1356 video_send_config_.rtp.ulpfec.red_rtx_payload_type = kRtxRedPayloadType; | |
1357 video_receive_configs_[stream_id].rtp.ulpfec.red_payload_type = | |
1358 kRedPayloadType; | |
1359 video_receive_configs_[stream_id].rtp.ulpfec.ulpfec_payload_type = | |
1360 kUlpfecPayloadType; | |
1361 video_receive_configs_[stream_id].rtp.ulpfec.red_rtx_payload_type = | |
1362 kRtxRedPayloadType; | |
1363 } | |
1364 | |
1365 if (params_.screenshare.enabled) | 1380 if (params_.screenshare.enabled) |
1366 SetupScreenshare(); | 1381 SetupScreenshare(); |
1367 | 1382 |
1368 video_send_stream_ = call->CreateVideoSendStream( | 1383 video_send_stream_ = call->CreateVideoSendStream( |
1369 video_send_config_.Copy(), video_encoder_config_.Copy()); | 1384 video_send_config_.Copy(), video_encoder_config_.Copy()); |
1370 video_receive_stream = call->CreateVideoReceiveStream( | 1385 video_receive_stream = call->CreateVideoReceiveStream( |
1371 video_receive_configs_[stream_id].Copy()); | 1386 video_receive_configs_[stream_id].Copy()); |
1372 CreateCapturer(); | 1387 CreateCapturer(); |
1373 video_send_stream_->SetSource( | 1388 video_send_stream_->SetSource( |
1374 video_capturer_.get(), | 1389 video_capturer_.get(), |
1375 VideoSendStream::DegradationPreference::kBalanced); | 1390 VideoSendStream::DegradationPreference::kBalanced); |
1376 } | 1391 } |
1377 | 1392 |
1378 AudioReceiveStream* audio_receive_stream = nullptr; | 1393 AudioReceiveStream* audio_receive_stream = nullptr; |
1379 if (params_.audio.enabled) { | 1394 if (params_.audio.enabled) { |
1380 SetupAudio(voe.send_channel_id, voe.receive_channel_id, call.get(), | 1395 SetupAudio(voe.send_channel_id, voe.receive_channel_id, call.get(), |
1381 &transport, &audio_receive_stream); | 1396 &transport, &audio_receive_stream); |
1382 } | 1397 } |
1383 | 1398 |
1384 StartEncodedFrameLogs(video_receive_stream); | 1399 StartEncodedFrameLogs(video_receive_stream); |
1385 StartEncodedFrameLogs(video_send_stream_); | 1400 StartEncodedFrameLogs(video_send_stream_); |
1386 | 1401 |
1387 // Start sending and receiving video. | 1402 // Start sending and receiving video. |
1388 if (params_.video.enabled) { | 1403 if (params_.video.enabled) { |
1404 if (flexfec_receive_stream) | |
1405 flexfec_receive_stream->Start(); | |
1389 video_receive_stream->Start(); | 1406 video_receive_stream->Start(); |
1390 video_send_stream_->Start(); | 1407 video_send_stream_->Start(); |
1391 video_capturer_->Start(); | 1408 video_capturer_->Start(); |
1392 } | 1409 } |
1393 | 1410 |
1394 if (params_.audio.enabled) { | 1411 if (params_.audio.enabled) { |
1395 // Start receiving audio. | 1412 // Start receiving audio. |
1396 audio_receive_stream->Start(); | 1413 audio_receive_stream->Start(); |
1397 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); | 1414 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); |
1398 | 1415 |
(...skipping 14 matching lines...) Expand all Loading... | |
1413 audio_receive_stream->Stop(); | 1430 audio_receive_stream->Stop(); |
1414 call->DestroyAudioSendStream(audio_send_stream_); | 1431 call->DestroyAudioSendStream(audio_send_stream_); |
1415 call->DestroyAudioReceiveStream(audio_receive_stream); | 1432 call->DestroyAudioReceiveStream(audio_receive_stream); |
1416 } | 1433 } |
1417 | 1434 |
1418 // Stop receiving and sending video. | 1435 // Stop receiving and sending video. |
1419 if (params_.video.enabled) { | 1436 if (params_.video.enabled) { |
1420 video_capturer_->Stop(); | 1437 video_capturer_->Stop(); |
1421 video_send_stream_->Stop(); | 1438 video_send_stream_->Stop(); |
1422 video_receive_stream->Stop(); | 1439 video_receive_stream->Stop(); |
1440 if (flexfec_receive_stream) { | |
1441 flexfec_receive_stream->Stop(); | |
1442 call->DestroyFlexfecReceiveStream(flexfec_receive_stream); | |
1443 } | |
1423 call->DestroyVideoReceiveStream(video_receive_stream); | 1444 call->DestroyVideoReceiveStream(video_receive_stream); |
1424 call->DestroyVideoSendStream(video_send_stream_); | 1445 call->DestroyVideoSendStream(video_send_stream_); |
1425 } | 1446 } |
1426 | 1447 |
1427 transport.StopSending(); | 1448 transport.StopSending(); |
1428 if (params_.audio.enabled) | 1449 if (params_.audio.enabled) |
1429 DestroyVoiceEngine(&voe); | 1450 DestroyVoiceEngine(&voe); |
1430 } | 1451 } |
1431 | 1452 |
1432 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { | 1453 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { |
(...skipping 15 matching lines...) Expand all Loading... | |
1448 std::ostringstream str; | 1469 std::ostringstream str; |
1449 str << receive_logs_++; | 1470 str << receive_logs_++; |
1450 std::string path = | 1471 std::string path = |
1451 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 1472 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
1452 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 1473 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
1453 10000000); | 1474 10000000); |
1454 } | 1475 } |
1455 } | 1476 } |
1456 | 1477 |
1457 } // namespace webrtc | 1478 } // namespace webrtc |
OLD | NEW |