Commit 07b906af authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Media: Removing uuid property from medias.

Every uuid is now located in a clip. To select a media, use its base
clip's uuid.
parent 2c3f2c3b
......@@ -175,13 +175,14 @@ ImportController::clipSelection( const QUuid& uuid )
void
ImportController::updateMediaRequested( const Media *media )
{
if ( m_temporaryMedias.contains( media->uuid() ) == false )
if ( m_temporaryMedias.contains( media->baseClip()->uuid() ) == false )
return ;
MediaCellView* cell = m_mediaListController->cell( media->uuid() );
MediaCellView* cell = m_mediaListController->cell( media->baseClip()->uuid() );
if ( cell == NULL )
return;
cell->setThumbnail( media->snapshot() );
cell->setLength( media->lengthMS() );
cell->setEnabled( true );
}
void
......@@ -246,7 +247,7 @@ ImportController::importMedia( const QString &filePath )
this, SLOT( updateMediaRequested( const Media* ) ) );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( mediaLoaded() ) );
m_temporaryMedias[media->uuid()] = media;
m_temporaryMedias[media->baseClip()->uuid()] = media;
MetaDataManager::getInstance()->computeMediaMetadata( media );
m_mediaListController->addMedia( media );
}
......@@ -458,7 +459,7 @@ ImportController::failedToLoad( Media *media )
m_ui->errorLabelImg->show();
m_ui->errorLabel->show();
QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
mediaDeletion( media->uuid() );
mediaDeletion( media->baseClip()->uuid() );
}
void
......
......@@ -39,7 +39,7 @@ ImportMediaListController::~ImportMediaListController()
void
ImportMediaListController::addMedia( Media* media )
{
MediaCellView* cell = new MediaCellView( media->uuid() );
MediaCellView* cell = new MediaCellView( media->baseClip()->uuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( mediaSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
......@@ -53,7 +53,7 @@ ImportMediaListController::addMedia( Media* media )
cell->setThumbnail( media->snapshot() );
addCell( cell );
m_mediaCellList->insert( media->uuid(), cell );
m_mediaCellList->insert( media->baseClip()->uuid(), cell );
if ( media->baseClip() == NULL )
connect( media, SIGNAL( metaDataComputed( const Media* ) ),
cell, SLOT( enableCell() ) );
......@@ -62,7 +62,7 @@ ImportMediaListController::addMedia( Media* media )
void
ImportMediaListController::metaDataComputed( const Media* media )
{
m_mediaCellList->value( media->uuid() )->setThumbnail( media->snapshot() );
m_mediaCellList->value( media->baseClip()->uuid() )->setThumbnail( media->snapshot() );
}
MediaCellView*
......@@ -144,7 +144,7 @@ ImportMediaListController::clipAdded( Clip* clip )
{
if ( clip->getParent() == 0 )
return ;
const QUuid& uuid = clip->getParent()->uuid();
const QUuid& uuid = clip->getParent()->baseClip()->uuid();
if ( m_mediaCellList->contains( uuid ) )
m_mediaCellList->value( uuid )->incrementClipCount();
}
......
......@@ -127,8 +127,6 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
return;
QMimeData* mimeData = new QMimeData;
//FIXME the second argument is a media UUID instead of a Clip
// and this is not logical... but it works.
mimeData->setData( "vlmc/uuid", m_uuid.toString().toAscii() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
......
......@@ -40,7 +40,7 @@ MediaListViewController::~MediaListViewController()
void MediaListViewController::newMediaLoaded( Media* media )
{
MediaCellView* cell = new MediaCellView( media->uuid() );
MediaCellView* cell = new MediaCellView( media->baseClip()->uuid() );
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelection( QUuid ) ) );
......@@ -59,7 +59,7 @@ void MediaListViewController::newMediaLoaded( Media* media )
if ( media->baseClip() != NULL )
cell->setEnabled(true);
addCell(cell);
m_cells->insert( media->uuid(), cell );
m_cells->insert( media->baseClip()->uuid(), cell );
}
void MediaListViewController::cellSelection( const QUuid& uuid )
......@@ -92,7 +92,7 @@ void MediaListViewController::mediaRemoved( const QUuid& uuid )
void MediaListViewController::updateCell( const Media* media )
{
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( media->uuid(), NULL ) );
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( media->baseClip()->uuid(), NULL ) );
if ( cell != NULL )
{
cell->setNbClips( media->clipsCount() );
......@@ -121,7 +121,7 @@ void MediaListViewController::newClipAdded( Clip* clip )
{
if ( clip->getParent() == 0 )
return ;
const QUuid& uuid = clip->getParent()->uuid();
const QUuid& uuid = clip->getParent()->baseClip()->uuid();
if ( m_cells->contains( uuid ) )
{
......
......@@ -196,7 +196,7 @@ TracksView::deleteMedia( const QUuid &uuid )
// is the one we would like to remove.
foreach( item, items )
{
if ( item->clip()->getParent()->uuid() ==
if ( item->clip()->getParent()->baseClip()->uuid() ==
uuid )
{
// This item needs to be removed.
......@@ -323,7 +323,6 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
connect( m_dragVideoItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
}
// Group the items together
if ( audioClip != NULL && videoClip != NULL )
m_dragVideoItem->group( m_dragAudioItem );
......
......@@ -56,20 +56,14 @@ Library::media( const QUuid& uuid )
Clip*
Library::clip( const QUuid& uuid )
{
if ( m_medias.contains( uuid ) )
{
Media* media = m_medias.value( uuid );
if ( media->baseClip() == NULL )
return NULL;
return media->baseClip();
}
Media* m = media( uuid );
if ( m != NULL )
return m->baseClip();
QUuid mediaUuid;
foreach( mediaUuid, m_medias.keys() )
foreach( m, m_medias.values() )
{
Media* media = m_medias.value( mediaUuid );
if ( media != NULL && media->clips().contains( uuid ) )
return media->clip( uuid );
if ( m != NULL && m->clips().contains( uuid ) )
return m->clip( uuid );
}
return NULL;
}
......@@ -125,7 +119,7 @@ Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
void
Library::addMedia( Media *media )
{
m_medias[media->uuid()] = media;
m_medias[media->baseClip()->uuid()] = media;
emit newMediaLoaded( media );
}
......@@ -189,9 +183,9 @@ Library::loadProject( const QDomElement& medias )
if ( it.value()->fileInfo()->absoluteFilePath() == path )
{
media = it.value();
media->setUuid( QUuid( uuid ) );
media->baseClip()->setUuid( QUuid( uuid ) );
m_medias.erase( it );
m_medias[media->uuid()] = media;
m_medias[media->baseClip()->uuid()] = media;
break ;
}
}
......@@ -250,7 +244,7 @@ Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
text = doc.createTextNode( it.value()->fileInfo()->absoluteFilePath() );
QDomElement uuid = doc.createElement( "uuid" );
QDomCharacterData text2 = doc.createTextNode( it.value()->uuid().toString() );
QDomCharacterData text2 = doc.createTextNode( it.value()->baseClip()->uuid().toString() );
mrl.appendChild( text );
uuid.appendChild( text2 );
......@@ -267,7 +261,7 @@ Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
clip.setAttribute( "begin", c->begin() );
clip.setAttribute( "end", c->end() );
clip.setAttribute( "uuid", c->uuid() );
clip.setAttribute( "parentUuid", c->getParent()->uuid() );
clip.setAttribute( "parentUuid", c->getParent()->baseClip()->uuid() );
clips.appendChild( clip );
}
media.appendChild( clips );
......
......@@ -31,14 +31,17 @@
const int Clip::DefaultFPS = 30;
Clip::Clip( Media *parent ) :
Clip::Clip( Media *parent, const QString& uuid ) :
m_parent( parent ),
m_begin( 0 ),
m_end( parent->nbFrames() ),
m_maxBegin( 0 ),
m_maxEnd( parent->nbFrames() )
{
m_Uuid = QUuid::createUuid();
if ( uuid.isEmpty() == true )
m_Uuid = QUuid::createUuid();
else
m_Uuid = QUuid( uuid );
computeLength();
}
......@@ -210,6 +213,12 @@ Clip::uuid() const
return m_Uuid;
}
void
Clip::setUuid( const QUuid &uuid )
{
m_Uuid = uuid;
}
void
Clip::setBegin( qint64 begin, bool updateMax /*= false*/ )
{
......
......@@ -42,7 +42,7 @@ class Clip : public QObject
public:
static const int DefaultFPS;
Clip( Media *parent );
Clip( Media *parent, const QString& uuid = QString() );
Clip( Media *parent, qint64 begin, qint64 end = -1 );
Clip( Clip *creator, qint64 begin, qint64 end );
Clip( const Clip *clip );
......@@ -79,6 +79,7 @@ class Clip : public QObject
\return The Clip's Uuid as a QUuid
*/
const QUuid &uuid() const;
void setUuid( const QUuid &uuid );
const QStringList &metaTags() const;
void setMetaTags( const QStringList &tags );
......@@ -90,9 +91,9 @@ class Clip : public QObject
qint64 maxBegin() const;
qint64 maxEnd() const;
private:
void computeLength();
private:
Media *m_parent;
/**
* \brief This represents the beginning of the Clip in frames, from the
......
......@@ -52,11 +52,6 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_nbAudioTracks( 0 ),
m_nbVideoTracks( 0 )
{
if ( uuid.length() == 0 )
m_uuid = QUuid::createUuid();
else
m_uuid = QUuid( uuid );
if ( filePath.startsWith( Media::streamPrefix ) == false )
{
m_inputType = Media::File;
......@@ -79,6 +74,7 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_fileName = m_mrl;
qDebug() << "Loading a stream";
}
m_baseClip = new Clip( this, uuid );
m_audioValueList = new QList<int>();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
}
......@@ -143,11 +139,6 @@ const QPixmap& Media::snapshot() const
return *Media::defaultSnapshot;
}
const QUuid& Media::uuid() const
{
return m_uuid;
}
const QFileInfo* Media::fileInfo() const
{
return m_fileInfo;
......@@ -200,8 +191,9 @@ Media::FileType Media::fileType() const
void Media::emitMetaDataComputed()
{
Q_ASSERT( m_baseClip == NULL );
m_baseClip = new Clip( this );
m_baseClip->setBegin( 0 );
m_baseClip->setEnd( m_nbFrames );
m_baseClip->computeLength();
emit metaDataComputed( this );
}
......@@ -212,7 +204,7 @@ void Media::emitSnapshotComputed()
void Media::emitAudioSpectrumComuted()
{
emit audioSpectrumComputed( this->uuid() );
emit audioSpectrumComputed( baseClip()->uuid() );
}
Media::InputType Media::inputType() const
......@@ -220,11 +212,6 @@ Media::InputType Media::inputType() const
return m_inputType;
}
void Media::setUuid( const QUuid& uuid )
{
m_uuid = uuid;
}
void Media::setNbFrames( qint64 nbFrames )
{
m_nbFrames = nbFrames;
......
......@@ -113,9 +113,6 @@ public:
qint64 nbFrames() const;
const QUuid &uuid() const;
void setUuid( const QUuid& uuid );
bool hasAudioTrack() const;
bool hasVideoTrack() const;
void setNbAudioTrack( int nbTrack );
......@@ -149,6 +146,7 @@ public:
QList<int>* audioValues() { return m_audioValueList; }
Clip* baseClip() { return m_baseClip; }
const Clip* baseClip() const { return m_baseClip; }
private:
void setFileType();
......@@ -159,7 +157,6 @@ protected:
QString m_mrl;
QList<QString> m_volatileParameters;
QPixmap* m_snapshot;
QUuid m_uuid;
QFileInfo* m_fileInfo;
qint64 m_lengthMS;
qint64 m_nbFrames;
......
......@@ -189,7 +189,7 @@ ClipRenderer::getLengthMs() const
void
ClipRenderer::mediaUnloaded( const QUuid& uuid )
{
if ( m_selectedMedia != NULL && m_selectedMedia->uuid() == uuid )
if ( m_selectedMedia != NULL && m_selectedMedia->baseClip()->uuid() == uuid )
{
m_mediaPlayer->stop();
m_clipLoaded = false;
......
......@@ -400,7 +400,7 @@ void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
{
QDomElement parent = doc.createElement( "parent" );
QDomCharacterData text = doc.createTextNode( it.value()->getClip()->getParent()->uuid().toString() );
QDomCharacterData text = doc.createTextNode( it.value()->getClip()->getParent()->baseClip()->uuid().toString() );
parent.appendChild( text );
clipNode.appendChild( parent );
}
......
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