QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
clocktime.h
1 /*
2  Copyright (C) 2011 Collabora Ltd. <info@collabora.co.uk>
3  @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
4 
5  This library is free software; you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation; either version 2.1 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef QGST_CLOCKTIME_H
19 #define QGST_CLOCKTIME_H
20 
21 #include "global.h"
22 class QTime;
23 
24 namespace QGst {
25 
29 typedef qint64 ClockTimeDiff;
30 
31 
37 class QTGSTREAMER_EXPORT ClockTime
38 {
39 public:
41  static const quint64 None = -1;
42 
43  inline ClockTime(quint64 t = None) : m_clocktime(t) {}
44  inline operator quint64() const { return m_clocktime; }
45 
47  inline bool isValid() const { return m_clocktime != None; }
48 
53  QTime toTime() const;
54 
56  static ClockTime fromTime(const QTime & time);
57 
59  inline static ClockTime fromSeconds(quint64 seconds);
60 
62  inline static ClockTime fromMSecs(quint64 msec);
63 
65  inline static ClockTime fromUSecs(quint64 usec);
66 
67 private:
68  quint64 m_clocktime;
69 };
70 
71 inline ClockTime ClockTime::fromSeconds(quint64 seconds)
72 {
73  return ClockTime(seconds * 1000 * 1000 * 1000);
74 }
75 
76 inline ClockTime ClockTime::fromMSecs(quint64 msec)
77 {
78  return ClockTime(msec * 1000 * 1000);
79 }
80 
81 inline ClockTime ClockTime::fromUSecs(quint64 usec)
82 {
83  return ClockTime(usec * 1000);
84 }
85 
86 
87 } //namspace QGst
88 
89 QGST_REGISTER_TYPE(QGst::ClockTime)
90 
91 #endif // QGST_CLOCKTIME_H
qint64 ClockTimeDiff
Definition: clocktime.h:29
static ClockTime fromSeconds(quint64 seconds)
Definition: clocktime.h:71
A datatype to hold a time, measured in nanoseconds.
Definition: clocktime.h:37
static ClockTime fromUSecs(quint64 usec)
Definition: clocktime.h:81
static ClockTime fromMSecs(quint64 msec)
Definition: clocktime.h:76
bool isValid() const
Definition: clocktime.h:47