Commit 57bee67a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Size changes are now handled.

parent 0fcb7245
......@@ -24,7 +24,9 @@
#include "vlmc.h"
#include "WorkflowFileRendererDialog.h"
WorkflowFileRendererDialog::WorkflowFileRendererDialog()
WorkflowFileRendererDialog::WorkflowFileRendererDialog( quint32 width, quint32 height ) :
m_width( width ),
m_height( height )
{
m_ui.setupUi( this );
m_workflow = MainWorkflow::getInstance();
......@@ -35,7 +37,7 @@ WorkflowFileRendererDialog::WorkflowFileRendererDialog()
void WorkflowFileRendererDialog::setOutputFileName( const QString& outputFileName )
{
m_ui.nameLabel->setText( outputFileName );
m_ui.previewLabel->setMinimumSize( m_workflow->getWidth(), m_workflow->getHeight() );
m_ui.previewLabel->setMinimumSize( m_width, m_height );
setWindowTitle( "Rendering to " + outputFileName );
}
......@@ -47,7 +49,7 @@ void WorkflowFileRendererDialog::setProgressBarValue( int val )
void WorkflowFileRendererDialog::updatePreview( const uchar* buff )
{
m_ui.previewLabel->setPixmap(
QPixmap::fromImage( QImage( buff, m_workflow->getWidth(), m_workflow->getHeight(),
QPixmap::fromImage( QImage( buff, m_width, m_height,
QImage::Format_RGB888 ).rgbSwapped() ) );
}
......
......@@ -33,13 +33,15 @@ class WorkflowFileRendererDialog : public QDialog
Q_OBJECT
Q_DISABLE_COPY( WorkflowFileRendererDialog );
public:
WorkflowFileRendererDialog();
WorkflowFileRendererDialog( quint32 width, quint32 height );
void setOutputFileName( const QString& filename );
void setProgressBarValue( int val );
private:
Ui::WorkflowFileRendererDialog m_ui;
MainWorkflow* m_workflow;
quint32 m_width;
quint32 m_height;
public slots:
void updatePreview( const uchar* buff );
......
......@@ -31,17 +31,9 @@
WorkflowFileRenderer::WorkflowFileRenderer( const QString& outputFileName ) :
WorkflowRenderer(),
m_outputFileName( outputFileName )
m_outputFileName( outputFileName ),
m_image( NULL )
{
m_image = NULL;
m_dialog = new WorkflowFileRendererDialog();
m_dialog->setModal( true );
m_dialog->setOutputFileName( 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 );
}
WorkflowFileRenderer::~WorkflowFileRenderer()
......@@ -54,9 +46,14 @@ void WorkflowFileRenderer::run()
// char buffer[256];
m_mainWorkflow->setCurrentFrame( 0, MainWorkflow::Renderer );
m_outputFps = SettingsManager::getInstance()->getValue( "VLMC", "VLMCOutPutFPS" )->get().toDouble();
//Media as already been created an mainly initialized by the WorkflowRenderer
//Ugly hack to update render parameter.
//We don't really care if anything has changed as WorkflowFileRenderer is called
//only once, and is deleted then.
parametersChanged();
setupRenderer();
//Media as already been created and mainly initialized by the WorkflowRenderer
QString transcodeStr = ":sout=#transcode{vcodec=h264,vb=800,acodec=a52,ab=128,no-hurry-up}"
":standard{access=file,mux=ps,dst=\""
+ m_outputFileName + "\"}";
......@@ -75,7 +72,6 @@ void WorkflowFileRenderer::run()
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) );
connect( m_mainWorkflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason) ),
this, SLOT( __frameChanged( qint64,MainWorkflow::FrameChangedReason ) ) );
m_dialog->show();
m_isRendering = true;
m_stopping = false;
......@@ -83,6 +79,8 @@ void WorkflowFileRenderer::run()
m_pts = 0;
m_audioPts = 0;
setupDialog();
m_mainWorkflow->setFullSpeedRender( true );
m_mainWorkflow->startRender( width(), height() );
m_mediaPlayer->play();
......@@ -163,3 +161,17 @@ WorkflowFileRenderer::height() const
"VideoProjectHeight" );
return height->get().toUInt();
}
void
WorkflowFileRenderer::setupDialog()
{
m_dialog = new WorkflowFileRendererDialog( m_width, m_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();
}
......@@ -44,6 +44,9 @@ public:
void run();
virtual float getFps() const;
private:
void setupDialog();
private:
const QString m_outputFileName;
WorkflowFileRendererDialog* m_dialog;
......
......@@ -42,7 +42,9 @@ WorkflowRenderer::WorkflowRenderer() :
m_stopping( false ),
m_oldLength( 0 ),
m_renderVideoFrame( NULL ),
m_media( NULL )
m_media( NULL ),
m_width( 0 ),
m_height( 0 )
{
}
......@@ -82,15 +84,13 @@ WorkflowRenderer::setupRenderer()
char inputSlave[256];
char audioParameters[256];
char callbacks[64];
quint32 width = this->width();
quint32 height = this->height();
if ( m_renderVideoFrame != NULL )
delete m_renderVideoFrame;
m_renderVideoFrame = new unsigned char[width * height * Pixel::NbComposantes];
m_renderVideoFrame = new unsigned char[m_width * m_height * Pixel::NbComposantes];
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0",
width, height, "16/9", "30/1",
m_width, m_height, "16/9", "30/1",
(qint64)m_videoEsHandler, "RV24" );
sprintf( audioParameters, "data=%lld:cat=1:codec=fl32:samplerate=%u:channels=%u:caching=0",
(qint64)m_audioEsHandler, m_rate, m_nbChannels );
......@@ -209,7 +209,8 @@ void WorkflowRenderer::startPreview()
{
if ( m_mainWorkflow->getLengthFrame() <= 0 )
return ;
setupRenderer();
if ( parametersChanged() == true )
setupRenderer();
m_mediaPlayer->setMedia( m_media );
//Media player part: to update PreviewWidget
......@@ -224,13 +225,12 @@ void WorkflowRenderer::startPreview()
(*MainWorkflow::blackOutput)->nboctets );
m_mainWorkflow->setFullSpeedRender( false );
m_mainWorkflow->startRender( width(), height() );
m_mainWorkflow->startRender( m_width, m_height );
m_isRendering = true;
m_paused = false;
m_stopping = false;
m_pts = 0;
m_audioPts = 0;
m_outputFps = SettingsManager::getInstance()->getValue( "VLMC", "VLMCOutPutFPS" )->get().toDouble();
m_mediaPlayer->play();
}
......@@ -355,6 +355,25 @@ WorkflowRenderer::height() const
return height->get().toUInt();
}
bool
WorkflowRenderer::parametersChanged()
{
const SettingValue *newOutputFpsSV = SettingsManager::getInstance()->getValue( "VLMC",
"VLMCOutPutFPS" );
quint32 newWidth = width();
quint32 newHeight = height();
float newOutputFps = newOutputFpsSV->get().toDouble();
if ( newWidth != m_width || newHeight != m_height ||
newOutputFps != m_outputFps )
{
m_width = newWidth;
m_height = newHeight;
m_outputFps = newOutputFps;
return true;
}
return false;
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
......
......@@ -231,7 +231,13 @@ class WorkflowRenderer : public GenericRenderer
* \brief Configure the production chain.
*/
void setupRenderer();
/**
* \brief Check for parameters modification, and update them if
* necessary.
* \return true if some render parameters has changed.
* Parameters include : width, height, fps.
*/
bool parametersChanged();
protected:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
......@@ -244,6 +250,8 @@ class WorkflowRenderer : public GenericRenderer
*/
qint64 m_pts;
qint64 m_audioPts;
quint32 m_width;
quint32 m_height;
private:
/**
......
......@@ -189,7 +189,7 @@ MainWorkflow::getClipPosition( const QUuid& uuid, unsigned int trackId,
void
MainWorkflow::stop()
{
QMutexLocker lock( m_renderStartedMutex );
QMutexLocker lock( m_renderStartedMutex );
QWriteLocker lock2( m_currentFrameLock );
m_renderStarted = false;
......
......@@ -31,7 +31,9 @@
VideoClipWorkflow::VideoClipWorkflow( Clip *clip ) :
ClipWorkflow( clip ),
m_lastRenderedFrame( NULL )
m_lastRenderedFrame( NULL ),
m_width( 0 ),
m_height( 0 )
{
debugType = 2;
}
......@@ -47,10 +49,18 @@ VideoClipWorkflow::~VideoClipWorkflow()
void
VideoClipWorkflow::preallocate()
{
for ( unsigned int i = 0; i < VideoClipWorkflow::nbBuffers; ++i )
quint32 newWidth = MainWorkflow::getInstance()->getWidth();
quint32 newHeight = MainWorkflow::getInstance()->getHeight();
if ( newWidth != m_width || newHeight != m_height )
{
m_availableBuffers.enqueue( new LightVideoFrame( MainWorkflow::getInstance()->getWidth(),
MainWorkflow::getInstance()->getHeight() ) );
m_width = newWidth;
m_height = newHeight;
while ( m_availableBuffers.isEmpty() == false )
delete m_availableBuffers.dequeue();
for ( unsigned int i = 0; i < VideoClipWorkflow::nbBuffers; ++i )
{
m_availableBuffers.enqueue( new LightVideoFrame( newWidth, newHeight ) );
}
}
}
......@@ -59,6 +69,7 @@ VideoClipWorkflow::initVlcOutput()
{
char buffer[32];
preallocate();
m_vlcMedia->addOption( ":no-audio" );
m_vlcMedia->addOption( ":no-sout-audio" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
......@@ -71,15 +82,12 @@ VideoClipWorkflow::initVlcOutput()
else
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
sprintf( buffer, ":sout-transcode-width=%i",
MainWorkflow::getInstance()->getWidth() );
sprintf( buffer, ":sout-transcode-width=%i", m_width );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-height=%i",
MainWorkflow::getInstance()->getHeight() );
sprintf( buffer, ":sout-transcode-height=%i", m_height );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-fps=%f", (float)Clip::DefaultFPS );
m_vlcMedia->addOption( buffer );
preallocate();
}
void*
......@@ -129,8 +137,7 @@ VideoClipWorkflow::lock( VideoClipWorkflow *cw, void **pp_ret, int size )
cw->m_computedBuffersMutex->lock();
if ( cw->m_availableBuffers.isEmpty() == true )
{
lvf = new LightVideoFrame( MainWorkflow::getInstance()->getWidth(),
MainWorkflow::getInstance()->getHeight() );
lvf = new LightVideoFrame( cw->m_width, cw->m_height );
}
else
lvf = cw->m_availableBuffers.dequeue();
......
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