phoglund@webrtc.org | 4cebe6c | 2012-11-07 13:37:19 +0000 | [diff] [blame] | 1 | /* |
| 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 Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 11 | #include "webrtc/system_wrappers/include/tick_util.h" |
phoglund@webrtc.org | 4cebe6c | 2012-11-07 13:37:19 +0000 | [diff] [blame] | 12 | |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 13 | #include "webrtc/base/timeutils.h" |
phoglund@webrtc.org | 4cebe6c | 2012-11-07 13:37:19 +0000 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
thaloun | 2935e01 | 2015-11-17 15:02:44 -0800 | [diff] [blame] | 17 | int64_t TickTime::MillisecondTimestamp() { |
| 18 | return TicksToMilliseconds(TickTime::Now().Ticks()); |
| 19 | } |
| 20 | |
| 21 | int64_t TickTime::MicrosecondTimestamp() { |
| 22 | return TicksToMicroseconds(TickTime::Now().Ticks()); |
| 23 | } |
| 24 | |
| 25 | int64_t TickTime::MillisecondsToTicks(const int64_t ms) { |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 26 | return ms * rtc::kNumNanosecsPerMillisec; |
thaloun | 2935e01 | 2015-11-17 15:02:44 -0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | int64_t TickTime::TicksToMilliseconds(const int64_t ticks) { |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 30 | return ticks / rtc::kNumNanosecsPerMillisec; |
thaloun | 2935e01 | 2015-11-17 15:02:44 -0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | int64_t TickTime::TicksToMicroseconds(const int64_t ticks) { |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 34 | return ticks / rtc::kNumNanosecsPerMicrosec; |
thaloun | 2935e01 | 2015-11-17 15:02:44 -0800 | [diff] [blame] | 35 | } |
| 36 | |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 37 | // Gets the native system tick count, converted to nanoseconds. |
fischman@webrtc.org | 1d4a2d5 | 2013-06-27 17:15:20 +0000 | [diff] [blame] | 38 | int64_t TickTime::QueryOsForTicks() { |
Erik Språng | 1c39098 | 2016-01-27 12:55:33 +0100 | [diff] [blame] | 39 | return rtc::TimeNanos(); |
fischman@webrtc.org | 1d4a2d5 | 2013-06-27 17:15:20 +0000 | [diff] [blame] | 40 | } |
| 41 | |
phoglund@webrtc.org | 4cebe6c | 2012-11-07 13:37:19 +0000 | [diff] [blame] | 42 | } // namespace webrtc |