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/renderer/pepper/pepper_media_device_manager.h" | 9 #include "content/renderer/pepper/pepper_media_device_manager.h" |
10 #include "content/renderer/pepper/pepper_platform_audio_input.h" | 10 #include "content/renderer/pepper/pepper_platform_audio_input.h" |
11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
12 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 12 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
13 #include "content/renderer/render_view_impl.h" | 13 #include "content/renderer/render_view_impl.h" |
14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/host/dispatch_host_message.h" | 16 #include "ppapi/host/dispatch_host_message.h" |
17 #include "ppapi/host/ppapi_host.h" | 17 #include "ppapi/host/ppapi_host.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
19 #include "ppapi/proxy/serialized_structs.h" | 19 #include "ppapi/proxy/serialized_structs.h" |
20 #include "third_party/WebKit/public/web/WebDocument.h" | |
21 #include "third_party/WebKit/public/web/WebElement.h" | |
22 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
23 | 20 |
24 namespace content { | 21 namespace content { |
25 | 22 |
26 namespace { | 23 namespace { |
27 | 24 |
28 base::PlatformFile ConvertSyncSocketHandle(const base::SyncSocket& socket) { | 25 base::PlatformFile ConvertSyncSocketHandle(const base::SyncSocket& socket) { |
29 return socket.handle(); | 26 return socket.handle(); |
30 } | 27 } |
31 | 28 |
32 base::PlatformFile ConvertSharedMemoryHandle( | 29 base::PlatformFile ConvertSharedMemoryHandle( |
(...skipping 13 matching lines...) Expand all Loading... |
46 RendererPpapiHostImpl* host, | 43 RendererPpapiHostImpl* host, |
47 PP_Instance instance, | 44 PP_Instance instance, |
48 PP_Resource resource) | 45 PP_Resource resource) |
49 : ResourceHost(host->GetPpapiHost(), instance, resource), | 46 : ResourceHost(host->GetPpapiHost(), instance, resource), |
50 renderer_ppapi_host_(host), | 47 renderer_ppapi_host_(host), |
51 audio_input_(NULL), | 48 audio_input_(NULL), |
52 enumeration_helper_( | 49 enumeration_helper_( |
53 this, | 50 this, |
54 PepperMediaDeviceManager::GetForRenderView( | 51 PepperMediaDeviceManager::GetForRenderView( |
55 host->GetRenderViewForInstance(pp_instance())), | 52 host->GetRenderViewForInstance(pp_instance())), |
56 PP_DEVICETYPE_DEV_AUDIOCAPTURE) { | 53 PP_DEVICETYPE_DEV_AUDIOCAPTURE, |
| 54 host->GetDocumentURL(instance)) { |
57 } | 55 } |
58 | 56 |
59 PepperAudioInputHost::~PepperAudioInputHost() { | 57 PepperAudioInputHost::~PepperAudioInputHost() { |
60 Close(); | 58 Close(); |
61 } | 59 } |
62 | 60 |
63 int32_t PepperAudioInputHost::OnResourceMessageReceived( | 61 int32_t PepperAudioInputHost::OnResourceMessageReceived( |
64 const IPC::Message& msg, | 62 const IPC::Message& msg, |
65 ppapi::host::HostMessageContext* context) { | 63 ppapi::host::HostMessageContext* context) { |
66 int32_t result = PP_ERROR_FAILED; | 64 int32_t result = PP_ERROR_FAILED; |
(...skipping 25 matching lines...) Expand all Loading... |
92 int32_t PepperAudioInputHost::OnOpen( | 90 int32_t PepperAudioInputHost::OnOpen( |
93 ppapi::host::HostMessageContext* context, | 91 ppapi::host::HostMessageContext* context, |
94 const std::string& device_id, | 92 const std::string& device_id, |
95 PP_AudioSampleRate sample_rate, | 93 PP_AudioSampleRate sample_rate, |
96 uint32_t sample_frame_count) { | 94 uint32_t sample_frame_count) { |
97 if (open_context_) | 95 if (open_context_) |
98 return PP_ERROR_INPROGRESS; | 96 return PP_ERROR_INPROGRESS; |
99 if (audio_input_) | 97 if (audio_input_) |
100 return PP_ERROR_FAILED; | 98 return PP_ERROR_FAILED; |
101 | 99 |
102 PepperPluginInstanceImpl* instance = | 100 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); |
103 renderer_ppapi_host_->GetPluginInstanceImpl(pp_instance()); | 101 if (!document_url.is_valid()) |
104 if (!instance) | |
105 return PP_ERROR_FAILED; | 102 return PP_ERROR_FAILED; |
106 | 103 |
107 // When it is done, we'll get called back on StreamCreated() or | 104 // When it is done, we'll get called back on StreamCreated() or |
108 // StreamCreationFailed(). | 105 // StreamCreationFailed(). |
109 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( | 106 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( |
110 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); | 107 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); |
111 | 108 |
112 audio_input_ = PepperPlatformAudioInput::Create( | 109 audio_input_ = PepperPlatformAudioInput::Create( |
113 render_view->AsWeakPtr(), device_id, | 110 render_view->AsWeakPtr(), device_id, |
114 instance->container()->element().document().url(), | 111 document_url, |
115 static_cast<int>(sample_rate), | 112 static_cast<int>(sample_rate), |
116 static_cast<int>(sample_frame_count), this); | 113 static_cast<int>(sample_frame_count), this); |
117 if (audio_input_) { | 114 if (audio_input_) { |
118 open_context_.reset(new ppapi::host::ReplyMessageContext( | 115 open_context_.reset(new ppapi::host::ReplyMessageContext( |
119 context->MakeReplyMessageContext())); | 116 context->MakeReplyMessageContext())); |
120 return PP_OK_COMPLETIONPENDING; | 117 return PP_OK_COMPLETIONPENDING; |
121 } else { | 118 } else { |
122 return PP_ERROR_FAILED; | 119 return PP_ERROR_FAILED; |
123 } | 120 } |
124 } | 121 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 208 |
212 if (open_context_) { | 209 if (open_context_) { |
213 open_context_->params.set_result(PP_ERROR_ABORTED); | 210 open_context_->params.set_result(PP_ERROR_ABORTED); |
214 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); | 211 host()->SendReply(*open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
215 open_context_.reset(); | 212 open_context_.reset(); |
216 } | 213 } |
217 } | 214 } |
218 | 215 |
219 } // namespace content | 216 } // namespace content |
220 | 217 |
OLD | NEW |