Commit a7dac860 authored by luyikei's avatar luyikei Committed by Hugo Beauzée-Luyssen

Clip: Merge ClipHelper

Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 1fe602ee
......@@ -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* ) ),
......
......@@ -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 );
......@@ -99,12 +90,6 @@ Clip::media() const
return m_media;
}
qint64
Clip::nbFrames() const
{
return m_nbFrames;
}
qint64
Clip::lengthSecond() const
{
......@@ -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()
{
......
......@@ -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.
......@@ -64,27 +73,6 @@ class Clip : public QObject
Clip( Clip *creator, qint64 begin = -1, qint64 end = -1, const QString& uuid = QString() );
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.
*/
......@@ -137,18 +125,14 @@ 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
*/
......@@ -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__
......@@ -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 );
......
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