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 /** Wraps the VEML command of the same name; requests that the renderer
72 should create a video window. If show is true, then the window should be
73 displayed, otherwise it should be hidden. Render will emit the signal
74 replyCreateVideoXWindow() once the renderer has replied. */
75 void createVideoXWindow(WId winid, WId externalMonitor);
76 /** Seeks the renderer clip to the given time. */
77 void seek(GenTime time);
78 void seekToFrame(int pos);
80 static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
81 QPixmap getImageThumbnail(KUrl url, int width, int height);
83 /** Return thumbnail for color clip */
84 //void getImage(int id, QString color, QPoint size);
86 static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
88 /** Return thumbnail for image clip */
89 //void getImage(KUrl url, QPoint size);
91 /** Requests a particular frame from the given file.
93 * The pixmap will be returned by emitting the replyGetImage() signal.
95 //void getImage(KUrl url, int frame, QPoint size);
98 /** Wraps the VEML command of the same name. Sets the current scene list to
100 void setSceneList(QDomDocument list, int position = 0);
102 /** Wraps the VEML command of the same name. Tells the renderer to
103 play the current scene at the speed specified, relative to normal
104 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
105 backwards. Does not specify start/stop times for playback.*/
106 void play(double speed);
109 void stop(const GenTime & startTime);
110 void setVolume(double volume);
112 QPixmap extractFrame(int frame_position, int width, int height);
113 /** Wraps the VEML command of the same name. Tells the renderer to
114 play the current scene at the speed specified, relative to normal
115 playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
116 backwards. Specifes the start/stop times for playback.*/
117 void play(double speed, const GenTime & startTime);
118 void play(double speed, const GenTime & startTime,
119 const GenTime & stopTime);
120 /** Wraps the VEML command of the same name - render the currently
121 specified sceneList - set with setSceneList() - to the document
123 void render(const KUrl & url);
125 /** Returns the description of this renderer */
126 QString description();
128 /** Returns the name of the renderer. */
129 const QString & rendererName() const;
131 /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
132 not playing anything. */
134 /** Returns the current seek position of the renderer. */
135 const GenTime & seekPosition() const;
137 void emitFrameNumber(double position);
138 void emitConsumerStopped();
140 /** Gives the aspect ratio of the consumer */
141 double consumerRatio() const;
143 /** Gives the aspect ratio of the consumer */
144 void askForRefresh();
146 /** Save current producer frame as image */
147 void exportCurrentFrame(KUrl url, bool notify);
149 /** Turn on or off on screen display */
150 void refreshDisplay();
151 /** returns the current scenelist */
152 QDomDocument sceneList() const;
153 int resetRendererProfile(char * profile);
155 const double fps() const;
157 /** Playlist manipulation */
158 void mltInsertClip(int track, GenTime position, QDomElement element);
159 void mltCutClip(int track, GenTime position);
160 void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
161 void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
162 void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
163 void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
164 void mltRemoveClip(int track, GenTime position);
165 void mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index);
166 void mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args);
167 void mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args);
168 void mltChangeTrackState(int track, bool mute, bool blind);
169 void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
170 void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
173 private: // Private attributes & methods
174 /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
176 Mlt::Consumer * m_mltConsumer;
177 Mlt::Producer * m_mltProducer;
178 Mlt::Producer *m_mltTextProducer;
179 Mlt::Filter *m_osdInfo;
180 Mlt::Profile *m_mltProfile;
181 double m_framePosition;
184 bool m_generateScenelist;
186 /** Holds the path to on screen display profile */
187 QString m_osdProfile;
189 QTimer *refreshTimer;
191 QTimer *m_connectTimer;
193 int exportDuration, firstExportFrame, lastExportFrame;
195 /** Holds the scenelist to be sent, if pending. */
196 QDomDocument m_sceneList;
198 /** A human-readable description of this renderer. */
199 QString m_description;
202 /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
203 void sendSeekCommand(GenTime time);
205 /** Sets the description of this renderer to desc. */
206 void setDescription(const QString & description);
208 void mltCheckLength();
210 private slots: // Private slots
211 /** refresh monitor display */
213 void slotOsdTimeout();
214 void restartConsumer();
215 void connectPlaylist();
216 void initSceneList();
219 /** This signal is emitted once a reply to createVideoXWidow() has been recieved. */
220 void replyCreateVideoXWindow(WId);
221 /** emitted when the renderer recieves a reply to a getFileProperties request. */
222 void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
224 /** emitted when the renderer recieves a reply to a getImage request. */
225 void replyGetImage(int , int, const QPixmap &, int, int);
226 void replyGetImage(int, const QPixmap &, int, int);
228 /** Emitted when the renderer stops, either playing or rendering. */
230 /** Emitted when the renderer starts playing. */
231 void playing(double);
232 /** Emitted when the renderer is rendering. */
233 void rendering(const GenTime &);
234 /** Emitted when rendering has finished */
235 void renderFinished();
236 /** Emitted when the current seek position has been changed by the renderer. */
237 // void positionChanged(const GenTime &);
238 /** Emitted when an error occurs within this renderer. */
239 void error(const QString &, const QString &);
240 void playListDuration(int);
241 void rendererPosition(int);
242 void rendererStopped(int);
245 public slots: // Public slots
246 /** Start Consumer */
252 /** If the file is readable by mlt, return true, otherwise false */
253 bool isValid(KUrl url);
255 /** Wraps the VEML command of the same name. Requests the file properties
256 for the specified url from the renderer. Upon return, the result will be emitted
257 via replyGetFileProperties(). */
258 void getFileProperties(const QDomElement &xml, int clipId);
260 void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
261 static char *decodedString(QString str);
262 void mltSavePlaylist();