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/rtp_timestamp_helper.h" | 5 #include "media/cast/rtp_timestamp_helper.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 namespace cast { | 8 namespace cast { |
9 | 9 |
10 RtpTimestampHelper::RtpTimestampHelper(int frequency) | 10 RtpTimestampHelper::RtpTimestampHelper(int frequency) |
11 : frequency_(frequency), | 11 : frequency_(frequency), |
12 last_rtp_timestamp_(0) { | 12 last_rtp_timestamp_(0) { |
13 } | 13 } |
14 | 14 |
15 RtpTimestampHelper::~RtpTimestampHelper() { | 15 RtpTimestampHelper::~RtpTimestampHelper() { |
16 } | 16 } |
17 | 17 |
18 bool RtpTimestampHelper::GetCurrentTimeAsRtpTimestamp( | 18 bool RtpTimestampHelper::GetCurrentTimeAsRtpTimestamp( |
19 const base::TimeTicks& now, uint32* rtp_timestamp) const { | 19 const base::TimeTicks& now, uint32* rtp_timestamp) const { |
20 if (last_capture_time_.is_null()) | 20 if (last_capture_time_.is_null()) |
21 return false; | 21 return false; |
22 base::TimeDelta elapsed_time = now - last_capture_time_; | 22 const base::TimeDelta elapsed_time = now - last_capture_time_; |
23 *rtp_timestamp = last_rtp_timestamp_ + elapsed_time.InMilliseconds() * | 23 const int64 rtp_delta = |
miu
2014/05/23 22:41:28
Not sure whether this was hurting anything, but th
| |
24 frequency_ / base::Time::kMillisecondsPerSecond; | 24 elapsed_time * frequency_ / base::TimeDelta::FromSeconds(1); |
hubbe
2014/05/23 22:47:34
I think this will wrap around actually...
| |
25 *rtp_timestamp = last_rtp_timestamp_ + static_cast<uint32>(rtp_delta); | |
25 return true; | 26 return true; |
26 } | 27 } |
27 | 28 |
28 void RtpTimestampHelper::StoreLatestTime( | 29 void RtpTimestampHelper::StoreLatestTime( |
29 base::TimeTicks capture_time, uint32 rtp_timestamp) { | 30 base::TimeTicks capture_time, uint32 rtp_timestamp) { |
30 last_capture_time_ = capture_time; | 31 last_capture_time_ = capture_time; |
31 last_rtp_timestamp_ = rtp_timestamp; | 32 last_rtp_timestamp_ = rtp_timestamp; |
32 } | 33 } |
33 | 34 |
34 } // namespace cast | 35 } // namespace cast |
35 } // namespace media | 36 } // namespace media |
OLD | NEW |