Commit a37e981f authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere
Browse files

Merge commit 'origin/master' into geoff_import

parents 329ed3e6 56893065
......@@ -36,6 +36,8 @@ public:
void setProgressBarValue( int val );
private:
Ui::WorkflowFileRendererDialog m_ui;
friend class WorkflowFileRenderer;
};
#endif // WORKFLOWFILERENDERERDIALOG_H
......@@ -29,7 +29,9 @@ ClipRenderer::ClipRenderer() :
GenericRenderer(),
m_clipLoaded( false ),
m_vlcMedia( NULL ),
m_selectedClip( NULL ),
m_selectedMedia( NULL ),
m_begin( 0 ),
m_end( -1 ),
m_mediaChanged( false )
{
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
......@@ -41,12 +43,27 @@ ClipRenderer::ClipRenderer() :
ClipRenderer::~ClipRenderer()
{
if ( m_vlcMedia )
delete m_vlcMedia;
stop();
}
void ClipRenderer::setMedia( Media* media )
{
m_selectedMedia = media;
m_begin = 0;
m_end = media->getNbFrames();
if ( m_isRendering == true )
m_mediaChanged = true;
else
m_clipLoaded = false;
}
void ClipRenderer::setClip( Clip* clip )
{
m_selectedClip = clip;
m_selectedMedia = clip->getParent();
m_begin = clip->getBegin();
m_end = clip->getEnd();
if ( m_isRendering == true )
m_mediaChanged = true;
else
......@@ -58,17 +75,17 @@ void ClipRenderer::setClip( Clip* clip )
void ClipRenderer::startPreview()
{
if ( m_selectedClip == NULL )
if ( m_selectedMedia == NULL )
return ;
//If an old media is found, we delete it, and disconnect
if ( m_vlcMedia != NULL )
delete m_vlcMedia;
m_vlcMedia = new LibVLCpp::Media( m_selectedClip->getParent()->getFileInfo()->absoluteFilePath() );
m_vlcMedia = new LibVLCpp::Media( m_selectedMedia->getFileInfo()->absoluteFilePath() );
m_mediaPlayer->setMedia( m_vlcMedia );
m_mediaPlayer->play();
m_mediaPlayer->setPosition( m_selectedClip->getBegin() / m_selectedClip->getLength() );
m_mediaPlayer->setPosition( m_begin / m_end );
m_clipLoaded = true;
m_isRendering = true;
m_paused = false;
......@@ -79,8 +96,8 @@ void ClipRenderer::setPosition( float newPos )
{
if ( m_clipLoaded == false || m_isRendering == false )
return ;
float begin = m_selectedClip->getBegin() / m_selectedClip->getLength();
float end = m_selectedClip->getEnd() / m_selectedClip->getEnd();
float begin = m_begin / ( m_end - m_begin );
float end = m_end / ( m_end - m_begin );
float pos = newPos * ( end - begin ) + begin;
m_mediaPlayer->setPosition( pos );
}
......@@ -119,7 +136,7 @@ void ClipRenderer::togglePlayPause( bool forcePause )
if ( m_isRendering == false )
{
m_mediaPlayer->play();
m_mediaPlayer->setPosition( m_selectedClip->getBegin() / m_selectedClip->getLength() );
m_mediaPlayer->setPosition( m_begin / ( m_end - m_begin ) );
m_isRendering = true;
}
else
......@@ -145,13 +162,14 @@ void ClipRenderer::previousFrame()
}
}
//FIXME: this won't work with clips !
void ClipRenderer::mediaUnloaded( const QUuid& uuid )
{
if ( m_selectedClip != NULL && m_selectedClip->getUuid() == uuid )
if ( m_selectedMedia != NULL && m_selectedMedia->getUuid() == uuid )
{
m_mediaPlayer->stop();
m_clipLoaded = false;
m_selectedClip = NULL;
m_selectedMedia = NULL;
m_isRendering = false;
m_paused = false;
}
......@@ -180,8 +198,8 @@ void ClipRenderer::__positionChanged()
if ( m_clipLoaded == false)
return ;
float begin = m_selectedClip->getBegin() / m_selectedClip->getLength();
float end = m_selectedClip->getEnd() / m_selectedClip->getEnd();
float begin = m_begin / ( m_end - m_begin );
float end = m_end / ( m_end - m_begin );
float pos = ( m_mediaPlayer->getPosition() - begin ) /
( end - begin );
emit positionChanged( pos );
......
......@@ -51,7 +51,9 @@ private:
private:
bool m_clipLoaded;
LibVLCpp::Media* m_vlcMedia;
Clip* m_selectedClip;
Media* m_selectedMedia;
qint64 m_begin;
qint64 m_end;
/**
* \brief This flags is used to know if a new media has been selected in the
* library. If so, we must relaunch the render if the play button is clicked again.
......@@ -60,6 +62,7 @@ private:
public slots:
virtual void setClip( Clip* clip );
virtual void setMedia( Media* media );
virtual void mediaUnloaded( const QUuid& );
void __positionChanged();
......
......@@ -86,6 +86,7 @@ public slots:
virtual void __videoPlaying() = 0;
virtual void __endReached() = 0;
virtual void setClip( Clip* ) = 0;
virtual void setMedia( Media* ) = 0;
virtual void mediaUnloaded( const QUuid& ) = 0;
......
......@@ -4,8 +4,10 @@ WorkflowFileRenderer::WorkflowFileRenderer( const QString& outputFileName ) :
m_outputFileName( outputFileName )
{
m_dialog = new WorkflowFileRendererDialog;
m_dialog->setModal( true );
m_dialog->setOutputFileName( outputFileName );
m_mediaPlayer = new LibVLCpp::MediaPlayer;
connect( m_dialog->m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButtonClicked() ) );
}
WorkflowFileRenderer::~WorkflowFileRenderer()
......@@ -27,6 +29,9 @@ void WorkflowFileRenderer::run()
+ m_outputFileName + "\"}";
m_media->addOption( transcodeStr.toStdString().c_str() );
sprintf( buffer, ":sout-transcode-fps=%f", (float)FPS );
m_media->addOption( buffer );
m_mediaPlayer->setMedia( m_media );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) );
......@@ -53,7 +58,7 @@ void WorkflowFileRenderer::positionChanged( float newPos )
m_dialog->setProgressBarValue( static_cast<int>( newPos * 100 ) );
}
void WorkflowFileRenderer::on_cancelButton_clicked()
void WorkflowFileRenderer::cancelButtonClicked()
{
stop();
}
......@@ -48,7 +48,7 @@ private:
private slots:
void stop();
void positionChanged( float newPos );
void on_cancelButton_clicked();
void cancelButtonClicked();
};
#endif // WORKFLOWFILERENDERER_H
......@@ -53,6 +53,7 @@ WorkflowRenderer::WorkflowRenderer() :
m_media->addOption( buffer );
sprintf( buffer, ":height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
m_media->addOption( ":no-audio" );
m_condMutex = new QMutex;
m_waitCond = new QWaitCondition;
......
......@@ -81,7 +81,8 @@ class WorkflowRenderer : public GenericRenderer
QWaitCondition* m_waitCond;
public slots:
void setClip( Clip* ){}
virtual void setClip( Clip* ){}
virtual void setMedia( Media* ) {}
void mediaUnloaded( const QUuid& ) {}
void timelineCursorChanged( qint64 newFrame );
......
......@@ -141,9 +141,11 @@ void ClipWorkflow::setVmem()
// m_vlcMedia->addOption( ":no-sout-keep" );
if ( m_fullSpeedRender == true )
m_vlcMedia->addOption( ":sout-sync" );
{
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
}
else
m_vlcMedia->addOption( ":no-sout-sync" );
m_vlcMedia->addOption( ":sout-smem-time-sync" );
sprintf( buffer, ":sout-transcode-width=%i", VIDEOWIDTH );
m_vlcMedia->addOption( buffer );
......@@ -151,6 +153,9 @@ void ClipWorkflow::setVmem()
sprintf( buffer, ":sout-transcode-height=%i", VIDEOHEIGHT );
m_vlcMedia->addOption( buffer );
sprintf( buffer, ":sout-transcode-fps=%f", (float)FPS );
m_vlcMedia->addOption( buffer );
//sprintf( buffer, "sout-smem-video-pitch=%i", VIDEOWIDTH * 3 );
//m_vlcMedia->addOption( buffer );
}
......
......@@ -80,7 +80,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void pause();
void unpause();
static unsigned char* blackOutput;
void nextFrame();
void previousFrame();
......@@ -115,6 +114,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
private:
static MainWorkflow* m_instance;
static unsigned char* blackOutput;
private:
void computeLength();
......
......@@ -145,7 +145,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->getStateLock()->unlock();
cw->initialize();
cw->startRender( m_paused );
if ( start != currentFrame ) //Clip was not started as its real begining
if ( start != currentFrame || cw->getClip()->getBegin() != 0 ) //Clip was not started as its real begining
{
adjustClipTime( currentFrame, start, cw );
}
......
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