]> git.sesse.net Git - kdenlive/blob - src/recmonitor.h
Complete rewrite of the video4linux capture to use MLT, in progress.
[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 "blackmagic/capture.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 <KRestrictedLine>
41 #include <KDateTime>
42 #include <kdeversion.h>
43 #include <KComboBox>
44
45 #if KDE_IS_VERSION(4,2,0)
46 #include <kcapacitybar.h>
47 #endif
48
49 class MonitorManager;
50 class MltDeviceCapture;
51 class AbstractRender;
52
53 class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI
54 {
55     Q_OBJECT
56
57 public:
58     explicit RecMonitor(QString name, MonitorManager *manager, QWidget *parent = 0);
59     virtual ~RecMonitor();
60
61     const QString name() const;
62     AbstractRender *abstractRender();
63     void analyseFrames(bool analyse);
64     enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3};
65
66 protected:
67     virtual void mousePressEvent(QMouseEvent * event);
68
69 private:
70     QString m_name;
71     KDateTime m_captureTime;
72     /** @brief Provide feedback about dvgrab operations */
73     QLabel m_dvinfo;
74     
75     /** @brief Keeps a brief (max ten items) history of warning or error messages
76      *  (currently only used for BLACKMAGIC). */
77     KComboBox m_logger;
78     QString m_capturePath;
79
80 #if KDE_IS_VERSION(4,2,0)
81     KCapacityBar *m_freeSpace;
82     QTimer m_spaceTimer;
83 #endif
84
85     KUrl m_captureFile;
86     KIcon m_playIcon;
87     KIcon m_pauseIcon;
88
89     QProcess *m_captureProcess;
90     QProcess *m_displayProcess;
91     bool m_isCapturing;
92     /** did the user capture something ? */
93     bool m_didCapture;
94     bool m_isPlaying;
95     QStringList m_captureArgs;
96     QStringList m_displayArgs;
97     QAction *m_recAction;
98     QAction *m_playAction;
99     QAction *m_fwdAction;
100     QAction *m_rewAction;
101     QAction *m_stopAction;
102     QAction *m_discAction;
103
104
105     CaptureHandler *m_bmCapture;
106     /** @brief Indicates whether we are currently capturing from BLACKMAGIC. */
107     bool m_blackmagicCapturing;
108     MonitorManager *m_manager;
109     MltDeviceCapture *m_captureDevice;
110     VideoPreviewContainer *m_videoBox;
111     bool m_analyse;
112     void checkDeviceAvailability();
113     QPixmap mergeSideBySide(const QPixmap& pix, const QString txt);
114     void manageCapturedFiles();
115     void createBlackmagicDevice();
116
117 private slots:
118     void slotStartCapture(bool play = true);
119     void slotRecord();
120     void slotProcessStatus(QProcess::ProcessState status);
121     void slotVideoDeviceChanged(int ix);
122     void slotRewind();
123     void slotForward();
124     void slotDisconnect();
125     //void slotStartGrab(const QRect &rect);
126     void slotConfigure();
127     void slotReadDvgrabInfo();
128     void slotUpdateFreeSpace();
129     void slotGotBlackmagicFrameNumber(ulong ix);
130     void slotGotBlackmagicMessage(const QString &message);
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 showConfigDialog(int, int);
145 };
146
147 #endif