| 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_transport_sender_ipc.h" | 5 #include "chrome/renderer/media/cast_transport_sender_ipc.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "chrome/common/cast_messages.h" | 9 #include "chrome/common/cast_messages.h" |
| 10 #include "chrome/renderer/media/cast_ipc_dispatcher.h" | 10 #include "chrome/renderer/media/cast_ipc_dispatcher.h" |
| 11 #include "ipc/ipc_channel_proxy.h" | 11 #include "ipc/ipc_channel_proxy.h" |
| 12 #include "media/cast/cast_sender.h" | 12 #include "media/cast/cast_sender.h" |
| 13 #include "media/cast/transport/cast_transport_sender.h" | 13 #include "media/cast/transport/cast_transport_sender.h" |
| 14 | 14 |
| 15 CastTransportSenderIPC::CastTransportSenderIPC( | 15 CastTransportSenderIPC::CastTransportSenderIPC( |
| 16 const media::cast::transport::CastTransportConfig& config, | 16 const media::cast::transport::CastTransportConfig& config, |
| 17 const media::cast::transport::CastTransportStatusCallback& status_cb) | 17 const media::cast::CastLoggingConfig& logging_config, |
| 18 : status_callback_(status_cb) { | 18 const media::cast::transport::CastTransportStatusCallback& status_cb, |
| 19 const media::cast::transport::BulkRawEventsCallback& raw_events_cb) |
| 20 : status_callback_(status_cb), raw_events_callback_(raw_events_cb) { |
| 19 if (CastIPCDispatcher::Get()) { | 21 if (CastIPCDispatcher::Get()) { |
| 20 channel_id_ = CastIPCDispatcher::Get()->AddSender(this); | 22 channel_id_ = CastIPCDispatcher::Get()->AddSender(this); |
| 21 } | 23 } |
| 22 Send(new CastHostMsg_New(channel_id_, config)); | 24 Send(new CastHostMsg_New(channel_id_, config, logging_config)); |
| 23 } | 25 } |
| 24 | 26 |
| 25 CastTransportSenderIPC::~CastTransportSenderIPC() { | 27 CastTransportSenderIPC::~CastTransportSenderIPC() { |
| 26 Send(new CastHostMsg_Delete(channel_id_)); | 28 Send(new CastHostMsg_Delete(channel_id_)); |
| 27 if (CastIPCDispatcher::Get()) { | 29 if (CastIPCDispatcher::Get()) { |
| 28 CastIPCDispatcher::Get()->RemoveSender(channel_id_); | 30 CastIPCDispatcher::Get()->RemoveSender(channel_id_); |
| 29 } | 31 } |
| 30 } | 32 } |
| 31 | 33 |
| 32 void CastTransportSenderIPC::SetPacketReceiver( | 34 void CastTransportSenderIPC::SetPacketReceiver( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 91 |
| 90 | 92 |
| 91 void CastTransportSenderIPC::OnReceivedPacket( | 93 void CastTransportSenderIPC::OnReceivedPacket( |
| 92 const media::cast::Packet& packet) { | 94 const media::cast::Packet& packet) { |
| 93 if (!packet_callback_.is_null()) { | 95 if (!packet_callback_.is_null()) { |
| 94 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? | 96 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? |
| 95 scoped_ptr<media::cast::transport::Packet> packet_copy( | 97 scoped_ptr<media::cast::transport::Packet> packet_copy( |
| 96 new media::cast::transport::Packet(packet)); | 98 new media::cast::transport::Packet(packet)); |
| 97 packet_callback_.Run(packet_copy.Pass()); | 99 packet_callback_.Run(packet_copy.Pass()); |
| 98 } else { | 100 } else { |
| 99 LOG(ERROR) << "CastIPCDispatcher::OnReceivedPacket " | 101 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; |
| 100 << "no packet callback yet."; | |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 void CastTransportSenderIPC::OnNotifyStatusChange( | 105 void CastTransportSenderIPC::OnNotifyStatusChange( |
| 105 media::cast::transport::CastTransportStatus status) { | 106 media::cast::transport::CastTransportStatus status) { |
| 106 status_callback_.Run(status); | 107 status_callback_.Run(status); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void CastTransportSenderIPC::OnRtpStatistics( | 110 void CastTransportSenderIPC::OnRtpStatistics( |
| 110 bool audio, | 111 bool audio, |
| 111 const media::cast::transport::RtcpSenderInfo& sender_info, | 112 const media::cast::transport::RtcpSenderInfo& sender_info, |
| 112 base::TimeTicks time_sent, | 113 base::TimeTicks time_sent, |
| 113 uint32 rtp_timestamp) { | 114 uint32 rtp_timestamp) { |
| 114 const media::cast::transport::CastTransportRtpStatistics& callback = | 115 const media::cast::transport::CastTransportRtpStatistics& callback = |
| 115 audio ? audio_rtp_callback_ : video_rtp_callback_; | 116 audio ? audio_rtp_callback_ : video_rtp_callback_; |
| 116 callback.Run(sender_info, time_sent, rtp_timestamp); | 117 callback.Run(sender_info, time_sent, rtp_timestamp); |
| 117 } | 118 } |
| 118 | 119 |
| 120 void CastTransportSenderIPC::OnRawEvents( |
| 121 const std::vector<media::cast::PacketEvent>& packet_events) { |
| 122 raw_events_callback_.Run(packet_events); |
| 123 } |
| 124 |
| 119 void CastTransportSenderIPC::Send(IPC::Message* message) { | 125 void CastTransportSenderIPC::Send(IPC::Message* message) { |
| 120 if (CastIPCDispatcher::Get()) { | 126 if (CastIPCDispatcher::Get()) { |
| 121 CastIPCDispatcher::Get()->Send(message); | 127 CastIPCDispatcher::Get()->Send(message); |
| 122 } else { | 128 } else { |
| 123 delete message; | 129 delete message; |
| 124 } | 130 } |
| 125 } | 131 } |
| OLD | NEW |