IMediaLibrary.h 3.4 KB
Newer Older
1 2 3 4 5 6
#ifndef IMEDIALIBRARY_H
#define IMEDIALIBRARY_H

#include <vector>
#include <string>

7
#include "Types.h"
8
#include "factory/IFileSystem.h"
9
#include "IDiscoverer.h"
10

11
class IMediaLibraryCb
12
{
13
public:
14
    virtual ~IMediaLibraryCb() = default;
15 16 17 18 19
    /**
     * @brief onMetadataUpdated Will be called when a file gets some updated metadata
     * @param file The updated file.
     */
    virtual void onMetadataUpdated( FilePtr file ) = 0;
20 21 22 23 24 25 26 27 28

    virtual void onDiscoveryStarted( const std::string& entryPoint ) = 0;
    /**
     * @brief onFileAdded This will be called for each new file discovered
     *                    or restored when reloading the media library.
     * @param file
     */
    virtual void onFileAdded( FilePtr file ) = 0;
    virtual void onDiscoveryCompleted( const std::string& entryPoint ) = 0;
29 30
};

31
class IMediaLibrary
32 33
{
    public:
34
        virtual ~IMediaLibrary() {}
35
        ///
36 37 38
        /// \brief  initialize Initializes the media library.
        ///         This will use the provided discoverer to search for new media asynchronously.
        ///
39 40 41
        /// \param dbPath       Path to the database
        /// \return true in case of success, false otherwise
        ///
42
        virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMediaLibraryCb* metadataCb ) = 0;
43 44 45 46 47 48
        /**
         * Replaces the default filesystem factory
         * The default one will use standard opendir/readdir functions
         * Calling this after initialize() is not a supported scenario.
         */
        virtual void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ) = 0;
49
        /// Adds a stand alone file
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50 51
        virtual FilePtr addFile( const std::string& path ) = 0;
        virtual FilePtr file( const std::string& path ) = 0;
52 53
        virtual bool deleteFile( const std::string& mrl ) = 0;
        virtual bool deleteFile( FilePtr file ) = 0;
54 55 56

        /// Adds a folder and all the files it contains
        virtual FolderPtr folder( const std::string& path ) = 0;
57
        virtual bool deleteFolder( FolderPtr folder ) = 0;
58

59
        virtual LabelPtr createLabel( const std::string& label ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
60 61
        virtual bool deleteLabel( const std::string& label ) = 0;
        virtual bool deleteLabel( LabelPtr label ) = 0;
62
        virtual std::vector<FilePtr> files() = 0;
63 64
        virtual std::vector<FilePtr> audioFiles() = 0;
        virtual std::vector<FilePtr> videoFiles() = 0;
65 66
        virtual AlbumPtr album( const std::string& title ) = 0;
        virtual AlbumPtr createAlbum( const std::string& title ) = 0;
67 68
        virtual ShowPtr show( const std::string& name ) = 0;
        virtual ShowPtr createShow( const std::string& name ) = 0;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69 70
        virtual MoviePtr movie( const std::string& title ) = 0;
        virtual MoviePtr createMovie( const std::string& title ) = 0;
71

72 73
        /**
         * @brief discover Launch a discovery on the provided entry point.
74
         * The actuall discovery will run asynchronously, meaning this method will immediatly return.
75 76 77 78
         * Depending on which discoverer modules where provided, this might or might not work
         * @param entryPoint What to discover.
         */
        virtual void discover( const std::string& entryPoint ) = 0;
79
        virtual const std::string& snapshotPath() const = 0;
80
        virtual void setLogger( ILogger* logger ) = 0;
81 82
};

83 84 85 86 87 88
class MediaLibraryFactory
{
    public:
        static IMediaLibrary* create();
};

89
#endif // IMEDIALIBRARY_H