]> git.sesse.net Git - kdenlive/blob - src/definitions.h
Merge branch 'master' into audioAlign
[kdenlive] / src / definitions.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef DEFINITIONS_H
22 #define DEFINITIONS_H
23
24 #include "gentime.h"
25 #include "effectslist.h"
26
27 #include <QTreeWidgetItem>
28 #include <KLocale>
29 #include <QDebug>
30
31 const int MAXCLIPDURATION = 15000;
32
33 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
34 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
35
36 enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
37
38 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};
39
40 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
41
42 enum TRANSITIONTYPE {
43     /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
44     LUMA_TRANSITION = 0,
45     COMPOSITE_TRANSITION = 1,
46     PIP_TRANSITION = 2,
47     LUMAFILE_TRANSITION = 3,
48     MIX_TRANSITION = 200
49 };
50
51 enum MessageType {
52     DefaultMessage,
53     OperationCompletedMessage,
54     InformationMessage,
55     ErrorMessage,
56     MltError
57 };
58
59 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
60
61 enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5};
62
63 struct TrackInfo {
64     TRACKTYPE type;
65     QString trackName;
66     bool isMute;
67     bool isBlind;
68     bool isLocked;
69     EffectsList effectsList;
70     int duration;
71 };
72
73 typedef QMap<QString, QString> stringMap;
74 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
75
76 struct ItemInfo {
77     /** startPos is the position where the clip starts on the track */
78     GenTime startPos;
79     /** endPos is the duration where the clip ends on the track */
80     GenTime endPos;
81     /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
82     GenTime cropStart;
83     /** cropDuration is the duration of the clip */
84     GenTime cropDuration;
85     int track;
86 };
87
88 struct MltVideoProfile {
89     QString path;
90     QString description;
91     int frame_rate_num;
92     int frame_rate_den;
93     int width;
94     int height;
95     bool progressive;
96     int sample_aspect_num;
97     int sample_aspect_den;
98     int display_aspect_num;
99     int display_aspect_den;
100     int colorspace;
101     bool operator==(const MltVideoProfile& point) const
102     {
103         if (!description.isEmpty() && point.description  == description) return true;
104         return      point.frame_rate_num == frame_rate_num &&
105                     point.frame_rate_den  == frame_rate_den  &&
106                     point.width == width &&
107                     point.height == height &&
108                     point.progressive == progressive &&
109                     point.sample_aspect_num == sample_aspect_num &&
110                     point.sample_aspect_den == sample_aspect_den &&
111                     point.display_aspect_den == display_aspect_den &&
112                     point.colorspace == colorspace;
113     }
114     bool operator!=(const MltVideoProfile &other) const {
115         return !(*this == other);
116     }
117 };
118
119
120 class EffectParameter
121 {
122 public:
123     EffectParameter(const QString &name, const QString &value): m_name(name), m_value(value) {}
124     QString name()   const          {
125         return m_name;
126     }
127     QString value() const          {
128         return m_value;
129     }
130     void setValue(const QString &value) {
131         m_value = value;
132     }
133
134 private:
135     QString m_name;
136     QString m_value;
137 };
138
139 /** Use our own list for effect parameters so that they are not sorted in any ways, because
140     some effects like sox need a precise order
141 */
142 class EffectsParameterList: public QList < EffectParameter >
143 {
144 public:
145     EffectsParameterList(): QList < EffectParameter >() {}
146     bool hasParam(const QString &name) const {
147         for (int i = 0; i < size(); i++)
148             if (at(i).name() == name) return true;
149         return false;
150     }
151     QString paramValue(const QString &name, QString defaultValue = QString()) const {
152         for (int i = 0; i < size(); i++) {
153             if (at(i).name() == name) return at(i).value();
154         }
155         return defaultValue;
156     }
157     void addParam(const QString &name, const QString &value) {
158         if (name.isEmpty()) return;
159         append(EffectParameter(name, value));
160     }
161     void removeParam(const QString &name) {
162         for (int i = 0; i < size(); i++)
163             if (at(i).name() == name) {
164                 removeAt(i);
165                 break;
166             }
167     }
168 };
169
170 class CommentedTime
171 {
172 public:
173     CommentedTime(): t(GenTime(0)) {}
174     CommentedTime(const GenTime &time, QString comment)
175         : t(time), c(comment) { }
176
177     QString comment()   const          {
178         return (c.isEmpty() ? i18n("Marker") : c);
179     }
180     GenTime time() const          {
181         return t;
182     }
183     void    setComment(QString comm) {
184         c = comm;
185     }
186
187     /* Implementation of > operator; Works identically as with basic types. */
188     bool operator>(CommentedTime op) const {
189         return t > op.time();
190     }
191     /* Implementation of < operator; Works identically as with basic types. */
192     bool operator<(CommentedTime op) const {
193         return t < op.time();
194     }
195     /* Implementation of >= operator; Works identically as with basic types. */
196     bool operator>=(CommentedTime op) const {
197         return t >= op.time();
198     }
199     /* Implementation of <= operator; Works identically as with basic types. */
200     bool operator<=(CommentedTime op) const {
201         return t <= op.time();
202     }
203     /* Implementation of == operator; Works identically as with basic types. */
204     bool operator==(CommentedTime op) const {
205         return t == op.time();
206     }
207     /* Implementation of != operator; Works identically as with basic types. */
208     bool operator!=(CommentedTime op) const {
209         return t != op.time();
210     }
211
212 private:
213     GenTime t;
214     QString c;
215
216
217 };
218
219 QDebug operator << (QDebug qd, const ItemInfo &info);
220
221
222 #endif