1 /***************************************************************************
2 docclipbase.h - description
4 begin : Fri Apr 12 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
21 /**DocClip is a class for the various types of clip
33 #include "definitions.h"
38 class DocClipTextFile;
40 class EffectDescriptionList;*/
48 class DocClipBase: public QObject {
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
55 DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
56 DocClipBase(const DocClipBase& clip);
57 DocClipBase & operator=(const DocClipBase & clip);
58 virtual ~ DocClipBase();
60 /** sets the name of this clip. */
61 void setName(const QString name);
63 /** returns the name of this clip. */
64 const QString & name() const;
66 /** Returns the description of this clip. */
67 const QString description() const;
69 /** Returns any property of this clip. */
70 const QString getProperty(const QString prop) const;
71 void setProperty(QString key, QString value);
73 /** Returns the internal unique id of the clip. */
75 void setId(const uint &newId);
77 //KThumb *thumbCreator;
78 bool audioThumbCreated() const;
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);
86 /** returns clip type (audio, text, image,...) */
87 const CLIPTYPE & clipType() const;
88 /** set clip type (audio, text, image,...) */
89 void setClipType(CLIPTYPE type);
91 /** remove tmp file if the clip has one (for example text clips) */
92 void removeTmpFile() const;
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. */
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;
104 bool isDocClipAVFile() const {
108 /*virtual DocClipAVFile *toDocClipAVFile() {
112 virtual DocClipTextFile *toDocClipTextFile() {
116 virtual bool isDocClipTextFile() const {
120 virtual bool isDocClipVirtual() const {
124 virtual DocClipVirtual *toDocClipVirtual() {
128 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
129 * where it returns true. */
130 bool isProjectClip() const {
133 // Appends scene times for this clip to the passed vector.
134 /* virtual void populateSceneTimes(QList < GenTime >
135 &toPopulate) const = 0;*/
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;
145 /** Returns true if the xml passed matches the values in this clip */
146 bool matchesXML(const QDomElement & element) const;
148 void addReference() {
151 void removeReference() {
154 uint numReferences() const {
157 /** Returns true if this clip has a meaningful filesize. */
158 bool hasFileSize() const;
160 /** Returns the filesize, or 0 if there is no appropriate filesize. */
161 uint fileSize() const;
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;
167 /** Sets the thumbnail to be used by this clip */
168 void setThumbnail(const QPixmap & pixmap);
170 /** Returns the thumbnail producer used by this clip */
171 KThumb *thumbProducer();
173 /** Returns the thumbnail used by this clip */
174 const QPixmap & thumbnail() const;
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;
181 /** Clip is ready to get thumbs */
182 void slotRequestAudioThumbs();
183 /** Free cache data */
184 void slotClearAudioCache();
186 private: // Private attributes
187 /** The name of this clip */
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
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;
200 /** A thumbnail for this clip */
204 QTimer *m_audioTimer;
206 bool m_audioThumbCreated;
208 /** a unique numeric 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();
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;
235 void getAudioThumbs();