Split the lib in smaller libs to ease unit tests
This commit is contained in:
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
add_compile_options(-Wall -Wextra -pedantic -Werror)
|
add_compile_options(-Wall -Wextra -pedantic -Werror)
|
||||||
|
|
||||||
SUBDIRS(liblms lms)
|
add_subdirectory(libs)
|
||||||
|
add_subdirectory(lms)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
|
|
||||||
add_library(liblms SHARED
|
|
||||||
impl/api/subsonic/SubsonicId.cpp
|
|
||||||
impl/api/subsonic/SubsonicResource.cpp
|
|
||||||
impl/api/subsonic/SubsonicResponse.cpp
|
|
||||||
impl/auth/AuthTokenService.cpp
|
|
||||||
impl/auth/PasswordService.cpp
|
|
||||||
impl/auth/LoginThrottler.cpp
|
|
||||||
impl/av/AvInfo.cpp
|
|
||||||
impl/av/AvTranscoder.cpp
|
|
||||||
impl/av/AvTypes.cpp
|
|
||||||
impl/cover/CoverArtGrabber.cpp
|
|
||||||
impl/cover/Image.cpp
|
|
||||||
impl/database/Artist.cpp
|
|
||||||
impl/database/Cluster.cpp
|
|
||||||
impl/database/Db.cpp
|
|
||||||
impl/database/TrackArtistLink.cpp
|
|
||||||
impl/database/TrackFeatures.cpp
|
|
||||||
impl/database/TrackList.cpp
|
|
||||||
impl/database/Release.cpp
|
|
||||||
impl/database/ScanSettings.cpp
|
|
||||||
impl/database/Session.cpp
|
|
||||||
impl/database/SessionPool.cpp
|
|
||||||
impl/database/SqlQuery.cpp
|
|
||||||
impl/database/Track.cpp
|
|
||||||
impl/database/TrackBookmark.cpp
|
|
||||||
impl/database/User.cpp
|
|
||||||
impl/metadata/AvFormat.cpp
|
|
||||||
impl/metadata/TagLibParser.cpp
|
|
||||||
impl/scanner/MediaScanner.cpp
|
|
||||||
impl/scanner/MediaScannerStats.cpp
|
|
||||||
impl/recommendation/Engine.cpp
|
|
||||||
impl/recommendation/ProviderCreator.cpp
|
|
||||||
impl/recommendation/features/som/DataNormalizer.cpp
|
|
||||||
impl/recommendation/features/som/Network.cpp
|
|
||||||
impl/utils/Config.cpp
|
|
||||||
impl/utils/Logger.cpp
|
|
||||||
impl/utils/NetAddress.cpp
|
|
||||||
impl/utils/Path.cpp
|
|
||||||
impl/utils/Random.cpp
|
|
||||||
impl/utils/StreamLogger.cpp
|
|
||||||
impl/utils/String.cpp
|
|
||||||
impl/utils/UUID.cpp
|
|
||||||
impl/utils/WtLogger.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(liblms INTERFACE
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(liblms PRIVATE
|
|
||||||
include/
|
|
||||||
${IMAGEMAGICKXX_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_options(liblms PRIVATE
|
|
||||||
${IMAGEMAGICKXX_CFLAGS_OTHER}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(liblms PRIVATE
|
|
||||||
${IMAGEMAGICKXX_LIBRARIES}
|
|
||||||
avformat
|
|
||||||
avutil
|
|
||||||
config++
|
|
||||||
tag
|
|
||||||
stdc++fs
|
|
||||||
wtdbosqlite3
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(liblms PUBLIC
|
|
||||||
pthread
|
|
||||||
boost_system
|
|
||||||
wtdbo
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS liblms DESTINATION lib)
|
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
add_subdirectory(auth)
|
||||||
|
add_subdirectory(av)
|
||||||
|
add_subdirectory(cover)
|
||||||
|
add_subdirectory(database)
|
||||||
|
add_subdirectory(recommendation)
|
||||||
|
add_subdirectory(scanner)
|
||||||
|
add_subdirectory(subsonic)
|
||||||
|
add_subdirectory(utils)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
add_library(lmsauth SHARED
|
||||||
|
impl/AuthTokenService.cpp
|
||||||
|
impl/PasswordService.cpp
|
||||||
|
impl/LoginThrottler.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsauth INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsauth PRIVATE
|
||||||
|
include/
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsauth PRIVATE
|
||||||
|
lmsutils
|
||||||
|
lmsdatabase
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsauth PUBLIC
|
||||||
|
pthread
|
||||||
|
boost_system
|
||||||
|
wt
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmsauth DESTINATION lib)
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
add_library(lmsav SHARED
|
||||||
|
impl/AvInfo.cpp
|
||||||
|
impl/AvTranscoder.cpp
|
||||||
|
impl/AvTypes.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsav INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsav PRIVATE
|
||||||
|
include/
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO make these private
|
||||||
|
target_link_libraries(lmsav PUBLIC
|
||||||
|
lmsutils
|
||||||
|
avformat
|
||||||
|
avutil
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmsav DESTINATION lib)
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
add_library(lmscover SHARED
|
||||||
|
impl/CoverArtGrabber.cpp
|
||||||
|
impl/Image.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmscover INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmscover PRIVATE
|
||||||
|
include
|
||||||
|
${IMAGEMAGICKXX_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(lmscover PRIVATE
|
||||||
|
${IMAGEMAGICKXX_CFLAGS_OTHER}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmscover PRIVATE
|
||||||
|
lmsav
|
||||||
|
lmsdatabase
|
||||||
|
${IMAGEMAGICKXX_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmscover DESTINATION lib)
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
add_library(lmsdatabase SHARED
|
||||||
|
impl/Artist.cpp
|
||||||
|
impl/Cluster.cpp
|
||||||
|
impl/Db.cpp
|
||||||
|
impl/TrackArtistLink.cpp
|
||||||
|
impl/TrackFeatures.cpp
|
||||||
|
impl/TrackList.cpp
|
||||||
|
impl/Release.cpp
|
||||||
|
impl/ScanSettings.cpp
|
||||||
|
impl/Session.cpp
|
||||||
|
impl/SessionPool.cpp
|
||||||
|
impl/SqlQuery.cpp
|
||||||
|
impl/Track.cpp
|
||||||
|
impl/TrackBookmark.cpp
|
||||||
|
impl/User.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsdatabase INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsdatabase PRIVATE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsdatabase PRIVATE
|
||||||
|
wtdbosqlite3
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsdatabase PUBLIC
|
||||||
|
lmsutils
|
||||||
|
wtdbo
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmsdatabase DESTINATION lib)
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
add_library(lmsrecommendation SHARED
|
||||||
|
impl/Engine.cpp
|
||||||
|
impl/ProviderCreator.cpp
|
||||||
|
impl/features/som/DataNormalizer.cpp
|
||||||
|
impl/features/som/Network.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsrecommendation INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsrecommendation PRIVATE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsrecommendation PRIVATE
|
||||||
|
lmsdatabase
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsrecommendation PUBLIC
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmsrecommendation DESTINATION lib)
|
||||||
|
|
||||||
+1
-1
@@ -29,7 +29,7 @@ namespace Recommendation
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Provider> createFeaturesRecommendationProvider(Scanner::MediaScanner&)
|
std::unique_ptr<Provider> createFeaturesRecommendationProvider(Scanner::IMediaScanner&)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
+2
-2
@@ -28,13 +28,13 @@ namespace Database
|
|||||||
|
|
||||||
namespace Scanner
|
namespace Scanner
|
||||||
{
|
{
|
||||||
class MediaScanner;
|
class IMediaScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Recommendation
|
namespace Recommendation
|
||||||
{
|
{
|
||||||
class Provider;
|
class Provider;
|
||||||
|
|
||||||
std::unique_ptr<Provider> createFeaturesRecommendationProvider(Scanner::MediaScanner& scanner);
|
std::unique_ptr<Provider> createFeaturesRecommendationProvider(Scanner::IMediaScanner& scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
add_library(lmsscanner SHARED
|
||||||
|
impl/metadata/AvFormat.cpp
|
||||||
|
impl/metadata/TagLibParser.cpp
|
||||||
|
impl/MediaScanner.cpp
|
||||||
|
impl/MediaScannerStats.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsscanner INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmsscanner PRIVATE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsscanner PRIVATE
|
||||||
|
lmsav
|
||||||
|
lmsdatabase
|
||||||
|
lmsutils
|
||||||
|
tag
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmsscanner PUBLIC
|
||||||
|
wt
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmsscanner DESTINATION lib)
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scanner/MediaScanner.hpp"
|
#include "MediaScanner.hpp"
|
||||||
|
|
||||||
#include <boost/asio/placeholders.hpp>
|
#include <boost/asio/placeholders.hpp>
|
||||||
|
|
||||||
@@ -191,6 +191,12 @@ getOrCreateClusters(Session& session, const MetaData::Clusters& clustersNames)
|
|||||||
|
|
||||||
namespace Scanner {
|
namespace Scanner {
|
||||||
|
|
||||||
|
std::unique_ptr<IMediaScanner>
|
||||||
|
createMediaScanner(Database::Db& db)
|
||||||
|
{
|
||||||
|
return std::make_unique<MediaScanner>(db);
|
||||||
|
}
|
||||||
|
|
||||||
MediaScanner::MediaScanner(Database::Db& db)
|
MediaScanner::MediaScanner(Database::Db& db)
|
||||||
: _dbSession {db}
|
: _dbSession {db}
|
||||||
{
|
{
|
||||||
+12
-35
@@ -29,56 +29,33 @@
|
|||||||
|
|
||||||
#include <boost/asio/system_timer.hpp>
|
#include <boost/asio/system_timer.hpp>
|
||||||
|
|
||||||
|
#include "scanner/IMediaScanner.hpp"
|
||||||
#include "database/ScanSettings.hpp"
|
#include "database/ScanSettings.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "metadata/TagLibParser.hpp"
|
#include "metadata/TagLibParser.hpp"
|
||||||
|
|
||||||
#include "MediaScannerAddon.hpp"
|
|
||||||
#include "MediaScannerStats.hpp"
|
|
||||||
|
|
||||||
namespace Scanner {
|
namespace Scanner {
|
||||||
|
|
||||||
class MediaScanner
|
class MediaScanner : public IMediaScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MediaScanner(Database::Db& db);
|
MediaScanner(Database::Db& db);
|
||||||
|
|
||||||
void setAddon(MediaScannerAddon& addon);
|
void setAddon(MediaScannerAddon& addon) override;
|
||||||
|
|
||||||
void start();
|
void start() override;
|
||||||
void stop();
|
void stop() override;
|
||||||
void restart();
|
void restart() override;
|
||||||
|
|
||||||
// Async requests
|
void requestImmediateScan() override;
|
||||||
void requestImmediateScan();
|
void requestReschedule() override ;
|
||||||
void requestReschedule();
|
|
||||||
|
|
||||||
|
Status getStatus() override;
|
||||||
|
|
||||||
enum class State
|
Wt::Signal<>& scanComplete() override { return _sigScanComplete; }
|
||||||
{
|
Wt::Signal<ScanProgressStats>& scanInProgress() override { return _sigScanInProgress; }
|
||||||
NotScheduled,
|
Wt::Signal<Wt::WDateTime>& scheduled() override { return _sigScheduled; }
|
||||||
Scheduled,
|
|
||||||
InProgress,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Status
|
|
||||||
{
|
|
||||||
State currentState {State::NotScheduled};
|
|
||||||
Wt::WDateTime nextScheduledScan;
|
|
||||||
std::optional<ScanStats> lastCompleteScanStats;
|
|
||||||
std::optional<ScanProgressStats> inProgressScanStats;
|
|
||||||
};
|
|
||||||
|
|
||||||
Status getStatus();
|
|
||||||
|
|
||||||
// Called just after scan complete
|
|
||||||
Wt::Signal<>& scanComplete() { return _sigScanComplete; }
|
|
||||||
|
|
||||||
// Called during scan in progress
|
|
||||||
Wt::Signal<ScanProgressStats>& scanInProgress() { return _sigScanInProgress; }
|
|
||||||
|
|
||||||
// Called after a schedule
|
|
||||||
Wt::Signal<Wt::WDateTime>& scheduled() { return _sigScheduled; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "metadata/AvFormat.hpp"
|
#include "AvFormat.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "metadata/TagLibParser.hpp"
|
#include "TagLibParser.hpp"
|
||||||
|
|
||||||
#include <taglib/asffile.h>
|
#include <taglib/asffile.h>
|
||||||
#include <taglib/id3v2tag.h>
|
#include <taglib/id3v2tag.h>
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS 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 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include <Wt/WDateTime.h>
|
||||||
|
#include <Wt/WSignal.h>
|
||||||
|
|
||||||
|
#include "MediaScannerAddon.hpp"
|
||||||
|
#include "MediaScannerStats.hpp"
|
||||||
|
|
||||||
|
namespace Database
|
||||||
|
{
|
||||||
|
class Db;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Scanner {
|
||||||
|
|
||||||
|
class IMediaScanner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IMediaScanner() = default;
|
||||||
|
|
||||||
|
virtual void setAddon(MediaScannerAddon& addon) = 0;
|
||||||
|
|
||||||
|
virtual void start() = 0;
|
||||||
|
virtual void stop() = 0;
|
||||||
|
virtual void restart() = 0;
|
||||||
|
|
||||||
|
// Async requests
|
||||||
|
virtual void requestImmediateScan() = 0;
|
||||||
|
virtual void requestReschedule() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
enum class State
|
||||||
|
{
|
||||||
|
NotScheduled,
|
||||||
|
Scheduled,
|
||||||
|
InProgress,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Status
|
||||||
|
{
|
||||||
|
State currentState {State::NotScheduled};
|
||||||
|
Wt::WDateTime nextScheduledScan;
|
||||||
|
std::optional<ScanStats> lastCompleteScanStats;
|
||||||
|
std::optional<ScanProgressStats> inProgressScanStats;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual Status getStatus() = 0;
|
||||||
|
|
||||||
|
// Called just after scan complete
|
||||||
|
virtual Wt::Signal<>& scanComplete() = 0;
|
||||||
|
|
||||||
|
// Called during scan in progress
|
||||||
|
virtual Wt::Signal<ScanProgressStats>& scanInProgress() = 0;
|
||||||
|
|
||||||
|
// Called after a schedule
|
||||||
|
virtual Wt::Signal<Wt::WDateTime>& scheduled() = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<IMediaScanner> createMediaScanner(Database::Db& db);
|
||||||
|
|
||||||
|
|
||||||
|
} // Scanner
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
add_library(lmssubsonic SHARED
|
||||||
|
impl/SubsonicId.cpp
|
||||||
|
impl/SubsonicResource.cpp
|
||||||
|
impl/SubsonicResponse.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmssubsonic INTERFACE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(lmssubsonic PRIVATE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmssubsonic PRIVATE
|
||||||
|
lmsauth
|
||||||
|
lmsav
|
||||||
|
lmscover
|
||||||
|
lmsrecommendation
|
||||||
|
lmsutils
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(lmssubsonic PUBLIC
|
||||||
|
lmsdatabase
|
||||||
|
wt
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lmssubsonic DESTINATION lib)
|
||||||
|
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "api/subsonic/SubsonicResource.hpp"
|
#include "subsonic/SubsonicResource.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user