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/memory/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"
22 class PepperPlatformAudioInput
;
23 class RendererPpapiHostImpl
;
25 class PepperAudioInputHost
: public ppapi::host::ResourceHost
{
27 PepperAudioInputHost(RendererPpapiHostImpl
* host
,
29 PP_Resource resource
);
30 ~PepperAudioInputHost() override
;
32 int32_t OnResourceMessageReceived(
33 const IPC::Message
& msg
,
34 ppapi::host::HostMessageContext
* context
) override
;
36 // Called when the stream is created.
37 void StreamCreated(base::SharedMemoryHandle shared_memory_handle
,
38 size_t shared_memory_size
,
39 base::SyncSocket::Handle socket
);
40 void StreamCreationFailed();
43 int32_t OnOpen(ppapi::host::HostMessageContext
* context
,
44 const std::string
& device_id
,
45 PP_AudioSampleRate sample_rate
,
46 uint32_t sample_frame_count
);
47 int32_t OnStartOrStop(ppapi::host::HostMessageContext
* context
, bool capture
);
48 int32_t OnClose(ppapi::host::HostMessageContext
* context
);
50 void OnOpenComplete(int32_t result
,
51 base::SharedMemoryHandle shared_memory_handle
,
52 size_t shared_memory_size
,
53 base::SyncSocket::Handle socket_handle
);
55 int32_t GetRemoteHandles(
56 const base::SyncSocket
& socket
,
57 const base::SharedMemory
& shared_memory
,
58 IPC::PlatformFileForTransit
* remote_socket_handle
,
59 base::SharedMemoryHandle
* remote_shared_memory_handle
);
63 void SendOpenReply(int32_t result
);
65 // Non-owning pointer.
66 RendererPpapiHostImpl
* renderer_ppapi_host_
;
68 ppapi::host::ReplyMessageContext open_context_
;
70 // Audio input object that we delegate audio IPC through.
71 // We don't own this pointer but are responsible for calling Shutdown on it.
72 PepperPlatformAudioInput
* audio_input_
;
74 PepperDeviceEnumerationHostHelper enumeration_helper_
;
76 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost
);
79 } // namespace content
81 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_