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;*/
51 class DocClipBase: public QObject
54 /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
55 * - e.g. if you can have audio and video separately, it should be possible to combin the two, as is
56 * done here. If a new clip type is added then it should be possible to combine it with both audio
59 DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id);
60 // DocClipBase & operator=(const DocClipBase & clip);
61 virtual ~ DocClipBase();
63 /** returns the name of this clip. */
64 const QString name() const;
66 /** Returns the description of this clip. */
67 const QString description() const;
68 /** Does this clip need a transparent background (e.g. for titles). */
69 bool isTransparent() const;
71 /** Returns any property of this clip. */
72 const QString getProperty(const QString prop) const;
73 void setProperty(const QString &key, const QString &value);
74 void clearProperty(const QString &key);
76 /** Returns the internal unique id of the clip. */
77 const QString &getId() const;
78 void setId(const QString &newId);
80 //KThumb *thumbCreator;
81 bool audioThumbCreated() const;
82 /*void getClipMainThumb();*/
84 /** returns the duration of this clip */
85 const GenTime & duration() const;
86 const GenTime maxDuration() const;
87 /** returns the duration of this clip */
88 void setDuration(GenTime dur);
90 /** returns clip type (audio, text, image,...) */
91 const CLIPTYPE & clipType() const;
92 /** set clip type (audio, text, image,...) */
93 void setClipType(CLIPTYPE type);
95 /** remove tmp file if the clip has one (for example text clips) */
96 void removeTmpFile() const;
98 /** Returns a url to a file describing this clip. Exactly what this url is,
99 whether it is temporary or not, and whether it provokes a render will
100 depend entirely on what the clip consists of. */
101 KUrl fileURL() const;
103 /** Returns true if the clip duration is known, false otherwise. */
104 bool durationKnown() const;
105 // Returns the number of frames per second that this clip should play at.
106 double framesPerSecond() const;
108 bool isDocClipAVFile() const {
112 /** Sets producers for the current clip (one for each track due to a limitation in MLT's track mixing */
113 void setProducer(Mlt::Producer *producer, bool reset = false);
114 /** Retrieve a producer for a track */
115 Mlt::Producer *producer(int track = -1);
116 /** Retrieve the producer that shows only video */
117 Mlt::Producer *videoProducer();
118 /** Retrieve the producer that shows only audio */
119 Mlt::Producer *audioProducer(int track);
121 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
122 * where it returns true. */
123 bool isProjectClip() const {
127 /** Reads in the element structure and creates a clip out of it.*/
128 // Returns an XML document that describes part of the current scene.
129 QDomDocument sceneToXML(const GenTime & startTime,
130 const GenTime & endTime) const;
131 /** returns a QString containing all of the XML data required to recreate this clip. */
132 QDomElement toXML() const;
134 /** Returns true if the xml passed matches the values in this clip */
135 bool matchesXML(const QDomElement & element) const;
137 void addReference() {
140 void removeReference() {
143 uint numReferences() const {
146 /** Returns true if this clip has a meaningful filesize. */
147 bool hasFileSize() const;
149 /** Returns the filesize, or 0 if there is no appropriate filesize. */
150 uint fileSize() const;
152 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
153 * it uses it as part of it's own composition. */
154 bool referencesClip(DocClipBase * clip) const;
156 /** Sets the thumbnail to be used by this clip */
157 void setThumbnail(const QPixmap & pixmap);
159 /** Returns the thumbnail producer used by this clip */
160 KThumb *thumbProducer();
162 /** Returns the thumbnail used by this clip */
163 const QPixmap & thumbnail() const;
165 /** Cache for every audio Frame with 10 Bytes */
166 /** format is frame -> channel ->bytes */
167 QMap<int, QMap<int, QByteArray> > m_audioFrameCache;
169 /** Free cache data */
170 void slotClearAudioCache();
171 void askForAudioThumbs();
172 QString getClipHash() const;
173 void refreshThumbUrl();
174 const char *producerProperty(const char *name) const;
175 void setProducerProperty(const char *name, const char *data);
176 void deleteProducers();
178 /** Set default play zone for clip monitor */
179 void setZone(QPoint zone);
180 /** Get default play zone for clip monitor */
183 /** Returns true is clip is missing but user wants to keep it as placeholder */
184 bool isPlaceHolder() const;
185 static QString getHash(const QString &path);
187 private: // Private attributes
189 /** The number of times this clip is used in the project - the number of references to this clip
192 QList <Mlt::Producer *> m_baseTrackProducers;
193 QList <Mlt::Producer *> m_audioTrackProducers;
194 Mlt::Producer *m_videoOnlyProducer;
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 */
211 /** Wheter the clip is a placeholder (clip missing but user wants to see it) */
214 void setAudioThumbCreated(bool isDone);
215 /** Holds clip infos like fps, size,... */
216 QMap <QString, QString> m_properties;
217 /** Holds clip metadata like author, copyright,... */
218 QMap <QString, QString> m_metadata;
219 /** Create connections for audio thumbnails */
220 void slotCreateAudioTimer();
221 void slotRefreshProducer();
222 void setProducerProperty(const char *name, int data);
223 void setProducerProperty(const char *name, double data);
224 void getFileHash(const QString url);
227 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
228 bool slotGetAudioThumbs();
229 QList < CommentedTime > commentedSnapMarkers() const;
230 void setSnapMarkers(QList < CommentedTime > markers);
231 GenTime findNextSnapMarker(const GenTime & currTime);
232 GenTime findPreviousSnapMarker(const GenTime & currTime);
233 GenTime hasSnapMarkers(const GenTime & time);
234 QString deleteSnapMarker(const GenTime & time);
235 void editSnapMarker(const GenTime & time, QString comment);
236 void addSnapMarker(const GenTime & time, QString comment);
237 QList < GenTime > snapMarkers() const;
238 QString markerComment(GenTime t);
239 void setClipThumbFrame(const uint &ix);
240 uint getClipThumbFrame() const;
241 void setProperties(QMap <QString, QString> properties);
242 void setMetadata(QMap <QString, QString> properties);
243 QMap <QString, QString> properties() const;
244 QMap <QString, QString> metadata() const;
248 void getAudioThumbs();