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 #include "chrome/renderer/media/cast_ipc_dispatcher.h" | 5 #include "chrome/renderer/media/cast_ipc_dispatcher.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "chrome/common/cast_messages.h" | 8 #include "chrome/common/cast_messages.h" |
9 #include "chrome/renderer/media/cast_transport_sender_ipc.h" | 9 #include "chrome/renderer/media/cast_transport_sender_ipc.h" |
10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 void CastIPCDispatcher::Send(IPC::Message* message) { | 31 void CastIPCDispatcher::Send(IPC::Message* message) { |
32 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 32 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
33 if (sender_) { | 33 if (sender_) { |
34 sender_->Send(message); | 34 sender_->Send(message); |
35 } else { | 35 } else { |
36 delete message; | 36 delete message; |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 int32 CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) { | 40 int32_t CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) { |
41 return id_map_.Add(sender); | 41 return id_map_.Add(sender); |
42 } | 42 } |
43 | 43 |
44 void CastIPCDispatcher::RemoveSender(int32 channel_id) { | 44 void CastIPCDispatcher::RemoveSender(int32_t channel_id) { |
45 return id_map_.Remove(channel_id); | 45 return id_map_.Remove(channel_id); |
46 } | 46 } |
47 | 47 |
48 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { | 48 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { |
49 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 49 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
50 bool handled = true; | 50 bool handled = true; |
51 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) | 51 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) |
52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) | 52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) |
53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) | 53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) |
54 IPC_MESSAGE_HANDLER(CastMsg_Rtt, OnRtt) | 54 IPC_MESSAGE_HANDLER(CastMsg_Rtt, OnRtt) |
(...skipping 17 matching lines...) Expand all Loading... |
72 global_instance_ = NULL; | 72 global_instance_ = NULL; |
73 sender_ = NULL; | 73 sender_ = NULL; |
74 } | 74 } |
75 | 75 |
76 void CastIPCDispatcher::OnChannelClosing() { | 76 void CastIPCDispatcher::OnChannelClosing() { |
77 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 77 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
78 DCHECK_EQ(this, global_instance_); | 78 DCHECK_EQ(this, global_instance_); |
79 } | 79 } |
80 | 80 |
81 void CastIPCDispatcher::OnNotifyStatusChange( | 81 void CastIPCDispatcher::OnNotifyStatusChange( |
82 int32 channel_id, | 82 int32_t channel_id, |
83 media::cast::CastTransportStatus status) { | 83 media::cast::CastTransportStatus status) { |
84 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 84 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
85 if (sender) { | 85 if (sender) { |
86 sender->OnNotifyStatusChange(status); | 86 sender->OnNotifyStatusChange(status); |
87 } else { | 87 } else { |
88 DVLOG(1) | 88 DVLOG(1) |
89 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel."; | 89 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel."; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 void CastIPCDispatcher::OnRawEvents( | 93 void CastIPCDispatcher::OnRawEvents( |
94 int32 channel_id, | 94 int32_t channel_id, |
95 const std::vector<media::cast::PacketEvent>& packet_events, | 95 const std::vector<media::cast::PacketEvent>& packet_events, |
96 const std::vector<media::cast::FrameEvent>& frame_events) { | 96 const std::vector<media::cast::FrameEvent>& frame_events) { |
97 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 97 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
98 if (sender) { | 98 if (sender) { |
99 sender->OnRawEvents(packet_events, frame_events); | 99 sender->OnRawEvents(packet_events, frame_events); |
100 } else { | 100 } else { |
101 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel."; | 101 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel."; |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 void CastIPCDispatcher::OnRtt(int32 channel_id, | 105 void CastIPCDispatcher::OnRtt(int32_t channel_id, |
106 uint32 ssrc, | 106 uint32_t ssrc, |
107 base::TimeDelta rtt) { | 107 base::TimeDelta rtt) { |
108 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 108 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
109 if (sender) { | 109 if (sender) { |
110 sender->OnRtt(ssrc, rtt); | 110 sender->OnRtt(ssrc, rtt); |
111 } else { | 111 } else { |
112 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; | 112 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 void CastIPCDispatcher::OnRtcpCastMessage( | 116 void CastIPCDispatcher::OnRtcpCastMessage( |
117 int32 channel_id, | 117 int32_t channel_id, |
118 uint32 ssrc, | 118 uint32_t ssrc, |
119 const media::cast::RtcpCastMessage& cast_message) { | 119 const media::cast::RtcpCastMessage& cast_message) { |
120 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 120 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
121 if (sender) { | 121 if (sender) { |
122 sender->OnRtcpCastMessage(ssrc, cast_message); | 122 sender->OnRtcpCastMessage(ssrc, cast_message); |
123 } else { | 123 } else { |
124 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; | 124 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 void CastIPCDispatcher::OnReceivedPacket( | 128 void CastIPCDispatcher::OnReceivedPacket(int32_t channel_id, |
129 int32 channel_id, | 129 const media::cast::Packet& packet) { |
130 const media::cast::Packet& packet) { | |
131 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 130 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
132 if (sender) { | 131 if (sender) { |
133 sender->OnReceivedPacket(packet); | 132 sender->OnReceivedPacket(packet); |
134 } else { | 133 } else { |
135 DVLOG(1) << "CastIPCDispatcher::OnReceievdPacket on non-existing channel."; | 134 DVLOG(1) << "CastIPCDispatcher::OnReceievdPacket on non-existing channel."; |
136 } | 135 } |
137 } | 136 } |
OLD | NEW |