]> 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 <KLocale>
28 #include <QDebug>
29
30 #include <QTreeWidgetItem>
31  #include <QtCore/QString>
32
33 const int MAXCLIPDURATION = 15000;
34
35 namespace Kdenlive {
36   enum MONITORID { noMonitor, clipMonitor, projectMonitor, recordMonitor, stopmotionMonitor, dvdMonitor };
37   /*const QString clipMonitor("clipMonitor");
38   const QString recordMonitor("recordMonitor");
39   const QString projectMonitor("projectMonitor");
40   const QString stopmotionMonitor("stopmotionMonitor");*/
41 }
42
43 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};
44 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
45
46 enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
47
48 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};
49
50 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
51
52 enum TRANSITIONTYPE {
53     /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
54     LUMA_TRANSITION = 0,
55     COMPOSITE_TRANSITION = 1,
56     PIP_TRANSITION = 2,
57     LUMAFILE_TRANSITION = 3,
58     MIX_TRANSITION = 200
59 };
60
61 enum MessageType {
62     DefaultMessage,
63     OperationCompletedMessage,
64     InformationMessage,
65     ErrorMessage,
66     MltError
67 };
68
69 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
70
71 enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5};
72
73 struct TrackInfo {
74     TRACKTYPE type;
75     QString trackName;
76     bool isMute;
77     bool isBlind;
78     bool isLocked;
79     EffectsList effectsList;
80     int duration;
81 };
82
83 typedef QMap<QString, QString> stringMap;
84 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
85
86 struct ItemInfo {
87     /** startPos is the position where the clip starts on the track */
88     GenTime startPos;
89     /** endPos is the duration where the clip ends on the track */
90     GenTime endPos;
91     /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
92     GenTime cropStart;
93     /** cropDuration is the duration of the clip */
94     GenTime cropDuration;
95     int track;
96 };
97
98 struct TransitionInfo {
99 /** startPos is the position where the clip starts on the track */
100     GenTime startPos;
101     /** endPos is the duration where the clip ends on the track */
102     GenTime endPos;
103     /** the track on which the transition is (b_track)*/
104     int b_track;
105     /** the track on which the transition is applied (a_track)*/
106     int a_track;
107     /** Does the user request for a special a_track */
108     bool forceTrack;
109 };
110
111 struct MltVideoProfile {
112     QString path;
113     QString description;
114     int frame_rate_num;
115     int frame_rate_den;
116     int width;
117     int height;
118     bool progressive;
119     int sample_aspect_num;
120     int sample_aspect_den;
121     int display_aspect_num;
122     int display_aspect_den;
123     int colorspace;
124     bool operator==(const MltVideoProfile& point) const
125     {
126         if (!description.isEmpty() && point.description  == description) return true;
127         return      point.frame_rate_num == frame_rate_num &&
128                     point.frame_rate_den  == frame_rate_den  &&
129                     point.width == width &&
130                     point.height == height &&
131                     point.progressive == progressive &&
132                     point.sample_aspect_num == sample_aspect_num &&
133                     point.sample_aspect_den == sample_aspect_den &&
134                     point.display_aspect_den == display_aspect_den &&
135                     point.colorspace == colorspace;
136     }
137     bool operator!=(const MltVideoProfile &other) const {
138         return !(*this == other);
139     }
140 };
141
142 /**)
143  * @class EffectInfo
144  * @brief A class holding some meta info for effects widgets, like state (collapsed or not, ...)
145  * @author Jean-Baptiste Mardelle
146  */
147
148 class EffectInfo
149 {
150 public:
151     EffectInfo() {isCollapsed = false; groupIndex = -1;}
152     bool isCollapsed;
153     int groupIndex;
154     QString groupName;
155     QString toString() const {
156         QStringList data;
157         data << QString::number(isCollapsed) << QString::number(groupIndex) << groupName;
158         return data.join("/");
159     }
160     void fromString(QString value) {
161         if (value.isEmpty()) return;
162         QStringList data = value.split("/");
163         isCollapsed = data.at(0).toInt();
164         if (data.count() > 1) groupIndex = data.at(1).toInt();
165         if (data.count() > 2) groupName = data.at(2);
166     }
167 };
168
169 class EffectParameter
170 {
171 public:
172     EffectParameter(const QString &name, const QString &value): m_name(name), m_value(value) {}
173     QString name()   const          {
174         return m_name;
175     }
176     QString value() const          {
177         return m_value;
178     }
179     void setValue(const QString &value) {
180         m_value = value;
181     }
182
183 private:
184     QString m_name;
185     QString m_value;
186 };
187
188 /** Use our own list for effect parameters so that they are not sorted in any ways, because
189     some effects like sox need a precise order
190 */
191 class EffectsParameterList: public QList < EffectParameter >
192 {
193 public:
194     EffectsParameterList(): QList < EffectParameter >() {}
195     bool hasParam(const QString &name) const {
196         for (int i = 0; i < size(); i++)
197             if (at(i).name() == name) return true;
198         return false;
199     }
200     QString paramValue(const QString &name, QString defaultValue = QString()) const {
201         for (int i = 0; i < size(); i++) {
202             if (at(i).name() == name) return at(i).value();
203         }
204         return defaultValue;
205     }
206     void addParam(const QString &name, const QString &value) {
207         if (name.isEmpty()) return;
208         append(EffectParameter(name, value));
209     }
210     void removeParam(const QString &name) {
211         for (int i = 0; i < size(); i++)
212             if (at(i).name() == name) {
213                 removeAt(i);
214                 break;
215             }
216     }
217 };
218
219 class CommentedTime
220 {
221 public:
222     CommentedTime(): t(GenTime(0)) {}
223     CommentedTime(const GenTime &time, QString comment)
224         : t(time), c(comment) { }
225
226     QString comment()   const          {
227         return (c.isEmpty() ? i18n("Marker") : c);
228     }
229     GenTime time() const          {
230         return t;
231     }
232     void    setComment(QString comm) {
233         c = comm;
234     }
235
236     /* Implementation of > operator; Works identically as with basic types. */
237     bool operator>(CommentedTime op) const {
238         return t > op.time();
239     }
240     /* Implementation of < operator; Works identically as with basic types. */
241     bool operator<(CommentedTime op) const {
242         return t < op.time();
243     }
244     /* Implementation of >= operator; Works identically as with basic types. */
245     bool operator>=(CommentedTime op) const {
246         return t >= op.time();
247     }
248     /* Implementation of <= operator; Works identically as with basic types. */
249     bool operator<=(CommentedTime op) const {
250         return t <= op.time();
251     }
252     /* Implementation of == operator; Works identically as with basic types. */
253     bool operator==(CommentedTime op) const {
254         return t == op.time();
255     }
256     /* Implementation of != operator; Works identically as with basic types. */
257     bool operator!=(CommentedTime op) const {
258         return t != op.time();
259     }
260
261 private:
262     GenTime t;
263     QString c;
264
265
266 };
267
268 QDebug operator << (QDebug qd, const ItemInfo &info);
269
270
271 #endif