Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1776)

Unified Diff: content/renderer/pepper/pepper_platform_audio_input_impl.h

Issue 9705056: PepperPlatformAudioInputImpl: support audio input device selection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 4df6eb9c4718dccba2f4999873ca01103f81c9d7..38318e6b49da4e26385f294f7429b99de228d8c5 100644
--- a/content/renderer/pepper/pepper_platform_audio_input_impl.h
+++ b/content/renderer/pepper/pepper_platform_audio_input_impl.h
@@ -5,12 +5,17 @@
#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 PepperPluginDelegateImpl;
viettrungluu 2012/03/16 22:29:09 Alphabetical order?
yzshen1 2012/03/17 09:32:56 I thought 'class' should be prior to 'struct'. On
viettrungluu 2012/03/17 23:52:22 Most places I've seen alphabetize based on the nam
yzshen1 2012/03/19 21:47:54 Done.
struct AudioParameters;
class PepperPlatformAudioInputImpl
@@ -23,9 +28,11 @@ 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,
uint32_t sample_rate,
uint32_t sample_count,
- webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client);
+ webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client);
// PlatformAudioInput implementation (called on main thread).
virtual bool StartCapture() OVERRIDE;
@@ -36,12 +43,14 @@ class PepperPlatformAudioInputImpl
PepperPlatformAudioInputImpl();
bool Initialize(
+ const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate,
+ const std::string& device_id,
uint32_t sample_rate,
uint32_t sample_count,
- 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 +63,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 +83,20 @@ class PepperPlatformAudioInputImpl
base::MessageLoopProxy* main_message_loop_proxy_;
+ // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD.
viettrungluu 2012/03/16 22:29:09 Is the thread usage of this class documented somew
yzshen1 2012/03/19 21:47:54 Done. I added a threading comment for this class a
viettrungluu 2012/03/20 18:20:02 Sounds fine, now that you've clarified the thread
+ base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_;
+
+ // The label of the opened device. THIS MUST ONLY BE ACCESSED ON THE MAIN
viettrungluu 2012/03/16 22:29:09 What exactly is a "label"? (The human-readable nam
yzshen1 2012/03/19 21:47:54 This is a unique ID generated by the media code to
+ // 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);
};

Powered by Google App Engine
This is Rietveld 408576698