]> git.sesse.net Git - kdenlive/blob - src/timecode.h
Starting KDE4 porting
[kdenlive] / src / timecode.h
1 /***************************************************************************
2                         timecode  -  description
3                            -------------------
4   begin                : Wed Dec 17 2003
5   copyright            : (C) 2003 by Jason Wood
6   email                : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 #ifndef TIMECODE_H
18 #define TIMECODE_H
19
20 #include <qstring.h>
21
22 #include "gentime.h"
23
24 /**
25 Handles the conversion of a GenTime into a nicely formatted string, taking into account things such as drop frame if necessary. Handles multiple formats, such as HH:MM:SS:FF, HH:MM:SS:F, All Frames, All Seconds, etc.
26
27 @author Jason Wood
28 */
29 class Timecode {
30   public:
31     enum Formats { HH_MM_SS_FF, HH_MM_SS_HH, Frames, Seconds };
32
33      Timecode(Formats format = HH_MM_SS_FF, int framesPerSecond =
34         25, bool dropFrame = false);
35
36         /** Set the current timecode format; this is the output format for this timecode. */
37     void setFormat(int framesPerSecond, bool dropFrame = false, Formats format = HH_MM_SS_FF) {
38         m_displayedFramesPerSecond = framesPerSecond;
39         m_dropFrame = dropFrame;
40         m_format = format;
41     } 
42
43     Formats format() const {
44         return m_format;
45     } 
46
47     ~Timecode();
48
49         /** Returns the timecode for a given time */
50     QString getTimecode(const GenTime & time, double fps) const;
51     int getFrameNumber(const QString duration, double fps) const;
52     static QString getEasyTimecode(const GenTime & time, const double &fps);
53     QString getTimecodeFromFrames(int frames);
54   private:
55     Formats m_format;
56     bool m_dropFrame;
57     int m_displayedFramesPerSecond;
58
59     QString getTimecodeHH_MM_SS_FF(const GenTime & time, double fps) const;
60     QString getTimecodeHH_MM_SS_FF(int frames) const;
61     QString getTimecodeHH_MM_SS_HH(const GenTime & time) const;
62     QString getTimecodeFrames(const GenTime & time, double fps) const;
63     QString getTimecodeSeconds(const GenTime & time) const;
64     QString getTimecodeDropFrame(const GenTime & time, double fps) const;
65 };
66
67 #endif