[vlmc-devel] Clip: Merge ClipHelper

Yikai Lu git at videolan.org
Wed Jun 1 18:15:06 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun May  8 20:51:52 2016 +0900| [a7dac86061ac7f1e9df78fa951f9da955af2d2d1] | committer: Hugo Beauzée-Luyssen

Clip: Merge ClipHelper

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/a7dac86061ac7f1e9df78fa951f9da955af2d2d1
---

 src/Gui/timeline/AbstractGraphicsMediaItem.cpp |  2 +-
 src/Media/Clip.cpp                             | 49 +++++++++++--------
 src/Media/Clip.h                               | 65 +++++++++++---------------
 src/Renderer/ClipRenderer.cpp                  |  4 +-
 4 files changed, 59 insertions(+), 61 deletions(-)

diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 270757c..0999e5d 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -42,7 +42,7 @@ AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( Clip* clip ) :
 {
     m_clipHelper = new ClipHelper( clip );
     // Adjust the width
-    setWidth( clip->nbFrames() );
+    setWidth( clip->length() );
     // Automatically adjust future changes
     connect( m_clipHelper, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
     connect( clip, SIGNAL( unloaded( Clip* ) ),
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index b634442..13183f3 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -35,18 +35,14 @@
 const int   Clip::DefaultFPS = 30;
 
 Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= -1*/, const QString& uuid /*= QString()*/ ) :
+        Workflow::Helper( begin, end, uuid ),
         m_media( media ),
-        m_begin( begin ),
-        m_end( end ),
-        m_parent( media->baseClip() )
+        m_parent( media->baseClip() ),
+        m_clipWorkflow( nullptr )
 {
     int64_t nbSourceFrames = media->source()->nbFrames();
     if ( end == -1 )
         m_end = nbSourceFrames;
-    if ( uuid.isEmpty() == true )
-        m_uuid = QUuid::createUuid();
-    else
-        m_uuid = QUuid( uuid );
     m_beginPosition = (float)begin / (float)nbSourceFrames;
     m_endPosition = (float)end / (float)nbSourceFrames;
     m_childs = new MediaContainer( this );
@@ -58,9 +54,8 @@ Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= -1*/, const QStri
 
 Clip::Clip( Clip *parent, qint64 begin /*= -1*/, qint64 end /*= -1*/,
             const QString &uuid /*= QString()*/ ) :
+        Workflow::Helper( begin, end, uuid ),
         m_media( parent->media() ),
-        m_begin( begin ),
-        m_end( end ),
         m_rootClip( parent->rootClip() ),
         m_parent( parent )
 {
@@ -69,10 +64,6 @@ Clip::Clip( Clip *parent, qint64 begin /*= -1*/, qint64 end /*= -1*/,
         m_begin = parent->m_begin;
     if ( end < 0 )
         m_end = parent->m_end;
-    if ( uuid.isEmpty() == true )
-        m_uuid = QUuid::createUuid();
-    else
-        m_uuid = QUuid( uuid );
     m_beginPosition = (float)begin / (float)nbSourceFrames;
     m_endPosition = (float)end / (float)nbSourceFrames;
     m_childs = new MediaContainer( this );
@@ -100,12 +91,6 @@ Clip::media() const
 }
 
 qint64
-Clip::nbFrames() const
-{
-    return m_nbFrames;
-}
-
-qint64
 Clip::lengthSecond() const
 {
     return m_lengthSeconds;
@@ -270,6 +255,32 @@ Clip::toVariantFull() const
     return h;
 }
 
+Clip::Formats
+Clip::formats() const
+{
+    return m_formats;
+}
+
+void
+Clip::setFormats( Formats formats )
+{
+    if ( formats.testFlag( Clip::None ) )
+        m_formats = Clip::None;
+    m_formats = formats;
+}
+
+ClipWorkflow*
+Clip::clipWorkflow() const
+{
+    return m_clipWorkflow;
+}
+
+void
+Clip::setClipWorkflow( ClipWorkflow *cw )
+{
+    m_clipWorkflow = cw;
+}
+
 void
 Clip::mediaMetadataUpdated()
 {
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index 8b49b9a..eb0038f 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -28,19 +28,28 @@
 #ifndef CLIP_H__
 # define CLIP_H__
 
-#include <QObject>
+#include "Workflow/Helper.h"
 #include <QStringList>
 #include <QUuid>
 #include <QXmlStreamWriter>
 
 class   MediaContainer;
 class   Media;
+class   ClipWorkflow;
 
-class   Clip : public QObject
+class   Clip : public Workflow::Helper
 {
     Q_OBJECT
 
     public:
+        enum    Format
+        {
+            None          = 0,
+            Audio         = 1 << 0,
+            Video         = 1 << 1,
+        };
+        Q_DECLARE_FLAGS( Formats, Format )
+
         static const int DefaultFPS;
         /**
          *  \brief  Constructs a Clip that is a subpart of a Media.
@@ -65,27 +74,6 @@ class   Clip : public QObject
         virtual ~Clip();
 
         /**
-         *  \return         The clip beginning, in frame, starting at 0
-         */
-        qint64              begin() const
-        {
-            return m_begin;
-        }
-
-        /**
-         *  \return         The clip end, in frame, starting at 0.
-         */
-        qint64              end() const
-        {
-            return m_end;
-        }
-
-        /**
-            \return         Returns the clip length in frame.
-        */
-        qint64              nbFrames() const;
-
-        /**
             \return         Returns the clip length in seconds.
         */
         qint64              lengthSecond() const;
@@ -137,19 +125,15 @@ class   Clip : public QObject
         QVariant            toVariant() const;
         QVariant            toVariantFull() const;
 
+        Formats             formats() const;
+        void                setFormats( Formats formats );
+
+        ClipWorkflow*       clipWorkflow() const;
+        void                setClipWorkflow( ClipWorkflow* cw );
+
     private:
         Media               *m_media;
         /**
-         *  \brief  This represents the beginning of the Clip in frames, from the
-         *          beginning of the parent Media.
-         */
-        qint64              m_begin;
-        /**
-         *  \brief  This represents the end of the Clip in frames, from the
-         *          beginning of the parent Media.
-         */
-        qint64              m_end;
-        /**
          *  \brief  This represents the beginning of the Clip in form of [0; 1] float
          */
         float              m_beginPosition;
@@ -160,18 +144,15 @@ class   Clip : public QObject
 
         /**
          *  \brief  The length in frames
+         *     
          */
         qint64              m_nbFrames;
+
         /**
          *  \brief  The length in seconds (Be carreful, VLC uses MILLIseconds)
          */
         qint64              m_lengthSeconds;
-        /**
-         *  The Clip's timeline UUID. Used to identify the Clip in the
-         *  timeline, as a unique object, even if this clip is present more than
-         *  once.
-         */
-        QUuid               m_uuid;
+
         QStringList         m_metaTags;
         QString             m_notes;
 
@@ -186,6 +167,10 @@ class   Clip : public QObject
 
         Clip*               m_parent;
 
+        Formats             m_formats;
+
+        ClipWorkflow*       m_clipWorkflow;
+
     private slots:
         void                mediaMetadataUpdated();
 
@@ -198,4 +183,6 @@ class   Clip : public QObject
         friend class    ClipHelper;
 };
 
+Q_DECLARE_OPERATORS_FOR_FLAGS( Clip::Formats )
+
 #endif //CLIP_H__
diff --git a/src/Renderer/ClipRenderer.cpp b/src/Renderer/ClipRenderer.cpp
index c8f74b4..f70bfcc 100644
--- a/src/Renderer/ClipRenderer.cpp
+++ b/src/Renderer/ClipRenderer.cpp
@@ -64,7 +64,7 @@ ClipRenderer::setClip( Clip* clip )
         return ;
     }
     m_selectedClip = clip;
-    if ( clip->nbFrames() == 0 )
+    if ( clip->length() == 0 )
         return ;
     updateInfos( clip );
 }
@@ -83,7 +83,7 @@ ClipRenderer::updateInfos( Clip* clip )
 void
 ClipRenderer::startPreview()
 {
-    if ( m_selectedClip == nullptr || m_selectedClip->nbFrames() == 0 )
+    if ( m_selectedClip == nullptr || m_selectedClip->length() == 0 )
         return ;
     updateInfos( m_selectedClip );
 



More information about the Vlmc-devel mailing list