summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 14:37:00 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 14:37:00 +0000
commit2cfa9100b8ced3a2c03d45f999e2256a70d551ec (patch)
treef207cef9e5ea1e1ed58180d2e07607f4882e7793 /media
parent2d82a47ded8003b9868e8f4f5b615c753ed9ee52 (diff)
downloadchromium_src-2cfa9100b8ced3a2c03d45f999e2256a70d551ec.zip
chromium_src-2cfa9100b8ced3a2c03d45f999e2256a70d551ec.tar.gz
chromium_src-2cfa9100b8ced3a2c03d45f999e2256a70d551ec.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 BUG=157306 TEST=manual test Review URL: https://codereview.chromium.org/11231003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/audio_input_device.cc3
-rw-r--r--media/audio/audio_input_device.h66
-rw-r--r--media/base/audio_capturer_source.h81
-rw-r--r--media/media.gyp2
4 files changed, 96 insertions, 56 deletions
diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc
index e457787..a60d60d 100644
--- a/media/audio/audio_input_device.cc
+++ b/media/audio/audio_input_device.cc
@@ -13,9 +13,6 @@
namespace media {
-AudioInputDevice::CaptureCallback::~CaptureCallback() {}
-AudioInputDevice::CaptureEventHandler::~CaptureEventHandler() {}
-
// Takes care of invoking the capture callback on the audio thread.
// An instance of this class is created for each capture stream in
// OnLowLatencyCreated().
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 ----------------------------------------------
diff --git a/media/base/audio_capturer_source.h b/media/base/audio_capturer_source.h
new file mode 100644
index 0000000..7611025
--- /dev/null
+++ b/media/base/audio_capturer_source.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_
+#define MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_
+
+#include <vector>
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "media/audio/audio_parameters.h"
+#include "media/base/audio_bus.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+// AudioCapturerSource is an interface representing the source for
+// captured audio. An implementation will periodically call Capture() on a
+// callback object.
+class AudioCapturerSource
+ : public base::RefCountedThreadSafe<media::AudioCapturerSource> {
+ public:
+ class CaptureCallback {
+ public:
+ // Callback to deliver the captured data from the OS.
+ virtual void Capture(AudioBus* audio_source,
+ int audio_delay_milliseconds,
+ double volume) = 0;
+
+ // Signals an error has occurred.
+ virtual void OnCaptureError() = 0;
+
+ protected:
+ virtual ~CaptureCallback() {}
+ };
+
+ class CaptureEventHandler {
+ public:
+ // Notification to the client that the device with the specific |device_id|
+ // has been started.
+ 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() {}
+ };
+
+ // Sets information about the audio stream format and the device
+ // to be used. It must be called before any of the other methods.
+ // TODO(xians): Add |device_id| to this Initialize() function.
+ virtual void Initialize(const AudioParameters& params,
+ CaptureCallback* callback,
+ CaptureEventHandler* event_handler) = 0;
+
+ // Starts the audio recording.
+ virtual void Start() = 0;
+
+ // Stops the audio recording. This API is synchronous, and no more data
+ // callback will be passed to the client after it is being called.
+ virtual void Stop() = 0;
+
+ // Sets the capture volume, with range [0.0, 1.0] inclusive.
+ virtual void SetVolume(double volume) = 0;
+
+ // Specifies the |session_id| to query which device to use.
+ // TODO(xians): Change the interface to SetDevice(const std::string&).
+ virtual void SetDevice(int session_id) = 0;
+
+ // Enables or disables the WebRtc AGC control.
+ virtual void SetAutomaticGainControl(bool enable) = 0;
+
+ protected:
+ friend class base::RefCountedThreadSafe<AudioCapturerSource>;
+ virtual ~AudioCapturerSource() {}
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_AUDIO_CAPTURER_SOURCE_H_
diff --git a/media/media.gyp b/media/media.gyp
index 9fb5f37..b0c2bdf 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -158,6 +158,7 @@
'base/android/cookie_getter.h',
'base/android/media_player_bridge_manager.cc',
'base/android/media_player_bridge_manager.h',
+ 'base/audio_capturer_source.h',
'base/audio_decoder.cc',
'base/audio_decoder.h',
'base/audio_decoder_config.cc',
@@ -168,6 +169,7 @@
'base/audio_pull_fifo.h',
'base/audio_renderer.cc',
'base/audio_renderer.h',
+ 'base/audio_renderer_sink.h',
'base/audio_renderer_mixer.cc',
'base/audio_renderer_mixer.h',
'base/audio_renderer_mixer_input.cc',