| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/base/checks.h" | 10 #include "webrtc/base/checks.h" |
| 11 #include "webrtc/config.h" | 11 #include "webrtc/config.h" |
| 12 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 12 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
| 13 #include "webrtc/test/call_test.h" | 13 #include "webrtc/test/call_test.h" |
| 14 #include "webrtc/test/testsupport/fileutils.h" | 14 #include "webrtc/test/testsupport/fileutils.h" |
| 15 #include "webrtc/voice_engine/include/voe_base.h" | 15 #include "webrtc/voice_engine/include/voe_base.h" |
| 16 #include "webrtc/voice_engine/include/voe_codec.h" | |
| 17 | 16 |
| 18 namespace webrtc { | 17 namespace webrtc { |
| 19 namespace test { | 18 namespace test { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 const int kVideoRotationRtpExtensionId = 4; | 21 const int kVideoRotationRtpExtensionId = 4; |
| 23 } | 22 } |
| 24 | 23 |
| 25 CallTest::CallTest() | 24 CallTest::CallTest() |
| 26 : clock_(Clock::GetRealTimeClock()), | 25 : clock_(Clock::GetRealTimeClock()), |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 for (size_t i = 0; i < num_video_streams; ++i) | 193 for (size_t i = 0; i < num_video_streams; ++i) |
| 195 video_send_config_.rtp.ssrcs.push_back(kVideoSendSsrcs[i]); | 194 video_send_config_.rtp.ssrcs.push_back(kVideoSendSsrcs[i]); |
| 196 video_send_config_.rtp.extensions.push_back(RtpExtension( | 195 video_send_config_.rtp.extensions.push_back(RtpExtension( |
| 197 RtpExtension::kVideoRotationUri, kVideoRotationRtpExtensionId)); | 196 RtpExtension::kVideoRotationUri, kVideoRotationRtpExtensionId)); |
| 198 } | 197 } |
| 199 | 198 |
| 200 if (num_audio_streams > 0) { | 199 if (num_audio_streams > 0) { |
| 201 audio_send_config_ = AudioSendStream::Config(send_transport); | 200 audio_send_config_ = AudioSendStream::Config(send_transport); |
| 202 audio_send_config_.voe_channel_id = voe_send_.channel_id; | 201 audio_send_config_.voe_channel_id = voe_send_.channel_id; |
| 203 audio_send_config_.rtp.ssrc = kAudioSendSsrc; | 202 audio_send_config_.rtp.ssrc = kAudioSendSsrc; |
| 203 audio_send_config_.send_codec_spec.codec_inst = |
| 204 CodecInst{kAudioSendPayloadType, "ISAC", 16000, 480, 1, 32000}; |
| 204 } | 205 } |
| 205 } | 206 } |
| 206 | 207 |
| 207 void CallTest::CreateMatchingReceiveConfigs(Transport* rtcp_send_transport) { | 208 void CallTest::CreateMatchingReceiveConfigs(Transport* rtcp_send_transport) { |
| 208 RTC_DCHECK(video_receive_configs_.empty()); | 209 RTC_DCHECK(video_receive_configs_.empty()); |
| 209 RTC_DCHECK(allocated_decoders_.empty()); | 210 RTC_DCHECK(allocated_decoders_.empty()); |
| 210 if (num_video_streams_ > 0) { | 211 if (num_video_streams_ > 0) { |
| 211 RTC_DCHECK(!video_send_config_.rtp.ssrcs.empty()); | 212 RTC_DCHECK(!video_send_config_.rtp.ssrcs.empty()); |
| 212 VideoReceiveStream::Config video_config(rtcp_send_transport); | 213 VideoReceiveStream::Config video_config(rtcp_send_transport); |
| 213 video_config.rtp.remb = true; | 214 video_config.rtp.remb = true; |
| 214 video_config.rtp.local_ssrc = kReceiverLocalVideoSsrc; | 215 video_config.rtp.local_ssrc = kReceiverLocalVideoSsrc; |
| 215 for (const RtpExtension& extension : video_send_config_.rtp.extensions) | 216 for (const RtpExtension& extension : video_send_config_.rtp.extensions) |
| 216 video_config.rtp.extensions.push_back(extension); | 217 video_config.rtp.extensions.push_back(extension); |
| 217 video_config.renderer = &fake_renderer_; | 218 video_config.renderer = &fake_renderer_; |
| 218 for (size_t i = 0; i < video_send_config_.rtp.ssrcs.size(); ++i) { | 219 for (size_t i = 0; i < video_send_config_.rtp.ssrcs.size(); ++i) { |
| 219 VideoReceiveStream::Decoder decoder = | 220 VideoReceiveStream::Decoder decoder = |
| 220 test::CreateMatchingDecoder(video_send_config_.encoder_settings); | 221 test::CreateMatchingDecoder(video_send_config_.encoder_settings); |
| 221 allocated_decoders_.push_back( | 222 allocated_decoders_.push_back( |
| 222 std::unique_ptr<VideoDecoder>(decoder.decoder)); | 223 std::unique_ptr<VideoDecoder>(decoder.decoder)); |
| 223 video_config.decoders.clear(); | 224 video_config.decoders.clear(); |
| 224 video_config.decoders.push_back(decoder); | 225 video_config.decoders.push_back(decoder); |
| 225 video_config.rtp.remote_ssrc = video_send_config_.rtp.ssrcs[i]; | 226 video_config.rtp.remote_ssrc = video_send_config_.rtp.ssrcs[i]; |
| 226 video_receive_configs_.push_back(video_config.Copy()); | 227 video_receive_configs_.push_back(video_config.Copy()); |
| 227 } | 228 } |
| 228 } | 229 } |
| 229 | 230 |
| 230 RTC_DCHECK(num_audio_streams_ <= 1); | 231 RTC_DCHECK_GE(1u, num_audio_streams_); |
| 231 if (num_audio_streams_ == 1) { | 232 if (num_audio_streams_ == 1) { |
| 232 RTC_DCHECK(voe_send_.channel_id >= 0); | 233 RTC_DCHECK_LE(0, voe_send_.channel_id); |
| 233 AudioReceiveStream::Config audio_config; | 234 AudioReceiveStream::Config audio_config; |
| 234 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; | 235 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; |
| 235 audio_config.rtcp_send_transport = rtcp_send_transport; | 236 audio_config.rtcp_send_transport = rtcp_send_transport; |
| 236 audio_config.voe_channel_id = voe_recv_.channel_id; | 237 audio_config.voe_channel_id = voe_recv_.channel_id; |
| 237 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; | 238 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; |
| 238 audio_config.decoder_factory = decoder_factory_; | 239 audio_config.decoder_factory = decoder_factory_; |
| 239 audio_receive_configs_.push_back(audio_config); | 240 audio_receive_configs_.push_back(audio_config); |
| 240 } | 241 } |
| 241 } | 242 } |
| 242 | 243 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void CallTest::SetFakeVideoCaptureRotation(VideoRotation rotation) { | 285 void CallTest::SetFakeVideoCaptureRotation(VideoRotation rotation) { |
| 285 frame_generator_capturer_->SetFakeRotation(rotation); | 286 frame_generator_capturer_->SetFakeRotation(rotation); |
| 286 } | 287 } |
| 287 | 288 |
| 288 void CallTest::CreateAudioStreams() { | 289 void CallTest::CreateAudioStreams() { |
| 289 audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_); | 290 audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_); |
| 290 for (size_t i = 0; i < audio_receive_configs_.size(); ++i) { | 291 for (size_t i = 0; i < audio_receive_configs_.size(); ++i) { |
| 291 audio_receive_streams_.push_back( | 292 audio_receive_streams_.push_back( |
| 292 receiver_call_->CreateAudioReceiveStream(audio_receive_configs_[i])); | 293 receiver_call_->CreateAudioReceiveStream(audio_receive_configs_[i])); |
| 293 } | 294 } |
| 294 CodecInst isac = {kAudioSendPayloadType, "ISAC", 16000, 480, 1, 32000}; | |
| 295 EXPECT_EQ(0, voe_send_.codec->SetSendCodec(voe_send_.channel_id, isac)); | |
| 296 } | 295 } |
| 297 | 296 |
| 298 void CallTest::DestroyStreams() { | 297 void CallTest::DestroyStreams() { |
| 299 if (video_send_stream_) | 298 if (video_send_stream_) |
| 300 sender_call_->DestroyVideoSendStream(video_send_stream_); | 299 sender_call_->DestroyVideoSendStream(video_send_stream_); |
| 301 video_send_stream_ = nullptr; | 300 video_send_stream_ = nullptr; |
| 302 for (VideoReceiveStream* video_recv_stream : video_receive_streams_) | 301 for (VideoReceiveStream* video_recv_stream : video_receive_streams_) |
| 303 receiver_call_->DestroyVideoReceiveStream(video_recv_stream); | 302 receiver_call_->DestroyVideoReceiveStream(video_recv_stream); |
| 304 | 303 |
| 305 if (audio_send_stream_) | 304 if (audio_send_stream_) |
| 306 sender_call_->DestroyAudioSendStream(audio_send_stream_); | 305 sender_call_->DestroyAudioSendStream(audio_send_stream_); |
| 307 audio_send_stream_ = nullptr; | 306 audio_send_stream_ = nullptr; |
| 308 for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) | 307 for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) |
| 309 receiver_call_->DestroyAudioReceiveStream(audio_recv_stream); | 308 receiver_call_->DestroyAudioReceiveStream(audio_recv_stream); |
| 310 video_receive_streams_.clear(); | 309 video_receive_streams_.clear(); |
| 311 | 310 |
| 312 allocated_decoders_.clear(); | 311 allocated_decoders_.clear(); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void CallTest::CreateVoiceEngines() { | 314 void CallTest::CreateVoiceEngines() { |
| 316 CreateFakeAudioDevices(); | 315 CreateFakeAudioDevices(); |
| 317 voe_send_.voice_engine = VoiceEngine::Create(); | 316 voe_send_.voice_engine = VoiceEngine::Create(); |
| 318 voe_send_.base = VoEBase::GetInterface(voe_send_.voice_engine); | 317 voe_send_.base = VoEBase::GetInterface(voe_send_.voice_engine); |
| 319 voe_send_.codec = VoECodec::GetInterface(voe_send_.voice_engine); | |
| 320 EXPECT_EQ(0, voe_send_.base->Init(fake_send_audio_device_.get(), nullptr, | 318 EXPECT_EQ(0, voe_send_.base->Init(fake_send_audio_device_.get(), nullptr, |
| 321 decoder_factory_)); | 319 decoder_factory_)); |
| 322 VoEBase::ChannelConfig config; | 320 VoEBase::ChannelConfig config; |
| 323 config.enable_voice_pacing = true; | 321 config.enable_voice_pacing = true; |
| 324 voe_send_.channel_id = voe_send_.base->CreateChannel(config); | 322 voe_send_.channel_id = voe_send_.base->CreateChannel(config); |
| 325 EXPECT_GE(voe_send_.channel_id, 0); | 323 EXPECT_GE(voe_send_.channel_id, 0); |
| 326 | 324 |
| 327 voe_recv_.voice_engine = VoiceEngine::Create(); | 325 voe_recv_.voice_engine = VoiceEngine::Create(); |
| 328 voe_recv_.base = VoEBase::GetInterface(voe_recv_.voice_engine); | 326 voe_recv_.base = VoEBase::GetInterface(voe_recv_.voice_engine); |
| 329 voe_recv_.codec = VoECodec::GetInterface(voe_recv_.voice_engine); | |
| 330 EXPECT_EQ(0, voe_recv_.base->Init(fake_recv_audio_device_.get(), nullptr, | 327 EXPECT_EQ(0, voe_recv_.base->Init(fake_recv_audio_device_.get(), nullptr, |
| 331 decoder_factory_)); | 328 decoder_factory_)); |
| 332 voe_recv_.channel_id = voe_recv_.base->CreateChannel(); | 329 voe_recv_.channel_id = voe_recv_.base->CreateChannel(); |
| 333 EXPECT_GE(voe_recv_.channel_id, 0); | 330 EXPECT_GE(voe_recv_.channel_id, 0); |
| 334 } | 331 } |
| 335 | 332 |
| 336 void CallTest::DestroyVoiceEngines() { | 333 void CallTest::DestroyVoiceEngines() { |
| 337 voe_recv_.base->DeleteChannel(voe_recv_.channel_id); | 334 voe_recv_.base->DeleteChannel(voe_recv_.channel_id); |
| 338 voe_recv_.channel_id = -1; | 335 voe_recv_.channel_id = -1; |
| 339 voe_recv_.base->Release(); | 336 voe_recv_.base->Release(); |
| 340 voe_recv_.base = nullptr; | 337 voe_recv_.base = nullptr; |
| 341 voe_recv_.codec->Release(); | |
| 342 voe_recv_.codec = nullptr; | |
| 343 | 338 |
| 344 voe_send_.base->DeleteChannel(voe_send_.channel_id); | 339 voe_send_.base->DeleteChannel(voe_send_.channel_id); |
| 345 voe_send_.channel_id = -1; | 340 voe_send_.channel_id = -1; |
| 346 voe_send_.base->Release(); | 341 voe_send_.base->Release(); |
| 347 voe_send_.base = nullptr; | 342 voe_send_.base = nullptr; |
| 348 voe_send_.codec->Release(); | |
| 349 voe_send_.codec = nullptr; | |
| 350 | 343 |
| 351 VoiceEngine::Delete(voe_send_.voice_engine); | 344 VoiceEngine::Delete(voe_send_.voice_engine); |
| 352 voe_send_.voice_engine = nullptr; | 345 voe_send_.voice_engine = nullptr; |
| 353 VoiceEngine::Delete(voe_recv_.voice_engine); | 346 VoiceEngine::Delete(voe_recv_.voice_engine); |
| 354 voe_recv_.voice_engine = nullptr; | 347 voe_recv_.voice_engine = nullptr; |
| 355 } | 348 } |
| 356 | 349 |
| 357 const int CallTest::kDefaultWidth; | 350 const int CallTest::kDefaultWidth; |
| 358 const int CallTest::kDefaultHeight; | 351 const int CallTest::kDefaultHeight; |
| 359 const int CallTest::kDefaultFramerate; | 352 const int CallTest::kDefaultFramerate; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 437 |
| 445 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { | 438 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { |
| 446 } | 439 } |
| 447 | 440 |
| 448 bool EndToEndTest::ShouldCreateReceivers() const { | 441 bool EndToEndTest::ShouldCreateReceivers() const { |
| 449 return true; | 442 return true; |
| 450 } | 443 } |
| 451 | 444 |
| 452 } // namespace test | 445 } // namespace test |
| 453 } // namespace webrtc | 446 } // namespace webrtc |
| OLD | NEW |