Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux...
[chromium-blink-merge.git] / media / cast / rtp_timestamp_helper.cc
blob3349e7b33fd4adf9d8a176c05984c69801950879
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
3 // found in the LICENSE file.
5 #include "media/cast/rtp_timestamp_helper.h"
7 namespace media {
8 namespace cast {
10 RtpTimestampHelper::RtpTimestampHelper(int frequency)
11 : frequency_(frequency),
12 last_rtp_timestamp_(0) {
15 RtpTimestampHelper::~RtpTimestampHelper() {
18 bool RtpTimestampHelper::GetCurrentTimeAsRtpTimestamp(
19 const base::TimeTicks& now, uint32* rtp_timestamp) const {
20 if (last_capture_time_.is_null())
21 return false;
22 const base::TimeDelta elapsed_time = now - last_capture_time_;
23 const int64 rtp_delta =
24 elapsed_time * frequency_ / base::TimeDelta::FromSeconds(1);
25 *rtp_timestamp = last_rtp_timestamp_ + static_cast<uint32>(rtp_delta);
26 return true;
29 void RtpTimestampHelper::StoreLatestTime(
30 base::TimeTicks capture_time, uint32 rtp_timestamp) {
31 last_capture_time_ = capture_time;
32 last_rtp_timestamp_ = rtp_timestamp;
35 } // namespace cast
36 } // namespace media