summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/MediaTime.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WTF/wtf/MediaTime.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WTF/wtf/MediaTime.h')
-rw-r--r--Source/WTF/wtf/MediaTime.h58
1 files changed, 40 insertions, 18 deletions
diff --git a/Source/WTF/wtf/MediaTime.h b/Source/WTF/wtf/MediaTime.h
index af6561ae3..50a018065 100644
--- a/Source/WTF/wtf/MediaTime.h
+++ b/Source/WTF/wtf/MediaTime.h
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -38,6 +38,8 @@
namespace WTF {
+class PrintStream;
+
class WTF_EXPORT_PRIVATE MediaTime {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -47,15 +49,18 @@ public:
PositiveInfinite = 1 << 2,
NegativeInfinite = 1 << 3,
Indefinite = 1 << 4,
+ DoubleValue = 1 << 5,
};
MediaTime();
- MediaTime(int64_t value, int32_t scale, uint32_t flags = Valid);
+ MediaTime(int64_t value, uint32_t scale, uint8_t flags = Valid);
MediaTime(const MediaTime& rhs);
~MediaTime();
- static MediaTime createWithFloat(float floatTime, int32_t timeScale = DefaultTimeScale);
- static MediaTime createWithDouble(double doubleTime, int32_t timeScale = DefaultTimeScale);
+ static MediaTime createWithFloat(float floatTime);
+ static MediaTime createWithFloat(float floatTime, uint32_t timeScale);
+ static MediaTime createWithDouble(double doubleTime);
+ static MediaTime createWithDouble(double doubleTime, uint32_t timeScale);
float toFloat() const;
double toDouble() const;
@@ -65,13 +70,16 @@ public:
MediaTime& operator-=(const MediaTime& rhs) { return *this = *this - rhs; }
MediaTime operator+(const MediaTime& rhs) const;
MediaTime operator-(const MediaTime& rhs) const;
+ MediaTime operator-() const;
MediaTime operator*(int32_t) const;
- bool operator<(const MediaTime& rhs) const;
- bool operator>(const MediaTime& rhs) const;
- bool operator!=(const MediaTime& rhs) const;
- bool operator==(const MediaTime& rhs) const;
- bool operator>=(const MediaTime& rhs) const;
- bool operator<=(const MediaTime& rhs) const;
+ bool operator<(const MediaTime& rhs) const { return compare(rhs) == LessThan; }
+ bool operator>(const MediaTime& rhs) const { return compare(rhs) == GreaterThan; }
+ bool operator!=(const MediaTime& rhs) const { return compare(rhs) != EqualTo; }
+ bool operator==(const MediaTime& rhs) const { return compare(rhs) == EqualTo; }
+ bool operator>=(const MediaTime& rhs) const { return compare(rhs) >= EqualTo; }
+ bool operator<=(const MediaTime& rhs) const { return compare(rhs) <= EqualTo; }
+ bool operator!() const;
+ explicit operator bool() const;
typedef enum {
LessThan = -1,
@@ -80,6 +88,7 @@ public:
} ComparisonFlags;
ComparisonFlags compare(const MediaTime& rhs) const;
+ bool isBetween(const MediaTime&, const MediaTime&) const;
bool isValid() const { return m_timeFlags & Valid; }
bool isInvalid() const { return !isValid(); }
@@ -87,6 +96,7 @@ public:
bool isPositiveInfinite() const { return m_timeFlags & PositiveInfinite; }
bool isNegativeInfinite() const { return m_timeFlags & NegativeInfinite; }
bool isIndefinite() const { return m_timeFlags & Indefinite; }
+ bool hasDoubleValue() const { return m_timeFlags & DoubleValue; }
static const MediaTime& zeroTime();
static const MediaTime& invalidTime();
@@ -95,18 +105,30 @@ public:
static const MediaTime& indefiniteTime();
const int64_t& timeValue() const { return m_timeValue; }
- const int32_t& timeScale() const { return m_timeScale; }
+ const uint32_t& timeScale() const { return m_timeScale; }
+
+ void dump(PrintStream& out) const;
+
+ // Make the following casts errors:
+ operator double() const = delete;
+ MediaTime(double) = delete;
+ operator int() const = delete;
+ MediaTime(int) = delete;
friend WTF_EXPORT_PRIVATE MediaTime abs(const MediaTime& rhs);
-private:
- static const int32_t DefaultTimeScale = 6000;
- static const int32_t MaximumTimeScale;
- void setTimeScale(int32_t);
+ static const uint32_t DefaultTimeScale = 10000000;
+ static const uint32_t MaximumTimeScale;
- int64_t m_timeValue;
- int32_t m_timeScale;
- uint32_t m_timeFlags;
+private:
+ void setTimeScale(uint32_t);
+
+ union {
+ int64_t m_timeValue;
+ double m_timeValueAsDouble;
+ };
+ uint32_t m_timeScale;
+ uint8_t m_timeFlags;
};
inline MediaTime operator*(int32_t lhs, const MediaTime& rhs) { return rhs.operator*(lhs); }