MP7Time.hpp

Go to the documentation of this file.
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi Video Annotation Tool * 00004 * * 00005 * title: MP7Time.hpp * 00006 * * 00007 * $Id: MP7Time.hpp,v 1.4 2005/01/14 12:01:19 mkropfbe Exp $ 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 #ifndef _MP7TIME_HPP_ 00037 #define _MP7TIME_HPP_ 00038 00039 #include <global.hpp> 00040 00046 #define MP7TIME_DATE_LEN 15 00047 00049 #define MP7TIME_TZ_LEN 7 00050 00057 class MP7Time 00058 { 00059 public: 00061 MP7Time(); 00062 00067 bool setTimePoint(uint value, uint ticksPerSecond = 1); 00068 00072 bool setTimePoint(const char *mp7Value); 00073 00078 bool setTimePoint(const MP7Time &otherTime); 00079 00087 bool moveTimePoint(int value, uint ticksPerSecond); 00088 00092 bool setDuration(uint value, uint ticks); 00093 00097 bool setDuration(const char *mp7Value); 00098 00103 bool setDuration(const MP7Time &duration); 00104 00112 bool setDurationFromEnd(const MP7Time &end); 00113 00120 bool addDuration(const MP7Time &otherTime); 00121 00129 const char *timePointPretty(bool forceSubSec = false) const; 00130 00135 const char *durationPretty() const; 00136 00143 MP7Time endTimePoint() const; 00144 00155 const char * endTimePointPretty(bool forceSubSec = false) const; 00156 00161 const char *toString() const; 00162 00167 const char *timePointMP7() const; 00168 00175 const char *durationMP7() const; 00176 00180 double timeToSec() const; 00181 00185 int timeToMSec() const; 00186 00188 int durationToMSec() const; 00189 00191 double durationToSec() const; 00192 00196 bool timePointIsValid() const; 00197 00199 bool durationIsNull() const; 00200 00213 int compareTimePoint(const MP7Time &other) const; 00214 00218 bool contains(const MP7Time &time) const; 00219 00220 private: 00222 void reset(); 00223 00225 void resetTimePoint(); 00226 00228 void resetDuration(); 00229 00231 struct timepoint { 00232 char date[MP7TIME_DATE_LEN+1]; // date part, in MPEG-7 format, sign included 00233 bool hasTime; // false if both sec and num fields are invalid 00234 uint sec; // time in seconds 00235 uint num; // numerator of second fraction 00236 uint denom; // denominator of second fraction 00237 char tz[MP7TIME_TZ_LEN+1]; // time zone 00238 } tpoint; 00239 00241 struct duration { 00242 int sign; // +1 or -1 00243 uint days; 00244 uint sec; // seconds 00245 uint num; // numerator of second fraction 00246 uint denom; // denominator of second fraction 00247 char tz[MP7TIME_TZ_LEN+1]; // time zone 00248 int units; // number of time units (for IncrDuration type) 00249 } duration; 00250 00252 static uint commonMultiple(uint op1, uint op2); 00253 }; 00254 00255 #endif /* _MP7TIME_HPP_ */