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.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/shared_memory.h"
14 #include "base/sync_socket.h"
15 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
16 #include "ipc/ipc_platform_file.h"
17 #include "ppapi/c/ppb_audio_config.h"
18 #include "ppapi/host/host_message_context.h"
19 #include "ppapi/host/resource_host.h"
20 #include "webkit/plugins/ppapi/plugin_delegate.h"
24 class RendererPpapiHost
;
26 class PepperAudioInputHost
27 : public ppapi::host::ResourceHost
,
28 public webkit::ppapi::PluginDelegate::PlatformAudioInputClient
,
29 public PepperDeviceEnumerationHostHelper::Delegate
{
31 PepperAudioInputHost(RendererPpapiHost
* host
,
33 PP_Resource resource
);
34 virtual ~PepperAudioInputHost();
36 virtual int32_t OnResourceMessageReceived(
37 const IPC::Message
& msg
,
38 ppapi::host::HostMessageContext
* context
) OVERRIDE
;
40 // PluginDelegate::PlatformAudioInputClient implementation.
41 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle
,
42 size_t shared_memory_size
,
43 base::SyncSocket::Handle socket
) OVERRIDE
;
44 virtual void StreamCreationFailed() OVERRIDE
;
46 // PepperDeviceEnumerationHostHelper::Delegate implementation.
47 virtual webkit::ppapi::PluginDelegate
* GetPluginDelegate() OVERRIDE
;
50 int32_t OnOpen(ppapi::host::HostMessageContext
* context
,
51 const std::string
& device_id
,
52 PP_AudioSampleRate sample_rate
,
53 uint32_t sample_frame_count
);
54 int32_t OnStartOrStop(ppapi::host::HostMessageContext
* context
,
56 int32_t OnClose(ppapi::host::HostMessageContext
* context
);
58 void OnOpenComplete(int32_t result
,
59 base::SharedMemoryHandle shared_memory_handle
,
60 size_t shared_memory_size
,
61 base::SyncSocket::Handle socket_handle
);
63 int32_t GetRemoteHandles(
64 const base::SyncSocket
& socket
,
65 const base::SharedMemory
& shared_memory
,
66 IPC::PlatformFileForTransit
* remote_socket_handle
,
67 base::SharedMemoryHandle
* remote_shared_memory_handle
);
71 // Non-owning pointer.
72 RendererPpapiHost
* renderer_ppapi_host_
;
74 scoped_ptr
<ppapi::host::ReplyMessageContext
> open_context_
;
76 // PluginDelegate audio input object that we delegate audio IPC through.
77 // We don't own this pointer but are responsible for calling Shutdown on it.
78 webkit::ppapi::PluginDelegate::PlatformAudioInput
* audio_input_
;
80 PepperDeviceEnumerationHostHelper enumeration_helper_
;
82 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost
);
85 } // namespace content
87 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_