Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: mojo/services/media/common/cpp/timeline.h

Issue 1986303002: Motown: Use new TimelineTransform and related definitions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/media/common/cpp/BUILD.gn ('k') | mojo/services/media/common/cpp/timeline_function.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/media/common/cpp/timeline.h
diff --git a/mojo/services/media/common/cpp/timeline.h b/mojo/services/media/common/cpp/timeline.h
new file mode 100644
index 0000000000000000000000000000000000000000..4fc365141b5e46045c0e6f329434a37c950c46f5
--- /dev/null
+++ b/mojo/services/media/common/cpp/timeline.h
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_H_
+#define MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_H_
+
+#include <stdint.h>
+#include <chrono> // NOLINT(build/c++11)
+
+// TODO(johngro): As we add support for other environments, extend this list.
+#if defined(OS_POSIX)
+#include "mojo/services/media/common/cpp/platform/posix/local_time.h"
+#else
+// TODO(johngro): consider adding a #warning or #info to inform the user that
+// they are using the generic implementation of LocalTime, and really should get
+// around to implementing proper platform support ASAP.
+#include "mojo/services/media/common/cpp/platform/generic/local_time.h"
+#endif
+
+namespace mojo {
+namespace media {
+
+// Some helpful constants and static methods relating to timelines.
+class Timeline {
+ public:
+ // Returns the current local time in nanoseconds since epoch.
+ static int64_t local_now() {
+ return local_time::Clock::now().time_since_epoch().count();
+ }
+
+ template <typename T>
+ static constexpr int64_t ns_from_seconds(T seconds) {
+ return static_cast<int64_t>(seconds * std::nano::den);
+ }
+
+ template <typename T>
+ static constexpr int64_t ns_from_ms(T milliseconds) {
+ return static_cast<int64_t>(milliseconds *
+ (std::nano::den / std::milli::den));
+ }
+
+ template <typename T>
+ static constexpr int64_t ns_from_us(T microseconds) {
+ return static_cast<int64_t>(microseconds *
+ (std::nano::den / std::micro::den));
+ }
+};
+
+} // namespace media
+} // namespace mojo
+
+#endif // MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_H_
« no previous file with comments | « mojo/services/media/common/cpp/BUILD.gn ('k') | mojo/services/media/common/cpp/timeline_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698