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, QWidget *parent = 0);
69 /** Wraps the VEML command of the same name; requests that the renderer
70 should create a video window. If show is true, then the window should be
71 displayed, otherwise it should be hidden. Render will emit the signal
72 replyCreateVideoXWindow() once the renderer has replied. */
73 void createVideoXWindow(WId winid, WId externalMonitor);
74 /** Seeks the renderer clip to the given time. */
75 void seek(GenTime time);
76 void seekToFrame(int pos);
78 static QPixmap getVideoThumbnail(QString file, int frame, int width, int height);
79 QPixmap getImageThumbnail(KUrl url, int width, int height);
81 /** Return thumbnail for color clip */
82 //void getImage(int id, QString color, QPoint size);
84 static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
86 /** Return thumbnail for image clip */
87 //void getImage(KUrl url, QPoint size);
89 /** Requests a particular frame from the given file.
91 * The pixmap will be returned by emitting the replyGetImage() signal.
93 //void getImage(KUrl url, int frame, QPoint size);
96 /** Wraps the VEML command of the same name. Sets the current scene list to
98 void setSceneList(QDomDocument list, int position = 0);
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);
118 /** Wraps the VEML command of the same name - render the currently
119 specified sceneList - set with setSceneList() - to the document
121 void render(const KUrl & url);
123 /** Returns the description of this renderer */
124 QString description();
126 /** Returns the name of the renderer. */
127 const QString & rendererName() const;
129 /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
130 not playing anything. */
132 /** Returns the current seek position of the renderer. */
133 const GenTime & seekPosition() const;
135 void emitFrameNumber(double position);
136 void emitConsumerStopped();
138 /** Gives the aspect ratio of the consumer */
139 double consumerRatio() const;
141 /** Gives the aspect ratio of the consumer */
142 void askForRefresh();
144 /** Save current producer frame as image */
145 void exportCurrentFrame(KUrl url, bool notify);
147 /** Turn on or off on screen display */
148 void refreshDisplay();
149 /** returns the current scenelist */
150 QDomDocument sceneList() const;
151 int resetRendererProfile(char * profile);
153 const double fps() const;
155 /** Playlist manipulation */
156 void mltInsertClip(int track, GenTime position, QString resource);
157 void mltCutClip(int track, GenTime position);
158 void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
159 void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
160 void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
161 void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
162 void mltRemoveClip(int track, GenTime position);
163 void mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index);
164 void mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args);
165 void mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args);
166 void mltChangeTrackState(int track, bool mute, bool blind);
167 void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
168 void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
171 private: // Private attributes & methods
172 /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
174 Mlt::Consumer * m_mltConsumer;
175 Mlt::Producer * m_mltProducer;
176 Mlt::Producer *m_mltTextProducer;
177 Mlt::Filter *m_osdInfo;
178 double m_framePosition;
181 bool m_generateScenelist;
183 /** Holds the path to on screen display profile */
184 QString m_osdProfile;
186 QTimer *refreshTimer;
188 QTimer *m_connectTimer;
190 int exportDuration, firstExportFrame, lastExportFrame;
192 /** Holds the scenelist to be sent, if pending. */
193 QDomDocument m_sceneList;
195 /** A human-readable description of this renderer. */
196 QString m_description;
199 /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
200 void sendSeekCommand(GenTime time);
202 /** Sets the description of this renderer to desc. */
203 void setDescription(const QString & description);
205 void mltCheckLength();
207 private slots: // Private slots
208 /** refresh monitor display */
210 void slotOsdTimeout();
211 void restartConsumer();
212 void connectPlaylist();
213 void initSceneList();
216 /** This signal is emitted once a reply to createVideoXWidow() has been recieved. */
217 void replyCreateVideoXWindow(WId);
218 /** emitted when the renderer recieves a reply to a getFileProperties request. */
219 void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
221 /** emitted when the renderer recieves a reply to a getImage request. */
222 void replyGetImage(int , int, const QPixmap &, int, int);
223 void replyGetImage(int, const QPixmap &, int, int);
225 /** Emitted when the renderer stops, either playing or rendering. */
227 /** Emitted when the renderer starts playing. */
228 void playing(double);
229 /** Emitted when the renderer is rendering. */
230 void rendering(const GenTime &);
231 /** Emitted when rendering has finished */
232 void renderFinished();
233 /** Emitted when the current seek position has been changed by the renderer. */
234 // void positionChanged(const GenTime &);
235 /** Emitted when an error occurs within this renderer. */
236 void error(const QString &, const QString &);
237 void durationChanged();
238 void playListDuration(int);
239 void rendererPosition(int);
240 void rendererStopped(int);
243 public slots: // Public slots
244 /** Start Consumer */
250 /** If the file is readable by mlt, return true, otherwise false */
251 bool isValid(KUrl url);
253 /** Wraps the VEML command of the same name. Requests the file properties
254 for the specified url from the renderer. Upon return, the result will be emitted
255 via replyGetFileProperties(). */
256 void getFileProperties(const QDomElement &xml, int clipId);
258 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
259 static char *decodedString(QString str);
260 void mltSavePlaylist();