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;*/
56 class DocClipBase: public QObject
59 /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
60 * - e.g. if you can have audio and video separately, it should be possible to combin the two, as is
61 * done here. If a new clip type is added then it should be possible to combine it with both audio
64 DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id);
65 // DocClipBase & operator=(const DocClipBase & clip);
66 virtual ~ DocClipBase();
68 /** returns the name of this clip. */
69 const QString name() const;
71 /** Returns the description of this clip. */
72 const QString description() const;
73 /** Does this clip need a transparent background (e.g. for titles). */
74 bool isTransparent() const;
76 /** Returns any property of this clip. */
77 const QString getProperty(const QString prop) const;
78 void setProperty(const QString &key, const QString &value);
79 void clearProperty(const QString &key);
81 /** Returns the internal unique id of the clip. */
82 const QString &getId() const;
83 void setId(const QString &newId);
85 //KThumb *thumbCreator;
86 bool audioThumbCreated() const;
87 /*void getClipMainThumb();*/
89 /** returns the duration of this clip */
90 const GenTime & duration() const;
91 const GenTime maxDuration() const;
92 /** returns the duration of this clip */
93 void setDuration(GenTime dur);
95 /** returns clip type (audio, text, image,...) */
96 const CLIPTYPE & clipType() const;
97 /** set clip type (audio, text, image,...) */
98 void setClipType(CLIPTYPE type);
100 /** remove tmp file if the clip has one (for example text clips) */
101 void removeTmpFile() const;
103 /** Returns a url to a file describing this clip. Exactly what this url is,
104 whether it is temporary or not, and whether it provokes a render will
105 depend entirely on what the clip consists of. */
106 KUrl fileURL() const;
108 /** Returns true if the clip duration is known, false otherwise. */
109 bool durationKnown() const;
110 // Returns the number of frames per second that this clip should play at.
111 double framesPerSecond() const;
113 bool isDocClipAVFile() const {
117 /** Sets producers for the current clip (one for each track due to a limitation in MLT's track mixing */
118 void setProducer(Mlt::Producer *producer, bool reset = false);
119 /** Retrieve a producer for a track */
120 Mlt::Producer *producer(int track = -1);
121 /** Retrieve the producer that shows only video */
122 Mlt::Producer *videoProducer();
123 /** Retrieve the producer that shows only audio */
124 Mlt::Producer *audioProducer(int track);
126 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
127 * where it returns true. */
128 bool isProjectClip() const {
132 /** Reads in the element structure and creates a clip out of it.*/
133 // Returns an XML document that describes part of the current scene.
134 QDomDocument sceneToXML(const GenTime & startTime,
135 const GenTime & endTime) const;
136 /** returns a QString containing all of the XML data required to recreate this clip. */
137 QDomElement toXML() const;
139 /** Returns true if the xml passed matches the values in this clip */
140 bool matchesXML(const QDomElement & element) const;
142 void addReference() {
145 void removeReference() {
148 uint numReferences() const {
151 /** Returns true if this clip has a meaningful filesize. */
152 bool hasFileSize() const;
154 /** Returns the filesize, or 0 if there is no appropriate filesize. */
155 qulonglong fileSize() const;
157 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
158 * it uses it as part of it's own composition. */
159 bool referencesClip(DocClipBase * clip) const;
161 /** Sets the thumbnail to be used by this clip */
162 void setThumbnail(const QPixmap & pixmap);
164 /** Returns the thumbnail producer used by this clip */
165 KThumb *thumbProducer();
167 /** Returns the thumbnail used by this clip */
168 const QPixmap & thumbnail() const;
170 /** Cache for every audio Frame with 10 Bytes */
171 /** format is frame -> channel ->bytes */
172 QMap<int, QMap<int, QByteArray> > m_audioFrameCache;
174 /** Free cache data */
175 void slotClearAudioCache();
176 void askForAudioThumbs();
177 QString getClipHash() const;
178 void refreshThumbUrl();
179 const char *producerProperty(const char *name) const;
180 void setProducerProperty(const char *name, const char *data);
181 void resetProducerProperty(const char *name);
182 void clearProducers();
183 void deleteProducers();
185 /** Set default play zone for clip monitor */
186 void setZone(QPoint zone);
187 /** Get default play zone for clip monitor */
190 /** Returns true is clip is missing but user wants to keep it as placeholder */
191 bool isPlaceHolder() const;
192 static QString getHash(const QString &path);
194 void addCutZone(int in, int out, QString desc = QString());
195 bool hasCutZone(QPoint p) const;
196 void removeCutZone(int in, int out);
197 QList <CutZoneInfo> cutZones() const;
198 void updateCutZone(int oldin, int oldout, int in, int out, QString desc = QString());
200 bool hasVideoCodec(const QString &codec) const;
201 bool hasAudioCodec(const QString &codec) const;
203 private: // Private attributes
205 /** The number of times this clip is used in the project - the number of references to this clip
208 QList <Mlt::Producer *> m_baseTrackProducers;
209 QList <Mlt::Producer *> m_audioTrackProducers;
210 Mlt::Producer *m_videoOnlyProducer;
213 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
214 QList < CommentedTime > m_snapMarkers;
216 /** A thumbnail for this clip */
220 QTimer *m_audioTimer;
222 bool m_audioThumbCreated;
224 /** a unique numeric id */
227 /** Wheter the clip is a placeholder (clip missing but user wants to see it) */
230 QList <CutZoneInfo> m_cutZones;
232 void setAudioThumbCreated(bool isDone);
233 /** Holds clip infos like fps, size,... */
234 QMap <QString, QString> m_properties;
235 /** Holds clip metadata like author, copyright,... */
236 QMap <QString, QString> m_metadata;
237 /** Create connections for audio thumbnails */
238 void slotCreateAudioTimer();
239 void slotRefreshProducer();
240 void setProducerProperty(const char *name, int data);
241 void setProducerProperty(const char *name, double data);
242 void getFileHash(const QString url);
245 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
246 bool slotGetAudioThumbs();
247 QList < CommentedTime > commentedSnapMarkers() const;
248 void setSnapMarkers(QList < CommentedTime > markers);
249 GenTime findNextSnapMarker(const GenTime & currTime);
250 GenTime findPreviousSnapMarker(const GenTime & currTime);
251 GenTime hasSnapMarkers(const GenTime & time);
252 QString deleteSnapMarker(const GenTime & time);
253 void editSnapMarker(const GenTime & time, QString comment);
254 void addSnapMarker(const GenTime & time, QString comment);
255 QList < GenTime > snapMarkers() const;
256 QString markerComment(GenTime t);
257 void setClipThumbFrame(const uint &ix);
258 uint getClipThumbFrame() const;
259 void setProperties(QMap <QString, QString> properties);
260 void setMetadata(QMap <QString, QString> properties);
261 QMap <QString, QString> properties() const;
262 QMap <QString, QString> metadata() const;
266 void getAudioThumbs();