]> git.sesse.net Git - kdenlive/blobdiff - src/mltdevicecapture.cpp
Cleanup: remove duplicate monitor code, allow fullscreen for record monitor
[kdenlive] / src / mltdevicecapture.cpp
index 26dbf48d1dc2bc80fbf010f5845eba8fe456852b..419878bd6a203532885297a7293fc64cb9926d1d 100644 (file)
@@ -76,7 +76,7 @@ static void rec_consumer_frame_preview(mlt_consumer, MltDeviceCapture * self, ml
 }
 
 
-MltDeviceCapture::MltDeviceCapture(QString profile, VideoPreviewContainer *surface, QWidget *parent) :
+MltDeviceCapture::MltDeviceCapture(QString profile, VideoContainer *surface, QWidget *parent) :
     AbstractRender(Kdenlive::recordMonitor, parent),
     doCapture(0),
     sendFrameForAnalysis(false),
@@ -87,9 +87,9 @@ MltDeviceCapture::MltDeviceCapture(QString profile, VideoPreviewContainer *surfa
     m_showFrameEvent(NULL),
     m_droppedFrames(0),
     m_livePreview(KdenliveSettings::enable_recording_preview()),
-    m_captureDisplayWidget(surface),
     m_winid((int) surface->winId())
 {
+    m_captureDisplayWidget = surface;
     analyseAudio = KdenliveSettings::monitor_audio();
     if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
     buildConsumer(profile);
@@ -163,12 +163,21 @@ void MltDeviceCapture::buildConsumer(const QString &profileName)
     //m_mltConsumer->set("real_time", 0);
 }
 
+void MltDeviceCapture::pause()
+{   
+    if (m_mltConsumer) {
+          m_mltConsumer->set("refresh", 0);
+         //m_mltProducer->set_speed(0.0);
+         m_mltConsumer->purge();
+    }
+}
+
 void MltDeviceCapture::stop()
 {
     m_droppedFramesTimer.stop();
     bool isPlaylist = false;
-    disconnect(this, SIGNAL(imageReady(QImage)), this, SIGNAL(frameUpdated(QImage)));
-    m_captureDisplayWidget->stop();
+    //disconnect(this, SIGNAL(imageReady(QImage)), this, SIGNAL(frameUpdated(QImage)));
+    //m_captureDisplayWidget->stop();
     
     if (m_showFrameEvent) delete m_showFrameEvent;
     m_showFrameEvent = NULL;
@@ -215,9 +224,16 @@ void MltDeviceCapture::stop()
 }
 
 
-void MltDeviceCapture::doRefresh()
+void MltDeviceCapture::slotDoRefresh()
 {
-    if (m_mltConsumer) m_mltConsumer->set("refresh", 1);
+    QMutexLocker locker(&m_mutex);
+    if (!m_mltProducer)
+        return;
+    if (m_mltConsumer) {
+        if (m_mltConsumer->is_stopped()) m_mltConsumer->start();
+        m_mltConsumer->purge();
+        m_mltConsumer->set("refresh", 1);
+    }
 }
 
 
@@ -308,7 +324,7 @@ bool MltDeviceCapture::slotStartPreview(const QString &producer, bool xmlFormat)
         return 0;
     }
     m_droppedFramesTimer.start();
-    connect(this, SIGNAL(imageReady(QImage)), this, SIGNAL(frameUpdated(QImage)));
+    //connect(this, SIGNAL(imageReady(QImage)), this, SIGNAL(frameUpdated(QImage)));
     return 1;
 }
 
@@ -343,7 +359,7 @@ void MltDeviceCapture::gotCapturedFrame(Mlt::Frame& frame)
     //memcpy(image.bits(), data, width * height * 3);
     QImage image((uchar *)data, width, height, QImage::Format_RGB888);
 
-    m_captureDisplayWidget->setImage(image);
+    //m_captureDisplayWidget->setImage(image);
 
     //TEST: is it better to process frame conversion ouside MLT???
     /*
@@ -731,7 +747,7 @@ void MltDeviceCapture::uyvy2rgb(unsigned char *yuv_buffer, int width, int height
         rgb_ptr += 3;
     }
     //emit imageReady(image);
-    m_captureDisplayWidget->setImage(image);
+    //m_captureDisplayWidget->setImage(image);
     emit unblockPreview();
     //processingImage = false;
 }