OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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. |
| 4 |
| 5 #ifndef CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
| 6 #define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/id_map.h" |
| 10 #include "ipc/ipc_channel_proxy.h" |
| 11 #include "media/cast/cast_sender.h" |
| 12 #include "media/cast/transport/cast_transport_sender.h" |
| 13 |
| 14 class CastTransportSenderIPC; |
| 15 |
| 16 // This dispatcher listens to incoming IPC messages and sends |
| 17 // the call to the correct CastTransportSenderIPC instance. |
| 18 class CastIPCDispatcher : public IPC::ChannelProxy::MessageFilter { |
| 19 public: |
| 20 explicit CastIPCDispatcher( |
| 21 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| 22 |
| 23 static CastIPCDispatcher* Get(); |
| 24 void Send(IPC::Message* message); |
| 25 int32 AddSender(CastTransportSenderIPC* sender); |
| 26 void RemoveSender(int32 channel_id); |
| 27 |
| 28 // IPC::ChannelProxy::MessageFilter implementation |
| 29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 30 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| 31 virtual void OnFilterRemoved() OVERRIDE; |
| 32 virtual void OnChannelClosing() OVERRIDE; |
| 33 |
| 34 protected: |
| 35 virtual ~CastIPCDispatcher(); |
| 36 |
| 37 private: |
| 38 void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet); |
| 39 void OnNotifyStatusChange( |
| 40 int32 channel_id, |
| 41 media::cast::transport::CastTransportStatus status); |
| 42 void OnRtpStatistics( |
| 43 int32 channel_id, |
| 44 bool audio, |
| 45 const media::cast::transport::RtcpSenderInfo& sender_info, |
| 46 base::TimeTicks time_sent, |
| 47 uint32 rtp_timestamp); |
| 48 |
| 49 static CastIPCDispatcher* global_instance_; |
| 50 |
| 51 // IPC channel for Send(); must only be accesed on |io_message_loop_|. |
| 52 IPC::Channel* channel_; |
| 53 |
| 54 // Message loop on which IPC calls are driven. |
| 55 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 56 |
| 57 // A map of stream ids to delegates; must only be accessed on |
| 58 // |io_message_loop_|. |
| 59 IDMap<CastTransportSenderIPC> id_map_; |
| 60 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); |
| 61 }; |
| 62 |
| 63 #endif // CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
OLD | NEW |