| 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 <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "webrtc/audio/audio_send_stream.h" | 15 #include "webrtc/audio/audio_send_stream.h" |
| 16 #include "webrtc/audio/audio_state.h" | 16 #include "webrtc/audio/audio_state.h" |
| 17 #include "webrtc/audio/conversion.h" | 17 #include "webrtc/audio/conversion.h" |
| 18 #include "webrtc/base/ptr_util.h" |
| 18 #include "webrtc/base/task_queue.h" | 19 #include "webrtc/base/task_queue.h" |
| 20 #include "webrtc/call/fake_rtp_transport_controller_send.h" |
| 19 #include "webrtc/call/rtp_transport_controller_send_interface.h" | 21 #include "webrtc/call/rtp_transport_controller_send_interface.h" |
| 20 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" | 22 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" |
| 21 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 23 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
| 22 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" | 24 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
| 23 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_obse
rver.h" | 25 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_obse
rver.h" |
| 24 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" | 26 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.h" |
| 25 #include "webrtc/modules/pacing/paced_sender.h" | 27 #include "webrtc/modules/pacing/paced_sender.h" |
| 28 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" |
| 26 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" | 29 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" |
| 27 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h" | |
| 28 #include "webrtc/test/gtest.h" | 30 #include "webrtc/test/gtest.h" |
| 29 #include "webrtc/test/mock_audio_encoder.h" | 31 #include "webrtc/test/mock_audio_encoder.h" |
| 30 #include "webrtc/test/mock_audio_encoder_factory.h" | 32 #include "webrtc/test/mock_audio_encoder_factory.h" |
| 31 #include "webrtc/test/mock_voe_channel_proxy.h" | 33 #include "webrtc/test/mock_voe_channel_proxy.h" |
| 32 #include "webrtc/test/mock_voice_engine.h" | 34 #include "webrtc/test/mock_voice_engine.h" |
| 33 #include "webrtc/voice_engine/transmit_mixer.h" | 35 #include "webrtc/voice_engine/transmit_mixer.h" |
| 34 | 36 |
| 35 namespace webrtc { | 37 namespace webrtc { |
| 36 namespace test { | 38 namespace test { |
| 37 namespace { | 39 namespace { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 })); | 119 })); |
| 118 ON_CALL(*factory.get(), MakeAudioEncoderMock(_, _, _)) | 120 ON_CALL(*factory.get(), MakeAudioEncoderMock(_, _, _)) |
| 119 .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format, | 121 .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format, |
| 120 std::unique_ptr<AudioEncoder>* return_value) { | 122 std::unique_ptr<AudioEncoder>* return_value) { |
| 121 *return_value = SetupAudioEncoderMock(payload_type, format); | 123 *return_value = SetupAudioEncoderMock(payload_type, format); |
| 122 })); | 124 })); |
| 123 return factory; | 125 return factory; |
| 124 } | 126 } |
| 125 | 127 |
| 126 struct ConfigHelper { | 128 struct ConfigHelper { |
| 127 class FakeRtpTransportController | |
| 128 : public RtpTransportControllerSendInterface { | |
| 129 public: | |
| 130 explicit FakeRtpTransportController(RtcEventLog* event_log) | |
| 131 : simulated_clock_(123456), | |
| 132 send_side_cc_(&simulated_clock_, | |
| 133 &bitrate_observer_, | |
| 134 event_log, | |
| 135 &packet_router_) {} | |
| 136 PacketRouter* packet_router() override { return &packet_router_; } | |
| 137 | |
| 138 SendSideCongestionController* send_side_cc() override { | |
| 139 return &send_side_cc_; | |
| 140 } | |
| 141 TransportFeedbackObserver* transport_feedback_observer() override { | |
| 142 return &send_side_cc_; | |
| 143 } | |
| 144 | |
| 145 RtpPacketSender* packet_sender() override { return send_side_cc_.pacer(); } | |
| 146 | |
| 147 private: | |
| 148 SimulatedClock simulated_clock_; | |
| 149 testing::NiceMock<MockCongestionObserver> bitrate_observer_; | |
| 150 PacketRouter packet_router_; | |
| 151 SendSideCongestionController send_side_cc_; | |
| 152 }; | |
| 153 | |
| 154 ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call) | 129 ConfigHelper(bool audio_bwe_enabled, bool expect_set_encoder_call) |
| 155 : stream_config_(nullptr), | 130 : stream_config_(nullptr), |
| 156 fake_transport_(&event_log_), | 131 simulated_clock_(123456), |
| 132 send_side_cc_(rtc::MakeUnique<SendSideCongestionController>( |
| 133 &simulated_clock_, |
| 134 nullptr /* observer */, |
| 135 &event_log_, |
| 136 &packet_router_)), |
| 137 fake_transport_(send_side_cc_.get()), |
| 157 bitrate_allocator_(&limit_observer_), | 138 bitrate_allocator_(&limit_observer_), |
| 158 worker_queue_("ConfigHelper_worker_queue") { | 139 worker_queue_("ConfigHelper_worker_queue") { |
| 159 using testing::Invoke; | 140 using testing::Invoke; |
| 160 | 141 |
| 161 EXPECT_CALL(voice_engine_, | 142 EXPECT_CALL(voice_engine_, |
| 162 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 143 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
| 163 EXPECT_CALL(voice_engine_, | 144 EXPECT_CALL(voice_engine_, |
| 164 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 145 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
| 165 EXPECT_CALL(voice_engine_, audio_device_module()); | 146 EXPECT_CALL(voice_engine_, audio_device_module()); |
| 166 EXPECT_CALL(voice_engine_, audio_processing()); | 147 EXPECT_CALL(voice_engine_, audio_processing()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 296 |
| 316 EXPECT_CALL(audio_processing_, GetStatistics()) | 297 EXPECT_CALL(audio_processing_, GetStatistics()) |
| 317 .WillRepeatedly(Return(audio_processing_stats_)); | 298 .WillRepeatedly(Return(audio_processing_stats_)); |
| 318 } | 299 } |
| 319 | 300 |
| 320 private: | 301 private: |
| 321 testing::StrictMock<MockVoiceEngine> voice_engine_; | 302 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 322 rtc::scoped_refptr<AudioState> audio_state_; | 303 rtc::scoped_refptr<AudioState> audio_state_; |
| 323 AudioSendStream::Config stream_config_; | 304 AudioSendStream::Config stream_config_; |
| 324 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; | 305 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
| 325 testing::NiceMock<MockCongestionObserver> bitrate_observer_; | |
| 326 MockAudioProcessing audio_processing_; | 306 MockAudioProcessing audio_processing_; |
| 327 MockTransmitMixer transmit_mixer_; | 307 MockTransmitMixer transmit_mixer_; |
| 328 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; | 308 AudioProcessing::AudioProcessingStatistics audio_processing_stats_; |
| 329 FakeRtpTransportController fake_transport_; | 309 SimulatedClock simulated_clock_; |
| 310 PacketRouter packet_router_; |
| 311 std::unique_ptr<SendSideCongestionController> send_side_cc_; |
| 312 FakeRtpTransportControllerSend fake_transport_; |
| 330 MockRtcEventLog event_log_; | 313 MockRtcEventLog event_log_; |
| 331 MockRtpRtcp rtp_rtcp_; | 314 MockRtpRtcp rtp_rtcp_; |
| 332 MockRtcpRttStats rtcp_rtt_stats_; | 315 MockRtcpRttStats rtcp_rtt_stats_; |
| 333 testing::NiceMock<MockLimitObserver> limit_observer_; | 316 testing::NiceMock<MockLimitObserver> limit_observer_; |
| 334 BitrateAllocator bitrate_allocator_; | 317 BitrateAllocator bitrate_allocator_; |
| 335 // |worker_queue| is defined last to ensure all pending tasks are cancelled | 318 // |worker_queue| is defined last to ensure all pending tasks are cancelled |
| 336 // and deleted before any other members. | 319 // and deleted before any other members. |
| 337 rtc::TaskQueue worker_queue_; | 320 rtc::TaskQueue worker_queue_; |
| 338 }; | 321 }; |
| 339 } // namespace | 322 } // namespace |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105); | 537 stream_config.send_codec_spec->cng_payload_type = rtc::Optional<int>(105); |
| 555 internal::AudioSendStream send_stream( | 538 internal::AudioSendStream send_stream( |
| 556 stream_config, helper.audio_state(), helper.worker_queue(), | 539 stream_config, helper.audio_state(), helper.worker_queue(), |
| 557 helper.transport(), helper.bitrate_allocator(), helper.event_log(), | 540 helper.transport(), helper.bitrate_allocator(), helper.event_log(), |
| 558 helper.rtcp_rtt_stats()); | 541 helper.rtcp_rtt_stats()); |
| 559 send_stream.Reconfigure(stream_config); | 542 send_stream.Reconfigure(stream_config); |
| 560 } | 543 } |
| 561 | 544 |
| 562 } // namespace test | 545 } // namespace test |
| 563 } // namespace webrtc | 546 } // namespace webrtc |
| OLD | NEW |