OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/shared_memory.h" |
| 16 #include "base/sync_socket.h" |
| 17 #include "ipc/ipc_platform_file.h" |
| 18 #include "ppapi/c/ppb_audio_config.h" |
| 19 #include "ppapi/host/host_message_context.h" |
| 20 #include "ppapi/host/resource_host.h" |
| 21 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 22 |
| 23 namespace ppapi { |
| 24 struct DeviceRefData; |
| 25 } |
| 26 |
| 27 namespace content { |
| 28 |
| 29 class RendererPpapiHost; |
| 30 |
| 31 class PepperAudioInputHost |
| 32 : public ppapi::host::ResourceHost, |
| 33 public webkit::ppapi::PluginDelegate::PlatformAudioInputClient, |
| 34 public base::SupportsWeakPtr<PepperAudioInputHost> { |
| 35 public: |
| 36 PepperAudioInputHost(RendererPpapiHost* host, |
| 37 PP_Instance instance, |
| 38 PP_Resource resource); |
| 39 virtual ~PepperAudioInputHost(); |
| 40 |
| 41 virtual int32_t OnResourceMessageReceived( |
| 42 const IPC::Message& msg, |
| 43 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 44 |
| 45 // PluginDelegate::PlatformAudioInputClient implementation. |
| 46 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
| 47 size_t shared_memory_size, |
| 48 base::SyncSocket::Handle socket) OVERRIDE; |
| 49 virtual void StreamCreationFailed() OVERRIDE; |
| 50 |
| 51 private: |
| 52 int32_t OnMsgEnumerateDevices(ppapi::host::HostMessageContext* context); |
| 53 int32_t OnMsgOpen(ppapi::host::HostMessageContext* context, |
| 54 const std::string& device_id, |
| 55 PP_AudioSampleRate sample_rate, |
| 56 uint32_t sample_frame_count); |
| 57 int32_t OnMsgStartOrStop(ppapi::host::HostMessageContext* context, |
| 58 bool capture); |
| 59 int32_t OnMsgClose(ppapi::host::HostMessageContext* context); |
| 60 |
| 61 void EnumerateDevicesCallbackFunc( |
| 62 int request_id, |
| 63 bool succeeded, |
| 64 const std::vector<ppapi::DeviceRefData>& devices); |
| 65 |
| 66 void OnOpenComplete(int32_t result, |
| 67 base::SharedMemoryHandle shared_memory_handle, |
| 68 size_t shared_memory_size, |
| 69 base::SyncSocket::Handle socket_handle); |
| 70 |
| 71 int32_t GetRemoteHandles( |
| 72 const base::SyncSocket& socket, |
| 73 const base::SharedMemory& shared_memory, |
| 74 IPC::PlatformFileForTransit* remote_socket_handle, |
| 75 base::SharedMemoryHandle* remote_shared_memory_handle); |
| 76 |
| 77 void Close(); |
| 78 |
| 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. |
| 84 RendererPpapiHost* renderer_ppapi_host_; |
| 85 |
| 86 scoped_ptr<ppapi::host::ReplyMessageContext> enumerate_devices_context_; |
| 87 scoped_ptr<ppapi::host::ReplyMessageContext> open_context_; |
| 88 |
| 89 // 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. |
| 91 webkit::ppapi::PluginDelegate::PlatformAudioInput* audio_input_; |
| 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost); |
| 94 }; |
| 95 |
| 96 } // namespace content |
| 97 |
| 98 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
OLD | NEW |