]> git.sesse.net Git - kdenlive/blob - src/renderer.h
Fix transition moving
[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 class Profile;
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, int winid, int extid, QWidget *parent = 0);
67     ~Render();
68
69     /** Seeks the renderer clip to the given time. */
70     void seek(GenTime time);
71     void seekToFrame(int pos);
72
73     //static QPixmap getVideoThumbnail(char *profile, QString file, int frame, int width, int height);
74     QPixmap getImageThumbnail(KUrl url, int width, int height);
75
76     /** Return thumbnail for color clip */
77     //void getImage(int id, QString color, QPoint size);
78
79     // static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
80
81     /** Return thumbnail for image clip */
82     //void getImage(KUrl url, QPoint size);
83
84     /** Requests a particular frame from the given file.
85      *
86      * The pixmap will be returned by emitting the replyGetImage() signal.
87      * */
88     //void getImage(KUrl url, int frame, QPoint size);
89
90
91     /** Wraps the VEML command of the same name. Sets the current scene list to
92     be list. */
93     void setSceneList(QDomDocument list, int position = 0);
94     void setSceneList(QString playlist, int position = 0);
95     QString sceneList();
96     void saveSceneList(QString path, QDomElement kdenliveData = QDomElement());
97
98     /** Wraps the VEML command of the same name. Tells the renderer to
99     play the current scene at the speed specified, relative to normal
100     playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
101     backwards. Does not specify start/stop times for playback.*/
102     void play(double speed);
103     void switchPlay();
104     /** stop playing */
105     void stop(const GenTime & startTime);
106     void setVolume(double volume);
107
108     QPixmap extractFrame(int frame_position, int width = -1, int height = -1);
109     /** Wraps the VEML command of the same name. Tells the renderer to
110     play the current scene at the speed specified, relative to normal
111     playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
112     backwards. Specifes the start/stop times for playback.*/
113     void play(double speed, const GenTime & startTime);
114     void play(double speed, const GenTime & startTime,
115               const GenTime & stopTime);
116
117     /** Returns the description of this renderer */
118     QString description();
119
120     /** Returns the name of the renderer. */
121     const QString & rendererName() const;
122
123     /** Returns the speed at which the renderer is currently playing, 0.0 if the renderer is
124     not playing anything. */
125     double playSpeed();
126     /** Returns the current seek position of the renderer. */
127     GenTime seekPosition() const;
128
129     void emitFrameNumber(double position);
130     void emitConsumerStopped();
131
132     /** Gives the aspect ratio of the consumer */
133     double consumerRatio() const;
134
135     void askForRefresh();
136     void doRefresh();
137
138     /** Save current producer frame as image */
139     void exportCurrentFrame(KUrl url, bool notify);
140
141     /** Turn on or off on screen display */
142     void refreshDisplay();
143     int resetProfile(QString profile);
144     const double fps() const;
145     const int renderWidth() const;
146     const int renderHeight() const;
147
148     /** Playlist manipulation */
149     void mltInsertClip(int track, GenTime position, QDomElement element);
150     void mltUpdateClip(int track, GenTime position, QDomElement element);
151     void mltCutClip(int track, GenTime position);
152     void mltResizeClipEnd(int track, GenTime pos, GenTime in, GenTime out);
153     void mltResizeClipStart(int track, GenTime pos, GenTime moveEnd, GenTime moveStart, GenTime in, GenTime out);
154     void mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart);
155     void mltMoveClip(int startTrack, int endTrack, int pos, int moveStart);
156     void mltRemoveClip(int track, GenTime position);
157     void mltRemoveEffect(int track, GenTime position, QString index, bool doRefresh = true);
158     void mltAddEffect(int track, GenTime position, QMap <QString, QString> args, bool doRefresh = true);
159     void mltEditEffect(int track, GenTime position, QMap <QString, QString> args);
160     void mltMoveEffect(int track, GenTime position, int oldPos, int newPos);
161     void mltChangeTrackState(int track, bool mute, bool blind);
162     void mltMoveTransition(QString type, int startTrack,  int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
163     void mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
164     void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
165     void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
166     void mltUpdateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
167
168
169 private:   // Private attributes & methods
170     /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
171     QString m_name;
172     Mlt::Consumer * m_mltConsumer;
173     Mlt::Producer * m_mltProducer;
174     Mlt::Producer *m_mltTextProducer;
175     Mlt::Filter *m_osdInfo;
176     Mlt::Profile *m_mltProfile;
177     double m_framePosition;
178     double m_fps;
179     uint m_monitorId;
180     bool m_generateScenelist;
181     bool m_isBlocked;
182
183     /** Holds the path to on screen display profile */
184     QString m_osdProfile;
185
186     QTimer *refreshTimer;
187     QTimer *osdTimer;
188     QTimer *m_connectTimer;
189     KUrl m_exportedFile;
190     int exportDuration, firstExportFrame, lastExportFrame;
191
192     /** A human-readable description of this renderer. */
193     QString m_description;
194     int m_winid;
195     int m_externalwinid;
196     /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
197     void sendSeekCommand(GenTime time);
198
199     /** Sets the description of this renderer to desc. */
200     void setDescription(const QString & description);
201     void closeMlt();
202     void mltCheckLength(bool reload = true);
203     QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
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 durationChanged(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