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 ***************************************************************************/
21 * @brief Client side of the interface to a renderer.
23 * From Kdenlive's point of view, you treat the Render object as the renderer,
24 * and simply use it as if it was local. Calls are asynchronous - you send a
25 * call out, and then receive the return value through the relevant signal that
26 * get's emitted once the call completes.
33 #include "definitions.h"
44 #include "videoglwidget.h"
66 class MltErrorEvent : public QEvent
69 MltErrorEvent(QString message) : QEvent(QEvent::User), m_message(message) {}
70 QString message() const {
78 class Render: public QObject
82 enum FailStates { OK = 0,
86 Render(const QString & rendererName, int winid, int extid, QString profile = QString(), QWidget *parent = 0);
89 /** @brief Seeks the renderer clip to the given time. */
90 void seek(GenTime time);
91 void seekToFrame(int pos);
92 void seekToFrameDiff(int diff);
95 //static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
96 QPixmap getImageThumbnail(KUrl url, int width, int height);
98 /* Return thumbnail for color clip
99 void getImage(int id, QString color, QPoint size);*/
101 // static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
103 /* Return thumbnail for image clip
104 void getImage(KUrl url, QPoint size);*/
106 /* Requests a particular frame from the given file.
108 * The pixmap will be returned by emitting the replyGetImage() signal.
109 void getImage(KUrl url, int frame, QPoint size);*/
111 int setSceneList(QDomDocument list, int position = 0);
113 /** @brief Sets the current scene list.
114 * @param list new scene list
115 * @param position (optional) time to seek to
116 * @return 0 when it has success, different from 0 otherwise
118 * Creates the producer from the MLT XML QDomDocument. Wraps the VEML
119 * command of the same name. */
120 int setSceneList(QString playlist, int position = 0);
121 int setProducer(Mlt::Producer *producer, int position);
122 const QString sceneList();
123 bool saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
125 /** @brief Tells the renderer to play the scene at the specified speed,
126 * @param speed speed to play the scene to
128 * The speed is relative to normal playback, e.g. 1.0 is normal speed, 0.0
129 * is paused, -1.0 means play backwards. It does not specify start/stop
130 * times for playback. Wraps the VEML command of the same name. */
131 void play(double speed);
135 /** @brief Stops playing.
136 * @param startTime time to seek to */
137 void stop(const GenTime & startTime);
138 void setVolume(double volume);
140 QImage extractFrame(int frame_position, int width = -1, int height = -1);
142 /** @brief Plays the scene starting from a specific time.
143 * @param startTime time to start playing the scene from
145 * Wraps the VEML command of the same name. */
146 void play(const GenTime & startTime);
147 void playZone(const GenTime & startTime, const GenTime & stopTime);
148 void loopZone(const GenTime & startTime, const GenTime & stopTime);
150 void saveZone(KUrl url, QString desc, QPoint zone);
152 /** @brief Returns the name of the renderer. */
153 const QString & rendererName() const;
155 /** @brief Returns the speed at which the renderer is currently playing.
157 * It returns 0.0 when the renderer is not playing anything. */
160 /** @brief Returns the current seek position of the renderer. */
161 GenTime seekPosition() const;
162 int seekFramePosition() const;
164 void emitFrameNumber(double position);
165 void emitConsumerStopped();
167 /** @brief Returns the aspect ratio of the consumer. */
168 double consumerRatio() const;
172 /** @brief Saves current producer frame as an image. */
173 void exportCurrentFrame(KUrl url, bool notify);
175 /** @brief Turns on or off on screen display. */
176 void refreshDisplay();
177 int resetProfile(const QString profileName);
179 int renderWidth() const;
180 int renderHeight() const;
182 /** @brief Returns display aspect ratio. */
186 * Playlist manipulation.
188 Mlt::Producer *checkSlowMotionProducer(Mlt::Producer *prod, QDomElement element);
189 int mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod, bool overwrite = false, bool push = false);
190 bool mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
191 void mltCutClip(int track, GenTime position);
192 void mltInsertSpace(QMap <int, int> trackClipStartList, QMap <int, int> trackTransitionStartList, int track, const GenTime duration, const GenTime timeOffset);
193 int mltGetSpaceLength(const GenTime pos, int track, bool fromBlankStart);
194 int mltTrackDuration(int track);
195 bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration);
196 bool mltResizeClipStart(ItemInfo info, GenTime diff);
197 bool mltResizeClipCrop(ItemInfo info, GenTime diff);
198 bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod, bool overwrite = false, bool insert = false);
199 bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart, Mlt::Producer *prod, bool overwrite = false, bool insert = false);
200 bool mltRemoveClip(int track, GenTime position);
202 /** @brief Deletes an effect from a clip in MLT's playlist. */
203 bool mltRemoveEffect(int track, GenTime position, QString index, bool updateIndex, bool doRefresh = true);
205 /** @brief Adds an effect to a clip in MLT's playlist. */
206 bool mltAddEffect(int track, GenTime position, EffectsParameterList params, bool doRefresh = true);
208 /** @brief Edits an effect parameters in MLT's playlist. */
209 bool mltEditEffect(int track, GenTime position, EffectsParameterList params);
211 /** @brief Updates the "kdenlive_ix" (index) value of an effect. */
212 void mltUpdateEffectPosition(int track, GenTime position, int oldPos, int newPos);
214 /** @brief Changes the order of effects in MLT's playlist.
216 * It switches effects from oldPos and newPos, updating the "kdenlive_ix"
218 void mltMoveEffect(int track, GenTime position, int oldPos, int newPos);
220 /** @brief Enables/disables audio/video in a track. */
221 void mltChangeTrackState(int track, bool mute, bool blind);
222 bool mltMoveTransition(QString type, int startTrack, int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
223 bool mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
224 void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
225 void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool force = false);
226 void mltUpdateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
227 void mltAddClipTransparency(ItemInfo info, int transitiontrack, int id);
228 void mltMoveTransparency(int startTime, int endTime, int startTrack, int endTrack, int id);
229 void mltDeleteTransparency(int pos, int track, int id);
230 void mltResizeTransparency(int oldStart, int newStart, int newEnd, int track, int id);
231 void mltInsertTrack(int ix, bool videoTrack);
232 void mltDeleteTrack(int ix);
233 bool mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod);
234 void mltPlantTransition(Mlt::Field *field, Mlt::Transition &tr, int a_track, int b_track);
235 Mlt::Producer *invalidProducer(const QString &id);
237 /** @brief Changes the speed of a clip in MLT's playlist.
239 * It creates a new "framebuffer" producer, which must have its "resource"
240 * property set to "video.mpg?0.6", where "video.mpg" is the path to the
241 * clip and "0.6" is the speed in percentile. The newly created producer
242 * will have its "id" property set to "slowmotion:parentid:speed", where
243 * "parentid" is the id of the original clip in the ClipManager list and
244 * "speed" is the current speed. */
245 int mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, double speed, double oldspeed, int strobe, Mlt::Producer *prod);
247 const QList <Mlt::Producer *> producersList();
248 void updatePreviewSettings();
249 void setDropFrames(bool show);
250 QString updateSceneListFps(double current_fps, double new_fps, QString scene);
252 void showFrame(Mlt::Frame&);
254 QList <int> checkTrackSequence(int);
258 /** @brief The name of this renderer.
260 * Useful to identify the renderers by what they do - e.g. background
261 * rendering, workspace monitor, etc. */
263 Mlt::Consumer * m_mltConsumer;
264 Mlt::Producer * m_mltProducer;
265 Mlt::Profile *m_mltProfile;
266 double m_framePosition;
269 /** @brief True if we are playing a zone.
271 * It's determined by the "in" and "out" properties being temporarily
278 /** @brief True when the monitor is in split view. */
281 Mlt::Producer *m_blackClip;
282 QString m_activeProfile;
286 /** @brief A human-readable description of this renderer. */
290 VideoGLWidget *m_glWidget;
293 void mltCheckLength(Mlt::Tractor *tractor);
294 void mltPasteEffects(Mlt::Producer *source, Mlt::Producer *dest);
295 QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
296 QMap<QString, Mlt::Producer *> m_slowmotionProducers;
297 void buildConsumer(const QString profileName);
298 void resetZoneMode();
299 void fillSlowMotionProducers();
303 /** @brief Refreshes the monitor display. */
305 void slotOsdTimeout();
306 int connectPlaylist();
307 //void initSceneList();
311 /** @brief The renderer received a reply to a getFileProperties request. */
312 void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool);
314 /** @brief The renderer received a reply to a getImage request. */
315 void replyGetImage(const QString &, const QPixmap &);
317 /** @brief The renderer stopped, either playing or rendering. */
320 /** @brief The renderer started playing. */
321 void playing(double);
323 /** @brief The renderer started rendering. */
324 void rendering(const GenTime &);
326 /** @brief The rendering has finished. */
327 void renderFinished();
329 /* @brief The current seek position has been changed by the renderer.
330 void positionChanged(const GenTime &);*/
332 /** @brief An error occurred within this renderer. */
333 void error(const QString &, const QString &);
334 void durationChanged(int);
335 void rendererPosition(int);
336 void rendererStopped(int);
337 void removeInvalidClip(const QString &, bool replaceProducer);
338 void refreshDocumentProducers();
340 /** @brief A frame's image has to be shown.
342 * Used in Mac OS X. */
343 void showImageSignal(QImage);
347 /** @brief Starts the consumer. */
350 /** @brief Stops the consumer. */
354 /** @brief Checks if the file is readable by MLT. */
355 bool isValid(KUrl url);
357 /** @brief Requests the file properties for the specified URL.
359 * Upon return, the result will be emitted via replyGetFileProperties().
360 * Wraps the VEML command of the same name. */
361 void getFileProperties(const QDomElement xml, const QString &clipId, int imageHeight, bool replaceProducer = true);
363 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
364 static char *decodedString(QString str);
365 void mltSavePlaylist();
366 void slotSplitView(bool doit);
367 void slotSwitchFullscreen();