[vlmc-devel] commit: Adding a GUIMedia to handle GUi related stuff for medias. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Sat Mar 20 16:29:33 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Thu Mar 18 23:53:45 2010 +0100| [f9cf26536d54151c0ac254e465354b77b463ae5b] | committer: Hugo Beauzee-Luyssen 

Adding a GUIMedia to handle GUi related stuff for medias.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=f9cf26536d54151c0ac254e465354b77b463ae5b
---

 src/Gui/media/GuiMedia.cpp    |   60 +++++++++++++++++++++++++++++++++++++++++
 src/Gui/media/GuiMedia.h      |   53 ++++++++++++++++++++++++++++++++++++
 src/LibVLCpp/VLCInstance.h    |    6 ++--
 src/Media/Media.cpp           |   25 -----------------
 src/Media/Media.h             |   21 +++++++-------
 src/Metadata/MetaDataWorker.h |    1 -
 6 files changed, 126 insertions(+), 40 deletions(-)

diff --git a/src/Gui/media/GuiMedia.cpp b/src/Gui/media/GuiMedia.cpp
new file mode 100644
index 0000000..1e43a9f
--- /dev/null
+++ b/src/Gui/media/GuiMedia.cpp
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * GUIMedia.cpp: Represents the GUI part of a Media
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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 );
+}
diff --git a/src/Gui/media/GuiMedia.h b/src/Gui/media/GuiMedia.h
new file mode 100644
index 0000000..a7fb685
--- /dev/null
+++ b/src/Gui/media/GuiMedia.h
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * GUIMedia.h: Represents the GUI part of a Media
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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
diff --git a/src/LibVLCpp/VLCInstance.h b/src/LibVLCpp/VLCInstance.h
index c624804..1c920ef 100644
--- a/src/LibVLCpp/VLCInstance.h
+++ b/src/LibVLCpp/VLCInstance.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>;
     };
 }
 
diff --git a/src/Media/Media.cpp b/src/Media/Media.cpp
index eb14706..5a0ba10 100644
--- a/src/Media/Media.cpp
+++ b/src/Media/Media.cpp
@@ -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() );
diff --git a/src/Media/Media.h b/src/Media/Media.h
index ee8c264..f55a6fe 100644
--- a/src/Media/Media.h
+++ b/src/Media/Media.h
@@ -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__
diff --git a/src/Metadata/MetaDataWorker.h b/src/Metadata/MetaDataWorker.h
index 17e2f8a..505a82d 100644
--- a/src/Metadata/MetaDataWorker.h
+++ b/src/Metadata/MetaDataWorker.h
@@ -27,7 +27,6 @@
 #include "Media.h"
 
 #include <QList>
-#include <QLabel>
 #include <QTemporaryFile>
 #include <QTime>
 



More information about the Vlmc-devel mailing list