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