| 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 "chrome/common/cast_messages.h" | 7 #include "chrome/common/cast_messages.h" |
| 8 #include "chrome/renderer/media/cast_transport_sender_ipc.h" | 8 #include "chrome/renderer/media/cast_transport_sender_ipc.h" |
| 9 #include "ipc/ipc_message_macros.h" | 9 #include "ipc/ipc_message_macros.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 void CastIPCDispatcher::RemoveSender(int32 channel_id) { | 43 void CastIPCDispatcher::RemoveSender(int32 channel_id) { |
| 44 return id_map_.Remove(channel_id); | 44 return id_map_.Remove(channel_id); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { | 47 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { |
| 48 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 48 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 49 bool handled = true; | 49 bool handled = true; |
| 50 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) | 50 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) |
| 51 IPC_MESSAGE_HANDLER(CastMsg_ReceivedPacket, OnReceivedPacket) | |
| 52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) | 51 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) |
| 53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) | 52 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) |
| 53 IPC_MESSAGE_HANDLER(CastMsg_Rtt, OnRtt) |
| 54 IPC_MESSAGE_HANDLER(CastMsg_RtcpCastMessage, OnRtcpCastMessage) |
| 54 IPC_MESSAGE_UNHANDLED(handled = false); | 55 IPC_MESSAGE_UNHANDLED(handled = false); |
| 55 IPC_END_MESSAGE_MAP(); | 56 IPC_END_MESSAGE_MAP(); |
| 56 return handled; | 57 return handled; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void CastIPCDispatcher::OnFilterAdded(IPC::Sender* sender) { | 60 void CastIPCDispatcher::OnFilterAdded(IPC::Sender* sender) { |
| 60 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 61 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 61 DCHECK(!global_instance_); | 62 DCHECK(!global_instance_); |
| 62 global_instance_ = this; | 63 global_instance_ = this; |
| 63 sender_ = sender; | 64 sender_ = sender; |
| 64 } | 65 } |
| 65 | 66 |
| 66 void CastIPCDispatcher::OnFilterRemoved() { | 67 void CastIPCDispatcher::OnFilterRemoved() { |
| 67 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 68 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 68 DCHECK_EQ(this, global_instance_); | 69 DCHECK_EQ(this, global_instance_); |
| 69 global_instance_ = NULL; | 70 global_instance_ = NULL; |
| 70 sender_ = NULL; | 71 sender_ = NULL; |
| 71 } | 72 } |
| 72 | 73 |
| 73 void CastIPCDispatcher::OnChannelClosing() { | 74 void CastIPCDispatcher::OnChannelClosing() { |
| 74 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 75 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 75 DCHECK_EQ(this, global_instance_); | 76 DCHECK_EQ(this, global_instance_); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void CastIPCDispatcher::OnReceivedPacket( | |
| 79 int32 channel_id, | |
| 80 const media::cast::Packet& packet) { | |
| 81 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | |
| 82 if (sender) { | |
| 83 sender->OnReceivedPacket(packet); | |
| 84 } else { | |
| 85 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket " | |
| 86 << "on non-existing channel."; | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 void CastIPCDispatcher::OnNotifyStatusChange( | 79 void CastIPCDispatcher::OnNotifyStatusChange( |
| 91 int32 channel_id, | 80 int32 channel_id, |
| 92 media::cast::CastTransportStatus status) { | 81 media::cast::CastTransportStatus status) { |
| 93 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 82 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
| 94 if (sender) { | 83 if (sender) { |
| 95 sender->OnNotifyStatusChange(status); | 84 sender->OnNotifyStatusChange(status); |
| 96 } else { | 85 } else { |
| 97 DVLOG(1) | 86 DVLOG(1) |
| 98 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel."; | 87 << "CastIPCDispatcher::OnNotifystatusChange on non-existing channel."; |
| 99 } | 88 } |
| 100 } | 89 } |
| 101 | 90 |
| 102 void CastIPCDispatcher::OnRawEvents( | 91 void CastIPCDispatcher::OnRawEvents( |
| 103 int32 channel_id, | 92 int32 channel_id, |
| 104 const std::vector<media::cast::PacketEvent>& packet_events) { | 93 const std::vector<media::cast::PacketEvent>& packet_events, |
| 94 const std::vector<media::cast::FrameEvent>& frame_events) { |
| 105 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); | 95 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
| 106 if (sender) { | 96 if (sender) { |
| 107 sender->OnRawEvents(packet_events); | 97 sender->OnRawEvents(packet_events, frame_events); |
| 108 } else { | 98 } else { |
| 109 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel."; | 99 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel."; |
| 110 } | 100 } |
| 111 } | 101 } |
| 102 |
| 103 void CastIPCDispatcher::OnRtt(int32 channel_id, |
| 104 uint32 ssrc, |
| 105 const media::cast::RtcpRttReport& rtt_report) { |
| 106 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
| 107 if (sender) { |
| 108 sender->OnRtt(ssrc, rtt_report); |
| 109 } else { |
| 110 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; |
| 111 } |
| 112 } |
| 113 |
| 114 void CastIPCDispatcher::OnRtcpCastMessage( |
| 115 int32 channel_id, |
| 116 uint32 ssrc, |
| 117 const media::cast::RtcpCastMessage& cast_message) { |
| 118 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); |
| 119 if (sender) { |
| 120 sender->OnRtcpCastMessage(ssrc, cast_message); |
| 121 } else { |
| 122 DVLOG(1) << "CastIPCDispatcher::OnRtt on non-existing channel."; |
| 123 } |
| 124 } |
| OLD | NEW |