summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_input_device.h
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 18:11:43 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 18:11:43 +0000
commit4bc6545870f3d086c9a9aadd1dd6310a01b5ebe5 (patch)
tree2fd31bc4a457ae3f4df3c50548f17bf14a709656 /media/audio/audio_input_device.h
parent021b42b445d17573b4c53522f553e3558add3797 (diff)
downloadchromium_src-4bc6545870f3d086c9a9aadd1dd6310a01b5ebe5.zip
chromium_src-4bc6545870f3d086c9a9aadd1dd6310a01b5ebe5.tar.gz
chromium_src-4bc6545870f3d086c9a9aadd1dd6310a01b5ebe5.tar.bz2
Break down the webrtc code and AudioInputDevice into a WebRtcAudioCapturer.
This capturer contains a source (AudioInputDevice) and a sink (WebRtcAudioDeviceImpl) by default. What it does is to get data from AudioInputDevice via CaptureCallback::Capture() callback, and forward the data to WebRtcAudioDeviceImpl. The source can be over written by API: SetCapturerSource(media::AudioCapturerSource* source) This capture currently only support one sink (WebRtcAudioDeviceImpl), but this can be extended to multiple sinks for the future. Design doc: https://docs.google.com/a/google.com/document/d/1FmiXtk1pxFlAw_CWwbfG-EQ4Syi4vpnZm6GWMyJ1UfU/edit TBR=tommi@chromium.org BUG=157306 TEST=manual test Review URL: https://codereview.chromium.org/11366244 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_input_device.h')
-rw-r--r--media/audio/audio_input_device.h66
1 files changed, 13 insertions, 53 deletions
diff --git a/media/audio/audio_input_device.h b/media/audio/audio_input_device.h
index ddb2535..edefdf1 100644
--- a/media/audio/audio_input_device.h
+++ b/media/audio/audio_input_device.h
@@ -72,6 +72,7 @@
#include "media/audio/audio_input_ipc.h"
#include "media/audio/audio_parameters.h"
#include "media/audio/scoped_loop_observer.h"
+#include "media/base/audio_capturer_source.h"
#include "media/base/media_export.h"
namespace media {
@@ -82,63 +83,22 @@ namespace media {
// OnCaptureStopped etc.) and ensure that we can deliver these notifications
// to any clients using this class.
class MEDIA_EXPORT AudioInputDevice
- : NON_EXPORTED_BASE(public AudioInputIPCDelegate),
- NON_EXPORTED_BASE(public ScopedLoopObserver),
- public base::RefCountedThreadSafe<AudioInputDevice> {
+ : NON_EXPORTED_BASE(public AudioCapturerSource),
+ NON_EXPORTED_BASE(public AudioInputIPCDelegate),
+ NON_EXPORTED_BASE(public ScopedLoopObserver) {
public:
- class MEDIA_EXPORT CaptureCallback {
- public:
- virtual void Capture(AudioBus* audio_bus,
- int audio_delay_milliseconds,
- double volume) = 0;
- virtual void OnCaptureError() = 0;
- protected:
- virtual ~CaptureCallback();
- };
-
- class MEDIA_EXPORT CaptureEventHandler {
- public:
- // Notification to the client that the device with the specific |device_id|
- // has been started.
- // This callback is triggered as a result of StartDevice().
- virtual void OnDeviceStarted(const std::string& device_id) = 0;
-
- // Notification to the client that the device has been stopped.
- virtual void OnDeviceStopped() = 0;
-
- protected:
- virtual ~CaptureEventHandler();
- };
-
AudioInputDevice(AudioInputIPC* ipc,
const scoped_refptr<base::MessageLoopProxy>& io_loop);
- // Initializes the AudioInputDevice. This method must be called before
- // any other methods can be used.
- void Initialize(const AudioParameters& params,
- CaptureCallback* callback,
- CaptureEventHandler* event_handler);
-
- // Specify the |session_id| to query which device to use.
- // Start() will use the second sequence if this method is called before.
- void SetDevice(int session_id);
-
- // Starts audio capturing.
- // TODO(henrika): add support for notification when recording has started.
- void Start();
-
- // Stops audio capturing.
- // TODO(henrika): add support for notification when recording has stopped.
- void Stop();
-
- // Sets the capture volume scaling, with range [0.0, 1.0] inclusive.
- // Returns |true| on success.
- void SetVolume(double volume);
-
- // Sets the Automatic Gain Control state to on or off.
- // This method must be called before Start(). It will not have any effect
- // if it is called while capturing has already started.
- void SetAutomaticGainControl(bool enabled);
+ // AudioCapturerSource implementation.
+ virtual void Initialize(const AudioParameters& params,
+ CaptureCallback* callback,
+ CaptureEventHandler* event_handler) OVERRIDE;
+ virtual void Start() OVERRIDE;
+ virtual void Stop() OVERRIDE;
+ virtual void SetVolume(double volume) OVERRIDE;
+ virtual void SetDevice(int session_id) OVERRIDE;
+ virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
protected:
// Methods called on IO thread ----------------------------------------------