Allow overlapping sync and async startup requests
[chromium-blink-merge.git] / media / base / audio_capturer_source.h
blobb584f8a48db490ac1a1fcf2e6af67b0257ab4ab1
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.
5 #ifndef MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_
6 #define MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_
8 #include <string>
9 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "media/audio/audio_parameters.h"
13 #include "media/base/audio_bus.h"
14 #include "media/base/media_export.h"
16 namespace media {
18 // AudioCapturerSource is an interface representing the source for
19 // captured audio. An implementation will periodically call Capture() on a
20 // callback object.
21 class AudioCapturerSource
22 : public base::RefCountedThreadSafe<media::AudioCapturerSource> {
23 public:
24 class CaptureCallback {
25 public:
26 // Callback to deliver the captured data from the OS.
27 virtual void Capture(AudioBus* audio_source,
28 int audio_delay_milliseconds,
29 double volume,
30 bool key_pressed) = 0;
32 // Signals an error has occurred.
33 virtual void OnCaptureError() = 0;
35 protected:
36 virtual ~CaptureCallback() {}
39 // Sets information about the audio stream format and the device
40 // to be used. It must be called before any of the other methods.
41 // The |session_id| is used by the browser to identify which input device to
42 // be used. For clients who do not care about device permission and device
43 // selection, pass |session_id| using
44 // AudioInputDeviceManager::kFakeOpenSessionId.
45 virtual void Initialize(const AudioParameters& params,
46 CaptureCallback* callback,
47 int session_id) = 0;
49 // Starts the audio recording.
50 virtual void Start() = 0;
52 // Stops the audio recording. This API is synchronous, and no more data
53 // callback will be passed to the client after it is being called.
54 virtual void Stop() = 0;
56 // Sets the capture volume, with range [0.0, 1.0] inclusive.
57 virtual void SetVolume(double volume) = 0;
59 // Enables or disables the WebRtc AGC control.
60 virtual void SetAutomaticGainControl(bool enable) = 0;
62 protected:
63 friend class base::RefCountedThreadSafe<AudioCapturerSource>;
64 virtual ~AudioCapturerSource() {}
67 } // namespace media
69 #endif // MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_