QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
clocktime.cpp
1 /*
2  Copyright (C) 2010 Collabora Multimedia.
3  @author Mauricio Piacentini <mauricio.piacentini@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 #include "clocktime.h"
19 
20 #include <QtCore/QTime>
21 #include <gst/gst.h>
22 
23 namespace QGst {
24 
25 QTime ClockTime::toTime() const
26 {
27  ClockTime asSeconds = GST_TIME_AS_SECONDS(m_clocktime);
28  ClockTime h = (asSeconds / 3600) % 24;
29  ClockTime min = (asSeconds / 60) % 60;
30  ClockTime sec = asSeconds % 60;
31  ClockTime msec = GST_TIME_AS_MSECONDS(m_clocktime) % 1000;
32  return QTime(h, min, sec, msec);
33 }
34 
35 ClockTime ClockTime::fromTime(const QTime & time)
36 {
37  return (time.hour()*3600*Q_UINT64_C(1000000000)) + (time.minute()*60*Q_UINT64_C(1000000000))
38  + (time.second()*Q_UINT64_C(1000000000)) + (time.msec()*Q_UINT64_C(1000000));
39 }
40 
41 } //namespace QGst
QTime toTime() const
Definition: clocktime.cpp:25
A datatype to hold a time, measured in nanoseconds.
Definition: clocktime.h:37
static ClockTime fromTime(const QTime &time)
Definition: clocktime.cpp:35