aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-06-09 22:31:55 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-06-09 22:31:55 +0200
commit815a43744104a718329a5336b13f134bb8c11b33 (patch)
treeb4d99d393b98f7e77a374513ee880236af944e6e
parent2a20154fa3b36ffdfce0473c49c9c5577ac5dfff (diff)
Move record stuff in its own class, first steps to re-introduce webcam capture
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/monitor/CMakeLists.txt1
-rw-r--r--src/monitor/glwidget.cpp3
-rw-r--r--src/monitor/monitor.cpp153
-rw-r--r--src/monitor/monitor.h24
-rw-r--r--src/monitor/recmanager.cpp278
-rw-r--r--src/monitor/recmanager.h86
7 files changed, 394 insertions, 154 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e0fbf62..74c20e4 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -180,6 +180,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
m_clipMonitor = new Monitor(Kdenlive::ClipMonitor, pCore->monitorManager(), this);
pCore->bin()->setMonitor(m_clipMonitor);
+ connect(m_clipMonitor, &Monitor::showConfigDialog, this, &MainWindow::slotPreferences);
connect(pCore->bin(), SIGNAL(clipNeedsReload(QString,bool)),this, SLOT(slotUpdateClip(QString,bool)));
//TODO deprecated, replace with Bin methods if necessary
@@ -199,7 +200,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
m_recMonitor = new RecMonitor(Kdenlive::RecordMonitor, pCore->monitorManager(), this);
connect(m_recMonitor, SIGNAL(addProjectClip(QUrl)), this, SLOT(slotAddProjectClip(QUrl)));
connect(m_recMonitor, SIGNAL(addProjectClipList(QList<QUrl>)), this, SLOT(slotAddProjectClipList(QList<QUrl>)));
- connect(m_recMonitor, SIGNAL(showConfigDialog(int,int)), this, SLOT(slotPreferences(int,int)));
+
*/
pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
diff --git a/src/monitor/CMakeLists.txt b/src/monitor/CMakeLists.txt
index b838792..15022ba 100644
--- a/src/monitor/CMakeLists.txt
+++ b/src/monitor/CMakeLists.txt
@@ -6,6 +6,7 @@ set(kdenlive_SRCS
monitor/monitoreditwidget.cpp
monitor/monitormanager.cpp
monitor/monitorscene.cpp
+ monitor/recmanager.cpp
monitor/recmonitor.cpp
monitor/smallruler.cpp
monitor/sharedframe.cpp
diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index 58f69de..1872f8e 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -174,7 +174,7 @@ void GLWidget::resizeGL(int width, int height)
{
int x, y, w, h;
double this_aspect = (double) width / height;
- double video_aspect = pCore->binController()->profile()->dar();
+ double video_aspect = m_consumer->profile()->dar();
// Special case optimisation to negate odd effect of sample aspect ratio
// not corresponding exactly with image resolution.
@@ -680,7 +680,6 @@ int GLWidget::reconfigure(bool isMulti)
QString serviceName = property("mlt_service").toString();
if (!m_consumer || !m_consumer->is_valid()) {
if (serviceName.isEmpty()) {
- //m_consumer = new Mlt::FilteredConsumer(*pCore->binController()->profile(), "sdl_audio");
m_consumer = new Mlt::FilteredConsumer(*pCore->binController()->profile(), "sdl_audio");
if (m_consumer->is_valid())
serviceName = "sdl_audio";
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index d850c54..4454f0c 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -21,6 +21,7 @@
#include "monitor.h"
#include "glwidget.h"
+#include "recmanager.h"
#include "smallruler.h"
#include "mltcontroller/clipcontroller.h"
#include "mltcontroller/bincontroller.h"
@@ -69,11 +70,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
, m_splitProducer(NULL)
, m_effectCompare(NULL)
, m_forceSizeFactor(0)
- , m_recAction(NULL)
- , m_recToolbar(NULL)
- , m_screenCombo(NULL)
- , m_captureProcess(NULL)
- , m_switchRec(NULL)
+ , m_recManager(NULL)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
@@ -125,8 +122,9 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
if (id == Kdenlive::ClipMonitor) {
// Add options for recording
- m_recToolbar = new QToolBar(this);
- m_recToolbar->setIconSize(QSize(s, s));
+ m_recManager = new RecManager(s, this);
+ connect(m_recManager, &RecManager::warningMessage, this, &Monitor::warningMessage);
+ connect(m_recManager, &RecManager::addClipToProject, this, &Monitor::addClipToProject);
}
m_playIcon = QIcon::fromTheme("media-playback-start");
@@ -201,30 +199,6 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_effectCompare = m_toolbar->addAction(QIcon::fromTheme("view-split-left-right"), i18n("Compare effect"));
m_effectCompare->setCheckable(true);
connect(m_effectCompare, &QAction::toggled, this, &Monitor::slotSwitchCompare);
-
- // Recording options
- m_recAction = m_recToolbar->addAction(QIcon::fromTheme("media-record"), i18n("Record"));
- m_recAction->setCheckable(true);
- connect(m_recAction, &QAction::toggled, this, &Monitor::slotRecord);
-
- // Check number of monitors for FFmpeg screen capture
- int screens = QApplication::desktop()->screenCount();
- if (screens > 1) {
- m_screenCombo = new QComboBox(this);
- for (int ix = 0; ix < screens; ix++) {
- m_screenCombo->addItem(i18n("Monitor %1", ix));
- }
- m_recToolbar->addWidget(m_screenCombo);
- // Update screen grab monitor choice in case we changed from fullscreen
- m_screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
- }
- QWidget *spacer = new QWidget(this);
- spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_recToolbar->addWidget(spacer);
- m_switchRec = m_recToolbar->addAction(QIcon::fromTheme("list-add"), i18n("Show Record Control"));
- m_switchRec->setCheckable(true);
- connect(m_switchRec, &QAction::toggled, this, &Monitor::slotSwitchRec);
- m_recToolbar->setVisible(false);
}
// we need to show / hide the popup once so that it's geometry can be calculated in slotShowVolume
m_volumePopup->show();
@@ -264,13 +238,13 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
QWidget *spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_toolbar->addWidget(spacer);
- if (m_switchRec) m_toolbar->addAction(m_switchRec);
+ if (m_recManager) m_toolbar->addAction(m_recManager->switchAction());
m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this);
m_toolbar->addWidget(m_timePos);
connect(m_timePos, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotSeek()));
m_toolbar->setMaximumHeight(m_timePos->height());
layout->addWidget(m_toolbar);
- if (m_recToolbar) layout->addWidget(m_recToolbar);
+ if (m_recManager) layout->addWidget(m_recManager->toolbar());
// Info message widget
m_infoMessage = new KMessageWidget(this);
@@ -1026,6 +1000,13 @@ void Monitor::updateClipProducer(Mlt::Producer *prod)
render->setProducer(prod, render->seekFramePosition(), true);
}
+void Monitor::updateClipProducer(const QString &playlist)
+{
+ if (render == NULL) return;
+ Mlt::Producer *prod = new Mlt::Producer(*profile(), playlist.toUtf8().constData());
+ render->setProducer(prod, render->seekFramePosition(), true);
+}
+
void Monitor::openClip(ClipController *controller)
{
if (render == NULL) return;
@@ -1481,114 +1462,16 @@ Mlt::Profile *Monitor::profile()
return m_monitorManager->binController()->profile();
}
-
-void Monitor::slotRecord(bool record)
-{
- if (!record) {
- if (!m_captureProcess) return;
- m_captureProcess->terminate();
- QTimer::singleShot(1500, m_captureProcess, SLOT(kill()));
- return;
- }
- if (m_captureProcess) return;
- m_recError.clear();
- m_captureProcess = new QProcess;
- connect(m_captureProcess, &QProcess::stateChanged, this, &Monitor::slotProcessStatus);
- connect(m_captureProcess, &QProcess::readyReadStandardError, this, &Monitor::slotReadProcessInfo);
-
- QString extension = KdenliveSettings::grab_extension();
- QString capturePath = KdenliveSettings::capturefolder();
- QString path = QUrl(capturePath).path() + QDir::separator() + "capture0000." + extension;
- int i = 1;
- while (QFile::exists(path)) {
- QString num = QString::number(i).rightJustified(4, '0', false);
- path = QUrl(capturePath).path() + QDir::separator() + "capture" + num + '.' + extension;
- ++i;
- }
- m_captureFile = QUrl(path);
- QString args;
- QString captureSize;
- int screen = -1;
- if (m_screenCombo) {
- // Multi monitor setup, capture monitor selected by user
- screen = m_screenCombo->currentIndex();
- }
- QRect screenSize = QApplication::desktop()->screenGeometry(screen);
- QStringList captureArgs;
- captureArgs << "-f" << "x11grab";
- if (KdenliveSettings::grab_follow_mouse()) captureArgs << "-follow_mouse" << "centered";
- if (!KdenliveSettings::grab_hide_frame()) captureArgs << "-show_region" << "1";
- captureSize = ":0.0";
- if (KdenliveSettings::grab_capture_type() == 0) {
- // Full screen capture
- captureArgs << "-s" << QString::number(screenSize.width()) + 'x' + QString::number(screenSize.height());
- captureSize.append('+' + QString::number(screenSize.left()) + '.' + QString::number(screenSize.top()));
- } else {
- // Region capture
- captureArgs << "-s" << QString::number(KdenliveSettings::grab_width()) + 'x' + QString::number(KdenliveSettings::grab_height());
- captureSize.append('+' + QString::number(KdenliveSettings::grab_offsetx()) + '.' + QString::number(KdenliveSettings::grab_offsetx()));
- }
- // fps
- captureArgs << "-r" << QString::number(KdenliveSettings::grab_fps());
- if (KdenliveSettings::grab_hide_mouse()) captureSize.append("+nomouse");
- captureArgs << "-i" << captureSize;
- if (!KdenliveSettings::grab_parameters().simplified().isEmpty())
- captureArgs << KdenliveSettings::grab_parameters().simplified().split(' ');
- captureArgs << path;
-
- m_captureProcess->start(KdenliveSettings::ffmpegpath(), captureArgs);
- if (!m_captureProcess->waitForStarted()) {
- // Problem launching capture app
- warningMessage(i18n("Failed to start the capture application:\n%1", KdenliveSettings::ffmpegpath()));
- //delete m_captureProcess;
- }
-}
-
-
-void Monitor::slotProcessStatus(QProcess::ProcessState status)
-{
- if (status == QProcess::NotRunning) {
- m_recAction->setEnabled(true);
- m_recAction->setChecked(false);
- //device_selector->setEnabled(true);
- if (m_captureProcess) {
- if (m_captureProcess->exitStatus() == QProcess::CrashExit) {
- warningMessage(i18n("Capture crashed, please check your parameters"));
- } else {
- if (true) {
- int code = m_captureProcess->exitCode();
- if (code != 0 && code != 255) {
- warningMessage(i18n("Capture crashed, please check your parameters"));
- }
- else {
- // Capture successfull, add clip to project
- emit addClipToProject(m_captureFile);
- }
- }
- }
- }
- delete m_captureProcess;
- m_captureProcess = NULL;
- }
-}
-
-void Monitor::slotReadProcessInfo()
-{
- QString data = m_captureProcess->readAllStandardError().simplified();
- m_recError.append(data + '\n');
-}
-
void Monitor::slotSwitchRec(bool enable)
{
+ if (!m_recManager) return;
if (enable) {
m_toolbar->setVisible(false);
- m_recToolbar->setVisible(true);
+ m_recManager->toolbar()->setVisible(true);
}
else {
- if (m_captureProcess) {
- slotRecord(false);
- }
- m_recToolbar->setVisible(false);
+ m_recManager->stopCapture();
+ m_recManager->toolbar()->setVisible(false);
m_toolbar->setVisible(true);
}
}
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index bc62b54..6ed0e32 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -49,7 +49,7 @@ class KSelectAction;
class KMessageWidget;
class QQuickItem;
class QScrollBar;
-class QComboBox;
+class RecManager;
class Monitor : public AbstractMonitor
{
@@ -134,12 +134,7 @@ private:
int m_length;
bool m_dragStarted;
//TODO: Move capture stuff in own class
- QAction *m_switchRec;
- QString m_captureFolder;
- QUrl m_captureFile;
- QString m_recError;
- QProcess *m_captureProcess;
-
+ RecManager *m_recManager;
QIcon m_playIcon;
QIcon m_pauseIcon;
/** @brief The widget showing current time position **/
@@ -149,12 +144,10 @@ private:
/** Has to be available so we can enable and disable it. */
QAction *m_loopClipAction;
QAction *m_effectCompare;
- QAction *m_recAction;
QMenu *m_contextMenu;
QMenu *m_configMenu;
QMenu *m_playMenu;
QMenu *m_markerMenu;
- QComboBox *m_screenCombo;
QPoint m_DragStartPosition;
/** Selected clip/transition in timeline. Used for looping it. */
AbstractClipItem *m_selectedClip;
@@ -163,7 +156,6 @@ private:
bool m_loopClipTransition;
GenTime getSnapForPos(bool previous);
QToolBar *m_toolbar;
- QToolBar *m_recToolbar;
QWidget *m_volumeWidget;
QSlider *m_audioSlider;
QAction *m_editMarker;
@@ -173,8 +165,6 @@ private:
QQuickItem *m_rootItem;
void adjustScrollBars(float horizontal, float vertical);
void loadMasterQml();
- /** @brief Display a non blocking error message to user **/
- void warningMessage(const QString &text);
private slots:
void seekCursor(int pos);
@@ -199,15 +189,14 @@ private slots:
void slotShowMenu(const QPoint pos);
void slotForceSize(QAction *a);
void slotSeekToKeyFrame();
- void slotRecord(bool record);
- void slotProcessStatus(QProcess::ProcessState status);
- void slotReadProcessInfo();
- void slotSwitchRec(bool enable);
+ /** @brief Display a non blocking error message to user **/
+ void warningMessage(const QString &text);
public slots:
void slotOpenFile(const QString &);
//void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
void updateClipProducer(Mlt::Producer *prod);
+ void updateClipProducer(const QString &playlist);
void openClip(ClipController *controller);
void openClipZone(ClipController *controller, int in, int out);
void refreshMonitor(bool visible);
@@ -248,6 +237,8 @@ public slots:
void slotSetSelectedClip(Transition *item);
void slotMouseSeek(int eventDelta, bool fast);
void slotSwitchFullScreen(bool minimizeOnly = false);
+ /** @brief Display or hide the record toolbar */
+ void slotSwitchRec(bool enable);
signals:
void renderPosition(int);
@@ -264,6 +255,7 @@ signals:
void addKeyframe();
void seekToKeyframe(int);
void addClipToProject(QUrl);
+ void showConfigDialog(int,int);
};
#endif
diff --git a/src/monitor/recmanager.cpp b/src/monitor/recmanager.cpp
new file mode 100644
index 0000000..fc88e76
--- /dev/null
+++ b/src/monitor/recmanager.cpp
@@ -0,0 +1,278 @@
+/***************************************************************************
+ * Copyright (C) 2015 by Jean-Baptiste Mardelle ([email protected]) *
+ * This file is part of Kdenlive. See www.kdenlive.org. *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License or (at your option) version 3 or any later version *
+ * accepted by the membership of KDE e.V. (or its successor approved *
+ * by the membership of KDE e.V.), which shall act as a proxy *
+ * defined in Section 14 of version 3 of the license. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include "recmanager.h"
+#include "monitor.h"
+#include "kdenlivesettings.h"
+#include "capture/mltdevicecapture.h"
+#include "capture/managecapturesdialog.h"
+#include "dialogs/profilesdialog.h"
+
+#include <QDebug>
+#include "klocalizedstring.h"
+
+#include <QComboBox>
+#include <QToolBar>
+#include <QDesktopWidget>
+#include <QStandardPaths>
+#include <QIcon>
+#include <QDir>
+#include <QFile>
+
+RecManager::RecManager(int iconSize, Monitor *parent) :
+ QObject(parent)
+ , m_monitor(parent)
+ , m_recToolbar(new QToolBar(parent))
+ , m_screenCombo(NULL)
+ , m_captureProcess(NULL)
+{
+ m_recToolbar->setIconSize(QSize(iconSize, iconSize));
+ m_playAction = m_recToolbar->addAction(QIcon::fromTheme("media-playback-start"), i18n("Preview"));
+ m_playAction->setCheckable(true);
+ connect(m_playAction, &QAction::toggled, this, &RecManager::slotPreview);
+
+ m_recAction = m_recToolbar->addAction(QIcon::fromTheme("media-record"), i18n("Record"));
+ m_recAction->setCheckable(true);
+ connect(m_recAction, &QAction::toggled, this, &RecManager::slotRecord);
+
+ // Check number of monitors for FFmpeg screen capture
+ int screens = QApplication::desktop()->screenCount();
+ if (screens > 1) {
+ m_screenCombo = new QComboBox(parent);
+ for (int ix = 0; ix < screens; ix++) {
+ m_screenCombo->addItem(i18n("Monitor %1", ix));
+ }
+ m_recToolbar->addWidget(m_screenCombo);
+ // Update screen grab monitor choice in case we changed from fullscreen
+ m_screenCombo->setEnabled(KdenliveSettings::grab_capture_type() == 0);
+ }
+ QWidget *spacer = new QWidget(parent);
+ spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_recToolbar->addWidget(spacer);
+ m_device_selector = new QComboBox(parent);
+ m_device_selector->addItems(QStringList() << i18n("Firewire") << i18n("Webcam") << i18n("Screen Grab") << i18n("Blackmagic Decklink"));
+ m_device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
+ connect(m_device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
+ m_recToolbar->addWidget(m_device_selector);
+ QAction *configureRec = m_recToolbar->addAction(QIcon::fromTheme("configure"), i18n("Configure Recording"));
+ connect(configureRec, &QAction::triggered, this, &RecManager::showRecConfig);
+ m_recToolbar->addSeparator();
+ m_switchRec = m_recToolbar->addAction(QIcon::fromTheme("list-add"), i18n("Show Record Control"));
+ m_switchRec->setCheckable(true);
+ connect(m_switchRec, &QAction::toggled, m_monitor, &Monitor::slotSwitchRec);
+ m_recToolbar->setVisible(false);
+ slotVideoDeviceChanged(m_device_selector->currentIndex());
+}
+
+RecManager::~RecManager()
+{
+}
+
+void RecManager::showRecConfig()
+{
+ qDebug()<<"+ + +SHOW CONFIG + + +";
+ m_monitor->showConfigDialog(4, m_device_selector->currentIndex());
+}
+
+QToolBar *RecManager::toolbar() const
+{
+ return m_recToolbar;
+}
+
+QAction *RecManager::switchAction() const
+{
+ return m_switchRec;
+}
+
+void RecManager::stopCapture()
+{
+ if (m_captureProcess) {
+ slotRecord(false);
+ }
+}
+
+
+void RecManager::slotRecord(bool record)
+{
+ if (!record) {
+ if (!m_captureProcess) return;
+ m_captureProcess->terminate();
+ QTimer::singleShot(1500, m_captureProcess, SLOT(kill()));
+ return;
+ }
+ if (m_captureProcess) return;
+ m_recError.clear();
+ m_captureProcess = new QProcess;
+ connect(m_captureProcess, &QProcess::stateChanged, this, &RecManager::slotProcessStatus);
+ connect(m_captureProcess, &QProcess::readyReadStandardError, this, &RecManager::slotReadProcessInfo);
+
+ QString extension = KdenliveSettings::grab_extension();
+ QString capturePath = KdenliveSettings::capturefolder();
+ QString path = QUrl(capturePath).path() + QDir::separator() + "capture0000." + extension;
+ int i = 1;
+ while (QFile::exists(path)) {
+ QString num = QString::number(i).rightJustified(4, '0', false);
+ path = QUrl(capturePath).path() + QDir::separator() + "capture" + num + '.' + extension;
+ ++i;
+ }
+ m_captureFile = QUrl(path);
+ QString args;
+ QString captureSize;
+ int screen = -1;
+ if (m_screenCombo) {
+ // Multi monitor setup, capture monitor selected by user
+ screen = m_screenCombo->currentIndex();
+ }
+ QRect screenSize = QApplication::desktop()->screenGeometry(screen);
+ QStringList captureArgs;
+ captureArgs << "-f" << "x11grab";
+ if (KdenliveSettings::grab_follow_mouse()) captureArgs << "-follow_mouse" << "centered";
+ if (!KdenliveSettings::grab_hide_frame()) captureArgs << "-show_region" << "1";
+ captureSize = ":0.0";
+ if (KdenliveSettings::grab_capture_type() == 0) {
+ // Full screen capture
+ captureArgs << "-s" << QString::number(screenSize.width()) + 'x' + QString::number(screenSize.height());
+ captureSize.append('+' + QString::number(screenSize.left()) + '.' + QString::number(screenSize.top()));
+ } else {
+ // Region capture
+ captureArgs << "-s" << QString::number(KdenliveSettings::grab_width()) + 'x' + QString::number(KdenliveSettings::grab_height());
+ captureSize.append('+' + QString::number(KdenliveSettings::grab_offsetx()) + '.' + QString::number(KdenliveSettings::grab_offsetx()));
+ }
+ // fps
+ captureArgs << "-r" << QString::number(KdenliveSettings::grab_fps());
+ if (KdenliveSettings::grab_hide_mouse()) captureSize.append("+nomouse");
+ captureArgs << "-i" << captureSize;
+ if (!KdenliveSettings::grab_parameters().simplified().isEmpty())
+ captureArgs << KdenliveSettings::grab_parameters().simplified().split(' ');
+ captureArgs << path;
+
+ m_captureProcess->start(KdenliveSettings::ffmpegpath(), captureArgs);
+ if (!m_captureProcess->waitForStarted()) {
+ // Problem launching capture app
+ emit warningMessage(i18n("Failed to start the capture application:\n%1", KdenliveSettings::ffmpegpath()));
+ //delete m_captureProcess;
+ }
+}
+
+
+void RecManager::slotProcessStatus(QProcess::ProcessState status)
+{
+ if (status == QProcess::NotRunning) {
+ m_recAction->setEnabled(true);
+ m_recAction->setChecked(false);
+ m_device_selector->setEnabled(true);
+ if (m_captureProcess) {
+ if (m_captureProcess->exitStatus() == QProcess::CrashExit) {
+ warningMessage(i18n("Capture crashed, please check your parameters"));
+ } else {
+ if (true) {
+ int code = m_captureProcess->exitCode();
+ if (code != 0 && code != 255) {
+ emit warningMessage(i18n("Capture crashed, please check your parameters"));
+ }
+ else {
+ // Capture successfull, add clip to project
+ emit addClipToProject(m_captureFile);
+ }
+ }
+ }
+ }
+ delete m_captureProcess;
+ m_captureProcess = NULL;
+ }
+}
+
+void RecManager::slotReadProcessInfo()
+{
+ QString data = m_captureProcess->readAllStandardError().simplified();
+ m_recError.append(data + '\n');
+}
+
+
+void RecManager::slotVideoDeviceChanged(int ix)
+{
+ switch (ix) {
+ case Video4Linux:
+ m_playAction->setEnabled(true);
+ break;
+ case BlackMagic:
+ m_playAction->setEnabled(false);
+ break;
+ default:
+ m_playAction->setEnabled(false);
+ break;
+ }
+ /*
+ m_previewSettings->setEnabled(ix == Video4Linux || ix == BlackMagic);
+ control_frame->setVisible(ix == Video4Linux);
+ monitor_box->setVisible(ix == ScreenBag && monitor_box->count() > 0);
+ m_playAction->setVisible(ix != ScreenBag);
+ m_fwdAction->setVisible(ix == Firewire);
+ m_discAction->setVisible(ix == Firewire);
+ m_rewAction->setVisible(ix == Firewire);
+ m_recAction->setEnabled(ix != Firewire);
+ m_logger.setVisible(ix == BlackMagic);
+ if (m_captureDevice) {
+ // MLT capture still running, abort
+ m_monitorManager->clearScopeSource();
+ m_captureDevice->stop();
+ delete m_captureDevice;
+ m_captureDevice = NULL;
+ }
+
+ // The m_videoBox container has to be shown once before the MLT consumer is build, or preview will fail
+ switch (ix) {
+ case ScreenBag:
+ }
+ */
+}
+
+void RecManager::slotPreview(bool record)
+{
+ //TODO:
+ if (m_device_selector->currentIndex() == Video4Linux) {
+ QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/profiles/video4linux";
+ MltVideoProfile profile = ProfilesDialog::getVideoProfile(path);
+ QString playlist =QString("video4linux2:%1?width:%2&amp;height:%3&amp;frame_rate:%4").arg(KdenliveSettings::video4vdevice()).arg(profile.width).arg(profile.height).arg((double) profile.frame_rate_num / profile.frame_rate_den);
+ m_monitor->updateClipProducer(playlist);
+ }
+
+
+
+ /*
+ buildMltDevice(path);
+
+ bool isXml;
+ producer = getV4lXmlPlaylist(profile, &isXml);
+
+ //producer = QString("avformat-novalidate:video4linux2:%1?width:%2&height:%3&frame_rate:%4").arg(KdenliveSettings::video4vdevice()).arg(profile.width).arg(profile.height).arg((double) profile.frame_rate_num / profile.frame_rate_den);
+ if (!m_captureDevice->slotStartPreview(producer, isXml)) {
+ // v4l capture failed to start
+ video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters..."));
+
+ } else {
+ m_playAction->setEnabled(false);
+ m_stopAction->setEnabled(true);
+ m_isPlaying = true;
+ }
+ }*/
+}
+
diff --git a/src/monitor/recmanager.h b/src/monitor/recmanager.h
new file mode 100644
index 0000000..c45db21
--- /dev/null
+++ b/src/monitor/recmanager.h
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2015 by Jean-Baptiste Mardelle ([email protected]) *
+ * This file is part of Kdenlive. See www.kdenlive.org. *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License or (at your option) version 3 or any later version *
+ * accepted by the membership of KDE e.V. (or its successor approved *
+ * by the membership of KDE e.V.), which shall act as a proxy *
+ * defined in Section 14 of version 3 of the license. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+/*!
+* @class RecManager
+* @brief All recording specific features are gathered here
+* @author Jean-Baptiste Mardelle
+*/
+
+#ifndef RECMANAGER_H
+#define RECMANAGER_H
+
+#include "definitions.h"
+
+#include <QUrl>
+#include <QProcess>
+
+class Monitor;
+class QAction;
+class QToolBar;
+class QComboBox;
+
+
+class RecManager : public QObject
+{
+ Q_OBJECT
+
+enum CaptureDevice {
+ Firewire = 0,
+ Video4Linux = 1,
+ ScreenGrab = 2,
+ BlackMagic = 3
+};
+
+public:
+ explicit RecManager(int iconSize, Monitor *parent = 0);
+ ~RecManager();
+ QToolBar *toolbar() const;
+ void stopCapture();
+ QAction *switchAction() const;
+
+private:
+ Monitor *m_monitor;
+ QAction *m_switchRec;
+ QString m_captureFolder;
+ QUrl m_captureFile;
+ QString m_recError;
+ QProcess *m_captureProcess;
+ QAction *m_recAction;
+ QAction *m_playAction;
+ QToolBar *m_recToolbar;
+ QComboBox *m_screenCombo;
+ QComboBox *m_device_selector;
+
+private slots:
+ void slotRecord(bool record);
+ void slotPreview(bool record);
+ void slotProcessStatus(QProcess::ProcessState status);
+ void slotReadProcessInfo();
+ void showRecConfig();
+ void slotVideoDeviceChanged(int ix);
+
+signals:
+ void addClipToProject(QUrl);
+ void warningMessage(QString);
+};
+
+#endif