#ifndef CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_
#define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_
#include "base/callback.h"
#include "base/id_map.h"
#include "ipc/ipc_channel_proxy.h"
#include "media/cast/cast_sender.h"
#include "media/cast/logging/logging_defines.h"
#include "media/cast/transport/cast_transport_sender.h"
class CastTransportSenderIPC;
class CastIPCDispatcher : public IPC::ChannelProxy::MessageFilter {
public:
explicit CastIPCDispatcher(
const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
static CastIPCDispatcher* Get();
void Send(IPC::Message* message);
int32 AddSender(CastTransportSenderIPC* sender);
void RemoveSender(int32 channel_id);
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
virtual void OnFilterRemoved() OVERRIDE;
virtual void OnChannelClosing() OVERRIDE;
protected:
virtual ~CastIPCDispatcher();
private:
void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet);
void OnNotifyStatusChange(
int32 channel_id,
media::cast::transport::CastTransportStatus status);
void OnRtpStatistics(
int32 channel_id,
bool audio,
const media::cast::transport::RtcpSenderInfo& sender_info,
base::TimeTicks time_sent,
uint32 rtp_timestamp);
void OnRawEvents(int32 channel_id,
const std::vector<media::cast::PacketEvent>& packet_events);
static CastIPCDispatcher* global_instance_;
IPC::Channel* channel_;
const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
IDMap<CastTransportSenderIPC> id_map_;
DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher);
};
#endif