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;*/
50 class DocClipBase: public QObject {
52 /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
53 * - e.g. if you can have audio and video seperately, it should be possible to combin the two, as is
54 * done here. If a new clip type is added then it should be possible to combine it with both audio
57 DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
58 // DocClipBase & operator=(const DocClipBase & clip);
59 virtual ~ DocClipBase();
61 /** sets the name of this clip. */
62 void setName(const QString name);
64 /** returns the name of this clip. */
65 const QString & name() const;
67 /** Returns the description of this clip. */
68 const QString description() const;
70 /** Returns any property of this clip. */
71 const QString getProperty(const QString prop) const;
72 void setProperty(QString key, QString value);
74 /** Returns the internal unique id of the clip. */
76 void setId(const uint &newId);
78 //KThumb *thumbCreator;
79 bool audioThumbCreated() const;
81 /** returns the duration of this clip */
82 const GenTime & duration() const;
83 const GenTime &maxDuration() const;
84 /** returns the duration of this clip */
85 void setDuration(GenTime dur);
87 /** returns clip type (audio, text, image,...) */
88 const CLIPTYPE & clipType() const;
89 /** set clip type (audio, text, image,...) */
90 void setClipType(CLIPTYPE type);
92 /** remove tmp file if the clip has one (for example text clips) */
93 void removeTmpFile() const;
95 /** Returns a url to a file describing this clip. Exactly what this url is,
96 whether it is temporary or not, and whether it provokes a render will
97 depend entirely on what the clip consists of. */
100 /** Returns true if the clip duration is known, false otherwise. */
101 bool durationKnown() const;
102 // Returns the number of frames per second that this clip should play at.
103 double framesPerSecond() const;
105 bool isDocClipAVFile() const {
109 void setProducer(Mlt::Producer *producer);
110 Mlt::Producer *producer();
112 /*virtual DocClipAVFile *toDocClipAVFile() {
116 virtual DocClipTextFile *toDocClipTextFile() {
120 virtual bool isDocClipTextFile() const {
124 virtual bool isDocClipVirtual() const {
128 virtual DocClipVirtual *toDocClipVirtual() {
132 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
133 * where it returns true. */
134 bool isProjectClip() const {
137 // Appends scene times for this clip to the passed vector.
138 /* virtual void populateSceneTimes(QList < GenTime >
139 &toPopulate) const = 0;*/
141 /** Reads in the element structure and creates a clip out of it.*/
142 // Returns an XML document that describes part of the current scene.
143 QDomDocument sceneToXML(const GenTime & startTime,
144 const GenTime & endTime) const;
145 /** returns a QString containing all of the XML data required to recreate this clip. */
146 QDomElement toXML() const;
148 /** Returns true if the xml passed matches the values in this clip */
149 bool matchesXML(const QDomElement & element) const;
151 void addReference() {
154 void removeReference() {
157 uint numReferences() const {
160 /** Returns true if this clip has a meaningful filesize. */
161 bool hasFileSize() const;
163 /** Returns the filesize, or 0 if there is no appropriate filesize. */
164 uint fileSize() const;
166 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
167 * it uses it as part of it's own composition. */
168 bool referencesClip(DocClipBase * clip) const;
170 /** Sets the thumbnail to be used by this clip */
171 void setThumbnail(const QPixmap & pixmap);
173 /** Returns the thumbnail producer used by this clip */
174 KThumb *thumbProducer();
176 /** Returns the thumbnail used by this clip */
177 const QPixmap & thumbnail() const;
179 static DocClipBase *createClip(KdenliveDoc *doc, const QDomElement & element);
180 /** Cache for every audio Frame with 10 Bytes */
181 /** format is frame -> channel ->bytes */
182 QMap<int, QMap<int, QByteArray> > audioFrameChache;
184 /** Clip is ready to get thumbs */
185 void slotRequestAudioThumbs();
186 /** Free cache data */
187 void slotClearAudioCache();
189 private: // Private attributes
190 /** The name of this clip */
192 /** A description of this clip */
193 QString m_description;
194 /** The number of times this clip is used in the project - the number of references to this clip
197 Mlt::Producer *m_clipProducer;
200 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
201 QList < CommentedTime > m_snapMarkers;
203 /** A thumbnail for this clip */
207 QTimer *m_audioTimer;
209 bool m_audioThumbCreated;
211 /** a unique numeric id */
213 void setAudioThumbCreated(bool isDone);
214 /** Holds clip infos like fps, size,... */
215 QMap <QString, QString> m_properties;
216 /** Create connections for audio thumbnails */
217 void slotCreateAudioTimer();
218 void slotRefreshProducer();
221 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
222 void slotGetAudioThumbs();
223 QList < CommentedTime > commentedSnapMarkers() const;
224 void setSnapMarkers(QList < CommentedTime > markers);
225 GenTime findNextSnapMarker(const GenTime & currTime);
226 GenTime findPreviousSnapMarker(const GenTime & currTime);
227 GenTime hasSnapMarkers(const GenTime & time);
228 QString deleteSnapMarker(const GenTime & time);
229 void editSnapMarker(const GenTime & time, QString comment);
230 void addSnapMarker(const GenTime & time, QString comment);
231 QList < GenTime > snapMarkers() const;
232 QString markerComment(GenTime t);
233 void setClipThumbFrame(const uint &ix);
234 uint getClipThumbFrame() const;
235 void setProperties(QMap <QString, QString> properties);
236 QMap <QString, QString> properties() const;
239 void getAudioThumbs();