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 "docclipref.h"
31 #include "effectdesc.h"
32 #include "effectparamdescfactory.h"*/
34 #include <mlt++/Mlt.h>
36 /**Render encapsulates the client side of the interface to a renderer.
37 From Kdenlive's point of view, you treat the Render object as the
38 renderer, and simply use it as if it was local. Calls are asyncrhonous -
39 you send a call out, and then recieve the return value through the
40 relevant signal that get's emitted once the call completes.
45 //class EffectParamDesc;
61 class Render: public QObject {
64 enum FailStates { OK = 0,
68 Render(const QString & rendererName, int winid, int extid, QWidget *parent = 0);
71 /** Seeks the renderer clip to the given time. */
72 void seek(GenTime time);
73 void seekToFrame(int pos);
75 //static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
76 QPixmap getImageThumbnail(KUrl url, int width, int height);
78 /** Return thumbnail for color clip */
79 //void getImage(int id, QString color, QPoint size);
81 // static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
83 /** Return thumbnail for image clip */
84 //void getImage(KUrl url, QPoint size);
86 /** Requests a particular frame from the given file.
88 * The pixmap will be returned by emitting the replyGetImage() signal.
90 //void getImage(KUrl url, int frame, QPoint size);
93 /** Wraps the VEML command of the same name. Sets the current scene list to
95 void setSceneList(QDomDocument list, int position = 0);
96 void setSceneList(QString playlist, int position = 0);
98 void saveSceneList(QString path, QDomElement addedXml = QDomElement());
100 /** Wraps the VEML command of the same name. Tells the renderer to
101 play the current scene at the speed specified, relative to normal
102 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
103 backwards. Does not specify start/stop times for playback.*/
104 void play(double speed);
107 void stop(const GenTime & startTime);
108 void setVolume(double volume);
110 QPixmap extractFrame(int frame_position, int width, int height);
111 /** Wraps the VEML command of the same name. Tells the renderer to
112 play the current scene at the speed specified, relative to normal
113 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
114 backwards. Specifes the start/stop times for playback.*/
115 void play(double speed, const GenTime & startTime);
116 void play(double speed, const GenTime & startTime,
117 const GenTime & stopTime);
119 /** Returns the description of this renderer */
120 QString description();
122 /** Returns the name of the renderer. */
123 const QString & rendererName() const;
125 /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
126 not playing anything. */
128 /** Returns the current seek position of the renderer. */
129 const GenTime & seekPosition() const;
131 void emitFrameNumber(double position);
132 void emitConsumerStopped();
134 /** Gives the aspect ratio of the consumer */
135 double consumerRatio() const;
137 void askForRefresh();
140 /** Save current producer frame as image */
141 void exportCurrentFrame(KUrl url, bool notify);
143 /** Turn on or off on screen display */
144 void refreshDisplay();
145 int resetProfile(QString profile);
146 const double fps() const;
148 /** Playlist manipulation */
149 void mltInsertClip(int track, GenTime position, QDomElement element);
150 void mltCutClip(int track, GenTime position);
151 void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
152 void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
153 void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
154 void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
155 void mltRemoveClip(int track, GenTime position);
156 void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
157 void mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh = true);
158 void mltEditEffect(int track, GenTime position, QMap <QString, QString> args);
159 void mltChangeTrackState(int track, bool mute, bool blind);
160 void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
161 void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
162 void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
163 void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
166 private: // Private attributes & methods
167 /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
169 Mlt::Consumer * m_mltConsumer;
170 Mlt::Producer * m_mltProducer;
171 Mlt::Producer *m_mltTextProducer;
172 Mlt::Filter *m_osdInfo;
173 Mlt::Profile *m_mltProfile;
174 double m_framePosition;
177 bool m_generateScenelist;
180 /** Holds the path to on screen display profile */
181 QString m_osdProfile;
183 QTimer *refreshTimer;
185 QTimer *m_connectTimer;
187 int exportDuration, firstExportFrame, lastExportFrame;
189 /** A human-readable description of this renderer. */
190 QString m_description;
193 /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
194 void sendSeekCommand(GenTime time);
196 /** Sets the description of this renderer to desc. */
197 void setDescription(const QString & description);
199 void mltCheckLength();
200 mlt_tractor getTractor();
201 mlt_playlist getPlaylist(int track);
202 void replaceTimelineTractor(Mlt::Tractor t);
203 private slots: // Private slots
204 /** refresh monitor display */
206 void slotOsdTimeout();
207 void connectPlaylist();
208 //void initSceneList();
211 /** emitted when the renderer recieves a reply to a getFileProperties request. */
212 void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
214 /** emitted when the renderer recieves a reply to a getImage request. */
215 void replyGetImage(int , int, const QPixmap &, int, int);
216 void replyGetImage(int, const QPixmap &, int, int);
218 /** Emitted when the renderer stops, either playing or rendering. */
220 /** Emitted when the renderer starts playing. */
221 void playing(double);
222 /** Emitted when the renderer is rendering. */
223 void rendering(const GenTime &);
224 /** Emitted when rendering has finished */
225 void renderFinished();
226 /** Emitted when the current seek position has been changed by the renderer. */
227 // void positionChanged(const GenTime &);
228 /** Emitted when an error occurs within this renderer. */
229 void error(const QString &, const QString &);
230 void durationChanged(int);
231 void rendererPosition(int);
232 void rendererStopped(int);
235 public slots: // Public slots
236 /** Start Consumer */
242 /** If the file is readable by mlt, return true, otherwise false */
243 bool isValid(KUrl url);
245 /** Wraps the VEML command of the same name. Requests the file properties
246 for the specified url from the renderer. Upon return, the result will be emitted
247 via replyGetFileProperties(). */
248 void getFileProperties(const QDomElement &xml, int clipId);
250 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
251 static char *decodedString(QString str);
252 void mltSavePlaylist();