]> git.sesse.net Git - kdenlive/blob - src/renderer.h
Effects are now stored in clip as xml, get ready for effectstack connection
[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         /** Seeks the renderer clip to the given time. */
72     void seek(GenTime time);
73     void seekToFrame(int pos);
74     
75     static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
76     QPixmap getImageThumbnail(KUrl url, int width, int height);
77
78         /** Return thumbnail for color clip */
79     //void getImage(int id, QString color, QPoint size);
80
81     static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
82     
83     /** Return thumbnail for image clip */
84     //void getImage(KUrl url, QPoint size);
85
86         /** Requests a particular frame from the given file. 
87          * 
88          * The pixmap will be returned by emitting the replyGetImage() signal.
89          * */
90     //void getImage(KUrl url, int frame, QPoint size);
91
92
93         /** Wraps the VEML command of the same name. Sets the current scene list to
94         be list. */
95     void setSceneList(QDomDocument list, int position = 0);
96
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);
102     void switchPlay();
103         /** stop playing */
104     void stop(const GenTime & startTime);
105     void setVolume(double volume);
106
107     QPixmap extractFrame(int frame_position, int width, int height);
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);
115         /** Wraps the VEML command of the same name - render the currently
116         specified sceneList - set with setSceneList() - to the document
117         name specified. */
118     void render(const KUrl & url);
119
120         /** Returns the description of this renderer */
121     QString description();
122
123         /** Returns the name of the renderer. */
124     const QString & rendererName() const;
125
126         /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
127         not playing anything. */
128     double playSpeed();
129         /** Returns the current seek position of the renderer. */
130     const GenTime & seekPosition() const;
131
132     void emitFrameNumber(double position);
133     void emitConsumerStopped();
134
135     /** Gives the aspect ratio of the consumer */
136     double consumerRatio() const;
137
138     void askForRefresh();
139     void doRefresh();
140     
141     /** Save current producer frame as image */
142     void exportCurrentFrame(KUrl url, bool notify);
143
144     /** Turn on or off on screen display */
145     void refreshDisplay();
146     /** returns the current scenelist */
147     QDomDocument sceneList() const;
148     int resetRendererProfile(char * profile);
149     const double fps() const;
150
151     /** Playlist manipulation */
152     void mltInsertClip(int track, GenTime position, QDomElement element);
153     void mltCutClip(int track, GenTime position);
154     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
155     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
156     void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
157     void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
158     void mltRemoveClip(int track, GenTime position);
159     void mltRemoveEffect(int track, GenTime position, QString index);
160     void mltAddEffect(int track, GenTime position, QMap <QString, QString> args);
161     void mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args);
162     void mltChangeTrackState(int track, bool mute, bool blind);
163     void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
164     void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
165
166  
167   private:                      // Private attributes & methods
168         /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
169      QString m_name;
170      Mlt::Consumer * m_mltConsumer;
171      Mlt::Producer * m_mltProducer;
172      Mlt::Producer *m_mltTextProducer;
173      Mlt::Filter *m_osdInfo;
174      Mlt::Profile *m_mltProfile;
175      double m_framePosition;
176      double m_fps;
177      uint m_monitorId;
178      bool m_generateScenelist;
179      bool m_isBlocked;
180
181         /** Holds the path to on screen display profile */
182      QString m_osdProfile;
183      
184      QTimer *refreshTimer;
185      QTimer *osdTimer;
186      QTimer *m_connectTimer;
187      KUrl m_exportedFile;
188      int exportDuration, firstExportFrame, lastExportFrame;
189
190         /** Holds the scenelist to be sent, if pending. */
191     QDomDocument m_sceneList;
192
193         /** A human-readable description of this renderer. */
194     QString m_description;
195     int m_winid;
196     int m_externalwinid;
197         /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
198     void sendSeekCommand(GenTime time);
199
200         /** Sets the description of this renderer to desc. */
201     void setDescription(const QString & description);
202     void closeMlt();
203     void mltCheckLength();
204
205     private slots:              // Private slots
206         /** refresh monitor display */
207         void refresh();
208         void slotOsdTimeout();
209         void connectPlaylist();
210         void initSceneList();
211
212      signals:                   // Signals
213         /** emitted when the renderer recieves a reply to a getFileProperties request. */
214     void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
215
216         /** emitted when the renderer recieves a reply to a getImage request. */
217     void replyGetImage(int , int, const QPixmap &, int, int);
218     void replyGetImage(int, const QPixmap &, int, int);
219
220         /** Emitted when the renderer stops, either playing or rendering. */
221     void stopped();
222         /** Emitted when the renderer starts playing. */
223     void playing(double);
224         /** Emitted when the renderer is rendering. */
225     void rendering(const GenTime &);
226         /** Emitted when rendering has finished */
227     void renderFinished();
228         /** Emitted when the current seek position has been changed by the renderer. */
229 //    void positionChanged(const GenTime &);
230         /** Emitted when an error occurs within this renderer. */
231     void error(const QString &, const QString &);
232     void playListDuration(int);
233     void rendererPosition(int);
234     void rendererStopped(int);
235
236     
237     public slots:               // Public slots
238         /** Start Consumer */
239     void start();
240         /** Stop Consumer */
241     void stop();
242     void clear();
243     int getLength();
244         /** If the file is readable by mlt, return true, otherwise false */
245     bool isValid(KUrl url);
246
247         /** Wraps the VEML command of the same name. Requests the file properties
248     for the specified url from the renderer. Upon return, the result will be emitted
249     via replyGetFileProperties(). */
250     void getFileProperties(const QDomElement &xml, int clipId);
251     
252     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
253     static char *decodedString(QString str);
254     void mltSavePlaylist();
255 };
256
257 #endif