]> git.sesse.net Git - kdenlive/blob - src/recmonitor.h
b5d767a5dabe7a937a3621f7bc3ff2536e16a5e5
[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 <KRestrictedLine>
41 #include <KDateTime>
42 #include <kdeversion.h>
43 #include <KComboBox>
44 #include <kcapacitybar.h>
45
46 #if KDE_IS_VERSION(4,7,0)
47 #include <KMessageWidget>
48 #endif
49
50 class MonitorManager;
51 class MltDeviceCapture;
52 class AbstractRender;
53
54 class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI
55 {
56     Q_OBJECT
57
58 public:
59     explicit RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidget *parent = 0);
60     ~RecMonitor();
61
62     AbstractRender *abstractRender();
63     void analyseFrames(bool analyse);
64     enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3};
65
66 protected:
67     void mousePressEvent(QMouseEvent * event);
68     void mouseDoubleClickEvent(QMouseEvent * event);
69
70 private:
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     KCapacityBar *m_freeSpace;
81     QTimer m_spaceTimer;
82
83     KUrl m_captureFile;
84     KIcon m_playIcon;
85     KIcon m_pauseIcon;
86
87     QProcess *m_captureProcess;
88     QProcess *m_displayProcess;
89     bool m_isCapturing;
90     /** did the user capture something ? */
91     bool m_didCapture;
92     bool m_isPlaying;
93     QStringList m_captureArgs;
94     QStringList m_displayArgs;
95     QAction *m_recAction;
96     QAction *m_playAction;
97     QAction *m_fwdAction;
98     QAction *m_rewAction;
99     QAction *m_stopAction;
100     QAction *m_discAction;
101
102     MonitorManager *m_manager;
103     MltDeviceCapture *m_captureDevice;
104     VideoContainer *m_videoBox;
105     QAction *m_addCapturedClip;
106     QAction *m_previewSettings;
107     QString m_error;
108
109 #if KDE_IS_VERSION(4,7,0)
110     KMessageWidget *m_infoMessage;
111 #endif
112
113     bool m_analyse;
114     void checkDeviceAvailability();
115     QPixmap mergeSideBySide(const QPixmap& pix, const QString &txt);
116     void manageCapturedFiles();
117     /** @brief Build MLT producer for device, using path as profile. */
118     void buildMltDevice(const QString &path);
119     /** @brief Create string containing an XML playlist for v4l capture. */
120     const QString getV4lXmlPlaylist(const MltVideoProfile &profile, bool *isXml);
121     /** @brief Display an error message to user. */
122     void showWarningMessage(const QString &text, bool logAction = false);
123
124 private slots:
125     void slotStartPreview(bool play = true);
126     void slotRecord();
127     void slotProcessStatus(QProcess::ProcessState status);
128     void slotVideoDeviceChanged(int ix);
129     void slotRewind();
130     void slotForward();
131     void slotDisconnect();
132     //void slotStartGrab(const QRect &rect);
133     void slotConfigure();
134     void slotReadProcessInfo();
135     void slotUpdateFreeSpace();
136     void slotSetInfoMessage(const QString &message);
137     void slotDroppedFrames(int dropped);
138     /** @brief Change setting for preview while recording. */
139     void slotChangeRecordingPreview(bool enable);
140     /** @brief Show last jog error log. */
141     void slotShowLog();
142
143 public slots:
144     void refreshRecMonitor(bool visible);
145     void slotPlay();
146     void stop();
147     void start();
148     void slotStopCapture();
149     void slotUpdateCaptureFolder(const QString &currentProjectFolder);
150     void slotMouseSeek(int eventDelta, bool fast);
151     void slotSwitchFullScreen();
152
153 signals:
154     void renderPosition(int);
155     void durationChanged(int);
156     void addProjectClip(KUrl);
157     void addProjectClipList(KUrl::List);
158     void showConfigDialog(int, int);
159 };
160
161 #endif