]> git.sesse.net Git - kdenlive/blob - src/recmonitor.h
Audio recording (works even while playing project, nice for voiceover)
[kdenlive] / src / recmonitor.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 /**
21 * @class RecMonitor
22 * @brief Records video via dvgrab, video4linux and recordmydesktop
23 * @author Jean-Baptiste Mardelle
24 */
25
26 #ifndef RECMONITOR_H
27 #define RECMONITOR_H
28
29 #include "abstractmonitor.h"
30 #include "definitions.h"
31 #include "ui_recmonitor_ui.h"
32
33 #include <QToolBar>
34 #include <QTimer>
35 #include <QProcess>
36 #include <QImage>
37
38 #include <KIcon>
39 #include <KAction>
40 #include <KSelectAction>
41 #include <KRestrictedLine>
42 #include <KDateTime>
43 #include <kdeversion.h>
44 #include <KComboBox>
45 #include <kcapacitybar.h>
46
47 class MonitorManager;
48 class MltDeviceCapture;
49 class AbstractRender;
50
51 class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI
52 {
53     Q_OBJECT
54
55 public:
56     explicit RecMonitor(QString name, MonitorManager *manager, QWidget *parent = 0);
57     virtual ~RecMonitor();
58
59     const QString name() const;
60     AbstractRender *abstractRender();
61     void analyseFrames(bool analyse);
62     enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3};
63
64 protected:
65     virtual void mousePressEvent(QMouseEvent * event);
66
67 private:
68     QString m_name;
69     KDateTime m_captureTime;
70     /** @brief Provide feedback about dvgrab operations */
71     QLabel m_dvinfo;
72     
73     /** @brief Keeps a brief (max ten items) history of warning or error messages
74      *  (currently only used for BLACKMAGIC). */
75     KComboBox m_logger;
76     QString m_capturePath;
77
78     KCapacityBar *m_freeSpace;
79     QTimer m_spaceTimer;
80
81     KUrl m_captureFile;
82     KIcon m_playIcon;
83     KIcon m_pauseIcon;
84
85     QProcess *m_captureProcess;
86     QProcess *m_displayProcess;
87     bool m_isCapturing;
88     /** did the user capture something ? */
89     bool m_didCapture;
90     bool m_isPlaying;
91     QStringList m_captureArgs;
92     QStringList m_displayArgs;
93     QAction *m_recAction;
94     QAction *m_playAction;
95     QAction *m_fwdAction;
96     QAction *m_rewAction;
97     QAction *m_stopAction;
98     QAction *m_discAction;
99
100     MonitorManager *m_manager;
101     MltDeviceCapture *m_captureDevice;
102     VideoPreviewContainer *m_videoBox;
103     QAction *m_addCapturedClip;
104     KSelectAction *m_previewSettings;
105     
106     bool m_analyse;
107     void checkDeviceAvailability();
108     QPixmap mergeSideBySide(const QPixmap& pix, const QString &txt);
109     void manageCapturedFiles();
110     /** @brief Build MLT producer for device, using path as profile. */
111     void buildMltDevice(const QString &path);
112     /** @brief Create string containing an XML playlist for v4l capture. */
113     const QString getV4lXmlPlaylist(MltVideoProfile profile);
114
115 private slots:
116     void slotStartPreview(bool play = true);
117     void slotRecord();
118     void slotProcessStatus(QProcess::ProcessState status);
119     void slotVideoDeviceChanged(int ix);
120     void slotRewind();
121     void slotForward();
122     void slotDisconnect();
123     //void slotStartGrab(const QRect &rect);
124     void slotConfigure();
125     void slotReadDvgrabInfo();
126     void slotUpdateFreeSpace();
127     void slotSetInfoMessage(const QString &message);
128     void slotDroppedFrames(int dropped);
129     /** @brief Change setting for preview while recording. */
130     void slotChangeRecordingPreview(int ix);
131
132 public slots:
133     void refreshRecMonitor(bool visible);
134     void slotPlay();
135     void stop();
136     void start();
137     void slotStopCapture();
138     void slotUpdateCaptureFolder(const QString &currentProjectFolder);
139
140 signals:
141     void renderPosition(int);
142     void durationChanged(int);
143     void addProjectClip(KUrl);
144     void addProjectClipList(KUrl::List);
145     void showConfigDialog(int, int);
146 };
147
148 #endif