]> git.sesse.net Git - kdenlive/blob - src/docclipbase.h
c85e65a251a28847b2b65ff52f3393f8bf260992
[kdenlive] / src / docclipbase.h
1 /***************************************************************************
2                           docclipbase.h  -  description
3                              -------------------
4     begin                : Fri Apr 12 2002
5     copyright            : (C) 2002 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
18 #ifndef DOCCLIPBASE_H
19 #define DOCCLIPBASE_H
20
21 /**DocClip is a class for the various types of clip
22   *@author Jason Wood
23   */
24
25 #include <qdom.h>
26 #include <QPixmap>
27 #include <QObject>
28 #include <QTimer>
29
30 #include <KUrl>
31
32 #include "gentime.h"
33 #include "definitions.h"
34
35 /*
36 class DocTrackBase;
37 class DocClipAVFile;
38 class DocClipTextFile;
39 class DocClipVirtual;
40 class EffectDescriptionList;*/
41 class KdenliveDoc;
42 class KThumb;
43 class ClipManager;
44
45
46
47
48 class DocClipBase: public QObject {
49 Q_OBJECT public:
50     /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
51      * - e.g. if you can have audio and video seperately, it should be possible to combin the two, as is
52      *   done here. If a new clip type is added then it should be possible to combine it with both audio
53      *   and video. */
54
55     DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
56     DocClipBase(const DocClipBase& clip);
57     DocClipBase & operator=(const DocClipBase & clip);
58     virtual ~ DocClipBase();
59
60     /** sets the name of this clip. */
61     void setName(const QString name);
62
63     /** returns the name of this clip. */
64     const QString & name() const;
65
66     /** Returns the description of this clip. */
67     const QString description() const;
68
69     /** Returns any property of this clip. */
70     const QString getProperty(const QString prop) const;
71     void setProperty(QString key, QString value);
72
73     /** Returns the internal unique id of the clip. */
74     uint getId() const;
75     void setId(const uint &newId);
76
77     //KThumb *thumbCreator;
78     bool audioThumbCreated() const;
79
80     /** returns the duration of this clip */
81     const GenTime & duration() const;
82     const GenTime &maxDuration() const;
83     /** returns the duration of this clip */
84     void setDuration(GenTime dur);
85
86     /** returns clip type (audio, text, image,...) */
87     const CLIPTYPE & clipType() const;
88     /** set clip type (audio, text, image,...) */
89     void setClipType(CLIPTYPE type);
90
91     /** remove tmp file if the clip has one (for example text clips) */
92     void removeTmpFile() const;
93
94     /** Returns a url to a file describing this clip. Exactly what this url is,
95     whether it is temporary or not, and whether it provokes a render will
96     depend entirely on what the clip consists of. */
97     KUrl fileURL() const;
98
99     /** Returns true if the clip duration is known, false otherwise. */
100     bool durationKnown() const;
101     // Returns the number of frames per second that this clip should play at.
102     double framesPerSecond() const;
103
104     bool isDocClipAVFile() const {
105         return false;
106     }
107
108     /*virtual DocClipAVFile *toDocClipAVFile() {
109     return 0;
110     }
111
112     virtual DocClipTextFile *toDocClipTextFile() {
113         return 0;
114     }
115
116     virtual bool isDocClipTextFile() const {
117         return false;
118     }
119
120     virtual bool isDocClipVirtual() const {
121         return false;
122     }
123
124     virtual DocClipVirtual *toDocClipVirtual() {
125         return 0;
126     }*/
127
128     /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
129      * where it returns true. */
130     bool isProjectClip() const {
131         return false;
132     }
133     // Appends scene times for this clip to the passed vector.
134     /* virtual void populateSceneTimes(QList < GenTime >
135      &toPopulate) const = 0;*/
136
137     /** Reads in the element structure and creates a clip out of it.*/
138     // Returns an XML document that describes part of the current scene.
139     QDomDocument sceneToXML(const GenTime & startTime,
140                             const GenTime & endTime) const;
141     /** returns a QString containing all of the XML data required to recreate this clip. */
142     QDomElement toXML() const;
143     QDomDocument generateSceneList(bool addProducers = true, bool rendering = false) const;
144
145     /** Returns true if the xml passed matches the values in this clip */
146     bool matchesXML(const QDomElement & element) const;
147
148     void addReference() {
149         ++m_refcount;
150     }
151     void removeReference() {
152         --m_refcount;
153     }
154     uint numReferences() const {
155         return m_refcount;
156     }
157     /** Returns true if this clip has a meaningful filesize. */
158     bool hasFileSize() const;
159
160     /** Returns the filesize, or 0 if there is no appropriate filesize. */
161     uint fileSize() const;
162
163     /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
164      * it uses it as part of it's own composition. */
165     bool referencesClip(DocClipBase * clip) const;
166
167     /** Sets the thumbnail to be used by this clip */
168     void setThumbnail(const QPixmap & pixmap);
169
170     /** Returns the thumbnail producer used by this clip */
171     KThumb *thumbProducer();
172
173     /** Returns the thumbnail used by this clip */
174     const QPixmap & thumbnail() const;
175
176     static DocClipBase *createClip(KdenliveDoc *doc, const QDomElement & element);
177     /** Cache for every audio Frame with 10 Bytes */
178     /** format is frame -> channel ->bytes */
179     QMap<int, QMap<int, QByteArray> > audioFrameChache;
180
181     /** Clip is ready to get thumbs */
182     void slotRequestAudioThumbs();
183     /** Free cache data */
184     void slotClearAudioCache();
185
186 private:   // Private attributes
187     /** The name of this clip */
188     QString m_name;
189     /** A description of this clip */
190     QString m_description;
191     /** The number of times this clip is used in the project - the number of references to this clip
192      * that exist. */
193     uint m_refcount;
194
195     CLIPTYPE m_clipType;
196
197     /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
198     QList < CommentedTime > m_snapMarkers;
199
200     /** A thumbnail for this clip */
201     QPixmap m_thumbnail;
202     GenTime m_duration;
203
204     QTimer *m_audioTimer;
205     KThumb *m_thumbProd;
206     bool m_audioThumbCreated;
207
208     /** a unique numeric id */
209     uint m_id;
210     void setAudioThumbCreated(bool isDone);
211     /** Holds clip infos like fps, size,... */
212     QMap <QString, QString> m_properties;
213     /** Create connections for audio thumbnails */
214     void slotCreateAudioTimer();
215
216 public slots:
217     void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
218     void slotGetAudioThumbs();
219     QList < CommentedTime > commentedSnapMarkers() const;
220     void setSnapMarkers(QList < CommentedTime > markers);
221     GenTime findNextSnapMarker(const GenTime & currTime);
222     GenTime findPreviousSnapMarker(const GenTime & currTime);
223     GenTime hasSnapMarkers(const GenTime & time);
224     QString deleteSnapMarker(const GenTime & time);
225     void editSnapMarker(const GenTime & time, QString comment);
226     void addSnapMarker(const GenTime & time, QString comment);
227     QList < GenTime > snapMarkers() const;
228     QString markerComment(GenTime t);
229     void setClipThumbFrame(const uint &ix);
230     uint getClipThumbFrame() const;
231     void setProperties(QMap <QString, QString> properties);
232     QMap <QString, QString> properties() const;
233
234 signals:
235     void getAudioThumbs();
236     void gotAudioData();
237 };
238
239 #endif