Chromium Code Reviews| 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 "media/cast/net/cast_transport_sender_impl.h" | 5 #include "media/cast/net/cast_transport_sender_impl.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "media/cast/net/cast_transport_defines.h" | 9 #include "media/cast/net/cast_transport_defines.h" |
| 10 #include "media/cast/net/udp_transport.h" | 10 #include "media/cast/net/udp_transport.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 int32 max_burst_size = | 44 int32 max_burst_size = |
| 45 LookupOptionWithDefault(options, kOptionPacerMaxBurstSize, | 45 LookupOptionWithDefault(options, kOptionPacerMaxBurstSize, |
| 46 kMaxBurstSize) * kMaxIpPacketSize; | 46 kMaxBurstSize) * kMaxIpPacketSize; |
| 47 int32 min_send_buffer_size = | 47 int32 min_send_buffer_size = |
| 48 LookupOptionWithDefault(options, kOptionSendBufferMinSize, 0); | 48 LookupOptionWithDefault(options, kOptionSendBufferMinSize, 0); |
| 49 return std::max(max_burst_size, min_send_buffer_size); | 49 return std::max(max_burst_size, min_send_buffer_size); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 CastTransportSender::CreateParams::CreateParams( | |
| 55 net::NetLog* log, | |
| 56 base::TickClock* input_clock, | |
| 57 net::IPEndPoint local_addr, | |
| 58 net::IPEndPoint remote_addr, | |
| 59 scoped_ptr<Client> transport_client, | |
| 60 base::TimeDelta transport_logging_flush_interval, | |
| 61 scoped_ptr<base::DictionaryValue> options, | |
| 62 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | |
| 63 : net_log(log), | |
| 64 clock(input_clock), | |
| 65 local_end_point(local_addr), | |
| 66 remote_end_point(remote_addr), | |
| 67 client(transport_client.Pass()), | |
| 68 logging_flush_interval(transport_logging_flush_interval), | |
| 69 optional_config(options.Pass()), | |
| 70 transport_task_runner(task_runner) {} | |
| 71 | |
| 72 CastTransportSender::CreateParams::~CreateParams() {} | |
| 73 | |
| 74 CastTransportSender::Client::~Client() {} | |
|
imcheng
2015/12/17 00:18:11
Can this be inlined into cast_transport_sender.h?
xjz
2015/12/17 22:54:58
Done.
| |
| 75 | |
| 54 scoped_ptr<CastTransportSender> CastTransportSender::Create( | 76 scoped_ptr<CastTransportSender> CastTransportSender::Create( |
| 55 net::NetLog* net_log, | 77 const CreateParams& params) { |
| 56 base::TickClock* clock, | |
| 57 const net::IPEndPoint& local_end_point, | |
| 58 const net::IPEndPoint& remote_end_point, | |
| 59 scoped_ptr<base::DictionaryValue> options, | |
| 60 const CastTransportStatusCallback& status_callback, | |
| 61 const BulkRawEventsCallback& raw_events_callback, | |
| 62 base::TimeDelta raw_events_callback_interval, | |
| 63 const PacketReceiverCallback& packet_callback, | |
| 64 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner) { | |
| 65 return scoped_ptr<CastTransportSender>( | 78 return scoped_ptr<CastTransportSender>( |
| 66 new CastTransportSenderImpl(net_log, | 79 new CastTransportSenderImpl(params, nullptr)); |
| 67 clock, | |
| 68 local_end_point, | |
| 69 remote_end_point, | |
| 70 options.Pass(), | |
| 71 status_callback, | |
| 72 raw_events_callback, | |
| 73 raw_events_callback_interval, | |
| 74 transport_task_runner.get(), | |
| 75 packet_callback, | |
| 76 NULL)); | |
| 77 } | 80 } |
| 78 | 81 |
| 79 PacketReceiverCallback CastTransportSender::PacketReceiverForTesting() { | 82 PacketReceiverCallback CastTransportSender::PacketReceiverForTesting() { |
| 80 return PacketReceiverCallback(); | 83 return PacketReceiverCallback(); |
| 81 } | 84 } |
| 82 | 85 |
| 83 CastTransportSenderImpl::CastTransportSenderImpl( | 86 CastTransportSenderImpl::CastTransportSenderImpl( |
| 84 net::NetLog* net_log, | 87 const CreateParams& params, |
| 85 base::TickClock* clock, | |
| 86 const net::IPEndPoint& local_end_point, | |
| 87 const net::IPEndPoint& remote_end_point, | |
| 88 scoped_ptr<base::DictionaryValue> options, | |
| 89 const CastTransportStatusCallback& status_callback, | |
| 90 const BulkRawEventsCallback& raw_events_callback, | |
| 91 base::TimeDelta raw_events_callback_interval, | |
| 92 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, | |
| 93 const PacketReceiverCallback& packet_callback, | |
| 94 PacketSender* external_transport) | 88 PacketSender* external_transport) |
| 95 : clock_(clock), | 89 : transport_params_(params), |
| 96 status_callback_(status_callback), | 90 clock_(params.clock), |
| 97 transport_task_runner_(transport_task_runner), | 91 transport_task_runner_(params.transport_task_runner), |
| 98 transport_(external_transport | 92 logging_flush_interval_(params.logging_flush_interval), |
| 99 ? nullptr | |
| 100 : new UdpTransport(net_log, | |
| 101 transport_task_runner, | |
| 102 local_end_point, | |
| 103 remote_end_point, | |
| 104 GetTransportSendBufferSize(*options), | |
| 105 status_callback)), | |
| 106 pacer_(LookupOptionWithDefault(*options, | |
| 107 kOptionPacerTargetBurstSize, | |
| 108 kTargetBurstSize), | |
| 109 LookupOptionWithDefault(*options, | |
| 110 kOptionPacerMaxBurstSize, | |
| 111 kMaxBurstSize), | |
| 112 clock, | |
| 113 raw_events_callback.is_null() ? nullptr : &recent_packet_events_, | |
| 114 external_transport ? external_transport : transport_.get(), | |
| 115 transport_task_runner), | |
| 116 raw_events_callback_(raw_events_callback), | |
| 117 raw_events_callback_interval_(raw_events_callback_interval), | |
| 118 last_byte_acked_for_audio_(0), | 93 last_byte_acked_for_audio_(0), |
| 119 packet_callback_(packet_callback), | |
| 120 weak_factory_(this) { | 94 weak_factory_(this) { |
| 121 DCHECK(clock_); | 95 DCHECK(params.clock); |
| 122 if (!raw_events_callback_.is_null()) { | 96 transport_.reset( |
| 123 DCHECK(raw_events_callback_interval > base::TimeDelta()); | 97 external_transport |
| 124 transport_task_runner->PostDelayedTask( | 98 ? nullptr |
| 125 FROM_HERE, | 99 : new UdpTransport( |
| 126 base::Bind(&CastTransportSenderImpl::SendRawEvents, | 100 params.net_log, transport_task_runner_, params.local_end_point, |
| 127 weak_factory_.GetWeakPtr()), | 101 params.remote_end_point, |
| 128 raw_events_callback_interval); | 102 GetTransportSendBufferSize(*(params.optional_config)), |
| 103 base::Bind(&CastTransportSenderImpl::OnStatusChange, | |
| 104 weak_factory_.GetWeakPtr()))); | |
| 105 pacer_.reset(new PacedSender( | |
| 106 LookupOptionWithDefault(*(params.optional_config), | |
| 107 kOptionPacerTargetBurstSize, kTargetBurstSize), | |
| 108 LookupOptionWithDefault(*(params.optional_config), | |
| 109 kOptionPacerMaxBurstSize, kMaxBurstSize), | |
| 110 params.clock, | |
| 111 params.logging_flush_interval > base::TimeDelta() ? &recent_packet_events_ | |
| 112 : nullptr, | |
| 113 external_transport ? external_transport : transport_.get(), | |
| 114 params.transport_task_runner)); | |
| 115 if (logging_flush_interval_ > base::TimeDelta()) { | |
| 116 transport_task_runner_->PostDelayedTask( | |
| 117 FROM_HERE, base::Bind(&CastTransportSenderImpl::SendRawEvents, | |
| 118 weak_factory_.GetWeakPtr()), | |
| 119 logging_flush_interval_); | |
| 129 } | 120 } |
| 130 if (transport_) { | 121 if (transport_) { |
| 131 if (options->HasKey(kOptionDscp)) { | 122 if (params.optional_config->HasKey(kOptionDscp)) { |
| 132 // The default DSCP value for cast is AF41. Which gives it a higher | 123 // The default DSCP value for cast is AF41. Which gives it a higher |
| 133 // priority over other traffic. | 124 // priority over other traffic. |
| 134 transport_->SetDscp(net::DSCP_AF41); | 125 transport_->SetDscp(net::DSCP_AF41); |
| 135 } | 126 } |
| 136 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
| 137 if (!options->HasKey(kOptionDisableNonBlockingIO)) { | 128 if (!params.optional_config->HasKey(kOptionDisableNonBlockingIO)) { |
| 138 transport_->UseNonBlockingIO(); | 129 transport_->UseNonBlockingIO(); |
| 139 } | 130 } |
| 140 #endif | 131 #endif |
| 141 transport_->StartReceiving( | 132 transport_->StartReceiving( |
| 142 base::Bind(&CastTransportSenderImpl::OnReceivedPacket, | 133 base::Bind(&CastTransportSenderImpl::OnReceivedPacket, |
| 143 base::Unretained(this))); | 134 base::Unretained(this))); |
| 144 int wifi_options = 0; | 135 int wifi_options = 0; |
| 145 if (options->HasKey(kOptionWifiDisableScan)) { | 136 if (params.optional_config->HasKey(kOptionWifiDisableScan)) { |
| 146 wifi_options |= net::WIFI_OPTIONS_DISABLE_SCAN; | 137 wifi_options |= net::WIFI_OPTIONS_DISABLE_SCAN; |
| 147 } | 138 } |
| 148 if (options->HasKey(kOptionWifiMediaStreamingMode)) { | 139 if (params.optional_config->HasKey(kOptionWifiMediaStreamingMode)) { |
| 149 wifi_options |= net::WIFI_OPTIONS_MEDIA_STREAMING_MODE; | 140 wifi_options |= net::WIFI_OPTIONS_MEDIA_STREAMING_MODE; |
| 150 } | 141 } |
| 151 if (wifi_options) { | 142 if (wifi_options) { |
| 152 wifi_options_autoreset_ = net::SetWifiOptions(wifi_options); | 143 wifi_options_autoreset_ = net::SetWifiOptions(wifi_options); |
| 153 } | 144 } |
| 154 } | 145 } |
| 155 } | 146 } |
| 156 | 147 |
| 157 CastTransportSenderImpl::~CastTransportSenderImpl() { | 148 CastTransportSenderImpl::~CastTransportSenderImpl() { |
| 158 if (transport_) { | 149 if (transport_) { |
| 159 transport_->StopReceiving(); | 150 transport_->StopReceiving(); |
| 160 } | 151 } |
| 161 } | 152 } |
| 162 | 153 |
| 163 void CastTransportSenderImpl::InitializeAudio( | 154 void CastTransportSenderImpl::InitializeAudio( |
| 164 const CastTransportRtpConfig& config, | 155 const CastTransportRtpConfig& config, |
| 165 const RtcpCastMessageCallback& cast_message_cb, | 156 const RtcpCastMessageCallback& cast_message_cb, |
| 166 const RtcpRttCallback& rtt_cb) { | 157 const RtcpRttCallback& rtt_cb) { |
| 167 LOG_IF(WARNING, config.aes_key.empty() || config.aes_iv_mask.empty()) | 158 LOG_IF(WARNING, config.aes_key.empty() || config.aes_iv_mask.empty()) |
| 168 << "Unsafe to send audio with encryption DISABLED."; | 159 << "Unsafe to send audio with encryption DISABLED."; |
| 160 DCHECK(transport_params_.client); | |
| 169 if (!audio_encryptor_.Initialize(config.aes_key, config.aes_iv_mask)) { | 161 if (!audio_encryptor_.Initialize(config.aes_key, config.aes_iv_mask)) { |
| 170 status_callback_.Run(TRANSPORT_AUDIO_UNINITIALIZED); | 162 transport_params_.client->OnStatusChange(TRANSPORT_AUDIO_UNINITIALIZED); |
| 171 return; | 163 return; |
| 172 } | 164 } |
| 173 | 165 |
| 174 audio_sender_.reset(new RtpSender(transport_task_runner_, &pacer_)); | 166 audio_sender_.reset(new RtpSender(transport_task_runner_, pacer_.get())); |
| 175 if (audio_sender_->Initialize(config)) { | 167 if (audio_sender_->Initialize(config)) { |
| 176 // Audio packets have a higher priority. | 168 // Audio packets have a higher priority. |
| 177 pacer_.RegisterAudioSsrc(config.ssrc); | 169 pacer_->RegisterAudioSsrc(config.ssrc); |
| 178 pacer_.RegisterPrioritySsrc(config.ssrc); | 170 pacer_->RegisterPrioritySsrc(config.ssrc); |
| 179 status_callback_.Run(TRANSPORT_AUDIO_INITIALIZED); | 171 transport_params_.client->OnStatusChange(TRANSPORT_AUDIO_INITIALIZED); |
| 180 } else { | 172 } else { |
| 181 audio_sender_.reset(); | 173 audio_sender_.reset(); |
| 182 status_callback_.Run(TRANSPORT_AUDIO_UNINITIALIZED); | 174 transport_params_.client->OnStatusChange(TRANSPORT_AUDIO_UNINITIALIZED); |
| 183 return; | 175 return; |
| 184 } | 176 } |
| 185 | 177 |
| 186 audio_rtcp_session_.reset( | 178 audio_rtcp_session_.reset(new Rtcp( |
| 187 new Rtcp(base::Bind(&CastTransportSenderImpl::OnReceivedCastMessage, | 179 base::Bind(&CastTransportSenderImpl::OnReceivedCastMessage, |
| 188 weak_factory_.GetWeakPtr(), config.ssrc, | 180 weak_factory_.GetWeakPtr(), config.ssrc, cast_message_cb), |
| 189 cast_message_cb), | 181 rtt_cb, base::Bind(&CastTransportSenderImpl::OnReceivedLogMessage, |
| 190 rtt_cb, | 182 weak_factory_.GetWeakPtr(), AUDIO_EVENT), |
| 191 base::Bind(&CastTransportSenderImpl::OnReceivedLogMessage, | 183 clock_, pacer_.get(), config.ssrc, config.feedback_ssrc)); |
| 192 weak_factory_.GetWeakPtr(), AUDIO_EVENT), | 184 pacer_->RegisterAudioSsrc(config.ssrc); |
| 193 clock_, | |
| 194 &pacer_, | |
| 195 config.ssrc, | |
| 196 config.feedback_ssrc)); | |
| 197 pacer_.RegisterAudioSsrc(config.ssrc); | |
| 198 AddValidSsrc(config.feedback_ssrc); | 185 AddValidSsrc(config.feedback_ssrc); |
| 199 status_callback_.Run(TRANSPORT_AUDIO_INITIALIZED); | 186 transport_params_.client->OnStatusChange(TRANSPORT_AUDIO_INITIALIZED); |
| 200 } | 187 } |
| 201 | 188 |
| 202 void CastTransportSenderImpl::InitializeVideo( | 189 void CastTransportSenderImpl::InitializeVideo( |
| 203 const CastTransportRtpConfig& config, | 190 const CastTransportRtpConfig& config, |
| 204 const RtcpCastMessageCallback& cast_message_cb, | 191 const RtcpCastMessageCallback& cast_message_cb, |
| 205 const RtcpRttCallback& rtt_cb) { | 192 const RtcpRttCallback& rtt_cb) { |
| 206 LOG_IF(WARNING, config.aes_key.empty() || config.aes_iv_mask.empty()) | 193 LOG_IF(WARNING, config.aes_key.empty() || config.aes_iv_mask.empty()) |
| 207 << "Unsafe to send video with encryption DISABLED."; | 194 << "Unsafe to send video with encryption DISABLED."; |
| 195 DCHECK(transport_params_.client); | |
| 208 if (!video_encryptor_.Initialize(config.aes_key, config.aes_iv_mask)) { | 196 if (!video_encryptor_.Initialize(config.aes_key, config.aes_iv_mask)) { |
| 209 status_callback_.Run(TRANSPORT_VIDEO_UNINITIALIZED); | 197 transport_params_.client->OnStatusChange(TRANSPORT_VIDEO_UNINITIALIZED); |
| 210 return; | 198 return; |
| 211 } | 199 } |
| 212 | 200 |
| 213 video_sender_.reset(new RtpSender(transport_task_runner_, &pacer_)); | 201 video_sender_.reset(new RtpSender(transport_task_runner_, pacer_.get())); |
| 214 if (!video_sender_->Initialize(config)) { | 202 if (!video_sender_->Initialize(config)) { |
| 215 video_sender_.reset(); | 203 video_sender_.reset(); |
| 216 status_callback_.Run(TRANSPORT_VIDEO_UNINITIALIZED); | 204 transport_params_.client->OnStatusChange(TRANSPORT_VIDEO_UNINITIALIZED); |
| 217 return; | 205 return; |
| 218 } | 206 } |
| 219 | 207 |
| 220 video_rtcp_session_.reset( | 208 video_rtcp_session_.reset(new Rtcp( |
| 221 new Rtcp(base::Bind(&CastTransportSenderImpl::OnReceivedCastMessage, | 209 base::Bind(&CastTransportSenderImpl::OnReceivedCastMessage, |
| 222 weak_factory_.GetWeakPtr(), config.ssrc, | 210 weak_factory_.GetWeakPtr(), config.ssrc, cast_message_cb), |
| 223 cast_message_cb), | 211 rtt_cb, base::Bind(&CastTransportSenderImpl::OnReceivedLogMessage, |
| 224 rtt_cb, | 212 weak_factory_.GetWeakPtr(), VIDEO_EVENT), |
| 225 base::Bind(&CastTransportSenderImpl::OnReceivedLogMessage, | 213 clock_, pacer_.get(), config.ssrc, config.feedback_ssrc)); |
| 226 weak_factory_.GetWeakPtr(), VIDEO_EVENT), | 214 pacer_->RegisterVideoSsrc(config.ssrc); |
| 227 clock_, | |
| 228 &pacer_, | |
| 229 config.ssrc, | |
| 230 config.feedback_ssrc)); | |
| 231 pacer_.RegisterVideoSsrc(config.ssrc); | |
| 232 AddValidSsrc(config.feedback_ssrc); | 215 AddValidSsrc(config.feedback_ssrc); |
| 233 status_callback_.Run(TRANSPORT_VIDEO_INITIALIZED); | 216 transport_params_.client->OnStatusChange(TRANSPORT_VIDEO_INITIALIZED); |
| 234 } | 217 } |
| 235 | 218 |
| 236 namespace { | 219 namespace { |
| 237 void EncryptAndSendFrame(const EncodedFrame& frame, | 220 void EncryptAndSendFrame(const EncodedFrame& frame, |
| 238 TransportEncryptionHandler* encryptor, | 221 TransportEncryptionHandler* encryptor, |
| 239 RtpSender* sender) { | 222 RtpSender* sender) { |
| 240 // TODO(miu): We probably shouldn't attempt to send an empty frame, but this | 223 // TODO(miu): We probably shouldn't attempt to send an empty frame, but this |
| 241 // issue is still under investigation. http://crbug.com/519022 | 224 // issue is still under investigation. http://crbug.com/519022 |
| 242 if (encryptor->is_activated() && !frame.data.empty()) { | 225 if (encryptor->is_activated() && !frame.data.empty()) { |
| 243 EncodedFrame encrypted_frame; | 226 EncodedFrame encrypted_frame; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 } | 312 } |
| 330 } | 313 } |
| 331 | 314 |
| 332 PacketReceiverCallback CastTransportSenderImpl::PacketReceiverForTesting() { | 315 PacketReceiverCallback CastTransportSenderImpl::PacketReceiverForTesting() { |
| 333 return base::Bind( | 316 return base::Bind( |
| 334 base::IgnoreResult(&CastTransportSenderImpl::OnReceivedPacket), | 317 base::IgnoreResult(&CastTransportSenderImpl::OnReceivedPacket), |
| 335 weak_factory_.GetWeakPtr()); | 318 weak_factory_.GetWeakPtr()); |
| 336 } | 319 } |
| 337 | 320 |
| 338 void CastTransportSenderImpl::SendRawEvents() { | 321 void CastTransportSenderImpl::SendRawEvents() { |
| 339 DCHECK(!raw_events_callback_.is_null()); | 322 DCHECK(transport_params_.client && |
| 323 logging_flush_interval_ > base::TimeDelta()); | |
| 340 | 324 |
| 341 if (!recent_frame_events_.empty() || !recent_packet_events_.empty()) { | 325 if (!recent_frame_events_.empty() || !recent_packet_events_.empty()) { |
| 342 scoped_ptr<std::vector<FrameEvent>> frame_events( | 326 scoped_ptr<std::vector<FrameEvent>> frame_events( |
| 343 new std::vector<FrameEvent>()); | 327 new std::vector<FrameEvent>()); |
| 344 frame_events->swap(recent_frame_events_); | 328 frame_events->swap(recent_frame_events_); |
| 345 scoped_ptr<std::vector<PacketEvent>> packet_events( | 329 scoped_ptr<std::vector<PacketEvent>> packet_events( |
| 346 new std::vector<PacketEvent>()); | 330 new std::vector<PacketEvent>()); |
| 347 packet_events->swap(recent_packet_events_); | 331 packet_events->swap(recent_packet_events_); |
| 348 raw_events_callback_.Run(frame_events.Pass(), packet_events.Pass()); | 332 transport_params_.client->OnReceivedLoggingEvents(frame_events.Pass(), |
| 333 packet_events.Pass()); | |
| 349 } | 334 } |
| 350 | 335 |
| 351 transport_task_runner_->PostDelayedTask( | 336 transport_task_runner_->PostDelayedTask( |
| 352 FROM_HERE, | 337 FROM_HERE, base::Bind(&CastTransportSenderImpl::SendRawEvents, |
| 353 base::Bind(&CastTransportSenderImpl::SendRawEvents, | 338 weak_factory_.GetWeakPtr()), |
| 354 weak_factory_.GetWeakPtr()), | 339 logging_flush_interval_); |
| 355 raw_events_callback_interval_); | |
| 356 } | 340 } |
| 357 | 341 |
| 358 bool CastTransportSenderImpl::OnReceivedPacket(scoped_ptr<Packet> packet) { | 342 bool CastTransportSenderImpl::OnReceivedPacket(scoped_ptr<Packet> packet) { |
| 359 const uint8_t* const data = &packet->front(); | 343 const uint8_t* const data = &packet->front(); |
| 360 const size_t length = packet->size(); | 344 const size_t length = packet->size(); |
| 361 uint32 ssrc; | 345 uint32 ssrc; |
| 362 if (Rtcp::IsRtcpPacket(data, length)) { | 346 if (Rtcp::IsRtcpPacket(data, length)) { |
| 363 ssrc = Rtcp::GetSsrcOfSender(data, length); | 347 ssrc = Rtcp::GetSsrcOfSender(data, length); |
| 364 } else if (!RtpParser::ParseSsrc(data, length, &ssrc)) { | 348 } else if (!RtpParser::ParseSsrc(data, length, &ssrc)) { |
| 365 VLOG(1) << "Invalid RTP packet."; | 349 VLOG(1) << "Invalid RTP packet."; |
| 366 return false; | 350 return false; |
| 367 } | 351 } |
| 368 if (valid_ssrcs_.find(ssrc) == valid_ssrcs_.end()) { | 352 if (valid_ssrcs_.find(ssrc) == valid_ssrcs_.end()) { |
| 369 VLOG(1) << "Stale packet received."; | 353 VLOG(1) << "Stale packet received."; |
| 370 return false; | 354 return false; |
| 371 } | 355 } |
| 372 | 356 |
| 373 if (audio_rtcp_session_ && | 357 if (audio_rtcp_session_ && |
| 374 audio_rtcp_session_->IncomingRtcpPacket(data, length)) { | 358 audio_rtcp_session_->IncomingRtcpPacket(data, length)) { |
| 375 return true; | 359 return true; |
| 376 } | 360 } |
| 377 if (video_rtcp_session_ && | 361 if (video_rtcp_session_ && |
| 378 video_rtcp_session_->IncomingRtcpPacket(data, length)) { | 362 video_rtcp_session_->IncomingRtcpPacket(data, length)) { |
| 379 return true; | 363 return true; |
| 380 } | 364 } |
| 381 if (packet_callback_.is_null()) { | 365 DCHECK(transport_params_.client); |
|
imcheng
2015/12/17 00:18:11
If this DCHECK and other needed? If client is null
xjz
2015/12/17 22:54:58
Done. Removed DCHECKs.
| |
| 382 VLOG(1) << "Stale packet received."; | 366 transport_params_.client->OnReceivedPackets(packet.Pass()); |
| 383 return false; | |
| 384 } | |
| 385 packet_callback_.Run(packet.Pass()); | |
| 386 return true; | 367 return true; |
| 387 } | 368 } |
| 388 | 369 |
| 389 void CastTransportSenderImpl::OnReceivedLogMessage( | 370 void CastTransportSenderImpl::OnReceivedLogMessage( |
| 390 EventMediaType media_type, | 371 EventMediaType media_type, |
| 391 const RtcpReceiverLogMessage& log) { | 372 const RtcpReceiverLogMessage& log) { |
| 392 if (raw_events_callback_.is_null()) | 373 if ((!transport_params_.client) || |
| 374 (logging_flush_interval_ == base::TimeDelta())) | |
| 393 return; | 375 return; |
| 394 | 376 |
| 395 // Add received log messages into our log system. | 377 // Add received log messages into our log system. |
| 396 for (const RtcpReceiverFrameLogMessage& frame_log_message : log) { | 378 for (const RtcpReceiverFrameLogMessage& frame_log_message : log) { |
| 397 for (const RtcpReceiverEventLogMessage& event_log_message : | 379 for (const RtcpReceiverEventLogMessage& event_log_message : |
| 398 frame_log_message.event_log_messages_) { | 380 frame_log_message.event_log_messages_) { |
| 399 switch (event_log_message.type) { | 381 switch (event_log_message.type) { |
| 400 case PACKET_RECEIVED: { | 382 case PACKET_RECEIVED: { |
| 401 recent_packet_events_.push_back(PacketEvent()); | 383 recent_packet_events_.push_back(PacketEvent()); |
| 402 PacketEvent& receive_event = recent_packet_events_.back(); | 384 PacketEvent& receive_event = recent_packet_events_.back(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 } | 452 } |
| 471 | 453 |
| 472 void CastTransportSenderImpl::SendRtcpFromRtpReceiver( | 454 void CastTransportSenderImpl::SendRtcpFromRtpReceiver( |
| 473 uint32 ssrc, | 455 uint32 ssrc, |
| 474 uint32 sender_ssrc, | 456 uint32 sender_ssrc, |
| 475 const RtcpTimeData& time_data, | 457 const RtcpTimeData& time_data, |
| 476 const RtcpCastMessage* cast_message, | 458 const RtcpCastMessage* cast_message, |
| 477 base::TimeDelta target_delay, | 459 base::TimeDelta target_delay, |
| 478 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 460 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
| 479 const RtpReceiverStatistics* rtp_receiver_statistics) { | 461 const RtpReceiverStatistics* rtp_receiver_statistics) { |
| 480 const Rtcp rtcp(RtcpCastMessageCallback(), | 462 const Rtcp rtcp(RtcpCastMessageCallback(), RtcpRttCallback(), |
| 481 RtcpRttCallback(), | 463 RtcpLogMessageCallback(), clock_, pacer_.get(), ssrc, |
| 482 RtcpLogMessageCallback(), | |
| 483 clock_, | |
| 484 &pacer_, | |
| 485 ssrc, | |
| 486 sender_ssrc); | 464 sender_ssrc); |
| 487 rtcp.SendRtcpFromRtpReceiver(time_data, | 465 rtcp.SendRtcpFromRtpReceiver(time_data, |
| 488 cast_message, | 466 cast_message, |
| 489 target_delay, | 467 target_delay, |
| 490 rtcp_events, | 468 rtcp_events, |
| 491 rtp_receiver_statistics); | 469 rtp_receiver_statistics); |
| 492 } | 470 } |
| 493 | 471 |
| 472 void CastTransportSenderImpl::OnStatusChange(CastTransportStatus status) { | |
| 473 transport_params_.client->OnStatusChange(status); | |
| 474 } | |
| 475 | |
| 494 } // namespace cast | 476 } // namespace cast |
| 495 } // namespace media | 477 } // namespace media |
| OLD | NEW |