[vlmc-devel] Add a MediaLibrary class shell

Hugo Beauzée-Luyssen git at videolan.org
Mon Jul 4 15:34:33 CEST 2016


vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Jun  2 09:26:59 2016 +0200| [c16b654d662c0f439cfc81bf1e520a8b6a9d61fa] | committer: Hugo Beauzée-Luyssen

Add a MediaLibrary class shell

> https://code.videolan.org/videolan/vlmc/commit/c16b654d662c0f439cfc81bf1e520a8b6a9d61fa
---

 src/CMakeLists.txt           |  10 ++++-
 src/Library/MediaLibrary.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++
 src/Library/MediaLibrary.h   |  67 ++++++++++++++++++++++++++++
 src/Main/Core.cpp            |   2 +
 src/Main/Core.h              |   3 ++
 5 files changed, 184 insertions(+), 2 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 64cc9f7..506f31e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -43,6 +43,13 @@ list(APPEND VLMC_LIBS ${MLTPP_LIBRARIES})
 link_directories(${MLTPP_LIBRARY_DIRS})
 INCLUDE_DIRECTORIES(${MLTPP_INCLUDE_DIRS})
 
+# Handle contribs:
+message(STATUS "Contribs prefix: ${CONTRIBS_DIR}")
+include_directories( ${CONTRIBS_DIR}/include )
+link_directories(${CONTRIBS_DIR}/lib)
+
+list(APPEND VLMC_LIBS medialibrary)
+
 FIND_PACKAGE(frei0r REQUIRED)
 
 if(APPLE)
@@ -78,6 +85,7 @@ SET(VLMC_SRCS
     EffectsEngine/EffectHelper.cpp
     Library/Library.cpp
     Library/MediaContainer.cpp
+    Library/MediaLibrary.cpp
     Main/Core.cpp
     Main/main.cpp
     Media/Clip.cpp
@@ -299,8 +307,6 @@ ENDIF( NOT WITH_GUI )
 
 add_dependencies(vlmc libvlcpp)
 add_dependencies(vlmc medialibrarydeps)
-message(STATUS "Contribs prefix: ${CONTRIBS_DIR}")
-include_directories( ${CONTRIBS_DIR}/include )
 
 INSTALL(TARGETS vlmc
         BUNDLE  DESTINATION ${VLMC_BIN_DIR}
diff --git a/src/Library/MediaLibrary.cpp b/src/Library/MediaLibrary.cpp
new file mode 100644
index 0000000..be388d5
--- /dev/null
+++ b/src/Library/MediaLibrary.cpp
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * MediaLibrary.cpp: Wraps the media library
+ *****************************************************************************
+ * Copyright (C) 2008-2016 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
+ *
+ * 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 "MediaLibrary.h"
+#include "Settings/Settings.h"
+
+MediaLibrary::MediaLibrary( Settings* settings )
+{
+    m_ml.reset( NewMediaLibrary() );
+    settings->createVar( SettingValue::List, QStringLiteral( "vlmc/mlDirs" ), QVariant(),
+                                       "", "", SettingValue::Nothing );
+    connect( settings, &Settings::postLoad, this, &MediaLibrary::postLoad, Qt::DirectConnection );
+}
+
+void MediaLibrary::postLoad()
+{
+    auto workspace = VLMC_GET_STRING( "vlmc/Workspace" ).toStdString();
+    Q_ASSERT( workspace.length() != 0 );
+    m_ml->initialize( workspace + "/ml.db", workspace + "/thumbnails/", this );
+}
+
+
+void MediaLibrary::onMediaAdded( std::vector<medialibrary::MediaPtr> )
+{
+}
+
+void MediaLibrary::onMediaUpdated( std::vector<medialibrary::MediaPtr> )
+{
+}
+
+void MediaLibrary::onMediaDeleted( std::vector<int64_t> )
+{
+}
+
+void MediaLibrary::onArtistsAdded( std::vector<medialibrary::ArtistPtr> )
+{
+}
+
+void MediaLibrary::onArtistsModified( std::vector<medialibrary::ArtistPtr> )
+{
+}
+
+void MediaLibrary::onArtistsDeleted( std::vector<int64_t> )
+{
+}
+
+void MediaLibrary::onAlbumsAdded( std::vector<medialibrary::AlbumPtr> )
+{
+}
+
+void MediaLibrary::onAlbumsModified( std::vector<medialibrary::AlbumPtr> )
+{
+}
+
+void MediaLibrary::onAlbumsDeleted( std::vector<int64_t> )
+{
+}
+
+void MediaLibrary::onTracksAdded( std::vector<medialibrary::AlbumTrackPtr> )
+{
+}
+
+void MediaLibrary::onTracksDeleted( std::vector<int64_t> )
+{
+}
+
+void MediaLibrary::onDiscoveryStarted( const std::string& )
+{
+}
+
+void MediaLibrary::onDiscoveryCompleted( const std::string& )
+{
+}
+
+void MediaLibrary::onReloadStarted( const std::string& )
+{
+}
+
+void MediaLibrary::onReloadCompleted( const std::string& )
+{
+}
+
+void MediaLibrary::onParsingStatsUpdated( uint32_t )
+{
+}
diff --git a/src/Library/MediaLibrary.h b/src/Library/MediaLibrary.h
new file mode 100644
index 0000000..821a108
--- /dev/null
+++ b/src/Library/MediaLibrary.h
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * MediaLibrary.h: Wraps the media library
+ *****************************************************************************
+ * Copyright (C) 2008-2016 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
+ *
+ * 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 MEDIALIBRARY_H
+#define MEDIALIBRARY_H
+
+#include <medialibrary/IMediaLibrary.h>
+
+#include <QObject>
+
+#include <memory>
+
+class Settings;
+
+class MediaLibrary : public QObject, private medialibrary::IMediaLibraryCb
+{
+    Q_OBJECT
+    Q_DISABLE_COPY( MediaLibrary )
+
+public:
+    explicit MediaLibrary( Settings* settings );
+
+private:
+    void postLoad();
+
+private:
+    virtual void onMediaAdded( std::vector<medialibrary::MediaPtr> media ) override;
+    virtual void onMediaUpdated( std::vector<medialibrary::MediaPtr> media ) override;
+    virtual void onMediaDeleted( std::vector<int64_t> ids ) override;
+    virtual void onArtistsAdded( std::vector<medialibrary::ArtistPtr> artists ) override;
+    virtual void onArtistsModified( std::vector<medialibrary::ArtistPtr> artist ) override;
+    virtual void onArtistsDeleted( std::vector<int64_t> ids ) override;
+    virtual void onAlbumsAdded( std::vector<medialibrary::AlbumPtr> albums ) override;
+    virtual void onAlbumsModified( std::vector<medialibrary::AlbumPtr> albums ) override;
+    virtual void onAlbumsDeleted( std::vector<int64_t> ids ) override;
+    virtual void onTracksAdded( std::vector<medialibrary::AlbumTrackPtr> tracks ) override;
+    virtual void onTracksDeleted( std::vector<int64_t> trackIds ) override;
+    virtual void onDiscoveryStarted( const std::string& entryPoint ) override;
+    virtual void onDiscoveryCompleted( const std::string& entryPoint ) override;
+    virtual void onReloadStarted( const std::string& entryPoint ) override;
+    virtual void onReloadCompleted( const std::string& entryPoint ) override;
+    virtual void onParsingStatsUpdated( uint32_t percent ) override;
+
+private:
+    std::unique_ptr<medialibrary::IMediaLibrary> m_ml;
+};
+
+#endif // MEDIALIBRARY_H
diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index 1dc3bcf..eec3b64 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -30,6 +30,7 @@
 
 #include <Backend/IBackend.h>
 #include "Library/Library.h"
+#include "Library/MediaLibrary.h"
 #include "Project/RecentProjects.h"
 #include "Project/Workspace.h"
 #include <Settings/Settings.h>
@@ -45,6 +46,7 @@ Core::Core()
     createSettings();
     m_currentProject = new Project( m_settings );
     m_library = new Library( m_currentProject->settings() );
+    m_ml.reset( new MediaLibrary( m_settings ) );
     m_recentProjects = new RecentProjects( m_settings );
     m_workspace = new Workspace( m_settings );
     m_workflow = new MainWorkflow( m_currentProject->settings() );
diff --git a/src/Main/Core.h b/src/Main/Core.h
index 37c3838..a0a0fd0 100644
--- a/src/Main/Core.h
+++ b/src/Main/Core.h
@@ -26,6 +26,7 @@
 class AutomaticBackup;
 class Library;
 class MainWorkflow;
+class MediaLibrary;
 class NotificationZone;
 class Project;
 class RecentProjects;
@@ -58,6 +59,7 @@ class Core : public ScopedSingleton<Core>
         MainWorkflow*           workflow();
         Commands::AbstractUndoStack*   undoStack();
         Library*                library();
+        MediaLibrary*           mediaLibrary();
         /**
          * @brief runtime returns the application runtime
          */
@@ -83,6 +85,7 @@ class Core : public ScopedSingleton<Core>
         MainWorkflow*           m_workflow;
         Commands::AbstractUndoStack*   m_undoStack;
         Library*                m_library;
+        std::unique_ptr<MediaLibrary> m_ml;
         QElapsedTimer           m_timer;
 
         friend Singleton_t::AllowInstantiation;



More information about the Vlmc-devel mailing list