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