Commit 00ca41cc authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Clip has been renamed to Media

parent ff71dbf3
......@@ -23,52 +23,51 @@
/** \file
* This file the library contains class implementation.
* It's the the backend part of the Library widget of vlmc.
* It can load and unload Clips (Clip.h/Clip.cpp)
* It can load and unload Medias (Medias.h/Media.cpp)
*/
#include <QtDebug>
#include "Library.h"
#include "Clip.h"
Library::Library()
{
}
Clip* Library::getClip( const QUuid& uuid )
Media* Library::getClip( const QUuid& uuid )
{
QMutexLocker locker( &m_mutex );
QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
if ( it == m_clips.end() )
QHash<QUuid, Media*>::iterator it = m_medias.find( uuid );
if ( it == m_medias.end() )
return NULL;
return *it;
}
void Library::removingClipAsked( const QUuid& uuid )
void Library::removingMediaAsked( const QUuid& uuid )
{
QMutexLocker locker( &m_mutex );
QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
if ( it == m_clips.end() )
QHash<QUuid, Media*>::iterator it = m_medias.find( uuid );
if ( it == m_medias.end() )
return ;
emit clipRemoved( uuid );
emit mediaRemoved( uuid );
//TODO: this is obviously a memleak, but at the moment, the library depends on the clip to work,
//and won't be abble to remove the ListViewMediaItem without it.
//delete *it;
m_clips.erase( it );
m_medias.erase( it );
}
void Library::newClipLoadingAsked( const QString& filePath )
void Library::newMediaLoadingAsked( const QString& filePath )
{
QMutexLocker locker( &m_mutex );
Clip* clip;
foreach ( clip, m_clips )
Media* media;
foreach ( media, m_medias )
{
if ( clip->getFileInfo()->absoluteFilePath() == filePath )
if ( media->getFileInfo()->absoluteFilePath() == filePath )
return ;
}
//TODO: maybe we should think about taking a reference to a QFileInfo on Clip::Clip() to avoid multiple new...
QFileInfo* fInfo = new QFileInfo( filePath );
clip = new Clip( fInfo );
m_clips[clip->getUuid()] = clip;
emit newClipLoaded( clip );
media = new Media( fInfo );
m_medias[media->getUuid()] = media;
emit newMediaLoaded( media );
delete fInfo;
}
......@@ -36,7 +36,7 @@
#include <QMutex>
#include <QMutexLocker>
#include "Clip.h"
#include "Media.h"
#include "Singleton.hpp"
class Library : public QObject, public Singleton<Library>
......@@ -54,22 +54,22 @@ public:
Video,
Image
};
Clip* getClip( const QUuid& uuid );
Media* getClip( const QUuid& uuid );
private:
Library();
QHash<QUuid, Clip*> m_clips;
QHash<QUuid, Media*> m_medias;
QMutex m_mutex;
public slots:
void newClipLoadingAsked( const QString& filePath );
void removingClipAsked( const QUuid& uuid );
void newMediaLoadingAsked( const QString& filePath );
void removingMediaAsked( const QUuid& uuid );
signals:
void newClipLoaded( Clip* );
void clipRemoved( const QUuid& );
void newMediaLoaded( Media* );
void mediaRemoved( const QUuid& );
friend class Singleton<Library>;
friend class Singleton<Library>;
};
#endif // LIBRARY_H
/*****************``************************************************************
* Clip.cpp: Represents a basic container for media informations.
* Media.cpp: Represents a basic container for media informations.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
......@@ -21,19 +21,19 @@
*****************************************************************************/
/** \file
* This file contains the Clip class implementation.
* This file contains the Media class implementation.
* It contains a VLCMedia and the meta-datas.
* It's used by the Library
*/
#include <QtDebug>
#include "Clip.h"
#include "Media.h"
QPixmap* Clip::defaultSnapshot = NULL;
QPixmap* Media::defaultSnapshot = NULL;
Clip::Clip( const QString& mrl )
Media::Media( const QString& mrl )
: m_vlcMedia( NULL ), m_mrl( mrl ), m_snapshot( NULL ), m_length( 0 ),
m_begin( 0 ), m_end( -1 ), m_width( 0 ), m_height( 0 )
m_width( 0 ), m_height( 0 )
{
m_vlcMedia = new LibVLCpp::Media( mrl );
m_uuid = QUuid::createUuid();
......@@ -41,9 +41,9 @@ Clip::Clip( const QString& mrl )
m_fileInfo = NULL;
}
Clip::Clip( const QFileInfo* fileInfo)
Media::Media( const QFileInfo* fileInfo)
: m_vlcMedia( NULL ), m_snapshot( NULL ), m_length( 0 ),
m_begin( 0 ), m_end( -1 ), m_width( 0 ), m_height( 0 )
m_width( 0 ), m_height( 0 )
{
m_mrl = "file://" + fileInfo->absoluteFilePath();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
......@@ -51,7 +51,7 @@ Clip::Clip( const QFileInfo* fileInfo)
m_fileInfo = new QFileInfo( *fileInfo );
}
Clip::~Clip()
Media::~Media()
{
if ( m_vlcMedia )
{
......@@ -59,7 +59,7 @@ Clip::~Clip()
}
}
void Clip::loadMedia( const QString& mrl )
void Media::loadMedia( const QString& mrl )
{
if ( m_vlcMedia )
delete m_vlcMedia;
......@@ -68,7 +68,7 @@ void Clip::loadMedia( const QString& mrl )
m_vlcMedia = new LibVLCpp::Media( mrl );
}
void Clip::flushParameters()
void Media::flushParameters()
{
//Flushing the args into the media :
QString param;
......@@ -77,12 +77,12 @@ void Clip::flushParameters()
m_parameters.clear();
}
void Clip::addParam( const QString& param )
void Media::addParam( const QString& param )
{
m_parameters.append( param );
}
void Clip::setSnapshot( QPixmap* snapshot )
void Media::setSnapshot( QPixmap* snapshot )
{
if ( m_snapshot != NULL )
delete m_snapshot;
......@@ -90,51 +90,51 @@ void Clip::setSnapshot( QPixmap* snapshot )
emit snapshotChanged();
}
const QPixmap& Clip::getSnapshot() const
const QPixmap& Media::getSnapshot() const
{
if ( m_snapshot != NULL )
return *m_snapshot;
if ( Clip::defaultSnapshot == NULL )
Clip::defaultSnapshot = new QPixmap( ":/images/images/vlmc.png" );
return *Clip::defaultSnapshot;
if ( Media::defaultSnapshot == NULL )
Media::defaultSnapshot = new QPixmap( ":/images/images/vlmc.png" );
return *Media::defaultSnapshot;
}
const QUuid& Clip::getUuid() const
const QUuid& Media::getUuid() const
{
return m_uuid;
}
const QFileInfo* Clip::getFileInfo() const
const QFileInfo* Media::getFileInfo() const
{
return m_fileInfo;
}
void Clip::setLength( qint64 length )
void Media::setLength( qint64 length )
{
m_length = length;
}
qint64 Clip::getLength() const
qint64 Media::getLength() const
{
return m_length;
}
int Clip::getWidth() const
int Media::getWidth() const
{
return m_width;
}
void Clip::setWidth( int width )
void Media::setWidth( int width )
{
m_width = width;
}
int Clip::getHeight() const
int Media::getHeight() const
{
return m_height;
}
void Clip::setHeight( int height )
void Media::setHeight( int height )
{
m_height = height;
}
......
/*****************************************************************************
* Clip.h : Represents a basic container for media informations.
* Media.h : Represents a basic container for media informations.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
......@@ -21,13 +21,13 @@
*****************************************************************************/
/** \file
* This file contains the Clip class declaration/definition.
* This file contains the Media class declaration/definition.
* It contains a VLCMedia and the meta-datas.
* It's used by the Library
*/
#ifndef CLIP_H__
#define CLIP_H__
#ifndef MEDIA_H__
#define MEDIA_H__
#include <QList>
#include <QString>
......@@ -41,47 +41,46 @@
/**
* Represents a basic container for media informations.
*/
class Clip : public QObject
class Media : public QObject
{
Q_OBJECT
public:
Clip( const QFileInfo* fileInfo );
Clip( const QString& mrl );
virtual ~Clip();
Media( const QFileInfo* fileInfo );
Media( const QString& mrl );
virtual ~Media();
void loadMedia( const QString& mrl );
void addParam( const QString& param );
void flushParameters();
LibVLCpp::Media* getVLCMedia() { return m_vlcMedia; }
void loadMedia( const QString& mrl );
void addParam( const QString& param );
void flushParameters();
LibVLCpp::Media* getVLCMedia() { return m_vlcMedia; }
void setSnapshot( QPixmap* snapshot );
const QPixmap& getSnapshot() const;
void setSnapshot( QPixmap* snapshot );
const QPixmap& getSnapshot() const;
const QFileInfo* getFileInfo() const;
const QFileInfo* getFileInfo() const;
qint64 getLength() const;
void setLength( qint64 length );
qint64 getLength() const;
void setLength( qint64 length );
int getWidth() const;
void setWidth( int width );
int getWidth() const;
void setWidth( int width );
int getHeight() const;
void setHeight( int height );
int getHeight() const;
void setHeight( int height );
const QUuid& getUuid() const;
const QUuid& getUuid() const;
protected:
static QPixmap* defaultSnapshot;
LibVLCpp::Media* m_vlcMedia;
QString m_mrl;
QList<QString> m_parameters;
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;
......@@ -89,4 +88,4 @@ signals:
void snapshotChanged();
};
#endif // MEDIA_H
#endif // CLIP_H__
......@@ -27,7 +27,7 @@ MetaDataManager::~MetaDataManager()
delete[] m_tmpSnapshotFilename;
}
void MetaDataManager::newClipLoaded( Clip* item )
void MetaDataManager::newMediaLoaded( Media* item )
{
m_mediaList.append( item );
......
......@@ -11,7 +11,7 @@
#include <QTemporaryFile>
#include <QThread>
#include <QWidget>
#include "Clip.h"
#include "Media.h"
#include "VLCMediaPlayer.h"
class MetaDataManager : public QThread
......@@ -39,18 +39,18 @@ class MetaDataManager : public QThread
QWidget* m_renderWidget;
// TODO: THREAD SAFING
QList<Clip*> m_mediaList;
QList<Media*> m_mediaList;
// Thread component
bool m_nextMedia;
Clip* m_currentClip;
Media* m_currentClip;
//FIXME: Won't work in asynchrone mode
char* m_tmpSnapshotFilename;
private slots:
void renderSnapshot();
void getMetaData();
void newClipLoaded( Clip* );
void newMediaLoaded( Media* );
void setSnapshot();
void startAudioDataParsing();
};
......
......@@ -23,7 +23,7 @@
#include "GraphicsMovieItem.h"
#include "TracksView.h"
GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip ), m_width( 0 ), m_height( 0 )
GraphicsMovieItem::GraphicsMovieItem( Media* media ) : m_media ( media ), m_width( 0 ), m_height( 0 )
{
}
......
......@@ -24,19 +24,19 @@
#define GRAPHICSMOVIEITEM_H
#include "AbstractGraphicsMediaItem.h"
#include "Clip.h"
#include "Media.h"
#include "TracksView.h"
class GraphicsMovieItem : public AbstractGraphicsMediaItem
{
Q_OBJECT
public:
GraphicsMovieItem( Clip* clip );
GraphicsMovieItem( Media* media );
virtual ~GraphicsMovieItem();
virtual bool expandable() const { return false; }
virtual bool moveable() const { return true; }
virtual const QUuid& uuid() const { return m_clip->getUuid(); }
virtual const QUuid& uuid() const { return m_media->getUuid(); }
virtual QRectF boundingRect() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
......@@ -44,9 +44,9 @@ public:
void setHeight( int height );
private:
Clip* m_clip;
int m_width;
int m_height;
Media* m_media;
int m_width;
int m_height;
};
#endif // GRAPHICSMOVIEITEM_H
......@@ -51,9 +51,9 @@ LibraryWidget::~LibraryWidget()
}
}
ListViewMediaItem* LibraryWidget::addMedia( const Clip* clip, Library::FileType fileType )
ListViewMediaItem* LibraryWidget::addMedia( const Media* media, Library::FileType fileType )
{
ListViewMediaItem* item = new ListViewMediaItem( clip, fileType );
ListViewMediaItem* item = new ListViewMediaItem( media, fileType );
//TODO: replace this :
//emit listViewMediaAdded( item->getClip() );
m_medias->append( item );
......@@ -82,7 +82,7 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
ListViewMediaItem* item;
foreach (item, *m_medias)
{
if ( item->getClip()->getUuid() == uuid )
if ( item->getMedia()->getUuid() == uuid )
{
switch( item->getFileType() )
{
......@@ -116,10 +116,10 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
// return item;
//}
void LibraryWidget::newClipLoaded( Clip* clip )
void LibraryWidget::newMediaLoaded( Media* media )
{
//From here, the clip is const.
addMedia( clip, Library::Video );
addMedia( media, Library::Video );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType )
......@@ -171,7 +171,7 @@ void LibraryWidget::on_pushButtonRemoveMedia_clicked()
ListViewMediaItem* item = ( ListViewMediaItem* ) mediaList->currentItem();
if ( !item ) return;
// removeMedia( item );
emit removingClipAsked( item->getClip()->getUuid() );
emit removingClipAsked( item->getMedia()->getUuid() );
}
void LibraryWidget::changeEvent( QEvent *e )
......
......@@ -34,7 +34,9 @@
#include <QDrag>
#include <QList>
#include <QSettings>
#include "Library.h"
#include "Media.h"
#include "ListViewMediaItem.h"
#include "ui_LibraryWidget.h"
......@@ -46,7 +48,7 @@ public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addMedia( const Clip* clip, Library::FileType fileType );
ListViewMediaItem* addMedia( const Media* clip, Library::FileType fileType );
void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media );
......@@ -62,7 +64,7 @@ private:
public slots:
void newClipLoaded( Clip* );
void newMediaLoaded( Media* );
void clipRemoved( const QUuid& );
private slots:
......
......@@ -25,15 +25,15 @@
#include <QDebug>
#include <QTime>
ListViewMediaItem::ListViewMediaItem( const Clip* clip, Library::FileType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type ), m_clip( clip )
ListViewMediaItem::ListViewMediaItem( const Media* media, Library::FileType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type ), m_media ( media )
{
m_fileType = fType;
setIcon( QIcon( ":/images/images/vlmc.png") );
setText( clip->getFileInfo()->baseName() );
setText( media->getFileInfo()->baseName() );
connect( m_clip, SIGNAL( snapshotChanged() ), this, SLOT( snapshotChanged() ) );
connect( media, SIGNAL( snapshotChanged() ), this, SLOT( snapshotChanged() ) );
}
ListViewMediaItem::~ListViewMediaItem()
......@@ -43,22 +43,22 @@ ListViewMediaItem::~ListViewMediaItem()
void ListViewMediaItem::snapshotChanged()
{
setIcon( QIcon( m_clip->getSnapshot() ) );
setIcon( QIcon( m_media->getSnapshot() ) );
//this is a nasty patch for the moment :
//TODO: fix this !!!!
QTime length;
length = length.addSecs( m_clip->getLength() / 1000 );
length = length.addSecs( m_media->getLength() / 1000 );
qDebug() << m_clip->getLength();
qDebug() << m_media->getLength();
qDebug() << length;
setToolTip( "Filename: " + m_clip->getFileInfo()->fileName() + "\n" +
setToolTip( "Filename: " + m_media->getFileInfo()->fileName() + "\n" +
"Length: " + length.toString() );
//"Length: " + length.toString("h 'h' m 'm' s 's'") );
}
const Clip* ListViewMediaItem::getClip() const
const Media* ListViewMediaItem::getMedia() const
{
return m_clip;
return m_media;
}
......
......@@ -26,7 +26,7 @@
#include <QObject>
#include <QFileInfo>
#include <QListWidgetItem>
#include "Clip.h"
#include "Media.h"
#include "Library.h"
/**
......@@ -47,7 +47,7 @@ public:
* \param parent parent widget
* \param type
*/
ListViewMediaItem( const Clip* clip, Library::FileType fType, QListWidget* parent = 0, int type = Type );
ListViewMediaItem( const Media* media, Library::FileType fType, QListWidget* parent = 0, int type = Type );
/**
* \brief Destructor
......@@ -58,9 +58,9 @@ public:
* \brief Getter for filetype
* \return filetype of the item
*/
Library::FileType getFileType() const { return m_fileType; }
Library::FileType getFileType() const { return m_fileType; }
const Clip* getClip() const;
const Media* getMedia() const;
//void setInputMedia( InputMedia* inputMedia ) { m_inputMedia = inputMedia; }
......@@ -73,7 +73,7 @@ private:
/**
* \Instance of the InputMedia
*/
const Clip* m_clip;
const Media* m_media;
private slots:
void snapshotChanged();
......
......@@ -68,10 +68,10 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", item->getClip()->getUuid().toString().toAscii() );
mimeData->setData( "vlmc/uuid", item->getMedia()->getUuid().toString().toAscii() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
const QPixmap& dragPixmap = static_cast<ListViewMediaItem*>( currentItem() )->getClip()->getSnapshot();
const QPixmap& dragPixmap = static_cast<ListViewMediaItem*>( currentItem() )->getMedia()->getSnapshot();
drag->setPixmap( dragPixmap.scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
......
......@@ -77,10 +77,10 @@ void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
void PreviewWidget::dropEvent( QDropEvent* event )
{
Clip* clip = Library::getInstance()->getClip( QUuid( (const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
Media* media = Library::getInstance()->getClip( QUuid( (const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
clip->flushParameters();
m_mediaPlayer->setMedia( clip->getVLCMedia() );
media->flushParameters();
m_mediaPlayer->setMedia( media->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
......
......@@ -26,7 +26,7 @@
#include <QtDebug>
#include <cmath>
#include "TracksView.h"
#include "Clip.h"
#include "Media.h"
#include "Library.h"
#include "GraphicsMovieItem.h"
......@@ -62,10 +62,11 @@ void TracksView::dragEnterEvent( QDragEnterEvent* event )
void TracksView::dropEvent( QDropEvent* event )
{
QUuid uuid = QUuid( (const QString& )event->mimeData()->data( "vlmc/uuid" ) );
Clip* clip = Library::getInstance()->getClip( uuid );
if ( !clip ) return;
Media* media = Library::getInstance()->getClip( uuid );
if ( !media )
return;
addClip( clip, event->pos() );
addClip( media, event->pos() );
event->acceptProposedAction();
}
......@@ -160,7 +161,7 @@ void TracksView::setCursorPos(int pos)
m_cursorLine->setPos(m_cursorPos, 0);
}
void TracksView::addClip( Clip* clip, const QPoint& point )
void TracksView::addClip( Media* clip, const QPoint& point )
{
int track = (int)( mapToScene( point ).y() / m_tracksHeight );
if ( track + 1 > m_tracksCount ) return;
......
......@@ -30,7 +30,7 @@
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
#include "Clip.h"
#include "Media.h"
class TracksView : public QGraphicsView
{
......@@ -43,7 +43,7 @@ public:
int tracksHeight() const { return m_tracksHeight; }
int tracksCount() const { return m_tracksCount; }
void setCursorPos( int pos );
void addClip( Clip* clip, const QPoint& point );
void addClip( Media* clip, const QPoint& point );
void setScale( double scaleFactor );
protected:
......
......@@ -34,7 +34,8 @@ SOURCES += src/main.cpp \
src/LibVLCpp/VLCMediaList.cpp \
src/Library.cpp \
src/gui/GraphicsMovieItem.cpp \
src/gui/AbstractGraphicsMediaItem.cpp
src/gui/AbstractGraphicsMediaItem.cpp \
src/Media.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -61,7 +62,8 @@ HEADERS += src/gui/MainWindow.h \
src/Singleton.hpp \
src/Library.h \
src/gui/AbstractGraphicsMediaItem.h \
src/gui/GraphicsMovieItem.h
src/gui/GraphicsMovieItem.h \
src/Media.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......
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