]> git.sesse.net Git - kdenlive/blob - src/renderer.h
Connect project monitor
[kdenlive] / src / renderer.h
1 /***************************************************************************
2                          krender.h  -  description
3                             -------------------
4    begin                : Fri Nov 22 2002
5    copyright            : (C) 2002 by Jason Wood
6    email                : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
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.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef KRENDER_H
19 #define KRENDER_H
20
21 #include <qdom.h>
22 #include <qstring.h>
23 #include <qmap.h>
24 #include <QList>
25 #include <QWidget>
26
27 #include <kurl.h>
28
29 #include "gentime.h"
30 /*#include "docclipref.h"
31 #include "effectdesc.h"
32 #include "effectparamdescfactory.h"*/
33
34 #include <mlt++/Mlt.h>
35
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.
41   *@author Jason Wood
42   */
43
44 class Render;
45 //class EffectParamDesc;
46 class QPixmap;
47
48 namespace Mlt {
49     class Consumer;
50     class Playlist;
51     class Tractor;
52     class Frame;
53     class Producer;
54     class Filter;
55     class Profile;
56     class Multitrack;
57 };
58
59
60
61 class Render:public QObject {
62   Q_OBJECT public:
63
64     enum FailStates { OK = 0,
65         APP_NOEXIST
66     };
67
68      Render(const QString & rendererName, int winid, int extid, QWidget *parent = 0);
69     ~Render();
70
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);
79     
80     static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
81     QPixmap getImageThumbnail(KUrl url, int width, int height);
82
83         /** Return thumbnail for color clip */
84     //void getImage(int id, QString color, QPoint size);
85
86     static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
87     
88     /** Return thumbnail for image clip */
89     //void getImage(KUrl url, QPoint size);
90
91         /** Requests a particular frame from the given file. 
92          * 
93          * The pixmap will be returned by emitting the replyGetImage() signal.
94          * */
95     //void getImage(KUrl url, int frame, QPoint size);
96
97
98         /** Wraps the VEML command of the same name. Sets the current scene list to
99         be list. */
100     void setSceneList(QDomDocument list, int position = 0);
101
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);
107     void switchPlay();
108         /** stop playing */
109     void stop(const GenTime & startTime);
110     void setVolume(double volume);
111
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
122         name specified. */
123     void render(const KUrl & url);
124
125         /** Returns the description of this renderer */
126     QString description();
127
128         /** Returns the name of the renderer. */
129     const QString & rendererName() const;
130
131         /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
132         not playing anything. */
133     double playSpeed();
134         /** Returns the current seek position of the renderer. */
135     const GenTime & seekPosition() const;
136
137     void emitFrameNumber(double position);
138     void emitConsumerStopped();
139
140     /** Gives the aspect ratio of the consumer */
141     double consumerRatio() const;
142
143     /** Gives the aspect ratio of the consumer */
144     void askForRefresh();
145     
146     /** Save current producer frame as image */
147     void exportCurrentFrame(KUrl url, bool notify);
148
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);
154     bool isBlocked;
155     const double fps() const;
156
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);
171
172  
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... */
175      QString m_name;
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;
182      double m_fps;
183      uint m_monitorId;
184      bool m_generateScenelist;
185
186         /** Holds the path to on screen display profile */
187      QString m_osdProfile;
188      
189      QTimer *refreshTimer;
190      QTimer *osdTimer;
191      QTimer *m_connectTimer;
192      KUrl m_exportedFile;
193      int exportDuration, firstExportFrame, lastExportFrame;
194
195         /** Holds the scenelist to be sent, if pending. */
196     QDomDocument m_sceneList;
197
198         /** A human-readable description of this renderer. */
199     QString m_description;
200     int m_winid;
201     int m_externalwinid;
202         /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
203     void sendSeekCommand(GenTime time);
204
205         /** Sets the description of this renderer to desc. */
206     void setDescription(const QString & description);
207     void closeMlt();
208     void mltCheckLength();
209
210     private slots:              // Private slots
211         /** refresh monitor display */
212         void refresh();
213         void slotOsdTimeout();
214         void restartConsumer();
215         void connectPlaylist();
216         void initSceneList();
217
218      signals:                   // Signals
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 > &);
223
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);
227
228         /** Emitted when the renderer stops, either playing or rendering. */
229     void stopped();
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 durationChanged();
241     void playListDuration(int);
242     void rendererPosition(int);
243     void rendererStopped(int);
244
245     
246     public slots:               // Public slots
247         /** Start Consumer */
248     void start();
249         /** Stop Consumer */
250     void stop();
251     void clear();
252     int getLength();
253         /** If the file is readable by mlt, return true, otherwise false */
254     bool isValid(KUrl url);
255
256         /** Wraps the VEML command of the same name. Requests the file properties
257     for the specified url from the renderer. Upon return, the result will be emitted
258     via replyGetFileProperties(). */
259     void getFileProperties(const QDomElement &xml, int clipId);
260     
261     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
262     static char *decodedString(QString str);
263     void mltSavePlaylist();
264 };
265
266 #endif