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

Side by Side Diff: content/renderer/pepper/pepper_audio_input_host.cc

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and undo checkdeps change Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/renderer/pepper/renderer_ppapi_host_impl.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(
31 const base::SharedMemory& shared_memory) { 31 const base::SharedMemory& shared_memory) {
32 #if defined(OS_POSIX) 32 #if defined(OS_POSIX)
33 return shared_memory.handle().fd; 33 return shared_memory.handle().fd;
34 #elif defined(OS_WIN) 34 #elif defined(OS_WIN)
35 return shared_memory.handle(); 35 return shared_memory.handle();
36 #else 36 #else
37 #error "Platform not supported." 37 #error "Platform not supported."
38 #endif 38 #endif
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 PepperAudioInputHost::PepperAudioInputHost( 43 PepperAudioInputHost::PepperAudioInputHost(
44 RendererPpapiHost* host, 44 RendererPpapiHostImpl* host,
45 PP_Instance instance, 45 PP_Instance instance,
46 PP_Resource resource) 46 PP_Resource resource)
47 : ResourceHost(host->GetPpapiHost(), instance, resource), 47 : ResourceHost(host->GetPpapiHost(), instance, resource),
48 renderer_ppapi_host_(host), 48 renderer_ppapi_host_(host),
49 audio_input_(NULL), 49 audio_input_(NULL),
50 enumeration_helper_(this, this, PP_DEVICETYPE_DEV_AUDIOCAPTURE) { 50 enumeration_helper_(this, this, PP_DEVICETYPE_DEV_AUDIOCAPTURE) {
51 } 51 }
52 52
53 PepperAudioInputHost::~PepperAudioInputHost() { 53 PepperAudioInputHost::~PepperAudioInputHost() {
54 Close(); 54 Close();
(...skipping 22 matching lines...) Expand all
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 renderer_ppapi_host_->GetPluginInstanceImpl(pp_instance());
89 if (instance) 89 if (instance)
90 return instance->delegate(); 90 return instance->delegate();
91 return NULL; 91 return NULL;
92 } 92 }
93 93
94 int32_t PepperAudioInputHost::OnOpen( 94 int32_t PepperAudioInputHost::OnOpen(
95 ppapi::host::HostMessageContext* context, 95 ppapi::host::HostMessageContext* context,
96 const std::string& device_id, 96 const std::string& device_id,
97 PP_AudioSampleRate sample_rate, 97 PP_AudioSampleRate sample_rate,
98 uint32_t sample_frame_count) { 98 uint32_t sample_frame_count) {
99 if (open_context_) 99 if (open_context_)
100 return PP_ERROR_INPROGRESS; 100 return PP_ERROR_INPROGRESS;
101 if (audio_input_) 101 if (audio_input_)
102 return PP_ERROR_FAILED; 102 return PP_ERROR_FAILED;
103 103
104 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); 104 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate();
105 if (!plugin_delegate) 105 if (!plugin_delegate)
106 return PP_ERROR_FAILED; 106 return PP_ERROR_FAILED;
107 107
108 webkit::ppapi::PluginInstance* instance = 108 webkit::ppapi::PluginInstanceImpl* instance =
109 renderer_ppapi_host_->GetPluginInstance(pp_instance()); 109 renderer_ppapi_host_->GetPluginInstanceImpl(pp_instance());
110 if (!instance) 110 if (!instance)
111 return PP_ERROR_FAILED; 111 return PP_ERROR_FAILED;
112 112
113 // When it is done, we'll get called back on StreamCreated() or 113 // When it is done, we'll get called back on StreamCreated() or
114 // StreamCreationFailed(). 114 // StreamCreationFailed().
115 audio_input_ = plugin_delegate->CreateAudioInput( 115 audio_input_ = plugin_delegate->CreateAudioInput(
116 device_id, instance->container()->element().document().url(), 116 device_id, instance->container()->element().document().url(),
117 sample_rate, sample_frame_count, this); 117 sample_rate, sample_frame_count, this);
118 if (audio_input_) { 118 if (audio_input_) {
119 open_context_.reset(new ppapi::host::ReplyMessageContext( 119 open_context_.reset(new ppapi::host::ReplyMessageContext(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 if (open_context_) { 219 if (open_context_) {
220 open_context_->params.set_result(PP_ERROR_ABORTED); 220 open_context_->params.set_result(PP_ERROR_ABORTED);
221 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); 221 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply());
222 open_context_.reset(); 222 open_context_.reset();
223 } 223 }
224 } 224 }
225 225
226 } // namespace content 226 } // namespace content
227 227
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_audio_input_host.h ('k') | content/renderer/pepper/pepper_file_io_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698