Commit fd27bbd5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

TrackWorkflow: Adding a setter for trackworkflow effects.

parent 473933aa
......@@ -50,6 +50,7 @@ TrackWorkflow::TrackWorkflow( Workflow::TrackType type, quint32 trackId ) :
m_renderOneFrameMutex = new QMutex;
m_clipsLock = new QReadWriteLock;
m_mixerBuffer = new Workflow::Frame;
m_effectsLock = new QReadWriteLock;
}
TrackWorkflow::~TrackWorkflow()
......@@ -63,6 +64,7 @@ TrackWorkflow::~TrackWorkflow()
delete it.value();
it = m_clips.erase( it );
}
delete m_effectsLock;
delete m_clipsLock;
delete m_renderOneFrameMutex;
}
......@@ -108,6 +110,21 @@ TrackWorkflow::addEffect( Effect *effect, const QUuid &uuid )
return NULL;
}
EffectsEngine::EffectHelper*
TrackWorkflow::addEffect( Effect *effect, qint64 start /*= 0*/, qint64 end /*= -1*/ )
{
EffectInstance *effectInstance = effect->createInstance();
if ( m_isRendering == true )
effectInstance->init( m_width, m_height );
EffectsEngine::EffectHelper *ret = new EffectsEngine::EffectHelper( effectInstance, start, end );
QWriteLocker lock( m_effectsLock );
if ( effect->type() == Effect::Filter )
m_filters.push_back( ret );
else
m_mixers[start] = ret;
return ret;
}
//Must be called from a thread safe method (m_clipsLock locked)
void
TrackWorkflow::computeLength()
......@@ -278,6 +295,7 @@ TrackWorkflow::stop()
++it;
}
m_lastFrame = 0;
m_isRendering = false;
}
Workflow::OutputBuffer*
......@@ -539,6 +557,9 @@ TrackWorkflow::initRender( quint32 width, quint32 height, double fps )
m_mixerBuffer->resize( width, height );
m_fps = fps;
m_width = width;
m_height = height;
m_isRendering = true;
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
while ( it != end )
......@@ -549,7 +570,9 @@ TrackWorkflow::initRender( quint32 width, quint32 height, double fps )
preloadClip( cw );
++it;
}
QReadLocker lock2( m_effectsLock );
EffectsEngine::initMixers( m_mixers, width, height );
EffectsEngine::initFilters( m_filters, width, height );
}
bool
......
......@@ -59,7 +59,19 @@ class TrackWorkflow : public QObject
ClipWorkflow* removeClipWorkflow( const QUuid& id );
void addClip( ClipHelper*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
/**
* \brief Add an effect to a contained ClipWorkflow
*
* \param effect The effect to add.
* \param uuid The ClipHelper's uuid
*/
EffectsEngine::EffectHelper *addEffect( Effect *effect, const QUuid &uuid );
/**
* \brief Add an effect to the TrackWorkflow
*
* \param effect The effect instance. Can be either mixer or filter.
*/
EffectsEngine::EffectHelper *addEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
qint64 getClipPosition( const QUuid& uuid ) const;
ClipHelper *getClipHelper( const QUuid& uuid );
......@@ -107,7 +119,9 @@ class TrackWorkflow : public QObject
private:
QMap<qint64, ClipWorkflow*> m_clips;
QReadWriteLock *m_effectsLock;
EffectsEngine::MixerList m_mixers;
EffectsEngine::EffectList m_filters;
/**
* \brief The track length in frames.
......@@ -124,6 +138,9 @@ class TrackWorkflow : public QObject
Workflow::Frame *m_mixerBuffer;
double m_fps;
const quint32 m_trackId;
quint32 m_width;
quint32 m_height;
bool m_isRendering;
signals:
void lengthChanged( qint64 newLength );
......
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