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