Commit 1880c780 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectsEngine: Adding the basic classes to load an effect plugin

parent df8cc1f1
......@@ -6,8 +6,8 @@
SET(VLMC_SRCS
Commands/Commands.cpp
Settings/SettingsManager.cpp
Settings/SettingValue.cpp
EffectsEngine/EffectsEngine.cpp
EffectsEngine/Effect.cpp
Library/Library.cpp
Library/MediaContainer.cpp
LibVLCpp/VLCInstance.cpp
......@@ -25,6 +25,8 @@ SET(VLMC_SRCS
Renderer/GenericRenderer.cpp
Renderer/WorkflowFileRenderer.cpp
Renderer/WorkflowRenderer.cpp
Settings/SettingsManager.cpp
Settings/SettingValue.cpp
Tools/ErrorHandler.cpp
Tools/Pool.hpp
Tools/QSingleton.hpp
......@@ -51,8 +53,8 @@ ELSE (WIN32)
ENDIF(WIN32)
SET (VLMC_HDRS
Settings/SettingsManager.h
Settings/SettingValue.h
EffectsEngine/EffectsEngine.h
EffectsEngine/Effect.h
Library/Library.h
Library/MediaContainer.h
LibVLCpp/VLCInstance.h
......@@ -68,6 +70,8 @@ SET (VLMC_HDRS
Renderer/GenericRenderer.h
Renderer/WorkflowFileRenderer.h
Renderer/WorkflowRenderer.h
Settings/SettingsManager.h
Settings/SettingValue.h
Tools/ErrorHandler.h
Tools/VlmcDebug.h
Workflow/AudioClipWorkflow.h
......@@ -96,6 +100,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/src
.
Commands
EffectsEngine
Settings
Gui
Gui/import
......@@ -114,6 +119,7 @@ INCLUDE_DIRECTORIES(
Renderer
Tools
Workflow
${CMAKE_SOURCE_DIR}/extras
)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
......
/*****************************************************************************
* Effect.cpp: Handle a frei0r effect.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Effect.h"
#include "frei0r/frei0r.h"
#include <QtDebug>
Effect::Effect( const QString &fileName ) :
QLibrary( fileName ),
m_instance( NULL ),
m_width( 0 ),
m_height( 0 )
{
}
Effect::~Effect()
{
if ( m_instance != NULL )
{
m_f0r_deinit();
m_f0r_destruct( m_instance );
}
}
#define LOAD_FREI0R_SYMBOL( dest, symbolName ) \
if ( ( dest = reinterpret_cast<typeof( dest )>( resolve( symbolName ) ) ) == NULL ) \
{ \
qCritical() << "Failed to load symbol:" << symbolName; \
return false; \
}
bool
Effect::load()
{
LOAD_FREI0R_SYMBOL( m_f0r_init, "f0r_init" );
LOAD_FREI0R_SYMBOL( m_f0r_deinit, "f0r_deinit" )
LOAD_FREI0R_SYMBOL( m_f0r_info, "f0r_get_plugin_info" )
LOAD_FREI0R_SYMBOL( m_f0r_construct, "f0r_construct" )
LOAD_FREI0R_SYMBOL( m_f0r_destruct, "f0r_destruct" )
LOAD_FREI0R_SYMBOL( m_f0r_update, "f0r_update" )
//Initializing structures
f0r_plugin_info_t infos;
m_f0r_info( &infos );
m_name = infos.name;
m_desc = infos.explanation;
return true;
}
#undef LOAD_FREI0R_SYMBOL
const QString&
Effect::name() const
{
return m_name;
}
const QString&
Effect::description() const
{
return m_desc;
}
void
Effect::init( quint32 width, quint32 height )
{
if ( width != m_width || height != m_height )
{
if ( m_instance != NULL )
{
m_f0r_deinit();
m_f0r_destruct( m_instance );
}
m_instance = m_f0r_construct( width, height );
m_f0r_init();
m_width = width;
m_height = height;
}
}
void
Effect::process( double time, const quint32 *input, quint32 *output ) const
{
m_f0r_update( m_instance, time, input, output );
}
/*****************************************************************************
* Effect.h: Handle a frei0r effect.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef EFFECT_H
#define EFFECT_H
#include <QLibrary>
#include "frei0r/frei0r.h"
class Effect : public QLibrary
{
public:
enum Type
{
Filter = F0R_PLUGIN_TYPE_FILTER,
Source = F0R_PLUGIN_TYPE_SOURCE,
Mixer2 = F0R_PLUGIN_TYPE_MIXER2,
Mixer3 = F0R_PLUGIN_TYPE_MIXER3
};
typedef int (*f0r_init_t)();
typedef void (*f0r_deinit_t)();
typedef void (*f0r_get_info_t)(f0r_plugin_info_t*);
typedef f0r_instance_t (*f0r_construct_t)( unsigned int, unsigned int );
typedef void (*f0r_destruct_t)( f0r_instance_t );
typedef void (*f0r_update_t)( f0r_instance_t, double, const unsigned int*, unsigned int * );
Effect( const QString& fileName );
virtual ~Effect();
bool load();
const QString& name() const;
const QString& description() const;
void init( quint32 width, quint32 height );
void process( double time, const quint32* input, quint32* output ) const;
private:
f0r_init_t m_f0r_init;
f0r_deinit_t m_f0r_deinit;
f0r_get_info_t m_f0r_info;
f0r_construct_t m_f0r_construct;
f0r_destruct_t m_f0r_destruct;
f0r_update_t m_f0r_update;
f0r_instance_t m_instance;
QString m_name;
QString m_desc;
quint32 m_width;
quint32 m_height;
};
#endif // EFFECT_H
/*****************************************************************************
* EffectsEngine.cpp: Manage the effects plugins.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "EffectsEngine.h"
#include "Effect.h"
EffectsEngine::EffectsEngine()
{
Effect *e = new Effect("libbw0r");
m_effects.push_back( e );
}
EffectsEngine::~EffectsEngine()
{
}
void
EffectsEngine::initAll( quint32 width, quint32 height )
{
foreach ( Effect *e, m_effects )
e->init( width, height );
}
Effect*
EffectsEngine::effect( qint32 idx )
{
return m_effects.at( idx );
}
/*****************************************************************************
* EffectsEngine.h: Manage the effects plugins.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef EFFECTSENGINE_H
#define EFFECTSENGINE_H
#include "Singleton.hpp"
class Effect;
#include <QList>
class EffectsEngine : public Singleton<EffectsEngine>
{
public:
void initAll( quint32 width, quint32 height );
Effect* effect( qint32 idx );
private:
EffectsEngine();
~EffectsEngine();
QList<Effect*> m_effects;
friend class Singleton<EffectsEngine>;
};
#endif // EFFECTSENGINE_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