OLD | NEW |
---|---|
(Empty) | |
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 #ifndef MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_ | |
6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 | |
11 #include "base/cancelable_callback.h" | |
12 #include "base/gtest_prod_util.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "media/audio/audio_io.h" | |
15 #include "media/audio/audio_manager_base.h" | |
16 #include "media/audio/audio_parameters.h" | |
17 #include "media/base/audio_converter.h" | |
18 | |
19 namespace media { | |
20 | |
21 class LoopbackAudioConverter; | |
22 class VirtualAudioOutputStream; | |
23 | |
24 // Virtual audio input stream which is used for audio mirroring through the | |
25 // TabCaptureApi. This audio stream uses virtual audio output streams as input | |
Alpha Left Google
2012/11/28 01:04:47
No need to mention TabCaptureApi, just say this is
justinlin
2012/11/28 14:30:31
Done.
| |
26 // and will mix them together to render audio. It will continuously render | |
27 // audio until the audio mirroring session is ended. | |
28 class MEDIA_EXPORT VirtualAudioInputStream | |
29 : public AudioInputStream { | |
30 public: | |
31 static VirtualAudioInputStream* MakeStream(AudioManagerBase* manager, | |
32 const AudioParameters& params); | |
33 | |
34 // AudioInputStream: | |
35 virtual bool Open() OVERRIDE; | |
36 virtual void Start(AudioInputCallback* callback) OVERRIDE; | |
37 virtual void Stop() OVERRIDE; | |
38 virtual void Close() OVERRIDE; | |
39 virtual double GetMaxVolume() OVERRIDE; | |
40 virtual void SetVolume(double volume) OVERRIDE; | |
41 virtual double GetVolume() OVERRIDE; | |
42 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE; | |
43 virtual bool GetAutomaticGainControl() OVERRIDE; | |
44 | |
45 // Attaches a virtual audio output stream to be used as input. | |
46 void AddOutputStream( | |
Alpha Left Google
2012/11/28 01:04:47
Mention ownership here, is VAOS owned by this clas
justinlin
2012/11/28 14:30:31
Done.
I think it's common that all streams are own
| |
47 VirtualAudioOutputStream* stream, const AudioParameters& params); | |
48 // Detaches a virtual audio output stream that went away (i.e. video closed). | |
Alpha Left Google
2012/11/28 01:04:47
nit: empty line before comments. It's confusing to
justinlin
2012/11/28 14:30:31
Done.
| |
49 void RemoveOutputStream(VirtualAudioOutputStream* stream); | |
50 | |
51 protected: | |
52 friend class VirtualAudioInputStreamTest; | |
53 FRIEND_TEST_ALL_PREFIXES(AudioOutputControllerTest, | |
54 VirtualStreamsTriggerDeviceChange); | |
55 | |
56 typedef std::map<AudioParameters, LoopbackAudioConverter*> AudioConvertersMap; | |
57 typedef std::map<AudioOutputStream*, AudioParameters> OutputStreamParams; | |
58 | |
59 void DoCallback(); | |
Alpha Left Google
2012/11/28 01:04:47
Need more detailed comments.
justinlin
2012/11/28 14:30:31
Done.
| |
60 | |
61 VirtualAudioInputStream(AudioManagerBase* manager, | |
62 const AudioParameters& params); | |
63 | |
64 virtual ~VirtualAudioInputStream(); | |
65 | |
66 AudioManagerBase* audio_manager_; | |
67 AudioInputCallback* callback_; | |
68 const int buffer_duration_ms_; | |
69 base::Time next_read_time_; | |
70 scoped_array<uint8> buffer_; | |
71 AudioParameters params_; | |
72 scoped_ptr<AudioBus> audio_bus_; | |
73 base::CancelableClosure on_more_data_cb_; | |
74 // AudioConverters associated with the attached virtual audio output streams, | |
Alpha Left Google
2012/11/28 01:04:47
nit: empty line before comments.
justinlin
2012/11/28 14:30:31
Done.
| |
75 // partitioned by common AudioParameters. | |
76 AudioConvertersMap converters_; | |
77 // AudioConverter that takes all the audio converters and mixes them into one | |
Alpha Left Google
2012/11/28 01:04:47
nit: empty line before comments.
justinlin
2012/11/28 14:30:31
Done.
| |
78 // final audio stream. | |
79 AudioConverter mixer_; | |
80 // Maps attached output streams to their parameters. We need this later to | |
Alpha Left Google
2012/11/28 01:04:47
nit: empty line before comments.
justinlin
2012/11/28 14:30:31
Done.
| |
81 // remove the virtual output stream from the right AudioConverter. | |
82 OutputStreamParams output_params_; | |
83 int num_attached_outputs_streams_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(VirtualAudioInputStream); | |
86 }; | |
87 | |
88 } // namespace media | |
89 | |
90 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | |
OLD | NEW |