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/debug/trace_event.h" | 7 #include "base/debug/trace_event.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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 &delay_seconds, | 266 &delay_seconds, |
267 &delay_fraction); | 267 &delay_fraction); |
268 report_block.delay_since_last_sr = | 268 report_block.delay_since_last_sr = |
269 ConvertToNtpDiff(delay_seconds, delay_fraction); | 269 ConvertToNtpDiff(delay_seconds, delay_fraction); |
270 } else { | 270 } else { |
271 report_block.delay_since_last_sr = 0; | 271 report_block.delay_since_last_sr = 0; |
272 } | 272 } |
273 | 273 |
274 packet_type_flags |= RtcpSender::kRtcpRrtr; | 274 packet_type_flags |= RtcpSender::kRtcpRrtr; |
275 RtcpReceiverReferenceTimeReport rrtr; | 275 RtcpReceiverReferenceTimeReport rrtr; |
276 ConvertTimeToNtp(now, &rrtr.ntp_seconds, &rrtr.ntp_fraction); | 276 ConvertTimeTicksToNtp(now, &rrtr.ntp_seconds, &rrtr.ntp_fraction); |
277 | 277 |
278 time_last_report_sent_ = now; | 278 time_last_report_sent_ = now; |
279 last_report_sent_ = ConvertToNtpDiff(rrtr.ntp_seconds, rrtr.ntp_fraction); | 279 last_report_sent_ = ConvertToNtpDiff(rrtr.ntp_seconds, rrtr.ntp_fraction); |
280 | 280 |
281 rtcp_sender_->SendRtcp(packet_type_flags, | 281 rtcp_sender_->SendRtcp(packet_type_flags, |
282 NULL, | 282 NULL, |
283 &report_block, | 283 &report_block, |
284 media_ssrc, | 284 media_ssrc, |
285 NULL, | 285 NULL, |
286 &rrtr, | 286 &rrtr, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // a frame older than the last received RTCP message. | 328 // a frame older than the last received RTCP message. |
329 int64 rtp_timestamp_diff = | 329 int64 rtp_timestamp_diff = |
330 rtp_timestamp_int64 - last_received_rtp_timestamp_int64; | 330 rtp_timestamp_int64 - last_received_rtp_timestamp_int64; |
331 | 331 |
332 int frequency_khz = frequency / 1000; | 332 int frequency_khz = frequency / 1000; |
333 int64 rtp_time_diff_ms = rtp_timestamp_diff / frequency_khz; | 333 int64 rtp_time_diff_ms = rtp_timestamp_diff / frequency_khz; |
334 | 334 |
335 // Sanity check. | 335 // Sanity check. |
336 if (abs(rtp_time_diff_ms) > kMaxDiffSinceReceivedRtcpMs) return false; | 336 if (abs(rtp_time_diff_ms) > kMaxDiffSinceReceivedRtcpMs) return false; |
337 | 337 |
338 *rtp_timestamp_in_ticks = | 338 *rtp_timestamp_in_ticks = ConvertNtpToTimeTicks(last_received_ntp_seconds_, |
339 ConvertNtpToTime(last_received_ntp_seconds_, last_received_ntp_fraction_) + | 339 last_received_ntp_fraction_) + |
340 base::TimeDelta::FromMilliseconds(rtp_time_diff_ms); | 340 base::TimeDelta::FromMilliseconds(rtp_time_diff_ms); |
341 return true; | 341 return true; |
342 } | 342 } |
343 | 343 |
344 void Rtcp::OnReceivedDelaySinceLastReport(uint32 receivers_ssrc, | 344 void Rtcp::OnReceivedDelaySinceLastReport(uint32 receivers_ssrc, |
345 uint32 last_report, | 345 uint32 last_report, |
346 uint32 delay_since_last_report) { | 346 uint32 delay_since_last_report) { |
347 if (last_report_sent_ != last_report) return; // Feedback on another report. | 347 if (last_report_sent_ != last_report) return; // Feedback on another report. |
348 if (time_last_report_sent_.is_null()) return; | 348 if (time_last_report_sent_.is_null()) return; |
349 | 349 |
350 base::TimeDelta sender_delay = clock_->NowTicks() - time_last_report_sent_; | 350 base::TimeDelta sender_delay = clock_->NowTicks() - time_last_report_sent_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 int random = base::RandInt(0, 999); | 409 int random = base::RandInt(0, 999); |
410 base::TimeDelta time_to_next = (rtcp_interval_ / 2) + | 410 base::TimeDelta time_to_next = (rtcp_interval_ / 2) + |
411 (rtcp_interval_ * random / 1000); | 411 (rtcp_interval_ * random / 1000); |
412 | 412 |
413 base::TimeTicks now = clock_->NowTicks(); | 413 base::TimeTicks now = clock_->NowTicks(); |
414 next_time_to_send_rtcp_ = now + time_to_next; | 414 next_time_to_send_rtcp_ = now + time_to_next; |
415 } | 415 } |
416 | 416 |
417 } // namespace cast | 417 } // namespace cast |
418 } // namespace media | 418 } // namespace media |
OLD | NEW |