]> git.sesse.net Git - kdenlive/blob - src/renderer.h
7e00c8ac92eb8acb1904284b1f35906e937d32e8
[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 /**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.
39   *@author Jason Wood
40   */
41
42 class Render;
43 //class EffectParamDesc;
44 class QPixmap;
45
46 namespace Mlt {
47     class Consumer;
48     class Playlist;
49     class Tractor;
50     class Frame;
51     class Producer;
52     class Filter;
53
54     class Multitrack;
55 };
56
57
58
59 class Render:public QObject {
60   Q_OBJECT public:
61
62     enum FailStates { OK = 0,
63         APP_NOEXIST
64     };
65
66      Render(const QString & rendererName, QWidget *parent = 0);
67     ~Render();
68
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);
77     
78     static QPixmap getVideoThumbnail(QString file, int frame, int width, int height);
79     QPixmap getImageThumbnail(KUrl url, int width, int height);
80
81         /** Return thumbnail for color clip */
82     void getImage(int id, QString color, QPoint size);
83
84     static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
85     
86     /** Return thumbnail for image clip */
87     void getImage(KUrl url, QPoint size);
88
89         /** Requests a particular frame from the given file. 
90          * 
91          * The pixmap will be returned by emitting the replyGetImage() signal.
92          * */
93     void getImage(KUrl url, int frame, QPoint size);
94
95         /** Wraps the VEML command of the same name. Sets the current scene list to
96         be list. */
97     void setSceneList(QDomDocument list, int position = 0);
98
99         /** Wraps the VEML command of the same name. Tells the renderer to
100         play the current scene at the speed specified, relative to normal
101         playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
102         backwards. Does not specify start/stop times for playback.*/
103     void play(double speed);
104     void switchPlay();
105         /** stop playing */
106     void stop(const GenTime & startTime);
107     void setVolume(double volume);
108
109     QPixmap extractFrame(int frame_position, int width, int height);
110         /** Wraps the VEML command of the same name. Tells the renderer to
111         play the current scene at the speed specified, relative to normal
112         playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
113         backwards. Specifes the start/stop times for playback.*/
114     void play(double speed, const GenTime & startTime);
115     void play(double speed, const GenTime & startTime,
116         const GenTime & stopTime);
117         /** Wraps the VEML command of the same name - render the currently
118         specified sceneList - set with setSceneList() - to the document
119         name specified. */
120     void render(const KUrl & url);
121
122         /** Returns the description of this renderer */
123     QString description();
124
125         /** Returns the name of the renderer. */
126     const QString & rendererName() const;
127
128         /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
129         not playing anything. */
130     double playSpeed();
131         /** Returns the current seek position of the renderer. */
132     const GenTime & seekPosition() const;
133
134     void emitFrameNumber(double position);
135     void emitConsumerStopped();
136
137     /** Gives the aspect ratio of the consumer */
138     double consumerRatio() const;
139
140     /** Gives the aspect ratio of the consumer */
141     void askForRefresh();
142     
143     /** Save current producer frame as image */
144     void exportCurrentFrame(KUrl url, bool notify);
145
146     /** Turn on or off on screen display */
147     void refreshDisplay();
148     /** returns the current scenelist */
149     QDomDocument sceneList() const;
150     int resetRendererProfile(char * profile);
151     bool isBlocked;
152     const double fps() const;
153
154     /** Playlist manipulation */
155     void mltInsertClip(int track, GenTime position, QString resource);
156     void mltCutClip(int track, GenTime position);
157     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
158     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
159     void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
160     void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
161     void mltRemoveClip(int track, GenTime position);
162     void mltRemoveEffect(int track, GenTime position, QString id, QString tag, int index);
163     void mltAddEffect(int track, GenTime position, QString id, QString tag, QMap <QString, QString> args);
164     void mltEditEffect(int track, GenTime position, int index, QString id, QString tag, QMap <QString, QString> args);
165     void mltChangeTrackState(int track, bool mute, bool blind);
166     void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
167     void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
168
169  
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... */
172      QString m_name;
173      Mlt::Consumer * m_mltConsumer;
174      Mlt::Producer * m_mltProducer;
175      Mlt::Producer *m_mltTextProducer;
176      Mlt::Filter *m_osdInfo;
177      double m_framePosition;
178      double m_fps;
179      uint m_monitorId;
180      bool m_generateScenelist;
181
182         /** Holds the path to on screen display profile */
183      QString m_osdProfile;
184      
185      QTimer *refreshTimer;
186      QTimer *osdTimer;
187      QTimer *m_connectTimer;
188      KUrl m_exportedFile;
189      int exportDuration, firstExportFrame, lastExportFrame;
190
191         /** Holds the scenelist to be sent, if pending. */
192     QDomDocument m_sceneList;
193
194         /** A human-readable description of this renderer. */
195     QString m_description;
196     int m_winid;
197     int m_externalwinid;
198         /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
199     void sendSeekCommand(GenTime time);
200
201         /** Sets the description of this renderer to desc. */
202     void setDescription(const QString & description);
203     void closeMlt();
204     void mltCheckLength();
205
206     private slots:              // Private slots
207         /** refresh monitor display */
208         void refresh();
209         void slotOsdTimeout();
210         void restartConsumer();
211         void connectPlaylist();
212         void initSceneList();
213
214      signals:                   // Signals
215         /** This signal is emitted once a reply to createVideoXWidow() has been recieved. */
216     void replyCreateVideoXWindow(WId);
217         /** emitted when the renderer recieves a reply to a getFileProperties request. */
218     void replyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &);
219
220         /** emitted when the renderer recieves a reply to a getImage request. */
221     void replyGetImage(const KUrl &, int, const QPixmap &, int, int);
222     void replyGetImage(int, const QPixmap &, int, int);
223
224         /** Emitted when the renderer stops, either playing or rendering. */
225     void stopped();
226         /** Emitted when the renderer starts playing. */
227     void playing(double);
228         /** Emitted when the renderer is rendering. */
229     void rendering(const GenTime &);
230         /** Emitted when rendering has finished */
231     void renderFinished();
232         /** Emitted when the current seek position has been changed by the renderer. */
233 //    void positionChanged(const GenTime &);
234         /** Emitted when an error occurs within this renderer. */
235     void error(const QString &, const QString &);
236     void durationChanged();
237     void playListDuration(int);
238     void rendererPosition(int);
239     void rendererStopped(int);
240
241     
242     public slots:               // Public slots
243         /** Start Consumer */
244     void start();
245         /** Stop Consumer */
246     void stop();
247     void clear();
248     int getLength();
249         /** If the file is readable by mlt, return true, otherwise false */
250     bool isValid(KUrl url);
251
252         /** Wraps the VEML command of the same name. Requests the file properties
253     for the specified url from the renderer. Upon return, the result will be emitted
254     via replyGetFileProperties(). */
255     void getFileProperties(const KUrl &url, uint framenb = 0);
256     
257     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
258     static char *decodedString(QString str);
259     void mltSavePlaylist();
260 };
261
262 #endif