Commit 9008b431 authored by luyikei's avatar luyikei

Backend: Separate IParameterInfo and IInfo from IFilter

parent c8fafd36
......@@ -15,6 +15,7 @@ vlmc_SOURCES = \
src/Backend/MLT/MLTFilter.cpp \
src/Backend/MLT/MLTTransition.cpp \
src/Backend/MLT/MLTMultiTrack.cpp \
src/Backend/MLT/MLTParameterInfo.cpp \
src/EffectsEngine/EffectHelper.cpp \
src/Library/Library.cpp \
src/Library/MediaLibraryModel.cpp \
......@@ -79,6 +80,7 @@ vlmc_SOURCES += \
src/Backend/MLT/MLTInput.h \
src/Backend/MLT/MLTMultiTrack.h \
src/Backend/MLT/MLTOutput.h \
src/Backend/MLT/MLTParameterInfo.h \
src/Backend/IBackend.h \
src/Backend/IProfile.h \
src/Backend/IMultiTrack.h \
......
......@@ -34,7 +34,7 @@ namespace Backend
class IOutput;
class IProfile;
class IFilterInfo;
class IInfo;
class IBackend
{
......@@ -50,8 +50,8 @@ class IBackend
virtual ~IBackend() = default;
virtual IProfile& profile() = 0;
virtual const std::map<std::string, IFilterInfo*>& availableFilters() const = 0;
virtual IFilterInfo* filterInfo( const std::string& id ) const = 0;
virtual const std::map<std::string, IInfo*>& availableFilters() const = 0;
virtual IInfo* filterInfo( const std::string& id ) const = 0;
virtual void setLogHandler( LogHandler logHandler ) = 0;
};
......
......@@ -31,32 +31,7 @@
namespace Backend
{
class IInput;
class IParameterInfo
{
public:
virtual ~IParameterInfo() = default;
virtual const std::string& identifier() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& type() const = 0;
virtual const std::string& description() const = 0;
virtual const std::string& defaultValue() const = 0;
virtual const std::string& minValue() const = 0;
virtual const std::string& maxValue() const = 0;
};
class IFilterInfo
{
public:
virtual ~IFilterInfo() = default;
virtual const std::string& identifier() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& description() const = 0;
virtual const std::string& author() const = 0;
virtual const std::vector<IParameterInfo*>& paramInfos() const = 0;
};
class IInfo;
class IFilter
{
......@@ -74,7 +49,7 @@ namespace Backend
virtual std::shared_ptr<IInput> input() const = 0;
virtual const IFilterInfo& filterInfo() const = 0;
virtual const IInfo& filterInfo() const = 0;
};
}
......
#ifndef IINFO_H
#define IINFO_H
#include <vector>
#include "IParameterInfo.h"
namespace Backend
{
class IInfo
{
public:
virtual ~IInfo() = default;
virtual const std::string& identifier() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& description() const = 0;
virtual const std::string& author() const = 0;
virtual const std::vector<IParameterInfo*>& paramInfos() const = 0;
};
}
#endif // IINFO_H
#ifndef IPARAMETERINFO_H
#define IPARAMETERINFO_H
#include <string>
namespace Backend
{
class IParameterInfo
{
public:
virtual ~IParameterInfo() = default;
virtual const std::string& identifier() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& type() const = 0;
virtual const std::string& description() const = 0;
virtual const std::string& defaultValue() const = 0;
virtual const std::string& minValue() const = 0;
virtual const std::string& maxValue() const = 0;
};
}
#endif // IPARAMETERINFO_H
......@@ -63,7 +63,7 @@ MLTBackend::MLTBackend()
for ( int i = 0; i < m_mltRepo->filters()->count(); ++i )
{
auto pro = std::unique_ptr<Mlt::Properties>( m_mltRepo->metadata( filter_type, m_mltRepo->filters()->get_name( i ) ) );
auto filterInfo = new MLTFilterInfo;
auto filterInfo = new MLTServiceInfo;
filterInfo->setProperties( pro.get() );
if ( filterInfo->identifier().empty() == true )
{
......@@ -88,13 +88,13 @@ MLTBackend::profile()
return m_profile;
}
const std::map<std::string, IFilterInfo*>&
const std::map<std::string, IInfo*>&
MLTBackend::availableFilters() const
{
return m_availableFilters;
}
IFilterInfo*
IInfo*
MLTBackend::filterInfo( const std::string& id ) const
{
auto it = m_availableFilters.find( id );
......
......@@ -42,7 +42,7 @@ class IOutput;
class IInput;
class IProfile;
class IClip;
class IFilterInfo;
class IInfo;
namespace MLT
......@@ -53,8 +53,8 @@ class MLTBackend : public IBackend, public Singleton<MLTBackend>
virtual IProfile& profile() override;
virtual const std::map<std::string, IFilterInfo*>& availableFilters() const override;
virtual IFilterInfo* filterInfo( const std::string& id ) const override;
virtual const std::map<std::string, IInfo*>& availableFilters() const override;
virtual IInfo* filterInfo( const std::string& id ) const override;
virtual void setLogHandler( LogHandler logHandler ) override;
......@@ -64,7 +64,7 @@ class MLTBackend : public IBackend, public Singleton<MLTBackend>
Mlt::Repository* m_mltRepo;
MLTProfile m_profile;
std::map<std::string, IFilterInfo*> m_availableFilters;
std::map<std::string, IInfo*> m_availableFilters;
friend Singleton_t::AllowInstantiation;
};
......
......@@ -36,129 +36,6 @@
using namespace Backend::MLT;
inline std::string makeString( char* str )
{
if ( str == nullptr )
return std::string( "" );
return std::string( str );
}
const std::string&
MLTParameterInfo::identifier() const
{
return m_identifier;
}
const std::string&
MLTParameterInfo::name() const
{
return m_name;
}
const std::string&
MLTParameterInfo::type() const
{
return m_type;
}
const std::string&
MLTParameterInfo::description() const
{
return m_description;
}
const std::string&
MLTParameterInfo::defaultValue() const
{
return m_defaultValue;
}
const std::string&
MLTParameterInfo::minValue() const
{
return m_minValue;
}
const std::string&
MLTParameterInfo::maxValue() const
{
return m_maxValue;
}
void
MLTParameterInfo::setProperties( Mlt::Properties* properties )
{
if ( properties == nullptr )
return;
m_identifier = makeString( properties->get( "identifier" ) );
m_name = makeString( properties->get( "title" ) );
m_type = makeString( properties->get( "type" ) );
m_description = makeString( properties->get( "description" ) );
m_defaultValue = makeString( properties->get( "default" ) );
m_minValue = makeString( properties->get( "minimum" ) );
m_maxValue = makeString( properties->get( "maximum" ) );
}
MLTFilterInfo::~MLTFilterInfo()
{
for ( IParameterInfo* info : m_paramInfos )
delete info;
m_paramInfos.clear();
}
const std::string&
MLTFilterInfo::identifier() const
{
return m_identifier;
}
const std::string&
MLTFilterInfo::name() const
{
return m_name;
}
const std::string&
MLTFilterInfo::description() const
{
return m_description;
}
const std::string&
MLTFilterInfo::author() const
{
return m_author;
}
const std::vector<Backend::IParameterInfo*>&
MLTFilterInfo::paramInfos() const
{
return m_paramInfos;
}
void
MLTFilterInfo::setProperties( Mlt::Properties* properties )
{
if ( properties == nullptr )
return;
m_identifier = makeString( properties->get( "identifier" ) );
m_name = makeString( properties->get( "title" ) );
m_description = makeString( properties->get( "description" ) );
m_author = makeString( properties->get( "creator" ) );
Mlt::Properties params( (mlt_properties)properties->get_data( "parameters" ) );
for ( int i = 0; i < params.count(); ++i )
{
int s;
Mlt::Properties param( (mlt_properties)params.get_data( i, s ) );
MLTParameterInfo* info = new MLTParameterInfo;
info->setProperties( &param );
m_paramInfos.push_back( info );
}
}
MLTFilter::MLTFilter( Backend::IProfile& profile, const char* id )
{
MLTProfile& mltProfile = static_cast<MLTProfile&>( profile );
......@@ -273,7 +150,7 @@ MLTFilter::input() const
return std::make_shared<MLTInput>( new Mlt::Producer( m_connectedProducer->get_producer() ) );
}
const Backend::IFilterInfo&
const Backend::IInfo&
MLTFilter::filterInfo() const
{
return *Backend::instance()->filterInfo( identifier() );
......
......@@ -39,54 +39,6 @@ class IProfile;
class IInput;
namespace MLT
{
class MLTParameterInfo : public IParameterInfo
{
public:
MLTParameterInfo() = default;
virtual const std::string& identifier() const override;
virtual const std::string& name() const override;
virtual const std::string& type() const override;
virtual const std::string& description() const override;
virtual const std::string& defaultValue() const override;
virtual const std::string& minValue() const override;
virtual const std::string& maxValue() const override;
void setProperties( Mlt::Properties* properties );
private:
std::string m_identifier;
std::string m_name;
std::string m_type;
std::string m_description;
std::string m_defaultValue;
std::string m_minValue;
std::string m_maxValue;
};
class MLTFilterInfo : public IFilterInfo
{
public:
MLTFilterInfo() = default;
virtual ~MLTFilterInfo() override;
virtual const std::string& identifier() const override;
virtual const std::string& name() const override;
virtual const std::string& description() const override;
virtual const std::string& author() const override;
virtual const std::vector<IParameterInfo*>& paramInfos() const override;
void setProperties( Mlt::Properties* properties );
private:
std::string m_identifier;
std::string m_name;
std::string m_author;
std::string m_description;
std::vector<IParameterInfo*> m_paramInfos;
};
class MLTFilter : public IFilter, public MLTService
{
public:
......@@ -111,7 +63,7 @@ namespace MLT
virtual std::shared_ptr<IInput> input() const override;
virtual const IFilterInfo& filterInfo() const override;
virtual const IInfo& filterInfo() const override;
private:
Mlt::Filter* m_filter;
......
#include "MLTParameterInfo.h"
#include <mlt++/MltProperties.h>
using namespace Backend::MLT;
inline std::string makeString( char* str )
{
if ( str == nullptr )
return std::string( "" );
return std::string( str );
}
const std::string&
MLTParameterInfo::identifier() const
{
return m_identifier;
}
const std::string&
MLTParameterInfo::name() const
{
return m_name;
}
const std::string&
MLTParameterInfo::type() const
{
return m_type;
}
const std::string&
MLTParameterInfo::description() const
{
return m_description;
}
const std::string&
MLTParameterInfo::defaultValue() const
{
return m_defaultValue;
}
const std::string&
MLTParameterInfo::minValue() const
{
return m_minValue;
}
const std::string&
MLTParameterInfo::maxValue() const
{
return m_maxValue;
}
void
MLTParameterInfo::setProperties( Mlt::Properties* properties )
{
if ( properties == nullptr )
return;
m_identifier = makeString( properties->get( "identifier" ) );
m_name = makeString( properties->get( "title" ) );
m_type = makeString( properties->get( "type" ) );
m_description = makeString( properties->get( "description" ) );
m_defaultValue = makeString( properties->get( "default" ) );
m_minValue = makeString( properties->get( "minimum" ) );
m_maxValue = makeString( properties->get( "maximum" ) );
}
#ifndef MLTPARAMETERINFO_H
#define MLTPARAMETERINFO_H
#include "Backend/IParameterInfo.h"
namespace Mlt
{
class Properties;
}
namespace Backend
{
namespace MLT
{
class MLTParameterInfo : public IParameterInfo
{
public:
MLTParameterInfo() = default;
virtual const std::string& identifier() const override;
virtual const std::string& name() const override;
virtual const std::string& type() const override;
virtual const std::string& description() const override;
virtual const std::string& defaultValue() const override;
virtual const std::string& minValue() const override;
virtual const std::string& maxValue() const override;
void setProperties( Mlt::Properties* properties );
private:
std::string m_identifier;
std::string m_name;
std::string m_type;
std::string m_description;
std::string m_defaultValue;
std::string m_minValue;
std::string m_maxValue;
};
}
}
#endif // MLTPARAMETERINFO_H
......@@ -30,10 +30,78 @@
#include "MLTFilter.h"
#include "MLTProfile.h"
#include "MLTParameterInfo.h"
#include <cassert>
using namespace Backend::MLT;
inline std::string makeString( char* str )
{
if ( str == nullptr )
return std::string( "" );
return std::string( str );
}
MLTServiceInfo::~MLTServiceInfo()
{
for ( IParameterInfo* info : m_paramInfos )
delete info;
m_paramInfos.clear();
}
const std::string&
MLTServiceInfo::identifier() const
{
return m_identifier;
}
const std::string&
MLTServiceInfo::name() const
{
return m_name;
}
const std::string&
MLTServiceInfo::description() const
{
return m_description;
}
const std::string&
MLTServiceInfo::author() const
{
return m_author;
}
const std::vector<Backend::IParameterInfo*>&
MLTServiceInfo::paramInfos() const
{
return m_paramInfos;
}
void
MLTServiceInfo::setProperties( Mlt::Properties* properties )
{
if ( properties == nullptr )
return;
m_identifier = makeString( properties->get( "identifier" ) );
m_name = makeString( properties->get( "title" ) );
m_description = makeString( properties->get( "description" ) );
m_author = makeString( properties->get( "creator" ) );
Mlt::Properties params( properties->get_data( "parameters" ) );
for ( int i = 0; i < params.count(); ++i )
{
int s;
Mlt::Properties param( params.get_data( i, s ) );
MLTParameterInfo* info = new MLTParameterInfo;
info->setProperties( &param );
m_paramInfos.push_back( info );
}
}
MLTService::~MLTService()
{
......
......@@ -26,6 +26,8 @@
#include <memory>
#include <exception>
#include "Backend/IInfo.h"
namespace Mlt
{
class Service;
......@@ -48,6 +50,30 @@ public:
namespace MLT
{
class MLTServiceInfo : public IInfo
{
public:
MLTServiceInfo() = default;
virtual ~MLTServiceInfo() override;
virtual const std::string& identifier() const override;
virtual const std::string& name() const override;
virtual const std::string& description() const override;
virtual const std::string& author() const override;
virtual const std::vector<IParameterInfo*>& paramInfos() const override;
void setProperties( Mlt::Properties* properties );
private:
std::string m_identifier;
std::string m_name;
std::string m_author;
std::string m_description;
std::vector<IParameterInfo*> m_paramInfos;
};
class MLTService
{
public:
......
......@@ -279,7 +279,7 @@ EffectHelper::setTarget( Backend::IInput* input )
input->attach( *m_filter );
}
Backend::IFilterInfo*
Backend::IInfo*
EffectHelper::filterInfo()
{
if ( m_filterInfo == nullptr )
......
......@@ -69,7 +69,7 @@ class EffectHelper : public Workflow::Helper
void setTarget( Backend::IInput* input );
Backend::IFilterInfo* filterInfo();
Backend::IInfo* filterInfo();
QString identifier();
......@@ -88,7 +88,7 @@ class EffectHelper : public Workflow::Helper
private:
std::shared_ptr<Backend::MLT::MLTFilter> m_filter;
Backend::IFilterInfo* m_filterInfo;
Backend::IInfo* m_filterInfo;
Settings m_settings;
......
......@@ -33,6 +33,7 @@
#include "Gui/settings/DoubleSliderWidget.h"
#include "EffectsEngine/EffectHelper.h"
#include "Backend/IFilter.h"
#include "Backend/IInfo.h"
#include "Main/Core.h"
#include "Tools/VlmcDebug.h"
......
......@@ -27,6 +27,7 @@
#include "EffectStack.h"
#include "ui/EffectStack.h"
#include "Backend/IInfo.h"
#include "Backend/IInput.h"
#include "Backend/IBackend.h"
#include "Backend/IFilter.h"
......
......@@ -25,6 +25,7 @@
#endif
#include "Backend/IFilter.h"
#include "Backend/IInfo.h"
#include "EffectWidget.h"
#include "ui/EffectWidget.h"
......@@ -41,7 +42,7 @@ EffectWidget::~EffectWidget()
}
void
EffectWidget::setFilterInfo( Backend::IFilterInfo* info )
EffectWidget::setFilterInfo( Backend::IInfo* info )
{
clear();
m_ui->nameValueLabel->setText( QString::fromStdString( info->name() ) );
......
......@@ -32,7 +32,7 @@ namespace Ui
namespace Backend
{
class IFilterInfo;
class IInfo;
}
class EffectWidget : public QWidget
......@@ -42,7 +42,7 @@ class EffectWidget : public QWidget
public:
explicit EffectWidget( QWidget *parent = 0 );
~EffectWidget();
void setFilterInfo( Backend::IFilterInfo* info );
void setFilterInfo( Backend::IInfo* info );
void clear();
private:
......
......@@ -27,6 +27,7 @@
#include "Main/Core.h"
#include "Backend/IBackend.h"
#include "Backend/IFilter.h"
#include "Backend/IInfo.h"
#include "EffectsListView.h"
#include "EffectWidget.h"
......
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