Commit 92c75f70 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Fixed setTime problems.

parent 5f8413a3
...@@ -94,7 +94,6 @@ WorkflowRenderer::~WorkflowRenderer() ...@@ -94,7 +94,6 @@ WorkflowRenderer::~WorkflowRenderer()
int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer ) int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer )
{ {
static char computed = 0;
int ret = 1; int ret = 1;
EsHandler* handler = reinterpret_cast<EsHandler*>( datas ); EsHandler* handler = reinterpret_cast<EsHandler*>( datas );
...@@ -102,21 +101,16 @@ int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigne ...@@ -102,21 +101,16 @@ int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigne
*flags = 0; *flags = 0;
if ( handler->type == Video ) if ( handler->type == Video )
{ {
++computed;
ret = lockVideo( handler->self, pts, bufferSize, buffer ); ret = lockVideo( handler->self, pts, bufferSize, buffer );
handler->self->m_mainWorkflow->goToNextFrame( MainWorkflow::VideoTrack );
} }
else if ( handler->type == Audio ) else if ( handler->type == Audio )
{ {
++computed;
ret = lockAudio( handler->self, pts, bufferSize, buffer ); ret = lockAudio( handler->self, pts, bufferSize, buffer );
handler->self->m_mainWorkflow->goToNextFrame( MainWorkflow::AudioTrack );
} }
else else
qWarning() << "Invalid ES type"; qWarning() << "Invalid ES type";
if ( computed == 2 )
{
handler->self->m_mainWorkflow->goToNextFrame();
computed = 0;
}
// qDebug() << "ES Type:" << handler->type << "pts:" << *pts; // qDebug() << "ES Type:" << handler->type << "pts:" << *pts;
return ret; return ret;
} }
...@@ -224,12 +218,13 @@ void WorkflowRenderer::startPreview() ...@@ -224,12 +218,13 @@ void WorkflowRenderer::startPreview()
void WorkflowRenderer::nextFrame() void WorkflowRenderer::nextFrame()
{ {
m_mainWorkflow->nextFrame(); //FIXME: won't work, just compile
m_mainWorkflow->nextFrame( MainWorkflow::VideoTrack );
} }
void WorkflowRenderer::previousFrame() void WorkflowRenderer::previousFrame()
{ {
m_mainWorkflow->previousFrame(); m_mainWorkflow->previousFrame( MainWorkflow::VideoTrack );
} }
void WorkflowRenderer::mainWorkflowPaused() void WorkflowRenderer::mainWorkflowPaused()
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
LightVideoFrame* MainWorkflow::blackOutput = NULL; LightVideoFrame* MainWorkflow::blackOutput = NULL;
MainWorkflow::MainWorkflow( int trackCount ) : MainWorkflow::MainWorkflow( int trackCount ) :
m_currentFrame( 0 ),
m_lengthFrame( 0 ), m_lengthFrame( 0 ),
m_renderStarted( false ) m_renderStarted( false )
{ {
...@@ -49,6 +48,7 @@ MainWorkflow::MainWorkflow( int trackCount ) : ...@@ -49,6 +48,7 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_effectEngine->disable(); m_effectEngine->disable();
m_tracks = new TrackHandler*[MainWorkflow::NbTrackType]; m_tracks = new TrackHandler*[MainWorkflow::NbTrackType];
m_currentFrame = new qint64[MainWorkflow::NbTrackType];
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i ) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
{ {
MainWorkflow::TrackType trackType = (i == 0 ? MainWorkflow::VideoTrack : MainWorkflow::AudioTrack ); MainWorkflow::TrackType trackType = (i == 0 ? MainWorkflow::VideoTrack : MainWorkflow::AudioTrack );
...@@ -57,6 +57,7 @@ MainWorkflow::MainWorkflow( int trackCount ) : ...@@ -57,6 +57,7 @@ MainWorkflow::MainWorkflow( int trackCount ) :
connect( m_tracks[i], SIGNAL( tracksUnpaused() ), this, SLOT( tracksUnpaused() ) ); connect( m_tracks[i], SIGNAL( tracksUnpaused() ), this, SLOT( tracksUnpaused() ) );
connect( m_tracks[i], SIGNAL( allTracksRenderCompleted() ), this, SLOT( tracksRenderCompleted() ) ); connect( m_tracks[i], SIGNAL( allTracksRenderCompleted() ), this, SLOT( tracksRenderCompleted() ) );
connect( m_tracks[i], SIGNAL( tracksEndReached() ), this, SLOT( tracksEndReached() ) ); connect( m_tracks[i], SIGNAL( tracksEndReached() ), this, SLOT( tracksEndReached() ) );
m_currentFrame[i] = 0;
} }
m_outputBuffers = new OutputBuffers; m_outputBuffers = new OutputBuffers;
blackOutput = new LightVideoFrame( VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes ); blackOutput = new LightVideoFrame( VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes );
...@@ -76,6 +77,7 @@ MainWorkflow::~MainWorkflow() ...@@ -76,6 +77,7 @@ MainWorkflow::~MainWorkflow()
delete m_renderMutex; delete m_renderMutex;
delete m_renderStartedLock; delete m_renderStartedLock;
delete m_currentFrameLock; delete m_currentFrameLock;
delete m_currentFrame;
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i ) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
delete m_tracks[i]; delete m_tracks[i];
delete[] m_tracks; delete[] m_tracks;
...@@ -126,16 +128,17 @@ void MainWorkflow::getOutput( TrackType trackType ) ...@@ -126,16 +128,17 @@ void MainWorkflow::getOutput( TrackType trackType )
QReadLocker lock3( m_currentFrameLock ); QReadLocker lock3( m_currentFrameLock );
QMutexLocker lock4( m_nbTrackHandlerToRenderMutex ); QMutexLocker lock4( m_nbTrackHandlerToRenderMutex );
//This has probably no reason for existing... and therefore shouldn't
if ( trackType == BothTrackType ) if ( trackType == BothTrackType )
{ {
m_nbTrackHandlerToRender = MainWorkflow::NbTrackType; m_nbTrackHandlerToRender = MainWorkflow::NbTrackType;
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i ) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->getOutput( m_currentFrame ); m_tracks[i]->getOutput( m_currentFrame[i] );
} }
else else
{ {
m_nbTrackHandlerToRender = 1; m_nbTrackHandlerToRender = 1;
m_tracks[trackType]->getOutput( m_currentFrame ); m_tracks[trackType]->getOutput( m_currentFrame[trackType] );
} }
} }
} }
...@@ -156,26 +159,28 @@ void MainWorkflow::unpause() ...@@ -156,26 +159,28 @@ void MainWorkflow::unpause()
m_tracks[i]->unpause(); m_tracks[i]->unpause();
} }
void MainWorkflow::goToNextFrame() void MainWorkflow::goToNextFrame( MainWorkflow::TrackType trackType )
{ {
if ( m_paused == false ) if ( m_paused == false )
nextFrame(); nextFrame( trackType );
} }
void MainWorkflow::nextFrame() void MainWorkflow::nextFrame( MainWorkflow::TrackType trackType )
{ {
QWriteLocker lock( m_currentFrameLock ); QWriteLocker lock( m_currentFrameLock );
++m_currentFrame; ++m_currentFrame[trackType];
emit frameChanged( m_currentFrame, Renderer ); if ( trackType == MainWorkflow::VideoTrack )
emit frameChanged( m_currentFrame[MainWorkflow::VideoTrack], Renderer );
} }
void MainWorkflow::previousFrame() void MainWorkflow::previousFrame( MainWorkflow::TrackType trackType )
{ {
QWriteLocker lock( m_currentFrameLock ); QWriteLocker lock( m_currentFrameLock );
--m_currentFrame; --m_currentFrame[trackType];
emit frameChanged( m_currentFrame, Renderer ); if ( trackType == MainWorkflow::VideoTrack )
emit frameChanged( m_currentFrame[MainWorkflow::VideoTrack], Renderer );
} }
qint64 MainWorkflow::getLengthFrame() const qint64 MainWorkflow::getLengthFrame() const
...@@ -195,8 +200,10 @@ void MainWorkflow::stop() ...@@ -195,8 +200,10 @@ void MainWorkflow::stop()
m_renderStarted = false; m_renderStarted = false;
for (unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i) for (unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i)
{
m_tracks[i]->stop(); m_tracks[i]->stop();
m_currentFrame = 0; m_currentFrame[i] = 0;
}
emit frameChanged( 0, Renderer ); emit frameChanged( 0, Renderer );
} }
...@@ -273,8 +280,9 @@ void MainWorkflow::setCurrentFrame( qint64 currentFrame, MainWorkflow::Fr ...@@ -273,8 +280,9 @@ void MainWorkflow::setCurrentFrame( qint64 currentFrame, MainWorkflow::Fr
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i)
m_tracks[i]->activateAll(); m_tracks[i]->activateAll();
} }
m_currentFrame = currentFrame; for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i)
emit frameChanged( m_currentFrame, reason ); m_currentFrame[i] = currentFrame;
emit frameChanged( currentFrame, reason );
} }
Clip* MainWorkflow::getClip( const QUuid& uuid, unsigned int trackId, MainWorkflow::TrackType trackType ) Clip* MainWorkflow::getClip( const QUuid& uuid, unsigned int trackId, MainWorkflow::TrackType trackType )
...@@ -447,5 +455,5 @@ qint64 MainWorkflow::getCurrentFrame() const ...@@ -447,5 +455,5 @@ qint64 MainWorkflow::getCurrentFrame() const
{ {
QReadLocker lock( m_currentFrameLock ); QReadLocker lock( m_currentFrameLock );
return m_currentFrame; return m_currentFrame[MainWorkflow::VideoTrack];
} }
...@@ -76,7 +76,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -76,7 +76,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* The nextFrame() method will always go for the next frame, whereas this one only does when * The nextFrame() method will always go for the next frame, whereas this one only does when
* rendering isn't paused. * rendering isn't paused.
*/ */
void goToNextFrame(); void goToNextFrame( MainWorkflow::TrackType trackype );
/** /**
* \brief Set the workflow position by the desired frame * \brief Set the workflow position by the desired frame
...@@ -109,8 +109,8 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -109,8 +109,8 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void pause(); void pause();
void unpause(); void unpause();
void nextFrame(); void nextFrame( TrackType trackType );
void previousFrame(); void previousFrame( TrackType trackType );
Clip* removeClip( const QUuid& uuid, unsigned int trackId, MainWorkflow::TrackType trackType ); Clip* removeClip( const QUuid& uuid, unsigned int trackId, MainWorkflow::TrackType trackType );
...@@ -151,7 +151,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -151,7 +151,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
private: private:
QReadWriteLock* m_currentFrameLock; QReadWriteLock* m_currentFrameLock;
qint64 m_currentFrame; qint64* m_currentFrame;
qint64 m_lengthFrame; qint64 m_lengthFrame;
/** /**
* This boolean describe is a render has been started * This boolean describe is a render has been started
......
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