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
34 #include "definitions.h"
39 class DocClipTextFile;
41 class EffectDescriptionList;*/
48 CommentedTime(): t(GenTime(0)) {}
49 CommentedTime(const GenTime time, QString comment)
50 : t(time), c(comment) { }
52 QString comment() const {
53 return (c.isEmpty() ? i18n("Marker") : c);
55 GenTime time() const {
58 void setComment(QString comm) {
67 class DocClipBase: public QObject {
69 /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
70 * - e.g. if you can have audio and video seperately, it should be possible to combin the two, as is
71 * done here. If a new clip type is added then it should be possible to combine it with both audio
74 DocClipBase(ClipManager *clipManager, QDomElement xml, uint id);
75 DocClipBase(const DocClipBase& clip);
76 DocClipBase & operator=(const DocClipBase & clip);
77 virtual ~ DocClipBase();
79 /** sets the name of this clip. */
80 void setName(const QString name);
82 /** returns the name of this clip. */
83 const QString & name() const;
85 /** Returns the description of this clip. */
86 const QString description() const;
88 /** Returns the internal unique id of the clip. */
90 void setId(const uint &newId);
92 //KThumb *thumbCreator;
93 bool audioThumbCreated() const;
95 /** returns the duration of this clip */
96 const GenTime & duration() const;
97 /** returns the duration of this clip */
98 void setDuration(GenTime dur);
100 /** returns clip type (audio, text, image,...) */
101 const CLIPTYPE & clipType() const;
102 /** set clip type (audio, text, image,...) */
103 void setClipType(CLIPTYPE type);
105 /** remove tmp file if the clip has one (for example text clips) */
106 void removeTmpFile() const;
108 /** Returns a url to a file describing this clip. Exactly what this url is,
109 whether it is temporary or not, and whether it provokes a render will
110 depend entirely on what the clip consists of. */
111 KUrl fileURL() const;
113 /** Returns true if the clip duration is known, false otherwise. */
114 bool durationKnown() const;
115 // Returns the number of frames per second that this clip should play at.
116 double framesPerSecond() const;
118 bool isDocClipAVFile() const {
122 /*virtual DocClipAVFile *toDocClipAVFile() {
126 virtual DocClipTextFile *toDocClipTextFile() {
130 virtual bool isDocClipTextFile() const {
134 virtual bool isDocClipVirtual() const {
138 virtual DocClipVirtual *toDocClipVirtual() {
142 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
143 * where it returns true. */
144 bool isProjectClip() const {
147 // Appends scene times for this clip to the passed vector.
148 /* virtual void populateSceneTimes(QList < GenTime >
149 &toPopulate) const = 0;*/
151 /** Reads in the element structure and creates a clip out of it.*/
152 // Returns an XML document that describes part of the current scene.
153 QDomDocument sceneToXML(const GenTime & startTime,
154 const GenTime & endTime) const;
155 /** returns a QString containing all of the XML data required to recreate this clip. */
156 QDomElement toXML() const;
157 QDomDocument generateSceneList(bool addProducers = true, bool rendering = false) const;
159 /** Returns true if the xml passed matches the values in this clip */
160 bool matchesXML(const QDomElement & element) const;
162 void addReference() {
165 void removeReference() {
168 uint numReferences() const {
171 /** Returns true if this clip has a meaningful filesize. */
172 bool hasFileSize() const;
174 /** Returns the filesize, or 0 if there is no appropriate filesize. */
175 uint fileSize() const;
177 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
178 * it uses it as part of it's own composition. */
179 bool referencesClip(DocClipBase * clip) const;
181 /** Sets the thumbnail to be used by this clip */
182 void setThumbnail(const QPixmap & pixmap);
184 /** Returns the thumbnail producer used by this clip */
185 KThumb *thumbProducer();
187 /** Returns the thumbnail used by this clip */
188 const QPixmap & thumbnail() const;
190 static DocClipBase *createClip(KdenliveDoc *doc, const QDomElement & element);
191 /** Cache for every audio Frame with 10 Bytes */
192 /** format is frame -> channel ->bytes */
193 QMap<int, QMap<int, QByteArray> > audioFrameChache;
195 /** Clip is ready to get thumbs */
196 void slotRequestAudioThumbs();
197 /** Free cache data */
198 void slotClearAudioCache();
200 private: // Private attributes
201 /** The name of this clip */
203 /** A description of this clip */
204 QString m_description;
205 /** The number of times this clip is used in the project - the number of references to this clip
211 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
212 QList < CommentedTime > m_snapMarkers;
214 /** A thumbnail for this clip */
218 QTimer *m_audioTimer;
220 bool m_audioThumbCreated;
222 /** a unique numeric id */
224 uint m_projectThumbFrame;
225 void setAudioThumbCreated(bool isDone);
226 /** Holds clip infos like fps, size,... */
227 QMap <QString, QString> m_properties;
228 /** Create connections for audio thumbnails */
229 void slotCreateAudioTimer();
232 void updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data);
233 void slotGetAudioThumbs();
234 QList < CommentedTime > commentedSnapMarkers() const;
235 void setSnapMarkers(QList < CommentedTime > markers);
236 GenTime findNextSnapMarker(const GenTime & currTime);
237 GenTime findPreviousSnapMarker(const GenTime & currTime);
238 GenTime hasSnapMarkers(const GenTime & time);
239 QString deleteSnapMarker(const GenTime & time);
240 void editSnapMarker(const GenTime & time, QString comment);
241 void addSnapMarker(const GenTime & time, QString comment);
242 QList < GenTime > snapMarkers() const;
243 QString markerComment(GenTime t);
244 void setProjectThumbFrame(const uint &ix);
245 uint getProjectThumbFrame() const;
246 void setProperties(QMap <QString, QString> properties);
247 QMap <QString, QString> properties() const;
250 void getAudioThumbs();