#ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/sync_socket.h"
#include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
#include "ipc/ipc_platform_file.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
namespace content {
class PepperPlatformAudioInput;
class RendererPpapiHostImpl;
class PepperAudioInputHost : public ppapi::host::ResourceHost {
public:
PepperAudioInputHost(RendererPpapiHostImpl* host,
PP_Instance instance,
PP_Resource resource);
virtual ~PepperAudioInputHost();
virtual int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket);
void StreamCreationFailed();
private:
int32_t OnOpen(ppapi::host::HostMessageContext* context,
const std::string& device_id,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count);
int32_t OnStartOrStop(ppapi::host::HostMessageContext* context,
bool capture);
int32_t OnClose(ppapi::host::HostMessageContext* context);
void OnOpenComplete(int32_t result,
base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket_handle);
int32_t GetRemoteHandles(
const base::SyncSocket& socket,
const base::SharedMemory& shared_memory,
IPC::PlatformFileForTransit* remote_socket_handle,
base::SharedMemoryHandle* remote_shared_memory_handle);
void Close();
RendererPpapiHostImpl* renderer_ppapi_host_;
scoped_ptr<ppapi::host::ReplyMessageContext> open_context_;
PepperPlatformAudioInput* audio_input_;
PepperDeviceEnumerationHostHelper enumeration_helper_;
DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost);
};
}
#endif