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/rand_util.h" | 8 #include "base/rand_util.h" |
8 #include "media/cast/cast_config.h" | 9 #include "media/cast/cast_config.h" |
9 #include "media/cast/cast_defines.h" | 10 #include "media/cast/cast_defines.h" |
10 #include "media/cast/cast_environment.h" | 11 #include "media/cast/cast_environment.h" |
11 #include "media/cast/rtcp/rtcp_defines.h" | 12 #include "media/cast/rtcp/rtcp_defines.h" |
12 #include "media/cast/rtcp/rtcp_receiver.h" | 13 #include "media/cast/rtcp/rtcp_receiver.h" |
13 #include "media/cast/rtcp/rtcp_sender.h" | 14 #include "media/cast/rtcp/rtcp_sender.h" |
14 #include "media/cast/rtcp/rtcp_utility.h" | 15 #include "media/cast/rtcp/rtcp_utility.h" |
15 #include "media/cast/transport/cast_transport_defines.h" | 16 #include "media/cast/transport/cast_transport_defines.h" |
16 #include "net/base/big_endian.h" | |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 | 20 |
21 static const int kMaxRttMs = 10000; // 10 seconds. | 21 static const int kMaxRttMs = 10000; // 10 seconds. |
22 | 22 |
23 // Time limit for received RTCP messages when we stop using it for lip-sync. | 23 // Time limit for received RTCP messages when we stop using it for lip-sync. |
24 static const int64 kMaxDiffSinceReceivedRtcpMs = 100000; // 100 seconds. | 24 static const int64 kMaxDiffSinceReceivedRtcpMs = 100000; // 100 seconds. |
25 | 25 |
26 class LocalRtcpRttFeedback : public RtcpRttFeedback { | 26 class LocalRtcpRttFeedback : public RtcpRttFeedback { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 packet_type <= transport::kPacketTypeHigh) { | 198 packet_type <= transport::kPacketTypeHigh) { |
199 return true; | 199 return true; |
200 } | 200 } |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 // static | 204 // static |
205 uint32 Rtcp::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) { | 205 uint32 Rtcp::GetSsrcOfSender(const uint8* rtcp_buffer, size_t length) { |
206 DCHECK_GE(length, kMinLengthOfRtcp) << "Invalid RTCP packet"; | 206 DCHECK_GE(length, kMinLengthOfRtcp) << "Invalid RTCP packet"; |
207 uint32 ssrc_of_sender; | 207 uint32 ssrc_of_sender; |
208 net::BigEndianReader big_endian_reader(rtcp_buffer, length); | 208 base::BigEndianReader big_endian_reader( |
| 209 reinterpret_cast<const char*>(rtcp_buffer), length); |
209 big_endian_reader.Skip(4); // Skip header | 210 big_endian_reader.Skip(4); // Skip header |
210 big_endian_reader.ReadU32(&ssrc_of_sender); | 211 big_endian_reader.ReadU32(&ssrc_of_sender); |
211 return ssrc_of_sender; | 212 return ssrc_of_sender; |
212 } | 213 } |
213 | 214 |
214 base::TimeTicks Rtcp::TimeToSendNextRtcpReport() { | 215 base::TimeTicks Rtcp::TimeToSendNextRtcpReport() { |
215 if (next_time_to_send_rtcp_.is_null()) { | 216 if (next_time_to_send_rtcp_.is_null()) { |
216 UpdateNextTimeToSendRtcp(); | 217 UpdateNextTimeToSendRtcp(); |
217 } | 218 } |
218 return next_time_to_send_rtcp_; | 219 return next_time_to_send_rtcp_; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 int random = base::RandInt(0, 999); | 487 int random = base::RandInt(0, 999); |
487 base::TimeDelta time_to_next = | 488 base::TimeDelta time_to_next = |
488 (rtcp_interval_ / 2) + (rtcp_interval_ * random / 1000); | 489 (rtcp_interval_ / 2) + (rtcp_interval_ * random / 1000); |
489 | 490 |
490 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 491 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
491 next_time_to_send_rtcp_ = now + time_to_next; | 492 next_time_to_send_rtcp_ = now + time_to_next; |
492 } | 493 } |
493 | 494 |
494 } // namespace cast | 495 } // namespace cast |
495 } // namespace media | 496 } // namespace media |
OLD | NEW |