Commit fe483221 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Media: Lazy load base clip

Mostly because sharedFromThis cannot be called from a constructor
parent 5ff92ec9
......@@ -62,6 +62,8 @@ const QString Media::streamPrefix = "stream://";
Media::Media( medialibrary::MediaPtr media, const QUuid& uuid /* = QUuid() */ )
: m_input( nullptr )
, m_mlMedia( media )
, m_baseClipUuid( uuid )
, m_baseClip( nullptr )
{
auto files = media->files();
Q_ASSERT( files.size() > 0 );
......@@ -77,7 +79,6 @@ Media::Media( medialibrary::MediaPtr media, const QUuid& uuid /* = QUuid() */ )
if ( m_mlFile == nullptr )
vlmcFatal( "No file representing media %s", media->title().c_str(), "was found" );
m_input.reset( new Backend::MLT::MLTInput( m_mlFile->mrl().c_str() ) );
m_baseClip = new Clip( sharedFromThis(), 0, Backend::IInput::EndOfMedia, uuid );
}
QString
......@@ -113,6 +114,14 @@ Media::id() const
return m_mlMedia->id();
}
Clip*
Media::baseClip()
{
if ( m_baseClip == nullptr )
m_baseClip = new Clip( sharedFromThis(), 0, Backend::IInput::EndOfMedia, m_baseClipUuid );
return m_baseClip;
}
QSharedPointer<Clip>
Media::cut( qint64 begin, qint64 end )
{
......
......@@ -86,7 +86,8 @@ public:
QString title() const;
qint64 id() const;
Clip* baseClip() { return m_baseClip; }
Clip* baseClip();
/**
* @brief cut Creates a clip to represent a cut of a media
* @param begin The first frame of the cut
......@@ -112,7 +113,8 @@ protected:
std::unique_ptr<Backend::IInput> m_input;
medialibrary::MediaPtr m_mlMedia;
medialibrary::FilePtr m_mlFile;
Clip* m_baseClip;
QUuid m_baseClipUuid;
mutable Clip* m_baseClip;
QHash<QUuid, QSharedPointer<Clip>> m_clips;
signals:
......
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