Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 6c398370 authored by Nicolas Carion's avatar Nicolas Carion

move factory creation in MltConnection and wrap unique_ptr around Mlt::Repository

parent 5c88cc2b
......@@ -22,6 +22,8 @@ the Free Software Foundation, either version 3 of the License, or
#include "doc/kdenlivedoc.h"
#include "doc/docundostack.hpp"
#include <mlt++/MltRepository.h>
#include <locale>
#ifdef Q_OS_MAC
#include <xlocale.h>
......@@ -186,3 +188,8 @@ void Core::initLocale()
QLocale::setDefault(systemLocale);
}
std::unique_ptr<Mlt::Repository>& Core::getMltRepository()
{
return m_mltConnection->getMltRepository();
}
......@@ -26,6 +26,11 @@ class LibraryWidget;
class ProducerQueue;
class MltConnection;
namespace Mlt
{
class Repository;
}
#define EXIT_RESTART (42)
#define pCore Core::self()
......@@ -83,6 +88,9 @@ public:
/** @brief Add a new timeline tab. */
void addTimeline(QWidget *timeline, const QString &name);
/** @brief Returns a pointer to MLT's repository */
std::unique_ptr<Mlt::Repository>& getMltRepository();
private:
explicit Core();
static Core *m_self;
......
......@@ -179,9 +179,9 @@ bool DocumentValidator::validate(const double currentVersion)
}
// locale conversion might need to be redone
#ifndef Q_OS_MAC
initEffects::parseEffectFiles(pCore->binController()->mltRepository(), setlocale(LC_NUMERIC, nullptr));
initEffects::parseEffectFiles(pCore->getMltRepository(), setlocale(LC_NUMERIC, nullptr));
#else
initEffects::parseEffectFiles(pCore->binController()->mltRepository(), setlocale(LC_NUMERIC_MASK, nullptr));
initEffects::parseEffectFiles(pCore->getMltRepository(), setlocale(LC_NUMERIC_MASK, nullptr));
#endif
}
double version = -1;
......
......@@ -143,7 +143,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QString &projectFolder, QUndoGro
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
// locale conversion might need to be redone
initEffects::parseEffectFiles(pCore->binController()->mltRepository(), setlocale(LC_NUMERIC, nullptr));
initEffects::parseEffectFiles(pCore->getMltRepository(), setlocale(LC_NUMERIC, nullptr));
}
*openBackup = false;
if (url.isValid()) {
......
......@@ -128,7 +128,7 @@ QDomDocument initEffects::getUsedCustomEffects(const QMap<QString, QString> &eff
}
//static
bool initEffects::parseEffectFiles(Mlt::Repository *repository, const QString &locale)
bool initEffects::parseEffectFiles(std::unique_ptr<Mlt::Repository> &repository, const QString &locale)
{
bool movit = false;
QStringList::Iterator more;
......@@ -434,7 +434,7 @@ void initEffects::parseCustomEffectsFile()
}
// static
void initEffects::parseEffectFile(EffectsList *customEffectList, EffectsList *audioEffectList, EffectsList *videoEffectList, const QString &name, const QStringList &filtersList, const QStringList &producersList, Mlt::Repository *repository, const QMap<QString, QString> &effectDescriptions)
void initEffects::parseEffectFile(EffectsList *customEffectList, EffectsList *audioEffectList, EffectsList *videoEffectList, const QString &name, const QStringList &filtersList, const QStringList &producersList, std::unique_ptr<Mlt::Repository> &repository, const QMap<QString, QString> &effectDescriptions)
{
QDomDocument doc;
QFile file(name);
......@@ -550,7 +550,7 @@ void initEffects::parseEffectFile(EffectsList *customEffectList, EffectsList *au
}
}
QDomDocument initEffects::createDescriptionFromMlt(Mlt::Repository *repository, const QString & /*type*/, const QString &filtername)
QDomDocument initEffects::createDescriptionFromMlt(std::unique_ptr<Mlt::Repository> &repository, const QString & /*type*/, const QString &filtername)
{
QDomDocument ret;
......@@ -683,7 +683,7 @@ QDomDocument initEffects::createDescriptionFromMlt(Mlt::Repository *repository,
return ret;
}
void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names)
void initEffects::fillTransitionsList(std::unique_ptr<Mlt::Repository> &repository, EffectsList *transitions, QStringList names)
{
// Remove transitions that are not implemented.
int pos = names.indexOf(QStringLiteral("mix"));
......@@ -898,7 +898,7 @@ QDomElement initEffects::quickParameterFill(QDomDocument &doc, const QString &na
}
// static
void initEffects::parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, const QStringList &installedTransitions, const QMap<QString, QString> &effectDescriptions)
void initEffects::parseTransitionFile(EffectsList *transitionList, const QString &name, std::unique_ptr<Mlt::Repository> &repository, const QStringList &installedTransitions, const QMap<QString, QString> &effectDescriptions)
{
QDomDocument doc;
QFile file(name);
......
......@@ -21,6 +21,7 @@
#include <QDomDocument>
#include <QStringList>
#include <QMap>
#include <memory>
#include <mlt++/Mlt.h>
/**Init the MLT effects
......@@ -41,9 +42,9 @@ public:
* It checks for all available effects and transitions, removes blacklisted
* ones, calls fillTransitionsList() and parseEffectFile() to fill the lists
* (with sorted, unique items) and then fills the global lists. */
static bool parseEffectFiles(Mlt::Repository *repository, const QString &locale = QString());
static bool parseEffectFiles(std::unique_ptr<Mlt::Repository> &repository, const QString &locale = QString());
static void refreshLumas();
static QDomDocument createDescriptionFromMlt(Mlt::Repository *repository, const QString &type, const QString &name);
static QDomDocument createDescriptionFromMlt(std::unique_ptr<Mlt::Repository> &repository, const QString &type, const QString &name);
static QDomDocument getUsedCustomEffects(const QMap<QString, QString> &effectids);
/** @brief Fills the transitions list.
......@@ -54,7 +55,7 @@ public:
* It creates an element for each transition, asking to MLT for information
* when possible, using default parameters otherwise. It also adds some
* "virtual" transition, and removes those not implemented. */
static void fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names);
static void fillTransitionsList(std::unique_ptr<Mlt::Repository> &repository, EffectsList *transitions, QStringList names);
/** @brief Creates an element describing a transition parameter.
* @param doc document containing the transition element
......@@ -87,8 +88,8 @@ public:
EffectsList *videoEffectList,
const QString &name, const QStringList &filtersList,
const QStringList &producersList,
Mlt::Repository *repository, const QMap<QString, QString> &effectDescriptions);
static void parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, const QStringList &installedTransitions, const QMap<QString, QString> &effectDescriptions);
std::unique_ptr<Mlt::Repository> &repository, const QMap<QString, QString> &effectDescriptions);
static void parseTransitionFile(EffectsList *transitionList, const QString &name, std::unique_ptr<Mlt::Repository> &repository, const QStringList &installedTransitions, const QMap<QString, QString> &effectDescriptions);
/** @brief Reloads information about custom effects. */
static void parseCustomEffectsFile();
......
......@@ -235,7 +235,7 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
QTabBar *bar = m_timelineArea->findChild<QTabBar *>();
bar->setHidden(true);
m_gpuAllowed = initEffects::parseEffectFiles(pCore->binController()->mltRepository());
m_gpuAllowed = initEffects::parseEffectFiles(pCore->getMltRepository());
//initEffects::parseCustomEffectsFile();
m_shortcutRemoveFocus = new QShortcut(QKeySequence(QStringLiteral("Esc")), this);
......
......@@ -18,6 +18,7 @@ the Free Software Foundation, either version 3 of the License, or
#include <KUrlRequesterDialog>
#include <klocalizedstring.h>
#include <QFile>
#include <QStandardPaths>
#include "kdenlive_debug.h"
......@@ -30,6 +31,10 @@ MltConnection::MltConnection(const QString &mltPath)
qDebug() << "DEBUG: Warning : trying to open a second mlt connection";
return;
}
// Disable VDPAU that crashes in multithread environment.
//TODO: make configurable
setenv("MLT_NO_VDPAU", "1", 1);
m_repository = std::unique_ptr<Mlt::Repository>(Mlt::Factory::init());
locateMeltAndProfilesPath(mltPath);
}
......@@ -128,3 +133,8 @@ void MltConnection::locateMeltAndProfilesPath(const QString &mltPath)
locateMeltAndProfilesPath();
}
}
std::unique_ptr<Mlt::Repository>& MltConnection::getMltRepository()
{
return m_repository;
};
......@@ -11,12 +11,17 @@ the Free Software Foundation, either version 3 of the License, or
#ifndef MLTCONNECTION_H
#define MLTCONNECTION_H
#include <QObject>
#include <memory>
#include <QString>
namespace Mlt {
class Repository;
}
/**
* @class MltConnection
* @brief Initializes MLT and provides access to its API
*
* This is where the Mlt Factory is initialized
*/
class MltConnection
......@@ -28,6 +33,9 @@ public:
*/
MltConnection(const QString &mltPath);
/* @brief Returns a pointer to the MLT Repository*/
std::unique_ptr<Mlt::Repository>& getMltRepository();
protected:
/** @brief Locates the MLT environment.
......@@ -39,6 +47,10 @@ protected:
void locateMeltAndProfilesPath(const QString &mltPath = QString());
static int instanceCounter;
/** @brief The MLT repository, useful for filter/producer requests */
std::unique_ptr<Mlt::Repository> m_repository;
};
#endif
......@@ -28,10 +28,6 @@ BinController::BinController(const QString &profileName) :
QObject()
{
m_binPlaylist = nullptr;
// Disable VDPAU that crashes in multithread environment.
//TODO: make configurable
setenv("MLT_NO_VDPAU", "1", 1);
m_repository = Mlt::Factory::init();
//resetProfile(profileName.isEmpty() ? KdenliveSettings::current_profile() : profileName);
}
......@@ -40,10 +36,6 @@ BinController::~BinController()
destroyBin();
}
Mlt::Repository *BinController::mltRepository()
{
return m_repository;
}
Mlt::Profile *BinController::profile()
{
......
......@@ -40,7 +40,6 @@ class Profile;
* @class BinController
* @brief This is where MLT's project clips (the bin clips) are managed
*
* This is also where the Mlt::Factory is first initialized.
* The project profile, used to build the monitors renderers is stored here
*/
......@@ -141,9 +140,6 @@ public:
/** @brief A Bin clip effect was changed, update track producers */
void updateTrackProducer(const QString &id);
/** @brief Returns MLT's Repository data */
Mlt::Repository *mltRepository();
/** @brief Load thumbnails for all producers */
void checkThumbnails(const QDir &thumbFolder);
......@@ -182,9 +178,6 @@ private:
/** @brief The current MLT profile's filename */
QString m_activeProfile;
/** @brief The MLT repository, useful for filter/producer requests */
Mlt::Repository *m_repository;
/** @brief Can be used to copy filters from a clip to another */
void duplicateFilters(Mlt::Producer original, Mlt::Producer clone);
......
......@@ -34,6 +34,7 @@
#include "monitor/glwidget.h"
#include "mltcontroller/clipcontroller.h"
#include "timeline/transitionhandler.h"
#include "core.h"
#include <mlt++/Mlt.h>
#include "kdenlive_debug.h"
......@@ -1631,7 +1632,7 @@ bool Render::checkX11Grab()
double Render::getMltVersionInfo(const QString &tag)
{
double version = 0;
Mlt::Properties *metadata = m_binController->mltRepository()->metadata(producer_type, tag.toUtf8().data());
Mlt::Properties *metadata = pCore->getMltRepository()->metadata(producer_type, tag.toUtf8().data());
if (metadata && metadata->is_valid()) {
version = metadata->get_double("version");
}
......
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