summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-17 23:49:56 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-17 23:49:56 +0000
commit7aac3055e4809d516b05ddb9dd063346c2f94514 (patch)
tree17062b983be0063e60d63709065797f9aa61cc57 /webkit/plugins/ppapi
parent81c5deaba63aaddb9fcac95b4c1364f19edd6270 (diff)
downloadchromium_src-7aac3055e4809d516b05ddb9dd063346c2f94514.zip
chromium_src-7aac3055e4809d516b05ddb9dd063346c2f94514.tar.gz
chromium_src-7aac3055e4809d516b05ddb9dd063346c2f94514.tar.bz2
Revert 110587 - Microphone support for Pepper Flash.
[Committing for pbrophy@adobe.com. Original review: http://codereview.chromium.org/8138008/ .] This change supports audio capture from the microphone and supplies the data through a Pepper interface. Its enumeration is limited to the default audio device that uses mono 44.1kHz. TBR=tony@chromium.org Review URL: http://codereview.chromium.org/8574029 TBR=viettrungluu@chromium.org Review URL: http://codereview.chromium.org/8569003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/audio_helper.cc95
-rw-r--r--webkit/plugins/ppapi/audio_helper.h67
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc9
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h6
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h50
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc70
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.h25
-rw-r--r--webkit/plugins/ppapi/ppb_audio_input_impl.cc160
-rw-r--r--webkit/plugins/ppapi/ppb_audio_input_impl.h83
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc15
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h8
12 files changed, 95 insertions, 497 deletions
diff --git a/webkit/plugins/ppapi/audio_helper.cc b/webkit/plugins/ppapi/audio_helper.cc
deleted file mode 100644
index a077e5b..0000000
--- a/webkit/plugins/ppapi/audio_helper.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "ppapi/c/pp_completion_callback.h"
-#include "webkit/plugins/ppapi/audio_helper.h"
-#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/resource_helper.h"
-
-namespace webkit {
-namespace ppapi {
-
-// AudioHelper -----------------------------------------------------------------
-
-AudioHelper::AudioHelper()
- : create_callback_pending_(false),
- shared_memory_size_for_create_callback_(0) {
- create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
-}
-
-AudioHelper::~AudioHelper() {
- // If the completion callback hasn't fired yet, do so here
- // with an error condition.
- if (create_callback_pending_) {
- PP_RunCompletionCallback(&create_callback_, PP_ERROR_ABORTED);
- create_callback_pending_ = false;
- }
-}
-
-int32_t AudioHelper::GetSyncSocketImpl(int* sync_socket) {
- if (socket_for_create_callback_.get()) {
-#if defined(OS_POSIX)
- *sync_socket = socket_for_create_callback_->handle();
-#elif defined(OS_WIN)
- *sync_socket = reinterpret_cast<int>(socket_for_create_callback_->handle());
-#else
- #error "Platform not supported."
-#endif
- return PP_OK;
- }
- return PP_ERROR_FAILED;
-}
-
-int32_t AudioHelper::GetSharedMemoryImpl(int* shm_handle, uint32_t* shm_size) {
- if (shared_memory_for_create_callback_.get()) {
-#if defined(OS_POSIX)
- *shm_handle = shared_memory_for_create_callback_->handle().fd;
-#elif defined(OS_WIN)
- *shm_handle = reinterpret_cast<int>(
- shared_memory_for_create_callback_->handle());
-#else
- #error "Platform not supported."
-#endif
- *shm_size = shared_memory_size_for_create_callback_;
- return PP_OK;
- }
- return PP_ERROR_FAILED;
-}
-
-void AudioHelper::StreamCreated(
- base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size,
- base::SyncSocket::Handle socket_handle) {
- if (create_callback_pending_) {
- // Trusted side of proxy can specify a callback to recieve handles. In
- // this case we don't need to map any data or start the thread since it
- // will be handled by the proxy.
- shared_memory_for_create_callback_.reset(
- new base::SharedMemory(shared_memory_handle, false));
- shared_memory_size_for_create_callback_ = shared_memory_size;
- socket_for_create_callback_.reset(new base::SyncSocket(socket_handle));
-
- PP_RunCompletionCallback(&create_callback_, 0);
- create_callback_pending_ = false;
-
- // It might be nice to close the handles here to free up some system
- // resources, but we can't since there's a race condition. The handles must
- // be valid until they're sent over IPC, which is done from the I/O thread
- // which will often get done after this code executes. We could do
- // something more elaborate like an ACK from the plugin or post a task to
- // the I/O thread and back, but this extra complexity doesn't seem worth it
- // just to clean up these handles faster.
- } else {
- OnSetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
- }
-}
-
-void AudioHelper::SetCallbackInfo(bool create_callback_pending,
- PP_CompletionCallback create_callback) {
- create_callback_pending_ = create_callback_pending;
- create_callback_ = create_callback;
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/audio_helper.h b/webkit/plugins/ppapi/audio_helper.h
deleted file mode 100644
index 5d5df54..0000000
--- a/webkit/plugins/ppapi/audio_helper.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_AUDIO_HELPER_H_
-#define WEBKIT_PLUGINS_PPAPI_AUDIO_HELPER_H_
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/shared_memory.h"
-#include "base/sync_socket.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/scoped_pp_resource.h"
-#include "webkit/plugins/ppapi/plugin_delegate.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-
-namespace webkit {
-namespace ppapi {
-
-class AudioHelper : public PluginDelegate::PlatformAudioCommonClient {
- public:
- AudioHelper();
- virtual ~AudioHelper();
-
- // |PluginDelegate::PlatformAudioCommonClient| implementation.
- virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size_,
- base::SyncSocket::Handle socket) OVERRIDE;
-
- void SetCallbackInfo(bool create_callback_pending,
- PP_CompletionCallback create_callback);
-
- protected:
- // TODO(viettrungluu): This is all very poorly thought out. Refactor.
-
- // To be called by implementations of |PPB_Audio_API|/|PPB_AudioInput_API|.
- int32_t GetSyncSocketImpl(int* sync_socket);
- int32_t GetSharedMemoryImpl(int* shm_handle, uint32_t* shm_size);
-
- // To be implemented by subclasses to call their |SetStreamInfo()|.
- virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size,
- base::SyncSocket::Handle socket_handle) = 0;
-
- private:
- // Is a create callback pending to fire?
- bool create_callback_pending_;
-
- // Trusted callback invoked from StreamCreated.
- PP_CompletionCallback create_callback_;
-
- // When a create callback is being issued, these will save the info for
- // querying from the callback. The proxy uses this to get the handles to the
- // other process instead of mapping them in the renderer. These will be
- // invalid all other times.
- scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_;
- size_t shared_memory_size_for_create_callback_;
- scoped_ptr<base::SyncSocket> socket_for_create_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(AudioHelper);
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_AUDIO_HELPER_H_
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 80594fc..4a914bd 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -71,14 +71,7 @@ MockPluginDelegate::CreateVideoCapture(
MockPluginDelegate::PlatformAudio* MockPluginDelegate::CreateAudio(
uint32_t sample_rate,
uint32_t sample_count,
- PlatformAudioCommonClient* client) {
- return NULL;
-}
-
-MockPluginDelegate::PlatformAudioInput* MockPluginDelegate::CreateAudioInput(
- uint32_t sample_rate,
- uint32_t sample_count,
- PlatformAudioCommonClient* client) {
+ PlatformAudio::Client* client) {
return NULL;
}
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index 3670792..0988ebe 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -34,11 +34,7 @@ class MockPluginDelegate : public PluginDelegate {
media::VideoCapture::EventHandler* handler);
virtual PlatformAudio* CreateAudio(uint32_t sample_rate,
uint32_t sample_count,
- PlatformAudioCommonClient* client);
- virtual PlatformAudioInput* CreateAudioInput(
- uint32_t sample_rate,
- uint32_t sample_count,
- PlatformAudioCommonClient* client);
+ PlatformAudio::Client* client);
virtual PpapiBroker* ConnectToPpapiBroker(PPB_Broker_Impl* client);
virtual void NumberOfFindResultsChanged(int identifier,
int total,
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 65506e7..6f76384 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -180,21 +180,19 @@ class PluginDelegate {
virtual bool Echo(const base::Callback<void()>& callback) = 0;
};
- // The (interface for the) client used by |PlatformAudio| and
- // |PlatformAudioInput|.
- class PlatformAudioCommonClient {
- protected:
- virtual ~PlatformAudioCommonClient() {}
-
- public:
- // Called when the stream is created.
- virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size,
- base::SyncSocket::Handle socket) = 0;
- };
-
class PlatformAudio {
public:
+ class Client {
+ protected:
+ virtual ~Client() {}
+
+ public:
+ // Called when the stream is created.
+ virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
+ size_t shared_memory_size,
+ base::SyncSocket::Handle socket) = 0;
+ };
+
// Starts the playback. Returns false on error or if called before the
// stream is created or after the stream is closed.
virtual bool StartPlayback() = 0;
@@ -211,24 +209,6 @@ class PluginDelegate {
virtual ~PlatformAudio() {}
};
- class PlatformAudioInput {
- public:
- // Starts the playback. Returns false on error or if called before the
- // stream is created or after the stream is closed.
- virtual bool StartCapture() = 0;
-
- // Stops the capture. Returns false on error or if called before the stream
- // is created or after the stream is closed.
- virtual bool StopCapture() = 0;
-
- // Closes the stream. Make sure to call this before the object is
- // destructed.
- virtual void ShutDown() = 0;
-
- protected:
- virtual ~PlatformAudioInput() {}
- };
-
// Interface for PlatformVideoDecoder is directly inherited from general media
// VideoDecodeAccelerator interface.
class PlatformVideoDecoder : public media::VideoDecodeAccelerator {
@@ -305,13 +285,7 @@ class PluginDelegate {
// to clean up the corresponding resources allocated during this call.
virtual PlatformAudio* CreateAudio(uint32_t sample_rate,
uint32_t sample_count,
- PlatformAudioCommonClient* client) = 0;
-
- // The caller is responsible for calling Shutdown() on the returned pointer
- // to clean up the corresponding resources allocated during this call.
- virtual PlatformAudioInput* CreateAudioInput(uint32_t sample_rate,
- uint32_t sample_count,
- PlatformAudioCommonClient* client) = 0;
+ PlatformAudio::Client* client) = 0;
// A pointer is returned immediately, but it is not ready to be used until
// BrokerConnected has been called.
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 01cbee3..2fedc53 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -13,7 +13,6 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/time.h"
-#include "ppapi/c/dev/ppb_audio_input_dev.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/dev/ppb_char_set_dev.h"
#include "ppapi/c/dev/ppb_console_dev.h"
@@ -76,7 +75,6 @@
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
-#include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/trusted/ppb_buffer_trusted.h"
@@ -261,8 +259,6 @@ const void* GetInterface(const char* name) {
// Please keep alphabetized by interface macro name with "special" stuff at
// the bottom.
- if (strcmp(name, PPB_AUDIO_INPUT_TRUSTED_DEV_INTERFACE) == 0)
- return ::ppapi::thunk::GetPPB_AudioInputTrusted_Thunk();
if (strcmp(name, PPB_AUDIO_TRUSTED_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_AudioTrusted_Thunk();
if (strcmp(name, PPB_BUFFER_TRUSTED_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index c92c9b1..6cc1cd0 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -28,7 +28,10 @@ namespace ppapi {
PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance)
: Resource(instance),
- audio_(NULL) {
+ audio_(NULL),
+ create_callback_pending_(false),
+ shared_memory_size_for_create_callback_(0) {
+ create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
}
PPB_Audio_Impl::~PPB_Audio_Impl() {
@@ -41,6 +44,13 @@ PPB_Audio_Impl::~PPB_Audio_Impl() {
audio_->ShutDown();
audio_ = NULL;
}
+
+ // If the completion callback hasn't fired yet, do so here
+ // with an error condition.
+ if (create_callback_pending_) {
+ PP_RunCompletionCallback(&create_callback_, PP_ERROR_ABORTED);
+ create_callback_pending_ = false;
+ }
}
// static
@@ -131,25 +141,67 @@ int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config,
// At this point, we are guaranteeing ownership of the completion
// callback. Audio promises to fire the completion callback
// once and only once.
- SetCallbackInfo(true, create_callback);
-
+ create_callback_ = create_callback;
+ create_callback_pending_ = true;
return PP_OK_COMPLETIONPENDING;
}
int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) {
- return GetSyncSocketImpl(sync_socket);
+ if (socket_for_create_callback_.get()) {
+#if defined(OS_POSIX)
+ *sync_socket = socket_for_create_callback_->handle();
+#elif defined(OS_WIN)
+ *sync_socket = reinterpret_cast<int>(socket_for_create_callback_->handle());
+#else
+ #error "Platform not supported."
+#endif
+ return PP_OK;
+ }
+ return PP_ERROR_FAILED;
}
-int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle,
- uint32_t* shm_size) {
- return GetSharedMemoryImpl(shm_handle, shm_size);
+int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
+ if (shared_memory_for_create_callback_.get()) {
+#if defined(OS_POSIX)
+ *shm_handle = shared_memory_for_create_callback_->handle().fd;
+#elif defined(OS_WIN)
+ *shm_handle = reinterpret_cast<int>(
+ shared_memory_for_create_callback_->handle());
+#else
+ #error "Platform not supported."
+#endif
+ *shm_size = shared_memory_size_for_create_callback_;
+ return PP_OK;
+ }
+ return PP_ERROR_FAILED;
}
-void PPB_Audio_Impl::OnSetStreamInfo(
+void PPB_Audio_Impl::StreamCreated(
base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket_handle) {
- SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
+ if (create_callback_pending_) {
+ // Trusted side of proxy can specify a callback to recieve handles. In
+ // this case we don't need to map any data or start the thread since it
+ // will be handled by the proxy.
+ shared_memory_for_create_callback_.reset(
+ new base::SharedMemory(shared_memory_handle, false));
+ shared_memory_size_for_create_callback_ = shared_memory_size;
+ socket_for_create_callback_.reset(new base::SyncSocket(socket_handle));
+
+ PP_RunCompletionCallback(&create_callback_, 0);
+ create_callback_pending_ = false;
+
+ // It might be nice to close the handles here to free up some system
+ // resources, but we can't since there's a race condition. The handles must
+ // be valid until they're sent over IPC, which is done from the I/O thread
+ // which will often get done after this code executes. We could do
+ // something more elaborate like an ACK from the plugin or post a task to
+ // the I/O thread and back, but this extra complexity doesn't seem worth it
+ // just to clean up these handles faster.
+ } else {
+ SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
+ }
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h
index aa8e7f7..3be3f8a 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.h
+++ b/webkit/plugins/ppapi/ppb_audio_impl.h
@@ -17,7 +17,6 @@
#include "ppapi/shared_impl/audio_impl.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/shared_impl/resource.h"
-#include "webkit/plugins/ppapi/audio_helper.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -28,7 +27,7 @@ namespace ppapi {
// AudioImpl so it can be shared with the proxy.
class PPB_Audio_Impl : public ::ppapi::Resource,
public ::ppapi::AudioImpl,
- public AudioHelper {
+ public PluginDelegate::PlatformAudio::Client {
public:
// Trusted initialization. You must call Init after this.
//
@@ -62,10 +61,10 @@ class PPB_Audio_Impl : public ::ppapi::Resource,
virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
private:
- // AudioHelper implementation.
- virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size_,
- base::SyncSocket::Handle socket);
+ // PluginDelegate::PlatformAudio::Client implementation.
+ virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
+ size_t shared_memory_size_,
+ base::SyncSocket::Handle socket);
// AudioConfig used for creating this Audio object. We own a ref.
::ppapi::ScopedPPResource config_;
@@ -74,6 +73,20 @@ class PPB_Audio_Impl : public ::ppapi::Resource,
// own this pointer but are responsible for calling Shutdown on it.
PluginDelegate::PlatformAudio* audio_;
+ // Is a create callback pending to fire?
+ bool create_callback_pending_;
+
+ // Trusted callback invoked from StreamCreated.
+ PP_CompletionCallback create_callback_;
+
+ // When a create callback is being issued, these will save the info for
+ // querying from the callback. The proxy uses this to get the handles to the
+ // other process instead of mapping them in the renderer. These will be
+ // invalid all other times.
+ scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_;
+ size_t shared_memory_size_for_create_callback_;
+ scoped_ptr<base::SyncSocket> socket_for_create_callback_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_audio_input_impl.cc b/webkit/plugins/ppapi/ppb_audio_input_impl.cc
deleted file mode 100644
index 590dd81..0000000
--- a/webkit/plugins/ppapi/ppb_audio_input_impl.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "webkit/plugins/ppapi/ppb_audio_input_impl.h"
-
-#include "base/logging.h"
-#include "ppapi/c/dev/ppb_audio_input_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/ppb_audio_config.h"
-#include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h"
-#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_audio_config_api.h"
-#include "ppapi/thunk/thunk.h"
-#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/resource_helper.h"
-
-using ppapi::PpapiGlobals;
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_AudioInput_API;
-using ppapi::thunk::PPB_AudioConfig_API;
-
-namespace webkit {
-namespace ppapi {
-
-// PPB_AudioInput_Impl ---------------------------------------------------------
-
-PPB_AudioInput_Impl::PPB_AudioInput_Impl(PP_Instance instance)
- : Resource(instance),
- audio_input_(NULL) {
-}
-
-PPB_AudioInput_Impl::~PPB_AudioInput_Impl() {
- // Calling ShutDown() makes sure StreamCreated cannot be called anymore and
- // releases the audio data associated with the pointer. Note however, that
- // until ShutDown returns, StreamCreated may still be called. This will be
- // OK since we'll just immediately clean up the data it stored later in this
- // destructor.
- if (audio_input_) {
- audio_input_->ShutDown();
- audio_input_ = NULL;
- }
-}
-
-// static
-PP_Resource PPB_AudioInput_Impl::Create(PP_Instance instance,
- PP_Resource config,
- PPB_AudioInput_Callback audio_input_callback,
- void* user_data) {
- scoped_refptr<PPB_AudioInput_Impl>
- audio_input(new PPB_AudioInput_Impl(instance));
- if (!audio_input->Init(config, audio_input_callback, user_data))
- return 0;
- return audio_input->GetReference();
-}
-
-PPB_AudioInput_API* PPB_AudioInput_Impl::AsPPB_AudioInput_API() {
- return this;
-}
-
-bool PPB_AudioInput_Impl::Init(PP_Resource config,
- PPB_AudioInput_Callback callback,
- void* user_data) {
- // Validate the config and keep a reference to it.
- EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true);
- if (enter.failed())
- return false;
- config_ = config;
-
- if (!callback)
- return false;
- SetCallback(callback, user_data);
-
- PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
- if (!plugin_delegate)
- return false;
-
- // When the stream is created, we'll get called back on StreamCreated().
- CHECK(!audio_input_);
- audio_input_ = plugin_delegate->CreateAudioInput(
- enter.object()->GetSampleRate(),
- enter.object()->GetSampleFrameCount(),
- this);
- return audio_input_ != NULL;
-}
-
-PP_Resource PPB_AudioInput_Impl::GetCurrentConfig() {
- // AddRef on behalf of caller, while keeping a ref for ourselves.
- PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_);
- return config_;
-}
-
-PP_Bool PPB_AudioInput_Impl::StartCapture() {
- if (!audio_input_)
- return PP_FALSE;
- if (capturing())
- return PP_TRUE;
- SetStartCaptureState();
- return BoolToPPBool(audio_input_->StartCapture());
-}
-
-PP_Bool PPB_AudioInput_Impl::StopCapture() {
- if (!audio_input_)
- return PP_FALSE;
- if (!capturing())
- return PP_TRUE;
- if (!audio_input_->StopCapture())
- return PP_FALSE;
- SetStopCaptureState();
- return PP_TRUE;
-}
-
-int32_t PPB_AudioInput_Impl::OpenTrusted(PP_Resource config,
- PP_CompletionCallback create_callback) {
- // Validate the config and keep a reference to it.
- EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true);
- if (enter.failed())
- return PP_ERROR_FAILED;
- config_ = config;
-
- PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
- if (!plugin_delegate)
- return PP_ERROR_FAILED;
-
- // When the stream is created, we'll get called back on StreamCreated().
- DCHECK(!audio_input_);
- audio_input_ = plugin_delegate->CreateAudioInput(
- enter.object()->GetSampleRate(),
- enter.object()->GetSampleFrameCount(),
- this);
-
- if (!audio_input_)
- return PP_ERROR_FAILED;
-
- // At this point, we are guaranteeing ownership of the completion
- // callback. Audio promises to fire the completion callback
- // once and only once.
- SetCallbackInfo(true, create_callback);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PPB_AudioInput_Impl::GetSyncSocket(int* sync_socket) {
- return GetSyncSocketImpl(sync_socket);
-}
-
-int32_t PPB_AudioInput_Impl::GetSharedMemory(int* shm_handle,
- uint32_t* shm_size) {
- return GetSharedMemoryImpl(shm_handle, shm_size);
-}
-
-void PPB_AudioInput_Impl::OnSetStreamInfo(
- base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size,
- base::SyncSocket::Handle socket_handle) {
- SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle);
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_audio_input_impl.h b/webkit/plugins/ppapi/ppb_audio_input_impl.h
deleted file mode 100644
index 9fdf0cd..0000000
--- a/webkit/plugins/ppapi/ppb_audio_input_impl.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/shared_memory.h"
-#include "base/sync_socket.h"
-#include "ppapi/c/dev/ppb_audio_input_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h"
-#include "ppapi/shared_impl/audio_config_impl.h"
-#include "ppapi/shared_impl/audio_input_impl.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/scoped_pp_resource.h"
-#include "webkit/plugins/ppapi/audio_helper.h"
-#include "webkit/plugins/ppapi/plugin_delegate.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-
-namespace webkit {
-namespace ppapi {
-
-// Some of the backend functionality of this class is implemented by the
-// AudioInputImpl so it can be shared with the proxy.
-class PPB_AudioInput_Impl : public ::ppapi::Resource,
- public ::ppapi::AudioInputImpl,
- public AudioHelper {
- public:
- // Trusted initialization. You must call Init after this.
- //
- // Untrusted initialization should just call the static Create() function
- // to properly create & initialize this class.
- explicit PPB_AudioInput_Impl(PP_Instance instance);
-
- virtual ~PPB_AudioInput_Impl();
-
- // Creation function for untrusted plugins. This handles all initialization
- // and will return 0 on failure.
- static PP_Resource Create(PP_Instance instance,
- PP_Resource config_id,
- PPB_AudioInput_Callback audio_input_callback,
- void* user_data);
-
- // Initialization function for non-trusted init.
- bool Init(PP_Resource config_id,
- PPB_AudioInput_Callback callback, void* user_data);
-
- // Resource overrides.
- virtual ::ppapi::thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE;
-
- // PPB_AudioInput_API implementation.
- virtual PP_Resource GetCurrentConfig() OVERRIDE;
- virtual PP_Bool StartCapture() OVERRIDE;
- virtual PP_Bool StopCapture() OVERRIDE;
-
- virtual int32_t OpenTrusted(PP_Resource config_id,
- PP_CompletionCallback create_callback) OVERRIDE;
- virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE;
- virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
-
- private:
- // AudioHelper implementation.
- virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
- size_t shared_memory_size_,
- base::SyncSocket::Handle socket) OVERRIDE;
-
- // AudioConfig used for creating this AudioInput object. We own a ref.
- ::ppapi::ScopedPPResource config_;
-
- // PluginDelegate audio input object that we delegate audio IPC through.
- // We don't own this pointer but are responsible for calling Shutdown on it.
- PluginDelegate::PlatformAudioInput* audio_input_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Impl);
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 2a79845..bf74fc9 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -10,7 +10,6 @@
#include "ppapi/shared_impl/var.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
-#include "webkit/plugins/ppapi/ppb_audio_input_impl.h"
#include "webkit/plugins/ppapi/ppb_broker_impl.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
@@ -74,20 +73,6 @@ PP_Resource ResourceCreationImpl::CreateAudioTrusted(
return (new PPB_Audio_Impl(instance))->GetReference();
}
-PP_Resource ResourceCreationImpl::CreateAudioInput(
- PP_Instance instance,
- PP_Resource config_id,
- PPB_AudioInput_Callback audio_input_callback,
- void* user_data) {
- return PPB_AudioInput_Impl::Create(instance, config_id,
- audio_input_callback, user_data);
-}
-
-PP_Resource ResourceCreationImpl::CreateAudioInputTrusted(
- PP_Instance instance) {
- return (new PPB_AudioInput_Impl(instance))->GetReference();
-}
-
PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
return (new PPB_Broker_Impl(instance))->GetReference();
}
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index a7a1e44..a769a8e 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -29,16 +29,10 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
PP_Resource config_id,
PPB_Audio_Callback audio_callback,
void* user_data) OVERRIDE;
- virtual PP_Resource CreateAudioTrusted(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateAudioTrusted(PP_Instance instace) OVERRIDE;
virtual PP_Resource CreateAudioConfig(PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) OVERRIDE;
- virtual PP_Resource CreateAudioInput(
- PP_Instance instance,
- PP_Resource config_id,
- PPB_AudioInput_Callback audio_input_callback,
- void* user_data) OVERRIDE;
- virtual PP_Resource CreateAudioInputTrusted(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateBuffer(PP_Instance instance,
uint32_t size) OVERRIDE;