| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/rtcp/rtcp.h" | 5 #include "media/cast/rtcp/rtcp.h" |
| 6 | 6 |
| 7 #include "base/big_endian.h" | 7 #include "base/big_endian.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "media/cast/cast_config.h" | 9 #include "media/cast/cast_config.h" |
| 10 #include "media/cast/cast_defines.h" | 10 #include "media/cast/cast_defines.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 UpdateNextTimeToSendRtcp(); | 199 UpdateNextTimeToSendRtcp(); |
| 200 } | 200 } |
| 201 rtcp_sender_->SendRtcpFromRtpReceiver(packet_type_flags, | 201 rtcp_sender_->SendRtcpFromRtpReceiver(packet_type_flags, |
| 202 &report_block, | 202 &report_block, |
| 203 &rrtr, | 203 &rrtr, |
| 204 cast_message, | 204 cast_message, |
| 205 rtcp_events, | 205 rtcp_events, |
| 206 target_delay_ms_); | 206 target_delay_ms_); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void Rtcp::SendRtcpFromRtpSender( | 209 void Rtcp::SendRtcpFromRtpSender(base::TimeTicks current_time, |
| 210 transport::RtcpSenderInfo sender_info) { | 210 uint32 current_time_as_rtp_timestamp) { |
| 211 DCHECK(transport_sender_); | 211 DCHECK(transport_sender_); |
| 212 uint32 packet_type_flags = transport::kRtcpSr; | 212 uint32 packet_type_flags = transport::kRtcpSr; |
| 213 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 213 uint32 current_ntp_seconds = 0; |
| 214 | 214 uint32 current_ntp_fractions = 0; |
| 215 SaveLastSentNtpTime(now, sender_info.ntp_seconds, sender_info.ntp_fraction); | 215 ConvertTimeTicksToNtp(current_time, ¤t_ntp_seconds, |
| 216 ¤t_ntp_fractions); |
| 217 SaveLastSentNtpTime(current_time, current_ntp_seconds, |
| 218 current_ntp_fractions); |
| 216 | 219 |
| 217 transport::RtcpDlrrReportBlock dlrr; | 220 transport::RtcpDlrrReportBlock dlrr; |
| 218 if (!time_last_report_received_.is_null()) { | 221 if (!time_last_report_received_.is_null()) { |
| 219 packet_type_flags |= transport::kRtcpDlrr; | 222 packet_type_flags |= transport::kRtcpDlrr; |
| 220 dlrr.last_rr = last_report_received_; | 223 dlrr.last_rr = last_report_received_; |
| 221 uint32 delay_seconds = 0; | 224 uint32 delay_seconds = 0; |
| 222 uint32 delay_fraction = 0; | 225 uint32 delay_fraction = 0; |
| 223 base::TimeDelta delta = now - time_last_report_received_; | 226 base::TimeDelta delta = current_time - time_last_report_received_; |
| 224 ConvertTimeToFractions(delta.InMicroseconds(), &delay_seconds, | 227 ConvertTimeToFractions(delta.InMicroseconds(), &delay_seconds, |
| 225 &delay_fraction); | 228 &delay_fraction); |
| 226 | 229 |
| 227 dlrr.delay_since_last_rr = ConvertToNtpDiff(delay_seconds, delay_fraction); | 230 dlrr.delay_since_last_rr = ConvertToNtpDiff(delay_seconds, delay_fraction); |
| 228 } | 231 } |
| 229 | 232 |
| 230 transport_sender_->SendRtcpFromRtpSender( | 233 transport_sender_->SendRtcpFromRtpSender( |
| 231 packet_type_flags, sender_info, dlrr, local_ssrc_, | 234 packet_type_flags, current_ntp_seconds, current_ntp_fractions, |
| 232 c_name_); | 235 current_time_as_rtp_timestamp, dlrr, local_ssrc_, c_name_); |
| 233 UpdateNextTimeToSendRtcp(); | 236 UpdateNextTimeToSendRtcp(); |
| 234 } | 237 } |
| 235 | 238 |
| 236 void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) { | 239 void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) { |
| 237 last_report_received_ = (ntp_seconds << 16) + (ntp_fraction >> 16); | 240 last_report_received_ = (ntp_seconds << 16) + (ntp_fraction >> 16); |
| 238 | 241 |
| 239 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 242 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
| 240 time_last_report_received_ = now; | 243 time_last_report_received_ = now; |
| 241 } | 244 } |
| 242 | 245 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 VLOG(2) << "Received log message via RTCP that we did not expect: " | 430 VLOG(2) << "Received log message via RTCP that we did not expect: " |
| 428 << static_cast<int>(event_it->type); | 431 << static_cast<int>(event_it->type); |
| 429 break; | 432 break; |
| 430 } | 433 } |
| 431 } | 434 } |
| 432 } | 435 } |
| 433 } | 436 } |
| 434 | 437 |
| 435 } // namespace cast | 438 } // namespace cast |
| 436 } // namespace media | 439 } // namespace media |
| OLD | NEW |