| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/renderer/media/webmediaplayer_util.h" | 5 #include "webkit/renderer/media/webmediaplayer_util.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "media/base/media_keys.h" | 9 #include "media/base/media_keys.h" |
| 10 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" | 10 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" |
| 11 | 11 |
| 12 namespace webkit_media { | 12 namespace webkit_media { |
| 13 | 13 |
| 14 // Compile asserts shared by all platforms. | 14 // Compile asserts shared by all platforms. |
| 15 | 15 |
| 16 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 16 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| 17 COMPILE_ASSERT( \ | 17 COMPILE_ASSERT( \ |
| 18 static_cast<int>(WebKit::WebMediaPlayerClient::MediaKeyErrorCode ## name) == \ | 18 static_cast<int>(WebKit::WebMediaPlayerClient::MediaKeyErrorCode ## name) == \ |
| 19 static_cast<int>(media::MediaKeys::k ## name ## Error), \ | 19 static_cast<int>(media::MediaKeys::k ## name ## Error), \ |
| 20 mismatching_enums) | 20 mismatching_enums) |
| 21 COMPILE_ASSERT_MATCHING_ENUM(Unknown); | 21 COMPILE_ASSERT_MATCHING_ENUM(Unknown); |
| 22 COMPILE_ASSERT_MATCHING_ENUM(Client); | 22 COMPILE_ASSERT_MATCHING_ENUM(Client); |
| 23 COMPILE_ASSERT_MATCHING_ENUM(Service); | |
| 24 COMPILE_ASSERT_MATCHING_ENUM(Output); | |
| 25 COMPILE_ASSERT_MATCHING_ENUM(HardwareChange); | |
| 26 COMPILE_ASSERT_MATCHING_ENUM(Domain); | |
| 27 #undef COMPILE_ASSERT_MATCHING_ENUM | 23 #undef COMPILE_ASSERT_MATCHING_ENUM |
| 28 | 24 |
| 29 base::TimeDelta ConvertSecondsToTimestamp(double seconds) { | 25 base::TimeDelta ConvertSecondsToTimestamp(double seconds) { |
| 30 double microseconds = seconds * base::Time::kMicrosecondsPerSecond; | 26 double microseconds = seconds * base::Time::kMicrosecondsPerSecond; |
| 31 return base::TimeDelta::FromMicroseconds( | 27 return base::TimeDelta::FromMicroseconds( |
| 32 microseconds > 0 ? microseconds + 0.5 : ceil(microseconds - 0.5)); | 28 microseconds > 0 ? microseconds + 0.5 : ceil(microseconds - 0.5)); |
| 33 } | 29 } |
| 34 | 30 |
| 35 WebKit::WebTimeRanges ConvertToWebTimeRanges( | 31 WebKit::WebTimeRanges ConvertToWebTimeRanges( |
| 36 const media::Ranges<base::TimeDelta>& ranges) { | 32 const media::Ranges<base::TimeDelta>& ranges) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return WebKit::WebMediaPlayer::NetworkStateDecodeError; | 71 return WebKit::WebMediaPlayer::NetworkStateDecodeError; |
| 76 | 72 |
| 77 case media::PIPELINE_OK: | 73 case media::PIPELINE_OK: |
| 78 case media::PIPELINE_STATUS_MAX: | 74 case media::PIPELINE_STATUS_MAX: |
| 79 NOTREACHED() << "Unexpected status! " << error; | 75 NOTREACHED() << "Unexpected status! " << error; |
| 80 } | 76 } |
| 81 return WebKit::WebMediaPlayer::NetworkStateFormatError; | 77 return WebKit::WebMediaPlayer::NetworkStateFormatError; |
| 82 } | 78 } |
| 83 | 79 |
| 84 } // namespace webkit_media | 80 } // namespace webkit_media |
| OLD | NEW |