Commit dbcfa3a6 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Cleaning up things in WorkflowFileRenderer

The renderer doesn't contain the dialog anymore.
parent ba9beda2
...@@ -454,8 +454,14 @@ void MainWindow::on_actionRender_triggered() ...@@ -454,8 +454,14 @@ void MainWindow::on_actionRender_triggered()
quint32 vbitrate = settings->videoBitrate(); quint32 vbitrate = settings->videoBitrate();
quint32 abitrate = settings->audioBitrate(); quint32 abitrate = settings->audioBitrate();
delete settings; delete settings;
WorkflowFileRendererDialog *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height );
dialog->setModal( true );
dialog->setOutputFileName( outputFileName );
m_fileRenderer->initializeRenderer(); m_fileRenderer->initializeRenderer();
m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate ); m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate );
dialog->show();
} }
} }
......
...@@ -23,15 +23,22 @@ ...@@ -23,15 +23,22 @@
#include "vlmc.h" #include "vlmc.h"
#include "WorkflowFileRendererDialog.h" #include "WorkflowFileRendererDialog.h"
#include "WorkflowFileRenderer.h"
WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height ) : WorkflowFileRendererDialog::WorkflowFileRendererDialog( WorkflowFileRenderer* renderer,
quint32 width, quint32 height ) :
m_width( width ), m_width( width ),
m_height( height ) m_height( height ),
m_renderer( renderer )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
m_workflow = MainWorkflow::getInstance(); m_workflow = MainWorkflow::getInstance();
connect( m_workflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ), connect( m_ui.cancelButton, SIGNAL( clicked() ), m_renderer, SLOT( stop() ) );
this, SLOT( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) ); connect( m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( close() ) );
connect( m_renderer, SIGNAL( frameChanged( qint64 ) ), this, SLOT( frameChanged( qint64 ) ) );
connect( m_renderer, SIGNAL( imageUpdated( const uchar* ) ),
this, SLOT( updatePreview( const uchar* ) ),
Qt::QueuedConnection );
} }
void WorkflowFileRendererDialog::setOutputFileName( const QString& outputFileName ) void WorkflowFileRendererDialog::setOutputFileName( const QString& outputFileName )
...@@ -53,9 +60,8 @@ void WorkflowFileRendererDialog::updatePreview( const uchar* buff ) ...@@ -53,9 +60,8 @@ void WorkflowFileRendererDialog::updatePreview( const uchar* buff )
QImage::Format_RGB888 ).rgbSwapped() ) ); QImage::Format_RGB888 ).rgbSwapped() ) );
} }
void WorkflowFileRendererDialog::frameChanged( qint64 frame, MainWorkflow::FrameChangedReason reason ) void WorkflowFileRendererDialog::frameChanged( qint64 frame )
{ {
if ( reason == MainWorkflow::Renderer ) m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg(QString::number( frame ),
m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg(QString::number( frame ), QString::number(m_workflow->getLengthFrame() ) ) );
QString::number(m_workflow->getLengthFrame() ) ) );
} }
...@@ -28,12 +28,14 @@ ...@@ -28,12 +28,14 @@
#include "MainWorkflow.h" #include "MainWorkflow.h"
class WorkflowFileRenderer;
class WorkflowFileRendererDialog : public QDialog class WorkflowFileRendererDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY( WorkflowFileRendererDialog ); Q_DISABLE_COPY( WorkflowFileRendererDialog );
public: public:
WorkflowFileRendererDialog( quint32 width, quint32 height ); WorkflowFileRendererDialog( WorkflowFileRenderer* renderer, quint32 width, quint32 height );
void setOutputFileName( const QString& filename ); void setOutputFileName( const QString& filename );
void setProgressBarValue( int val ); void setProgressBarValue( int val );
...@@ -42,12 +44,13 @@ private: ...@@ -42,12 +44,13 @@ private:
MainWorkflow* m_workflow; MainWorkflow* m_workflow;
quint32 m_width; quint32 m_width;
quint32 m_height; quint32 m_height;
WorkflowFileRenderer *m_renderer;
public slots: public slots:
void updatePreview( const uchar* buff ); void updatePreview( const uchar* buff );
private slots: private slots:
void frameChanged( qint64, MainWorkflow::FrameChangedReason ); void frameChanged( qint64 );
friend class WorkflowFileRenderer; friend class WorkflowFileRenderer;
}; };
......
...@@ -39,6 +39,22 @@ ConsoleRenderer::ConsoleRenderer(QObject *parent) : ...@@ -39,6 +39,22 @@ ConsoleRenderer::ConsoleRenderer(QObject *parent) :
m_fps = VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ); m_fps = VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" );
m_vbitrate = 4000; m_vbitrate = 4000;
m_abitrate = 256; m_abitrate = 256;
connect( m_renderer, SIGNAL( frameChanged( qint64 ) ),
this, SLOT( frameChanged( qint64 ) ) );
}
void
ConsoleRenderer::frameChanged( qint64 frame ) const
{
static int percent = 0;
int newPercent;
newPercent = frame * 100 / MainWorkflow::getInstance()->getLengthFrame();
if ( newPercent != percent )
{
percent = newPercent;
qDebug().nospace() << percent << "%";
}
} }
void void
......
...@@ -38,6 +38,9 @@ public: ...@@ -38,6 +38,9 @@ public:
public slots: public slots:
void startRender(); void startRender();
private slots:
void frameChanged( qint64 frame ) const;
private: private:
WorkflowFileRenderer *m_renderer; WorkflowFileRenderer *m_renderer;
QString m_outputFileName; QString m_outputFileName;
......
...@@ -46,27 +46,18 @@ void WorkflowFileRenderer::run( const QString& outputFileName, quint32 wi ...@@ -46,27 +46,18 @@ void WorkflowFileRenderer::run( const QString& outputFileName, quint32 wi
quint32 height, double fps, quint32 vbitrate, quint32 height, double fps, quint32 vbitrate,
quint32 abitrate ) quint32 abitrate )
{ {
// char buffer[256];
m_outputFileName = outputFileName;
m_mainWorkflow->setCurrentFrame( 0, MainWorkflow::Renderer ); m_mainWorkflow->setCurrentFrame( 0, MainWorkflow::Renderer );
setupRenderer( width, height, fps ); setupRenderer( width, height, fps );
#ifdef WITH_GUI
setupDialog( width, height );
#endif
//Media as already been created and mainly initialized by the WorkflowRenderer //Media as already been created and mainly initialized by the WorkflowRenderer
QString transcodeStr = ":sout=#transcode{vcodec=h264,vb=" + QString::number( vbitrate ) + QString transcodeStr = ":sout=#transcode{vcodec=h264,vb=" + QString::number( vbitrate ) +
",acodec=a52,ab=" + QString::number( abitrate ) + ",acodec=a52,ab=" + QString::number( abitrate ) +
",no-hurry-up}" ",no-hurry-up}"
":standard{access=file,mux=ps,dst=\"" ":standard{access=file,mux=ps,dst=\""
+ m_outputFileName + "\"}"; + outputFileName + "\"}";
m_media->addOption( transcodeStr.toStdString().c_str() ); m_media->addOption( transcodeStr.toStdString().c_str() );
// sprintf( buffer, ":sout-transcode-fps=%f", m_outputFps );
// m_media->addOption( buffer );
m_mediaPlayer->setMedia( m_media ); m_mediaPlayer->setMedia( m_media );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) ); connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) );
...@@ -131,19 +122,7 @@ WorkflowFileRenderer::unlock( void *datas, size_t size, void* buff ) ...@@ -131,19 +122,7 @@ WorkflowFileRenderer::unlock( void *datas, size_t size, void* buff )
void void
WorkflowFileRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedReason ) WorkflowFileRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedReason )
{ {
#ifdef WITH_GUI emit frameChanged( frame );
m_dialog->setProgressBarValue( frame * 100 / m_mainWorkflow->getLengthFrame() );
#else
static int percent = 0;
int newPercent;
newPercent = frame * 100 / m_mainWorkflow->getLengthFrame();
if ( newPercent != percent )
{
percent = newPercent;
qDebug() << percent << "%";
}
#endif
} }
void* void*
...@@ -169,27 +148,3 @@ WorkflowFileRenderer::height() const ...@@ -169,27 +148,3 @@ WorkflowFileRenderer::height() const
{ {
return VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" ); return VLMC_PROJECT_GET_UINT( "video/VideoProjectHeight" );
} }
#ifdef WITH_GUI
void
WorkflowFileRenderer::setupDialog( quint32 width, quint32 height )
{
m_dialog = new WorkflowFileRendererDialog( width, height );
m_dialog->setModal( true );
m_dialog->setOutputFileName( m_outputFileName );
connect( m_dialog->m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButtonClicked() ) );
connect( m_dialog, SIGNAL( finished(int) ), this, SLOT( stop() ) );
connect( this, SIGNAL( imageUpdated( const uchar* ) ),
m_dialog, SLOT( updatePreview( const uchar* ) ),
Qt::QueuedConnection );
m_dialog->show();
}
void
WorkflowFileRenderer::cancelButtonClicked()
{
stop();
disconnect();
m_dialog->done( 0 );
}
#endif
...@@ -45,20 +45,13 @@ public: ...@@ -45,20 +45,13 @@ public:
void run(const QString& outputFileName, quint32 width, void run(const QString& outputFileName, quint32 width,
quint32 height, double fps, quint32 vbitrate, quint32 height, double fps, quint32 vbitrate,
quint32 abitrate); quint32 abitrate);
static int lock( void* datas, qint64 *dts, qint64 *pts, static int lock( void* datas, qint64 *dts, qint64 *pts,
quint32 *flags, size_t *bufferSize, void **buffer ); quint32 *flags, size_t *bufferSize, void **buffer );
static void unlock( void* datas, size_t size, void* buff ); static void unlock( void* datas, size_t size, void* buff );
virtual float getFps() const; virtual float getFps() const;
private: private:
void setupDialog( quint32 width, quint32 height );
private:
QString m_outputFileName;
#ifdef WITH_GUI #ifdef WITH_GUI
WorkflowFileRendererDialog* m_dialog;
QImage* m_image; QImage* m_image;
QTime m_time; QTime m_time;
#endif #endif
...@@ -70,15 +63,13 @@ protected: ...@@ -70,15 +63,13 @@ protected:
virtual quint32 height() const; virtual quint32 height() const;
private slots: private slots:
void stop(); void stop();
#ifdef WITH_GUI
void cancelButtonClicked();
#endif
void __frameChanged( qint64 frame, void __frameChanged( qint64 frame,
MainWorkflow::FrameChangedReason reason ); MainWorkflow::FrameChangedReason reason );
void __endReached(); void __endReached();
signals: signals:
void imageUpdated( const uchar* image ); void imageUpdated( const uchar* image );
void frameChanged( qint64 );
}; };
#endif // WORKFLOWFILERENDERER_H #endif // WORKFLOWFILERENDERER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment