| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 CastTransportSenderIPC::~CastTransportSenderIPC() { | 38 CastTransportSenderIPC::~CastTransportSenderIPC() { |
| 39 Send(new CastHostMsg_Delete(channel_id_)); | 39 Send(new CastHostMsg_Delete(channel_id_)); |
| 40 if (CastIPCDispatcher::Get()) { | 40 if (CastIPCDispatcher::Get()) { |
| 41 CastIPCDispatcher::Get()->RemoveSender(channel_id_); | 41 CastIPCDispatcher::Get()->RemoveSender(channel_id_); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 void CastTransportSenderIPC::InitializeAudio( | 45 void CastTransportSenderIPC::InitializeAudio( |
| 46 const media::cast::CastTransportRtpConfig& config, | 46 const media::cast::CastTransportRtpConfig& config, |
| 47 const media::cast::RtcpCastMessageCallback& cast_message_cb, | 47 const media::cast::RtcpCastMessageCallback& cast_message_cb, |
| 48 const media::cast::RtcpRttCallback& rtt_cb) { | 48 const media::cast::RtcpRttCallback& rtt_cb, |
| 49 const media::cast::RtcpPliCallback& pli_cb) { |
| 49 clients_[config.ssrc].cast_message_cb = cast_message_cb; | 50 clients_[config.ssrc].cast_message_cb = cast_message_cb; |
| 50 clients_[config.ssrc].rtt_cb = rtt_cb; | 51 clients_[config.ssrc].rtt_cb = rtt_cb; |
| 52 clients_[config.ssrc].pli_cb = pli_cb; |
| 51 Send(new CastHostMsg_InitializeAudio(channel_id_, config)); | 53 Send(new CastHostMsg_InitializeAudio(channel_id_, config)); |
| 52 } | 54 } |
| 53 | 55 |
| 54 void CastTransportSenderIPC::InitializeVideo( | 56 void CastTransportSenderIPC::InitializeVideo( |
| 55 const media::cast::CastTransportRtpConfig& config, | 57 const media::cast::CastTransportRtpConfig& config, |
| 56 const media::cast::RtcpCastMessageCallback& cast_message_cb, | 58 const media::cast::RtcpCastMessageCallback& cast_message_cb, |
| 57 const media::cast::RtcpRttCallback& rtt_cb) { | 59 const media::cast::RtcpRttCallback& rtt_cb, |
| 60 const media::cast::RtcpPliCallback& pli_cb) { |
| 58 clients_[config.ssrc].cast_message_cb = cast_message_cb; | 61 clients_[config.ssrc].cast_message_cb = cast_message_cb; |
| 59 clients_[config.ssrc].rtt_cb = rtt_cb; | 62 clients_[config.ssrc].rtt_cb = rtt_cb; |
| 63 clients_[config.ssrc].pli_cb = pli_cb; |
| 60 Send(new CastHostMsg_InitializeVideo(channel_id_, config)); | 64 Send(new CastHostMsg_InitializeVideo(channel_id_, config)); |
| 61 } | 65 } |
| 62 | 66 |
| 63 void CastTransportSenderIPC::InsertFrame( | 67 void CastTransportSenderIPC::InsertFrame( |
| 64 uint32_t ssrc, | 68 uint32_t ssrc, |
| 65 const media::cast::EncodedFrame& frame) { | 69 const media::cast::EncodedFrame& frame) { |
| 66 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame)); | 70 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame)); |
| 67 } | 71 } |
| 68 | 72 |
| 69 void CastTransportSenderIPC::SendSenderReport( | 73 void CastTransportSenderIPC::SendSenderReport( |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 ClientMap::iterator it = clients_.find(ssrc); | 179 ClientMap::iterator it = clients_.find(ssrc); |
| 176 if (it == clients_.end()) { | 180 if (it == clients_.end()) { |
| 177 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc; | 181 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc; |
| 178 return; | 182 return; |
| 179 } | 183 } |
| 180 if (it->second.cast_message_cb.is_null()) | 184 if (it->second.cast_message_cb.is_null()) |
| 181 return; | 185 return; |
| 182 it->second.cast_message_cb.Run(cast_message); | 186 it->second.cast_message_cb.Run(cast_message); |
| 183 } | 187 } |
| 184 | 188 |
| 189 void CastTransportSenderIPC::OnReceivedPli(uint32_t ssrc) { |
| 190 ClientMap::iterator it = clients_.find(ssrc); |
| 191 if (it == clients_.end()) { |
| 192 LOG(ERROR) << "Received picture loss indicator from for unknown SSRC: " |
| 193 << ssrc; |
| 194 return; |
| 195 } |
| 196 if (!it->second.pli_cb.is_null()) |
| 197 it->second.pli_cb.Run(); |
| 198 } |
| 199 |
| 185 void CastTransportSenderIPC::OnReceivedPacket( | 200 void CastTransportSenderIPC::OnReceivedPacket( |
| 186 const media::cast::Packet& packet) { | 201 const media::cast::Packet& packet) { |
| 187 if (!packet_callback_.is_null()) { | 202 if (!packet_callback_.is_null()) { |
| 188 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? | 203 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? |
| 189 scoped_ptr<media::cast::Packet> packet_copy( | 204 scoped_ptr<media::cast::Packet> packet_copy( |
| 190 new media::cast::Packet(packet)); | 205 new media::cast::Packet(packet)); |
| 191 packet_callback_.Run(std::move(packet_copy)); | 206 packet_callback_.Run(std::move(packet_copy)); |
| 192 } else { | 207 } else { |
| 193 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; | 208 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; |
| 194 } | 209 } |
| 195 } | 210 } |
| 196 | 211 |
| 197 void CastTransportSenderIPC::Send(IPC::Message* message) { | 212 void CastTransportSenderIPC::Send(IPC::Message* message) { |
| 198 if (CastIPCDispatcher::Get()) { | 213 if (CastIPCDispatcher::Get()) { |
| 199 CastIPCDispatcher::Get()->Send(message); | 214 CastIPCDispatcher::Get()->Send(message); |
| 200 } else { | 215 } else { |
| 201 delete message; | 216 delete message; |
| 202 } | 217 } |
| 203 } | 218 } |
| OLD | NEW |