Commit 712b7c5e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

IMediaLibrary: Don't expose addMetadataService

Instead, automatically add available service.
parent 84ec8879
......@@ -52,16 +52,6 @@ class IMediaLibrary
virtual MoviePtr movie( const std::string& title ) = 0;
virtual MoviePtr createMovie( const std::string& title ) = 0;
/**
* @brief addMetadataService Adds a service to parse media
*
* User is expected to add all services before calling parse for the first time.
* Once parse has been called, adding another service is an undefined behavior.
* This method will call service->initialize(), therefor the passed ServiceStatus
* is expected to be uninitialized.
*/
virtual void addMetadataService( std::unique_ptr<IMetadataService> service ) = 0;
/**
* @brief discover Launch a discovery on the provided entry point.
* There no garanty on how this will be processed, or if it will be processed synchronously or not.
......
......@@ -19,6 +19,10 @@
// Discoverers:
#include "discoverer/FsDiscoverer.h"
// Metadata services:
#include "metadata_services/vlc/VLCMetadataService.h"
#include "metadata_services/vlc/VLCThumbnailer.h"
#include "filesystem/IDirectory.h"
#include "filesystem/IFile.h"
#include "factory/FileSystem.h"
......@@ -68,6 +72,19 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
m_snapshotPath = snapshotPath;
m_metadataCb = metadataCb;
if ( metadataCb != nullptr )
{
const char* args[] = {
"-vv",
"--vout=dummy",
};
VLC::Instance vlcInstance( sizeof(args) / sizeof(args[0]), args );
auto vlcService = std::unique_ptr<VLCMetadataService>( new VLCMetadataService( vlcInstance ) );
auto thumbnailerService = std::unique_ptr<VLCThumbnailer>( new VLCThumbnailer( vlcInstance ) );
addMetadataService( std::move( vlcService ) );
addMetadataService( std::move( thumbnailerService ) );
}
m_discoverers.emplace_back( new FsDiscoverer( m_fsFactory, this ) );
sqlite3* dbConnection;
......
......@@ -37,7 +37,6 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
virtual MoviePtr movie( const std::string& title );
virtual MoviePtr createMovie( const std::string& title );
virtual void addMetadataService( std::unique_ptr<IMetadataService> service );
virtual void parse( FilePtr file, IMetadataCb* cb );
virtual void discover( const std::string& entryPoint ) override;
......@@ -55,6 +54,7 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
bool checkSubfolders( fs::IDirectory* folder, unsigned int parentId );
void checkFiles( fs::IDirectory* folder, unsigned int parentId );
FilePtr addFile( const fs::IFile* file, unsigned int folderId );
void addMetadataService( std::unique_ptr<IMetadataService> service );
private:
std::shared_ptr<sqlite3> m_dbConnection;
......
......@@ -9,8 +9,6 @@
#include "IAlbum.h"
#include "IAlbumTrack.h"
#include "IVideoTrack.h"
#include "metadata_services/vlc/VLCMetadataService.h"
#include "metadata_services/vlc/VLCThumbnailer.h"
class ServiceCb : public IMetadataCb
{
......@@ -38,17 +36,6 @@ class VLCMetadataServices : public Tests
virtual void SetUp() override
{
Tests::Reload( nullptr, cb.get() );
const char* args[] = {
"-vv",
"--vout=dummy",
};
VLC::Instance vlcInstance( sizeof(args) / sizeof(args[0]), args );
auto vlcService = std::unique_ptr<VLCMetadataService>( new VLCMetadataService( vlcInstance ) );
auto thumbnailerService = std::unique_ptr<VLCThumbnailer>( new VLCThumbnailer( vlcInstance ) );
ml->addMetadataService( std::move( vlcService ) );
ml->addMetadataService( std::move( thumbnailerService ) );
}
};
......
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