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

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

Issue 2136573002: Adding audio to video_quality_test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: using fake audio device Created 4 years, 5 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
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"
37 39
38 namespace webrtc { 40 namespace webrtc {
39 41
40 static const int kSendStatsPollingIntervalMs = 1000; 42 static const int kSendStatsPollingIntervalMs = 1000;
41 static const int kPayloadTypeH264 = 122; 43 static const int kPayloadTypeH264 = 122;
42 static const int kPayloadTypeVP8 = 123; 44 static const int kPayloadTypeVP8 = 123;
43 static const int kPayloadTypeVP9 = 124; 45 static const int kPayloadTypeVP9 = 124;
44 46
45 class VideoAnalyzer : public PacketReceiver, 47 class VideoAnalyzer : public PacketReceiver,
46 public Transport, 48 public Transport,
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 for (VideoReceiveStream* receive_stream : video_receive_streams_) 1081 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1080 receive_stream->Stop(); 1082 receive_stream->Stop();
1081 video_send_stream_->Stop(); 1083 video_send_stream_->Stop();
1082 1084
1083 DestroyStreams(); 1085 DestroyStreams();
1084 1086
1085 if (graph_data_output_file) 1087 if (graph_data_output_file)
1086 fclose(graph_data_output_file); 1088 fclose(graph_data_output_file);
1087 } 1089 }
1088 1090
1089 void VideoQualityTest::RunWithVideoRenderer(const Params& params) { 1091 void VideoQualityTest::RunWithVideoRenderer(const Params& params) {
stefan-webrtc 2016/07/11 15:01:10 The name of this method is no longer good. We shou
minyue-webrtc 2016/07/12 10:09:36 any suggestions?
stefan-webrtc 2016/08/08 14:11:18 RunWithRenderer
minyue-webrtc 2016/08/15 15:34:31 RunWithRenderer does not imply that it may contain
stefan-webrtc 2016/08/15 15:46:24 I think RunWithRenderers is better since it doesn'
1090 params_ = params; 1092 params_ = params;
1091 CheckParams(); 1093 CheckParams();
1092 1094
1093 std::unique_ptr<test::VideoRenderer> local_preview( 1095 std::unique_ptr<test::VideoRenderer> local_preview(
1094 test::VideoRenderer::Create("Local Preview", params_.common.width, 1096 test::VideoRenderer::Create("Local Preview", params_.common.width,
1095 params_.common.height)); 1097 params_.common.height));
1096 size_t stream_id = params_.ss.selected_stream; 1098 size_t stream_id = params_.ss.selected_stream;
1097 std::string title = "Loopback Video"; 1099 std::string title = "Loopback Video";
1098 if (params_.ss.streams.size() > 1) { 1100 if (params_.ss.streams.size() > 1) {
1099 std::ostringstream s; 1101 std::ostringstream s;
1100 s << stream_id; 1102 s << stream_id;
1101 title += " - Stream #" + s.str(); 1103 title += " - Stream #" + s.str();
1102 } 1104 }
1103 1105
1104 std::unique_ptr<test::VideoRenderer> loopback_video( 1106 std::unique_ptr<test::VideoRenderer> loopback_video(
1105 test::VideoRenderer::Create(title.c_str(), 1107 test::VideoRenderer::Create(title.c_str(),
1106 params_.ss.streams[stream_id].width, 1108 params_.ss.streams[stream_id].width,
1107 params_.ss.streams[stream_id].height)); 1109 params_.ss.streams[stream_id].height));
1108 1110
1109 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to 1111 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to
1110 // match the full stack tests. 1112 // match the full stack tests.
1111 Call::Config call_config; 1113 Call::Config call_config;
1112 call_config.bitrate_config = params_.common.call_bitrate_config; 1114 call_config.bitrate_config = params_.common.call_bitrate_config;
1115
1116 CreateVoiceEngine();
stefan-webrtc 2016/07/11 15:01:10 I think we should add an option to configure with
minyue-webrtc 2016/07/12 10:09:36 Done.
1117 AudioState::Config audio_state_config;
1118 audio_state_config.voice_engine = voe_.voice_engine;
1119 call_config.audio_state = AudioState::Create(audio_state_config);
1120
1113 std::unique_ptr<Call> call(Call::Create(call_config)); 1121 std::unique_ptr<Call> call(Call::Create(call_config));
1114 1122
1115 test::LayerFilteringTransport transport( 1123 test::LayerFilteringTransport transport(
1116 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, 1124 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9,
1117 params.common.selected_tl, params_.ss.selected_sl); 1125 params.common.selected_tl, params_.ss.selected_sl);
1118 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at 1126 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at
1119 // least share as much code as possible. That way this test would also match 1127 // least share as much code as possible. That way this test would also match
1120 // the full stack tests better. 1128 // the full stack tests better.
1121 transport.SetReceiver(call->Receiver()); 1129 transport.SetReceiver(call->Receiver());
1122 1130
1123 SetupCommon(&transport, &transport); 1131 SetupCommon(&transport, &transport);
1124 1132
1125 video_send_config_.local_renderer = local_preview.get(); 1133 video_send_config_.local_renderer = local_preview.get();
1126 video_receive_configs_[stream_id].renderer = loopback_video.get(); 1134 video_receive_configs_[stream_id].renderer = loopback_video.get();
1135 // video_receive_configs_[stream_id].sync_group = kSyncGroup;
stefan-webrtc 2016/07/11 15:01:10 Would be good to be able to test sync. Maybe have
minyue-webrtc 2016/07/12 10:09:36 Done. So we can use the actually device instead of
1127 1136
1128 video_send_config_.suspend_below_min_bitrate = 1137 video_send_config_.suspend_below_min_bitrate =
1129 params_.common.suspend_below_min_bitrate; 1138 params_.common.suspend_below_min_bitrate;
1130 1139
1131 if (params.common.fec) { 1140 if (params.common.fec) {
1132 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; 1141 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType;
1133 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; 1142 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType;
1134 video_receive_configs_[stream_id].rtp.fec.red_payload_type = 1143 video_receive_configs_[stream_id].rtp.fec.red_payload_type =
1135 kRedPayloadType; 1144 kRedPayloadType;
1136 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type = 1145 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type =
1137 kUlpfecPayloadType; 1146 kUlpfecPayloadType;
1138 } 1147 }
1139 1148
1140 if (params_.screenshare.enabled) 1149 if (params_.screenshare.enabled)
1141 SetupScreenshare(); 1150 SetupScreenshare();
1142 1151
1143 video_send_stream_ = 1152 video_send_stream_ =
1144 call->CreateVideoSendStream(video_send_config_, video_encoder_config_); 1153 call->CreateVideoSendStream(video_send_config_, video_encoder_config_);
1145 VideoReceiveStream* receive_stream = 1154 VideoReceiveStream* video_receive_stream =
1146 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy()); 1155 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy());
1147 CreateCapturer(video_send_stream_->Input()); 1156 CreateCapturer(video_send_stream_->Input());
1148 1157
1149 receive_stream->Start(); 1158 audio_send_config_ = AudioSendStream::Config(&transport);
1159 audio_send_config_.voe_channel_id = voe_.send_channel_id;
1160 audio_send_config_.rtp.ssrc = kAudioSendSsrc;
1161 audio_send_stream_ = call->CreateAudioSendStream(audio_send_config_);
1162
1163 AudioReceiveStream::Config audio_config;
1164 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc;
1165 audio_config.rtcp_send_transport = &transport;
1166 audio_config.voe_channel_id = voe_.receive_channel_id;
1167 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc;
1168 audio_config.decoder_factory = decoder_factory_;
1169 audio_receive_configs_.push_back(audio_config);
1170 AudioReceiveStream* audio_receive_stream =
1171 call->CreateAudioReceiveStream(audio_receive_configs_[0]);
1172
1173 const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000};
1174 EXPECT_EQ(0, voe_.codec->SetSendCodec(voe_.send_channel_id, kOpusInst));
1175
1176 // Start sending and receiving video.
1177 video_receive_stream->Start();
1150 video_send_stream_->Start(); 1178 video_send_stream_->Start();
1151 capturer_->Start(); 1179 capturer_->Start();
1152 1180
1181 // Start receiving audio.
1182 audio_receive_stream->Start();
1183 EXPECT_EQ(0, voe_.base->StartPlayout(voe_.receive_channel_id));
1184 EXPECT_EQ(0, voe_.base->StartReceive(voe_.receive_channel_id));
1185
1186 // Start sending audio.
1187 audio_send_stream_->Start();
1188 EXPECT_EQ(0, voe_.base->StartSend(voe_.send_channel_id));
1189 fake_audio_device_->Start();
1190
1153 test::PressEnterToContinue(); 1191 test::PressEnterToContinue();
1154 1192
1193 // Stop sending audio.
1194 fake_audio_device_->Stop();
1195 EXPECT_EQ(0, voe_.base->StopSend(voe_.send_channel_id));
1196 audio_send_stream_->Stop();
1197
1198 // Stop receiving audio.
1199 EXPECT_EQ(0, voe_.base->StopReceive(voe_.receive_channel_id));
1200 EXPECT_EQ(0, voe_.base->StopPlayout(voe_.receive_channel_id));
1201 audio_receive_stream->Stop();
1202
1203 // Stop receiving and sending video.
1155 capturer_->Stop(); 1204 capturer_->Stop();
1156 video_send_stream_->Stop(); 1205 video_send_stream_->Stop();
1157 receive_stream->Stop(); 1206 video_receive_stream->Stop();
1158 1207
1159 call->DestroyVideoReceiveStream(receive_stream); 1208 call->DestroyVideoReceiveStream(video_receive_stream);
1160 call->DestroyVideoSendStream(video_send_stream_); 1209 call->DestroyVideoSendStream(video_send_stream_);
1210 call->DestroyAudioSendStream(audio_send_stream_);
1211 call->DestroyAudioReceiveStream(audio_receive_stream);
1161 1212
1162 transport.StopSending(); 1213 transport.StopSending();
1214 DestroyVoiceEngine();
1215 }
1216
1217 void VideoQualityTest::CreateVoiceEngine() {
1218 fake_audio_device_.reset(new test::FakeAudioDevice(
1219 clock_, test::ResourcePath("voice_engine/audio_long16", "pcm"),
1220 test::DriftingClock::kNoDrift));
1221 voe_.voice_engine = VoiceEngine::Create();
1222 voe_.base = VoEBase::GetInterface(voe_.voice_engine);
1223 voe_.codec = VoECodec::GetInterface(voe_.voice_engine);
1224 EXPECT_EQ(0, voe_.base->Init(fake_audio_device_.get(), nullptr,
1225 decoder_factory_));
1226 Config voe_config;
1227 voe_config.Set<VoicePacing>(new VoicePacing(true));
1228 voe_.send_channel_id = voe_.base->CreateChannel(voe_config);
1229 EXPECT_GE(voe_.send_channel_id, 0);
1230 voe_.receive_channel_id = voe_.base->CreateChannel();
1231 EXPECT_GE(voe_.receive_channel_id, 0);
1232 }
1233
1234 void VideoQualityTest::DestroyVoiceEngine() {
1235 voe_.base->DeleteChannel(voe_.send_channel_id);
1236 voe_.send_channel_id = -1;
1237 voe_.base->DeleteChannel(voe_.receive_channel_id);
1238 voe_.receive_channel_id = -1;
1239 voe_.base->Release();
1240 voe_.base = nullptr;
1241 voe_.codec->Release();
1242 voe_.codec = nullptr;
1243
1244 VoiceEngine::Delete(voe_.voice_engine);
1245 voe_.voice_engine = nullptr;
1163 } 1246 }
1164 1247
1165 } // namespace webrtc 1248 } // namespace webrtc
OLDNEW
« webrtc/video/video_quality_test.h ('K') | « webrtc/video/video_quality_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698