| 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 29 matching lines...) Expand all Loading... |
| 40 CastTransportSenderIPC::~CastTransportSenderIPC() { | 40 CastTransportSenderIPC::~CastTransportSenderIPC() { |
| 41 Send(new CastHostMsg_Delete(channel_id_)); | 41 Send(new CastHostMsg_Delete(channel_id_)); |
| 42 if (CastIPCDispatcher::Get()) { | 42 if (CastIPCDispatcher::Get()) { |
| 43 CastIPCDispatcher::Get()->RemoveSender(channel_id_); | 43 CastIPCDispatcher::Get()->RemoveSender(channel_id_); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CastTransportSenderIPC::InitializeAudio( | 47 void CastTransportSenderIPC::InitializeAudio( |
| 48 const media::cast::CastTransportRtpConfig& config, | 48 const media::cast::CastTransportRtpConfig& config, |
| 49 const media::cast::RtcpCastMessageCallback& cast_message_cb, | 49 const media::cast::RtcpCastMessageCallback& cast_message_cb, |
| 50 const media::cast::RtcpRttCallback& rtt_cb) { | 50 const media::cast::RtcpRttCallback& rtt_cb, |
| 51 const media::cast::RtcpPliCallback& pli_cb) { |
| 51 clients_[config.ssrc].cast_message_cb = cast_message_cb; | 52 clients_[config.ssrc].cast_message_cb = cast_message_cb; |
| 52 clients_[config.ssrc].rtt_cb = rtt_cb; | 53 clients_[config.ssrc].rtt_cb = rtt_cb; |
| 54 clients_[config.ssrc].pli_cb = pli_cb; |
| 53 Send(new CastHostMsg_InitializeAudio(channel_id_, config)); | 55 Send(new CastHostMsg_InitializeAudio(channel_id_, config)); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void CastTransportSenderIPC::InitializeVideo( | 58 void CastTransportSenderIPC::InitializeVideo( |
| 57 const media::cast::CastTransportRtpConfig& config, | 59 const media::cast::CastTransportRtpConfig& config, |
| 58 const media::cast::RtcpCastMessageCallback& cast_message_cb, | 60 const media::cast::RtcpCastMessageCallback& cast_message_cb, |
| 59 const media::cast::RtcpRttCallback& rtt_cb) { | 61 const media::cast::RtcpRttCallback& rtt_cb, |
| 62 const media::cast::RtcpPliCallback& pli_cb) { |
| 60 clients_[config.ssrc].cast_message_cb = cast_message_cb; | 63 clients_[config.ssrc].cast_message_cb = cast_message_cb; |
| 61 clients_[config.ssrc].rtt_cb = rtt_cb; | 64 clients_[config.ssrc].rtt_cb = rtt_cb; |
| 65 clients_[config.ssrc].pli_cb = pli_cb; |
| 62 Send(new CastHostMsg_InitializeVideo(channel_id_, config)); | 66 Send(new CastHostMsg_InitializeVideo(channel_id_, config)); |
| 63 } | 67 } |
| 64 | 68 |
| 65 void CastTransportSenderIPC::InsertFrame( | 69 void CastTransportSenderIPC::InsertFrame( |
| 66 uint32_t ssrc, | 70 uint32_t ssrc, |
| 67 const media::cast::EncodedFrame& frame) { | 71 const media::cast::EncodedFrame& frame) { |
| 68 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame)); | 72 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame)); |
| 69 } | 73 } |
| 70 | 74 |
| 71 void CastTransportSenderIPC::SendSenderReport( | 75 void CastTransportSenderIPC::SendSenderReport( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 channel_id_, rtp_receiver_ssrc, time_data)); | 110 channel_id_, rtp_receiver_ssrc, time_data)); |
| 107 } | 111 } |
| 108 | 112 |
| 109 void CastTransportSenderIPC::AddCastFeedback( | 113 void CastTransportSenderIPC::AddCastFeedback( |
| 110 const media::cast::RtcpCastMessage& cast_message, | 114 const media::cast::RtcpCastMessage& cast_message, |
| 111 base::TimeDelta target_delay) { | 115 base::TimeDelta target_delay) { |
| 112 Send( | 116 Send( |
| 113 new CastHostMsg_AddCastFeedback(channel_id_, cast_message, target_delay)); | 117 new CastHostMsg_AddCastFeedback(channel_id_, cast_message, target_delay)); |
| 114 } | 118 } |
| 115 | 119 |
| 120 void CastTransportSenderIPC::AddPli( |
| 121 const media::cast::RtcpPliMessage& pli_message) { |
| 122 Send(new CastHostMsg_AddPli(channel_id_, pli_message)); |
| 123 } |
| 124 |
| 116 void CastTransportSenderIPC::AddRtcpEvents( | 125 void CastTransportSenderIPC::AddRtcpEvents( |
| 117 const media::cast::ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) { | 126 const media::cast::ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) { |
| 118 Send(new CastHostMsg_AddRtcpEvents(channel_id_, rtcp_events)); | 127 Send(new CastHostMsg_AddRtcpEvents(channel_id_, rtcp_events)); |
| 119 } | 128 } |
| 120 | 129 |
| 121 void CastTransportSenderIPC::AddRtpReceiverReport( | 130 void CastTransportSenderIPC::AddRtpReceiverReport( |
| 122 const media::cast::RtcpReportBlock& rtp_receiver_report_block) { | 131 const media::cast::RtcpReportBlock& rtp_receiver_report_block) { |
| 123 Send(new CastHostMsg_AddRtpReceiverReport(channel_id_, | 132 Send(new CastHostMsg_AddRtpReceiverReport(channel_id_, |
| 124 rtp_receiver_report_block)); | 133 rtp_receiver_report_block)); |
| 125 } | 134 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 taken_frame_events->swap( | 153 taken_frame_events->swap( |
| 145 const_cast<std::vector<media::cast::FrameEvent>&>(frame_events)); | 154 const_cast<std::vector<media::cast::FrameEvent>&>(frame_events)); |
| 146 scoped_ptr<std::vector<media::cast::PacketEvent>> taken_packet_events( | 155 scoped_ptr<std::vector<media::cast::PacketEvent>> taken_packet_events( |
| 147 new std::vector<media::cast::PacketEvent>()); | 156 new std::vector<media::cast::PacketEvent>()); |
| 148 taken_packet_events->swap( | 157 taken_packet_events->swap( |
| 149 const_cast<std::vector<media::cast::PacketEvent>&>(packet_events)); | 158 const_cast<std::vector<media::cast::PacketEvent>&>(packet_events)); |
| 150 raw_events_callback_.Run(std::move(taken_frame_events), | 159 raw_events_callback_.Run(std::move(taken_frame_events), |
| 151 std::move(taken_packet_events)); | 160 std::move(taken_packet_events)); |
| 152 } | 161 } |
| 153 | 162 |
| 154 void CastTransportSenderIPC::OnRtt(uint32_t ssrc, base::TimeDelta rtt) { | 163 void CastTransportSenderIPC::OnRtt(uint32_t rtp_sender_ssrc, |
| 155 ClientMap::iterator it = clients_.find(ssrc); | 164 base::TimeDelta rtt) { |
| 165 ClientMap::iterator it = clients_.find(rtp_sender_ssrc); |
| 156 if (it == clients_.end()) { | 166 if (it == clients_.end()) { |
| 157 LOG(ERROR) << "Received RTT report from for unknown SSRC: " << ssrc; | 167 LOG(ERROR) << "Received RTT report for unknown SSRC: " << rtp_sender_ssrc; |
| 158 return; | 168 return; |
| 159 } | 169 } |
| 160 if (!it->second.rtt_cb.is_null()) | 170 if (!it->second.rtt_cb.is_null()) |
| 161 it->second.rtt_cb.Run(rtt); | 171 it->second.rtt_cb.Run(rtt); |
| 162 } | 172 } |
| 163 | 173 |
| 164 void CastTransportSenderIPC::OnRtcpCastMessage( | 174 void CastTransportSenderIPC::OnRtcpCastMessage( |
| 165 uint32_t ssrc, | 175 uint32_t rtp_sender_ssrc, |
| 166 const media::cast::RtcpCastMessage& cast_message) { | 176 const media::cast::RtcpCastMessage& cast_message) { |
| 167 ClientMap::iterator it = clients_.find(ssrc); | 177 ClientMap::iterator it = clients_.find(rtp_sender_ssrc); |
| 168 if (it == clients_.end()) { | 178 if (it == clients_.end()) { |
| 169 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc; | 179 LOG(ERROR) << "Received cast message for unknown SSRC: " << rtp_sender_ssrc; |
| 170 return; | 180 return; |
| 171 } | 181 } |
| 172 if (it->second.cast_message_cb.is_null()) | 182 if (it->second.cast_message_cb.is_null()) |
| 173 return; | 183 return; |
| 174 it->second.cast_message_cb.Run(cast_message); | 184 it->second.cast_message_cb.Run(cast_message); |
| 175 } | 185 } |
| 176 | 186 |
| 187 void CastTransportSenderIPC::OnReceivedPli(uint32_t rtp_sender_ssrc) { |
| 188 ClientMap::iterator it = clients_.find(rtp_sender_ssrc); |
| 189 if (it == clients_.end()) { |
| 190 LOG(ERROR) << "Received picture loss indicator for unknown SSRC: " |
| 191 << rtp_sender_ssrc; |
| 192 return; |
| 193 } |
| 194 if (!it->second.pli_cb.is_null()) |
| 195 it->second.pli_cb.Run(); |
| 196 } |
| 197 |
| 177 void CastTransportSenderIPC::OnReceivedPacket( | 198 void CastTransportSenderIPC::OnReceivedPacket( |
| 178 const media::cast::Packet& packet) { | 199 const media::cast::Packet& packet) { |
| 179 if (!packet_callback_.is_null()) { | 200 if (!packet_callback_.is_null()) { |
| 180 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? | 201 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? |
| 181 scoped_ptr<media::cast::Packet> packet_copy( | 202 scoped_ptr<media::cast::Packet> packet_copy( |
| 182 new media::cast::Packet(packet)); | 203 new media::cast::Packet(packet)); |
| 183 packet_callback_.Run(std::move(packet_copy)); | 204 packet_callback_.Run(std::move(packet_copy)); |
| 184 } else { | 205 } else { |
| 185 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; | 206 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; |
| 186 } | 207 } |
| 187 } | 208 } |
| 188 | 209 |
| 189 void CastTransportSenderIPC::Send(IPC::Message* message) { | 210 void CastTransportSenderIPC::Send(IPC::Message* message) { |
| 190 if (CastIPCDispatcher::Get()) { | 211 if (CastIPCDispatcher::Get()) { |
| 191 CastIPCDispatcher::Get()->Send(message); | 212 CastIPCDispatcher::Get()->Send(message); |
| 192 } else { | 213 } else { |
| 193 delete message; | 214 delete message; |
| 194 } | 215 } |
| 195 } | 216 } |
| OLD | NEW |