Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #ifndef WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ | 10 #ifndef WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ |
| 11 #define WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ | 11 #define WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "webrtc/base/criticalsection.h" | 15 #include "webrtc/base/criticalsection.h" |
| 16 #include "webrtc/base/platform_thread.h" | 16 #include "webrtc/base/platform_thread.h" |
| 17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
| 18 #include "webrtc/modules/audio_device/include/fake_audio_device.h" | 18 #include "webrtc/modules/audio_device/include/fake_audio_device.h" |
| 19 #include "webrtc/test/drifting_clock.h" | |
| 19 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
| 20 | 21 |
| 21 namespace webrtc { | 22 namespace webrtc { |
| 22 | 23 |
| 23 class Clock; | 24 class Clock; |
| 24 class EventTimerWrapper; | 25 class EventTimerWrapper; |
| 25 class FileWrapper; | 26 class FileWrapper; |
| 26 class ModuleFileUtility; | 27 class ModuleFileUtility; |
| 27 | 28 |
| 28 namespace test { | 29 namespace test { |
| 29 | 30 |
| 30 class FakeAudioDevice : public FakeAudioDeviceModule { | 31 class FakeAudioDevice : public FakeAudioDeviceModule { |
| 31 public: | 32 public: |
| 32 FakeAudioDevice(Clock* clock, const std::string& filename); | 33 FakeAudioDevice(Clock* clock, const std::string& filename, float drift); |
| 33 | 34 |
| 34 virtual ~FakeAudioDevice(); | 35 virtual ~FakeAudioDevice(); |
| 35 | 36 |
| 36 int32_t Init() override; | 37 int32_t Init() override; |
| 37 int32_t RegisterAudioCallback(AudioTransport* callback) override; | 38 int32_t RegisterAudioCallback(AudioTransport* callback) override; |
| 38 | 39 |
| 39 bool Playing() const override; | 40 bool Playing() const override; |
| 40 int32_t PlayoutDelay(uint16_t* delay_ms) const override; | 41 int32_t PlayoutDelay(uint16_t* delay_ms) const override; |
| 41 bool Recording() const override; | 42 bool Recording() const override; |
| 42 | 43 |
| 43 void Start(); | 44 void Start(); |
| 44 void Stop(); | 45 void Stop(); |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 static bool Run(void* obj); | 48 static bool Run(void* obj); |
| 48 void CaptureAudio(); | 49 void CaptureAudio(); |
| 49 | 50 |
| 50 static const uint32_t kFrequencyHz = 16000; | 51 static const uint32_t kFrequencyHz = 16000; |
| 51 static const size_t kBufferSizeBytes = 2 * kFrequencyHz; | 52 static const size_t kBufferSizeBytes = 2 * kFrequencyHz; |
| 52 | 53 |
| 53 AudioTransport* audio_callback_; | 54 AudioTransport* audio_callback_; |
| 54 bool capturing_; | 55 bool capturing_; |
| 55 int8_t captured_audio_[kBufferSizeBytes]; | 56 int8_t captured_audio_[kBufferSizeBytes]; |
| 56 int8_t playout_buffer_[kBufferSizeBytes]; | 57 int8_t playout_buffer_[kBufferSizeBytes]; |
| 58 float drift_ = .0; | |
|
pbos-webrtc
2016/02/09 21:06:18
Initialize in init-list or move all default-values
pbos-webrtc
2016/02/09 21:08:12
Also, const? This should always be taken from the
danilchap
2016/02/10 12:40:35
Done. It was done more like a comment what value t
| |
| 57 int64_t last_playout_ms_; | 59 int64_t last_playout_ms_; |
| 58 | 60 |
| 61 DriftingClock drifting_clock_; | |
| 59 Clock* clock_; | 62 Clock* clock_; |
| 60 rtc::scoped_ptr<EventTimerWrapper> tick_; | 63 rtc::scoped_ptr<EventTimerWrapper> tick_; |
| 61 rtc::CriticalSection lock_; | 64 rtc::CriticalSection lock_; |
| 62 rtc::PlatformThread thread_; | 65 rtc::PlatformThread thread_; |
| 63 rtc::scoped_ptr<ModuleFileUtility> file_utility_; | 66 rtc::scoped_ptr<ModuleFileUtility> file_utility_; |
| 64 rtc::scoped_ptr<FileWrapper> input_stream_; | 67 rtc::scoped_ptr<FileWrapper> input_stream_; |
| 65 }; | 68 }; |
| 66 } // namespace test | 69 } // namespace test |
| 67 } // namespace webrtc | 70 } // namespace webrtc |
| 68 | 71 |
| 69 #endif // WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ | 72 #endif // WEBRTC_TEST_FAKE_AUDIO_DEVICE_H_ |
| OLD | NEW |