| Index: content/renderer/pepper/pepper_platform_audio_input_impl.h
|
| diff --git a/content/renderer/pepper/pepper_platform_audio_input_impl.h b/content/renderer/pepper/pepper_platform_audio_input_impl.h
|
| index f9f08f17f56e5e6f941e1f42c869bbd44a1b3f04..15681bba5ba8e44d6afbc5314ab66791078860c0 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);
|
| };
|
|
|
|
|