Commit e104b30f authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Adding some stuff to avoid multiple metadata parsing.

This would be used once imported media are stored as Media*
parent aa4b65b0
......@@ -82,6 +82,12 @@ void Library::newMediaLoadingAsked( const QString& filePath, const QStrin
emit newMediaLoaded( media );
}
void Library::addMedia( Media* media )
{
m_medias[media->getUuid()] = media;
metaDataComputed( media );
}
bool Library::mediaAlreadyLoaded( const QString& filePath )
{
Media* media;
......
......@@ -49,6 +49,12 @@ public:
Media* getMedia( const QUuid& uuid );
Clip* getClip( const QUuid& uudi );
/**
* \brief Add Media with already computed metadatas
* \param media The media to add.
*/
void addMedia( Media* media );
private:
Library();
bool mediaAlreadyLoaded( const QString& filePath );
......
......@@ -41,7 +41,8 @@ Media::Media( const QString& filePath, const QString& uuid )
m_fileInfo( NULL ),
m_length( 0 ),
m_width( 0 ),
m_height( 0 )
m_height( 0 ),
m_metadataParsed( false )
{
if ( uuid.length() == 0 )
m_uuid = QUuid::createUuid();
......@@ -216,7 +217,7 @@ void Media::addAudioFrame( void* datas, unsigned char* buffer, si
void Media::emitMetaDataComputed()
{
emit metaDataComputed();
m_metadataParsed = true;
emit metaDataComputed( this );
}
......@@ -229,3 +230,8 @@ void Media::setUuid( const QUuid& uuid )
{
m_uuid = uuid;
}
bool Media::hasMetadata() const
{
return m_metadataParsed;
}
......@@ -134,6 +134,8 @@ public:
void emitMetaDataComputed();
bool hasMetadata() const;
private:
void setFileType();
......@@ -154,9 +156,9 @@ protected:
audioData m_audioData;
FileType m_fileType;
InputType m_inputType;
bool m_metadataParsed;
signals:
void metaDataComputed();
void metaDataComputed( Media* );
};
......
......@@ -36,6 +36,9 @@ MetaDataManager::~MetaDataManager()
void MetaDataManager::newMediaLoaded( Media* media )
{
MetaDataWorker* w = new MetaDataWorker( media );
w->start();
if ( media->hasMetadata() == false )
{
MetaDataWorker* w = new MetaDataWorker( media );
w->start();
}
}
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