]> git.sesse.net Git - kdenlive/blob - src/renderer.h
Looks like I finally got the profile switching work!
[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     void setSceneList(QString playlist, int position = 0);
97     QString sceneList();
98     void saveSceneList(QString path, QDomElement addedXml = QDomElement());
99
100     /** Wraps the VEML command of the same name. Tells the renderer to
101     play the current scene at the speed specified, relative to normal
102     playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
103     backwards. Does not specify start/stop times for playback.*/
104     void play(double speed);
105     void switchPlay();
106     /** stop playing */
107     void stop(const GenTime & startTime);
108     void setVolume(double volume);
109
110     QPixmap extractFrame(int frame_position, int width, int height);
111     /** Wraps the VEML command of the same name. Tells the renderer to
112     play the current scene at the speed specified, relative to normal
113     playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
114     backwards. Specifes the start/stop times for playback.*/
115     void play(double speed, const GenTime & startTime);
116     void play(double speed, const GenTime & startTime,
117               const GenTime & stopTime);
118
119     /** Returns the description of this renderer */
120     QString description();
121
122     /** Returns the name of the renderer. */
123     const QString & rendererName() const;
124
125     /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
126     not playing anything. */
127     double playSpeed();
128     /** Returns the current seek position of the renderer. */
129     const GenTime & seekPosition() const;
130
131     void emitFrameNumber(double position);
132     void emitConsumerStopped();
133
134     /** Gives the aspect ratio of the consumer */
135     double consumerRatio() const;
136
137     void askForRefresh();
138     void doRefresh();
139
140     /** Save current producer frame as image */
141     void exportCurrentFrame(KUrl url, bool notify);
142
143     /** Turn on or off on screen display */
144     void refreshDisplay();
145     int resetProfile(QString profile);
146     const double fps() const;
147
148     /** Playlist manipulation */
149     void mltInsertClip(int track, GenTime position, QDomElement element);
150     void mltCutClip(int track, GenTime position);
151     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
152     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
153     void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
154     void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
155     void mltRemoveClip(int track, GenTime position);
156     void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
157     void mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh = true);
158     void mltEditEffect(int track, GenTime position, QMap <QString, QString> args);
159     void mltChangeTrackState(int track, bool mute, bool blind);
160     void mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
161     void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QMap <QString, QString> args);
162
163
164 private:   // Private attributes & methods
165     /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
166     QString m_name;
167     Mlt::Consumer * m_mltConsumer;
168     Mlt::Producer * m_mltProducer;
169     Mlt::Producer *m_mltTextProducer;
170     Mlt::Filter *m_osdInfo;
171     Mlt::Profile *m_mltProfile;
172     double m_framePosition;
173     double m_fps;
174     uint m_monitorId;
175     bool m_generateScenelist;
176     bool m_isBlocked;
177
178     /** Holds the path to on screen display profile */
179     QString m_osdProfile;
180
181     QTimer *refreshTimer;
182     QTimer *osdTimer;
183     QTimer *m_connectTimer;
184     KUrl m_exportedFile;
185     int exportDuration, firstExportFrame, lastExportFrame;
186
187     /** A human-readable description of this renderer. */
188     QString m_description;
189     int m_winid;
190     int m_externalwinid;
191     /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
192     void sendSeekCommand(GenTime time);
193
194     /** Sets the description of this renderer to desc. */
195     void setDescription(const QString & description);
196     void closeMlt();
197     void mltCheckLength();
198
199 private slots:  // Private slots
200     /** refresh monitor display */
201     void refresh();
202     void slotOsdTimeout();
203     void connectPlaylist();
204     void initSceneList();
205
206 signals:   // Signals
207     /** emitted when the renderer recieves a reply to a getFileProperties request. */
208     void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
209
210     /** emitted when the renderer recieves a reply to a getImage request. */
211     void replyGetImage(int , int, const QPixmap &, int, int);
212     void replyGetImage(int, const QPixmap &, int, int);
213
214     /** Emitted when the renderer stops, either playing or rendering. */
215     void stopped();
216     /** Emitted when the renderer starts playing. */
217     void playing(double);
218     /** Emitted when the renderer is rendering. */
219     void rendering(const GenTime &);
220     /** Emitted when rendering has finished */
221     void renderFinished();
222     /** Emitted when the current seek position has been changed by the renderer. */
223 //    void positionChanged(const GenTime &);
224     /** Emitted when an error occurs within this renderer. */
225     void error(const QString &, const QString &);
226     void durationChanged(int);
227     void rendererPosition(int);
228     void rendererStopped(int);
229
230
231 public slots:  // Public slots
232     /** Start Consumer */
233     void start();
234     /** Stop Consumer */
235     void stop();
236     void clear();
237     int getLength();
238     /** If the file is readable by mlt, return true, otherwise false */
239     bool isValid(KUrl url);
240
241     /** Wraps the VEML command of the same name. Requests the file properties
242     for the specified url from the renderer. Upon return, the result will be emitted
243     via replyGetFileProperties(). */
244     void getFileProperties(const QDomElement &xml, int clipId);
245
246     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
247     static char *decodedString(QString str);
248     void mltSavePlaylist();
249 };
250
251 #endif