Chromium Code Reviews| Index: webrtc/test/fake_audio_device.h |
| diff --git a/webrtc/test/fake_audio_device.h b/webrtc/test/fake_audio_device.h |
| index 77a74bac8f6d1bc962cf8b8aceea9313f9c50bec..c7ae60278381eae2fb2e0643466d40165724a218 100644 |
| --- a/webrtc/test/fake_audio_device.h |
| +++ b/webrtc/test/fake_audio_device.h |
| @@ -13,6 +13,7 @@ |
| #include <memory> |
| #include <string> |
| +#include "webrtc/base/buffer.h" |
| #include "webrtc/base/criticalsection.h" |
| #include "webrtc/base/platform_thread.h" |
| #include "webrtc/modules/audio_device/include/fake_audio_device.h" |
| @@ -23,17 +24,26 @@ namespace webrtc { |
| class Clock; |
| class EventTimerWrapper; |
| -class FileWrapper; |
| -class ModuleFileUtility; |
| namespace test { |
| class FakeAudioDevice : public FakeAudioDeviceModule { |
| public: |
| - FakeAudioDevice(Clock* clock, const std::string& filename, float speed); |
| + // Creates a new FakeAudioDevice. |speed| controls how much faster or slower |
| + // time elapse compared to the system clock. It can be used to simulate |
| + // clock drift. 1.0 means that the system clock will be used. |
| + FakeAudioDevice(Clock* clock, float speed, int sampling_frequency_in_hz); |
| + ~FakeAudioDevice() override; |
| - virtual ~FakeAudioDevice(); |
| + int32_t StartPlayout() override; |
| + int32_t StopPlayout() override; |
| + // Generates a signal where every second frame is zero and every second frame |
| + // is evenly distributed random noise with max amplitude |max_amplitude|. |
| + void StartRecordingPulsedNoise(int16_t max_amplitude); |
| + int32_t StopRecording() override; |
| + |
| + private: |
| int32_t Init() override; |
| int32_t RegisterAudioCallback(AudioTransport* callback) override; |
| @@ -41,29 +51,26 @@ class FakeAudioDevice : public FakeAudioDeviceModule { |
| int32_t PlayoutDelay(uint16_t* delay_ms) const override; |
| bool Recording() const override; |
| - void Start(); |
| - void Stop(); |
| - |
| - private: |
| static bool Run(void* obj); |
| - void CaptureAudio(); |
| + void ProcessAudio(); |
| - static const uint32_t kFrequencyHz = 16000; |
| - static const size_t kBufferSizeBytes = 2 * kFrequencyHz; |
| + const int sampling_frequency_in_hz_; |
| - AudioTransport* audio_callback_; |
| - bool capturing_; |
| - int8_t captured_audio_[kBufferSizeBytes]; |
| - int8_t playout_buffer_[kBufferSizeBytes]; |
| + rtc::CriticalSection lock_; |
| + AudioTransport* audio_callback_ GUARDED_BY(lock_); |
| + bool rendering_ GUARDED_BY(lock_); |
| + |
| + class PulsedNoiseCapturer; |
| + std::unique_ptr<PulsedNoiseCapturer> capturer_ GUARDED_BY(lock_); |
| + |
| + // Used for playout. |
| + rtc::BufferT<int16_t> playout_buffer_; |
|
peah-webrtc
2017/01/26 09:24:00
Since the size of playout_buffer_ is static, I thi
|
| const float speed_; |
| int64_t last_playout_ms_; |
| DriftingClock clock_; |
| std::unique_ptr<EventTimerWrapper> tick_; |
| - rtc::CriticalSection lock_; |
| rtc::PlatformThread thread_; |
| - std::unique_ptr<ModuleFileUtility> file_utility_; |
| - std::unique_ptr<FileWrapper> input_stream_; |
| }; |
| } // namespace test |
| } // namespace webrtc |