OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
6 #define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/macros.h" |
10 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
11 #include "ipc/ipc_channel_proxy.h" | 14 #include "ipc/ipc_channel_proxy.h" |
12 #include "ipc/message_filter.h" | 15 #include "ipc/message_filter.h" |
13 #include "media/cast/cast_sender.h" | 16 #include "media/cast/cast_sender.h" |
14 #include "media/cast/logging/logging_defines.h" | 17 #include "media/cast/logging/logging_defines.h" |
15 #include "media/cast/net/cast_transport_sender.h" | 18 #include "media/cast/net/cast_transport_sender.h" |
16 | 19 |
17 class CastTransportSenderIPC; | 20 class CastTransportSenderIPC; |
18 | 21 |
19 // This dispatcher listens to incoming IPC messages and sends | 22 // This dispatcher listens to incoming IPC messages and sends |
20 // the call to the correct CastTransportSenderIPC instance. | 23 // the call to the correct CastTransportSenderIPC instance. |
21 class CastIPCDispatcher : public IPC::MessageFilter { | 24 class CastIPCDispatcher : public IPC::MessageFilter { |
22 public: | 25 public: |
23 explicit CastIPCDispatcher( | 26 explicit CastIPCDispatcher( |
24 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
25 | 28 |
26 static CastIPCDispatcher* Get(); | 29 static CastIPCDispatcher* Get(); |
27 void Send(IPC::Message* message); | 30 void Send(IPC::Message* message); |
28 int32 AddSender(CastTransportSenderIPC* sender); | 31 int32_t AddSender(CastTransportSenderIPC* sender); |
29 void RemoveSender(int32 channel_id); | 32 void RemoveSender(int32_t channel_id); |
30 | 33 |
31 // IPC::MessageFilter implementation | 34 // IPC::MessageFilter implementation |
32 bool OnMessageReceived(const IPC::Message& message) override; | 35 bool OnMessageReceived(const IPC::Message& message) override; |
33 void OnFilterAdded(IPC::Sender* sender) override; | 36 void OnFilterAdded(IPC::Sender* sender) override; |
34 void OnFilterRemoved() override; | 37 void OnFilterRemoved() override; |
35 void OnChannelClosing() override; | 38 void OnChannelClosing() override; |
36 | 39 |
37 protected: | 40 protected: |
38 ~CastIPCDispatcher() override; | 41 ~CastIPCDispatcher() override; |
39 | 42 |
40 private: | 43 private: |
41 void OnNotifyStatusChange( | 44 void OnNotifyStatusChange(int32_t channel_id, |
42 int32 channel_id, | 45 media::cast::CastTransportStatus status); |
43 media::cast::CastTransportStatus status); | 46 void OnRtpStatistics(int32_t channel_id, |
44 void OnRtpStatistics( | 47 bool audio, |
45 int32 channel_id, | 48 const media::cast::RtcpSenderInfo& sender_info, |
46 bool audio, | 49 base::TimeTicks time_sent, |
47 const media::cast::RtcpSenderInfo& sender_info, | 50 uint32_t rtp_timestamp); |
48 base::TimeTicks time_sent, | 51 void OnRawEvents(int32_t channel_id, |
49 uint32 rtp_timestamp); | |
50 void OnRawEvents(int32 channel_id, | |
51 const std::vector<media::cast::PacketEvent>& packet_events, | 52 const std::vector<media::cast::PacketEvent>& packet_events, |
52 const std::vector<media::cast::FrameEvent>& frame_events); | 53 const std::vector<media::cast::FrameEvent>& frame_events); |
53 void OnRtt(int32 channel_id, uint32 ssrc, base::TimeDelta rtt); | 54 void OnRtt(int32_t channel_id, uint32_t ssrc, base::TimeDelta rtt); |
54 void OnRtcpCastMessage(int32 channel_id, | 55 void OnRtcpCastMessage(int32_t channel_id, |
55 uint32 ssrc, | 56 uint32_t ssrc, |
56 const media::cast::RtcpCastMessage& cast_message); | 57 const media::cast::RtcpCastMessage& cast_message); |
57 void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet); | 58 void OnReceivedPacket(int32_t channel_id, const media::cast::Packet& packet); |
58 | 59 |
59 static CastIPCDispatcher* global_instance_; | 60 static CastIPCDispatcher* global_instance_; |
60 | 61 |
61 // For IPC Send(); must only be accesed on |io_message_loop_|. | 62 // For IPC Send(); must only be accesed on |io_message_loop_|. |
62 IPC::Sender* sender_; | 63 IPC::Sender* sender_; |
63 | 64 |
64 // Task runner on which IPC calls are driven. | 65 // Task runner on which IPC calls are driven. |
65 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 66 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
66 | 67 |
67 // A map of stream ids to delegates; must only be accessed on | 68 // A map of stream ids to delegates; must only be accessed on |
68 // |io_message_loop_|. | 69 // |io_message_loop_|. |
69 IDMap<CastTransportSenderIPC> id_map_; | 70 IDMap<CastTransportSenderIPC> id_map_; |
70 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); | 71 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); |
71 }; | 72 }; |
72 | 73 |
73 #endif // CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ | 74 #endif // CHROME_RENDERER_MEDIA_CAST_IPC_DISPATCHER_H_ |
OLD | NEW |