| 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/browser/media/cast_transport_host_filter.h" | 5 #include "chrome/browser/media/cast_transport_host_filter.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/common/cast_messages.h" | 12 #include "chrome/common/cast_messages.h" |
| 11 #include "components/net_log/chrome_net_log.h" | 13 #include "components/net_log/chrome_net_log.h" |
| 12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 13 #include "device/power_save_blocker/power_save_blocker.h" | 15 #include "device/power_save_blocker/power_save_blocker.h" |
| 14 #include "media/cast/net/cast_transport.h" | 16 #include "media/cast/net/cast_transport.h" |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 local_end_point, remote_end_point, | 171 local_end_point, remote_end_point, |
| 170 base::Bind(&CastTransportHostFilter::OnStatusChanged, | 172 base::Bind(&CastTransportHostFilter::OnStatusChanged, |
| 171 weak_factory_.GetWeakPtr(), channel_id))); | 173 weak_factory_.GetWeakPtr(), channel_id))); |
| 172 udp_transport->SetUdpOptions(options); | 174 udp_transport->SetUdpOptions(options); |
| 173 std::unique_ptr<media::cast::CastTransport> transport = | 175 std::unique_ptr<media::cast::CastTransport> transport = |
| 174 media::cast::CastTransport::Create( | 176 media::cast::CastTransport::Create( |
| 175 &clock_, kSendEventsInterval, | 177 &clock_, kSendEventsInterval, |
| 176 base::MakeUnique<TransportClient>(channel_id, this), | 178 base::MakeUnique<TransportClient>(channel_id, this), |
| 177 std::move(udp_transport), base::ThreadTaskRunnerHandle::Get()); | 179 std::move(udp_transport), base::ThreadTaskRunnerHandle::Get()); |
| 178 transport->SetOptions(options); | 180 transport->SetOptions(options); |
| 179 id_map_.AddWithID(transport.release(), channel_id); | 181 id_map_.AddWithID(std::move(transport), channel_id); |
| 180 } | 182 } |
| 181 | 183 |
| 182 void CastTransportHostFilter::OnDelete(int32_t channel_id) { | 184 void CastTransportHostFilter::OnDelete(int32_t channel_id) { |
| 183 media::cast::CastTransport* transport = id_map_.Lookup(channel_id); | 185 media::cast::CastTransport* transport = id_map_.Lookup(channel_id); |
| 184 if (transport) { | 186 if (transport) { |
| 185 id_map_.Remove(channel_id); | 187 id_map_.Remove(channel_id); |
| 186 } else { | 188 } else { |
| 187 DVLOG(1) << "CastTransportHostFilter::Delete called " | 189 DVLOG(1) << "CastTransportHostFilter::Delete called " |
| 188 << "on non-existing channel"; | 190 << "on non-existing channel"; |
| 189 } | 191 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 208 | 210 |
| 209 void CastTransportHostFilter::OnInitializeStream( | 211 void CastTransportHostFilter::OnInitializeStream( |
| 210 int32_t channel_id, | 212 int32_t channel_id, |
| 211 const media::cast::CastTransportRtpConfig& config) { | 213 const media::cast::CastTransportRtpConfig& config) { |
| 212 media::cast::CastTransport* transport = id_map_.Lookup(channel_id); | 214 media::cast::CastTransport* transport = id_map_.Lookup(channel_id); |
| 213 if (transport) { | 215 if (transport) { |
| 214 if (config.rtp_payload_type == media::cast::RtpPayloadType::REMOTE_AUDIO || | 216 if (config.rtp_payload_type == media::cast::RtpPayloadType::REMOTE_AUDIO || |
| 215 config.rtp_payload_type == media::cast::RtpPayloadType::REMOTE_VIDEO) { | 217 config.rtp_payload_type == media::cast::RtpPayloadType::REMOTE_VIDEO) { |
| 216 // Create CastRemotingSender for this RTP stream. | 218 // Create CastRemotingSender for this RTP stream. |
| 217 remoting_sender_map_.AddWithID( | 219 remoting_sender_map_.AddWithID( |
| 218 new CastRemotingSender( | 220 base::MakeUnique<CastRemotingSender>( |
| 219 transport, config, kSendEventsInterval, | 221 transport, config, kSendEventsInterval, |
| 220 base::Bind(&CastTransportHostFilter::OnCastRemotingSenderEvents, | 222 base::Bind(&CastTransportHostFilter::OnCastRemotingSenderEvents, |
| 221 weak_factory_.GetWeakPtr(), channel_id)), | 223 weak_factory_.GetWeakPtr(), channel_id)), |
| 222 config.rtp_stream_id); | 224 config.rtp_stream_id); |
| 223 DVLOG(3) << "Create CastRemotingSender for stream: " | 225 DVLOG(3) << "Create CastRemotingSender for stream: " |
| 224 << config.rtp_stream_id; | 226 << config.rtp_stream_id; |
| 225 | 227 |
| 226 stream_id_map_.insert(std::make_pair(channel_id, config.rtp_stream_id)); | 228 stream_id_map_.insert(std::make_pair(channel_id, config.rtp_stream_id)); |
| 227 } else { | 229 } else { |
| 228 transport->InitializeStream( | 230 transport->InitializeStream( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 const std::vector<media::cast::FrameEvent>& events) { | 384 const std::vector<media::cast::FrameEvent>& events) { |
| 383 if (events.empty()) | 385 if (events.empty()) |
| 384 return; | 386 return; |
| 385 // PacketEvents can only come from CastTransport via CastTransport::Client | 387 // PacketEvents can only come from CastTransport via CastTransport::Client |
| 386 // interface. | 388 // interface. |
| 387 Send(new CastMsg_RawEvents(channel_id, | 389 Send(new CastMsg_RawEvents(channel_id, |
| 388 std::vector<media::cast::PacketEvent>(), events)); | 390 std::vector<media::cast::PacketEvent>(), events)); |
| 389 } | 391 } |
| 390 | 392 |
| 391 } // namespace cast | 393 } // namespace cast |
| OLD | NEW |