QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
clocktime.cpp
00001 /*
00002     Copyright (C) 2010  Collabora Multimedia.
00003       @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk>
00004 
00005     This library is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as published
00007     by the Free Software Foundation; either version 2.1 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 #include "clocktime.h"
00019 
00020 #include <QtCore/QTime>
00021 #include <gst/gstclock.h>
00022 
00023 namespace QGst {
00024 
00025 QTime ClockTime::toTime() const
00026 {
00027     ClockTime asSeconds = GST_TIME_AS_SECONDS(m_clocktime);
00028     ClockTime h = (asSeconds / 3600) % 24;
00029     ClockTime min = (asSeconds / 60) % 60;
00030     ClockTime sec = asSeconds % 60;
00031     ClockTime msec = GST_TIME_AS_MSECONDS(m_clocktime) % 1000;
00032     return QTime(h, min, sec, msec);
00033 }
00034 
00035 ClockTime ClockTime::fromTime(const QTime & time)
00036 {
00037     return (time.hour()*3600*Q_UINT64_C(1000000000)) + (time.minute()*60*Q_UINT64_C(1000000000))
00038             + (time.second()*Q_UINT64_C(1000000000)) + (time.msec()*Q_UINT64_C(1000000));
00039 }
00040 
00041 } //namespace QGst