1 /* 2 SPDX-FileCopyrightText: 2017 Nicolas Carion 3 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 */ 5 6 #ifndef TRANSITIONSREPOSITORY_H 7 #define TRANSITIONSREPOSITORY_H 8 9 #include "assets/abstractassetsrepository.hpp" 10 #include "assets/model/assetparametermodel.hpp" 11 #include "definitions.h" 12 #include <memory> 13 #include <mutex> 14 15 /** @class TransitionsRepository 16 @brief This class stores all the transitions that can be added by the user. 17 You can query any transitions based on its name. 18 Note that this class is a Singleton 19 */ 20 class TransitionsRepository : public AbstractAssetsRepository<AssetListType::AssetType> 21 { 22 23 public: 24 /** @brief Returns the instance of the Singleton */ 25 static std::unique_ptr<TransitionsRepository> &get(); 26 27 /** @brief Creates and return an instance of a transition given its id. 28 */ 29 std::unique_ptr<Mlt::Transition> getTransition(const QString &transitionId) const; 30 31 /** @brief returns true if the transition corresponding to \@transitionId is a composition*/ 32 bool isComposition(const QString &transitionId) const; 33 34 /** @brief returns true if the transition corresponding to \@transitionId is audio*/ 35 bool isAudio(const QString &transitionId) const; 36 37 /** @brief Returns the id of the transition to be used for compositing */ 38 const QString getCompositingTransition(); 39 40 protected: 41 // Constructor is protected because class is a Singleton 42 TransitionsRepository(); 43 44 /** @brief Retrieves the list of all available effects from Mlt*/ 45 Mlt::Properties *retrieveListFromMlt() const override; 46 47 /** @brief Retrieves additional info about effects from a custom XML file 48 The resulting assets are stored in customAssets 49 */ 50 void parseCustomAssetFile(const QString &file_name, std::unordered_map<QString, Info> &customAssets) const override; 51 52 /** @brief Returns the paths where the custom transitions' descriptions are stored */ 53 QStringList assetDirs() const override; 54 55 /** @brief Returns the path to the transitions' blacklist*/ 56 QString assetBlackListPath() const override; 57 58 /** @brief Returns the path to the effects' preferred list*/ 59 QString assetPreferredListPath() const override; 60 61 void parseType(QScopedPointer<Mlt::Properties> &metadata, Info &res) override; 62 63 /** @brief Returns the metadata associated with the given asset*/ 64 Mlt::Properties *getMetadata(const QString &assetId) const override; 65 66 /** @brief Returns all transitions that can be represented as Single Track Transitions*/ 67 static QSet<QString> getSingleTrackTransitions(); 68 69 static std::unique_ptr<TransitionsRepository> instance; 70 static std::once_flag m_onceFlag; // flag to create the repository only once; 71 }; 72 73 #endif 74