]> git.sesse.net Git - kdenlive/blob - src/mltdevicecapture.h
cppcheck fixes, patch by Mikko Rapeli [19/27]
[kdenlive] / src / mltdevicecapture.h
1 /***************************************************************************
2                          mltdevicecapture.h  -  description
3                             -------------------
4    begin                : Sun May 21 2011
5    copyright            : (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org)
6
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 /**
19  * @class MltDeviceCapture
20  * @brief Interface for MLT capture.
21  */
22
23 #ifndef MLTDEVICECAPTURE_H
24 #define MLTDEVICECAPTURE_H
25
26 #include "gentime.h"
27 #include "definitions.h"
28 #include "abstractmonitor.h"
29 #include "mlt/framework/mlt_types.h"
30
31 #include <QtConcurrentRun>
32
33 namespace Mlt
34 {
35 class Consumer;
36 class Playlist;
37 class Tractor;
38 class Transition;
39 class Frame;
40 class Field;
41 class Producer;
42 class Filter;
43 class Profile;
44 class Service;
45 };
46
47 class MltDeviceCapture: public AbstractRender
48 {
49 Q_OBJECT public:
50
51     enum FailStates { OK = 0,
52                       APP_NOEXIST
53                     };
54     /** @brief Build a MLT Renderer
55      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
56      *  @param profile The MLT profile used for the capture (default one will be used if empty). */
57     MltDeviceCapture(QString profile, VideoPreviewContainer *surface, QWidget *parent = 0);
58
59     /** @brief Destroy the MLT Renderer. */
60     ~MltDeviceCapture();
61
62     int doCapture;
63
64     /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */
65     bool sendFrameForAnalysis;
66
67     /** @brief Someone needs us to send again a frame. */
68     void sendFrameUpdate() {};
69     
70     void emitFrameUpdated(Mlt::Frame&);
71     void emitFrameNumber(double position);
72     void emitConsumerStopped();
73     void showFrame(Mlt::Frame&);
74     void showAudio(Mlt::Frame&);
75
76     void saveFrame(Mlt::Frame& frame);
77
78     /** @brief Starts the MLT Video4Linux process.
79      * @param surface The widget onto which the frame should be painted
80      */
81     bool slotStartCapture(const QString &params, const QString &path, const QString &playlist, int livePreview, bool xmlPlaylist = true);
82     bool slotStartPreview(const QString &producer, bool xmlFormat = false);
83     /** @brief A frame arrived from the MLT Video4Linux process. */
84     void gotCapturedFrame(Mlt::Frame& frame);
85     /** @brief Save current frame to file. */
86     void captureFrame(const QString &path);
87     void doRefresh();
88     /** @brief This will add the video clip from path and add it in the overlay track. */
89     void setOverlay(const QString &path);
90
91     /** @brief This will add an MLT video effect to the overlay track. */
92     void setOverlayEffect(const QString &tag, QStringList parameters);
93
94     /** @brief This will add a horizontal flip effect, easier to work when filming yourself. */
95     void mirror(bool activate);
96
97     /** @brief This property is used to decide if the renderer should send audio data for monitoring. */
98     bool analyseAudio;
99     
100     /** @brief True if we are processing an image (yuv > rgb) when recording. */
101     bool processingImage;
102
103 private:
104     Mlt::Consumer * m_mltConsumer;
105     Mlt::Producer * m_mltProducer;
106     Mlt::Profile *m_mltProfile;
107     QString m_activeProfile;
108     int m_droppedFrames;
109     /** @brief When true, images will be displayed on monitor while capturing. */
110     int m_livePreview;
111     /** @brief Count captured frames, used to display only one in ten images while capturing. */
112     int m_frameCount;
113
114     /** @brief The surface onto which the captured frames should be painted. */
115     VideoPreviewContainer *m_captureDisplayWidget;
116
117     /** @brief A human-readable description of this renderer. */
118     int m_winid;
119
120     void uyvy2rgb(unsigned char *yuv_buffer, int width, int height);
121
122     QString m_capturePath;
123
124     /** @brief Build the MLT Consumer object with initial settings.
125      *  @param profileName The MLT profile to use for the consumer */
126     void buildConsumer(const QString &profileName = QString());
127
128
129 private slots:
130     void slotPreparePreview();
131     void slotAllowPreview();
132   
133 signals:
134     /** @brief A frame's image has to be shown.
135      *
136      * Used in Mac OS X. */
137     void showImageSignal(QImage);
138     
139     /** @brief This signal contains the audio of the current frame. */
140     void audioSamplesSignal(const QVector<int16_t>&, int freq, int num_channels, int num_samples);
141
142     void frameSaved(const QString &);
143     
144     void droppedFrames(int);
145     
146     void unblockPreview();
147     void imageReady(QImage);
148
149
150 public slots:
151
152     /** @brief Stops the consumer. */
153     void stop();
154 };
155
156 #endif