00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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,
00038 SMIL_TIME_EVENT_BASED,
00039 SMIL_TIME_WALLCLOCK,
00040 SMIL_TIME_MEDIA_MARKER,
00041 SMIL_TIME_REPEAT,
00042 SMIL_TIME_ACCESSKEY,
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
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 }
00148
00149 #endif