[vlmc-devel] [PATCH 2/5] Remove WorkflowFileRenderer

Yikai Lu luyikei.qmltu at gmail.com
Wed Apr 6 13:59:03 CEST 2016


---
 src/CMakeLists.txt                     |   1 -
 src/Gui/MainWindow.cpp                 |  13 +----
 src/Gui/MainWindow.h                   |   2 -
 src/Gui/WorkflowFileRendererDialog.cpp |   7 +--
 src/Gui/WorkflowFileRendererDialog.h   |   6 +-
 src/Renderer/WorkflowFileRenderer.cpp  | 103 ---------------------------------
 src/Renderer/WorkflowFileRenderer.h    |  67 ---------------------
 7 files changed, 9 insertions(+), 190 deletions(-)
 delete mode 100644 src/Renderer/WorkflowFileRenderer.cpp
 delete mode 100644 src/Renderer/WorkflowFileRenderer.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 45927f2..4b34868 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -63,7 +63,6 @@ SET(VLMC_SRCS
     Project/RecentProjects.cpp
     Renderer/ClipRenderer.cpp
     Renderer/GenericRenderer.cpp
-    Renderer/WorkflowFileRenderer.cpp
     Renderer/WorkflowRenderer.cpp
     Services/AbstractSharingService.h
     Services/UploaderIODevice.cpp
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 012420a..d6ff46c 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -42,7 +42,6 @@
 #include "EffectsEngine/EffectsEngine.h"
 #include "Backend/IBackend.h"
 #include "Workflow/MainWorkflow.h"
-#include "Renderer/WorkflowFileRenderer.h"
 #include "Renderer/WorkflowRenderer.h"
 #include "Renderer/ClipRenderer.h"
 
@@ -73,7 +72,6 @@
 MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
     : QMainWindow( parent )
     , m_backend( backend )
-    , m_fileRenderer( nullptr )
     , m_projectPreferences( nullptr )
     , m_wizard( nullptr )
 {
@@ -139,8 +137,6 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
 
 MainWindow::~MainWindow()
 {
-    if ( m_fileRenderer )
-        delete m_fileRenderer;
     delete m_importController;
 }
 
@@ -607,15 +603,12 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
                          double fps, const QString& ar,
                          quint32 vbitrate, quint32 abitrate )
 {
-    if ( m_fileRenderer )
-        delete m_fileRenderer;
-    m_fileRenderer = new WorkflowFileRenderer( m_backend, Core::instance()->workflow() );
-
-    WorkflowFileRendererDialog  *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height );
+    WorkflowFileRendererDialog  *dialog = new WorkflowFileRendererDialog( width, height );
     dialog->setModal( true );
     dialog->setOutputFileName( outputFileName );
 
-    m_fileRenderer->run( outputFileName, width, height, fps, ar, vbitrate, abitrate );
+    Core::instance()->workflowRenderer()->startRenderToFile( outputFileName, width, height,
+                                                             fps, ar, vbitrate, abitrate );
 
     if ( dialog->exec() == QDialog::Rejected )
     {
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index 3e50a12..8f97d3a 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -42,7 +42,6 @@ class   Project;
 class   ProjectWizard;
 class   SettingsDialog;
 class   Timeline;
-class   WorkflowFileRenderer;
 class   WorkflowRenderer;
 
 namespace Backend
@@ -133,7 +132,6 @@ private:
     Backend::IBackend*      m_backend;
     PreviewWidget*          m_clipPreview;
     PreviewWidget*          m_projectPreview;
-    WorkflowFileRenderer*   m_fileRenderer;
     SettingsDialog*         m_globalPreferences;
     SettingsDialog*         m_DefaultProjectPreferences;
     SettingsDialog*         m_projectPreferences;
diff --git a/src/Gui/WorkflowFileRendererDialog.cpp b/src/Gui/WorkflowFileRendererDialog.cpp
index f75b051..151674f 100644
--- a/src/Gui/WorkflowFileRendererDialog.cpp
+++ b/src/Gui/WorkflowFileRendererDialog.cpp
@@ -27,13 +27,12 @@
 #include "Project/Project.h"
 #include "vlmc.h"
 #include "Workflow/MainWorkflow.h"
-#include "Renderer/WorkflowFileRenderer.h"
+#include "Renderer/WorkflowRenderer.h"
 
-WorkflowFileRendererDialog::WorkflowFileRendererDialog( WorkflowFileRenderer* renderer,
-                                                        quint32 width, quint32 height ) :
+WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height ) :
         m_width( width ),
         m_height( height ),
-        m_renderer( renderer )
+        m_renderer( Core::instance()->workflowRenderer() )
 {
     m_ui.setupUi( this );
     connect( m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancel() ) );
diff --git a/src/Gui/WorkflowFileRendererDialog.h b/src/Gui/WorkflowFileRendererDialog.h
index 54bec06..de46ee2 100644
--- a/src/Gui/WorkflowFileRendererDialog.h
+++ b/src/Gui/WorkflowFileRendererDialog.h
@@ -26,14 +26,14 @@
 #include <QDialog>
 #include "ui_WorkflowFileRendererDialog.h"
 
-class   WorkflowFileRenderer;
+class   WorkflowRenderer;
 
 class   WorkflowFileRendererDialog : public QDialog
 {
     Q_OBJECT
     Q_DISABLE_COPY( WorkflowFileRendererDialog );
 public:
-    WorkflowFileRendererDialog( WorkflowFileRenderer* renderer, quint32 width, quint32 height );
+    WorkflowFileRendererDialog( quint32 width, quint32 height );
     void    setOutputFileName( const QString& filename );
     void    setProgressBarValue( int val );
 
@@ -41,7 +41,7 @@ private:
     Ui::WorkflowFileRendererDialog      m_ui;
     quint32                             m_width;
     quint32                             m_height;
-    WorkflowFileRenderer                *m_renderer;
+    WorkflowRenderer*                   m_renderer;
 
 public slots:
     void    updatePreview( const uchar* buff );
diff --git a/src/Renderer/WorkflowFileRenderer.cpp b/src/Renderer/WorkflowFileRenderer.cpp
deleted file mode 100644
index dc883c5..0000000
--- a/src/Renderer/WorkflowFileRenderer.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*****************************************************************************
- * WorkflowFileRenderer.cpp: Output the workflow to a file
- *****************************************************************************
- * Copyright (C) 2008-2016 VideoLAN
- *
- * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
- *
- * 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) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include "vlmc.h"
-#include "WorkflowFileRenderer.h"
-#include "Settings/Settings.h"
-
-#include <QTime>
-
-WorkflowFileRenderer::WorkflowFileRenderer( Backend::IBackend* backend, MainWorkflow* workflow )
-    : WorkflowRenderer( backend, workflow )
-    , m_renderVideoFrame( nullptr )
-{
-}
-
-void
-WorkflowFileRenderer::run( const QString& outputFileName, quint32 width,
-                            quint32 height, double fps, const QString& ar,
-                            quint32 vbitrate, quint32 abitrate )
-{
-    m_mainWorkflow->setCurrentFrame( 0, Vlmc::Renderer );
-
-    setupRenderer( width, height, fps, ar );
-    m_sourceRenderer->setOutputFile( qPrintable( outputFileName ) );
-    m_sourceRenderer->setOutputAudioBitrate( abitrate );
-    m_sourceRenderer->setOutputVideoBitrate( vbitrate );
-
-    connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) );
-    connect( m_mainWorkflow, SIGNAL( frameChanged( qint64, Vlmc::FrameChangedReason ) ),
-             this, SLOT( __frameChanged( qint64,Vlmc::FrameChangedReason ) ) );
-    connect( this, SIGNAL( endReached() ), this, SIGNAL( renderComplete() ) );
-
-    m_isRendering = true;
-    m_stopping = false;
-    m_paused = false;
-    m_pts = 0;
-    m_audioPts = 0;
-
-    m_mainWorkflow->setFullSpeedRender( true );
-    m_mainWorkflow->startRender( width, height );
-    //Waiting for renderers to preload some frames:
-    SleepS( 1 );
-    m_sourceRenderer->start();
-}
-
-int
-WorkflowFileRenderer::lock( void *datas, const char* cookie, int64_t *dts, int64_t *pts,
-                            unsigned int *flags, size_t *bufferSize, const void **buffer )
-{
-    int         ret = WorkflowRenderer::lock( datas, cookie, dts, pts, flags, bufferSize, buffer );
-    EsHandler*  handler = reinterpret_cast<EsHandler*>( datas );
-    WorkflowFileRenderer* self = static_cast<WorkflowFileRenderer*>( handler->self );
-
-#ifdef WITH_GUI
-    if ( self->m_time.isValid() == false ||
-        self->m_time.elapsed() >= 1000 )
-    {
-        if ( self->m_renderVideoFrame == nullptr )
-            self->m_renderVideoFrame = new quint8[*bufferSize];
-        memcpy( self->m_renderVideoFrame, (uchar*)(*buffer), *bufferSize );
-        self->emit imageUpdated( self->m_renderVideoFrame );
-        self->m_time.restart();
-    }
-#endif
-    return ret;
-}
-
-void
-WorkflowFileRenderer::__frameChanged( qint64 frame, Vlmc::FrameChangedReason )
-{
-    emit frameChanged( frame );
-}
-
-Backend::ISourceRenderer::MemoryInputLockCallback
-WorkflowFileRenderer::getLockCallback()
-{
-    return &WorkflowFileRenderer::lock;
-}
-
-Backend::ISourceRenderer::MemoryInputUnlockCallback
-WorkflowFileRenderer::getUnlockCallback()
-{
-    return &WorkflowRenderer::unlock;
-}
diff --git a/src/Renderer/WorkflowFileRenderer.h b/src/Renderer/WorkflowFileRenderer.h
deleted file mode 100644
index 24e4ef0..0000000
--- a/src/Renderer/WorkflowFileRenderer.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * WorkflowFileRenderer.h: Output the workflow to a file
- *****************************************************************************
- * Copyright (C) 2008-2016 VideoLAN
- *
- * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
- *
- * 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) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef WORKFLOWFILERENDERER_H
-#define WORKFLOWFILERENDERER_H
-
-#include "config.h"
-#include "Backend/ISourceRenderer.h"
-#include "Workflow/MainWorkflow.h"
-#include "WorkflowRenderer.h"
-
-#include <QTime>
-
-class   WorkflowFileRenderer : public WorkflowRenderer
-{
-    Q_OBJECT
-
-public:
-    WorkflowFileRenderer( Backend::IBackend* backend , MainWorkflow* workflow );
-    virtual ~WorkflowFileRenderer() = default;
-
-    void                        run(const QString& outputFileName, quint32 width,
-                                    quint32 height, double fps, const QString& ar,
-                                    quint32 vbitrate, quint32 abitrate);
-    static int                  lock(void* datas, const char* cookie, int64_t *dts, int64_t *pts,
-                                      unsigned int *flags, size_t *bufferSize, const void **buffer );
-
-private:
-    quint8                      *m_renderVideoFrame;
-#ifdef WITH_GUI
-    QTime                       m_time;
-#endif
-
-protected:
-    virtual Backend::ISourceRenderer::MemoryInputLockCallback getLockCallback();
-    virtual Backend::ISourceRenderer::MemoryInputUnlockCallback getUnlockCallback();
-
-private slots:
-    void                        __frameChanged( qint64 frame,
-                                                Vlmc::FrameChangedReason reason );
-
-signals:
-    void                        imageUpdated( const uchar* image );
-    void                        frameChanged( qint64 );
-    void                        renderComplete();
-};
-
-#endif // WORKFLOWFILERENDERER_H
-- 
1.9.1



More information about the Vlmc-devel mailing list