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

Using ClipWorkflow's uuid to handle clip addition to the timeline.

parent 8eebc077
......@@ -29,6 +29,7 @@
#include "UndoStack.h"
#include "MainWorkflow.h"
#include "Clip.h"
#include "ClipWorkflow.h"
#define NEW_COMMAND(x) class x : public QUndoCommand
......@@ -52,21 +53,21 @@ namespace Commands
{
public:
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos ) :
m_workflow( workflow ), m_clip( clip ), m_trackNumber( trackNumber ), m_pos( pos )
m_workflow( workflow ), m_trackNumber( trackNumber ), m_pos( pos )
{
setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
}
virtual void redo()
{
m_workflow->addClip( m_clip, m_trackNumber, m_pos );
m_clipWorkflow = m_workflow->addClip( m_clip, m_trackNumber, m_pos );
}
virtual void undo()
{
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber );
m_workflow->removeClip( m_clipWorkflow->getUuid(), m_trackNumber );
}
private:
::MainWorkflow* m_workflow;
Clip* m_clip;
ClipWorklow* m_clipWorkflow;
unsigned int m_trackNumber;
qint64 m_pos;
};
......
......@@ -342,6 +342,7 @@ void TracksView::dropEvent( QDropEvent* event )
event->acceptProposedAction();
qreal mappedXPos = ( mapToScene( event->pos() ).x() + 0.5 );
//FIXME: this line seems useless ?
m_dragItem->oldTrackNumber = m_dragItem->trackNumber();
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
m_dragItem->clip(),
......
......@@ -51,6 +51,7 @@ Clip::~Clip()
void Clip::init()
{
m_uuid = QUuid::createUuid();
qDebug() << "Creating QUuid for clip:" << m_uuid;
computeLength();
m_metaTags << "Toto" << "titi" << "tutu";
}
......
......@@ -44,6 +44,7 @@ Media::Media( const QString& filePath )
m_height( 0 )
{
m_uuid = QUuid::createUuid();
qDebug() << "Creating QUuid for media:" << m_uuid;
if ( filePath.startsWith( Media::streamPrefix ) == false )
{
......
......@@ -34,6 +34,7 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip ) :
m_rendering( false ),
m_initFlag( false )
{
m_uuid = QUuid::createUuid();
m_stateLock = new QReadWriteLock;
m_requiredStateLock = new QMutex;
m_waitCond = new QWaitCondition;
......@@ -354,3 +355,8 @@ void ClipWorkflow::unpausedMediaPlayer()
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( unpausedMediaPlayer() ) );
emit unpaused();
}
const QUuid& ClipWorkflow::getUuid() const
{
return m_uuid;
}
......@@ -156,6 +156,8 @@ class ClipWorkflow : public QObject
LibVLCpp::MediaPlayer* getMediaPlayer();
const QUuid& getUuid() const;
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
static void unlock( ClipWorkflow* clipWorkflow );
......@@ -192,6 +194,8 @@ class ClipWorkflow : public QObject
WaitCondition* m_renderWaitCond;
WaitCondition* m_pausingStateWaitCond;
QUuid m_uuid;
/**
* While this flag is set to false, we will use the same buffer, to prevent
* having X buffers with the same picture (when media player is paused mainly)
......
......@@ -71,7 +71,7 @@ MainWorkflow::~MainWorkflow()
delete[] blackOutput;
}
void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
ClipWorkflow* MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
{
Q_ASSERT_X( trackId < m_trackCount, "MainWorkflow::addClip",
"The specified trackId isn't valid, for it's higher than the number of tracks");
......@@ -79,9 +79,10 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
//if the track is deactivated, we need to reactivate it :
if ( m_tracks[trackId].deactivated() == true )
activateTrack( trackId );
m_tracks[trackId]->addClip( clip, start );
ClipWorkflow* cw = m_tracks[trackId]->addClip( clip, start );
if ( m_tracks[trackId]->getLength() > m_length )
m_length = m_tracks[trackId]->getLength();
return cw;
}
void MainWorkflow::computeLength()
......
......@@ -40,7 +40,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
MainWorkflow( int trackCount );
~MainWorkflow();
void addClip( Clip* clip, unsigned int trackId, qint64 start );
ClipWorkflow* addClip( Clip* clip, unsigned int trackId, qint64 start );
void startRender();
void getOutput();
unsigned char* getSynchroneOutput();
......
......@@ -51,10 +51,11 @@ TrackWorkflow::~TrackWorkflow()
delete m_forceRepositionningMutex;
}
void TrackWorkflow::addClip( Clip* clip, qint64 start )
ClipWorkflow* TrackWorkflow::addClip( Clip* clip, qint64 start )
{
ClipWorkflow* cw = new ClipWorkflow( clip );
addClip( cw, start );
return cw;
}
void TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
......@@ -404,6 +405,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
ClipWorkflow* cw = it.value();
Clip* clip = cw->getClip();
m_clips.erase( it );
delete cw;
computeLength();
return clip;
}
......
......@@ -56,7 +56,7 @@ class TrackWorkflow : public QObject
void unpause();
void moveClip( const QUuid& id, qint64 startingFrame );
Clip* removeClip( const QUuid& id );
void addClip( Clip*, qint64 start );
ClipWorkflow* addClip( Clip*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
qint64 getClipPosition( const QUuid& uuid ) const;
......
Supports Markdown
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