Chromium Code Reviews| 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 <stdio.h> | 10 #include <stdio.h> |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 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 char kSyncGroup[] = "av_sync"; | |
| 47 | |
| 48 struct VoiceEngineState { | |
| 49 VoiceEngineState() | |
| 50 : voice_engine(nullptr), | |
| 51 base(nullptr), | |
| 52 codec(nullptr), | |
| 53 send_channel_id(-1), | |
| 54 receive_channel_id(-1) {} | |
| 55 | |
| 56 webrtc::VoiceEngine* voice_engine; | |
| 57 webrtc::VoEBase* base; | |
| 58 webrtc::VoECodec* codec; | |
| 59 int send_channel_id; | |
| 60 int receive_channel_id; | |
| 61 }; | |
| 62 | |
| 63 void CreateVoiceEngine(VoiceEngineState* voe, | |
| 64 rtc::scoped_refptr<webrtc::AudioDecoderFactory> | |
| 65 decoder_factory) { | |
| 66 voe->voice_engine = webrtc::VoiceEngine::Create(); | |
| 67 voe->base = webrtc::VoEBase::GetInterface(voe->voice_engine); | |
| 68 voe->codec = webrtc::VoECodec::GetInterface(voe->voice_engine); | |
| 69 EXPECT_EQ(0, voe->base->Init(nullptr, nullptr, decoder_factory)); | |
| 70 webrtc::Config voe_config; | |
| 71 voe_config.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true)); | |
| 72 voe->send_channel_id = voe->base->CreateChannel(voe_config); | |
| 73 EXPECT_GE(voe->send_channel_id, 0); | |
| 74 voe->receive_channel_id = voe->base->CreateChannel(); | |
| 75 EXPECT_GE(voe->receive_channel_id, 0); | |
| 76 } | |
| 77 | |
| 78 void DestroyVoiceEngine(VoiceEngineState* voe) { | |
| 79 voe->base->DeleteChannel(voe->send_channel_id); | |
| 80 voe->send_channel_id = -1; | |
| 81 voe->base->DeleteChannel(voe->receive_channel_id); | |
| 82 voe->receive_channel_id = -1; | |
| 83 voe->base->Release(); | |
| 84 voe->base = nullptr; | |
| 85 voe->codec->Release(); | |
| 86 voe->codec = nullptr; | |
| 87 | |
| 88 webrtc::VoiceEngine::Delete(voe->voice_engine); | |
| 89 voe->voice_engine = nullptr; | |
| 90 } | |
| 91 | |
| 92 } // namespace | |
| 37 | 93 |
| 38 namespace webrtc { | 94 namespace webrtc { |
| 39 | 95 |
| 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 | |
| 45 class VideoAnalyzer : public PacketReceiver, | 96 class VideoAnalyzer : public PacketReceiver, |
| 46 public Transport, | 97 public Transport, |
| 47 public rtc::VideoSinkInterface<VideoFrame>, | 98 public rtc::VideoSinkInterface<VideoFrame>, |
| 48 public VideoCaptureInput, | 99 public VideoCaptureInput, |
| 49 public EncodedFrameObserver { | 100 public EncodedFrameObserver { |
| 50 public: | 101 public: |
| 51 VideoAnalyzer(test::LayerFilteringTransport* transport, | 102 VideoAnalyzer(test::LayerFilteringTransport* transport, |
| 52 const std::string& test_label, | 103 const std::string& test_label, |
| 53 double avg_psnr_threshold, | 104 double avg_psnr_threshold, |
| 54 double avg_ssim_threshold, | 105 double avg_ssim_threshold, |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1103 | 1154 |
| 1104 std::unique_ptr<test::VideoRenderer> loopback_video( | 1155 std::unique_ptr<test::VideoRenderer> loopback_video( |
| 1105 test::VideoRenderer::Create(title.c_str(), | 1156 test::VideoRenderer::Create(title.c_str(), |
| 1106 params_.ss.streams[stream_id].width, | 1157 params_.ss.streams[stream_id].width, |
| 1107 params_.ss.streams[stream_id].height)); | 1158 params_.ss.streams[stream_id].height)); |
| 1108 | 1159 |
| 1109 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to | 1160 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to |
| 1110 // match the full stack tests. | 1161 // match the full stack tests. |
| 1111 Call::Config call_config; | 1162 Call::Config call_config; |
| 1112 call_config.bitrate_config = params_.common.call_bitrate_config; | 1163 call_config.bitrate_config = params_.common.call_bitrate_config; |
| 1164 | |
| 1165 ::VoiceEngineState voe; | |
| 1166 if (params_.audio) { | |
| 1167 CreateVoiceEngine(&voe, decoder_factory_); | |
| 1168 AudioState::Config audio_state_config; | |
| 1169 audio_state_config.voice_engine = voe.voice_engine; | |
| 1170 call_config.audio_state = AudioState::Create(audio_state_config); | |
| 1171 } | |
| 1172 | |
| 1113 std::unique_ptr<Call> call(Call::Create(call_config)); | 1173 std::unique_ptr<Call> call(Call::Create(call_config)); |
| 1114 | 1174 |
| 1115 test::LayerFilteringTransport transport( | 1175 test::LayerFilteringTransport transport( |
| 1116 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, | 1176 params.pipe, call.get(), kPayloadTypeVP8, kPayloadTypeVP9, |
| 1117 params.common.selected_tl, params_.ss.selected_sl); | 1177 params.common.selected_tl, params_.ss.selected_sl); |
| 1118 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at | 1178 // 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 | 1179 // least share as much code as possible. That way this test would also match |
| 1120 // the full stack tests better. | 1180 // the full stack tests better. |
| 1121 transport.SetReceiver(call->Receiver()); | 1181 transport.SetReceiver(call->Receiver()); |
| 1122 | 1182 |
| 1123 SetupCommon(&transport, &transport); | 1183 SetupCommon(&transport, &transport); |
| 1124 | 1184 |
| 1125 video_send_config_.local_renderer = local_preview.get(); | 1185 video_send_config_.local_renderer = local_preview.get(); |
| 1126 video_receive_configs_[stream_id].renderer = loopback_video.get(); | 1186 video_receive_configs_[stream_id].renderer = loopback_video.get(); |
| 1187 if (params_.audio && params_.audio_video_sync) { | |
| 1188 video_receive_configs_[stream_id].sync_group = kSyncGroup; | |
| 1189 } | |
| 1127 | 1190 |
| 1128 video_send_config_.suspend_below_min_bitrate = | 1191 video_send_config_.suspend_below_min_bitrate = |
| 1129 params_.common.suspend_below_min_bitrate; | 1192 params_.common.suspend_below_min_bitrate; |
| 1130 | 1193 |
| 1131 if (params.common.fec) { | 1194 if (params.common.fec) { |
| 1132 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; | 1195 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; |
| 1133 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 1196 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
| 1134 video_receive_configs_[stream_id].rtp.fec.red_payload_type = | 1197 video_receive_configs_[stream_id].rtp.fec.red_payload_type = |
| 1135 kRedPayloadType; | 1198 kRedPayloadType; |
| 1136 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type = | 1199 video_receive_configs_[stream_id].rtp.fec.ulpfec_payload_type = |
| 1137 kUlpfecPayloadType; | 1200 kUlpfecPayloadType; |
| 1138 } | 1201 } |
| 1139 | 1202 |
| 1140 if (params_.screenshare.enabled) | 1203 if (params_.screenshare.enabled) |
| 1141 SetupScreenshare(); | 1204 SetupScreenshare(); |
| 1142 | 1205 |
| 1143 video_send_stream_ = | 1206 video_send_stream_ = |
| 1144 call->CreateVideoSendStream(video_send_config_, video_encoder_config_); | 1207 call->CreateVideoSendStream(video_send_config_, video_encoder_config_); |
| 1145 VideoReceiveStream* receive_stream = | 1208 VideoReceiveStream* video_receive_stream = |
| 1146 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy()); | 1209 call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy()); |
| 1147 CreateCapturer(video_send_stream_->Input()); | 1210 CreateCapturer(video_send_stream_->Input()); |
| 1148 | 1211 |
| 1149 receive_stream->Start(); | 1212 AudioReceiveStream* audio_receive_stream = nullptr; |
| 1213 if (params_.audio) { | |
| 1214 audio_send_config_ = AudioSendStream::Config(&transport); | |
| 1215 audio_send_config_.voe_channel_id = voe.send_channel_id; | |
| 1216 audio_send_config_.rtp.ssrc = kAudioSendSsrc; | |
| 1217 audio_send_stream_ = call->CreateAudioSendStream(audio_send_config_); | |
|
stefan-webrtc
2016/08/08 14:11:18
Is audio configured with BWE?
minyue-webrtc
2016/08/15 15:34:31
The initial CL was made before AudioBWE landed. So
| |
| 1218 | |
| 1219 AudioReceiveStream::Config audio_config; | |
| 1220 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; | |
| 1221 audio_config.rtcp_send_transport = &transport; | |
| 1222 audio_config.voe_channel_id = voe.receive_channel_id; | |
| 1223 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; | |
| 1224 audio_config.decoder_factory = decoder_factory_; | |
| 1225 if (params_.audio_video_sync) | |
| 1226 audio_config.sync_group = kSyncGroup; | |
| 1227 | |
| 1228 audio_receive_stream =call->CreateAudioReceiveStream(audio_config); | |
| 1229 | |
| 1230 const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000}; | |
| 1231 EXPECT_EQ(0, voe.codec->SetSendCodec(voe.send_channel_id, kOpusInst)); | |
| 1232 } | |
| 1233 | |
| 1234 // Start sending and receiving video. | |
| 1235 video_receive_stream->Start(); | |
| 1150 video_send_stream_->Start(); | 1236 video_send_stream_->Start(); |
| 1151 capturer_->Start(); | 1237 capturer_->Start(); |
| 1152 | 1238 |
| 1239 if (params_.audio) { | |
| 1240 // Start receiving audio. | |
| 1241 audio_receive_stream->Start(); | |
| 1242 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); | |
| 1243 EXPECT_EQ(0, voe.base->StartReceive(voe.receive_channel_id)); | |
| 1244 | |
| 1245 // Start sending audio. | |
| 1246 audio_send_stream_->Start(); | |
| 1247 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id)); | |
| 1248 } | |
| 1249 | |
| 1153 test::PressEnterToContinue(); | 1250 test::PressEnterToContinue(); |
| 1154 | 1251 |
| 1252 if (params_.audio) { | |
| 1253 // Stop sending audio. | |
| 1254 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id)); | |
| 1255 audio_send_stream_->Stop(); | |
| 1256 | |
| 1257 // Stop receiving audio. | |
| 1258 EXPECT_EQ(0, voe.base->StopReceive(voe.receive_channel_id)); | |
| 1259 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id)); | |
| 1260 audio_receive_stream->Stop(); | |
| 1261 } | |
| 1262 | |
| 1263 // Stop receiving and sending video. | |
| 1155 capturer_->Stop(); | 1264 capturer_->Stop(); |
| 1156 video_send_stream_->Stop(); | 1265 video_send_stream_->Stop(); |
| 1157 receive_stream->Stop(); | 1266 video_receive_stream->Stop(); |
| 1158 | 1267 |
| 1159 call->DestroyVideoReceiveStream(receive_stream); | 1268 call->DestroyVideoReceiveStream(video_receive_stream); |
| 1160 call->DestroyVideoSendStream(video_send_stream_); | 1269 call->DestroyVideoSendStream(video_send_stream_); |
| 1161 | 1270 |
| 1271 if (params_.audio) { | |
| 1272 call->DestroyAudioSendStream(audio_send_stream_); | |
| 1273 call->DestroyAudioReceiveStream(audio_receive_stream); | |
| 1274 } | |
| 1275 | |
| 1162 transport.StopSending(); | 1276 transport.StopSending(); |
| 1277 if (params_.audio) | |
| 1278 DestroyVoiceEngine(&voe); | |
| 1163 } | 1279 } |
| 1164 | 1280 |
| 1165 } // namespace webrtc | 1281 } // namespace webrtc |
| OLD | NEW |