| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A fake implementation of AudioInputStream, useful for testing purpose. | 5 // A fake implementation of AudioInputStream, useful for testing purpose. |
| 6 | 6 |
| 7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | 7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ |
| 8 #define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | 8 #define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "media/audio/audio_io.h" | 16 #include "media/audio/audio_io.h" |
| 17 #include "media/audio/audio_parameters.h" | 17 #include "media/audio/audio_parameters.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 class AudioBus; | 21 class AudioBus; |
| 22 class AudioManagerBase; | 22 class AudioManagerBase; |
| 23 | 23 |
| 24 class MEDIA_EXPORT FakeAudioInputStream | 24 class MEDIA_EXPORT FakeAudioInputStream |
| 25 : public AudioInputStream { | 25 : public AudioInputStream { |
| 26 public: | 26 public: |
| 27 static AudioInputStream* MakeFakeStream(AudioManagerBase* manager, | 27 static AudioInputStream* MakeFakeStream(AudioManagerBase* manager, |
| 28 const AudioParameters& params); | 28 const AudioParameters& params); |
| 29 | 29 |
| 30 virtual bool Open() OVERRIDE; | 30 virtual bool Open() override; |
| 31 virtual void Start(AudioInputCallback* callback) OVERRIDE; | 31 virtual void Start(AudioInputCallback* callback) override; |
| 32 virtual void Stop() OVERRIDE; | 32 virtual void Stop() override; |
| 33 virtual void Close() OVERRIDE; | 33 virtual void Close() override; |
| 34 virtual double GetMaxVolume() OVERRIDE; | 34 virtual double GetMaxVolume() override; |
| 35 virtual void SetVolume(double volume) OVERRIDE; | 35 virtual void SetVolume(double volume) override; |
| 36 virtual double GetVolume() OVERRIDE; | 36 virtual double GetVolume() override; |
| 37 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE; | 37 virtual void SetAutomaticGainControl(bool enabled) override; |
| 38 virtual bool GetAutomaticGainControl() OVERRIDE; | 38 virtual bool GetAutomaticGainControl() override; |
| 39 | 39 |
| 40 // Generate one beep sound. This method is called by | 40 // Generate one beep sound. This method is called by |
| 41 // FakeVideoCaptureDevice to test audio/video synchronization. | 41 // FakeVideoCaptureDevice to test audio/video synchronization. |
| 42 // This is a static method because FakeVideoCaptureDevice is | 42 // This is a static method because FakeVideoCaptureDevice is |
| 43 // disconnected from an audio device. This means only one instance of | 43 // disconnected from an audio device. This means only one instance of |
| 44 // this class gets to respond, which is okay because we assume there's | 44 // this class gets to respond, which is okay because we assume there's |
| 45 // only one stream for this testing purpose. | 45 // only one stream for this testing purpose. |
| 46 // TODO(hclam): Make this non-static. To do this we'll need to fix | 46 // TODO(hclam): Make this non-static. To do this we'll need to fix |
| 47 // crbug.com/159053 such that video capture device is aware of audio | 47 // crbug.com/159053 such that video capture device is aware of audio |
| 48 // input stream. | 48 // input stream. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 // Allows us to run tasks on the FakeAudioInputStream instance which are | 74 // Allows us to run tasks on the FakeAudioInputStream instance which are |
| 75 // bound by its lifetime. | 75 // bound by its lifetime. |
| 76 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; | 76 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); | 78 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace media | 81 } // namespace media |
| 82 | 82 |
| 83 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | 83 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ |
| OLD | NEW |