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

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

Issue 2249163002: Revert of Adding audio to video_quality_test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 <stdio.h> 10 #include <stdio.h>
(...skipping 16 matching lines...) Expand all
27 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 27 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
28 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
30 #include "webrtc/system_wrappers/include/cpu_info.h" 30 #include "webrtc/system_wrappers/include/cpu_info.h"
31 #include "webrtc/test/layer_filtering_transport.h" 31 #include "webrtc/test/layer_filtering_transport.h"
32 #include "webrtc/test/run_loop.h" 32 #include "webrtc/test/run_loop.h"
33 #include "webrtc/test/statistics.h" 33 #include "webrtc/test/statistics.h"
34 #include "webrtc/test/testsupport/fileutils.h" 34 #include "webrtc/test/testsupport/fileutils.h"
35 #include "webrtc/test/video_renderer.h" 35 #include "webrtc/test/video_renderer.h"
36 #include "webrtc/video/video_quality_test.h" 36 #include "webrtc/video/video_quality_test.h"
37 #include "webrtc/voice_engine/include/voe_base.h"
38 #include "webrtc/voice_engine/include/voe_codec.h"
39
40 namespace {
41
42 constexpr int kSendStatsPollingIntervalMs = 1000;
43 constexpr int kPayloadTypeH264 = 122;
44 constexpr int kPayloadTypeVP8 = 123;
45 constexpr int kPayloadTypeVP9 = 124;
46 constexpr size_t kMaxComparisons = 10;
47 constexpr char kSyncGroup[] = "av_sync";
48 constexpr int kOpusMinBitrate = 6000;
49 constexpr int kOpusBitrateFb = 32000;
50
51 struct VoiceEngineState {
52 VoiceEngineState()
53 : voice_engine(nullptr),
54 base(nullptr),
55 codec(nullptr),
56 send_channel_id(-1),
57 receive_channel_id(-1) {}
58
59 webrtc::VoiceEngine* voice_engine;
60 webrtc::VoEBase* base;
61 webrtc::VoECodec* codec;
62 int send_channel_id;
63 int receive_channel_id;
64 };
65
66 void CreateVoiceEngine(VoiceEngineState* voe,
67 rtc::scoped_refptr<webrtc::AudioDecoderFactory>
68 decoder_factory) {
69 voe->voice_engine = webrtc::VoiceEngine::Create();
70 voe->base = webrtc::VoEBase::GetInterface(voe->voice_engine);
71 voe->codec = webrtc::VoECodec::GetInterface(voe->voice_engine);
72 EXPECT_EQ(0, voe->base->Init(nullptr, nullptr, decoder_factory));
73 webrtc::Config voe_config;
74 voe_config.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true));
75 voe->send_channel_id = voe->base->CreateChannel(voe_config);
76 EXPECT_GE(voe->send_channel_id, 0);
77 voe->receive_channel_id = voe->base->CreateChannel();
78 EXPECT_GE(voe->receive_channel_id, 0);
79 }
80
81 void DestroyVoiceEngine(VoiceEngineState* voe) {
82 voe->base->DeleteChannel(voe->send_channel_id);
83 voe->send_channel_id = -1;
84 voe->base->DeleteChannel(voe->receive_channel_id);
85 voe->receive_channel_id = -1;
86 voe->base->Release();
87 voe->base = nullptr;
88 voe->codec->Release();
89 voe->codec = nullptr;
90
91 webrtc::VoiceEngine::Delete(voe->voice_engine);
92 voe->voice_engine = nullptr;
93 }
94
95 } // namespace
96 37
97 namespace webrtc { 38 namespace webrtc {
98 39
40 static const int kSendStatsPollingIntervalMs = 1000;
41 static const int kPayloadTypeH264 = 122;
42 static const int kPayloadTypeVP8 = 123;
43 static const int kPayloadTypeVP9 = 124;
44 static const size_t kMaxComparisons = 10;
45
99 class VideoAnalyzer : public PacketReceiver, 46 class VideoAnalyzer : public PacketReceiver,
100 public Transport, 47 public Transport,
101 public rtc::VideoSinkInterface<VideoFrame>, 48 public rtc::VideoSinkInterface<VideoFrame>,
102 public VideoCaptureInput, 49 public VideoCaptureInput,
103 public EncodedFrameObserver { 50 public EncodedFrameObserver {
104 public: 51 public:
105 VideoAnalyzer(test::LayerFilteringTransport* transport, 52 VideoAnalyzer(test::LayerFilteringTransport* transport,
106 const std::string& test_label, 53 const std::string& test_label,
107 double avg_psnr_threshold, 54 double avg_psnr_threshold,
108 double avg_ssim_threshold, 55 double avg_ssim_threshold,
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 ASSERT_TRUE(capturer_) << "Could not create capturer for " 995 ASSERT_TRUE(capturer_) << "Could not create capturer for "
1049 << params_.video.clip_name 996 << params_.video.clip_name
1050 << ".yuv. Is this resource file present?"; 997 << ".yuv. Is this resource file present?";
1051 } 998 }
1052 } 999 }
1053 } 1000 }
1054 1001
1055 void VideoQualityTest::RunWithAnalyzer(const Params& params) { 1002 void VideoQualityTest::RunWithAnalyzer(const Params& params) {
1056 params_ = params; 1003 params_ = params;
1057 1004
1058 RTC_CHECK(!params_.audio);
1059 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to 1005 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to
1060 // differentiate between the analyzer and the renderer case. 1006 // differentiate between the analyzer and the renderer case.
1061 CheckParams(); 1007 CheckParams();
1062 1008
1063 FILE* graph_data_output_file = nullptr; 1009 FILE* graph_data_output_file = nullptr;
1064 if (!params_.analyzer.graph_data_output_filename.empty()) { 1010 if (!params_.analyzer.graph_data_output_filename.empty()) {
1065 graph_data_output_file = 1011 graph_data_output_file =
1066 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); 1012 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w");
1067 RTC_CHECK(graph_data_output_file) 1013 RTC_CHECK(graph_data_output_file)
1068 << "Can't open the file " << params_.analyzer.graph_data_output_filename 1014 << "Can't open the file " << params_.analyzer.graph_data_output_filename
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 for (VideoReceiveStream* receive_stream : video_receive_streams_) 1092 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1147 receive_stream->Stop(); 1093 receive_stream->Stop();
1148 video_send_stream_->Stop(); 1094 video_send_stream_->Stop();
1149 1095
1150 DestroyStreams(); 1096 DestroyStreams();
1151 1097
1152 if (graph_data_output_file) 1098 if (graph_data_output_file)
1153 fclose(graph_data_output_file); 1099 fclose(graph_data_output_file);
1154 } 1100 }
1155 1101
1156 void VideoQualityTest::RunWithRenderers(const Params& params) { 1102 void VideoQualityTest::RunWithVideoRenderer(const Params& params) {
1157 params_ = params; 1103 params_ = params;
1158 CheckParams(); 1104 CheckParams();
1159 1105
1160 std::unique_ptr<test::VideoRenderer> local_preview( 1106 std::unique_ptr<test::VideoRenderer> local_preview(
1161 test::VideoRenderer::Create("Local Preview", params_.common.width, 1107 test::VideoRenderer::Create("Local Preview", params_.common.width,
1162 params_.common.height)); 1108 params_.common.height));
1163 size_t stream_id = params_.ss.selected_stream; 1109 size_t stream_id = params_.ss.selected_stream;
1164 std::string title = "Loopback Video"; 1110 std::string title = "Loopback Video";
1165 if (params_.ss.streams.size() > 1) { 1111 if (params_.ss.streams.size() > 1) {
1166 std::ostringstream s; 1112 std::ostringstream s;
1167 s << stream_id; 1113 s << stream_id;
1168 title += " - Stream #" + s.str(); 1114 title += " - Stream #" + s.str();
1169 } 1115 }
1170 1116
1171 std::unique_ptr<test::VideoRenderer> loopback_video( 1117 std::unique_ptr<test::VideoRenderer> loopback_video(
1172 test::VideoRenderer::Create(title.c_str(), 1118 test::VideoRenderer::Create(title.c_str(),
1173 params_.ss.streams[stream_id].width, 1119 params_.ss.streams[stream_id].width,
1174 params_.ss.streams[stream_id].height)); 1120 params_.ss.streams[stream_id].height));
1175 1121
1176 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to 1122 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to
1177 // match the full stack tests. 1123 // match the full stack tests.
1178 Call::Config call_config; 1124 Call::Config call_config;
1179 call_config.bitrate_config = params_.common.call_bitrate_config; 1125 call_config.bitrate_config = params_.common.call_bitrate_config;
1180
1181 ::VoiceEngineState voe;
1182 if (params_.audio) {
1183 CreateVoiceEngine(&voe, decoder_factory_);
1184 AudioState::Config audio_state_config;
1185 audio_state_config.voice_engine = voe.voice_engine;
1186 call_config.audio_state = AudioState::Create(audio_state_config);
1187 }
1188
1189 std::unique_ptr<Call> call(Call::Create(call_config)); 1126 std::unique_ptr<Call> call(Call::Create(call_config));
1190 1127
1191 test::LayerFilteringTransport transport( 1128 test::LayerFilteringTransport transport(
1192 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, 1129 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9,
1193 params.common.selected_tl, params_.ss.selected_sl); 1130 params.common.selected_tl, params_.ss.selected_sl);
1194 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at 1131 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at
1195 // least share as much code as possible. That way this test would also match 1132 // least share as much code as possible. That way this test would also match
1196 // the full stack tests better. 1133 // the full stack tests better.
1197 transport.SetReceiver(call->Receiver()); 1134 transport.SetReceiver(call->Receiver());
1198 1135
1199 SetupCommon(&transport, &transport); 1136 SetupCommon(&transport, &transport);
1200 1137
1201 video_send_config_.local_renderer = local_preview.get(); 1138 video_send_config_.local_renderer = local_preview.get();
1202 video_receive_configs_[stream_id].renderer = loopback_video.get(); 1139 video_receive_configs_[stream_id].renderer = loopback_video.get();
1203 if (params_.audio && params_.audio_video_sync)
1204 video_receive_configs_[stream_id].sync_group = kSyncGroup;
1205 1140
1206 video_send_config_.suspend_below_min_bitrate = 1141 video_send_config_.suspend_below_min_bitrate =
1207 params_.common.suspend_below_min_bitrate; 1142 params_.common.suspend_below_min_bitrate;
1208 1143
1209 if (params.common.fec) { 1144 if (params.common.fec) {
1210 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; 1145 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType;
1211 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; 1146 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType;
1212 video_receive_configs_[stream_id].rtp.fec.red_payload_type = 1147 video_receive_configs_[stream_id].rtp.fec.red_payload_type =
1213 kRedPayloadType; 1148 kRedPayloadType;
1214 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type = 1149 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type =
1215 kUlpfecPayloadType; 1150 kUlpfecPayloadType;
1216 } 1151 }
1217 1152
1218 if (params_.screenshare.enabled) 1153 if (params_.screenshare.enabled)
1219 SetupScreenshare(); 1154 SetupScreenshare();
1220 1155
1221 video_send_stream_ = 1156 video_send_stream_ =
1222 call->CreateVideoSendStream(video_send_config_, video_encoder_config_); 1157 call->CreateVideoSendStream(video_send_config_, video_encoder_config_);
1223 VideoReceiveStream* video_receive_stream = 1158 VideoReceiveStream* receive_stream =
1224 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy()); 1159 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy());
1225 CreateCapturer(video_send_stream_->Input()); 1160 CreateCapturer(video_send_stream_->Input());
1226 1161
1227 AudioReceiveStream* audio_receive_stream = nullptr; 1162 receive_stream->Start();
1228 if (params_.audio) {
1229 audio_send_config_ = AudioSendStream::Config(&transport);
1230 audio_send_config_.voe_channel_id = voe.send_channel_id;
1231 audio_send_config_.rtp.ssrc = kAudioSendSsrc;
1232
1233 // Add extension to enable audio send side BWE, and allow audio bit rate
1234 // adaptation.
1235 audio_send_config_.rtp.extensions.clear();
1236 if (params_.common.send_side_bwe) {
1237 audio_send_config_.rtp.extensions.push_back(webrtc::RtpExtension(
1238 webrtc::RtpExtension::kTransportSequenceNumberUri,
1239 test::kTransportSequenceNumberExtensionId));
1240 audio_send_config_.min_bitrate_kbps = kOpusMinBitrate / 1000;
1241 audio_send_config_.max_bitrate_kbps = kOpusBitrateFb / 1000;
1242 }
1243
1244 audio_send_stream_ = call->CreateAudioSendStream(audio_send_config_);
1245
1246 AudioReceiveStream::Config audio_config;
1247 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc;
1248 audio_config.rtcp_send_transport = &transport;
1249 audio_config.voe_channel_id = voe.receive_channel_id;
1250 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc;
1251 audio_config.rtp.transport_cc = params_.common.send_side_bwe;
1252 audio_config.rtp.extensions = audio_send_config_.rtp.extensions;
1253 audio_config.decoder_factory = decoder_factory_;
1254 if (params_.audio_video_sync)
1255 audio_config.sync_group = kSyncGroup;
1256
1257 audio_receive_stream =call->CreateAudioReceiveStream(audio_config);
1258
1259 const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000};
1260 EXPECT_EQ(0, voe.codec->SetSendCodec(voe.send_channel_id, kOpusInst));
1261 }
1262
1263 // Start sending and receiving video.
1264 video_receive_stream->Start();
1265 video_send_stream_->Start(); 1163 video_send_stream_->Start();
1266 capturer_->Start(); 1164 capturer_->Start();
1267 1165
1268 if (params_.audio) {
1269 // Start receiving audio.
1270 audio_receive_stream->Start();
1271 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id));
1272 EXPECT_EQ(0, voe.base->StartReceive(voe.receive_channel_id));
1273
1274 // Start sending audio.
1275 audio_send_stream_->Start();
1276 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id));
1277 }
1278
1279 test::PressEnterToContinue(); 1166 test::PressEnterToContinue();
1280 1167
1281 if (params_.audio) {
1282 // Stop sending audio.
1283 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id));
1284 audio_send_stream_->Stop();
1285
1286 // Stop receiving audio.
1287 EXPECT_EQ(0, voe.base->StopReceive(voe.receive_channel_id));
1288 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id));
1289 audio_receive_stream->Stop();
1290 }
1291
1292 // Stop receiving and sending video.
1293 capturer_->Stop(); 1168 capturer_->Stop();
1294 video_send_stream_->Stop(); 1169 video_send_stream_->Stop();
1295 video_receive_stream->Stop(); 1170 receive_stream->Stop();
1296 1171
1297 call->DestroyVideoReceiveStream(video_receive_stream); 1172 call->DestroyVideoReceiveStream(receive_stream);
1298 call->DestroyVideoSendStream(video_send_stream_); 1173 call->DestroyVideoSendStream(video_send_stream_);
1299 1174
1300 if (params_.audio) {
1301 call->DestroyAudioSendStream(audio_send_stream_);
1302 call->DestroyAudioReceiveStream(audio_receive_stream);
1303 }
1304
1305 transport.StopSending(); 1175 transport.StopSending();
1306 if (params_.audio)
1307 DestroyVoiceEngine(&voe);
1308 } 1176 }
1309 1177
1310 } // namespace webrtc 1178 } // 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