1 /***************************************************************************
2 krender.h - description
4 begin : Fri Nov 22 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 ***************************************************************************/
30 #include "definitions.h"
32 /**Render encapsulates the client side of the interface to a renderer.
33 From Kdenlive's point of view, you treat the Render object as the
34 renderer, and simply use it as if it was local. Calls are asyncrhonous -
35 you send a call out, and then recieve the return value through the
36 relevant signal that get's emitted once the call completes.
41 //class EffectParamDesc;
57 class Render: public QObject {
60 enum FailStates { OK = 0,
64 Render(const QString & rendererName, int winid, int extid, QWidget *parent = 0);
67 /** Seeks the renderer clip to the given time. */
68 void seek(GenTime time);
69 void seekToFrame(int pos);
72 //static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
73 QPixmap getImageThumbnail(KUrl url, int width, int height);
75 /** Return thumbnail for color clip */
76 //void getImage(int id, QString color, QPoint size);
78 // static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
80 /** Return thumbnail for image clip */
81 //void getImage(KUrl url, QPoint size);
83 /** Requests a particular frame from the given file.
85 * The pixmap will be returned by emitting the replyGetImage() signal.
87 //void getImage(KUrl url, int frame, QPoint size);
90 /** Wraps the VEML command of the same name. Sets the current scene list to
92 void setSceneList(QDomDocument list, int position = 0);
93 void setSceneList(QString playlist, int position = 0);
94 void setProducer(Mlt::Producer *producer, int position);
96 void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
98 /** Wraps the VEML command of the same name. Tells the renderer to
99 play the current scene at the speed specified, relative to normal
100 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
101 backwards. Does not specify start/stop times for playback.*/
102 void play(double speed);
105 void stop(const GenTime & startTime);
106 void setVolume(double volume);
108 QPixmap extractFrame(int frame_position, int width = -1, int height = -1);
109 /** Wraps the VEML command of the same name. Tells the renderer to
110 play the current scene at the speed specified, relative to normal
111 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
112 backwards. Specifes the start/stop times for playback.*/
113 void play(double speed, const GenTime & startTime);
114 void play(double speed, const GenTime & startTime,
115 const GenTime & stopTime);
117 /** Returns the description of this renderer */
118 QString description();
120 /** Returns the name of the renderer. */
121 const QString & rendererName() const;
123 /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
124 not playing anything. */
126 /** Returns the current seek position of the renderer. */
127 GenTime seekPosition() const;
129 void emitFrameNumber(double position);
130 void emitConsumerStopped();
132 /** Gives the aspect ratio of the consumer */
133 double consumerRatio() const;
135 void askForRefresh();
138 /** Save current producer frame as image */
139 void exportCurrentFrame(KUrl url, bool notify);
141 /** Turn on or off on screen display */
142 void refreshDisplay();
144 const double fps() const;
145 const int renderWidth() const;
146 const int renderHeight() const;
147 /** get display aspect ratio */
148 const double dar() const;
150 /** Playlist manipulation */
151 void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
152 void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
153 void mltCutClip(int track, GenTime position);
154 bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration);
155 bool mltResizeClipStart(ItemInfo info, GenTime diff);
156 bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
157 bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
158 bool mltRemoveClip(int track, GenTime position);
159 bool mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
160 bool mltAddEffect(int track, GenTime position, QHash <QString, QString> args, bool doRefresh = true);
161 bool mltEditEffect(int track, GenTime position, QHash <QString, QString> args);
162 void mltMoveEffect(int track, GenTime position, int oldPos, int newPos);
163 void mltChangeTrackState(int track, bool mute, bool blind);
164 void mltMoveTransition(QString type, int startTrack, int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
165 void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
166 void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
167 void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
168 void mltUpdateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
169 void mltAddClipTransparency(ItemInfo info, int transitiontrack, int id);
170 void mltMoveTransparency(int startTime, int endTime, int startTrack, int endTrack, int id);
171 void mltDeleteTransparency(int pos, int track, int id);
172 void mltResizeTransparency(int oldStart, int newStart, int newEnd, int track, int id);
174 /** Change speed of a clip in playlist. To do this, we create a new "framebuffer" producer.
175 This new producer must have its "resource" param set to: video.mpg?0.6 where video.mpg is the path
176 to the clip and 0.6 is the speed in percents. The newly created producer will have it's
177 "id" parameter set to: "slowmotion:parentid:speed", where parentid is the id of the original clip
178 in the ClipManager list and speed is the current speed */
179 int mltChangeClipSpeed(ItemInfo info, double speed, Mlt::Producer *prod);
181 private: // Private attributes & methods
182 /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
184 Mlt::Consumer * m_mltConsumer;
185 Mlt::Producer * m_mltProducer;
186 Mlt::Producer *m_mltTextProducer;
187 Mlt::Filter *m_osdInfo;
188 Mlt::Profile *m_mltProfile;
189 double m_framePosition;
192 bool m_generateScenelist;
193 /** true when monitor is in split view (several tracks at the same time) */
196 Mlt::Producer *m_blackClip;
197 /** Holds the path to on screen display profile */
198 QString m_osdProfile;
200 QTimer *refreshTimer;
203 int exportDuration, firstExportFrame, lastExportFrame;
205 /** A human-readable description of this renderer. */
206 QString m_description;
209 /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
210 void sendSeekCommand(GenTime time);
212 /** Sets the description of this renderer to desc. */
213 void setDescription(const QString & description);
215 void mltCheckLength(bool reload = true);
216 QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
217 QMap<QString, Mlt::Producer *> m_slowmotionProducers;
218 void buildConsumer();
220 private slots: // Private slots
221 /** refresh monitor display */
223 void slotOsdTimeout();
224 void connectPlaylist();
225 //void initSceneList();
228 /** emitted when the renderer recieves a reply to a getFileProperties request. */
229 void replyGetFileProperties(int clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &);
231 /** emitted when the renderer recieves a reply to a getImage request. */
232 void replyGetImage(int , int, const QPixmap &, int, int);
233 void replyGetImage(int, const QPixmap &, int, int);
235 /** Emitted when the renderer stops, either playing or rendering. */
237 /** Emitted when the renderer starts playing. */
238 void playing(double);
239 /** Emitted when the renderer is rendering. */
240 void rendering(const GenTime &);
241 /** Emitted when rendering has finished */
242 void renderFinished();
243 /** Emitted when the current seek position has been changed by the renderer. */
244 // void positionChanged(const GenTime &);
245 /** Emitted when an error occurs within this renderer. */
246 void error(const QString &, const QString &);
247 void durationChanged(int);
248 void rendererPosition(int);
249 void rendererStopped(int);
250 void removeInvalidClip(int);
252 public slots: // Public slots
253 /** Start Consumer */
259 /** If the file is readable by mlt, return true, otherwise false */
260 bool isValid(KUrl url);
262 /** Wraps the VEML command of the same name. Requests the file properties
263 for the specified url from the renderer. Upon return, the result will be emitted
264 via replyGetFileProperties(). */
265 void getFileProperties(const QDomElement &xml, int clipId);
267 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
268 static char *decodedString(QString str);
269 void mltSavePlaylist();
270 void slotSplitView(bool doit);