Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: media/audio/virtual_audio_input_stream.h

Issue 11298006: Browser-wide audio mirroring for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adress comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/memory/scoped_ptr.h"
13 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_manager_base.h"
15 #include "media/audio/audio_parameters.h"
16 #include "media/base/audio_converter.h"
17
18 namespace media {
19
20 class LoopbackAudioConverter;
21 class VirtualAudioOutputStream;
22
23 // Virtual audio input stream which is used for audio mirroring through the
24 // TabCaptureApi. This audio stream uses virtual audio output streams as input
25 // and will mix them together to render audio. It will continuously render
26 // audio until the audio mirroring session is ended.
27 class MEDIA_EXPORT VirtualAudioInputStream
28 : public AudioInputStream {
29 public:
30 static VirtualAudioInputStream* MakeStream(AudioManagerBase* manager,
31 const AudioParameters& params);
32
33 // AudioInputStream:
34 virtual bool Open() OVERRIDE;
35 virtual void Start(AudioInputCallback* callback) OVERRIDE;
36 virtual void Stop() OVERRIDE;
37 virtual void Close() OVERRIDE;
38 virtual double GetMaxVolume() OVERRIDE;
39 virtual void SetVolume(double volume) OVERRIDE;
40 virtual double GetVolume() OVERRIDE;
41 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
42 virtual bool GetAutomaticGainControl() OVERRIDE;
43
44 // Attaches a virtual audio output stream to be used as input.
45 void AddOutputStream(
46 VirtualAudioOutputStream* stream, const AudioParameters& params);
47 // Detaches a virtual audio output stream that went away (i.e. video closed).
48 void RemoveOutputStream(VirtualAudioOutputStream* stream);
49
50 private:
51 typedef std::map<AudioParameters, LoopbackAudioConverter*> AudioConvertersMap;
52 typedef std::map<AudioOutputStream*, AudioParameters> OutputStreamParams;
53
54 void DoCallback();
55
56 VirtualAudioInputStream(AudioManagerBase* manager,
57 const AudioParameters& params);
58
59 virtual ~VirtualAudioInputStream();
60
61 AudioManagerBase* audio_manager_;
62 AudioInputCallback* callback_;
63 const float callback_delay_;
64 scoped_array<uint8> buffer_;
65 AudioParameters params_;
66 scoped_ptr<AudioBus> audio_bus_;
67 base::CancelableClosure on_more_data_cb_;
68 // AudioConverters associated with the attached virtual audio output streams,
69 // partitioned by common AudioParameters.
70 AudioConvertersMap converters_;
71 // AudioConverter that takes all the audio converters and mixes them into one
72 // final audio stream.
73 AudioConverter mixer_;
74 // Maps attached output streams to their parameters. We need this later to
75 // remove the virtual output stream from the right AudioConverter.
76 OutputStreamParams output_params_;
77
78 DISALLOW_COPY_AND_ASSIGN(VirtualAudioInputStream);
79 };
80
81 } // namespace media
82
83 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698