[vlmc-devel] [PATCH 01/12] WorkflowRenderer: Have a feature to render the project to files.

Yikai Lu luyikei.qmltu at gmail.com
Wed Apr 6 09:58:14 CEST 2016


Which kills usage of WorkflowFilRenderer
---
 src/Renderer/WorkflowRenderer.cpp | 39 ++++++++++++++++++++++++++++++++++++---
 src/Renderer/WorkflowRenderer.h   | 12 ++++++++++++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index f50838a..515c64c 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -151,6 +151,17 @@ WorkflowRenderer::lockVideo( void* data, int64_t *pts, size_t *bufferSize, const
     else
         *buffer = ret->buffer();
     *bufferSize = ret->size();
+
+#ifdef WITH_GUI
+    auto self = handler->self;
+    if ( self->m_time.isValid() == false ||
+         self->m_time.elapsed() >= 1000 )
+    {
+        emit self->imageUpdated( (quint8*)( *buffer ) );
+        self->m_time.restart();
+    }
+#endif
+
     vlmcDebug() << __func__ << "Rendered frame. pts:" << m_pts;
     return 0;
 }
@@ -202,7 +213,7 @@ WorkflowRenderer::unlock( void *data, const char*, size_t, void* )
 }
 
 void
-WorkflowRenderer::startPreview()
+WorkflowRenderer::prepareSetup()
 {
     if ( m_mainWorkflow->getLengthFrame() <= 0 )
         return ;
@@ -215,18 +226,40 @@ WorkflowRenderer::startPreview()
 
     initFilters();
     setupRenderer( m_width, m_height, m_outputFps, m_aspectRatio );
+}
 
-    m_mainWorkflow->setFullSpeedRender( false );
-    m_mainWorkflow->startRender( m_width, m_height );
+void
+WorkflowRenderer::start()
+{
     m_isRendering = true;
     m_paused = false;
     m_stopping = false;
     m_pts = 0;
     m_audioPts = 0;
+    m_mainWorkflow->startRender( m_width, m_height );
     m_sourceRenderer->start();
 }
 
 void
+WorkflowRenderer::startRenderToFile( const QString& outputFileName )
+{
+    prepareSetup();
+    m_sourceRenderer->setOutputFile( qPrintable( outputFileName ) );
+    connect( m_mainWorkflow, &MainWorkflow::mainWorkflowEndReached, this, &WorkflowRenderer::renderComplete );
+    connect( m_mainWorkflow, &MainWorkflow::mainWorkflowEndReached, this, &WorkflowRenderer::stop );
+    m_mainWorkflow->setFullSpeedRender( true );
+    start();
+}
+
+void
+WorkflowRenderer::startPreview()
+{
+    prepareSetup();
+    m_mainWorkflow->setFullSpeedRender( false );
+    start();
+}
+
+void
 WorkflowRenderer::nextFrame()
 {
     if ( m_paused == true )
diff --git a/src/Renderer/WorkflowRenderer.h b/src/Renderer/WorkflowRenderer.h
index 89aace6..805949a 100644
--- a/src/Renderer/WorkflowRenderer.h
+++ b/src/Renderer/WorkflowRenderer.h
@@ -29,6 +29,7 @@
 #include "Workflow/MainWorkflow.h"
 
 #include <QObject>
+#include <QTime>
 
 namespace Backend
 {
@@ -132,7 +133,11 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
          */
         virtual float       getFps() const;
 
+        void                startRenderToFile( const QString& outputFileName );
+
     private:
+        void                prepareSetup();
+        void                start();
         /**
          *  \brief          This is a subpart of the togglePlayPause( bool ) method
          *
@@ -249,6 +254,9 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
         static const quint8     VideoCookie = '0';
         static const quint8     AudioCookie = '1';
 
+        // For Preview
+        QTime                       m_time;
+
     public slots:
         /**
          *  \brief          The current frame just changed because of the timeline cursor
@@ -271,6 +279,10 @@ class   WorkflowRenderer : public GenericRenderer, public ILoadSave
          *  If the length comes to a 0 value again, the permanent playback will be stoped.
          */
         void                mainWorkflowLenghtChanged( qint64 newLength );
+
+    signals:
+        void                        imageUpdated( const uchar* image );
+        void                        renderComplete();
 };
 
 #endif // WORKFLOWRENDERER_H
-- 
1.9.1



More information about the Vlmc-devel mailing list