]> git.sesse.net Git - kdenlive/blob - src/recmonitor.h
* Play audio when previewing in v4l capture mode
[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 class MonitorManager;
47 class MltDeviceCapture;
48 class AbstractRender;
49
50 class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI
51 {
52     Q_OBJECT
53
54 public:
55     explicit RecMonitor(QString name, MonitorManager *manager, QWidget *parent = 0);
56     virtual ~RecMonitor();
57
58     const QString name() const;
59     AbstractRender *abstractRender();
60     void analyseFrames(bool analyse);
61     enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3};
62
63 protected:
64     virtual void mousePressEvent(QMouseEvent * event);
65
66 private:
67     QString m_name;
68     KDateTime m_captureTime;
69     /** @brief Provide feedback about dvgrab operations */
70     QLabel m_dvinfo;
71     
72     /** @brief Keeps a brief (max ten items) history of warning or error messages
73      *  (currently only used for BLACKMAGIC). */
74     KComboBox m_logger;
75     QString m_capturePath;
76
77     KCapacityBar *m_freeSpace;
78     QTimer m_spaceTimer;
79
80     KUrl m_captureFile;
81     KIcon m_playIcon;
82     KIcon m_pauseIcon;
83
84     QProcess *m_captureProcess;
85     QProcess *m_displayProcess;
86     bool m_isCapturing;
87     /** did the user capture something ? */
88     bool m_didCapture;
89     bool m_isPlaying;
90     QStringList m_captureArgs;
91     QStringList m_displayArgs;
92     QAction *m_recAction;
93     QAction *m_playAction;
94     QAction *m_fwdAction;
95     QAction *m_rewAction;
96     QAction *m_stopAction;
97     QAction *m_discAction;
98
99     MonitorManager *m_manager;
100     MltDeviceCapture *m_captureDevice;
101     VideoPreviewContainer *m_videoBox;
102     bool m_analyse;
103     void checkDeviceAvailability();
104     QPixmap mergeSideBySide(const QPixmap& pix, const QString &txt);
105     void manageCapturedFiles();
106     /** @brief Build MLT producer for device, using path as profile. */
107     void buildMltDevice(const QString &path);
108     /** @brief Create string containing an XML playlist for v4l capture. */
109     const QString getV4lXmlPlaylist(MltVideoProfile profile);
110
111 private slots:
112     void slotStartPreview(bool play = true);
113     void slotRecord();
114     void slotProcessStatus(QProcess::ProcessState status);
115     void slotVideoDeviceChanged(int ix);
116     void slotRewind();
117     void slotForward();
118     void slotDisconnect();
119     //void slotStartGrab(const QRect &rect);
120     void slotConfigure();
121     void slotReadDvgrabInfo();
122     void slotUpdateFreeSpace();
123     void slotSetInfoMessage(const QString &message);
124     void slotDroppedFrames(int dropped);
125     /** @brief Change setting for preview while recording. */
126     void slotChangeRecordingPreview(int ix);
127
128 public slots:
129     void refreshRecMonitor(bool visible);
130     void slotPlay();
131     void stop();
132     void start();
133     void slotStopCapture();
134     void slotUpdateCaptureFolder(const QString &currentProjectFolder);
135
136 signals:
137     void renderPosition(int);
138     void durationChanged(int);
139     void addProjectClip(KUrl);
140     void addProjectClipList(KUrl::List);
141     void showConfigDialog(int, int);
142 };
143
144 #endif