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 "kthumb.h"
38 class DocClipTextFile;
40 class EffectDescriptionList;*/
46 CommentedTime(): t(GenTime(0)) {}
47 CommentedTime( const GenTime time, QString comment)
48 : t( time ), c( comment )
51 QString comment() const { return (c.isEmpty() ? i18n("Marker") : c);}
52 GenTime time() const { return t; }
53 void setComment( QString comm) { c = comm; }
60 class DocClipBase:public QObject {
62 /** this enum determines the types of "feed" available within this clip. types must be non-exclusive
63 * - e.g. if you can have audio and video seperately, it should be possible to combin the two, as is
64 * done here. If a new clip type is added then it should be possible to combine it with both audio
66 enum CLIPTYPE { NONE = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR =
67 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9};
70 virtual ~ DocClipBase();
72 /** sets the name of this clip. */
73 void setName(const QString name);
75 /** returns the name of this clip. */
76 const QString & name() const;
78 /** Sets the description for this clip. */
79 void setDescription(const QString & descripton);
81 /** Returns the description of this clip. */
82 const QString & description() const;
84 /** Returns the internal unique id of the clip. */
86 void setId( const uint &newId);
88 //KThumb *thumbCreator;
89 bool audioThumbCreated;
91 /** returns the duration of this clip */
92 virtual const GenTime & duration() const = 0;
94 /** returns clip type (audio, text, image,...) */
95 virtual const DocClipBase::CLIPTYPE & clipType() const = 0;
97 /** remove tmp file if the clip has one (for example text clips) */
98 virtual void removeTmpFile() const = 0;
100 /** Returns a url to a file describing this clip. Exactly what this url is,
101 whether it is temporary or not, and whether it provokes a render will
102 depend entirely on what the clip consists of. */
103 virtual const KUrl & fileURL() const = 0;
105 /** Returns true if the clip duration is known, false otherwise. */
106 virtual bool durationKnown() const = 0;
107 // Returns the number of frames per second that this clip should play at.
108 virtual double framesPerSecond() const = 0;
110 virtual bool isDocClipAVFile() const {
114 /*virtual DocClipAVFile *toDocClipAVFile() {
118 virtual DocClipTextFile *toDocClipTextFile() {
122 virtual bool isDocClipTextFile() const {
126 virtual bool isDocClipVirtual() const {
130 virtual DocClipVirtual *toDocClipVirtual() {
134 /** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
135 * where it returns true. */
136 virtual bool isProjectClip() const {
139 // Appends scene times for this clip to the passed vector.
140 /* virtual void populateSceneTimes(QList < GenTime >
141 &toPopulate) const = 0;*/
143 /** Reads in the element structure and creates a clip out of it.*/
144 // Returns an XML document that describes part of the current scene.
145 virtual QDomDocument sceneToXML(const GenTime & startTime,
146 const GenTime & endTime) const = 0;
147 /** returns a QString containing all of the XML data required to recreate this clip. */
148 virtual QDomDocument toXML() const;
149 virtual QDomDocument generateSceneList(bool addProducers = true, bool rendering = false) const;
151 /** Returns true if the xml passed matches the values in this clip */
152 virtual bool matchesXML(const QDomElement & element) const = 0;
154 void addReference() {
157 void removeReference() {
160 uint numReferences() const {
163 /** Returns true if this clip has a meaningful filesize. */
164 virtual bool hasFileSize() const = 0;
166 /** Returns the filesize, or 0 if there is no appropriate filesize. */
167 virtual uint fileSize() const = 0;
169 /** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
170 * it uses it as part of it's own composition. */
171 virtual bool referencesClip(DocClipBase * clip) const = 0;
173 /** Sets the thumbnail to be used by this clip */
174 void setThumbnail(const QPixmap & pixmap);
176 /** Returns the thumbnail used by this clip */
177 const QPixmap & thumbnail() const;
179 static DocClipBase *createClip(KdenliveDoc *doc, const QDomElement & element);
180 /** Cache for every audio Frame with 10 Bytes */
181 /** format is frame -> channel ->bytes */
182 QMap<int,QMap<int,QByteArray> > audioFrameChache;
184 /** return english name for clip type */
185 static QString getTypeName(CLIPTYPE type);
187 private: // Private attributes
188 /** The name of this clip */
190 /** A description of this clip */
191 QString m_description;
192 /** The number of times this clip is used in the project - the number of references to this clip
196 /** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
197 QList < CommentedTime > m_snapMarkers;
200 /** A thumbnail for this clip */
203 /** a unique numeric id */
205 uint m_projectThumbFrame;
206 void setAudioThumbCreated(bool isDone);
209 void updateAudioThumbnail(QMap<int,QMap<int,QByteArray> > data);
210 QList < CommentedTime > commentedSnapMarkers() const;
211 void setSnapMarkers(QList < CommentedTime > markers);
212 GenTime findNextSnapMarker(const GenTime & currTime);
213 GenTime findPreviousSnapMarker(const GenTime & currTime);
214 GenTime hasSnapMarkers(const GenTime & time);
215 QString deleteSnapMarker(const GenTime & time);
216 void editSnapMarker(const GenTime & time, QString comment);
217 void addSnapMarker(const GenTime & time, QString comment);
218 QList < GenTime > snapMarkers() const;
219 QString markerComment(GenTime t);
220 void setProjectThumbFrame( const uint &ix);
221 uint getProjectThumbFrame() const;