[vlmc-devel] commit: TrackWorkflow: Adding a setter for trackworkflow effects. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Aug 29 21:38:11 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Aug 29 20:24:53 2010 +0200| [fd27bbd563dddb25a0e7c90059af8c0029d23b24] | committer: Hugo Beauzée-Luyssen 

TrackWorkflow: Adding a setter for trackworkflow effects.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=fd27bbd563dddb25a0e7c90059af8c0029d23b24
---

 src/Workflow/TrackWorkflow.cpp |   23 +++++++++++++++++++++++
 src/Workflow/TrackWorkflow.h   |   17 +++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 521f4aa..6a9b407 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -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
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 3554ba4..d483bbf 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -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 );



More information about the Vlmc-devel mailing list