ScummVM API documentation
timestamp.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef AUDIO_TIMESTAMP_H
23#define AUDIO_TIMESTAMP_H
24
25#include "common/scummsys.h"
26
27namespace Audio {
28
83class Timestamp {
84public:
91 Timestamp(uint msecs = 0, uint framerate = 1);
92
100 Timestamp(uint secs, uint frames, uint framerate);
101
107 Timestamp convertToFramerate(uint newFramerate) const;
108
116 bool operator==(const Timestamp &ts) const;
120 bool operator!=(const Timestamp &ts) const;
124 bool operator<(const Timestamp &ts) const;
128 bool operator<=(const Timestamp &ts) const;
132 bool operator>(const Timestamp &ts) const;
136 bool operator>=(const Timestamp &ts) const;
137
144 Timestamp addFrames(int frames) const;
145
153
154
162
168 Timestamp operator+(const Timestamp &ts) const;
169
175 Timestamp operator-(const Timestamp &ts) const;
176
183 int frameDiff(const Timestamp &ts) const;
184
186 int msecsDiff(const Timestamp &ts) const;
187
192 int msecs() const;
193
198 inline int secs() const {
199 return _secs;
200 }
201
205 inline int totalNumberOfFrames() const {
207 }
208
214 inline int numberOfFrames() const {
215 return _numFrames / (int)_framerateFactor;
216 }
217
219 inline uint framerate() const { return _framerate / _framerateFactor; }
220
221protected:
226 int cmp(const Timestamp &ts) const;
227
232 void normalize();
233
237 void addIntern(const Timestamp &ts);
238
239protected:
248 int _secs;
249
267
277
283};
284
286} // End of namespace Audio
287
288#endif
Definition: timestamp.h:83
bool operator>(const Timestamp &ts) const
int numberOfFrames() const
Definition: timestamp.h:214
bool operator!=(const Timestamp &ts) const
int cmp(const Timestamp &ts) const
Timestamp(uint secs, uint frames, uint framerate)
Timestamp operator-(const Timestamp &ts) const
uint _framerate
Definition: timestamp.h:276
uint _framerateFactor
Definition: timestamp.h:282
Timestamp operator+(const Timestamp &ts) const
int _numFrames
Definition: timestamp.h:266
int totalNumberOfFrames() const
Definition: timestamp.h:205
void addIntern(const Timestamp &ts)
Timestamp operator-() const
int secs() const
Definition: timestamp.h:198
Timestamp addMsecs(int msecs) const
Timestamp(uint msecs=0, uint framerate=1)
int _secs
Definition: timestamp.h:248
bool operator<=(const Timestamp &ts) const
bool operator<(const Timestamp &ts) const
Timestamp convertToFramerate(uint newFramerate) const
Timestamp addFrames(int frames) const
int msecs() const
uint framerate() const
Definition: timestamp.h:219
bool operator>=(const Timestamp &ts) const
int frameDiff(const Timestamp &ts) const
bool operator==(const Timestamp &ts) const
int msecsDiff(const Timestamp &ts) const
Definition: system.h:39