Commit 2ed1e54b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Clip removal is now stacked.

parent 9fdbb069
...@@ -77,20 +77,23 @@ void Commands::MainWorkflow::MoveClip::undo() ...@@ -77,20 +77,23 @@ void Commands::MainWorkflow::MoveClip::undo()
m_undoRedoAction = true; m_undoRedoAction = true;
} }
Commands::MainWorkflow::RemoveClips::RemoveClips( ::MainWorkflow* workflow, const QVector<ClipActionInfo>& clipsInfos ) : Commands::MainWorkflow::RemoveClips::RemoveClips( WorkflowRenderer* renderer, const QVector<ClipActionInfo>& clipsInfos ) :
m_workflow( workflow ), m_clips( clipsInfos ) m_renderer( renderer ), m_clips( clipsInfos )
{ {
setText( QObject::tr( "Remove clip" ) ); setText( QObject::tr( "Remove clip" ) );
} }
void Commands::MainWorkflow::RemoveClips::redo() void Commands::MainWorkflow::RemoveClips::redo()
{ {
for (int i = 0; i < m_clips.size(); ++i ) for (int i = 0; i < m_clips.size(); ++i )
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber, m_clips.at( i ).trackType ); {
const ClipActionInfo& clipInfo = m_clips.at( i );
m_renderer->removeClip( clipInfo.clip->getUuid(), clipInfo.trackNumber, clipInfo.trackType );
}
} }
void Commands::MainWorkflow::RemoveClips::undo() void Commands::MainWorkflow::RemoveClips::undo()
{ {
for (int i = 0; i < m_clips.size(); ++i ) for (int i = 0; i < m_clips.size(); ++i )
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos, m_clips.at( i ).trackType ); m_renderer->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos, m_clips.at( i ).trackType );
} }
Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId, Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "UndoStack.h" #include "UndoStack.h"
#include "MainWorkflow.h" #include "MainWorkflow.h"
#include "Clip.h" #include "Clip.h"
#include "WorkflowRenderer.h"
#define NEW_COMMAND(x) class x : public QUndoCommand #define NEW_COMMAND(x) class x : public QUndoCommand
...@@ -84,13 +85,13 @@ namespace Commands ...@@ -84,13 +85,13 @@ namespace Commands
NEW_COMMAND( RemoveClips ) NEW_COMMAND( RemoveClips )
{ {
public: public:
RemoveClips( ::MainWorkflow* workflow, const QVector<ClipActionInfo>& clipsInfos ); RemoveClips( WorkflowRenderer* renderer, const QVector<ClipActionInfo>& clipsInfos );
virtual void redo(); virtual void redo();
virtual void undo(); virtual void undo();
private: private:
::MainWorkflow* m_workflow; WorkflowRenderer* m_renderer;
QVector<ClipActionInfo> m_clips; QVector<ClipActionInfo> m_clips;
}; };
NEW_COMMAND( ResizeClip ) NEW_COMMAND( ResizeClip )
......
...@@ -30,7 +30,7 @@ GreenFilterEffect::GreenFilterEffect() : GenericEffect( ...@@ -30,7 +30,7 @@ GreenFilterEffect::GreenFilterEffect() : GenericEffect(
GreenFilterEffect::m_videoInputsNames, GreenFilterEffect::m_nbVideoInputs, GreenFilterEffect::m_videoInputsNames, GreenFilterEffect::m_nbVideoInputs,
GreenFilterEffect::m_videoOutputsNames, GreenFilterEffect::m_nbVideoOutputs GreenFilterEffect::m_videoOutputsNames, GreenFilterEffect::m_nbVideoOutputs
), ),
m_logo(QImage(QImage("vlmc.png").scaled(100, 100, Qt::KeepAspectRatio)).rgbSwapped()), m_logo(QImage(QImage(":/images/images/vlmc.png").scaled(100, 100, Qt::KeepAspectRatio)).rgbSwapped()),
m_enabled( true ) m_enabled( true )
{ {
}; };
......
...@@ -61,6 +61,7 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -61,6 +61,7 @@ MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent ), m_renderer( NULL ) QMainWindow( parent ), m_renderer( NULL )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
qRegisterMetaType<MainWorkflow::TrackType>( "MainWorkflow::TrackType" );
DockWidgetManager::instance( this )->setMainWindow( this ); DockWidgetManager::instance( this )->setMainWindow( this );
initializeDockWidgets(); initializeDockWidgets();
createStatusBar(); createStatusBar();
...@@ -269,7 +270,8 @@ void MainWindow::createStatusBar() ...@@ -269,7 +270,8 @@ void MainWindow::createStatusBar()
void MainWindow::initializeDockWidgets( void ) void MainWindow::initializeDockWidgets( void )
{ {
m_timeline = new Timeline( this ); WorkflowRenderer* workflowRenderer = new WorkflowRenderer();
m_timeline = new Timeline( workflowRenderer, this );
m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_timeline->show(); m_timeline->show();
setCentralWidget( m_timeline ); setCentralWidget( m_timeline );
...@@ -290,7 +292,7 @@ void MainWindow::initializeDockWidgets( void ) ...@@ -290,7 +292,7 @@ void MainWindow::initializeDockWidgets( void )
QShortcut* clipShortcut = new QShortcut( QKeySequence( tr( "Ctrl+Return", "Start clip preview" ) ), this ); QShortcut* clipShortcut = new QShortcut( QKeySequence( tr( "Ctrl+Return", "Start clip preview" ) ), this );
connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) ); connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) );
m_projectPreview = new PreviewWidget( new WorkflowRenderer(), this ); m_projectPreview = new PreviewWidget( workflowRenderer, this );
dockManager->addDockedWidget( m_projectPreview, dockManager->addDockedWidget( m_projectPreview,
tr( "Project Preview" ), tr( "Project Preview" ),
Qt::AllDockWidgetAreas, Qt::AllDockWidgetAreas,
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
Timeline* Timeline::m_instance = NULL; Timeline* Timeline::m_instance = NULL;
Timeline::Timeline( QWidget *parent ) : Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
QWidget( parent ), m_scale( 1.0 ) QWidget( parent ), m_scale( 1.0 ), m_renderer( renderer )
{ {
Q_ASSERT( m_instance == NULL ); Q_ASSERT( m_instance == NULL );
m_instance = this; m_instance = this;
...@@ -39,7 +39,7 @@ Timeline::Timeline( QWidget *parent ) : ...@@ -39,7 +39,7 @@ Timeline::Timeline( QWidget *parent ) :
m_mainWorkflow = MainWorkflow::getInstance(); m_mainWorkflow = MainWorkflow::getInstance();
m_tracksScene = new TracksScene( this ); m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame ); m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_renderer, m_ui.tracksFrame );
m_tracksView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_tracksView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_tracksView->scale(1, 1); m_tracksView->scale(1, 1);
...@@ -72,7 +72,7 @@ Timeline::Timeline( QWidget *parent ) : ...@@ -72,7 +72,7 @@ Timeline::Timeline( QWidget *parent ) :
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) ); connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64,MainWorkflow::TrackType ) ), this, SLOT( actionAddClip(Clip*,uint,qint64,MainWorkflow::TrackType ) ) ); connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64,MainWorkflow::TrackType ) ), this, SLOT( actionAddClip(Clip*,uint,qint64,MainWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,MainWorkflow::TrackType ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64,MainWorkflow::TrackType ) ) ); connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,MainWorkflow::TrackType ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64,MainWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint,MainWorkflow::TrackType ) ), this, SLOT( actionRemoveClip(QUuid,uint,MainWorkflow::TrackType )) ); connect( m_mainWorkflow, SIGNAL( clipRemoved(Clip*,uint,MainWorkflow::TrackType ) ), this, SLOT( actionRemoveClip(Clip*,uint,MainWorkflow::TrackType )) );
connect( m_mainWorkflow, SIGNAL( cleared() ), tracksView(), SLOT( clear() ) ); connect( m_mainWorkflow, SIGNAL( cleared() ), tracksView(), SLOT( clear() ) );
connect( m_tracksView, SIGNAL( videoTrackAdded(GraphicsTrack*) ), connect( m_tracksView, SIGNAL( videoTrackAdded(GraphicsTrack*) ),
...@@ -80,6 +80,11 @@ Timeline::Timeline( QWidget *parent ) : ...@@ -80,6 +80,11 @@ Timeline::Timeline( QWidget *parent ) :
connect( m_tracksView, SIGNAL( audioTrackAdded(GraphicsTrack*) ), connect( m_tracksView, SIGNAL( audioTrackAdded(GraphicsTrack*) ),
m_tracksControls, SLOT( addAudioTrack(GraphicsTrack*) ) ); m_tracksControls, SLOT( addAudioTrack(GraphicsTrack*) ) );
connect( m_mainWorkflow, SIGNAL( frameChanged(qint64) ),
m_tracksView->tracksCursor(), SLOT( setCursorPos( qint64 ) ), Qt::QueuedConnection );
connect( m_tracksView->tracksCursor(), SIGNAL( cursorPositionChanged( qint64 ) ),
m_renderer, SLOT( timelineCursorChanged(qint64) ) );
m_tracksView->createLayout(); m_tracksView->createLayout();
} }
...@@ -130,7 +135,7 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim ...@@ -130,7 +135,7 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim
tracksRuler()->update(); tracksRuler()->update();
} }
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track, MainWorkflow::TrackType ) void Timeline::actionRemoveClip( Clip* clip, unsigned int track, MainWorkflow::TrackType )
{ {
tracksView()->removeMediaItem( uuid, track ); tracksView()->removeMediaItem( clip->getUuid(), track );
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "TracksRuler.h" #include "TracksRuler.h"
#include "TracksControls.h" #include "TracksControls.h"
#include "Workflow/MainWorkflow.h" #include "Workflow/MainWorkflow.h"
#include "WorkflowRenderer.h"
class TracksScene; class TracksScene;
class TracksView; class TracksView;
...@@ -37,7 +38,7 @@ class Timeline : public QWidget ...@@ -37,7 +38,7 @@ class Timeline : public QWidget
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY( Timeline ) Q_DISABLE_COPY( Timeline )
public: public:
explicit Timeline( QWidget *parent = 0 ); explicit Timeline( WorkflowRenderer* renderer, QWidget *parent = 0 );
virtual ~Timeline(); virtual ~Timeline();
TracksView* tracksView() { return m_tracksView; } TracksView* tracksView() { return m_tracksView; }
TracksScene* tracksScene() { return m_tracksScene; } TracksScene* tracksScene() { return m_tracksScene; }
...@@ -50,7 +51,7 @@ public slots: ...@@ -50,7 +51,7 @@ public slots:
void setTool( ToolButtons button ); void setTool( ToolButtons button );
void actionAddClip( Clip* clip, unsigned int track, qint64 start, MainWorkflow::TrackType ); void actionAddClip( Clip* clip, unsigned int track, qint64 start, MainWorkflow::TrackType );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, MainWorkflow::TrackType ); void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, MainWorkflow::TrackType );
void actionRemoveClip( const QUuid& uuid, unsigned int track, MainWorkflow::TrackType ); void actionRemoveClip( Clip* clip, unsigned int track, MainWorkflow::TrackType );
protected: protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
...@@ -63,6 +64,7 @@ private: ...@@ -63,6 +64,7 @@ private:
TracksControls* m_tracksControls; TracksControls* m_tracksControls;
double m_scale; double m_scale;
MainWorkflow* m_mainWorkflow; MainWorkflow* m_mainWorkflow;
WorkflowRenderer* m_renderer;
static Timeline* m_instance; static Timeline* m_instance;
}; };
......
...@@ -73,7 +73,7 @@ void TracksScene::keyPressEvent( QKeyEvent* keyEvent ) ...@@ -73,7 +73,7 @@ void TracksScene::keyPressEvent( QKeyEvent* keyEvent )
clipsinfos.append( ai ); clipsinfos.append( ai );
} }
Commands::trigger( new Commands::MainWorkflow::RemoveClips( tv->m_mainWorkflow, Commands::trigger( new Commands::MainWorkflow::RemoveClips( tv->m_renderer,
clipsinfos ) ); clipsinfos ) );
} }
......
...@@ -35,8 +35,9 @@ ...@@ -35,8 +35,9 @@
#include "Commands.h" #include "Commands.h"
#include "GraphicsTrack.hpp" #include "GraphicsTrack.hpp"
TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent ) TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, WorkflowRenderer* renderer, QWidget* parent )
: QGraphicsView( scene, parent ), m_scene( scene ), m_mainWorkflow( mainWorkflow ) : QGraphicsView( scene, parent ), m_scene( scene ), m_mainWorkflow( mainWorkflow ),
m_renderer( renderer )
{ {
//TODO should be defined by the settings //TODO should be defined by the settings
m_tracksHeight = 25; m_tracksHeight = 25;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "MainWorkflow.h" #include "MainWorkflow.h"
#include "TrackWorkflow.h" #include "TrackWorkflow.h"
#include "AbstractGraphicsMediaItem.h" #include "AbstractGraphicsMediaItem.h"
#include "WorkflowRenderer.h"
class GraphicsMovieItem; class GraphicsMovieItem;
class TracksScene; class TracksScene;
...@@ -46,7 +47,7 @@ class TracksView : public QGraphicsView ...@@ -46,7 +47,7 @@ class TracksView : public QGraphicsView
Q_OBJECT Q_OBJECT
public: public:
TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent = 0 ); TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, WorkflowRenderer* renderer, QWidget* parent = 0 );
void setDuration( int duration ); void setDuration( int duration );
int duration() const { return m_projectDuration; } int duration() const { return m_projectDuration; }
int tracksHeight() const { return m_tracksHeight; } int tracksHeight() const { return m_tracksHeight; }
...@@ -103,6 +104,7 @@ private: ...@@ -103,6 +104,7 @@ private:
GraphicsMovieItem* m_dragItem; GraphicsMovieItem* m_dragItem;
QGraphicsWidget* m_separator; QGraphicsWidget* m_separator;
ToolButtons m_tool; ToolButtons m_tool;
WorkflowRenderer* m_renderer;
// Mouse actions on Medias // Mouse actions on Medias
bool m_actionMove; bool m_actionMove;
......
...@@ -36,7 +36,7 @@ WorkflowRenderer::WorkflowRenderer() : ...@@ -36,7 +36,7 @@ WorkflowRenderer::WorkflowRenderer() :
{ {
char buffer[64]; char buffer[64];
m_actionsLock = new QReadWriteLock; m_actionsMutex = new QMutex;
m_media = new LibVLCpp::Media( "fake://" ); m_media = new LibVLCpp::Media( "fake://" );
sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH ); sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH );
...@@ -67,10 +67,6 @@ WorkflowRenderer::WorkflowRenderer() : ...@@ -67,10 +67,6 @@ WorkflowRenderer::WorkflowRenderer() :
m_renderVideoFrame = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes]; m_renderVideoFrame = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * Pixel::NbComposantes];
//Workflow part //Workflow part
connect( m_mainWorkflow, SIGNAL( frameChanged(qint64) ),
Timeline::getInstance()->tracksView()->tracksCursor(), SLOT( setCursorPos( qint64 ) ), Qt::QueuedConnection );
connect( Timeline::getInstance()->tracksView()->tracksCursor(), SIGNAL( cursorPositionChanged( qint64 ) ),
this, SLOT( timelineCursorChanged(qint64) ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowPaused() ), this, SLOT( mainWorkflowPaused() ) ); connect( m_mainWorkflow, SIGNAL( mainWorkflowPaused() ), this, SLOT( mainWorkflowPaused() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowUnpaused() ), this, SLOT( mainWorkflowUnpaused() ) ); connect( m_mainWorkflow, SIGNAL( mainWorkflowUnpaused() ), this, SLOT( mainWorkflowUnpaused() ) );
} }
...@@ -80,16 +76,7 @@ WorkflowRenderer::~WorkflowRenderer() ...@@ -80,16 +76,7 @@ WorkflowRenderer::~WorkflowRenderer()
{ {
stop(); stop();
//FIXME this is probably useless... delete m_actionsMutex;
//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; delete m_media;
delete m_condMutex; delete m_condMutex;
delete m_waitCond; delete m_waitCond;
...@@ -124,28 +111,35 @@ void WorkflowRenderer::unlock( void* datas ) ...@@ -124,28 +111,35 @@ void WorkflowRenderer::unlock( void* datas )
void WorkflowRenderer::checkActions() void WorkflowRenderer::checkActions()
{ {
QReadLocker lock( m_actionsLock ); QMutexLocker lock( m_actionsMutex );
if ( m_actions.size() == 0 ) if ( m_actions.size() == 0 )
return ; return ;
while ( m_actions.empty() == false ) while ( m_actions.empty() == false )
{ {
Actions act = m_actions.top(); StackedAction* act = m_actions.top();
m_actions.pop(); m_actions.pop();
switch ( act ) switch ( act->action )
{ {
case Pause: case Pause:
if ( m_pauseAsked == true ) if ( m_pauseAsked == true )
continue ; continue ;
m_pauseAsked = true; m_pauseAsked = true;
// m_mediaPlayer->pause();
pauseMainWorkflow(); pauseMainWorkflow();
//This will also pause the MainWorkflow via a signal/slot //This will also pause the MainWorkflow via a signal/slot
break ; break ;
case AddClip:
qDebug() << "Unstacked action";
m_mainWorkflow->addClip( act->clip, act->trackId, act->startingPos, act->trackType );
break ;
case RemoveClip:
m_mainWorkflow->removeClip( act->uuid, act->trackId, act->trackType );
break ;
default: default:
qDebug() << "Unhandled action:" << act; qDebug() << "Unhandled action:" << act->action;
break ; break ;
} }
delete act;
} }
} }
...@@ -247,8 +241,9 @@ void WorkflowRenderer::internalPlayPause( bool forcePause ) ...@@ -247,8 +241,9 @@ void WorkflowRenderer::internalPlayPause( bool forcePause )
{ {
if ( m_paused == false ) if ( m_paused == false )
{ {
QWriteLocker lock( m_actionsLock ); QMutexLocker lock( m_actionsMutex );
m_actions.push( Pause ); StackedAction* act = new StackedAction( Pause );
m_actions.push( act );
} }
} }
} }
...@@ -281,6 +276,31 @@ float WorkflowRenderer::getFps() const ...@@ -281,6 +276,31 @@ float WorkflowRenderer::getFps() const
return m_outputFps; return m_outputFps;
} }
void WorkflowRenderer::removeClip( const QUuid& uuid, uint32_t trackId, MainWorkflow::TrackType trackType )
{
StackedAction* act = new StackedAction( RemoveClip );
act->uuid = uuid;
act->trackId = trackId;
act->trackType = trackType;
QMutexLocker lock( m_actionsMutex );
m_actions.push( act );
qDebug() << "<<<<<<<<";
}
void WorkflowRenderer::addClip( Clip* clip, uint32_t trackNumber, qint64 startingPos, MainWorkflow::TrackType trackType )
{
if ( m_isRendering == true )
{
StackedAction* act = new StackedAction( AddClip );
act->clip = clip;
act->trackId = trackNumber;
act->startingPos = startingPos;
act->trackType = trackType;
}
else
m_mainWorkflow->addClip( clip, trackNumber, startingPos, trackType );
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
/////SLOTS : /////SLOTS :
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
...@@ -332,4 +352,3 @@ void WorkflowRenderer::timelineCursorChanged( qint64 newFrame ) ...@@ -332,4 +352,3 @@ void WorkflowRenderer::timelineCursorChanged( qint64 newFrame )
{ {
m_mainWorkflow->setCurrentFrame( newFrame ); m_mainWorkflow->setCurrentFrame( newFrame );
} }
...@@ -40,8 +40,20 @@ class WorkflowRenderer : public GenericRenderer ...@@ -40,8 +40,20 @@ class WorkflowRenderer : public GenericRenderer
enum Actions enum Actions
{ {
Pause, Pause,
AddClip,
RemoveClip,
//Unpause, //Unpause,
}; };
struct StackedAction
{
StackedAction( Actions act ) : action( act ), trackId( -1 ), clip( NULL ) {}
Actions action;
QUuid uuid;
uint32_t trackId;
MainWorkflow::TrackType trackType;
Clip* clip;
qint64 startingPos;
};
WorkflowRenderer(); WorkflowRenderer();
~WorkflowRenderer(); ~WorkflowRenderer();
...@@ -58,11 +70,12 @@ class WorkflowRenderer : public GenericRenderer ...@@ -58,11 +70,12 @@ class WorkflowRenderer : public GenericRenderer
virtual qint64 getLengthMs() const; virtual qint64 getLengthMs() const;
virtual qint64 getCurrentFrame() const; virtual qint64 getCurrentFrame() const;
virtual float getFps() const; virtual float getFps() const;
void addClip( Clip* clip, uint32_t trackNumber, qint64 startingPos, MainWorkflow::TrackType trackType );
void removeClip( const QUuid& uuid, uint32_t trackId, MainWorkflow::TrackType trackType );
static void* lock( void* datas ); static void* lock( void* datas );
static void* lockAudio( void* datas ); static void* lockAudio( void* datas );
static void unlock( void* datas ); static void unlock( void* datas );
private: private:
void internalPlayPause( bool forcePause ); void internalPlayPause( bool forcePause );
void pauseMainWorkflow(); void pauseMainWorkflow();
...@@ -79,8 +92,8 @@ class WorkflowRenderer : public GenericRenderer ...@@ -79,8 +92,8 @@ class WorkflowRenderer : public GenericRenderer
private: private:
unsigned char* m_renderVideoFrame; unsigned char* m_renderVideoFrame;
unsigned char* m_renderAudioSample; unsigned char* m_renderAudioSample;
QStack<Actions> m_actions; QStack<StackedAction*> m_actions;
QReadWriteLock* m_actionsLock; QMutex* m_actionsMutex;
bool m_pauseAsked; bool m_pauseAsked;
bool m_unpauseAsked; bool m_unpauseAsked;
QMutex* m_condMutex; QMutex* m_condMutex;
......
...@@ -211,7 +211,7 @@ Clip* MainWorkflow::removeClip( const QUuid& uuid, unsigned int trackId, M ...@@ -211,7 +211,7 @@ Clip* MainWorkflow::removeClip( const QUuid& uuid, unsigned int trackId, M
{ {
Clip* clip = m_tracks[trackType]->removeClip( uuid, trackId ); Clip* clip = m_tracks[trackType]->removeClip( uuid, trackId );
computeLength(); computeLength();
emit clipRemoved( uuid, trackId, trackType ); emit clipRemoved( clip, trackId, trackType );
return clip; return clip;
} }
......
...@@ -54,6 +54,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -54,6 +54,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
NbTrackType, NbTrackType,
AudioTrack, AudioTrack,
}; };
void addClip( Clip* clip, unsigned int trackId, qint64 start, TrackType type ); void addClip( Clip* clip, unsigned int trackId, qint64 start, TrackType type );
void startRender(); void startRender();
...@@ -177,7 +178,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -177,7 +178,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void mainWorkflowPaused(); void mainWorkflowPaused();
void mainWorkflowUnpaused();