Commit 1d1585f0 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Sync the timecode with the workflow internals

parent 66365948
......@@ -37,10 +37,14 @@ PreviewRuler::PreviewRuler( QWidget* parent ) : QAbstractSlider( parent ), m_ren
void PreviewRuler::setRenderer( GenericRenderer* renderer )
{
if ( m_renderer )
{
disconnect( m_renderer, SIGNAL( positionChanged(float) ) );
disconnect( m_renderer, SIGNAL( frameChanged(qint64) ) );
}
m_renderer = renderer;
connect( m_renderer, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged() ) );
connect( m_renderer, SIGNAL( positionChanged(float) ), this, SLOT( update() ) );
connect( m_renderer, SIGNAL( frameChanged(qint64) ), this, SLOT( updateTimecode() ) );
}
void PreviewRuler::sliderChange( SliderChange change )
......@@ -59,6 +63,7 @@ void PreviewRuler::sliderChange( SliderChange change )
case QAbstractSlider::SliderValueChange:
m_frame = value() * m_renderer->getLengthMs() / m_range;
update();
updateTimecode();
break;
}
}
......@@ -209,25 +214,25 @@ void PreviewRuler::setFrame( qint64 frame )
setValue( frame * m_range / m_renderer->getLengthMs() );
if ( m_isSliding )
emit sliderPosChanged( frame * m_range / m_renderer->getLengthMs() );
positionChanged();
update();
}
void PreviewRuler::positionChanged()
void PreviewRuler::updateTimecode()
{
if ( m_renderer->getLengthMs() )
{
qint64 frames = m_frame;
int fps = (int)m_renderer->getFps();
qint64 frames = m_renderer->getCurrentFrame();
int h = frames / 24 / 60 / 60;
frames -= h * 24 * 60 * 60;
int h = frames / fps / 60 / 60;
frames -= h * fps * 60 * 60;
int m = frames / 24 / 60;
frames -= m * 24 * 60;
int m = frames / fps / 60;
frames -= m * fps * 60;
int s = frames / 24;
frames -= s * 24;
int s = frames / fps;
frames -= s * fps;
emit timeChanged( h, m, s, frames );
}
update();
}
......@@ -53,7 +53,7 @@ protected:
virtual void sliderChange( SliderChange change );
private slots:
void positionChanged();
void updateTimecode();
private:
GenericRenderer* m_renderer;
......
......@@ -39,6 +39,7 @@ ClipRenderer::ClipRenderer() :
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( __positionChanged() ) );
connect( m_mediaPlayer, SIGNAL( timeChanged() ), this, SLOT( __timeChanged() ) );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( __endReached() ) );
}
......@@ -255,6 +256,12 @@ void ClipRenderer::__positionChanged()
emit positionChanged( pos );
}
void ClipRenderer::__timeChanged()
{
qint64 f = qRound64( (qreal)m_mediaPlayer->getTime() / 1000 * (qreal)m_mediaPlayer->getFps() );
emit frameChanged( f );
}
void ClipRenderer::__endReached()
{
m_mediaPlayer->stop();
......
......@@ -70,6 +70,7 @@ public slots:
virtual void mediaUnloaded( const QUuid& );
void __positionChanged();
void __timeChanged();
void __videoPaused();
void __videoPlaying();
void __endReached();
......
......@@ -152,6 +152,7 @@ signals:
void paused();
void playing();
void positionChanged( float );
void frameChanged( qint64 );
void endReached();
};
......
......@@ -67,7 +67,7 @@ WorkflowRenderer::WorkflowRenderer() :
m_waitCond = new QWaitCondition;
m_renderVideoFrame = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes];
//Workflow part
connect( m_mainWorkflow, SIGNAL( frameChanged(qint64) ),
Timeline::getInstance()->tracksView()->tracksCursor(), SLOT( setCursorPos( qint64 ) ), Qt::QueuedConnection );
......@@ -84,11 +84,13 @@ WorkflowRenderer::~WorkflowRenderer()
stop();
//FIXME this is probably useless...
//etix says: yes it is...
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
disconnect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
disconnect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
disconnect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
disconnect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
disconnect( m_mainWorkflow, SIGNAL( frameChanged( qint64 ) ), this, SLOT( __frameChanged( qint64 ) ) );
delete m_actionsLock;
delete m_media;
......@@ -162,6 +164,7 @@ void WorkflowRenderer::startPreview()
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
connect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
connect( m_mainWorkflow, SIGNAL( frameChanged( qint64 ) ), this, SLOT( __frameChanged( qint64 ) ) );
m_mainWorkflow->setFullSpeedRender( false );
m_mainWorkflow->startRender();
......@@ -301,6 +304,11 @@ void WorkflowRenderer::__positionChanged( float pos )
emit positionChanged( pos );
}
void WorkflowRenderer::__frameChanged( qint64 frame )
{
emit frameChanged( frame );
}
void WorkflowRenderer::__videoPaused()
{
if ( m_pauseAsked == true )
......
......@@ -93,6 +93,7 @@ class WorkflowRenderer : public GenericRenderer
void __positionChanged();
void __positionChanged( float pos );
void __frameChanged( qint64 frame );
void __videoPaused();
void __videoStopped();
void __videoPlaying();
......
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