Commit 8704d5ce authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Use ClipWorkflow Get or Pop mode according to paused state.

Next frame is functionnal, but a bug remains elsewhere, preventing the
frame to be correctly displayed.
parent 52e59020
...@@ -131,7 +131,7 @@ WorkflowRenderer::lockVideo( qint64 *pts, size_t *bufferSize, void **buffer ) ...@@ -131,7 +131,7 @@ WorkflowRenderer::lockVideo( qint64 *pts, size_t *bufferSize, void **buffer )
{ {
qint64 ptsDiff = 0; qint64 ptsDiff = 0;
if ( m_stopping == false && m_paused == false ) if ( m_stopping == false )
{ {
MainWorkflow::OutputBuffers* ret = MainWorkflow::OutputBuffers* ret =
m_mainWorkflow->getOutput( MainWorkflow::VideoTrack ); m_mainWorkflow->getOutput( MainWorkflow::VideoTrack );
...@@ -235,8 +235,7 @@ void WorkflowRenderer::startPreview() ...@@ -235,8 +235,7 @@ void WorkflowRenderer::startPreview()
void WorkflowRenderer::nextFrame() void WorkflowRenderer::nextFrame()
{ {
//FIXME: won't work, just compile m_mainWorkflow->renderOneFrame();
m_mainWorkflow->nextFrame( MainWorkflow::VideoTrack );
} }
void WorkflowRenderer::previousFrame() void WorkflowRenderer::previousFrame()
......
...@@ -459,3 +459,12 @@ MainWorkflow::getHeight() const ...@@ -459,3 +459,12 @@ MainWorkflow::getHeight() const
{ {
return m_height; return m_height;
} }
void
MainWorkflow::renderOneFrame()
{
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->renderOneFrame();
nextFrame( VideoTrack );
nextFrame( AudioTrack );
}
...@@ -325,6 +325,14 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -325,6 +325,14 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
uint32_t getHeight() const; uint32_t getHeight() const;
/**
* \brief Will render one frame only
*
* It will change the ClipWorkflow frame getting mode from Get to Pop, just for
* one frame
*/
void renderOneFrame();
private: private:
MainWorkflow( int trackCount = 64 ); MainWorkflow( int trackCount = 64 );
~MainWorkflow(); ~MainWorkflow();
......
...@@ -320,3 +320,13 @@ TrackHandler::save( QDomDocument& doc, QDomElement& timelineNode ) const ...@@ -320,3 +320,13 @@ TrackHandler::save( QDomDocument& doc, QDomElement& timelineNode ) const
} }
} }
} }
void
TrackHandler::renderOneFrame()
{
for ( unsigned int i = 0; i < m_trackCount; ++i)
{
if ( m_tracks[i].activated() == true )
m_tracks[i]->renderOneFrame();
}
}
...@@ -77,6 +77,14 @@ class TrackHandler : public QObject ...@@ -77,6 +77,14 @@ class TrackHandler : public QObject
void save( QDomDocument& doc, QDomElement& timelineNode ) const; void save( QDomDocument& doc, QDomElement& timelineNode ) const;
/**
* \brief Will configure the track workflow so they render only one frame
*
* \sa MainWorkflow::renderOneFrame()
*/
void renderOneFrame();
private: private:
void computeLength(); void computeLength();
void activateTrack( unsigned int tracKId ); void activateTrack( unsigned int tracKId );
......
...@@ -44,6 +44,7 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ...@@ -44,6 +44,7 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type
m_audioStackedBuffer( NULL ) m_audioStackedBuffer( NULL )
{ {
m_forceRepositionningMutex = new QMutex; m_forceRepositionningMutex = new QMutex;
m_renderOneFrameMutex = new QMutex;
m_clipsLock = new QReadWriteLock; m_clipsLock = new QReadWriteLock;
} }
...@@ -59,6 +60,7 @@ TrackWorkflow::~TrackWorkflow() ...@@ -59,6 +60,7 @@ TrackWorkflow::~TrackWorkflow()
it = m_clips.erase( it ); it = m_clips.erase( it );
} }
delete m_clipsLock; delete m_clipsLock;
delete m_renderOneFrameMutex;
delete m_forceRepositionningMutex; delete m_forceRepositionningMutex;
} }
...@@ -130,10 +132,13 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid ) ...@@ -130,10 +132,13 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid )
} }
void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start , bool needRepositioning ) qint64 start , bool needRepositioning,
bool renderOneFrame )
{ {
cw->getStateLock()->lockForRead(); ClipWorkflow::GetMode mode = ( m_paused == false || renderOneFrame == true ?
ClipWorkflow::Pop : ClipWorkflow::Get );
cw->getStateLock()->lockForRead();
// qDebug() << "TrackWorkflow::renderClip. currentFrame:" << currentFrame << "trackType:" << m_trackType; // qDebug() << "TrackWorkflow::renderClip. currentFrame:" << currentFrame << "trackType:" << m_trackType;
if ( cw->getState() == ClipWorkflow::Rendering || if ( cw->getState() == ClipWorkflow::Rendering ||
cw->getState() == ClipWorkflow::Paused || cw->getState() == ClipWorkflow::Paused ||
...@@ -145,7 +150,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, ...@@ -145,7 +150,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
{ {
adjustClipTime( currentFrame, start, cw ); adjustClipTime( currentFrame, start, cw );
} }
return cw->getOutput( ClipWorkflow::Pop ); return cw->getOutput( mode );
} }
else if ( cw->getState() == ClipWorkflow::Stopped ) else if ( cw->getState() == ClipWorkflow::Stopped )
{ {
...@@ -154,7 +159,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, ...@@ -154,7 +159,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->waitForCompleteInit(); cw->waitForCompleteInit();
if ( start != currentFrame || cw->getClip()->getBegin() != 0 ) //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 ); adjustClipTime( currentFrame, start, cw );
return cw->getOutput( ClipWorkflow::Pop ); return cw->getOutput( mode );
} }
else if ( cw->getState() == ClipWorkflow::EndReached ) else if ( cw->getState() == ClipWorkflow::EndReached )
{ {
...@@ -252,6 +257,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -252,6 +257,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end(); QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
bool needRepositioning; bool needRepositioning;
void* ret = NULL; void* ret = NULL;
bool renderOneFrame = false;
if ( checkEnd( currentFrame ) == true ) if ( checkEnd( currentFrame ) == true )
{ {
...@@ -259,7 +265,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -259,7 +265,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
//We continue, as there can be ClipWorkflow that requires to be stopped. //We continue, as there can be ClipWorkflow that requires to be stopped.
} }
{ {
QMutexLocker lock( m_forceRepositionningMutex ); QMutexLocker lock2( m_forceRepositionningMutex );
if ( m_forceRepositionning == true ) if ( m_forceRepositionning == true )
{ {
needRepositioning = true; needRepositioning = true;
...@@ -270,6 +276,14 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -270,6 +276,14 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
else else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false; needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false;
} }
{
QMutexLocker lock2( m_renderOneFrameMutex );
if ( m_renderOneFrame == true )
{
m_renderOneFrame = false;
renderOneFrame = true;
}
}
while ( it != end ) while ( it != end )
{ {
...@@ -281,7 +295,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -281,7 +295,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
{ {
if ( ret != NULL ) if ( ret != NULL )
qCritical() << "There's more than one clip to render here. Undefined behaviour !"; qCritical() << "There's more than one clip to render here. Undefined behaviour !";
ret = renderClip( cw, currentFrame, start, needRepositioning ); ret = renderClip( cw, currentFrame, start, needRepositioning, renderOneFrame );
if ( m_trackType == MainWorkflow::VideoTrack ) if ( m_trackType == MainWorkflow::VideoTrack )
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret ); m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
else else
...@@ -297,6 +311,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -297,6 +311,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
++it; ++it;
} }
m_lastFrame = subFrame; m_lastFrame = subFrame;
return ret; return ret;
} }
...@@ -465,3 +480,10 @@ void TrackWorkflow::forceRepositionning() ...@@ -465,3 +480,10 @@ void TrackWorkflow::forceRepositionning()
QMutexLocker lock( m_forceRepositionningMutex ); QMutexLocker lock( m_forceRepositionningMutex );
m_forceRepositionning = true; m_forceRepositionning = true;
} }
void
TrackWorkflow::renderOneFrame()
{
QMutexLocker lock( m_renderOneFrameMutex );
m_renderOneFrame = true;
}
...@@ -79,11 +79,13 @@ class TrackWorkflow : public QObject ...@@ -79,11 +79,13 @@ class TrackWorkflow : public QObject
void clear(); void clear();
void forceRepositionning(); void forceRepositionning();
void renderOneFrame();
private: private:
void computeLength(); void computeLength();
void* renderClip( ClipWorkflow* cw, qint64 currentFrame, void* renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start, bool needRepositioning ); qint64 start, bool needRepositioning,
bool renderOneFrame );
void preloadClip( ClipWorkflow* cw ); void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw ); void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const; bool checkEnd( qint64 currentFrame ) const;
...@@ -107,6 +109,8 @@ class TrackWorkflow : public QObject ...@@ -107,6 +109,8 @@ class TrackWorkflow : public QObject
*/ */
bool m_forceRepositionning; bool m_forceRepositionning;
QMutex* m_forceRepositionningMutex; QMutex* m_forceRepositionningMutex;
bool m_renderOneFrame;
QMutex *m_renderOneFrameMutex;
QReadWriteLock* m_clipsLock; QReadWriteLock* m_clipsLock;
......
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