| 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 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "webrtc/api/test/mock_audio_mixer.h" | 16 #include "webrtc/api/test/mock_audio_mixer.h" |
| 17 #include "webrtc/base/ptr_util.h" | 17 #include "webrtc/base/ptr_util.h" |
| 18 #include "webrtc/call/audio_state.h" | 18 #include "webrtc/call/audio_state.h" |
| 19 #include "webrtc/call/call.h" | 19 #include "webrtc/call/call.h" |
| 20 #include "webrtc/call/fake_rtp_transport_controller_send.h" | 20 #include "webrtc/call/fake_rtp_transport_controller_send.h" |
| 21 #include "webrtc/call/rtp_transport_controller_send.h" |
| 21 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 22 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 22 #include "webrtc/modules/audio_device/include/mock_audio_device.h" | 23 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
| 23 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 24 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
| 24 #include "webrtc/modules/congestion_controller/include/mock/mock_send_side_conge
stion_controller.h" | 25 #include "webrtc/modules/congestion_controller/include/mock/mock_send_side_conge
stion_controller.h" |
| 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 26 #include "webrtc/test/gtest.h" | 27 #include "webrtc/test/gtest.h" |
| 27 #include "webrtc/test/mock_audio_decoder_factory.h" | 28 #include "webrtc/test/mock_audio_decoder_factory.h" |
| 28 #include "webrtc/test/mock_transport.h" | 29 #include "webrtc/test/mock_transport.h" |
| 29 #include "webrtc/test/mock_voice_engine.h" | 30 #include "webrtc/test/mock_voice_engine.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 struct CallHelper { | 34 struct CallHelper { |
| 34 explicit CallHelper( | 35 explicit CallHelper( |
| 35 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory = nullptr) | 36 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory = nullptr) |
| 36 : voice_engine_(decoder_factory) { | 37 : voice_engine_(decoder_factory) { |
| 37 webrtc::AudioState::Config audio_state_config; | 38 webrtc::AudioState::Config audio_state_config; |
| 38 audio_state_config.voice_engine = &voice_engine_; | 39 audio_state_config.voice_engine = &voice_engine_; |
| 39 audio_state_config.audio_mixer = webrtc::AudioMixerImpl::Create(); | 40 audio_state_config.audio_mixer = webrtc::AudioMixerImpl::Create(); |
| 40 EXPECT_CALL(voice_engine_, audio_device_module()); | 41 EXPECT_CALL(voice_engine_, audio_device_module()); |
| 41 EXPECT_CALL(voice_engine_, audio_processing()); | 42 EXPECT_CALL(voice_engine_, audio_processing()); |
| 42 EXPECT_CALL(voice_engine_, audio_transport()); | 43 EXPECT_CALL(voice_engine_, audio_transport()); |
| 44 |
| 45 rtp_transport_send_ = rtc::MakeUnique<webrtc::RtpTransportControllerSend>( |
| 46 webrtc::Clock::GetRealTimeClock(), &event_log_); |
| 47 |
| 43 webrtc::Call::Config config(&event_log_); | 48 webrtc::Call::Config config(&event_log_); |
| 44 config.audio_state = webrtc::AudioState::Create(audio_state_config); | 49 config.audio_state = webrtc::AudioState::Create(audio_state_config); |
| 45 call_.reset(webrtc::Call::Create(config)); | 50 config.audio_rtp_transport_send = rtp_transport_send_.get(); |
| 51 config.video_rtp_transport_send = rtp_transport_send_.get(); |
| 52 config.send_side_cc = rtp_transport_send_->send_side_cc(); |
| 53 call_ = rtc::WrapUnique(webrtc::Call::Create(config)); |
| 46 } | 54 } |
| 47 | 55 |
| 48 webrtc::Call* operator->() { return call_.get(); } | 56 webrtc::Call* operator->() { return call_.get(); } |
| 49 webrtc::test::MockVoiceEngine* voice_engine() { return &voice_engine_; } | 57 webrtc::test::MockVoiceEngine* voice_engine() { return &voice_engine_; } |
| 50 | 58 |
| 51 private: | 59 private: |
| 52 testing::NiceMock<webrtc::test::MockVoiceEngine> voice_engine_; | 60 testing::NiceMock<webrtc::test::MockVoiceEngine> voice_engine_; |
| 53 webrtc::RtcEventLogNullImpl event_log_; | 61 webrtc::RtcEventLogNullImpl event_log_; |
| 62 std::unique_ptr<webrtc::RtpTransportControllerSend> rtp_transport_send_; |
| 54 std::unique_ptr<webrtc::Call> call_; | 63 std::unique_ptr<webrtc::Call> call_; |
| 55 }; | 64 }; |
| 56 } // namespace | 65 } // namespace |
| 57 | 66 |
| 58 namespace webrtc { | 67 namespace webrtc { |
| 59 | 68 |
| 60 TEST(CallTest, ConstructDestruct) { | 69 TEST(CallTest, ConstructDestruct) { |
| 61 CallHelper call; | 70 CallHelper call; |
| 62 } | 71 } |
| 63 | 72 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 EXPECT_NE(stream, nullptr); | 322 EXPECT_NE(stream, nullptr); |
| 314 streams.push_back(stream); | 323 streams.push_back(stream); |
| 315 | 324 |
| 316 for (auto s : streams) { | 325 for (auto s : streams) { |
| 317 call->DestroyFlexfecReceiveStream(s); | 326 call->DestroyFlexfecReceiveStream(s); |
| 318 } | 327 } |
| 319 } | 328 } |
| 320 | 329 |
| 321 namespace { | 330 namespace { |
| 322 struct CallBitrateHelper { | 331 struct CallBitrateHelper { |
| 323 CallBitrateHelper() : CallBitrateHelper(Call::Config(&event_log_)) {} | 332 CallBitrateHelper() |
| 333 : mock_cc_(Clock::GetRealTimeClock(), &event_log_, &packet_router_), |
| 334 transport_send(&packet_router_, &mock_cc_) { |
| 335 Call::Config config(&event_log_); |
| 336 config.audio_rtp_transport_send = &transport_send; |
| 337 config.video_rtp_transport_send = &transport_send; |
| 324 | 338 |
| 325 explicit CallBitrateHelper(const Call::Config& config) | 339 call_ = rtc::WrapUnique(Call::Create(config)); |
| 326 : mock_cc_(Clock::GetRealTimeClock(), &event_log_, &packet_router_), | 340 } |
| 327 call_(Call::Create( | |
| 328 config, | |
| 329 rtc::MakeUnique<FakeRtpTransportControllerSend>(&packet_router_, | |
| 330 &mock_cc_))) {} | |
| 331 | |
| 332 webrtc::Call* operator->() { return call_.get(); } | 341 webrtc::Call* operator->() { return call_.get(); } |
| 333 testing::NiceMock<test::MockSendSideCongestionController>& mock_cc() { | 342 testing::NiceMock<test::MockSendSideCongestionController>& mock_cc() { |
| 334 return mock_cc_; | 343 return mock_cc_; |
| 335 } | 344 } |
| 336 | 345 |
| 337 private: | 346 private: |
| 338 webrtc::RtcEventLogNullImpl event_log_; | 347 webrtc::RtcEventLogNullImpl event_log_; |
| 339 PacketRouter packet_router_; | 348 PacketRouter packet_router_; |
| 340 testing::NiceMock<test::MockSendSideCongestionController> mock_cc_; | 349 testing::NiceMock<test::MockSendSideCongestionController> mock_cc_; |
| 350 FakeRtpTransportControllerSend transport_send; |
| 341 std::unique_ptr<Call> call_; | 351 std::unique_ptr<Call> call_; |
| 342 }; | 352 }; |
| 343 } // namespace | 353 } // namespace |
| 344 | 354 |
| 345 TEST(CallBitrateTest, SetBitrateConfigWithValidConfigCallsSetBweBitrates) { | 355 TEST(CallBitrateTest, SetBitrateConfigWithValidConfigCallsSetBweBitrates) { |
| 346 CallBitrateHelper call; | 356 CallBitrateHelper call; |
| 347 | 357 |
| 348 Call::Config::BitrateConfig bitrate_config; | 358 Call::Config::BitrateConfig bitrate_config; |
| 349 bitrate_config.min_bitrate_bps = 1; | 359 bitrate_config.min_bitrate_bps = 1; |
| 350 bitrate_config.start_bitrate_bps = 2; | 360 bitrate_config.start_bitrate_bps = 2; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 VoEBase* base; | 461 VoEBase* base; |
| 452 }; | 462 }; |
| 453 ScopedVoiceEngine voice_engine; | 463 ScopedVoiceEngine voice_engine; |
| 454 | 464 |
| 455 voice_engine.base->Init(&mock_adm); | 465 voice_engine.base->Init(&mock_adm); |
| 456 AudioState::Config audio_state_config; | 466 AudioState::Config audio_state_config; |
| 457 audio_state_config.voice_engine = voice_engine.voe; | 467 audio_state_config.voice_engine = voice_engine.voe; |
| 458 audio_state_config.audio_mixer = mock_mixer; | 468 audio_state_config.audio_mixer = mock_mixer; |
| 459 auto audio_state = AudioState::Create(audio_state_config); | 469 auto audio_state = AudioState::Create(audio_state_config); |
| 460 RtcEventLogNullImpl event_log; | 470 RtcEventLogNullImpl event_log; |
| 471 RtpTransportControllerSend rtp_transport_send( |
| 472 webrtc::Clock::GetRealTimeClock(), &event_log); |
| 461 Call::Config call_config(&event_log); | 473 Call::Config call_config(&event_log); |
| 462 call_config.audio_state = audio_state; | 474 call_config.audio_state = audio_state; |
| 475 call_config.audio_rtp_transport_send = &rtp_transport_send; |
| 476 call_config.video_rtp_transport_send = &rtp_transport_send; |
| 477 call_config.send_side_cc = rtp_transport_send.send_side_cc(); |
| 463 std::unique_ptr<Call> call(Call::Create(call_config)); | 478 std::unique_ptr<Call> call(Call::Create(call_config)); |
| 464 | 479 |
| 465 auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) { | 480 auto create_stream_and_get_rtp_state = [&](uint32_t ssrc) { |
| 466 AudioSendStream::Config config(nullptr); | 481 AudioSendStream::Config config(nullptr); |
| 467 config.rtp.ssrc = ssrc; | 482 config.rtp.ssrc = ssrc; |
| 468 config.voe_channel_id = voice_engine.base->CreateChannel(); | 483 config.voe_channel_id = voice_engine.base->CreateChannel(); |
| 469 AudioSendStream* stream = call->CreateAudioSendStream(config); | 484 AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 470 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine.voe); | 485 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine.voe); |
| 471 auto channel_proxy = voe_impl->GetChannelProxy(config.voe_channel_id); | 486 auto channel_proxy = voe_impl->GetChannelProxy(config.voe_channel_id); |
| 472 RtpRtcp* rtp_rtcp = nullptr; | 487 RtpRtcp* rtp_rtcp = nullptr; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 484 EXPECT_EQ(rtp_state1.sequence_number, rtp_state2.sequence_number); | 499 EXPECT_EQ(rtp_state1.sequence_number, rtp_state2.sequence_number); |
| 485 EXPECT_EQ(rtp_state1.start_timestamp, rtp_state2.start_timestamp); | 500 EXPECT_EQ(rtp_state1.start_timestamp, rtp_state2.start_timestamp); |
| 486 EXPECT_EQ(rtp_state1.timestamp, rtp_state2.timestamp); | 501 EXPECT_EQ(rtp_state1.timestamp, rtp_state2.timestamp); |
| 487 EXPECT_EQ(rtp_state1.capture_time_ms, rtp_state2.capture_time_ms); | 502 EXPECT_EQ(rtp_state1.capture_time_ms, rtp_state2.capture_time_ms); |
| 488 EXPECT_EQ(rtp_state1.last_timestamp_time_ms, | 503 EXPECT_EQ(rtp_state1.last_timestamp_time_ms, |
| 489 rtp_state2.last_timestamp_time_ms); | 504 rtp_state2.last_timestamp_time_ms); |
| 490 EXPECT_EQ(rtp_state1.media_has_been_sent, rtp_state2.media_has_been_sent); | 505 EXPECT_EQ(rtp_state1.media_has_been_sent, rtp_state2.media_has_been_sent); |
| 491 } | 506 } |
| 492 | 507 |
| 493 } // namespace webrtc | 508 } // namespace webrtc |
| OLD | NEW |