| 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 <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "webrtc/audio/audio_state.h" | 13 #include "webrtc/audio/audio_state.h" |
| 14 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 14 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
| 15 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
| 15 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
| 16 #include "webrtc/test/mock_voice_engine.h" | 17 #include "webrtc/test/mock_voice_engine.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 namespace test { | 20 namespace test { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const int kSampleRate = 8000; | 23 const int kSampleRate = 8000; |
| 23 const int kNumberOfChannels = 1; | 24 const int kNumberOfChannels = 1; |
| 24 const int kBytesPerSample = 2; | 25 const int kBytesPerSample = 2; |
| 25 | 26 |
| 26 struct ConfigHelper { | 27 struct ConfigHelper { |
| 27 ConfigHelper() : audio_mixer(AudioMixerImpl::Create()) { | 28 ConfigHelper() : audio_mixer(AudioMixerImpl::Create()) { |
| 28 EXPECT_CALL(mock_voice_engine, RegisterVoiceEngineObserver(testing::_)) | 29 EXPECT_CALL(mock_voice_engine, RegisterVoiceEngineObserver(testing::_)) |
| 29 .WillOnce(testing::Return(0)); | 30 .WillOnce(testing::Return(0)); |
| 30 EXPECT_CALL(mock_voice_engine, DeRegisterVoiceEngineObserver()) | 31 EXPECT_CALL(mock_voice_engine, DeRegisterVoiceEngineObserver()) |
| 31 .WillOnce(testing::Return(0)); | 32 .WillOnce(testing::Return(0)); |
| 32 EXPECT_CALL(mock_voice_engine, audio_device_module()) | 33 EXPECT_CALL(mock_voice_engine, audio_device_module()) |
| 33 .Times(testing::AtLeast(1)); | 34 .Times(testing::AtLeast(1)); |
| 34 EXPECT_CALL(mock_voice_engine, audio_processing()) | |
| 35 .Times(testing::AtLeast(1)); | |
| 36 EXPECT_CALL(mock_voice_engine, audio_transport()) | 35 EXPECT_CALL(mock_voice_engine, audio_transport()) |
| 37 .WillRepeatedly(testing::Return(&audio_transport)); | 36 .WillRepeatedly(testing::Return(&audio_transport)); |
| 38 | 37 |
| 39 auto device = static_cast<MockAudioDeviceModule*>( | 38 auto device = static_cast<MockAudioDeviceModule*>( |
| 40 voice_engine().audio_device_module()); | 39 voice_engine().audio_device_module()); |
| 41 | 40 |
| 42 // Populate the audio transport proxy pointer to the most recent | 41 // Populate the audio transport proxy pointer to the most recent |
| 43 // transport connected to the Audio Device. | 42 // transport connected to the Audio Device. |
| 44 ON_CALL(*device, RegisterAudioCallback(testing::_)) | 43 ON_CALL(*device, RegisterAudioCallback(testing::_)) |
| 45 .WillByDefault(testing::Invoke([this](AudioTransport* transport) { | 44 .WillByDefault(testing::Invoke([this](AudioTransport* transport) { |
| 46 registered_audio_transport = transport; | 45 registered_audio_transport = transport; |
| 47 return 0; | 46 return 0; |
| 48 })); | 47 })); |
| 49 | 48 |
| 50 audio_state_config.voice_engine = &mock_voice_engine; | 49 audio_state_config.voice_engine = &mock_voice_engine; |
| 51 audio_state_config.audio_mixer = audio_mixer; | 50 audio_state_config.audio_mixer = audio_mixer; |
| 51 audio_state_config.audio_processing = |
| 52 new rtc::RefCountedObject<MockAudioProcessing>(); |
| 52 } | 53 } |
| 53 AudioState::Config& config() { return audio_state_config; } | 54 AudioState::Config& config() { return audio_state_config; } |
| 54 MockVoiceEngine& voice_engine() { return mock_voice_engine; } | 55 MockVoiceEngine& voice_engine() { return mock_voice_engine; } |
| 55 rtc::scoped_refptr<AudioMixer> mixer() { return audio_mixer; } | 56 rtc::scoped_refptr<AudioMixer> mixer() { return audio_mixer; } |
| 56 MockAudioTransport& original_audio_transport() { return audio_transport; } | 57 MockAudioTransport& original_audio_transport() { return audio_transport; } |
| 57 AudioTransport* audio_transport_proxy() { return registered_audio_transport; } | 58 AudioTransport* audio_transport_proxy() { return registered_audio_transport; } |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 testing::StrictMock<MockVoiceEngine> mock_voice_engine; | 61 testing::StrictMock<MockVoiceEngine> mock_voice_engine; |
| 61 AudioState::Config audio_state_config; | 62 AudioState::Config audio_state_config; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 int16_t audio_buffer[kSampleRate / 100 * kNumberOfChannels]; | 166 int16_t audio_buffer[kSampleRate / 100 * kNumberOfChannels]; |
| 166 size_t n_samples_out; | 167 size_t n_samples_out; |
| 167 int64_t elapsed_time_ms; | 168 int64_t elapsed_time_ms; |
| 168 int64_t ntp_time_ms; | 169 int64_t ntp_time_ms; |
| 169 helper.audio_transport_proxy()->NeedMorePlayData( | 170 helper.audio_transport_proxy()->NeedMorePlayData( |
| 170 kSampleRate / 100, kBytesPerSample, kNumberOfChannels, kSampleRate, | 171 kSampleRate / 100, kBytesPerSample, kNumberOfChannels, kSampleRate, |
| 171 audio_buffer, n_samples_out, &elapsed_time_ms, &ntp_time_ms); | 172 audio_buffer, n_samples_out, &elapsed_time_ms, &ntp_time_ms); |
| 172 } | 173 } |
| 173 } // namespace test | 174 } // namespace test |
| 174 } // namespace webrtc | 175 } // namespace webrtc |
| OLD | NEW |