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 | |
31 | #include "definitions.h" |
32 | #include "ui_recmonitor_ui.h" |
33 | |
34 | #include <QToolBar> |
35 | #include <QTimer> |
36 | #include <QProcess> |
37 | #include <QImage> |
38 | |
39 | #include <KIcon> |
40 | #include <KAction> |
41 | #include <KRestrictedLine> |
42 | #include <KDateTime> |
43 | #include <kdeversion.h> |
44 | #include <KComboBox> |
45 | #include <kcapacitybar.h> |
46 | |
47 | #if KDE_IS_VERSION(4,7,0) |
48 | #include <KMessageWidget> |
49 | #endif |
50 | |
51 | class MonitorManager; |
52 | class MltDeviceCapture; |
53 | class AbstractRender; |
54 | |
55 | class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI |
56 | { |
57 | Q_OBJECT |
58 | |
59 | public: |
60 | explicit RecMonitor(Kdenlive::MonitorId name, MonitorManager *manager, QWidget *parent = 0); |
61 | ~RecMonitor(); |
62 | |
63 | AbstractRender *abstractRender(); |
64 | void analyseFrames(bool analyse); |
65 | enum CaptureDevice { |
66 | Firewire = 0, |
67 | Video4Linux = 1, |
68 | ScreenBag = 2, |
69 | BlackMagic = 3 |
70 | }; |
71 | |
72 | protected: |
73 | void mousePressEvent(QMouseEvent * event); |
74 | void mouseDoubleClickEvent(QMouseEvent * event); |
75 | |
76 | private: |
77 | KDateTime m_captureTime; |
78 | /** @brief Provide feedback about dvgrab operations */ |
79 | QLabel m_dvinfo; |
80 | |
81 | /** @brief Keeps a brief (max ten items) history of warning or error messages |
82 | * (currently only used for BLACKMAGIC). */ |
83 | KComboBox m_logger; |
84 | QString m_capturePath; |
85 | |
86 | KCapacityBar *m_freeSpace; |
87 | QTimer m_spaceTimer; |
88 | |
89 | KUrl m_captureFile; |
90 | KIcon m_playIcon; |
91 | KIcon m_pauseIcon; |
92 | |
93 | QProcess *m_captureProcess; |
94 | QProcess *m_displayProcess; |
95 | bool m_isCapturing; |
96 | /** did the user capture something ? */ |
97 | bool m_didCapture; |
98 | bool m_isPlaying; |
99 | QStringList m_captureArgs; |
100 | QStringList m_displayArgs; |
101 | QAction *m_recAction; |
102 | QAction *m_playAction; |
103 | QAction *m_fwdAction; |
104 | QAction *m_rewAction; |
105 | QAction *m_stopAction; |
106 | QAction *m_discAction; |
107 | |
108 | MltDeviceCapture *m_captureDevice; |
109 | QAction *m_addCapturedClip; |
110 | QAction *m_previewSettings; |
111 | QString m_error; |
112 | |
113 | #if KDE_IS_VERSION(4,7,0) |
114 | KMessageWidget *m_infoMessage; |
115 | #endif |
116 | |
117 | bool m_analyse; |
118 | void checkDeviceAvailability(); |
119 | QPixmap mergeSideBySide(const QPixmap& pix, const QString &txt); |
120 | void manageCapturedFiles(); |
121 | /** @brief Build MLT producer for device, using path as profile. */ |
122 | void buildMltDevice(const QString &path); |
123 | /** @brief Create string containing an XML playlist for v4l capture. */ |
124 | const QString getV4lXmlPlaylist(const MltVideoProfile &profile, bool *isXml); |
125 | /** @brief Display an error message to user. */ |
126 | void showWarningMessage(const QString &text, bool logAction = false); |
127 | |
128 | private slots: |
129 | void slotStartPreview(bool play = true); |
130 | void slotRecord(); |
131 | void slotProcessStatus(QProcess::ProcessState status); |
132 | void slotVideoDeviceChanged(int ix); |
133 | void slotRewind(); |
134 | void slotForward(); |
135 | void slotDisconnect(); |
136 | //void slotStartGrab(const QRect &rect); |
137 | void slotConfigure(); |
138 | void slotReadProcessInfo(); |
139 | void slotUpdateFreeSpace(); |
140 | void slotSetInfoMessage(const QString &message); |
141 | void slotDroppedFrames(int dropped); |
142 | /** @brief Change setting for preview while recording. */ |
143 | void slotChangeRecordingPreview(bool enable); |
144 | /** @brief Show last jog error log. */ |
145 | void slotShowLog(); |
146 | |
147 | public slots: |
148 | void slotPlay(); |
149 | void stop(); |
150 | void start(); |
151 | void slotStopCapture(); |
152 | void slotUpdateCaptureFolder(const QString ¤tProjectFolder); |
153 | void slotMouseSeek(int eventDelta, bool fast); |
154 | void slotSwitchFullScreen(); |
155 | |
156 | signals: |
157 | void renderPosition(int); |
158 | void durationChanged(int); |
159 | void addProjectClip(KUrl); |
160 | void addProjectClipList(KUrl::List); |
161 | void showConfigDialog(int, int); |
162 | }; |
163 | |
164 | #endif |
165 | |