| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_audio_input_host.h" | 5 #include "content/renderer/pepper/pepper_audio_input_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| 11 #include "media/audio/shared_memory_util.h" | 11 #include "media/audio/shared_memory_util.h" |
| 12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/host/dispatch_host_message.h" | 13 #include "ppapi/host/dispatch_host_message.h" |
| 14 #include "ppapi/host/ppapi_host.h" | 14 #include "ppapi/host/ppapi_host.h" |
| 15 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
| 16 #include "ppapi/proxy/serialized_structs.h" | 16 #include "ppapi/proxy/serialized_structs.h" |
| 17 #include "third_party/WebKit/public/web/WebDocument.h" | 17 #include "third_party/WebKit/public/web/WebDocument.h" |
| 18 #include "third_party/WebKit/public/web/WebElement.h" | 18 #include "third_party/WebKit/public/web/WebElement.h" |
| 19 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 19 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 base::PlatformFile ConvertSyncSocketHandle(const base::SyncSocket& socket) { | 26 base::PlatformFile ConvertSyncSocketHandle(const base::SyncSocket& socket) { |
| 27 return socket.handle(); | 27 return socket.handle(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 base::PlatformFile ConvertSharedMemoryHandle( | 30 base::PlatformFile ConvertSharedMemoryHandle( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 base::SyncSocket::Handle socket) { | 77 base::SyncSocket::Handle socket) { |
| 78 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); | 78 OnOpenComplete(PP_OK, shared_memory_handle, shared_memory_size, socket); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void PepperAudioInputHost::StreamCreationFailed() { | 81 void PepperAudioInputHost::StreamCreationFailed() { |
| 82 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemory::NULLHandle(), 0, | 82 OnOpenComplete(PP_ERROR_FAILED, base::SharedMemory::NULLHandle(), 0, |
| 83 base::SyncSocket::kInvalidHandle); | 83 base::SyncSocket::kInvalidHandle); |
| 84 } | 84 } |
| 85 | 85 |
| 86 webkit::ppapi::PluginDelegate* PepperAudioInputHost::GetPluginDelegate() { | 86 webkit::ppapi::PluginDelegate* PepperAudioInputHost::GetPluginDelegate() { |
| 87 webkit::ppapi::PluginInstance* instance = | 87 webkit::ppapi::PluginInstanceImpl* instance = |
| 88 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 88 static_cast<webkit::ppapi::PluginInstanceImpl*>( |
| 89 renderer_ppapi_host_->GetPluginInstance(pp_instance())); |
| 89 if (instance) | 90 if (instance) |
| 90 return instance->delegate(); | 91 return instance->delegate(); |
| 91 return NULL; | 92 return NULL; |
| 92 } | 93 } |
| 93 | 94 |
| 94 int32_t PepperAudioInputHost::OnOpen( | 95 int32_t PepperAudioInputHost::OnOpen( |
| 95 ppapi::host::HostMessageContext* context, | 96 ppapi::host::HostMessageContext* context, |
| 96 const std::string& device_id, | 97 const std::string& device_id, |
| 97 PP_AudioSampleRate sample_rate, | 98 PP_AudioSampleRate sample_rate, |
| 98 uint32_t sample_frame_count) { | 99 uint32_t sample_frame_count) { |
| 99 if (open_context_) | 100 if (open_context_) |
| 100 return PP_ERROR_INPROGRESS; | 101 return PP_ERROR_INPROGRESS; |
| 101 if (audio_input_) | 102 if (audio_input_) |
| 102 return PP_ERROR_FAILED; | 103 return PP_ERROR_FAILED; |
| 103 | 104 |
| 104 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); | 105 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); |
| 105 if (!plugin_delegate) | 106 if (!plugin_delegate) |
| 106 return PP_ERROR_FAILED; | 107 return PP_ERROR_FAILED; |
| 107 | 108 |
| 108 webkit::ppapi::PluginInstance* instance = | 109 webkit::ppapi::PluginInstanceImpl* instance = |
| 109 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 110 static_cast<webkit::ppapi::PluginInstanceImpl*>( |
| 111 renderer_ppapi_host_->GetPluginInstance(pp_instance())); |
| 110 if (!instance) | 112 if (!instance) |
| 111 return PP_ERROR_FAILED; | 113 return PP_ERROR_FAILED; |
| 112 | 114 |
| 113 // When it is done, we'll get called back on StreamCreated() or | 115 // When it is done, we'll get called back on StreamCreated() or |
| 114 // StreamCreationFailed(). | 116 // StreamCreationFailed(). |
| 115 audio_input_ = plugin_delegate->CreateAudioInput( | 117 audio_input_ = plugin_delegate->CreateAudioInput( |
| 116 device_id, instance->container()->element().document().url(), | 118 device_id, instance->container()->element().document().url(), |
| 117 sample_rate, sample_frame_count, this); | 119 sample_rate, sample_frame_count, this); |
| 118 if (audio_input_) { | 120 if (audio_input_) { |
| 119 open_context_.reset(new ppapi::host::ReplyMessageContext( | 121 open_context_.reset(new ppapi::host::ReplyMessageContext( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 220 |
| 219 if (open_context_) { | 221 if (open_context_) { |
| 220 open_context_->params.set_result(PP_ERROR_ABORTED); | 222 open_context_->params.set_result(PP_ERROR_ABORTED); |
| 221 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); | 223 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
| 222 open_context_.reset(); | 224 open_context_.reset(); |
| 223 } | 225 } |
| 224 } | 226 } |
| 225 | 227 |
| 226 } // namespace content | 228 } // namespace content |
| 227 | 229 |
| OLD | NEW |