crazy linker: convert relocation unpacking to Android style.
[chromium-blink-merge.git] / media / audio / fake_audio_input_stream.h
blob4b8a98bceaf07d746f522e7928e771da6a75b226
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
3 // found in the LICENSE file.
4 //
5 // A fake implementation of AudioInputStream, useful for testing purpose.
7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
8 #define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
10 #include <vector>
12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "media/audio/audio_io.h"
15 #include "media/audio/audio_parameters.h"
16 #include "media/audio/fake_audio_worker.h"
19 namespace media {
21 class AudioBus;
22 class AudioManagerBase;
23 class SimpleSource;
25 // This class acts as a fake audio input stream. The default is to generate a
26 // beeping sound unless --use-file-for-fake-audio-capture=<file> is specified,
27 // in which case the indicated .wav file will be read and played into the
28 // stream.
29 class MEDIA_EXPORT FakeAudioInputStream
30 : public AudioInputStream {
31 public:
32 static AudioInputStream* MakeFakeStream(
33 AudioManagerBase* manager, const AudioParameters& params);
35 bool Open() override;
36 void Start(AudioInputCallback* callback) override;
37 void Stop() override;
38 void Close() override;
39 double GetMaxVolume() override;
40 void SetVolume(double volume) override;
41 double GetVolume() override;
42 bool IsMuted() override;
43 bool SetAutomaticGainControl(bool enabled) override;
44 bool GetAutomaticGainControl() override;
46 // Generate one beep sound. This method is called by FakeVideoCaptureDevice to
47 // test audio/video synchronization. This is a static method because
48 // FakeVideoCaptureDevice is disconnected from an audio device. This means
49 // only one instance of this class gets to respond, which is okay because we
50 // assume there's only one stream for this testing purpose. Furthermore this
51 // method will do nothing if --use-file-for-fake-audio-capture is specified
52 // since the input stream will be playing from a file instead of beeping.
53 // TODO(hclam): Make this non-static. To do this we'll need to fix
54 // crbug.com/159053 such that video capture device is aware of audio
55 // input stream.
56 static void BeepOnce();
58 private:
59 FakeAudioInputStream(AudioManagerBase* manager,
60 const AudioParameters& params);
61 ~FakeAudioInputStream() override;
63 scoped_ptr<AudioOutputStream::AudioSourceCallback> ChooseSource();
64 void ReadAudioFromSource();
66 AudioManagerBase* audio_manager_;
67 AudioInputCallback* callback_;
68 FakeAudioWorker fake_audio_worker_;
69 AudioParameters params_;
71 scoped_ptr<AudioOutputStream::AudioSourceCallback> audio_source_;
72 scoped_ptr<media::AudioBus> audio_bus_;
74 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream);
77 } // namespace media
79 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_