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..3057f92dd9d6c103dd30ccbbda7bcb57c2c41157 100644 |
--- a/webrtc/test/fake_audio_device.h |
+++ b/webrtc/test/fake_audio_device.h |
@@ -12,28 +12,38 @@ |
#include <memory> |
#include <string> |
+#include <vector> |
#include "webrtc/base/criticalsection.h" |
#include "webrtc/base/platform_thread.h" |
#include "webrtc/modules/audio_device/include/fake_audio_device.h" |
-#include "webrtc/test/drifting_clock.h" |
#include "webrtc/typedefs.h" |
namespace webrtc { |
-class Clock; |
class EventTimerWrapper; |
-class FileWrapper; |
-class ModuleFileUtility; |
namespace test { |
+// FakeAudioDevice implements an AudioDevice module that can act both as a |
+// capturer and a renderer. It will use 10ms audio frames. |
class FakeAudioDevice : public FakeAudioDeviceModule { |
public: |
- FakeAudioDevice(Clock* clock, const std::string& filename, float speed); |
+ // Creates a new FakeAudioDevice. When capturing or playing, 10 ms audio |
+ // frames will be processed every 100ms / |speed|. |
+ // |sampling_frequency_in_hz| can be 8, 16, 32, 44.1 or 48kHz. |
+ FakeAudioDevice(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,24 @@ 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_; |
+ const int num_samples_per_frame_; |
- 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_); |
+ |
+ std::vector<int16_t> playout_buffer_ GUARDED_BY(lock_); |
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 |