#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_
#include "base/process/process.h"
#include "base/sync_socket.h"
#include "base/time/time.h"
#include "media/audio/audio_input_controller.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
#endif
namespace base {
class SharedMemory;
}
namespace content {
class AudioInputSyncWriter : public media::AudioInputController::SyncWriter {
public:
explicit AudioInputSyncWriter(base::SharedMemory* shared_memory,
int shared_memory_segment_count);
virtual ~AudioInputSyncWriter();
virtual void UpdateRecordedBytes(uint32 bytes) OVERRIDE;
virtual uint32 Write(const void* data,
uint32 size,
double volume,
bool key_pressed) OVERRIDE;
virtual void Close() OVERRIDE;
bool Init();
bool PrepareForeignSocketHandle(base::ProcessHandle process_handle,
#if defined(OS_WIN)
base::SyncSocket::Handle* foreign_handle);
#else
base::FileDescriptor* foreign_handle);
#endif
private:
base::SharedMemory* shared_memory_;
uint32 shared_memory_segment_size_;
uint32 shared_memory_segment_count_;
uint32 current_segment_id_;
scoped_ptr<base::CancelableSyncSocket> socket_;
scoped_ptr<base::CancelableSyncSocket> foreign_socket_;
base::Time creation_time_;
base::Time last_write_time_;
DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputSyncWriter);
};
}
#endif