Commit fdabb9b4 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactor is functionnal, synchronisation included.

parent f01a7cba
......@@ -58,9 +58,9 @@ Timeline::Timeline( QWidget *parent ) :
setDuration( 0 );
connect( m_tracksView->horizontalScrollBar(), SIGNAL( valueChanged( int ) ), m_tracksRuler, SLOT( moveRuler( int ) ) );
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64) ), this, SLOT( actionAddClip(Clip*,uint,qint64) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64 ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint) ), this, SLOT( actionRemoveClip(QUuid,uint)) );
connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64,TrackWorkflow::TrackType ) ), this, SLOT( actionAddClip(Clip*,uint,qint64,TrackWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,TrackWorkflow::TrackType ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64,TrackWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint,TrackWorkflow::TrackType ) ), this, SLOT( actionRemoveClip(QUuid,uint,TrackWorkflow::TrackType )) );
connect( m_mainWorkflow, SIGNAL( cleared() ), tracksView(), SLOT( clear() ) );
}
......@@ -99,19 +99,19 @@ void Timeline::setTool( ToolButtons button )
tracksView()->setTool( button );
}
void Timeline::actionAddClip( Clip* clip, unsigned int track, qint64 start )
void Timeline::actionAddClip( Clip* clip, unsigned int track, qint64 start, TrackWorkflow::TrackType )
{
tracksView()->addMediaItem( clip, track, start );
}
void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time )
void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, TrackWorkflow::TrackType )
{
tracksView()->moveMediaItem( uuid, track, time );
tracksView()->updateDuration();
tracksRuler()->update();
}
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track )
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track, TrackWorkflow::TrackType )
{
tracksView()->removeMediaItem( uuid, track );
}
......@@ -48,9 +48,9 @@ public slots:
void changeZoom( int factor );
void setDuration( int duration );
void setTool( ToolButtons button );
void actionAddClip( Clip* clip, unsigned int track, qint64 start );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time );
void actionRemoveClip( const QUuid& uuid, unsigned int track );
void actionAddClip( Clip* clip, unsigned int track, qint64 start, TrackWorkflow::TrackType );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, TrackWorkflow::TrackType );
void actionRemoveClip( const QUuid& uuid, unsigned int track, TrackWorkflow::TrackType );
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -93,10 +93,9 @@ void* WorkflowRenderer::lock( void* datas )
if ( self->m_stopping == false )
{
void* ret = self->m_mainWorkflow->getSynchroneOutput();
self->m_lastFrame = static_cast<unsigned char*>( ret );
return ret;
self->m_lastFrame = static_cast<MainWorkflow::OutputBuffers*>( ret );
}
return self->m_lastFrame;
return self->m_lastFrame->video;
}
void WorkflowRenderer::unlock( void* datas )
......
......@@ -72,7 +72,7 @@ class WorkflowRenderer : public GenericRenderer
bool m_stopping;
private:
unsigned char* m_lastFrame;
MainWorkflow::OutputBuffers* m_lastFrame;
QStack<Actions> m_actions;
QReadWriteLock* m_actionsLock;
bool m_pauseAsked;
......
......@@ -47,7 +47,8 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_tracks = new TrackHandler*[2];
for ( unsigned int i = 0; i < TrackWorkflow::NbType; ++i )
{
TrackWorkflow::TrackType trackType = (i == 0 ? TrackWorkflow::Video : TrackWorkflow::Audio );
//FIXME after refactoring
TrackWorkflow::TrackType trackType = (i == 0 ? TrackWorkflow::Video : TrackWorkflow::Video );
m_tracks[i] = new TrackHandler( trackCount, trackType );
connect( m_tracks[i], SIGNAL( tracksPaused() ), this, SLOT( tracksPaused() ) );
connect( m_tracks[i], SIGNAL( allTracksRenderCompleted() ), this, SLOT( tracksRenderCompleted() ) );
......@@ -65,8 +66,8 @@ MainWorkflow::~MainWorkflow()
delete m_renderMutex;
delete m_renderStartedLock;
delete[] blackOutput;
delete m_tracks[0];
delete m_tracks[1];
for ( unsigned int i = 0; i < TrackWorkflow::NbType; ++i )
delete m_tracks[i];
delete[] m_tracks;
}
......@@ -207,6 +208,7 @@ MainWorkflow::OutputBuffers* MainWorkflow::getSynchroneOutput()
m_synchroneRenderWaitCondition->wait( m_synchroneRenderWaitConditionMutex );
// qDebug() << "Got it";
m_synchroneRenderWaitConditionMutex->unlock();
m_outputBuffers->video = m_tracks[TrackWorkflow::Video]->getSynchroneOutput();
return m_outputBuffers;
}
......
......@@ -311,3 +311,8 @@ unsigned int TrackHandler::getTrackCount() const
{
return m_trackCount;
}
unsigned char* TrackHandler::getSynchroneOutput()
{
return m_synchroneRenderingBuffer;
}
......@@ -56,6 +56,7 @@ class TrackHandler : public QObject
Clip* getClip( const QUuid& uuid, unsigned int trackId );
void clear();
void setFullSpeedRender( bool value );
unsigned char* getSynchroneOutput();
bool isPaused() const;
bool allTracksRendered() const;
......
......@@ -50,7 +50,7 @@ class TrackWorkflow : public QObject
enum TrackType
{
Video,
Audio,
// Audio,
NbType
};
TrackWorkflow( unsigned int trackId, TrackType type );
......
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