diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 23:43:57 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 23:43:57 +0000 |
commit | 38244d9bed99ff00c33235a27b80b28368c21cf3 (patch) | |
tree | b68e34ac9121cf548f384391fd8a303d5f2819fb /content/renderer/pepper/pepper_platform_audio_input_impl.h | |
parent | 72bbaccaa082a3ad6fff9bbc1cf70d01dabd79e8 (diff) | |
download | chromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.zip chromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.tar.gz chromium_src-38244d9bed99ff00c33235a27b80b28368c21cf3.tar.bz2 |
PepperPlatformAudioInputImpl: support audio input device selection.
BUG=None
TEST=ppapi/examples/audio_input
Review URL: http://codereview.chromium.org/9705056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/pepper/pepper_platform_audio_input_impl.h')
-rw-r--r-- | content/renderer/pepper/pepper_platform_audio_input_impl.h | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.h b/content/renderer/pepper/pepper_platform_audio_input_impl.h index f9f08f1..15681bb 100644 --- a/content/renderer/pepper/pepper_platform_audio_input_impl.h +++ b/content/renderer/pepper/pepper_platform_audio_input_impl.h @@ -5,14 +5,26 @@ #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ +#include <string> + #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "content/renderer/media/audio_input_message_filter.h" +#include "media/audio/audio_parameters.h" #include "webkit/plugins/ppapi/plugin_delegate.h" class AudioParameters; - +class PepperPluginDelegateImpl; + +// PepperPlatformAudioInputImpl is operated on two threads: the main thread (the +// thread on which objects are created) and the I/O thread. All public methods, +// except the destructor, must be called on the main thread. The notifications +// to the users of this class (via the PlatformAudioInputClient interface) are +// also sent on the main thread. Internally, this class sends audio input IPC +// messages and receives AudioInputMessageFilter::Delegate notifications on the +// I/O thread. class PepperPlatformAudioInputImpl : public webkit::ppapi::PluginDelegate::PlatformAudioInput, public AudioInputMessageFilter::Delegate, @@ -23,25 +35,29 @@ class PepperPlatformAudioInputImpl // Factory function, returns NULL on failure. StreamCreated() will be called // when the stream is created. static PepperPlatformAudioInputImpl* Create( + const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, + const std::string& device_id, int sample_rate, int frames_per_buffer, - webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); + webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); // PlatformAudioInput implementation (called on main thread). - virtual bool StartCapture() OVERRIDE; - virtual bool StopCapture() OVERRIDE; + virtual void StartCapture() OVERRIDE; + virtual void StopCapture() OVERRIDE; virtual void ShutDown() OVERRIDE; private: PepperPlatformAudioInputImpl(); bool Initialize( + const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, + const std::string& device_id, int sample_rate, int frames_per_buffer, - webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); + webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); // I/O thread backends to above functions. - void InitializeOnIOThread(const AudioParameters& params); + void InitializeOnIOThread(int session_id); void StartCaptureOnIOThread(); void StopCaptureOnIOThread(); void ShutDownOnIOThread(); @@ -54,9 +70,15 @@ class PepperPlatformAudioInputImpl virtual void OnStateChanged(AudioStreamState state) OVERRIDE; virtual void OnDeviceReady(const std::string&) OVERRIDE; + void OnDeviceOpened(int request_id, + bool succeeded, + const std::string& label); + void CloseDevice(); + void NotifyStreamCreationFailed(); + // The client to notify when the stream is created. THIS MUST ONLY BE // ACCESSED ON THE MAIN THREAD. - webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client_; + webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE // I/O thread except to send messages and get the message loop. @@ -68,6 +90,20 @@ class PepperPlatformAudioInputImpl base::MessageLoopProxy* main_message_loop_proxy_; + // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. + base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; + + // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON + // THE MAIN THREAD. + std::string label_; + + // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON + // THE I/O THREAD. + bool shutdown_called_; + + // Initialized on the main thread and accessed on the I/O thread afterwards. + AudioParameters params_; + DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); }; |