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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
10 | 9 |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
16 #include "base/sync_socket.h" | 14 #include "base/sync_socket.h" |
| 15 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" |
17 #include "ipc/ipc_platform_file.h" | 16 #include "ipc/ipc_platform_file.h" |
18 #include "ppapi/c/ppb_audio_config.h" | 17 #include "ppapi/c/ppb_audio_config.h" |
19 #include "ppapi/host/host_message_context.h" | 18 #include "ppapi/host/host_message_context.h" |
20 #include "ppapi/host/resource_host.h" | 19 #include "ppapi/host/resource_host.h" |
21 #include "webkit/plugins/ppapi/plugin_delegate.h" | 20 #include "webkit/plugins/ppapi/plugin_delegate.h" |
22 | 21 |
23 namespace ppapi { | |
24 struct DeviceRefData; | |
25 } | |
26 | |
27 namespace content { | 22 namespace content { |
28 | 23 |
29 class RendererPpapiHost; | 24 class RendererPpapiHost; |
30 | 25 |
31 class PepperAudioInputHost | 26 class PepperAudioInputHost |
32 : public ppapi::host::ResourceHost, | 27 : public ppapi::host::ResourceHost, |
33 public webkit::ppapi::PluginDelegate::PlatformAudioInputClient, | 28 public webkit::ppapi::PluginDelegate::PlatformAudioInputClient, |
34 public base::SupportsWeakPtr<PepperAudioInputHost> { | 29 public PepperDeviceEnumerationHostHelper::Delegate { |
35 public: | 30 public: |
36 PepperAudioInputHost(RendererPpapiHost* host, | 31 PepperAudioInputHost(RendererPpapiHost* host, |
37 PP_Instance instance, | 32 PP_Instance instance, |
38 PP_Resource resource); | 33 PP_Resource resource); |
39 virtual ~PepperAudioInputHost(); | 34 virtual ~PepperAudioInputHost(); |
40 | 35 |
41 virtual int32_t OnResourceMessageReceived( | 36 virtual int32_t OnResourceMessageReceived( |
42 const IPC::Message& msg, | 37 const IPC::Message& msg, |
43 ppapi::host::HostMessageContext* context) OVERRIDE; | 38 ppapi::host::HostMessageContext* context) OVERRIDE; |
44 | 39 |
45 // PluginDelegate::PlatformAudioInputClient implementation. | 40 // PluginDelegate::PlatformAudioInputClient implementation. |
46 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 41 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
47 size_t shared_memory_size, | 42 size_t shared_memory_size, |
48 base::SyncSocket::Handle socket) OVERRIDE; | 43 base::SyncSocket::Handle socket) OVERRIDE; |
49 virtual void StreamCreationFailed() OVERRIDE; | 44 virtual void StreamCreationFailed() OVERRIDE; |
50 | 45 |
| 46 // PepperDeviceEnumerationHostHelper::Delegate implementation. |
| 47 virtual webkit::ppapi::PluginDelegate* GetPluginDelegate() OVERRIDE; |
| 48 |
51 private: | 49 private: |
52 int32_t OnMsgEnumerateDevices(ppapi::host::HostMessageContext* context); | |
53 int32_t OnMsgOpen(ppapi::host::HostMessageContext* context, | 50 int32_t OnMsgOpen(ppapi::host::HostMessageContext* context, |
54 const std::string& device_id, | 51 const std::string& device_id, |
55 PP_AudioSampleRate sample_rate, | 52 PP_AudioSampleRate sample_rate, |
56 uint32_t sample_frame_count); | 53 uint32_t sample_frame_count); |
57 int32_t OnMsgStartOrStop(ppapi::host::HostMessageContext* context, | 54 int32_t OnMsgStartOrStop(ppapi::host::HostMessageContext* context, |
58 bool capture); | 55 bool capture); |
59 int32_t OnMsgClose(ppapi::host::HostMessageContext* context); | 56 int32_t OnMsgClose(ppapi::host::HostMessageContext* context); |
60 | 57 |
61 void EnumerateDevicesCallbackFunc( | |
62 int request_id, | |
63 bool succeeded, | |
64 const std::vector<ppapi::DeviceRefData>& devices); | |
65 | |
66 void OnOpenComplete(int32_t result, | 58 void OnOpenComplete(int32_t result, |
67 base::SharedMemoryHandle shared_memory_handle, | 59 base::SharedMemoryHandle shared_memory_handle, |
68 size_t shared_memory_size, | 60 size_t shared_memory_size, |
69 base::SyncSocket::Handle socket_handle); | 61 base::SyncSocket::Handle socket_handle); |
70 | 62 |
71 int32_t GetRemoteHandles( | 63 int32_t GetRemoteHandles( |
72 const base::SyncSocket& socket, | 64 const base::SyncSocket& socket, |
73 const base::SharedMemory& shared_memory, | 65 const base::SharedMemory& shared_memory, |
74 IPC::PlatformFileForTransit* remote_socket_handle, | 66 IPC::PlatformFileForTransit* remote_socket_handle, |
75 base::SharedMemoryHandle* remote_shared_memory_handle); | 67 base::SharedMemoryHandle* remote_shared_memory_handle); |
76 | 68 |
77 void Close(); | 69 void Close(); |
78 | 70 |
79 // TODO(yzshen): Move the relevant functionality out of PluginDelegate and get | |
80 // rid of this method. | |
81 webkit::ppapi::PluginDelegate* GetDelegate() const; | |
82 | |
83 // Non-owning pointer. | 71 // Non-owning pointer. |
84 RendererPpapiHost* renderer_ppapi_host_; | 72 RendererPpapiHost* renderer_ppapi_host_; |
85 | 73 |
86 scoped_ptr<ppapi::host::ReplyMessageContext> enumerate_devices_context_; | |
87 scoped_ptr<ppapi::host::ReplyMessageContext> open_context_; | 74 scoped_ptr<ppapi::host::ReplyMessageContext> open_context_; |
88 | 75 |
89 // PluginDelegate audio input object that we delegate audio IPC through. | 76 // PluginDelegate audio input object that we delegate audio IPC through. |
90 // We don't own this pointer but are responsible for calling Shutdown on it. | 77 // We don't own this pointer but are responsible for calling Shutdown on it. |
91 webkit::ppapi::PluginDelegate::PlatformAudioInput* audio_input_; | 78 webkit::ppapi::PluginDelegate::PlatformAudioInput* audio_input_; |
92 | 79 |
| 80 PepperDeviceEnumerationHostHelper enumeration_helper_; |
| 81 |
93 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost); | 82 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost); |
94 }; | 83 }; |
95 | 84 |
96 } // namespace content | 85 } // namespace content |
97 | 86 |
98 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ | 87 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
OLD | NEW |