Commit 60db5067 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Removed old, useless, ugly API files.

parent dc739f00
/*****************************************************************************
* Module.cpp: Represents the vlmc's internal representation of a module
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 <QtDebug>
#include "Module.h"
Module::Module( const QFileInfo& moduleFile )
{
qDebug() << "Trying to load module :" << moduleFile.absolutePath() + '/' + moduleFile.baseName();
m_moduleInstance = new QLibrary( moduleFile.absolutePath() + '/' + moduleFile.baseName() );
}
Module::~Module()
{
m_moduleInstance->unload();
delete m_moduleInstance;
}
void Module::initInternalPtr()
{
m_p_module = new vlmc_module_internal_t;
m_p_module->public_module.f_ratio = 0;
m_p_module->public_module.psz_name = NULL;
m_p_module->public_module.p_callbacks = new vlmc_callback_t;
m_p_module->public_module.p_callbacks->pf_open = NULL;
m_p_module->public_module.p_callbacks->pf_close = NULL;
m_p_module->public_module.p_callbacks->pf_process = NULL;
m_p_module->public_module.p_output = new vlmc_output_t;
m_p_module->public_module.p_output->i_height = 0;
m_p_module->public_module.p_output->i_width = 0;
m_p_module->public_module.p_output->p_buffer = NULL;
}
bool Module::initialize()
{
#ifdef Q_WS_WIN
qDebug() << "Loading of modules is currently disabled under Windows.";
return false;
#else
m_entryPoint = reinterpret_cast<vlmc_module_entrypoint_t>( m_moduleInstance->resolve( "vlmc_module_entrypoint" ) );
if ( m_entryPoint == NULL )
{
qDebug() << "Can't find module entry point";
return false;
}
initInternalPtr();
m_entryPoint( reinterpret_cast<vlmc_module_t*>( m_p_module ) );
if ( m_p_module->public_module.psz_name == NULL )
{
qDebug() << "No name set. Invalid module";
return false;
}
return true;
#endif
}
bool Module::isLibrary( const QString& fileName )
{
return QLibrary::isLibrary( fileName );
}
/*****************************************************************************
* Module.h: Represents the vlmc's internal representation of a module
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 MODULE_H
#define MODULE_H
#include <QLibrary>
#include <QFileInfo>
#include "vlmc_module_internal.h"
class Module
{
public:
Module( const QFileInfo& moduleFile );
~Module();
bool initialize();
static bool isLibrary( const QString& fileName );
private:
void initInternalPtr();
private:
QString m_name;
QLibrary* m_moduleInstance;
vlmc_module_entrypoint_t m_entryPoint;
vlmc_module_internal_t* m_p_module;
};
#endif // MODULE_H
/*****************************************************************************
* ModuleManager.cpp: Manage modules loading
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 <QtDebug>
#include <QDir>
#include <QStringList>
#include "ModuleManager.h"
ModuleManager::ModuleManager()
{
}
bool ModuleManager::loadModules()
{
QFileInfo moduleDir( "modules/" );
return loadSubDir( moduleDir );
}
bool ModuleManager::loadSubDir( const QFileInfo& dir )
{
if ( dir.exists() == false || dir.isDir() == false )
return false;
QDir subDir( dir.absoluteFilePath() );
if ( subDir.exists() == false )
{
qDebug() << "Modules directory was not found. This is usually a bad thing.";
return false;
}
subDir.setFilter( QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot );
QStringList nameFilters;
nameFilters << "*.so" << "*.dll" << "*.dynlib";
subDir.setNameFilters( nameFilters );
QFileInfoList results = subDir.entryInfoList();
if ( results.count() == 0 )
return true;
QFileInfoList::const_iterator it = results.begin();
QFileInfoList::const_iterator end = results.end();
while ( it != end )
{
if ( it->isDir() == true )
{
loadSubDir( *it );
}
else
checkAndAddModule( *it );
++it;
}
return true;
}
void ModuleManager::checkAndAddModule( const QFileInfo& moduleFile )
{
if ( Module::isLibrary( moduleFile.absoluteFilePath() ) )
{
Module* module = new Module( moduleFile );
if (module->initialize() == false)
{
qDebug() << "Invalid module. Unloading...";
}
}
else
qDebug() << moduleFile.absoluteFilePath() << "isn't a library file";
}
/*****************************************************************************
* ModuleManager.h: Manage modules loading
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 MODULEMANAGER_H
#define MODULEMANAGER_H
#include <QFileInfo>
#include <QHash>
#include "Module.h"
#include "Singleton.hpp"
class ModuleManager : public Singleton<ModuleManager>
{
public:
bool loadModules();
private:
ModuleManager();
bool loadSubDir( const QFileInfo& dir );
void checkAndAddModule( const QFileInfo& moduleFile );
private:
QHash<QString, Module*> m_modules;
friend class Singleton<ModuleManager>;
};
#endif // MODULEMANAGER_H
/*****************************************************************************
* vlcm_module.h: Header to be used by effects modules
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 VLMC_MODULE_H
#define VLMC_MODULE_H
#define VLMC_EXTERN extern "C"
#ifdef __cplusplus
VLMC_EXTERN
{
#endif
typedef struct
{
/* Output buffer */
unsigned char* p_buffer;
/* Output width */
unsigned int i_width;
/* Output height */
unsigned int i_height;
} vlmc_output_t;
enum vlmc_return_type_t
{
VLMC_SUCCESS = 0,
VLMC_INVALID_INPUT_PARAMETER,
VLMC_OUT_OF_MEMORY,
VLMC_UNEXPECTED_ERROR,
};
typedef vlmc_return_type_t (*open_callback_t)( void* );
typedef vlmc_return_type_t (*close_callback_t)( void* );
typedef vlmc_return_type_t (*process_callback_t)( unsigned char*, unsigned int );
typedef struct
{
open_callback_t pf_open;
close_callback_t pf_close;
process_callback_t pf_process;
} vlmc_callback_t;
typedef struct
{
char* psz_name;
float f_ratio;
vlmc_output_t* p_output;
vlmc_callback_t* p_callbacks;
} vlmc_module_t;
#define CPP_CONCATENACK( a, b ) y##__##z
#define CONCATENATE( a, b ) CPP_CONCATENACK( a, b )
#if defined(VLMC_MODULE) && defined( WIN32 )
#define VLMC_EXPORT __declspec(dllexport)
#else
#define VLMC_EXPORT
#endif
#define vlmc_module_begin() \
VLMC_EXTERN VLMC_EXPORT vlmc_return_type_t vlmc_module_entrypoint( vlmc_module_t* p_module ) \
{
#define vlmc_module_end() \
return VLMC_SUCCESS; \
}
#define vlmc_set_callbacks( open, close ) \
p_module->p_callbacks->pf_open = open; \
p_module->p_callbacks->pf_close = close;
#ifdef __cplusplus
}
#endif
#define create_p_module( void_var ) \
vlmc_module_t* p_module = (vlmc_module_t*) void_var;\
/*
* Function part :
*/
vlmc_return_type_t vlmc_add_variable_int( vlmc_module_t* p_module, const char* psz_varname, int value );
#endif // VLMC_MODULE_H
/*****************************************************************************
* vlmc_module_internal.h: Represents the vlmc's internal representation of a module
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 VLMC_MODULE_INTERNAL_H
#define VLMC_MODULE_INTERNAL_H
#include "vlmc_module.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef vlmc_return_type_t (*vlmc_module_entrypoint_t)( vlmc_module_t* );
typedef struct
{
vlmc_module_t public_module;
} vlmc_module_internal_t;
#ifdef __cplusplus
}
#endif
#endif // VLMC_MODULE_INTERNAL_H
#include <QtDebug>
#include "vlmc_module.h"
vlmc_return_type_t vlmc_add_variable_int( vlmc_module_t* p_module, const char* psz_varname, int value )
{
Q_UNUSED( p_module );
Q_UNUSED( psz_varname );
Q_UNUSED( value );
qDebug() << "Setting variable";
return VLMC_SUCCESS;
}
......@@ -5,9 +5,6 @@ SUBDIRS(EffectsEngine/Plugins/src)
SET(VLMC_SRCS
main.cpp
API/Module.cpp
API/ModuleManager.cpp
API/vlmc_module_variables.cpp
Commands/Commands.cpp
Commands/KeyboardShortcutHelper.cpp
Configuration/ProjectSettingsDefault.cpp
......@@ -239,7 +236,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
.
API
Commands
Configuration
EffectsEngine
......
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