/* * Copyright (C) 2015 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 . */ #pragma once #include #include #include "database/objects/ImageId.hpp" #include "database/objects/TrackEmbeddedImageId.hpp" #include "services/artwork/IArtworkService.hpp" #include "ImageCache.hpp" namespace lms::audio { class IAudioFileInfoParser; } namespace lms::db { class Session; } namespace lms::artwork { class ArtworkService : public IArtworkService { public: ArtworkService(db::IDb& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath); ~ArtworkService() override; ArtworkService(const ArtworkService&) = delete; ArtworkService& operator=(const ArtworkService&) = delete; private: db::ArtworkId findTrackListImage(db::TrackListId trackListId) override; std::shared_ptr getImage(db::ArtworkId artworkId, std::optional width) override; std::shared_ptr getDefaultReleaseArtwork() override; std::shared_ptr getDefaultArtistArtwork() override; void flushCache() override; void setJpegQuality(unsigned quality) override; std::shared_ptr getImage(db::ImageId imageId, std::optional width); std::shared_ptr getTrackEmbeddedImage(db::TrackEmbeddedImageId trackEmbeddedImageId, std::optional width); std::unique_ptr getFromImageFile(const std::filesystem::path& p, std::string_view mimeType, std::optional width) const; std::unique_ptr getTrackImage(const std::filesystem::path& path, std::size_t index, std::optional width) const; db::IDb& _db; ImageCache _cache; std::shared_ptr _defaultReleaseCover; std::shared_ptr _defaultArtistImage; std::unique_ptr _audioFileInfoParser; static inline const std::vector _fileExtensions{ ".jpg", ".jpeg", ".png", ".bmp" }; // TODO parametrize unsigned _jpegQuality; }; } // namespace lms::artwork