-
Notifications
You must be signed in to change notification settings - Fork 13
/
smiltime.h
150 lines (125 loc) · 3.13 KB
/
smiltime.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* smiltime.h -- W3C SMIL2 Time value parser
* Copyright (C) 2003-2008 Dan Dennedy <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _SMILTIME_H
#define _SMILTIME_H
#include <string>
using namespace std;
namespace SMIL
{
class Time
{
public:
typedef enum {
SMIL_TIME_INDEFINITE = 0,
SMIL_TIME_OFFSET,
SMIL_TIME_SYNC_BASED, // not implemented
SMIL_TIME_EVENT_BASED, // not implemented
SMIL_TIME_WALLCLOCK, // not implemented
SMIL_TIME_MEDIA_MARKER, // not implemented
SMIL_TIME_REPEAT, // not implemented
SMIL_TIME_ACCESSKEY, //not implemented
} TimeType;
typedef enum {
TIME_FORMAT_NONE,
TIME_FORMAT_FRAMES,
TIME_FORMAT_SMPTE,
TIME_FORMAT_CLOCK,
TIME_FORMAT_MS,
TIME_FORMAT_S,
TIME_FORMAT_MIN,
TIME_FORMAT_H
} TimeFormat;
protected:
// internally stored in milliseconds
long timeValue;
long offset;
bool indefinite;
bool resolved;
bool syncbaseBegin;
TimeType timeType;
public:
Time();
Time( long time );
Time( string time );
virtual ~Time()
{}
virtual void parseTimeValue( string time );
long getTimeValue()
{
return timeValue;
}
TimeType getTimeType()
{
return timeType;
}
long getOffset()
{
return offset;
}
bool operator< ( Time& time );
bool operator==( Time& time );
bool operator> ( Time& time );
bool isResolved()
{
return resolved;
}
long getResolvedOffset();
bool isNegative();
bool isIndefinite()
{
return indefinite;
}
virtual string toString( TimeFormat format = TIME_FORMAT_CLOCK );
virtual string serialise();
protected:
long parseClockValue( string time );
private:
void setTimeValue( Time& source );
};
class MediaClippingTime : public Time
{
public:
typedef enum {
SMIL_SUBFRAME_NONE,
SMIL_SUBFRAME_0,
SMIL_SUBFRAME_1
} SubframeType;
MediaClippingTime();
MediaClippingTime( float framerate );
MediaClippingTime( string time, float framerate );
virtual ~MediaClippingTime()
{}
void setFramerate( float framerate );
virtual void parseValue( string time );
void parseSmpteValue( string time );
void parseSmpteNtscDropValue( string time );
virtual string toString( TimeFormat format = TIME_FORMAT_SMPTE );
virtual string serialise();
string parseValueToString( string time, TimeFormat format );
string parseFramesToString( int frames, TimeFormat format );
int getFrames();
private:
float m_framerate;
bool m_isSmpteValue;
SubframeType m_subframe;
};
string framesToSmpte( int frames, int fps );
} // namespace
#endif