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 /**Render encapsulates the client side of the interface to a renderer.
35 From Kdenlive's point of view, you treat the Render object as the
36 renderer, and simply use it as if it was local. Calls are asyncrhonous -
37 you send a call out, and then recieve the return value through the
38 relevant signal that get's emitted once the call completes.
43 //class EffectParamDesc;
59 class Render: public QObject {
62 enum FailStates { OK = 0,
66 Render(const QString & rendererName, int winid, int extid, QWidget *parent = 0);
69 /** Seeks the renderer clip to the given time. */
70 void seek(GenTime time);
71 void seekToFrame(int pos);
73 //static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
74 QPixmap getImageThumbnail(KUrl url, int width, int height);
76 /** Return thumbnail for color clip */
77 //void getImage(int id, QString color, QPoint size);
79 // static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
81 /** Return thumbnail for image clip */
82 //void getImage(KUrl url, QPoint size);
84 /** Requests a particular frame from the given file.
86 * The pixmap will be returned by emitting the replyGetImage() signal.
88 //void getImage(KUrl url, int frame, QPoint size);
91 /** Wraps the VEML command of the same name. Sets the current scene list to
93 void setSceneList(QDomDocument list, int position = 0);
94 void setSceneList(QString playlist, int position = 0);
96 void saveSceneList(QString path, QDomElement addedXml = 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, int height);
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 const 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();
143 int resetProfile(QString profile);
144 const double fps() const;
146 /** Playlist manipulation */
147 void mltInsertClip(int track, GenTime position, QDomElement element);
148 void mltCutClip(int track, GenTime position);
149 void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
150 void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
151 void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
152 void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
153 void mltRemoveClip(int track, GenTime position);
154 void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
155 void mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh = true);
156 void mltEditEffect(int track, GenTime position, QMap <QString, QString> args);
157 void mltChangeTrackState(int track, bool mute, bool blind);
158 void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
159 void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
160 void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
161 void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
164 private: // Private attributes & methods
165 /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
167 Mlt::Consumer * m_mltConsumer;
168 Mlt::Producer * m_mltProducer;
169 Mlt::Producer *m_mltTextProducer;
170 Mlt::Filter *m_osdInfo;
171 Mlt::Profile *m_mltProfile;
172 double m_framePosition;
175 bool m_generateScenelist;
178 /** Holds the path to on screen display profile */
179 QString m_osdProfile;
181 QTimer *refreshTimer;
183 QTimer *m_connectTimer;
185 int exportDuration, firstExportFrame, lastExportFrame;
187 /** A human-readable description of this renderer. */
188 QString m_description;
191 /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
192 void sendSeekCommand(GenTime time);
194 /** Sets the description of this renderer to desc. */
195 void setDescription(const QString & description);
197 void mltCheckLength();
198 Mlt::Tractor* getTractor();
199 Mlt::Playlist* getPlaylist(int track);
200 void replaceTimelineTractor(Mlt::Tractor t);
201 private slots: // Private slots
202 /** refresh monitor display */
204 void slotOsdTimeout();
205 void connectPlaylist();
206 //void initSceneList();
209 /** emitted when the renderer recieves a reply to a getFileProperties request. */
210 void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
212 /** emitted when the renderer recieves a reply to a getImage request. */
213 void replyGetImage(int , int, const QPixmap &, int, int);
214 void replyGetImage(int, const QPixmap &, int, int);
216 /** Emitted when the renderer stops, either playing or rendering. */
218 /** Emitted when the renderer starts playing. */
219 void playing(double);
220 /** Emitted when the renderer is rendering. */
221 void rendering(const GenTime &);
222 /** Emitted when rendering has finished */
223 void renderFinished();
224 /** Emitted when the current seek position has been changed by the renderer. */
225 // void positionChanged(const GenTime &);
226 /** Emitted when an error occurs within this renderer. */
227 void error(const QString &, const QString &);
228 void durationChanged(int);
229 void rendererPosition(int);
230 void rendererStopped(int);
233 public slots: // Public slots
234 /** Start Consumer */
240 /** If the file is readable by mlt, return true, otherwise false */
241 bool isValid(KUrl url);
243 /** Wraps the VEML command of the same name. Requests the file properties
244 for the specified url from the renderer. Upon return, the result will be emitted
245 via replyGetFileProperties(). */
246 void getFileProperties(const QDomElement &xml, int clipId);
248 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
249 static char *decodedString(QString str);
250 void mltSavePlaylist();