Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

smiltime.h

Go to the documentation of this file.
00001 /*
00002 * smiltime.h -- W3C SMIL2 Time value parser
00003 * Copyright (C) 2003-2007 Dan Dennedy <dan@dennedy.org>
00004 *
00005 * This program is free software; you can redistribute it and/or modify
00006 * it under the terms of the GNU General Public License as published by
00007 * the Free Software Foundation; either version 2 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 General Public License for more details.
00014 *
00015 * You should have received a copy of the GNU General Public License
00016 * along with this program; if not, write to the Free Software Foundation,
00017 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 *
00019 */
00020 
00021 #ifndef _SMILTIME_H
00022 #define _SMILTIME_H
00023 
00024 #include <string>
00025 
00026 using namespace std;
00027 
00028 namespace SMIL
00029 {
00030 
00031 class Time
00032 {
00033 public:
00034     typedef enum {
00035         SMIL_TIME_INDEFINITE = 0,
00036         SMIL_TIME_OFFSET,
00037         SMIL_TIME_SYNC_BASED,    // not implemented
00038         SMIL_TIME_EVENT_BASED,    // not implemented
00039         SMIL_TIME_WALLCLOCK,    // not implemented
00040         SMIL_TIME_MEDIA_MARKER,    // not implemented
00041         SMIL_TIME_REPEAT,     // not implemented
00042         SMIL_TIME_ACCESSKEY,    //not implemented
00043     } TimeType;
00044 
00045     typedef enum {
00046         TIME_FORMAT_NONE = 0,
00047         TIME_FORMAT_FRAMES,
00048         TIME_FORMAT_SMPTE,
00049         TIME_FORMAT_CLOCK,
00050         TIME_FORMAT_MS,
00051         TIME_FORMAT_S,
00052         TIME_FORMAT_MIN,
00053         TIME_FORMAT_H
00054     } TimeFormat;
00055 
00056 
00057 protected:
00058     // internally stored in milliseconds
00059     long timeValue;
00060     long offset;
00061     bool indefinite;
00062     bool resolved;
00063     bool syncbaseBegin;
00064     TimeType timeType;
00065 
00066 public:
00067     Time();
00068     Time( long time );
00069     Time( string time );
00070     virtual ~Time()
00071     {}
00072         
00073     virtual void parseTimeValue( string time );
00074         
00075     long getTimeValue()
00076     {
00077         return timeValue;
00078     }
00079     TimeType getTimeType()
00080     {
00081         return timeType;
00082     }
00083     long getOffset()
00084     {
00085         return offset;
00086     }
00087 
00088     bool operator< ( Time& time );
00089     bool operator==( Time& time );
00090     bool operator> ( Time& time );
00091     bool isResolved()
00092     {
00093         return resolved;
00094     }
00095     long getResolvedOffset();
00096     bool isNegative();
00097     bool isIndefinite()
00098     {
00099         return indefinite;
00100     }
00101     virtual string toString( TimeFormat format = TIME_FORMAT_CLOCK );
00102     virtual string serialise();
00103 
00104 protected:
00105     long parseClockValue( string time );
00106     
00107 
00108 private:
00109     void setTimeValue( Time& source );
00110 
00111 };
00112 
00113 
00114 class MediaClippingTime : public Time
00115 {
00116 public:
00117     typedef enum {
00118         SMIL_SUBFRAME_NONE,
00119         SMIL_SUBFRAME_0,
00120         SMIL_SUBFRAME_1
00121     } SubframeType;
00122 
00123     MediaClippingTime();
00124     MediaClippingTime( float framerate );
00125     MediaClippingTime( string time, float framerate );
00126     virtual ~MediaClippingTime()
00127     {}
00128     void setFramerate( float framerate );
00129     virtual void parseValue( string time );
00130     void parseSmpteValue( string time );
00131         
00132     virtual string toString( TimeFormat format = TIME_FORMAT_SMPTE );
00133     virtual string serialise();
00134     
00135     string parseValueToString( string time, TimeFormat format );
00136     string parseFramesToString( int frames, TimeFormat format );
00137     int getFrames();
00138 
00139 private:
00140     float m_framerate;
00141     bool m_isSmpteValue;
00142     SubframeType m_subframe;
00143 };
00144 
00145 string framesToSmpte( int frames, int fps );
00146 
00147 } // namespace
00148 
00149 #endif

Generated on Sun Mar 11 22:11:47 2007 for Kino by  doxygen 1.4.2