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

Adding a GUIMedia to handle GUi related stuff for medias.

parent 47492d18
/*****************************************************************************
* GUIMedia.cpp: Represents the GUI part of a Media
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "GuiMedia.h"
QPixmap* GUIMedia::defaultSnapshot = NULL;
GUIMedia::GUIMedia() :
m_snapshot( NULL )
{
}
GUIMedia::~GUIMedia()
{
if ( m_snapshot )
delete m_snapshot;
}
void
GUIMedia::setSnapshot( QPixmap* snapshot )
{
if ( m_snapshot != NULL )
delete m_snapshot;
m_snapshot = snapshot;
}
const QPixmap&
GUIMedia::snapshot() const
{
if ( m_snapshot != NULL )
return *m_snapshot;
if ( Media::defaultSnapshot == NULL )
Media::defaultSnapshot = new QPixmap( ":/images/images/vlmc.png" );
return *Media::defaultSnapshot;
}
void
GUIMedia::emitSnapshotComputed()
{
emit snapshotComputed( this );
}
/*****************************************************************************
* GUIMedia.h: Represents the GUI part of a Media
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef GUIMEDIA_H
#define GUIMEDIA_H
#include <QObject>
#include <QPixmap>
class QPixmap;
class GUIMedia : public QObject
{
Q_OBJECT
public:
~GUIMedia();
void setSnapshot( QPixmap* snapshot );
const QPixmap &snapshot() const;
void emitSnapshotComputed();
protected:
//A GUIMedia shouldn't be constructed by something else than a media
GUIMedia();
static QPixmap* defaultSnapshot;
QPixmap* m_snapshot;
signals:
void snapshotComputed( const GUIMedia* );
};
#endif // GUIMEDIA_H
......@@ -24,7 +24,7 @@
#define VLCINSTANCE_H
#include "VLCpp.hpp"
#include "QSingleton.hpp"
#include "Singleton.hpp"
#include <QObject>
......@@ -37,7 +37,7 @@ namespace LibVLCpp
*/
class Instance : public QObject,
public Internal< libvlc_instance_t >,
public QSingleton<Instance>
public Singleton<Instance>
{
Q_OBJECT
private:
......@@ -47,7 +47,7 @@ namespace LibVLCpp
~Instance();
private:
friend class QSingleton<Instance>;
friend class Singleton<Instance>;
};
}
......
......@@ -35,7 +35,6 @@
#include <QtDebug>
#include <QUrl>
QPixmap* Media::defaultSnapshot = NULL;
const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4 *.ogg *.ogv";
const QString Media::ImageExtensions = "*.gif *.png *.jpg *.jpeg";
const QString Media::AudioExtensions = "*.mp3 *.oga *.flac *.aac *.wav";
......@@ -43,7 +42,6 @@ const QString Media::streamPrefix = "stream://";
Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
: m_vlcMedia( NULL ),
m_snapshot( NULL ),
m_fileInfo( NULL ),
m_lengthMS( 0 ),
m_nbFrames( 0 ),
......@@ -85,8 +83,6 @@ Media::~Media()
{
if ( m_vlcMedia )
delete m_vlcMedia;
if ( m_snapshot )
delete m_snapshot;
if ( m_fileInfo )
delete m_fileInfo;
}
......@@ -125,22 +121,6 @@ void Media::addConstantParam( const QString& param )
m_vlcMedia->addOption( param.toStdString().c_str() );
}
void Media::setSnapshot( QPixmap* snapshot )
{
if ( m_snapshot != NULL )
delete m_snapshot;
m_snapshot = snapshot;
}
const QPixmap& Media::snapshot() const
{
if ( m_snapshot != NULL )
return *m_snapshot;
if ( Media::defaultSnapshot == NULL )
Media::defaultSnapshot = new QPixmap( ":/images/images/vlmc.png" );
return *Media::defaultSnapshot;
}
const QFileInfo* Media::fileInfo() const
{
return m_fileInfo;
......@@ -200,11 +180,6 @@ void Media::emitMetaDataComputed()
emit metaDataComputed( this );
}
void Media::emitSnapshotComputed()
{
emit snapshotComputed( this );
}
void Media::emitAudioSpectrumComuted()
{
emit audioSpectrumComputed( baseClip()->uuid() );
......
......@@ -29,14 +29,18 @@
#ifndef MEDIA_H__
#define MEDIA_H__
#include "config.h"
#include <QList>
#include <QString>
#include <QPixmap>
#include <QUuid>
#include <QObject>
#include <QFileInfo>
#include <QHash>
#ifdef WITH_GUI
#include "Media/GUIMedia.h"
#endif
namespace LibVLCpp
{
class Media;
......@@ -48,7 +52,11 @@ class QXmlStreamWriter;
/**
* Represents a basic container for media informations.
*/
#ifdef WITH_GUI
class Media : public GUIMedia
#else
class Media : public QObject
#endif
{
Q_OBJECT
......@@ -83,9 +91,6 @@ public:
void flushVolatileParameters();
LibVLCpp::Media *vlcMedia() { return m_vlcMedia; }
void setSnapshot( QPixmap* snapshot );
const QPixmap &snapshot() const;
const QFileInfo *fileInfo() const;
const QString &mrl() const;
const QString &fileName() const;
......@@ -130,11 +135,8 @@ public:
static const QString streamPrefix;
void emitMetaDataComputed();
void emitSnapshotComputed();
void emitAudioSpectrumComuted();
// bool hasMetadata() const;
QList<int>* audioValues() { return m_audioValueList; }
Clip* baseClip() { return m_baseClip; }
......@@ -149,11 +151,9 @@ private:
void setFileType();
protected:
static QPixmap* defaultSnapshot;
LibVLCpp::Media* m_vlcMedia;
QString m_mrl;
QList<QString> m_volatileParameters;
QPixmap* m_snapshot;
QFileInfo* m_fileInfo;
qint64 m_lengthMS;
qint64 m_nbFrames;
......@@ -171,8 +171,7 @@ protected:
signals:
void metaDataComputed( const Media* );
void snapshotComputed( const Media* );
void audioSpectrumComputed( const QUuid& );
};
#endif // CLIP_H__
#endif // MEDIA_H__
......@@ -27,7 +27,6 @@
#include "Media.h"
#include <QList>
#include <QLabel>
#include <QTemporaryFile>
#include <QTime>
......
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