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 separately, 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, const QString &id);
58 // DocClipBase & operator=(const DocClipBase & clip);
59 virtual ~ DocClipBase();
61 /** returns the name of this clip. */
62 const QString name() const;
64 /** Returns the description of this clip. */
65 const QString description() const;
66 /** Does this clip need a transparent background (e.g. for titles). */
67 bool isTransparent() const;
69 /** Returns any property of this clip. */
70 const QString getProperty(const QString prop) const;
71 void setProperty(const QString &key, const QString &value);
72 void clearProperty(const QString &key);
74 /** Returns the internal unique id of the clip. */
75 const QString &getId() const;
76 void setId(const QString &newId);
78 //KThumb *thumbCreator;
79 bool audioThumbCreated() const;
80 /*void getClipMainThumb();*/
82 /** returns the duration of this clip */
83 const GenTime & duration() const;
84 const GenTime maxDuration() const;
85 /** returns the duration of this clip */
86 void setDuration(GenTime dur);
88 /** returns clip type (audio, text, image,...) */
89 const CLIPTYPE & clipType() const;
90 /** set clip type (audio, text, image,...) */
91 void setClipType(CLIPTYPE type);
93 /** remove tmp file if the clip has one (for example text clips) */
94 void removeTmpFile() const;
96 /** Returns a url to a file describing this clip. Exactly what this url is,
97 whether it is temporary or not, and whether it provokes a render will
98 depend entirely on what the clip consists of. */
101 /** Returns true if the clip duration is known, false otherwise. */
102 bool durationKnown() const;
103 // Returns the number of frames per second that this clip should play at.
104 double framesPerSecond() const;
106 bool isDocClipAVFile() const {
110 /** Sets producers for the current clip (one for each track due to a limitation in MLT's track mixing */
111 void setProducer(Mlt::Producer *producer);
112 /** Retrieve a producer for a track */
113 Mlt::Producer *producer(int track = -1);
114 /** Retrieve the producer that shows only video */
115 Mlt::Producer *videoProducer();
116 /** Retrieve the producer that shows only audio */
117 Mlt::Producer *audioProducer(int track);
119 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
120 * where it returns true. */
121 bool isProjectClip() const {
125 /** Reads in the element structure and creates a clip out of it.*/
126 // Returns an XML document that describes part of the current scene.
127 QDomDocument sceneToXML(const GenTime & startTime,
128 const GenTime & endTime) const;
129 /** returns a QString containing all of the XML data required to recreate this clip. */
130 QDomElement toXML() const;
132 /** Returns true if the xml passed matches the values in this clip */
133 bool matchesXML(const QDomElement & element) const;
135 void addReference() {
138 void removeReference() {
141 uint numReferences() const {
144 /** Returns true if this clip has a meaningful filesize. */
145 bool hasFileSize() const;
147 /** Returns the filesize, or 0 if there is no appropriate filesize. */
148 uint fileSize() const;
150 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
151 * it uses it as part of it's own composition. */
152 bool referencesClip(DocClipBase * clip) const;
154 /** Sets the thumbnail to be used by this clip */
155 void setThumbnail(const QPixmap & pixmap);
157 /** Returns the thumbnail producer used by this clip */
158 KThumb *thumbProducer();
160 /** Returns the thumbnail used by this clip */
161 const QPixmap & thumbnail() const;
163 /** Cache for every audio Frame with 10 Bytes */
164 /** format is frame -> channel ->bytes */
165 QMap<int, QMap<int, QByteArray> > audioFrameChache;
167 /** Free cache data */
168 void slotClearAudioCache();
169 void askForAudioThumbs();
170 QString getClipHash() const;
171 void refreshThumbUrl();
172 const char *producerProperty(const char *name) const;
173 void setProducerProperty(const char *name, const char *data);
174 void deleteProducers();
176 /** Set default play zone for clip monitor */
177 void setZone(QPoint zone);
178 /** Get default play zone for clip monitor */
181 private: // Private attributes
183 /** A description of this clip */
184 QString m_description;
185 /** The number of times this clip is used in the project - the number of references to this clip
188 QList <Mlt::Producer *> m_baseTrackProducers;
189 QList <Mlt::Producer *> m_audioTrackProducers;
190 Mlt::Producer *m_videoOnlyProducer;
193 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
194 QList < CommentedTime > m_snapMarkers;
196 /** A thumbnail for this clip */
200 QTimer *m_audioTimer;
202 bool m_audioThumbCreated;
204 /** a unique numeric id */
206 void setAudioThumbCreated(bool isDone);
207 /** Holds clip infos like fps, size,... */
208 QMap <QString, QString> m_properties;
209 /** Holds clip metadata like author, copyright,... */
210 QMap <QString, QString> m_metadata;
211 /** Create connections for audio thumbnails */
212 void slotCreateAudioTimer();
213 void slotRefreshProducer();
214 void setProducerProperty(const char *name, int data);
215 void getFileHash(const QString url);
218 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
219 bool slotGetAudioThumbs();
220 QList < CommentedTime > commentedSnapMarkers() const;
221 void setSnapMarkers(QList < CommentedTime > markers);
222 GenTime findNextSnapMarker(const GenTime & currTime);
223 GenTime findPreviousSnapMarker(const GenTime & currTime);
224 GenTime hasSnapMarkers(const GenTime & time);
225 QString deleteSnapMarker(const GenTime & time);
226 void editSnapMarker(const GenTime & time, QString comment);
227 void addSnapMarker(const GenTime & time, QString comment);
228 QList < GenTime > snapMarkers() const;
229 QString markerComment(GenTime t);
230 void setClipThumbFrame(const uint &ix);
231 uint getClipThumbFrame() const;
232 void setProperties(QMap <QString, QString> properties);
233 void setMetadata(QMap <QString, QString> properties);
234 QMap <QString, QString> properties() const;
235 QMap <QString, QString> metadata() const;
239 void getAudioThumbs();