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