Commit f7330fd4 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Added metadata for Clip (width / height / length)

Small refactoring to prepare UI / Backend separation.
parent 49f9a87a
......@@ -26,10 +26,21 @@
QPixmap* Clip::defaultSnapshot = NULL;
Clip::Clip( const QString& mrl )
: m_vlcMedia( NULL ), m_mrl( mrl ), m_snapshot( NULL )
: m_vlcMedia( NULL ), m_mrl( mrl ), m_snapshot( NULL ), m_begin( 0 ), m_end( -1 )
{
m_vlcMedia = new LibVLCpp::Media( mrl );
m_uuid = QUuid::createUuid();
//We avoid creating a fileInfo from the mrl since it can be "fake://" for invmem.
m_fileInfo = NULL;
}
Clip::Clip( const QFileInfo* fileInfo)
: m_vlcMedia( NULL ), m_snapshot( NULL ), m_begin( 0 ), m_end( -1 )
{
m_mrl = "file://" + fileInfo->absoluteFilePath();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
m_uuid = QUuid::createUuid();
m_fileInfo = new QFileInfo( *fileInfo );
}
Clip::~Clip()
......@@ -83,3 +94,39 @@ const QUuid& Clip::getUuid() const
{
return m_uuid;
}
const QFileInfo* Clip::getFileInfo() const
{
return m_fileInfo;
}
void Clip::setLength( qint64 length )
{
m_length = length;
}
qint64 Clip::getLength() const
{
return m_length;
}
int Clip::getWidth() const
{
return m_width;
}
void Clip::setWidth( int width )
{
m_width = width;
}
int Clip::getHeight() const
{
return m_height;
}
void Clip::setHeight( int height )
{
m_height = height;
}
......@@ -28,6 +28,7 @@
#include <QPixmap>
#include <QUuid>
#include <QObject>
#include <QFileInfo>
#include "VLCMedia.h"
......@@ -39,6 +40,7 @@ class Clip : public QObject
Q_OBJECT
public:
Clip( const QFileInfo* fileInfo );
Clip( const QString& mrl );
virtual ~Clip();
......@@ -50,6 +52,17 @@ public:
void setSnapshot( QPixmap* snapshot );
const QPixmap& getSnapshot() const;
const QFileInfo* getFileInfo() const;
qint64 getLength() const;
void setLength( qint64 length );
int getWidth() const;
void setWidth( int width );
int getHeight() const;
void setHeight( int height );
const QUuid& getUuid() const;
protected:
......@@ -59,6 +72,12 @@ protected:
QPixmap* m_snapshot;
QUuid m_uuid;
static QPixmap* defaultSnapshot;
QFileInfo* m_fileInfo;
qint64 m_length;
qint64 m_begin;
qint64 m_end;
unsigned int m_width;
unsigned int m_height;
signals:
void snapshotChanged();
......
......@@ -219,3 +219,17 @@ void MediaPlayer::setMedia( Media* media )
{
libvlc_media_player_set_media( m_internalPtr, media->getInternalPtr(), m_ex);
}
int MediaPlayer::getWidth()
{
int width = libvlc_video_get_width( m_internalPtr, m_ex );
m_ex.checkThrow();
return width;
}
int MediaPlayer::getHeight()
{
int height = libvlc_video_get_height( m_internalPtr, m_ex );
m_ex.checkThrow();
return height;
}
......@@ -54,6 +54,8 @@ namespace LibVLCpp
void setDrawable( void* hwnd );
void setDrawable( uint32_t drawable );
void setMedia(Media* media);
int getWidth();
int getHeight();
private:
static void callbacks( const libvlc_event_t* event, void* self );
......
......@@ -46,7 +46,6 @@ void MetaDataManager::run()
}
usleep( 10000 );
}
qDebug() << "Exiting thread";
return;
}
......@@ -54,7 +53,9 @@ void MetaDataManager::getMetaData()
{
disconnect( this, SLOT( getMetaData() ) );
m_nextMedia = true;
qDebug() << "Length:" << m_mediaPlayer->getLength();
m_currentClip->setLength( m_mediaPlayer->getLength() );
m_currentClip->setWidth( m_mediaPlayer->getWidth() );
m_currentClip->setHeight( m_mediaPlayer->getHeight() );
//Setting time for snapshot :
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
......
......@@ -102,11 +102,12 @@ ListViewMediaItem* LibraryWidget::insertNewMedia( QString fileNam
ListViewMediaItem* item = NULL;
foreach( item, *m_medias )
{
if ( item->fileInfo()->absoluteFilePath() == fileName )
if ( item->getClip()->getFileInfo()->absoluteFilePath() == fileName )
return item;
}
QFileInfo* fileInfo = new QFileInfo( fileName );
item = this->addMedia( fileInfo, fileType );
item = addMedia( fileInfo, fileType );
delete fileInfo;
return item;
}
......@@ -122,7 +123,7 @@ void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString fil
foreach ( fileName, fileNames )
item = insertNewMedia( fileName, filetype );
if ( item != NULL )
settings.setValue( "mediaLibraryDialogPath" , item->fileInfo()->absoluteDir().absolutePath() );
settings.setValue( "mediaLibraryDialogPath" , item->getClip()->getFileInfo()->absoluteDir().absolutePath() );
return ;
}
......
......@@ -25,9 +25,8 @@
#include <QDebug>
ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type ), m_fileInfo( NULL ), m_clip( NULL )
QListWidgetItem( parent, type ), m_clip( NULL )
{
m_fileInfo = fInfo;
m_fileType = fType;
setIcon( QIcon( ":/images/images/vlmc.png") );
......@@ -35,14 +34,12 @@ ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType
m_renderWidget = new QWidget();
m_clip = new Clip( "file://" + fInfo->absoluteFilePath() );
m_clip = new Clip( fInfo );
connect( m_clip, SIGNAL( snapshotChanged() ), this, SLOT( snapshotChanged() ) );
}
ListViewMediaItem::~ListViewMediaItem()
{
if ( m_fileInfo != NULL )
delete m_fileInfo;
if ( m_clip != NULL )
delete m_clip;
}
......
......@@ -64,12 +64,6 @@ public:
*/
virtual ~ListViewMediaItem();
/**
* \brief Getter for fileinfo
* \return fileInfo of the item
*/
QFileInfo* fileInfo() { return m_fileInfo; }
/**
* \brief Getter for filetype
* \return filetype of the item
......@@ -88,27 +82,20 @@ public:
//void setInputMedia( InputMedia* inputMedia ) { m_inputMedia = inputMedia; }
private:
/**
* \brief fileInfo member
*/
QFileInfo* m_fileInfo;
/**
* \brief fileType member
*/
ListViewMediaItem::fType m_fileType;
ListViewMediaItem::fType m_fileType;
/**
* \Instance of the InputMedia
*/
Clip* m_clip;
Clip* m_clip;
/**
* \brief Instance of the temporary QWidget use for the snapshot
*/
QWidget* m_renderWidget;
public slots:
QWidget* m_renderWidget;
private slots:
void snapshotChanged();
......
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