blob: 0485e429211a114f48ebe6900a8c558850531f63 [file] [log] [blame]
phoglund@webrtc.org4cebe6c2012-11-07 13:37:19 +00001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Henrik Kjellander98f53512015-10-28 18:17:40 +010011#include "webrtc/system_wrappers/include/tick_util.h"
phoglund@webrtc.org4cebe6c2012-11-07 13:37:19 +000012
Erik Språng1c390982016-01-27 12:55:33 +010013#include "webrtc/base/timeutils.h"
phoglund@webrtc.org4cebe6c2012-11-07 13:37:19 +000014
15namespace webrtc {
16
thaloun2935e012015-11-17 15:02:44 -080017int64_t TickTime::MillisecondTimestamp() {
18 return TicksToMilliseconds(TickTime::Now().Ticks());
19}
20
21int64_t TickTime::MicrosecondTimestamp() {
22 return TicksToMicroseconds(TickTime::Now().Ticks());
23}
24
25int64_t TickTime::MillisecondsToTicks(const int64_t ms) {
Erik Språng1c390982016-01-27 12:55:33 +010026 return ms * rtc::kNumNanosecsPerMillisec;
thaloun2935e012015-11-17 15:02:44 -080027}
28
29int64_t TickTime::TicksToMilliseconds(const int64_t ticks) {
Erik Språng1c390982016-01-27 12:55:33 +010030 return ticks / rtc::kNumNanosecsPerMillisec;
thaloun2935e012015-11-17 15:02:44 -080031}
32
33int64_t TickTime::TicksToMicroseconds(const int64_t ticks) {
Erik Språng1c390982016-01-27 12:55:33 +010034 return ticks / rtc::kNumNanosecsPerMicrosec;
thaloun2935e012015-11-17 15:02:44 -080035}
36
Erik Språng1c390982016-01-27 12:55:33 +010037// Gets the native system tick count, converted to nanoseconds.
fischman@webrtc.org1d4a2d52013-06-27 17:15:20 +000038int64_t TickTime::QueryOsForTicks() {
Erik Språng1c390982016-01-27 12:55:33 +010039 return rtc::TimeNanos();
fischman@webrtc.org1d4a2d52013-06-27 17:15:20 +000040}
41
phoglund@webrtc.org4cebe6c2012-11-07 13:37:19 +000042} // namespace webrtc