Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Side by Side Diff: media/cast/net/rtcp/rtcp.cc

Issue 1472083005: Remove kint64min. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint5
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/rtcp/rtcp.h" 5 #include "media/cast/net/rtcp/rtcp.h"
6 6
7 #include <limits>
8
7 #include "media/cast/cast_config.h" 9 #include "media/cast/cast_config.h"
8 #include "media/cast/cast_defines.h" 10 #include "media/cast/cast_defines.h"
9 #include "media/cast/cast_environment.h" 11 #include "media/cast/cast_environment.h"
10 #include "media/cast/net/cast_transport_defines.h" 12 #include "media/cast/net/cast_transport_defines.h"
11 #include "media/cast/net/pacing/paced_sender.h" 13 #include "media/cast/net/pacing/paced_sender.h"
12 #include "media/cast/net/rtcp/rtcp_builder.h" 14 #include "media/cast/net/rtcp/rtcp_builder.h"
13 #include "media/cast/net/rtcp/rtcp_defines.h" 15 #include "media/cast/net/rtcp/rtcp_defines.h"
14 #include "media/cast/net/rtcp/rtcp_utility.h" 16 #include "media/cast/net/rtcp/rtcp_utility.h"
15 17
16 using base::TimeDelta; 18 using base::TimeDelta;
17 19
18 namespace media { 20 namespace media {
19 namespace cast { 21 namespace cast {
20 22
21 static const int32 kStatsHistoryWindowMs = 10000; // 10 seconds. 23 static const int32_t kStatsHistoryWindowMs = 10000; // 10 seconds.
22 // Reject packets that are older than 0.5 seconds older than 24 // Reject packets that are older than 0.5 seconds older than
23 // the newest packet we've seen so far. This protect internal 25 // the newest packet we've seen so far. This protect internal
24 // states from crazy routers. (Based on RRTR) 26 // states from crazy routers. (Based on RRTR)
25 static const int32 kOutOfOrderMaxAgeMs = 500; 27 static const int32_t kOutOfOrderMaxAgeMs = 500;
26 28
27 namespace { 29 namespace {
28 30
29 // A receiver frame event is identified by frame RTP timestamp, event timestamp 31 // A receiver frame event is identified by frame RTP timestamp, event timestamp
30 // and event type. 32 // and event type.
31 // A receiver packet event is identified by all of the above plus packet id. 33 // A receiver packet event is identified by all of the above plus packet id.
32 // The key format is as follows: 34 // The key format is as follows:
33 // First uint64: 35 // First uint64_t:
34 // bits 0-11: zeroes (unused). 36 // bits 0-11: zeroes (unused).
35 // bits 12-15: event type ID. 37 // bits 12-15: event type ID.
36 // bits 16-31: packet ID if packet event, 0 otherwise. 38 // bits 16-31: packet ID if packet event, 0 otherwise.
37 // bits 32-63: RTP timestamp. 39 // bits 32-63: RTP timestamp.
38 // Second uint64: 40 // Second uint64_t:
39 // bits 0-63: event TimeTicks internal value. 41 // bits 0-63: event TimeTicks internal value.
40 std::pair<uint64, uint64> GetReceiverEventKey( 42 std::pair<uint64_t, uint64_t> GetReceiverEventKey(
41 uint32 frame_rtp_timestamp, 43 uint32_t frame_rtp_timestamp,
42 const base::TimeTicks& event_timestamp, 44 const base::TimeTicks& event_timestamp,
43 uint8 event_type, 45 uint8_t event_type,
44 uint16 packet_id_or_zero) { 46 uint16_t packet_id_or_zero) {
45 uint64 value1 = event_type; 47 uint64_t value1 = event_type;
46 value1 <<= 16; 48 value1 <<= 16;
47 value1 |= packet_id_or_zero; 49 value1 |= packet_id_or_zero;
48 value1 <<= 32; 50 value1 <<= 32;
49 value1 |= frame_rtp_timestamp; 51 value1 |= frame_rtp_timestamp;
50 return std::make_pair( 52 return std::make_pair(
51 value1, static_cast<uint64>(event_timestamp.ToInternalValue())); 53 value1, static_cast<uint64_t>(event_timestamp.ToInternalValue()));
52 } 54 }
53 55
54 } // namespace 56 } // namespace
55 57
56 Rtcp::Rtcp(const RtcpCastMessageCallback& cast_callback, 58 Rtcp::Rtcp(const RtcpCastMessageCallback& cast_callback,
57 const RtcpRttCallback& rtt_callback, 59 const RtcpRttCallback& rtt_callback,
58 const RtcpLogMessageCallback& log_callback, 60 const RtcpLogMessageCallback& log_callback,
59 base::TickClock* clock, 61 base::TickClock* clock,
60 PacedPacketSender* packet_sender, 62 PacedPacketSender* packet_sender,
61 uint32 local_ssrc, 63 uint32_t local_ssrc,
62 uint32 remote_ssrc) 64 uint32_t remote_ssrc)
63 : cast_callback_(cast_callback), 65 : cast_callback_(cast_callback),
64 rtt_callback_(rtt_callback), 66 rtt_callback_(rtt_callback),
65 log_callback_(log_callback), 67 log_callback_(log_callback),
66 clock_(clock), 68 clock_(clock),
67 rtcp_builder_(local_ssrc), 69 rtcp_builder_(local_ssrc),
68 packet_sender_(packet_sender), 70 packet_sender_(packet_sender),
69 local_ssrc_(local_ssrc), 71 local_ssrc_(local_ssrc),
70 remote_ssrc_(remote_ssrc), 72 remote_ssrc_(remote_ssrc),
71 last_report_truncated_ntp_(0), 73 last_report_truncated_ntp_(0),
72 local_clock_ahead_by_(ClockDriftSmoother::GetDefaultTimeConstant()), 74 local_clock_ahead_by_(ClockDriftSmoother::GetDefaultTimeConstant()),
73 lip_sync_rtp_timestamp_(0), 75 lip_sync_rtp_timestamp_(0),
74 lip_sync_ntp_timestamp_(0), 76 lip_sync_ntp_timestamp_(0),
75 largest_seen_timestamp_( 77 largest_seen_timestamp_(base::TimeTicks::FromInternalValue(
76 base::TimeTicks::FromInternalValue(kint64min)) { 78 std::numeric_limits<int64_t>::min())) {}
77 }
78 79
79 Rtcp::~Rtcp() {} 80 Rtcp::~Rtcp() {}
80 81
81 bool Rtcp::IsRtcpPacket(const uint8* packet, size_t length) { 82 bool Rtcp::IsRtcpPacket(const uint8_t* packet, size_t length) {
82 if (length < kMinLengthOfRtcp) { 83 if (length < kMinLengthOfRtcp) {
83 LOG(ERROR) << "Invalid RTCP packet received."; 84 LOG(ERROR) << "Invalid RTCP packet received.";
84 return false; 85 return false;
85 } 86 }
86 87
87 uint8 packet_type = packet[1]; 88 uint8_t packet_type = packet[1];
88 return packet_type >= kPacketTypeLow && packet_type <= kPacketTypeHigh; 89 return packet_type >= kPacketTypeLow && packet_type <= kPacketTypeHigh;
89 } 90 }
90 91
91 uint32 Rtcp::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) { 92 uint32_t Rtcp::GetSsrcOfSender(const uint8_t* rtcp_buffer, size_t length) {
92 if (length < kMinLengthOfRtcp) 93 if (length < kMinLengthOfRtcp)
93 return 0; 94 return 0;
94 uint32 ssrc_of_sender; 95 uint32_t ssrc_of_sender;
95 base::BigEndianReader big_endian_reader( 96 base::BigEndianReader big_endian_reader(
96 reinterpret_cast<const char*>(rtcp_buffer), length); 97 reinterpret_cast<const char*>(rtcp_buffer), length);
97 big_endian_reader.Skip(4); // Skip header. 98 big_endian_reader.Skip(4); // Skip header.
98 big_endian_reader.ReadU32(&ssrc_of_sender); 99 big_endian_reader.ReadU32(&ssrc_of_sender);
99 return ssrc_of_sender; 100 return ssrc_of_sender;
100 } 101 }
101 102
102 bool Rtcp::IncomingRtcpPacket(const uint8* data, size_t length) { 103 bool Rtcp::IncomingRtcpPacket(const uint8_t* data, size_t length) {
103 // Check if this is a valid RTCP packet. 104 // Check if this is a valid RTCP packet.
104 if (!IsRtcpPacket(data, length)) { 105 if (!IsRtcpPacket(data, length)) {
105 VLOG(1) << "Rtcp@" << this << "::IncomingRtcpPacket() -- " 106 VLOG(1) << "Rtcp@" << this << "::IncomingRtcpPacket() -- "
106 << "Received an invalid (non-RTCP?) packet."; 107 << "Received an invalid (non-RTCP?) packet.";
107 return false; 108 return false;
108 } 109 }
109 110
110 // Check if this packet is to us. 111 // Check if this packet is to us.
111 uint32 ssrc_of_sender = GetSsrcOfSender(data, length); 112 uint32_t ssrc_of_sender = GetSsrcOfSender(data, length);
112 if (ssrc_of_sender != remote_ssrc_) { 113 if (ssrc_of_sender != remote_ssrc_) {
113 return false; 114 return false;
114 } 115 }
115 116
116 // Parse this packet. 117 // Parse this packet.
117 RtcpParser parser(local_ssrc_, remote_ssrc_); 118 RtcpParser parser(local_ssrc_, remote_ssrc_);
118 base::BigEndianReader reader(reinterpret_cast<const char*>(data), length); 119 base::BigEndianReader reader(reinterpret_cast<const char*>(data), length);
119 if (parser.Parse(&reader)) { 120 if (parser.Parse(&reader)) {
120 if (parser.has_receiver_reference_time_report()) { 121 if (parser.has_receiver_reference_time_report()) {
121 base::TimeTicks t = ConvertNtpToTimeTicks( 122 base::TimeTicks t = ConvertNtpToTimeTicks(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (rtp_receiver_statistics) { 219 if (rtp_receiver_statistics) {
219 report_block.remote_ssrc = 0; // Not needed to set send side. 220 report_block.remote_ssrc = 0; // Not needed to set send side.
220 report_block.media_ssrc = remote_ssrc_; // SSRC of the RTP packet sender. 221 report_block.media_ssrc = remote_ssrc_; // SSRC of the RTP packet sender.
221 report_block.fraction_lost = rtp_receiver_statistics->fraction_lost; 222 report_block.fraction_lost = rtp_receiver_statistics->fraction_lost;
222 report_block.cumulative_lost = rtp_receiver_statistics->cumulative_lost; 223 report_block.cumulative_lost = rtp_receiver_statistics->cumulative_lost;
223 report_block.extended_high_sequence_number = 224 report_block.extended_high_sequence_number =
224 rtp_receiver_statistics->extended_high_sequence_number; 225 rtp_receiver_statistics->extended_high_sequence_number;
225 report_block.jitter = rtp_receiver_statistics->jitter; 226 report_block.jitter = rtp_receiver_statistics->jitter;
226 report_block.last_sr = last_report_truncated_ntp_; 227 report_block.last_sr = last_report_truncated_ntp_;
227 if (!time_last_report_received_.is_null()) { 228 if (!time_last_report_received_.is_null()) {
228 uint32 delay_seconds = 0; 229 uint32_t delay_seconds = 0;
229 uint32 delay_fraction = 0; 230 uint32_t delay_fraction = 0;
230 base::TimeDelta delta = time_data.timestamp - time_last_report_received_; 231 base::TimeDelta delta = time_data.timestamp - time_last_report_received_;
231 ConvertTimeToFractions(delta.InMicroseconds(), &delay_seconds, 232 ConvertTimeToFractions(delta.InMicroseconds(), &delay_seconds,
232 &delay_fraction); 233 &delay_fraction);
233 report_block.delay_since_last_sr = 234 report_block.delay_since_last_sr =
234 ConvertToNtpDiff(delay_seconds, delay_fraction); 235 ConvertToNtpDiff(delay_seconds, delay_fraction);
235 } else { 236 } else {
236 report_block.delay_since_last_sr = 0; 237 report_block.delay_since_last_sr = 0;
237 } 238 }
238 } 239 }
239 RtcpBuilder rtcp_builder(local_ssrc_); 240 RtcpBuilder rtcp_builder(local_ssrc_);
240 packet_sender_->SendRtcpPacket( 241 packet_sender_->SendRtcpPacket(
241 local_ssrc_, 242 local_ssrc_,
242 rtcp_builder.BuildRtcpFromReceiver( 243 rtcp_builder.BuildRtcpFromReceiver(
243 rtp_receiver_statistics ? &report_block : NULL, 244 rtp_receiver_statistics ? &report_block : NULL,
244 &rrtr, 245 &rrtr,
245 cast_message, 246 cast_message,
246 rtcp_events, 247 rtcp_events,
247 target_delay)); 248 target_delay));
248 } 249 }
249 250
250 void Rtcp::SendRtcpFromRtpSender(base::TimeTicks current_time, 251 void Rtcp::SendRtcpFromRtpSender(base::TimeTicks current_time,
251 uint32 current_time_as_rtp_timestamp, 252 uint32_t current_time_as_rtp_timestamp,
252 uint32 send_packet_count, 253 uint32_t send_packet_count,
253 size_t send_octet_count) { 254 size_t send_octet_count) {
254 uint32 current_ntp_seconds = 0; 255 uint32_t current_ntp_seconds = 0;
255 uint32 current_ntp_fractions = 0; 256 uint32_t current_ntp_fractions = 0;
256 ConvertTimeTicksToNtp(current_time, &current_ntp_seconds, 257 ConvertTimeTicksToNtp(current_time, &current_ntp_seconds,
257 &current_ntp_fractions); 258 &current_ntp_fractions);
258 SaveLastSentNtpTime(current_time, current_ntp_seconds, 259 SaveLastSentNtpTime(current_time, current_ntp_seconds,
259 current_ntp_fractions); 260 current_ntp_fractions);
260 261
261 RtcpSenderInfo sender_info; 262 RtcpSenderInfo sender_info;
262 sender_info.ntp_seconds = current_ntp_seconds; 263 sender_info.ntp_seconds = current_ntp_seconds;
263 sender_info.ntp_fraction = current_ntp_fractions; 264 sender_info.ntp_fraction = current_ntp_fractions;
264 sender_info.rtp_timestamp = current_time_as_rtp_timestamp; 265 sender_info.rtp_timestamp = current_time_as_rtp_timestamp;
265 sender_info.send_packet_count = send_packet_count; 266 sender_info.send_packet_count = send_packet_count;
266 sender_info.send_octet_count = send_octet_count; 267 sender_info.send_octet_count = send_octet_count;
267 268
268 packet_sender_->SendRtcpPacket( 269 packet_sender_->SendRtcpPacket(
269 local_ssrc_, 270 local_ssrc_,
270 rtcp_builder_.BuildRtcpFromSender(sender_info)); 271 rtcp_builder_.BuildRtcpFromSender(sender_info));
271 } 272 }
272 273
273 void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) { 274 void Rtcp::OnReceivedNtp(uint32_t ntp_seconds, uint32_t ntp_fraction) {
274 last_report_truncated_ntp_ = ConvertToNtpDiff(ntp_seconds, ntp_fraction); 275 last_report_truncated_ntp_ = ConvertToNtpDiff(ntp_seconds, ntp_fraction);
275 276
276 const base::TimeTicks now = clock_->NowTicks(); 277 const base::TimeTicks now = clock_->NowTicks();
277 time_last_report_received_ = now; 278 time_last_report_received_ = now;
278 279
279 // TODO(miu): This clock offset calculation does not account for packet 280 // TODO(miu): This clock offset calculation does not account for packet
280 // transit time over the network. End2EndTest.EvilNetwork confirms that this 281 // transit time over the network. End2EndTest.EvilNetwork confirms that this
281 // contributes a very significant source of error here. Determine whether 282 // contributes a very significant source of error here. Determine whether
282 // RTT should be factored-in, and how that changes the rest of the 283 // RTT should be factored-in, and how that changes the rest of the
283 // calculation. 284 // calculation.
284 const base::TimeDelta measured_offset = 285 const base::TimeDelta measured_offset =
285 now - ConvertNtpToTimeTicks(ntp_seconds, ntp_fraction); 286 now - ConvertNtpToTimeTicks(ntp_seconds, ntp_fraction);
286 local_clock_ahead_by_.Update(now, measured_offset); 287 local_clock_ahead_by_.Update(now, measured_offset);
287 if (measured_offset < local_clock_ahead_by_.Current()) { 288 if (measured_offset < local_clock_ahead_by_.Current()) {
288 // Logically, the minimum offset between the clocks has to be the correct 289 // Logically, the minimum offset between the clocks has to be the correct
289 // one. For example, the time it took to transmit the current report may 290 // one. For example, the time it took to transmit the current report may
290 // have been lower than usual, and so some of the error introduced by the 291 // have been lower than usual, and so some of the error introduced by the
291 // transmission time can be eliminated. 292 // transmission time can be eliminated.
292 local_clock_ahead_by_.Reset(now, measured_offset); 293 local_clock_ahead_by_.Reset(now, measured_offset);
293 } 294 }
294 VLOG(1) << "Local clock is ahead of the remote clock by: " 295 VLOG(1) << "Local clock is ahead of the remote clock by: "
295 << "measured=" << measured_offset.InMicroseconds() << " usec, " 296 << "measured=" << measured_offset.InMicroseconds() << " usec, "
296 << "filtered=" << local_clock_ahead_by_.Current().InMicroseconds() 297 << "filtered=" << local_clock_ahead_by_.Current().InMicroseconds()
297 << " usec."; 298 << " usec.";
298 } 299 }
299 300
300 void Rtcp::OnReceivedLipSyncInfo(uint32 rtp_timestamp, uint32 ntp_seconds, 301 void Rtcp::OnReceivedLipSyncInfo(uint32_t rtp_timestamp,
301 uint32 ntp_fraction) { 302 uint32_t ntp_seconds,
303 uint32_t ntp_fraction) {
302 if (ntp_seconds == 0) { 304 if (ntp_seconds == 0) {
303 NOTREACHED(); 305 NOTREACHED();
304 return; 306 return;
305 } 307 }
306 lip_sync_rtp_timestamp_ = rtp_timestamp; 308 lip_sync_rtp_timestamp_ = rtp_timestamp;
307 lip_sync_ntp_timestamp_ = 309 lip_sync_ntp_timestamp_ =
308 (static_cast<uint64>(ntp_seconds) << 32) | ntp_fraction; 310 (static_cast<uint64_t>(ntp_seconds) << 32) | ntp_fraction;
309 } 311 }
310 312
311 bool Rtcp::GetLatestLipSyncTimes(uint32* rtp_timestamp, 313 bool Rtcp::GetLatestLipSyncTimes(uint32_t* rtp_timestamp,
312 base::TimeTicks* reference_time) const { 314 base::TimeTicks* reference_time) const {
313 if (!lip_sync_ntp_timestamp_) 315 if (!lip_sync_ntp_timestamp_)
314 return false; 316 return false;
315 317
316 const base::TimeTicks local_reference_time = 318 const base::TimeTicks local_reference_time =
317 ConvertNtpToTimeTicks(static_cast<uint32>(lip_sync_ntp_timestamp_ >> 32), 319 ConvertNtpToTimeTicks(
318 static_cast<uint32>(lip_sync_ntp_timestamp_)) + 320 static_cast<uint32_t>(lip_sync_ntp_timestamp_ >> 32),
321 static_cast<uint32_t>(lip_sync_ntp_timestamp_)) +
319 local_clock_ahead_by_.Current(); 322 local_clock_ahead_by_.Current();
320 323
321 // Sanity-check: Getting regular lip sync updates? 324 // Sanity-check: Getting regular lip sync updates?
322 DCHECK((clock_->NowTicks() - local_reference_time) < 325 DCHECK((clock_->NowTicks() - local_reference_time) <
323 base::TimeDelta::FromMinutes(1)); 326 base::TimeDelta::FromMinutes(1));
324 327
325 *rtp_timestamp = lip_sync_rtp_timestamp_; 328 *rtp_timestamp = lip_sync_rtp_timestamp_;
326 *reference_time = local_reference_time; 329 *reference_time = local_reference_time;
327 return true; 330 return true;
328 } 331 }
329 332
330 void Rtcp::OnReceivedDelaySinceLastReport(uint32 last_report, 333 void Rtcp::OnReceivedDelaySinceLastReport(uint32_t last_report,
331 uint32 delay_since_last_report) { 334 uint32_t delay_since_last_report) {
332 RtcpSendTimeMap::iterator it = last_reports_sent_map_.find(last_report); 335 RtcpSendTimeMap::iterator it = last_reports_sent_map_.find(last_report);
333 if (it == last_reports_sent_map_.end()) { 336 if (it == last_reports_sent_map_.end()) {
334 return; // Feedback on another report. 337 return; // Feedback on another report.
335 } 338 }
336 339
337 const base::TimeDelta sender_delay = clock_->NowTicks() - it->second; 340 const base::TimeDelta sender_delay = clock_->NowTicks() - it->second;
338 const base::TimeDelta receiver_delay = 341 const base::TimeDelta receiver_delay =
339 ConvertFromNtpDiff(delay_since_last_report); 342 ConvertFromNtpDiff(delay_since_last_report);
340 current_round_trip_time_ = sender_delay - receiver_delay; 343 current_round_trip_time_ = sender_delay - receiver_delay;
341 // If the round trip time was computed as less than 1 ms, assume clock 344 // If the round trip time was computed as less than 1 ms, assume clock
342 // imprecision by one or both peers caused a bad value to be calculated. 345 // imprecision by one or both peers caused a bad value to be calculated.
343 // While plenty of networks do easily achieve less than 1 ms round trip time, 346 // While plenty of networks do easily achieve less than 1 ms round trip time,
344 // such a level of precision cannot be measured with our approach; and 1 ms is 347 // such a level of precision cannot be measured with our approach; and 1 ms is
345 // good enough to represent "under 1 ms" for our use cases. 348 // good enough to represent "under 1 ms" for our use cases.
346 current_round_trip_time_ = 349 current_round_trip_time_ =
347 std::max(current_round_trip_time_, base::TimeDelta::FromMilliseconds(1)); 350 std::max(current_round_trip_time_, base::TimeDelta::FromMilliseconds(1));
348 351
349 if (!rtt_callback_.is_null()) 352 if (!rtt_callback_.is_null())
350 rtt_callback_.Run(current_round_trip_time_); 353 rtt_callback_.Run(current_round_trip_time_);
351 } 354 }
352 355
353 void Rtcp::OnReceivedCastFeedback(const RtcpCastMessage& cast_message) { 356 void Rtcp::OnReceivedCastFeedback(const RtcpCastMessage& cast_message) {
354 if (cast_callback_.is_null()) 357 if (cast_callback_.is_null())
355 return; 358 return;
356 cast_callback_.Run(cast_message); 359 cast_callback_.Run(cast_message);
357 } 360 }
358 361
359 void Rtcp::SaveLastSentNtpTime(const base::TimeTicks& now, 362 void Rtcp::SaveLastSentNtpTime(const base::TimeTicks& now,
360 uint32 last_ntp_seconds, 363 uint32_t last_ntp_seconds,
361 uint32 last_ntp_fraction) { 364 uint32_t last_ntp_fraction) {
362 // Make sure |now| is always greater than the last element in 365 // Make sure |now| is always greater than the last element in
363 // |last_reports_sent_queue_|. 366 // |last_reports_sent_queue_|.
364 if (!last_reports_sent_queue_.empty()) { 367 if (!last_reports_sent_queue_.empty()) {
365 DCHECK(now >= last_reports_sent_queue_.back().second); 368 DCHECK(now >= last_reports_sent_queue_.back().second);
366 } 369 }
367 370
368 uint32 last_report = ConvertToNtpDiff(last_ntp_seconds, last_ntp_fraction); 371 uint32_t last_report = ConvertToNtpDiff(last_ntp_seconds, last_ntp_fraction);
369 last_reports_sent_map_[last_report] = now; 372 last_reports_sent_map_[last_report] = now;
370 last_reports_sent_queue_.push(std::make_pair(last_report, now)); 373 last_reports_sent_queue_.push(std::make_pair(last_report, now));
371 374
372 const base::TimeTicks timeout = 375 const base::TimeTicks timeout =
373 now - TimeDelta::FromMilliseconds(kStatsHistoryWindowMs); 376 now - TimeDelta::FromMilliseconds(kStatsHistoryWindowMs);
374 377
375 // Cleanup old statistics older than |timeout|. 378 // Cleanup old statistics older than |timeout|.
376 while (!last_reports_sent_queue_.empty()) { 379 while (!last_reports_sent_queue_.empty()) {
377 RtcpSendTimePair oldest_report = last_reports_sent_queue_.front(); 380 RtcpSendTimePair oldest_report = last_reports_sent_queue_.front();
378 if (oldest_report.second < timeout) { 381 if (oldest_report.second < timeout) {
379 last_reports_sent_map_.erase(oldest_report.first); 382 last_reports_sent_map_.erase(oldest_report.first);
380 last_reports_sent_queue_.pop(); 383 last_reports_sent_queue_.pop();
381 } else { 384 } else {
382 break; 385 break;
383 } 386 }
384 } 387 }
385 } 388 }
386 389
387 void Rtcp::OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log) { 390 void Rtcp::OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log) {
388 if (log_callback_.is_null()) 391 if (log_callback_.is_null())
389 return; 392 return;
390 log_callback_.Run(receiver_log); 393 log_callback_.Run(receiver_log);
391 } 394 }
392 395
393 } // namespace cast 396 } // namespace cast
394 } // namespace media 397 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698