]> git.sesse.net Git - kdenlive/blob - src/renderer.h
Reindent the codebase using 'linux' bracket placement.
[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 RENDERER_H
19 #define RENDERER_H
20
21 #include <qdom.h>
22 #include <qstring.h>
23 #include <qmap.h>
24 #include <QList>
25
26 #include <kurl.h>
27
28 #include "gentime.h"
29 #include "definitions.h"
30
31 /**Render encapsulates the client side of the interface to a renderer.
32 From Kdenlive's point of view, you treat the Render object as the
33 renderer, and simply use it as if it was local. Calls are asyncrhonous -
34 you send a call out, and then receive the return value through the
35 relevant signal that get's emitted once the call completes.
36   *@author Jason Wood
37   */
38
39 class Render;
40
41 class QTimer;
42 class QPixmap;
43
44 namespace Mlt
45 {
46 class Consumer;
47 class Playlist;
48 class Tractor;
49 class Frame;
50 class Producer;
51 class Filter;
52 class Profile;
53 class Multitrack;
54 };
55
56
57
58 class Render: public QObject
59 {
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     void setProducer(Mlt::Producer *producer, int position);
97     const QString sceneList();
98     bool saveSceneList(QString path, QDomElement kdenliveData = 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     void pause();
107     /** stop playing */
108     void stop(const GenTime & startTime);
109     void setVolume(double volume);
110
111     QPixmap extractFrame(int frame_position, int width = -1, int height = -1);
112     /** Wraps the VEML command of the same name. Tells the renderer to
113     play the current scene at the speed specified, relative to normal
114     playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
115     backwards. Specifes the start/stop times for playback.*/
116     void play(const GenTime & startTime);
117     void playZone(const GenTime & startTime, const GenTime & stopTime);
118     void loopZone(const GenTime & startTime, const GenTime & stopTime);
119
120     void saveZone(KUrl url, QString desc, QPoint zone);
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     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();
146     double fps() const;
147     int renderWidth() const;
148     int renderHeight() const;
149     /** get display aspect ratio */
150     double dar() const;
151
152     /** Playlist manipulation */
153     void mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
154     void mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod);
155     void mltCutClip(int track, GenTime position);
156     void mltInsertSpace(QMap <int, int> trackClipStartList, QMap <int, int> trackTransitionStartList, int track, const GenTime duration, const GenTime timeOffset);
157     int mltGetSpaceLength(const GenTime pos, int track, bool fromBlankStart);
158     int mltTrackDuration(int track);
159     bool mltResizeClipEnd(ItemInfo info, GenTime clipDuration);
160     bool mltResizeClipStart(ItemInfo info, GenTime diff);
161     bool mltResizeClipCrop(ItemInfo info, GenTime diff);
162     bool mltMoveClip(int startTrack, int endTrack, GenTime pos, GenTime moveStart, Mlt::Producer *prod);
163     bool mltMoveClip(int startTrack, int endTrack, int pos, int moveStart, Mlt::Producer *prod);
164     bool mltRemoveClip(int track, GenTime position);
165     bool mltRemoveEffect(int track, GenTime position, QString index, bool updateIndex, bool doRefresh = true);
166     bool mltAddEffect(int track, GenTime position, EffectsParameterList params, bool doRefresh = true);
167     bool mltEditEffect(int track, GenTime position, EffectsParameterList params);
168     void mltMoveEffect(int track, GenTime position, int oldPos, int newPos);
169     void mltChangeTrackState(int track, bool mute, bool blind);
170     bool mltMoveTransition(QString type, int startTrack,  int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut);
171     bool mltAddTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
172     void mltDeleteTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool refresh = true);
173     void mltUpdateTransition(QString oldTag, QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
174     void mltUpdateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml);
175     void mltAddClipTransparency(ItemInfo info, int transitiontrack, int id);
176     void mltMoveTransparency(int startTime, int endTime, int startTrack, int endTrack, int id);
177     void mltDeleteTransparency(int pos, int track, int id);
178     void mltResizeTransparency(int oldStart, int newStart, int newEnd, int track, int id);
179     void mltInsertTrack(int ix, bool videoTrack);
180     void mltDeleteTrack(int ix);
181     void mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod);
182
183     /** Change speed of a clip in playlist. To do this, we create a new "framebuffer" producer.
184     This new producer must have its "resource" param set to: video.mpg?0.6 where video.mpg is the path
185     to the clip and 0.6 is the speed in percents. The newly created producer will have it's
186     "id" parameter set to: "slowmotion:parentid:speed", where parentid is the id of the original clip
187     in the ClipManager list and speed is the current speed */
188     int mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, Mlt::Producer *prod);
189
190     QList <Mlt::Producer *> producersList();
191     void updatePreviewSettings();
192
193 private:   // Private attributes & methods
194     /** The name of this renderer - useful to identify the renderes by what they do - e.g. background rendering, workspace monitor, etc... */
195     QString m_name;
196     Mlt::Consumer * m_mltConsumer;
197     Mlt::Producer * m_mltProducer;
198     Mlt::Producer *m_mltTextProducer;
199     Mlt::Filter *m_osdInfo;
200     Mlt::Profile *m_mltProfile;
201     double m_framePosition;
202     double m_fps;
203
204     /** true if we are playing a zone (ie the in and out properties have been temporarily changed) */
205     bool m_isZoneMode;
206     bool m_isLoopMode;
207     GenTime m_loopStart;
208     int m_originalOut;
209
210     /** true when monitor is in split view (several tracks at the same time) */
211     bool m_isSplitView;
212
213     Mlt::Producer *m_blackClip;
214     /** Holds the path to on screen display profile */
215     QString m_osdProfile;
216     QString m_activeProfile;
217
218     QTimer *refreshTimer;
219     QTimer *osdTimer;
220     KUrl m_exportedFile;
221
222     /** A human-readable description of this renderer. */
223     int m_winid;
224     int m_externalwinid;
225
226     /** Sets the description of this renderer to desc. */
227     void closeMlt();
228     void mltCheckLength();
229     QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
230     QMap<QString, Mlt::Producer *> m_slowmotionProducers;
231     void buildConsumer();
232     void resetZoneMode();
233     void fillSlowMotionProducers();
234
235 private slots:  // Private slots
236     /** refresh monitor display */
237     void refresh();
238     void slotOsdTimeout();
239     void connectPlaylist();
240     //void initSceneList();
241
242 signals:   // Signals
243     /** emitted when the renderer recieves a reply to a getFileProperties request. */
244     void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool);
245
246     /** emitted when the renderer recieves a reply to a getImage request. */
247     void replyGetImage(const QString &, const QPixmap &);
248
249     /** Emitted when the renderer stops, either playing or rendering. */
250     void stopped();
251     /** Emitted when the renderer starts playing. */
252     void playing(double);
253     /** Emitted when the renderer is rendering. */
254     void rendering(const GenTime &);
255     /** Emitted when rendering has finished */
256     void renderFinished();
257     /** Emitted when the current seek position has been changed by the renderer. */
258 //    void positionChanged(const GenTime &);
259     /** Emitted when an error occurs within this renderer. */
260     void error(const QString &, const QString &);
261     void durationChanged(int);
262     void rendererPosition(int);
263     void rendererStopped(int);
264     void removeInvalidClip(const QString &);
265
266 public slots:  // Public slots
267     /** Start Consumer */
268     void start();
269     /** Stop Consumer */
270     void stop();
271     void clear();
272     int getLength();
273     /** If the file is readable by mlt, return true, otherwise false */
274     bool isValid(KUrl url);
275
276     /** Wraps the VEML command of the same name. Requests the file properties
277     for the specified url from the renderer. Upon return, the result will be emitted
278     via replyGetFileProperties(). */
279     void getFileProperties(const QDomElement &xml, const QString &clipId, bool replaceProducer = true);
280
281     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
282     static char *decodedString(QString str);
283     void mltSavePlaylist();
284     void slotSplitView(bool doit);
285 };
286
287 #endif