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_frame_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 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 namespace { | 23 namespace { |
(...skipping 15 matching lines...) Expand all Loading... |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 PepperAudioInputHost::PepperAudioInputHost(RendererPpapiHostImpl* host, | 42 PepperAudioInputHost::PepperAudioInputHost(RendererPpapiHostImpl* host, |
43 PP_Instance instance, | 43 PP_Instance instance, |
44 PP_Resource resource) | 44 PP_Resource resource) |
45 : ResourceHost(host->GetPpapiHost(), instance, resource), | 45 : ResourceHost(host->GetPpapiHost(), instance, resource), |
46 renderer_ppapi_host_(host), | 46 renderer_ppapi_host_(host), |
47 audio_input_(NULL), | 47 audio_input_(NULL), |
48 enumeration_helper_(this, | 48 enumeration_helper_(this, |
49 PepperMediaDeviceManager::GetForRenderView( | 49 PepperMediaDeviceManager::GetForRenderFrame( |
50 host->GetRenderViewForInstance(pp_instance())), | 50 host->GetRenderFrameForInstance(pp_instance())), |
51 PP_DEVICETYPE_DEV_AUDIOCAPTURE, | 51 PP_DEVICETYPE_DEV_AUDIOCAPTURE, |
52 host->GetDocumentURL(instance)) {} | 52 host->GetDocumentURL(instance)) {} |
53 | 53 |
54 PepperAudioInputHost::~PepperAudioInputHost() { Close(); } | 54 PepperAudioInputHost::~PepperAudioInputHost() { Close(); } |
55 | 55 |
56 int32_t PepperAudioInputHost::OnResourceMessageReceived( | 56 int32_t PepperAudioInputHost::OnResourceMessageReceived( |
57 const IPC::Message& msg, | 57 const IPC::Message& msg, |
58 ppapi::host::HostMessageContext* context) { | 58 ppapi::host::HostMessageContext* context) { |
59 int32_t result = PP_ERROR_FAILED; | 59 int32_t result = PP_ERROR_FAILED; |
60 if (enumeration_helper_.HandleResourceMessage(msg, context, &result)) | 60 if (enumeration_helper_.HandleResourceMessage(msg, context, &result)) |
(...skipping 30 matching lines...) Expand all Loading... |
91 return PP_ERROR_INPROGRESS; | 91 return PP_ERROR_INPROGRESS; |
92 if (audio_input_) | 92 if (audio_input_) |
93 return PP_ERROR_FAILED; | 93 return PP_ERROR_FAILED; |
94 | 94 |
95 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); | 95 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); |
96 if (!document_url.is_valid()) | 96 if (!document_url.is_valid()) |
97 return PP_ERROR_FAILED; | 97 return PP_ERROR_FAILED; |
98 | 98 |
99 // When it is done, we'll get called back on StreamCreated() or | 99 // When it is done, we'll get called back on StreamCreated() or |
100 // StreamCreationFailed(). | 100 // StreamCreationFailed(). |
101 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( | 101 audio_input_ = PepperPlatformAudioInput::Create( |
102 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); | 102 renderer_ppapi_host_->GetRenderFrameForInstance(pp_instance())-> |
103 | 103 GetRoutingID(), |
104 audio_input_ = | 104 device_id, |
105 PepperPlatformAudioInput::Create(render_view->AsWeakPtr(), | 105 document_url, |
106 device_id, | 106 static_cast<int>(sample_rate), |
107 document_url, | 107 static_cast<int>(sample_frame_count), |
108 static_cast<int>(sample_rate), | 108 this); |
109 static_cast<int>(sample_frame_count), | |
110 this); | |
111 if (audio_input_) { | 109 if (audio_input_) { |
112 open_context_ = context->MakeReplyMessageContext(); | 110 open_context_ = context->MakeReplyMessageContext(); |
113 return PP_OK_COMPLETIONPENDING; | 111 return PP_OK_COMPLETIONPENDING; |
114 } else { | 112 } else { |
115 return PP_ERROR_FAILED; | 113 return PP_ERROR_FAILED; |
116 } | 114 } |
117 } | 115 } |
118 | 116 |
119 int32_t PepperAudioInputHost::OnStartOrStop( | 117 int32_t PepperAudioInputHost::OnStartOrStop( |
120 ppapi::host::HostMessageContext* /* context */, | 118 ppapi::host::HostMessageContext* /* context */, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 SendOpenReply(PP_ERROR_ABORTED); | 201 SendOpenReply(PP_ERROR_ABORTED); |
204 } | 202 } |
205 | 203 |
206 void PepperAudioInputHost::SendOpenReply(int32_t result) { | 204 void PepperAudioInputHost::SendOpenReply(int32_t result) { |
207 open_context_.params.set_result(result); | 205 open_context_.params.set_result(result); |
208 host()->SendReply(open_context_, PpapiPluginMsg_AudioInput_OpenReply()); | 206 host()->SendReply(open_context_, PpapiPluginMsg_AudioInput_OpenReply()); |
209 open_context_ = ppapi::host::ReplyMessageContext(); | 207 open_context_ = ppapi::host::ReplyMessageContext(); |
210 } | 208 } |
211 | 209 |
212 } // namespace content | 210 } // namespace content |
OLD | NEW |