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

Unified Diff: webkit/media/webmediaplayer_util.cc

Issue 10073016: Upstream WebMediaPlayerAndroid as WebKit::WebMediaPlayer implementation on android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small changes to address comments Created 8 years, 8 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 | « webkit/media/webmediaplayer_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_util.cc
diff --git a/webkit/media/webmediaplayer_util.cc b/webkit/media/webmediaplayer_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e2d5ef8d62dcb5d2f275c3ed09c6584d56b5b11f
--- /dev/null
+++ b/webkit/media/webmediaplayer_util.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2012 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.
+
+#include "webkit/media/webmediaplayer_util.h"
+
+#include <math.h>
+
+namespace webkit_media {
+
+base::TimeDelta ConvertSecondsToTimestamp(float seconds) {
+ float microseconds = seconds * base::Time::kMicrosecondsPerSecond;
+ float integer = ceilf(microseconds);
+ float difference = integer - microseconds;
+
+ // Round down if difference is large enough.
+ if ((microseconds > 0 && difference > 0.5f) ||
+ (microseconds <= 0 && difference >= 0.5f)) {
+ integer -= 1.0f;
+ }
+
+ // Now we can safely cast to int64 microseconds.
+ return base::TimeDelta::FromMicroseconds(static_cast<int64>(integer));
+}
+
+} // namespace webkit_media
« no previous file with comments | « webkit/media/webmediaplayer_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698