]> git.sesse.net Git - kdenlive/blobdiff - src/recmonitor.cpp
Check clips property before launching proxy creation so that we only proxy the HD...
[kdenlive] / src / recmonitor.cpp
index 24cdd8119e3a969c7b18cf4d9ee2df40c8a014e7..51e9b1bf202df2d50989b20e5f2a2ff851bfb0a1 100644 (file)
@@ -50,7 +50,9 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) :
     m_isActive(false),
     m_isCapturing(false),
     m_didCapture(false),
-    m_isPlaying(false)
+    m_isPlaying(false),
+    m_bmCapture(NULL),
+    m_blackmagicCapturing(false)
 {
     setupUi(this);
 
@@ -58,9 +60,7 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) :
     device_selector->setCurrentIndex(KdenliveSettings::defaultcapture());
     connect(device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(slotVideoDeviceChanged(int)));
 
-
-
-    QToolBar *toolbar = new QToolBar(name, this);
+    QToolBar *toolbar = new QToolBar(this);
     QHBoxLayout *layout = new QHBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
     m_playIcon = KIcon("media-playback-start");
@@ -92,8 +92,12 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) :
     configAction->setCheckable(false);
 
     layout->addWidget(toolbar);
-
+    layout->addWidget(&m_logger);
     layout->addWidget(&m_dvinfo);
+    m_logger.setMaxCount(10);
+    m_logger.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    m_logger.setFrame(false);
+    //m_logger.setInsertPolicy(QComboBox::InsertAtTop);
 
 #if KDE_IS_VERSION(4,2,0)
     m_freeSpace = new KCapacityBar(KCapacityBar::DrawTextInline, this);
@@ -179,6 +183,14 @@ void RecMonitor::slotUpdateCaptureFolder(const QString currentProjectFolder)
 
 void RecMonitor::slotVideoDeviceChanged(int ix)
 {
+    QString capturefile;
+    QString capturename;
+    video_capture->setHidden(true);
+    video_frame->setHidden(false);
+    m_fwdAction->setVisible(ix != BLACKMAGIC);
+    m_discAction->setVisible(ix != BLACKMAGIC);
+    m_rewAction->setVisible(ix != BLACKMAGIC);
+    m_logger.setVisible(ix == BLACKMAGIC);
     switch (ix) {
     case SCREENGRAB:
         m_discAction->setEnabled(false);
@@ -204,6 +216,19 @@ void RecMonitor::slotVideoDeviceChanged(int ix)
         m_playAction->setEnabled(true);
         checkDeviceAvailability();
         break;
+    case BLACKMAGIC:
+        createBlackmagicDevice();
+        m_recAction->setEnabled(false);
+        m_stopAction->setEnabled(false);
+        m_playAction->setEnabled(true);
+
+        capturefile = m_capturePath;
+        if (!capturefile.endsWith("/")) capturefile.append("/");
+        capturename = KdenliveSettings::hdmifilename();
+        capturename.append("xxx.raw");
+        capturefile.append(capturename);
+        video_frame->setPixmap(mergeSideBySide(KIcon("camera-photo").pixmap(QSize(50, 50)), i18n("Plug your camcorder and\npress play button\nto start preview.\nFiles will be saved in:\n%1", capturefile)));
+        break;
     default: // FIREWIRE
         m_discAction->setEnabled(true);
         m_recAction->setEnabled(false);
@@ -219,9 +244,9 @@ void RecMonitor::slotVideoDeviceChanged(int ix)
             else KdenliveSettings::setDvgrab_path(dvgrabpath);
         } else {
             // Show capture info
-            QString capturefile = m_capturePath;
+            capturefile = m_capturePath;
             if (!capturefile.endsWith("/")) capturefile.append("/");
-            QString capturename = KdenliveSettings::dvgrabfilename();
+            capturename = KdenliveSettings::dvgrabfilename();
             if (capturename.isEmpty()) capturename = "capture";
             QString extension;
             switch (KdenliveSettings::firewireformat()) {
@@ -244,6 +269,28 @@ void RecMonitor::slotVideoDeviceChanged(int ix)
     }
 }
 
+void RecMonitor::createBlackmagicDevice()
+{
+    //video_capture->setVisible(true);
+    if (m_bmCapture == NULL) {
+        QVBoxLayout *lay = new QVBoxLayout;
+        m_bmCapture = new BmdCaptureHandler(lay);
+        connect(m_bmCapture, SIGNAL(gotTimeCode(ulong)), this, SLOT(slotGotBlackMagicFrameNumber(ulong)));
+        connect(m_bmCapture, SIGNAL(gotMessage(const QString &)), this, SLOT(slotGotBlackmagicMessage(const QString &)));
+        video_capture->setLayout(lay);
+    }
+}
+
+void RecMonitor::slotGotBlackmagicFrameNumber(ulong ix)
+{
+    m_dvinfo.setText(QString::number(ix));
+}
+
+void RecMonitor::slotGotBlackmagicMessage(const QString &message)
+{
+    m_logger.insertItem(0, message);
+}
+
 QPixmap RecMonitor::mergeSideBySide(const QPixmap& pix, const QString txt)
 {
     QPainter p;
@@ -309,6 +356,8 @@ void RecMonitor::slotForward()
 void RecMonitor::slotStopCapture()
 {
     // stop capture
+    video_capture->setHidden(true);
+    video_frame->setHidden(false);
     switch (device_selector->currentIndex()) {
     case FIREWIRE:
         m_captureProcess->write("\e", 2);
@@ -320,6 +369,12 @@ void RecMonitor::slotStopCapture()
         m_captureProcess->write("q\n", 3);
         QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
         break;
+    case BLACKMAGIC:
+        m_bmCapture->stopPreview();
+        m_playAction->setEnabled(true);
+        m_stopAction->setEnabled(false);
+        m_recAction->setEnabled(false);
+        break;
     default:
         break;
     }
@@ -347,6 +402,8 @@ void RecMonitor::slotStartCapture(bool play)
     m_isPlaying = false;
     QString capturename = KdenliveSettings::dvgrabfilename();
     QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts);
+    video_capture->setVisible(device_selector->currentIndex() == BLACKMAGIC);
+    video_frame->setHidden(device_selector->currentIndex() == BLACKMAGIC);
 
     switch (device_selector->currentIndex()) {
     case FIREWIRE:
@@ -369,7 +426,7 @@ void RecMonitor::slotStartCapture(bool play)
         case 3:
             // HDV CAPTURE
             m_captureArgs << "--format" << "hdv";
-            m_displayArgs << "-f" << KdenliveSettings::video4container();
+            m_displayArgs << "-f" << "mpegts";
             break;
         }
         if (KdenliveSettings::firewireautosplit()) m_captureArgs << "--autosplit";
@@ -398,11 +455,17 @@ void RecMonitor::slotStartCapture(bool play)
         kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");
         m_captureProcess->start("ffmpeg", m_captureArgs);
         break;
+    case BLACKMAGIC:
+        m_bmCapture->startPreview(KdenliveSettings::hdmi_capturedevice(), KdenliveSettings::hdmi_capturemode());
+        m_playAction->setEnabled(false);
+        m_stopAction->setEnabled(true);
+        m_recAction->setEnabled(true);
+        break;
     default:
         break;
     }
 
-    if (device_selector->currentIndex() != SCREENGRAB) {
+    if (device_selector->currentIndex() == FIREWIRE || device_selector->currentIndex() == VIDEO4LINUX) {
         kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
         m_displayProcess->start("ffplay", m_displayArgs);
         video_frame->setText(i18n("Initialising..."));
@@ -413,6 +476,22 @@ void RecMonitor::slotStartCapture(bool play)
 
 void RecMonitor::slotRecord()
 {
+    if (device_selector->currentIndex() == BLACKMAGIC) {
+        if (m_blackmagicCapturing) {
+            // We are capturing, stop it
+            m_bmCapture->stopCapture();
+            m_blackmagicCapturing = false;
+        } else {
+            // Start capture, get capture filename first
+            QString path = m_capturePath;
+            if (!path.endsWith("/")) path.append("/");
+            path.append(KdenliveSettings::hdmifilename());
+            m_bmCapture->startCapture(path);
+            m_blackmagicCapturing = true;
+        }
+        return;
+    }
+
     if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
         slotStartCapture();
     }