From fb460899af4f72c9d4c328d9a6a2253e4a35b173 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 14 Mar 2012 22:38:36 +0100 Subject: [PATCH] Some more cleanup in monitors, improve capture fullscreen --- src/abstractmonitor.cpp | 46 ++++++++++++-- src/abstractmonitor.h | 27 +++++++-- src/mltdevicecapture.cpp | 2 +- src/mltdevicecapture.h | 4 +- src/monitor.cpp | 110 +++++++++++++++------------------- src/monitor.h | 15 ----- src/recmonitor.cpp | 60 +++++++------------ src/recmonitor.h | 2 - src/renderer.cpp | 2 +- src/renderer.h | 4 +- src/stopmotion/stopmotion.cpp | 21 ++----- src/stopmotion/stopmotion.h | 2 - 12 files changed, 146 insertions(+), 149 deletions(-) diff --git a/src/abstractmonitor.cpp b/src/abstractmonitor.cpp index 02ed9a99..c41569cc 100644 --- a/src/abstractmonitor.cpp +++ b/src/abstractmonitor.cpp @@ -26,13 +26,33 @@ #include #include +#include AbstractMonitor::AbstractMonitor(Kdenlive::MONITORID id, MonitorManager *manager, QWidget *parent): QWidget(parent), m_id(id), + videoSurface(NULL), m_monitorManager(manager) -{} +{ + videoBox = new VideoContainer(this); +} + + +AbstractMonitor::~AbstractMonitor() +{ + if (videoSurface) + delete videoSurface; +} + +void AbstractMonitor::createVideoSurface() +{ + QVBoxLayout *lay = new QVBoxLayout; + lay->setContentsMargins(0, 0, 0, 0); + videoSurface = new VideoSurface; + lay->addWidget(videoSurface); + videoBox->setLayout(lay); +} bool AbstractMonitor::isActive() const { @@ -50,8 +70,6 @@ VideoContainer::VideoContainer(AbstractMonitor* monitor, QWidget *parent) : { setFrameShape(QFrame::NoFrame); setFocusPolicy(Qt::ClickFocus); - setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_OpaquePaintEvent); //setEnabled(false); setContentsMargins(0, 0, 0, 0); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -94,7 +112,6 @@ void VideoContainer::mouseDoubleClickEvent(QMouseEvent * event) void VideoContainer::switchFullScreen() { // TODO: disable screensaver? - m_monitor->pause(); Qt::WindowFlags flags = windowFlags(); if (!isFullScreen()) { // Check if we ahave a multiple monitor setup @@ -142,5 +159,24 @@ void VideoContainer::switchFullScreen() setEnabled(false); show(); } - m_monitor->unpause(); } + +VideoSurface::VideoSurface(QWidget* parent) : + QWidget(parent) +{ + // MonitorRefresh is used as container for the SDL display (it's window id is passed to SDL) + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_OpaquePaintEvent); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + setAttribute(Qt::WA_NoSystemBackground); + setUpdatesEnabled(false); +} + +void VideoSurface::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + //WARNING: This might trigger unnecessary refreshes from MLT's producer, but without this, + // as soon as monitor is covered by a popup menu or another window, image is corrupted. + emit refreshMonitor(); +} + diff --git a/src/abstractmonitor.h b/src/abstractmonitor.h index 33154d40..58fc1093 100644 --- a/src/abstractmonitor.h +++ b/src/abstractmonitor.h @@ -33,7 +33,7 @@ #include class MonitorManager; - +class VideoContainer; class AbstractRender: public QObject { @@ -70,17 +70,35 @@ signals: void audioSamplesSignal(QVector,int,int,int); }; + + +class VideoSurface : public QWidget +{ + Q_OBJECT +public: + VideoSurface(QWidget *parent = 0); + +signals: + void refreshMonitor(); + +protected: + virtual void paintEvent ( QPaintEvent * event ); +}; + + class AbstractMonitor : public QWidget { Q_OBJECT public: AbstractMonitor(Kdenlive::MONITORID id, MonitorManager *manager, QWidget *parent = 0); Kdenlive::MONITORID id() {return m_id;}; - virtual ~AbstractMonitor() {}; + virtual ~AbstractMonitor(); virtual AbstractRender *abstractRender() = 0; - virtual void pause() = 0; - virtual void unpause() = 0; bool isActive() const; + VideoContainer *videoBox; + VideoSurface *videoSurface; + void createVideoSurface(); + public slots: virtual void stop() = 0; @@ -113,5 +131,4 @@ private: AbstractMonitor *m_monitor; }; - #endif diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index 419878bd..e93e5419 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -76,7 +76,7 @@ static void rec_consumer_frame_preview(mlt_consumer, MltDeviceCapture * self, ml } -MltDeviceCapture::MltDeviceCapture(QString profile, VideoContainer *surface, QWidget *parent) : +MltDeviceCapture::MltDeviceCapture(QString profile, VideoSurface *surface, QWidget *parent) : AbstractRender(Kdenlive::recordMonitor, parent), doCapture(0), sendFrameForAnalysis(false), diff --git a/src/mltdevicecapture.h b/src/mltdevicecapture.h index 27c52346..b0004a31 100644 --- a/src/mltdevicecapture.h +++ b/src/mltdevicecapture.h @@ -50,7 +50,7 @@ Q_OBJECT public: /** @brief Build a MLT Renderer * @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering * @param profile The MLT profile used for the capture (default one will be used if empty). */ - MltDeviceCapture(QString profile, VideoContainer *surface, QWidget *parent = 0); + MltDeviceCapture(QString profile, VideoSurface *surface, QWidget *parent = 0); /** @brief Destroy the MLT Renderer. */ ~MltDeviceCapture(); @@ -108,7 +108,7 @@ private: int m_frameCount; /** @brief The surface onto which the captured frames should be painted. */ - VideoContainer *m_captureDisplayWidget; + VideoSurface *m_captureDisplayWidget; /** @brief A human-readable description of this renderer. */ int m_winid; diff --git a/src/monitor.cpp b/src/monitor.cpp index 9dc2aa33..3a69d0f7 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -52,7 +52,6 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil m_scale(1), m_length(0), m_dragStarted(false), - m_monitorRefresh(NULL), m_contextMenu(NULL), m_effectWidget(NULL), m_selectedClip(NULL), @@ -64,8 +63,7 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil layout->setSpacing(0); // Video widget holder - m_videoBox = new VideoContainer(this); - layout->addWidget(m_videoBox, 10); + layout->addWidget(videoBox, 10); layout->addStretch(); // Get base size for icons @@ -149,27 +147,25 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil bool monitorCreated = false; #ifdef Q_WS_MAC - createOpenGlWidget(m_videoBox, profile); + createOpenGlWidget(videoBox, profile); monitorCreated = true; //m_glWidget->setFixedSize(width, height); #elif defined(USE_OPENGL) if (KdenliveSettings::openglmonitors()) { - monitorCreated = createOpenGlWidget(m_videoBox, profile); + monitorCreated = createOpenGlWidget(videoBox, profile); } #endif - QVBoxLayout *lay = new QVBoxLayout; - lay->setContentsMargins(0, 0, 0, 0); if (!monitorCreated) { - m_monitorRefresh = new MonitorRefresh; - lay->addWidget(m_monitorRefresh); - m_videoBox->setLayout(lay); - render = new Render(m_id, (int) m_monitorRefresh->winId(), profile, this); - m_monitorRefresh->setRenderer(render); + createVideoSurface(); + render = new Render(m_id, (int) videoSurface->winId(), profile, this); + connect(videoSurface, SIGNAL(refreshMonitor()), render, SLOT(doRefresh())); } #ifdef USE_OPENGL else if (m_glWidget) { + QVBoxLayout *lay = new QVBoxLayout; + lay->setContentsMargins(0, 0, 0, 0); lay->addWidget(m_glWidget); - m_videoBox->setLayout(lay); + videoBox->setLayout(lay); } #endif @@ -187,12 +183,12 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SLOT(setClipZone(QPoint))); } - if (m_monitorRefresh) m_monitorRefresh->show(); + if (videoSurface) videoSurface->show(); if (id == Kdenlive::projectMonitor) { - m_effectWidget = new MonitorEditWidget(render, m_videoBox); + m_effectWidget = new MonitorEditWidget(render, videoBox); m_toolbar->addAction(m_effectWidget->getVisibilityAction()); - lay->addWidget(m_effectWidget); + videoBox->layout()->addWidget(m_effectWidget); m_effectWidget->hide(); } @@ -213,13 +209,12 @@ Monitor::~Monitor() delete m_overlay; if (m_effectWidget) delete m_effectWidget; - delete m_monitorRefresh; delete render; } QWidget *Monitor::container() { - return m_videoBox; + return videoBox; } #ifdef USE_OPENGL @@ -315,7 +310,7 @@ void Monitor::slotSetSizeOneToOne() height = height * 0.8; } kDebug() << "// MONITOR; set SIZE: " << width << ", " << height; - m_videoBox->setFixedSize(width, height); + videoBox->setFixedSize(width, height); updateGeometry(); adjustSize(); //m_ui.video_frame->setMinimumSize(0, 0); @@ -335,7 +330,7 @@ void Monitor::slotSetSizeOneToTwo() height = height * 0.8; } kDebug() << "// MONITOR; set SIZE: " << width << ", " << height; - m_videoBox->setFixedSize(width, height); + videoBox->setFixedSize(width, height); updateGeometry(); adjustSize(); //m_ui.video_frame->setMinimumSize(0, 0); @@ -344,7 +339,7 @@ void Monitor::slotSetSizeOneToTwo() void Monitor::resetSize() { - m_videoBox->setMinimumSize(0, 0); + videoBox->setMinimumSize(0, 0); } DocClipBase *Monitor::activeClip() @@ -441,7 +436,7 @@ void Monitor::slotSetZoneEnd() void Monitor::mousePressEvent(QMouseEvent * event) { if (event->button() != Qt::RightButton) { - if (m_videoBox->geometry().contains(event->pos()) && (!m_overlay || !m_overlay->underMouse())) { + if (videoBox->geometry().contains(event->pos()) && (!m_overlay || !m_overlay->underMouse())) { m_dragStarted = true; m_DragStartPosition = event->pos(); } @@ -456,17 +451,16 @@ void Monitor::resizeEvent(QResizeEvent *event) if (render && isVisible() && isActive()) render->doRefresh(); } - void Monitor::slotSwitchFullScreen() { - m_videoBox->switchFullScreen(); + videoBox->switchFullScreen(); } // virtual void Monitor::mouseReleaseEvent(QMouseEvent * event) { if (m_dragStarted && event->button() != Qt::RightButton) { - if (m_videoBox->geometry().contains(event->pos()) && (!m_effectWidget || !m_effectWidget->isVisible())) { + if (videoBox->geometry().contains(event->pos()) && (!m_effectWidget || !m_effectWidget->isVisible())) { if (isActive()) slotPlay(); else slotActivateMonitor(); } //else event->ignore(); //QWidget::mouseReleaseEvent(event); @@ -541,7 +535,7 @@ void Monitor::wheelEvent(QWheelEvent * event) void Monitor::mouseDoubleClickEvent(QMouseEvent * event) { if (!KdenliveSettings::openglmonitors()) { - m_videoBox->switchFullScreen(); + videoBox->switchFullScreen(); event->accept(); } } @@ -616,21 +610,24 @@ void Monitor::slotSeek(int pos) void Monitor::checkOverlay() { if (m_overlay == NULL) return; + QString overlayText; int pos = m_ruler->position(); QPoint zone = m_ruler->zone(); if (pos == zone.x()) - m_overlay->setOverlayText(i18n("In Point")); + overlayText = i18n("In Point"); else if (pos == zone.y()) - m_overlay->setOverlayText(i18n("Out Point")); + overlayText = i18n("Out Point"); else { if (m_currentClip) { - QString markerComment = m_currentClip->markerComment(GenTime(pos, m_monitorManager->timecode().fps())); - if (markerComment.isEmpty()) - m_overlay->setHidden(true); - else - m_overlay->setOverlayText(markerComment, false); - } else m_overlay->setHidden(true); + overlayText = m_currentClip->markerComment(GenTime(pos, m_monitorManager->timecode().fps())); + if (!overlayText.isEmpty()) { + m_overlay->setOverlayText(overlayText, false); + return; + } + } } + if (m_overlay->isVisible() && overlayText.isEmpty()) m_overlay->setOverlayText(QString(), false); + else m_overlay->setOverlayText(overlayText); } void Monitor::slotStart() @@ -734,8 +731,8 @@ void Monitor::stop() void Monitor::start() { - if (!isVisible()) return; - if (render) render->start(); + if (!isVisible() || !isActive()) return; + if (render) render->doRefresh();// start(); } void Monitor::refreshMonitor(bool visible) @@ -913,7 +910,7 @@ void Monitor::slotSwitchMonitorInfo(bool show) KdenliveSettings::setDisplayMonitorInfo(show); if (show) { if (m_overlay) return; - if (m_monitorRefresh == NULL) { + if (videoSurface == NULL) { // Using OpenGL display #ifdef USE_OPENGL if (m_glWidget->layout()) delete m_glWidget->layout(); @@ -925,13 +922,13 @@ void Monitor::slotSwitchMonitorInfo(bool show) m_glWidget->setLayout(layout); #endif } else { - if (m_monitorRefresh->layout()) delete m_monitorRefresh->layout(); + if (videoSurface->layout()) delete videoSurface->layout(); m_overlay = new Overlay(); connect(m_overlay, SIGNAL(editMarker()), this, SLOT(slotEditMarker())); QVBoxLayout *layout = new QVBoxLayout; layout->addStretch(10); layout->addWidget(m_overlay); - m_monitorRefresh->setLayout(layout); + videoSurface->setLayout(layout); m_overlay->raise(); m_overlay->setHidden(true); } @@ -992,8 +989,8 @@ void Monitor::slotSetSelectedClip(Transition* item) void Monitor::slotEffectScene(bool show) { if (m_id == Kdenlive::projectMonitor) { - if (m_monitorRefresh) { - m_monitorRefresh->setVisible(!show); + if (videoSurface) { + videoSurface->setVisible(!show); } else { #ifdef USE_OPENGL m_glWidget->setVisible(!show); @@ -1005,7 +1002,7 @@ void Monitor::slotEffectScene(bool show) if (show) { m_effectWidget->getScene()->slotZoomFit(); } - m_videoBox->setEnabled(show); + videoBox->setEnabled(show); render->doRefresh(); } } @@ -1054,22 +1051,6 @@ void Monitor::reloadProducer(const QString &id) slotSetClipProducer(m_currentClip, m_currentClip->zone(), true); } -MonitorRefresh::MonitorRefresh(QWidget* parent) : - QWidget(parent) - , m_renderer(NULL) -{ - // MonitorRefresh is used as container for the SDL display (it's window id is passed to SDL) - setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_OpaquePaintEvent); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - //setAttribute(Qt::WA_NoSystemBackground); -} - -void MonitorRefresh::setRenderer(Render* render) -{ - m_renderer = render; -} - Overlay::Overlay(QWidget* parent) : QLabel(parent) @@ -1102,16 +1083,23 @@ void Overlay::mouseDoubleClickEvent ( QMouseEvent * event ) void Overlay::setOverlayText(const QString &text, bool isZone) { + if (text.isEmpty()) { + QPalette p; + p.setColor(QPalette::Base, KdenliveSettings::window_background()); + setPalette(p); + setText(QString()); + repaint(); + setHidden(true); + return; + } setHidden(true); - m_isZone = isZone; QPalette p; p.setColor(QPalette::Text, Qt::white); - if (m_isZone) p.setColor(QPalette::Base, QColor(200, 0, 0)); + if (isZone) p.setColor(QPalette::Base, QColor(200, 0, 0)); else p.setColor(QPalette::Base, QColor(0, 0, 200)); setPalette(p); setText(' ' + text + ' '); setHidden(false); - update(); } diff --git a/src/monitor.h b/src/monitor.h index 3ea5da5a..0fe6d50a 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -49,17 +49,6 @@ class Monitor; class MonitorManager; -class MonitorRefresh : public QWidget -{ - Q_OBJECT -public: - MonitorRefresh(QWidget *parent = 0); - void setRenderer(Render* render); - -private: - Render *m_renderer; -}; - class Overlay : public QLabel { Q_OBJECT @@ -67,9 +56,6 @@ public: Overlay(QWidget* parent = 0); void setOverlayText(const QString &, bool isZone = true); -private: - bool m_isZone; - protected: virtual void mouseDoubleClickEvent ( QMouseEvent * event ); virtual void mousePressEvent ( QMouseEvent * event ); @@ -132,7 +118,6 @@ private: double m_scale; int m_length; bool m_dragStarted; - MonitorRefresh *m_monitorRefresh; KIcon m_playIcon; KIcon m_pauseIcon; TimecodeDisplay *m_timePos; diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index c24adfae..474cf114 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -61,9 +61,9 @@ RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidge QVBoxLayout *l = new QVBoxLayout; l->setContentsMargins(0, 0, 0, 0); l->setSpacing(0); - m_videoBox = new VideoContainer(this); - l->addWidget(m_videoBox, 10); + l->addWidget(videoBox, 10); video_frame->setLayout(l); + createVideoSurface(); QToolBar *toolbar = new QToolBar(this); QHBoxLayout *layout = new QHBoxLayout; @@ -142,7 +142,7 @@ RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidge QString videoDriver = KdenliveSettings::videodrivername(); #if QT_VERSION >= 0x040600 QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - env.insert("SDL_WINDOWID", QString::number(m_videoBox->winId())); + env.insert("SDL_WINDOWID", QString::number(videoSurface->winId())); if (!videoDriver.isEmpty()) { if (videoDriver == "x11_noaccel") { env.insert("SDL_VIDEO_YUV_HWACCEL", "0"); @@ -152,7 +152,7 @@ RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidge m_displayProcess->setProcessEnvironment(env); #else QStringList env = QProcess::systemEnvironment(); - env << "SDL_WINDOWID=" + QString::number(m_videoBox->winId()); + env << "SDL_WINDOWID=" + QString::number(videoSurface->winId()); if (!videoDriver.isEmpty()) { if (videoDriver == "x11_noaccel") { env << "SDL_VIDEO_YUV_HWACCEL=0"; @@ -163,7 +163,7 @@ RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidge #endif setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 1); - kDebug() << "/////// BUILDING MONITOR, ID: " << m_videoBox->winId(); + kDebug() << "/////// BUILDING MONITOR, ID: " << videoSurface->winId(); slotVideoDeviceChanged(device_selector->currentIndex()); m_previewSettings->setChecked(KdenliveSettings::enable_recording_preview()); connect(m_previewSettings, SIGNAL(triggered(bool)), this, SLOT(slotChangeRecordingPreview(bool))); @@ -179,15 +179,15 @@ RecMonitor::~RecMonitor() void RecMonitor::mouseDoubleClickEvent(QMouseEvent * event) { - if (!KdenliveSettings::openglmonitors() && m_videoBox && m_videoBox->isVisible()) { - m_videoBox->switchFullScreen(); + if (!KdenliveSettings::openglmonitors() && videoBox && videoBox->isVisible()) { + videoBox->switchFullScreen(); event->accept(); } } void RecMonitor::slotSwitchFullScreen() { - m_videoBox->switchFullScreen(); + videoBox->switchFullScreen(); } void RecMonitor::stop() @@ -241,8 +241,8 @@ void RecMonitor::slotVideoDeviceChanged(int ix) } // The m_videoBox container has to be shown once before the MLT consumer is build, or preview will fail - m_videoBox->setHidden(ix != VIDEO4LINUX && ix != BLACKMAGIC); - m_videoBox->setHidden(true); + videoBox->setHidden(ix != VIDEO4LINUX && ix != BLACKMAGIC); + videoBox->setHidden(true); switch (ix) { case SCREENGRAB: m_discAction->setEnabled(false); @@ -384,7 +384,7 @@ void RecMonitor::slotStopCapture() { // stop capture if (!m_isCapturing && !m_isPlaying) return; - m_videoBox->setHidden(true); + videoBox->setHidden(true); rec_audio->setEnabled(true); rec_video->setEnabled(true); switch (device_selector->currentIndex()) { @@ -440,6 +440,7 @@ void RecMonitor::slotStartPreview(bool play) } return; } + slotActivateMonitor(); if (m_isPlaying) return; m_captureArgs.clear(); m_displayArgs.clear(); @@ -450,7 +451,7 @@ void RecMonitor::slotStartPreview(bool play) QString producer; QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(" ", QString::SkipEmptyParts); int ix = device_selector->currentIndex(); - m_videoBox->setHidden(ix != VIDEO4LINUX && ix != BLACKMAGIC); + videoBox->setHidden(ix != VIDEO4LINUX && ix != BLACKMAGIC); switch (ix) { case FIREWIRE: switch (KdenliveSettings::firewireformat()) { @@ -496,7 +497,6 @@ void RecMonitor::slotStartPreview(bool play) break; case VIDEO4LINUX: path = KStandardDirs::locateLocal("appdata", "profiles/video4linux"); - slotActivateMonitor(); buildMltDevice(path); profile = ProfilesDialog::getVideoProfile(path); producer = getV4lXmlPlaylist(profile); @@ -505,7 +505,7 @@ void RecMonitor::slotStartPreview(bool play) if (!m_captureDevice->slotStartPreview(producer, true)) { // v4l capture failed to start video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters...")); - m_videoBox->setHidden(true); + videoBox->setHidden(true); } else { m_playAction->setEnabled(false); @@ -522,7 +522,7 @@ void RecMonitor::slotStartPreview(bool play) if (!m_captureDevice->slotStartPreview(producer)) { // v4l capture failed to start video_frame->setText(i18n("Failed to start Decklink,\ncheck your parameters...")); - m_videoBox->setHidden(true); + videoBox->setHidden(true); } else { m_playAction->setEnabled(false); @@ -642,7 +642,7 @@ void RecMonitor::slotRecord() if (!rec_video->isChecked()) showPreview = false; if (m_captureDevice->slotStartCapture(v4lparameters, m_captureFile.path(), playlist, showPreview)) { - m_videoBox->setHidden(false); + videoBox->setHidden(false); m_isCapturing = true; m_recAction->setEnabled(false); m_stopAction->setEnabled(true); @@ -650,7 +650,7 @@ void RecMonitor::slotRecord() } else { video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters...")); - m_videoBox->setHidden(true); + videoBox->setHidden(true); m_isCapturing = false; } break; @@ -665,7 +665,7 @@ void RecMonitor::slotRecord() playlist = QString("producer100000pause%1decklink").arg(KdenliveSettings::decklink_capturedevice()); if (m_captureDevice->slotStartCapture(KdenliveSettings::decklink_parameters(), m_captureFile.path(), QString("decklink:%1").arg(KdenliveSettings::decklink_capturedevice()), m_previewSettings->isChecked(), false)) { - m_videoBox->setHidden(false); + videoBox->setHidden(false); m_isCapturing = true; slotSetInfoMessage(i18n("Capturing to %1", m_captureFile.fileName())); m_recAction->setEnabled(false); @@ -675,7 +675,7 @@ void RecMonitor::slotRecord() else { video_frame->setText(i18n("Failed to start Decklink,\ncheck your parameters...")); slotSetInfoMessage(i18n("Failed to start capture")); - m_videoBox->setHidden(true); + videoBox->setHidden(true); m_isCapturing = false; } break; @@ -918,8 +918,8 @@ void RecMonitor::refreshRecMonitor(bool visible) void RecMonitor::slotPlay() { - if (m_isPlaying) slotStopCapture(); - else slotStartPreview(true); + /*if (m_isPlaying) slotStopCapture(); + else slotStartPreview(true);*/ } void RecMonitor::slotReadDvgrabInfo() @@ -951,7 +951,7 @@ void RecMonitor::buildMltDevice(const QString &path) { if (m_captureDevice == NULL) { m_monitorManager->updateScopeSource(); - m_captureDevice = new MltDeviceCapture(path, m_videoBox, this); + m_captureDevice = new MltDeviceCapture(path, videoSurface, this); connect(m_captureDevice, SIGNAL(droppedFrames(int)), this, SLOT(slotDroppedFrames(int))); m_captureDevice->sendFrameForAnalysis = m_analyse; m_monitorManager->updateScopeSource(); @@ -963,22 +963,6 @@ void RecMonitor::slotChangeRecordingPreview(bool enable) KdenliveSettings::setEnable_recording_preview(enable); } -void RecMonitor::pause() -{ - if (m_isCapturing) return; - slotStopCapture(); - if (m_captureDevice) { - m_monitorManager->clearScopeSource(); - delete m_captureDevice; - m_captureDevice = NULL; - } -} - -void RecMonitor::unpause() -{ - if (m_isCapturing) return; - slotStartPreview(true); -} void RecMonitor::slotMouseSeek(int /*eventDelta*/, bool /*fast*/) { diff --git a/src/recmonitor.h b/src/recmonitor.h index 8fc2f7bd..aeb10290 100644 --- a/src/recmonitor.h +++ b/src/recmonitor.h @@ -57,8 +57,6 @@ public: AbstractRender *abstractRender(); void analyseFrames(bool analyse); - void pause(); - void unpause(); enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3}; protected: diff --git a/src/renderer.cpp b/src/renderer.cpp index 0593bc50..e7842aab 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -125,7 +125,7 @@ Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWi m_mltConsumer->connect(*m_mltProducer); m_mltProducer->set_speed(0.0); m_refreshTimer.setSingleShot(true); - m_refreshTimer.setInterval(50); + m_refreshTimer.setInterval(70); connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); } diff --git a/src/renderer.h b/src/renderer.h index 9a7c54f3..b2ca2676 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -170,8 +170,6 @@ Q_OBJECT public: /** @brief Returns the aspect ratio of the consumer. */ double consumerRatio() const; - void doRefresh(); - /** @brief Saves current producer frame as an image. */ void exportCurrentFrame(KUrl url, bool notify); @@ -431,6 +429,8 @@ public slots: void slotSwitchFullscreen(); void slotSetVolume(int volume); void seekToFrame(int pos); + /** @brief Starts a timer to query for a refresh. */ + void doRefresh(); }; #endif diff --git a/src/stopmotion/stopmotion.cpp b/src/stopmotion/stopmotion.cpp index 5611f2d4..1201eca6 100644 --- a/src/stopmotion/stopmotion.cpp +++ b/src/stopmotion/stopmotion.cpp @@ -133,14 +133,6 @@ void StopmotionMonitor::start() { } -void StopmotionMonitor::pause() -{ -} - -void StopmotionMonitor::unpause() -{ -} - void StopmotionMonitor::slotPlay() { } @@ -266,9 +258,8 @@ StopmotionWidget::StopmotionWidget(MonitorManager *manager, KUrl projectFolder, QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - m_videoBox = new VideoContainer(m_monitor); - m_videoBox->setLineWidth(4); - layout->addWidget(m_videoBox); + m_monitor->videoBox->setLineWidth(4); + layout->addWidget(m_monitor->videoBox); #ifdef USE_BLACKMAGIC if (BMInterface::getBlackMagicDeviceList(capture_device)) { @@ -319,7 +310,7 @@ StopmotionWidget::StopmotionWidget(MonitorManager *manager, KUrl projectFolder, profilePath = KdenliveSettings::current_profile(); } - m_captureDevice = new MltDeviceCapture(profilePath, m_videoBox, this); + m_captureDevice = new MltDeviceCapture(profilePath, m_monitor->videoSurface, this); m_captureDevice->sendFrameForAnalysis = KdenliveSettings::analyse_stopmotion(); m_monitor->setRender(m_captureDevice); connect(m_captureDevice, SIGNAL(frameSaved(const QString &)), this, SLOT(slotNewThumb(const QString &))); @@ -479,7 +470,7 @@ void StopmotionWidget::slotLive(bool isOn) capture_button->setEnabled(false); if (isOn) { m_frame_preview->setHidden(true); - m_videoBox->setHidden(false); + m_monitor->videoBox->setHidden(false); QLocale locale; MltVideoProfile profile; @@ -504,7 +495,7 @@ void StopmotionWidget::slotLive(bool isOn) } if (m_captureDevice == NULL) { - m_captureDevice = new MltDeviceCapture(profilePath, m_videoBox, this); + m_captureDevice = new MltDeviceCapture(profilePath, m_monitor->videoSurface, this); m_captureDevice->sendFrameForAnalysis = KdenliveSettings::analyse_stopmotion(); m_monitor->setRender(m_captureDevice); connect(m_captureDevice, SIGNAL(frameSaved(const QString &)), this, SLOT(slotNewThumb(const QString &))); @@ -533,7 +524,7 @@ void StopmotionWidget::slotLive(bool isOn) live_button->setChecked(false); if (m_captureDevice) { m_captureDevice->stop(); - m_videoBox->setHidden(true); + m_monitor->videoBox->setHidden(true); log_box->insertItem(-1, i18n("Stopped")); log_box->setCurrentIndex(0); //delete m_captureDevice; diff --git a/src/stopmotion/stopmotion.h b/src/stopmotion/stopmotion.h index 32fe04e7..124b1167 100644 --- a/src/stopmotion/stopmotion.h +++ b/src/stopmotion/stopmotion.h @@ -67,8 +67,6 @@ public: AbstractRender *abstractRender(); Kdenlive::MONITORID id() const; void setRender(MltDeviceCapture *render); - void pause(); - void unpause(); private: MltDeviceCapture *m_captureDevice; -- 2.39.2