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, const QString &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;
69 /** Does this clip need a transparent background (e.g. for titles). */
70 bool isTransparent() const;
72 /** Returns any property of this clip. */
73 const QString getProperty(const QString prop) const;
74 void setProperty(const QString &key, const QString &value);
75 void clearProperty(const QString &key);
77 /** Returns the internal unique id of the clip. */
78 const QString &getId() const;
79 void setId(const QString &newId);
81 //KThumb *thumbCreator;
82 bool audioThumbCreated() const;
83 /*void getClipMainThumb();*/
85 /** returns the duration of this clip */
86 const GenTime & duration() const;
87 const GenTime &maxDuration() const;
88 /** returns the duration of this clip */
89 void setDuration(GenTime dur);
91 /** returns clip type (audio, text, image,...) */
92 const CLIPTYPE & clipType() const;
93 /** set clip type (audio, text, image,...) */
94 void setClipType(CLIPTYPE type);
96 /** remove tmp file if the clip has one (for example text clips) */
97 void removeTmpFile() const;
99 /** Returns a url to a file describing this clip. Exactly what this url is,
100 whether it is temporary or not, and whether it provokes a render will
101 depend entirely on what the clip consists of. */
102 KUrl fileURL() const;
104 /** Returns true if the clip duration is known, false otherwise. */
105 bool durationKnown() const;
106 // Returns the number of frames per second that this clip should play at.
107 double framesPerSecond() const;
109 bool isDocClipAVFile() const {
113 void setProducer(Mlt::Producer *producer);
114 Mlt::Producer *producer(int track = -1);
116 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
117 * where it returns true. */
118 bool isProjectClip() const {
122 /** Reads in the element structure and creates a clip out of it.*/
123 // Returns an XML document that describes part of the current scene.
124 QDomDocument sceneToXML(const GenTime & startTime,
125 const GenTime & endTime) const;
126 /** returns a QString containing all of the XML data required to recreate this clip. */
127 QDomElement toXML() const;
129 /** Returns true if the xml passed matches the values in this clip */
130 bool matchesXML(const QDomElement & element) const;
132 void addReference() {
135 void removeReference() {
138 uint numReferences() const {
141 /** Returns true if this clip has a meaningful filesize. */
142 bool hasFileSize() const;
144 /** Returns the filesize, or 0 if there is no appropriate filesize. */
145 uint fileSize() const;
147 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
148 * it uses it as part of it's own composition. */
149 bool referencesClip(DocClipBase * clip) const;
151 /** Sets the thumbnail to be used by this clip */
152 void setThumbnail(const QPixmap & pixmap);
154 /** Returns the thumbnail producer used by this clip */
155 KThumb *thumbProducer();
157 /** Returns the thumbnail used by this clip */
158 const QPixmap & thumbnail() const;
160 static DocClipBase *createClip(KdenliveDoc *doc, const QDomElement & element);
161 /** Cache for every audio Frame with 10 Bytes */
162 /** format is frame -> channel ->bytes */
163 QMap<int, QMap<int, QByteArray> > audioFrameChache;
165 /** Free cache data */
166 void slotClearAudioCache();
167 void askForAudioThumbs();
168 QString getClipHash() const;
169 void refreshThumbUrl();
171 private: // Private attributes
172 /** The name of this clip */
174 /** A description of this clip */
175 QString m_description;
176 /** The number of times this clip is used in the project - the number of references to this clip
179 QList <Mlt::Producer *> m_baseTrackProducers;
182 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
183 QList < CommentedTime > m_snapMarkers;
185 /** A thumbnail for this clip */
189 QTimer *m_audioTimer;
191 bool m_audioThumbCreated;
193 /** a unique numeric id */
195 void setAudioThumbCreated(bool isDone);
196 /** Holds clip infos like fps, size,... */
197 QMap <QString, QString> m_properties;
198 /** Create connections for audio thumbnails */
199 void slotCreateAudioTimer();
200 void slotRefreshProducer();
201 void setProducerProperty(const char *name, const char *data);
202 void setProducerProperty(const char *name, int data);
203 void getFileHash(const QString &url);
206 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
207 bool slotGetAudioThumbs();
208 QList < CommentedTime > commentedSnapMarkers() const;
209 void setSnapMarkers(QList < CommentedTime > markers);
210 GenTime findNextSnapMarker(const GenTime & currTime);
211 GenTime findPreviousSnapMarker(const GenTime & currTime);
212 GenTime hasSnapMarkers(const GenTime & time);
213 QString deleteSnapMarker(const GenTime & time);
214 void editSnapMarker(const GenTime & time, QString comment);
215 void addSnapMarker(const GenTime & time, QString comment);
216 QList < GenTime > snapMarkers() const;
217 QString markerComment(GenTime t);
218 void setClipThumbFrame(const uint &ix);
219 uint getClipThumbFrame() const;
220 void setProperties(QMap <QString, QString> properties);
221 QMap <QString, QString> properties() const;
224 void getAudioThumbs();