1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QMEDIATIMERANGE_H |
41 | #define QMEDIATIMERANGE_H |
42 | |
43 | #include <QtMultimedia/qtmultimediaglobal.h> |
44 | #include <QtMultimedia/qmultimedia.h> |
45 | #include <QtCore/qshareddata.h> |
46 | |
47 | QT_BEGIN_NAMESPACE |
48 | |
49 | |
50 | class QMediaTimeRangePrivate; |
51 | |
52 | class Q_MULTIMEDIA_EXPORT QMediaTimeInterval |
53 | { |
54 | public: |
55 | QMediaTimeInterval(); |
56 | QMediaTimeInterval(qint64 start, qint64 end); |
57 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
58 | QMediaTimeInterval(const QMediaTimeInterval&); |
59 | QMediaTimeInterval &operator=(const QMediaTimeInterval&) = default; |
60 | QMediaTimeInterval(QMediaTimeInterval &&) = default; |
61 | QMediaTimeInterval &operator=(QMediaTimeInterval &&) = default; |
62 | #endif |
63 | |
64 | qint64 start() const; |
65 | qint64 end() const; |
66 | |
67 | bool contains(qint64 time) const; |
68 | |
69 | bool isNormal() const; |
70 | QMediaTimeInterval normalized() const; |
71 | QMediaTimeInterval translated(qint64 offset) const; |
72 | |
73 | private: |
74 | friend class QMediaTimeRangePrivate; |
75 | friend class QMediaTimeRange; |
76 | |
77 | qint64 s; |
78 | qint64 e; |
79 | }; |
80 | |
81 | Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeInterval&, const QMediaTimeInterval&); |
82 | Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeInterval&, const QMediaTimeInterval&); |
83 | |
84 | class Q_MULTIMEDIA_EXPORT QMediaTimeRange |
85 | { |
86 | public: |
87 | |
88 | QMediaTimeRange(); |
89 | QMediaTimeRange(qint64 start, qint64 end); |
90 | QMediaTimeRange(const QMediaTimeInterval&); |
91 | QMediaTimeRange(const QMediaTimeRange &range); |
92 | ~QMediaTimeRange(); |
93 | |
94 | QMediaTimeRange &operator=(const QMediaTimeRange&); |
95 | QMediaTimeRange &operator=(const QMediaTimeInterval&); |
96 | |
97 | qint64 earliestTime() const; |
98 | qint64 latestTime() const; |
99 | |
100 | QList<QMediaTimeInterval> intervals() const; |
101 | bool isEmpty() const; |
102 | bool isContinuous() const; |
103 | |
104 | bool contains(qint64 time) const; |
105 | |
106 | void addInterval(qint64 start, qint64 end); |
107 | void addInterval(const QMediaTimeInterval &interval); |
108 | void addTimeRange(const QMediaTimeRange&); |
109 | |
110 | void removeInterval(qint64 start, qint64 end); |
111 | void removeInterval(const QMediaTimeInterval &interval); |
112 | void removeTimeRange(const QMediaTimeRange&); |
113 | |
114 | QMediaTimeRange& operator+=(const QMediaTimeRange&); |
115 | QMediaTimeRange& operator+=(const QMediaTimeInterval&); |
116 | QMediaTimeRange& operator-=(const QMediaTimeRange&); |
117 | QMediaTimeRange& operator-=(const QMediaTimeInterval&); |
118 | |
119 | void clear(); |
120 | |
121 | private: |
122 | QSharedDataPointer<QMediaTimeRangePrivate> d; |
123 | }; |
124 | |
125 | Q_MULTIMEDIA_EXPORT bool operator==(const QMediaTimeRange&, const QMediaTimeRange&); |
126 | Q_MULTIMEDIA_EXPORT bool operator!=(const QMediaTimeRange&, const QMediaTimeRange&); |
127 | Q_MULTIMEDIA_EXPORT QMediaTimeRange operator+(const QMediaTimeRange&, const QMediaTimeRange&); |
128 | Q_MULTIMEDIA_EXPORT QMediaTimeRange operator-(const QMediaTimeRange&, const QMediaTimeRange&); |
129 | |
130 | #ifndef QT_NO_DEBUG_STREAM |
131 | Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange &); |
132 | #endif |
133 | |
134 | QT_END_NAMESPACE |
135 | |
136 | |
137 | #endif // QMEDIATIMERANGE_H |
138 | |