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

Clip moving is now functionnal in the workflow

parent c8fb6f26
......@@ -114,7 +114,6 @@ void MetaDataManager::getMetaData()
m_currentClip->setWidth( m_mediaPlayer->getWidth() );
m_currentClip->setHeight( m_mediaPlayer->getHeight() );
// qDebug() << "length =" << m_currentClip->getLength();
//Setting time for snapshot :
if ( m_currentClip->getFileType() == Media::Video )
{
......
......@@ -193,3 +193,14 @@ MainWorkflow* MainWorkflow::getInstance()
Q_ASSERT( m_instance != NULL );
return m_instance;
}
void MainWorkflow::clipMoved( QUuid clipUuid, int trackId, qint64 startingFrame )
{
//If the frame was stopped, reactivating it, since it can have something to render after
//the clip displacement
Q_ASSERT( trackId < m_trackCount );
if ( m_tracks[trackId].activated() == false )
m_tracks[trackId].activate();
//And now, just move the clip.
m_tracks[trackId]->moveClip( clipUuid, startingFrame );
}
......@@ -84,6 +84,9 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
bool m_renderStarted;
QReadWriteLock* m_renderStartedLock;
public slots:
void clipMoved( QUuid, int, qint64 );
private slots:
void trackEndReached( unsigned int trackId );
......
......@@ -27,9 +27,11 @@
TrackWorkflow::TrackWorkflow( unsigned int trackId ) :
m_trackId( trackId ),
m_length( 0 )
m_length( 0 ),
m_forceRepositionning( false )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_forceRepositionningMutex = new QMutex;
}
TrackWorkflow::~TrackWorkflow()
......@@ -43,6 +45,7 @@ TrackWorkflow::~TrackWorkflow()
delete it.value();
it = m_clips.erase( it );
}
delete m_forceRepositionningMutex;
delete m_mediaPlayer;
}
......@@ -223,7 +226,16 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
emit trackEndReached( m_trackId );
//We continue, as there can be ClipWorkflow that required to be stopped.
}
needRepositioning = ( abs( currentFrame - lastFrame ) > 1 ) ? true : false;
{
QMutexLocker lock( m_forceRepositionningMutex );
if ( m_forceRepositionning == true )
{
needRepositioning = true;
m_forceRepositionning = false;
}
else
needRepositioning = ( abs( currentFrame - lastFrame ) > 1 ) ? true : false;
}
while ( it != end )
{
qint64 start = it.key();
......@@ -249,3 +261,25 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
}
return ret;
}
void TrackWorkflow::moveClip( QUuid id, qint64 startingFrame )
{
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
while ( it != end )
{
if ( it.value()->getClip()->getUuid() == id )
{
ClipWorkflow* cw = it.value();
m_clips.erase( it );
m_clips[startingFrame] = cw;
QMutexLocker lock( m_forceRepositionningMutex );
m_forceRepositionning = true;
return ;
}
++it;
}
qDebug() << "Track" << m_trackId << "was asked to move clip" << id << "to position" << startingFrame
<< "but this clip doesn't exist in this track";
}
......@@ -53,6 +53,7 @@ class TrackWorkflow : public QObject
unsigned char* getOutput( qint64 currentFrame );
qint64 getLength() const;
void stop();
void moveClip( QUuid id, qint64 startingFrame );
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60;
......@@ -81,6 +82,13 @@ class TrackWorkflow : public QObject
*/
qint64 m_length;
/**
* \brief If a clip was moved, we may have to force repositionning.
* If this flag is set to true, we will force it anyway.
*/
bool m_forceRepositionning;
QMutex* m_forceRepositionningMutex;
public:
void addClip( Clip*, qint64 start );
......
......@@ -59,6 +59,8 @@ 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_tracksView, SIGNAL( clipMoved( QUuid, int, qint64) ),
MainWorkflow::getInstance(), SLOT( clipMoved( QUuid, int, qint64 ) ) );
}
void Timeline::changeEvent( QEvent *e )
......
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