2012-11-07 13:37:19 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/tick_util.h"
|
2012-11-07 13:37:19 +00:00
|
|
|
|
2016-01-27 12:55:33 +01:00
|
|
|
#include "webrtc/base/timeutils.h"
|
2012-11-07 13:37:19 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-11-17 15:02:44 -08:00
|
|
|
int64_t TickTime::MillisecondTimestamp() {
|
|
|
|
|
return TicksToMilliseconds(TickTime::Now().Ticks());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t TickTime::MicrosecondTimestamp() {
|
|
|
|
|
return TicksToMicroseconds(TickTime::Now().Ticks());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t TickTime::MillisecondsToTicks(const int64_t ms) {
|
2016-01-27 12:55:33 +01:00
|
|
|
return ms * rtc::kNumNanosecsPerMillisec;
|
2015-11-17 15:02:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t TickTime::TicksToMilliseconds(const int64_t ticks) {
|
2016-01-27 12:55:33 +01:00
|
|
|
return ticks / rtc::kNumNanosecsPerMillisec;
|
2015-11-17 15:02:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t TickTime::TicksToMicroseconds(const int64_t ticks) {
|
2016-01-27 12:55:33 +01:00
|
|
|
return ticks / rtc::kNumNanosecsPerMicrosec;
|
2015-11-17 15:02:44 -08:00
|
|
|
}
|
|
|
|
|
|
2016-01-27 12:55:33 +01:00
|
|
|
// Gets the native system tick count, converted to nanoseconds.
|
2013-06-27 17:15:20 +00:00
|
|
|
int64_t TickTime::QueryOsForTicks() {
|
2016-01-27 12:55:33 +01:00
|
|
|
return rtc::TimeNanos();
|
2013-06-27 17:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-07 13:37:19 +00:00
|
|
|
} // namespace webrtc
|