init
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
PROJECT(openvibe-plugins-tests)
|
||||
|
||||
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
|
||||
SET(PROJECT_VERSION ${OV_GLOBAL_VERSION_STRING})
|
||||
|
||||
FILE(GLOB_RECURSE SRC_FILES src/*.cpp src/*.h src/*.inl)
|
||||
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC_FILES})
|
||||
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
FOLDER ${PLUGINS_FOLDER}
|
||||
COMPILE_FLAGS "-DOVP_Exports -DOVP_Shared")
|
||||
|
||||
# ---------------------------------
|
||||
INCLUDE("FindOpenViBE")
|
||||
INCLUDE("FindOpenViBECommon")
|
||||
INCLUDE("FindOpenViBEToolkit")
|
||||
INCLUDE("FindOpenViBEModuleEBML")
|
||||
INCLUDE("FindOpenViBEModuleXML")
|
||||
|
||||
# -----------------------------
|
||||
# Install files
|
||||
# -----------------------------
|
||||
INSTALL(TARGETS ${PROJECT_NAME}
|
||||
RUNTIME DESTINATION ${DIST_BINDIR}
|
||||
LIBRARY DESTINATION ${DIST_LIBDIR}
|
||||
ARCHIVE DESTINATION ${DIST_LIBDIR})
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* \page BoxAlgorithm_CodecToolkitTestbox Codec Toolkit testbox
|
||||
__________________________________________________________________
|
||||
|
||||
Detailed description
|
||||
__________________________________________________________________
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Description|
|
||||
The purpose of this box is to test the \ref Doc_Tutorial_Developer_SignalProcessing_CodecToolkit_Ref "Codec Toolkit".
|
||||
This box is able to read data from any type of input. It extract some information from the incoming chunks and print it in the console.
|
||||
An output chunk is then generated as a full copy on the corresponding output, as the \ref BoxAlgorithm_Identity Identity box does.
|
||||
|
||||
For more information on the Codec Toolkit, please read the \ref Doc_Tutorial_Developer_SignalProcessing_CodecToolkit "dedicated tutorial" that presents the implementatio of this box.
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Description|
|
||||
__________________________________________________________________
|
||||
|
||||
Inputs description
|
||||
__________________________________________________________________
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Inputs|
|
||||
All possible types of input are represented.
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Inputs|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input1|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input1|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input2|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input2|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input3|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input3|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input4|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input4|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input5|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input5|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input6|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input6|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Input7|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Input7|
|
||||
__________________________________________________________________
|
||||
|
||||
Outputs description
|
||||
__________________________________________________________________
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Outputs|
|
||||
All possible types of output are represented.
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Outputs|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output1|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output1|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output2|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output2|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output3|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output3|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output4|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output4|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output5|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output5|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output6|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output6|
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Output7|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Output7|
|
||||
__________________________________________________________________
|
||||
|
||||
Examples description
|
||||
__________________________________________________________________
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Examples|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Examples|
|
||||
__________________________________________________________________
|
||||
|
||||
Miscellaneous description
|
||||
__________________________________________________________________
|
||||
|
||||
* |OVP_DocBegin_BoxAlgorithm_CodecToolkitTestbox_Miscellaneous|
|
||||
* |OVP_DocEnd_BoxAlgorithm_CodecToolkitTestbox_Miscellaneous|
|
||||
*/
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#include "ovpCAlgorithmAddition.h"
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
|
||||
bool CAlgorithmAddition::initialize()
|
||||
{
|
||||
m_parameter1.initialize(getInputParameter(CIdentifier(0, 1)));
|
||||
m_parameter2.initialize(getInputParameter(CIdentifier(0, 2)));
|
||||
m_parameter3.initialize(getOutputParameter(CIdentifier(0, 3)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAlgorithmAddition::uninitialize()
|
||||
{
|
||||
m_parameter3.uninitialize();
|
||||
m_parameter2.uninitialize();
|
||||
m_parameter1.uninitialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAlgorithmAddition::process()
|
||||
{
|
||||
m_parameter3 = m_parameter1 + m_parameter2;
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ovp_defines.h"
|
||||
|
||||
#include <openvibe/ov_all.h>
|
||||
|
||||
#include <toolkit/ovtk_all.h>
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
class CAlgorithmAddition final : public Toolkit::TAlgorithm<IAlgorithm>
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { delete this; }
|
||||
|
||||
bool initialize() override;
|
||||
bool uninitialize() override;
|
||||
bool process() override;
|
||||
|
||||
_IsDerivedFromClass_Final_(Toolkit::TAlgorithm<IAlgorithm>, OVP_ClassId_AlgorithmAddition)
|
||||
|
||||
protected:
|
||||
|
||||
Kernel::TParameterHandler<int64_t> m_parameter1;
|
||||
Kernel::TParameterHandler<int64_t> m_parameter2;
|
||||
Kernel::TParameterHandler<int64_t> m_parameter3;
|
||||
};
|
||||
|
||||
class CAlgorithmAdditionDesc final : public IAlgorithmDesc
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { }
|
||||
|
||||
CString getName() const override { return CString("Addition"); }
|
||||
CString getAuthorName() const override { return CString("Yann Renard"); }
|
||||
CString getAuthorCompanyName() const override { return CString("INRIA/IRISA"); }
|
||||
CString getShortDescription() const override { return CString("Computes and outputs the sum of two inputs"); }
|
||||
CString getDetailedDescription() const override { return CString(""); }
|
||||
CString getCategory() const override { return CString("Tests"); }
|
||||
CString getVersion() const override { return CString("1.0"); }
|
||||
|
||||
CIdentifier getCreatedClass() const override { return OVP_ClassId_AlgorithmAddition; }
|
||||
IPluginObject* create() override { return new CAlgorithmAddition(); }
|
||||
|
||||
bool getAlgorithmPrototype(Kernel::IAlgorithmProto& prototype) const override
|
||||
{
|
||||
prototype.addInputParameter(CIdentifier(0, 1), "First addition operand", Kernel::ParameterType_Integer);
|
||||
prototype.addInputParameter(CIdentifier(0, 2), "Second addition operand", Kernel::ParameterType_Integer);
|
||||
prototype.addOutputParameter(CIdentifier(0, 3), "Addition result", Kernel::ParameterType_Integer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_IsDerivedFromClass_Final_(IAlgorithmDesc, OVP_ClassId_AlgorithmAdditionDesc)
|
||||
};
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#include "ovpCBoxAlgorithmAdditionTest.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
|
||||
bool CBoxAlgorithmAdditionTest::initialize()
|
||||
{
|
||||
CString level;
|
||||
getStaticBoxContext().getSettingValue(0, level);
|
||||
m_logLevel = Kernel::ELogLevel(getTypeManager().getEnumerationEntryValueFromName(OV_TypeId_LogLevel, level));
|
||||
|
||||
m_proxy1 = &getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_ClassId_AlgorithmAddition));
|
||||
m_proxy2 = &getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_ClassId_AlgorithmAddition));
|
||||
m_proxy3 = &getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_ClassId_AlgorithmAddition));
|
||||
|
||||
m_proxy1->initialize();
|
||||
m_proxy2->initialize();
|
||||
m_proxy3->initialize();
|
||||
|
||||
m_proxy1->getInputParameter(CIdentifier(0, 1))->setReferenceTarget(&m_i1);
|
||||
m_proxy1->getInputParameter(CIdentifier(0, 2))->setReferenceTarget(&m_i2);
|
||||
m_proxy2->getInputParameter(CIdentifier(0, 1))->setReferenceTarget(&m_i3);
|
||||
m_proxy2->getInputParameter(CIdentifier(0, 2))->setReferenceTarget(&m_i4);
|
||||
m_proxy3->getInputParameter(CIdentifier(0, 1))->setReferenceTarget(m_proxy1->getOutputParameter(CIdentifier(0, 3)));
|
||||
m_proxy3->getInputParameter(CIdentifier(0, 2))->setReferenceTarget(m_proxy2->getOutputParameter(CIdentifier(0, 3)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoxAlgorithmAdditionTest::uninitialize()
|
||||
{
|
||||
m_proxy1->uninitialize();
|
||||
m_proxy2->uninitialize();
|
||||
m_proxy3->uninitialize();
|
||||
|
||||
getAlgorithmManager().releaseAlgorithm(*m_proxy1);
|
||||
getAlgorithmManager().releaseAlgorithm(*m_proxy2);
|
||||
getAlgorithmManager().releaseAlgorithm(*m_proxy3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoxAlgorithmAdditionTest::processClock(Kernel::CMessageClock& /*msg*/)
|
||||
{
|
||||
m_i1 = (rand() % 100);
|
||||
m_i2 = (rand() % 100) * 100;
|
||||
m_i3 = (rand() % 100) * 10000;
|
||||
m_i4 = (rand() % 100) * 1000000;
|
||||
|
||||
m_proxy1->process();
|
||||
m_proxy2->process();
|
||||
m_proxy3->process();
|
||||
|
||||
const Kernel::TParameterHandler<int64_t> parameter11(m_proxy1->getInputParameter(CIdentifier(0, 1))),
|
||||
parameter12(m_proxy1->getInputParameter(CIdentifier(0, 2))),
|
||||
parameter13(m_proxy1->getOutputParameter(CIdentifier(0, 3))),
|
||||
parameter21(m_proxy2->getInputParameter(CIdentifier(0, 1))),
|
||||
parameter22(m_proxy2->getInputParameter(CIdentifier(0, 2))),
|
||||
parameter23(m_proxy2->getOutputParameter(CIdentifier(0, 3))),
|
||||
parameter31(m_proxy3->getInputParameter(CIdentifier(0, 1))),
|
||||
parameter32(m_proxy3->getInputParameter(CIdentifier(0, 2))),
|
||||
parameter33(m_proxy3->getOutputParameter(CIdentifier(0, 3)));
|
||||
|
||||
getLogManager() << m_logLevel << "paramater_1_1 = " << parameter11 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_1_2 = " << parameter12 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_1_3 = " << parameter13 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_2_1 = " << parameter21 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_2_2 = " << parameter22 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_2_3 = " << parameter23 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_3_1 = " << parameter31 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_3_2 = " << parameter32 << "\n";
|
||||
getLogManager() << m_logLevel << "paramater_3_3 = " << parameter33 << "\n";
|
||||
getLogManager() << m_logLevel << "------------------\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBoxAlgorithmAdditionTest::process() { return true; }
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ovp_defines.h"
|
||||
#include <openvibe/ov_all.h>
|
||||
#include <toolkit/ovtk_all.h>
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
class CBoxAlgorithmAdditionTest final : public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
|
||||
{
|
||||
public:
|
||||
|
||||
CBoxAlgorithmAdditionTest() {}
|
||||
|
||||
void release() override { delete this; }
|
||||
|
||||
uint64_t getClockFrequency() override { return uint64_t(1LL) << 36; }
|
||||
bool initialize() override;
|
||||
bool uninitialize() override;
|
||||
bool processClock(Kernel::CMessageClock& msg) override;
|
||||
bool process() override;
|
||||
|
||||
_IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_BoxAlgorithmAdditionTest)
|
||||
|
||||
protected:
|
||||
|
||||
Kernel::ELogLevel m_logLevel = Kernel::LogLevel_None;
|
||||
|
||||
int64_t m_i1 = 0;
|
||||
int64_t m_i2 = 0;
|
||||
int64_t m_i3 = 0;
|
||||
int64_t m_i4 = 0;
|
||||
|
||||
Kernel::IAlgorithmProxy* m_proxy1 = nullptr;
|
||||
Kernel::IAlgorithmProxy* m_proxy2 = nullptr;
|
||||
Kernel::IAlgorithmProxy* m_proxy3 = nullptr;
|
||||
};
|
||||
|
||||
class CBoxAlgorithmAdditionTestDesc final : public IBoxAlgorithmDesc
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { }
|
||||
|
||||
CString getName() const override { return CString("Addition Test"); }
|
||||
CString getAuthorName() const override { return CString("Yann Renard"); }
|
||||
CString getAuthorCompanyName() const override { return CString("INRIA/IRISA"); }
|
||||
CString getShortDescription() const override { return CString("This box illustrates how an algorithm can be used in a box"); }
|
||||
|
||||
CString getDetailedDescription() const override
|
||||
{
|
||||
return CString("This specific sample computes 4 random numbers and uses 3 sum operator algorithms in order to get the total");
|
||||
}
|
||||
|
||||
CString getCategory() const override { return CString("Tests"); }
|
||||
CString getVersion() const override { return CString("1.0"); }
|
||||
|
||||
CIdentifier getCreatedClass() const override { return OVP_ClassId_BoxAlgorithmAdditionTest; }
|
||||
IPluginObject* create() override { return new CBoxAlgorithmAdditionTest(); }
|
||||
|
||||
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
|
||||
{
|
||||
prototype.addSetting("Log level to use", OV_TypeId_LogLevel, "Information");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithmAdditionTestDesc)
|
||||
};
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#include "ovpCCrashingBox.h"
|
||||
#include <cmath> // For unix system
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
|
||||
bool CCrashingBox::initialize(Kernel::IBoxAlgorithmContext& /*context*/) { throw 0; }
|
||||
|
||||
bool CCrashingBox::uninitialize(Kernel::IBoxAlgorithmContext& /*context*/)
|
||||
{
|
||||
const int one = int(1.0);
|
||||
const int zero = int(sin(0.0));
|
||||
const int div = one / zero;
|
||||
return div ? true : false;
|
||||
}
|
||||
|
||||
bool CCrashingBox::processInput(Kernel::IBoxAlgorithmContext& context, const size_t /*index*/)
|
||||
{
|
||||
context.markAlgorithmAsReadyToProcess();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCrashingBox::process(Kernel::IBoxAlgorithmContext& /*context*/)
|
||||
{
|
||||
*static_cast<int*>(nullptr) = 0;
|
||||
return true;
|
||||
}
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ovp_defines.h"
|
||||
|
||||
#include <openvibe/ov_all.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
class CCrashingBox final : public IBoxAlgorithm
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { delete this; }
|
||||
|
||||
bool initialize(Kernel::IBoxAlgorithmContext& context) override;
|
||||
bool uninitialize(Kernel::IBoxAlgorithmContext& context) override;
|
||||
|
||||
bool processInput(Kernel::IBoxAlgorithmContext& context, const size_t index) override;
|
||||
bool process(Kernel::IBoxAlgorithmContext& context) override;
|
||||
|
||||
_IsDerivedFromClass_Final_(IBoxAlgorithm, OVP_ClassId_CrashingBox)
|
||||
};
|
||||
|
||||
class CCrashingBoxDesc final : public IBoxAlgorithmDesc
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { }
|
||||
CString getName() const override { return CString("Crashing box"); }
|
||||
CString getAuthorName() const override { return CString("Yann Renard"); }
|
||||
CString getAuthorCompanyName() const override { return CString("INRIA/IRISA"); }
|
||||
CString getShortDescription() const override { return CString("A box which code launches exceptions"); }
|
||||
|
||||
CString getDetailedDescription() const override { return CString("This box illustrates the behavior of the platform given a crashing plugin code"); }
|
||||
|
||||
CString getCategory() const override { return CString("Tests"); }
|
||||
CString getVersion() const override { return CString("1.0"); }
|
||||
|
||||
CIdentifier getCreatedClass() const override { return OVP_ClassId_CrashingBox; }
|
||||
IPluginObject* create() override { return new CCrashingBox(); }
|
||||
|
||||
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
|
||||
{
|
||||
prototype.addInput("an input", CIdentifier::undefined());
|
||||
return true;
|
||||
}
|
||||
|
||||
CString getStockItemName() const override { return CString("gtk-cancel"); }
|
||||
|
||||
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_CrashingBoxDesc)
|
||||
};
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
#include "ovpCTestCodecToolkit.h"
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
|
||||
|
||||
bool CTestCodecToolkit::initialize()
|
||||
{
|
||||
// You can also manipulate pointers to Codec object. Creation and destruction must be done like that :
|
||||
Toolkit::TStreamedMatrixDecoder<CTestCodecToolkit>* matrixDecoder = new Toolkit::TStreamedMatrixDecoder<CTestCodecToolkit>(*this, 0);
|
||||
delete matrixDecoder;
|
||||
Toolkit::TStreamedMatrixEncoder<CTestCodecToolkit>* matrixEncoder = new Toolkit::TStreamedMatrixEncoder<CTestCodecToolkit>(*this, 0);
|
||||
delete matrixEncoder;
|
||||
|
||||
Toolkit::TChannelLocalisationDecoder<CTestCodecToolkit>* channelLocalisationDecoder = new Toolkit::TChannelLocalisationDecoder<CTestCodecToolkit>(*this, 1);
|
||||
delete channelLocalisationDecoder;
|
||||
Toolkit::TChannelLocalisationEncoder<CTestCodecToolkit>* channelLocalisationEncoder = new Toolkit::TChannelLocalisationEncoder<CTestCodecToolkit>(*this, 1);
|
||||
delete channelLocalisationEncoder;
|
||||
|
||||
Toolkit::TFeatureVectorDecoder<CTestCodecToolkit>* vectorDecoder = new Toolkit::TFeatureVectorDecoder<CTestCodecToolkit>(*this, 2);
|
||||
delete vectorDecoder;
|
||||
Toolkit::TFeatureVectorEncoder<CTestCodecToolkit>* vectorEncoder = new Toolkit::TFeatureVectorEncoder<CTestCodecToolkit>(*this, 2);
|
||||
delete vectorEncoder;
|
||||
|
||||
Toolkit::TSpectrumDecoder<CTestCodecToolkit>* spectrumDecoder = new Toolkit::TSpectrumDecoder<CTestCodecToolkit>(*this, 3);
|
||||
delete spectrumDecoder;
|
||||
Toolkit::TSpectrumEncoder<CTestCodecToolkit>* spectrumEncoder = new Toolkit::TSpectrumEncoder<CTestCodecToolkit>(*this, 3);
|
||||
delete spectrumEncoder;
|
||||
|
||||
Toolkit::TSignalDecoder<CTestCodecToolkit>* signalDecoder = new Toolkit::TSignalDecoder<CTestCodecToolkit>(*this, 4);
|
||||
delete signalDecoder;
|
||||
Toolkit::TSignalEncoder<CTestCodecToolkit>* signalEncoder = new Toolkit::TSignalEncoder<CTestCodecToolkit>(*this, 4);
|
||||
delete signalEncoder;
|
||||
|
||||
Toolkit::TStimulationDecoder<CTestCodecToolkit>* stimulationDecoder = new Toolkit::TStimulationDecoder<CTestCodecToolkit>(*this, 5);
|
||||
delete stimulationDecoder;
|
||||
Toolkit::TStimulationEncoder<CTestCodecToolkit>* stimulationEncoder = new Toolkit::TStimulationEncoder<CTestCodecToolkit>(*this, 5);
|
||||
delete stimulationEncoder;
|
||||
|
||||
Toolkit::TExperimentInfoDecoder<CTestCodecToolkit>* experimentInfoDecoder = new Toolkit::TExperimentInfoDecoder<CTestCodecToolkit>(*this, 6);
|
||||
delete experimentInfoDecoder;
|
||||
Toolkit::TExperimentInfoEncoder<CTestCodecToolkit>* experimentInfoEncoder = new Toolkit::TExperimentInfoEncoder<CTestCodecToolkit>(*this, 6);
|
||||
delete experimentInfoEncoder;
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
m_matrixDecoder.initialize(*this, 0);
|
||||
m_streamedMatrixEncoder.initialize(*this, 0);
|
||||
m_streamedMatrixEncoder.getInputMatrix().setReferenceTarget(m_matrixDecoder.getOutputMatrix());
|
||||
m_decoders.push_back(&m_matrixDecoder);
|
||||
m_encoders.push_back(&m_streamedMatrixEncoder);
|
||||
|
||||
m_channelLocalisationDecoder.initialize(*this, 1);
|
||||
m_channelLocalisationEncoder.initialize(*this, 1);
|
||||
m_channelLocalisationEncoder.getInputMatrix().setReferenceTarget(m_channelLocalisationDecoder.getOutputMatrix());
|
||||
m_channelLocalisationEncoder.getInputDynamic().setReferenceTarget(m_channelLocalisationDecoder.getOutputDynamic());
|
||||
m_decoders.push_back(&m_channelLocalisationDecoder);
|
||||
m_encoders.push_back(&m_channelLocalisationEncoder);
|
||||
|
||||
m_featureVectorDecoder.initialize(*this, 2);
|
||||
m_featureVectorEncoder.initialize(*this, 2);
|
||||
m_featureVectorEncoder.getInputMatrix().setReferenceTarget(m_featureVectorDecoder.getOutputMatrix());
|
||||
m_decoders.push_back(&m_featureVectorDecoder);
|
||||
m_encoders.push_back(&m_featureVectorEncoder);
|
||||
|
||||
m_spectrumDecoder.initialize(*this, 3);
|
||||
m_spectrumEncoder.initialize(*this, 3);
|
||||
m_spectrumEncoder.getInputMatrix().setReferenceTarget(m_spectrumDecoder.getOutputMatrix());
|
||||
m_spectrumEncoder.getInputFrequencyAbscissa().setReferenceTarget(m_spectrumDecoder.getOutputFrequencyAbscissa());
|
||||
m_spectrumEncoder.getInputSamplingRate().setReferenceTarget(m_spectrumDecoder.getOutputSamplingRate());
|
||||
m_decoders.push_back(&m_spectrumDecoder);
|
||||
m_encoders.push_back(&m_spectrumEncoder);
|
||||
|
||||
m_signalDecoder.initialize(*this, 4);
|
||||
m_signalEncoder.initialize(*this, 4);
|
||||
m_signalEncoder.getInputMatrix().setReferenceTarget(m_signalDecoder.getOutputMatrix());
|
||||
m_signalEncoder.getInputSamplingRate().setReferenceTarget(m_signalDecoder.getOutputSamplingRate());
|
||||
m_decoders.push_back(&m_signalDecoder);
|
||||
m_encoders.push_back(&m_signalEncoder);
|
||||
|
||||
m_stimDecoder.initialize(*this, 5);
|
||||
m_stimEncoder.initialize(*this, 5);
|
||||
m_stimEncoder.getInputStimulationSet().setReferenceTarget(m_stimDecoder.getOutputStimulationSet());
|
||||
m_decoders.push_back(&m_stimDecoder);
|
||||
m_encoders.push_back(&m_stimEncoder);
|
||||
|
||||
m_experimentInfoDecoder.initialize(*this, 6);
|
||||
m_experimentInfoEncoder.initialize(*this, 6);
|
||||
m_experimentInfoEncoder.getInputExperimentID().setReferenceTarget(m_experimentInfoDecoder.getOutputExperimentID());
|
||||
m_experimentInfoEncoder.getInputExperimentDate().setReferenceTarget(m_experimentInfoDecoder.getOutputExperimentDate());
|
||||
m_experimentInfoEncoder.getInputSubjectID().setReferenceTarget(m_experimentInfoDecoder.getOutputSubjectID());
|
||||
m_experimentInfoEncoder.getInputSubjectName().setReferenceTarget(m_experimentInfoDecoder.getOutputSubjectName());
|
||||
m_experimentInfoEncoder.getInputSubjectAge().setReferenceTarget(m_experimentInfoDecoder.getOutputSubjectAge());
|
||||
m_experimentInfoEncoder.getInputSubjectGender().setReferenceTarget(m_experimentInfoDecoder.getOutputSubjectGender());
|
||||
m_experimentInfoEncoder.getInputLaboratoryID().setReferenceTarget(m_experimentInfoDecoder.getOutputLaboratoryID());
|
||||
m_experimentInfoEncoder.getInputLaboratoryName().setReferenceTarget(m_experimentInfoDecoder.getOutputLaboratoryName());
|
||||
m_experimentInfoEncoder.getInputTechnicianID().setReferenceTarget(m_experimentInfoDecoder.getOutputTechnicianID());
|
||||
m_experimentInfoEncoder.getInputTechnicianName().setReferenceTarget(m_experimentInfoDecoder.getOutputTechnicianName());
|
||||
m_decoders.push_back(&m_experimentInfoDecoder);
|
||||
m_encoders.push_back(&m_experimentInfoEncoder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CTestCodecToolkit::uninitialize()
|
||||
{
|
||||
for (size_t i = 0; i < m_decoders.size(); ++i) { m_decoders[i]->uninitialize(); }
|
||||
for (size_t i = 0; i < m_encoders.size(); ++i) { m_encoders[i]->uninitialize(); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CTestCodecToolkit::processInput(const size_t /*index*/)
|
||||
{
|
||||
this->getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CTestCodecToolkit::process()
|
||||
{
|
||||
Kernel::IBoxIO& boxContext = this->getDynamicBoxContext();
|
||||
const Kernel::IBox& staticBoxContext = this->getStaticBoxContext();
|
||||
|
||||
for (size_t i = 0; i < staticBoxContext.getInputCount(); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < boxContext.getInputChunkCount(i); ++j)
|
||||
{
|
||||
// we can manipulate decoders and encoders without knowing their types
|
||||
m_decoders[i]->decode(j);
|
||||
|
||||
if (m_decoders[i]->isHeaderReceived()) { m_encoders[i]->encodeHeader(); }
|
||||
if (m_decoders[i]->isBufferReceived())
|
||||
{
|
||||
//let's check what is inside the buffer
|
||||
CIdentifier iType;
|
||||
staticBoxContext.getInputType(i, iType);
|
||||
if (iType == OV_TypeId_StreamedMatrix)
|
||||
{
|
||||
CMatrix* matrix = m_matrixDecoder.getOutputMatrix();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Streamed Matrix buffer received (" << matrix->getBufferElementCount() <<
|
||||
" elements in buffer).\n";
|
||||
}
|
||||
else if (iType == OV_TypeId_ChannelLocalisation)
|
||||
{
|
||||
CMatrix* matrix = m_channelLocalisationDecoder.getOutputMatrix();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Channel localisation buffer received (" << matrix->getBufferElementCount() <<
|
||||
" elements in buffer).\n";
|
||||
}
|
||||
else if (iType == OV_TypeId_FeatureVector)
|
||||
{
|
||||
CMatrix* matrix = m_featureVectorDecoder.getOutputMatrix();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Feature Vector buffer received (" << matrix->getBufferElementCount() <<
|
||||
" features in vector).\n";
|
||||
}
|
||||
else if (iType == OV_TypeId_Spectrum)
|
||||
{
|
||||
CMatrix* matrix = m_spectrumDecoder.getOutputFrequencyAbscissa();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Spectrum frequencies abscissas received (" << matrix->getBufferElementCount() <<
|
||||
" elements in matrix).\n";
|
||||
}
|
||||
else if (iType == OV_TypeId_Signal)
|
||||
{
|
||||
CMatrix* matrix = m_signalDecoder.getOutputMatrix();
|
||||
uint64_t sampling = m_signalDecoder.getOutputSamplingRate();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Signal buffer received (" << matrix->getBufferElementCount() <<
|
||||
" elements in buffer) with sampling frequency " << sampling << "Hz.\n";
|
||||
}
|
||||
else if (iType == OV_TypeId_Stimulations)
|
||||
{
|
||||
IStimulationSet* stimSet = m_stimDecoder.getOutputStimulationSet();
|
||||
// as we constantly receive stimulations on the stream, we will check if the incoming set is empty or not
|
||||
if (stimSet->getStimulationCount() != 0)
|
||||
{
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Stimulation Set buffer received (1st stim is ["
|
||||
<< stimSet->getStimulationIdentifier(0) << ":"
|
||||
<< this->getTypeManager().getEnumerationEntryNameFromValue(OV_TypeId_Stimulation, stimSet->getStimulationIdentifier(0))
|
||||
<< "]).\n";
|
||||
m_stimEncoder.getInputStimulationSet()->clear();
|
||||
m_stimEncoder.getInputStimulationSet()->appendStimulation(stimSet->getStimulationIdentifier(0) + 1, stimSet->getStimulationDate(0), 0);
|
||||
}
|
||||
}
|
||||
else if (iType == OV_TypeId_ExperimentInfo)
|
||||
{
|
||||
uint64_t xPid = m_experimentInfoDecoder.getOutputExperimentID();
|
||||
this->getLogManager() << Kernel::LogLevel_Info << "Experiment information buffer received (xp ID: " << xPid << ").\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getLogManager() << Kernel::LogLevel_Error << "Undefined input type.\n";
|
||||
return true;
|
||||
}
|
||||
m_encoders[i]->encodeBuffer();
|
||||
}
|
||||
if (m_decoders[i]->isEndReceived()) { m_encoders[i]->encodeEnd(); }
|
||||
boxContext.markOutputAsReadyToSend(i, boxContext.getInputChunkStartTime(i, j), boxContext.getInputChunkEndTime(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ovp_defines.h"
|
||||
#include <openvibe/ov_all.h>
|
||||
#include <toolkit/ovtk_all.h>
|
||||
#include <vector>
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
class CTestCodecToolkit final : public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { delete this; }
|
||||
|
||||
bool initialize() override;
|
||||
bool uninitialize() override;
|
||||
bool processInput(const size_t index) override;
|
||||
bool process() override;
|
||||
|
||||
_IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_TestCodecToolkit)
|
||||
|
||||
protected:
|
||||
|
||||
Toolkit::TStreamedMatrixDecoder<CTestCodecToolkit> m_matrixDecoder;
|
||||
Toolkit::TStreamedMatrixEncoder<CTestCodecToolkit> m_streamedMatrixEncoder;
|
||||
|
||||
Toolkit::TChannelLocalisationDecoder<CTestCodecToolkit> m_channelLocalisationDecoder;
|
||||
Toolkit::TChannelLocalisationEncoder<CTestCodecToolkit> m_channelLocalisationEncoder;
|
||||
|
||||
Toolkit::TFeatureVectorDecoder<CTestCodecToolkit> m_featureVectorDecoder;
|
||||
Toolkit::TFeatureVectorEncoder<CTestCodecToolkit> m_featureVectorEncoder;
|
||||
|
||||
Toolkit::TSpectrumDecoder<CTestCodecToolkit> m_spectrumDecoder;
|
||||
Toolkit::TSpectrumEncoder<CTestCodecToolkit> m_spectrumEncoder;
|
||||
|
||||
Toolkit::TSignalDecoder<CTestCodecToolkit> m_signalDecoder;
|
||||
Toolkit::TSignalEncoder<CTestCodecToolkit> m_signalEncoder;
|
||||
|
||||
Toolkit::TStimulationDecoder<CTestCodecToolkit> m_stimDecoder;
|
||||
Toolkit::TStimulationEncoder<CTestCodecToolkit> m_stimEncoder;
|
||||
|
||||
Toolkit::TExperimentInfoDecoder<CTestCodecToolkit> m_experimentInfoDecoder;
|
||||
Toolkit::TExperimentInfoEncoder<CTestCodecToolkit> m_experimentInfoEncoder;
|
||||
|
||||
/* One decoder per input. This vector makes easy the decoding in one iteration over the inputs. */
|
||||
std::vector<Toolkit::TDecoder<CTestCodecToolkit>*> m_decoders;
|
||||
|
||||
/* One encoder per output This vector makes easy the encoding in one iteration over the outputs. */
|
||||
std::vector<Toolkit::TEncoder<CTestCodecToolkit>*> m_encoders;
|
||||
};
|
||||
|
||||
class CTestCodecToolkitDesc final : public IBoxAlgorithmDesc
|
||||
{
|
||||
public:
|
||||
|
||||
void release() override { }
|
||||
|
||||
CString getName() const override { return CString("Codec Toolkit testbox"); }
|
||||
CString getAuthorName() const override { return CString("Laurent Bonnet"); }
|
||||
CString getAuthorCompanyName() const override { return CString("INRIA"); }
|
||||
|
||||
CString getShortDescription() const override { return CString("Sample box to test the codec toolkit. Identity (input = output)."); }
|
||||
|
||||
CString getDetailedDescription() const override { return CString(""); }
|
||||
CString getCategory() const override { return CString("Tests/Algorithms"); }
|
||||
CString getVersion() const override { return CString("1.0"); }
|
||||
CString getStockItemName() const override { return CString("gtk-execute"); }
|
||||
|
||||
CIdentifier getCreatedClass() const override { return OVP_ClassId_TestCodecToolkit; }
|
||||
IPluginObject* create() override { return new CTestCodecToolkit; }
|
||||
|
||||
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
|
||||
{
|
||||
prototype.addInput("Streamed Matrix", OV_TypeId_StreamedMatrix);
|
||||
prototype.addOutput("Streamed Matrix", OV_TypeId_StreamedMatrix);
|
||||
|
||||
prototype.addInput("Channel Localisation", OV_TypeId_ChannelLocalisation);
|
||||
prototype.addOutput("Channel Localisation", OV_TypeId_ChannelLocalisation);
|
||||
|
||||
prototype.addInput("Feature Vector", OV_TypeId_FeatureVector);
|
||||
prototype.addOutput("Feature Vector", OV_TypeId_FeatureVector);
|
||||
|
||||
prototype.addInput("Spectrum", OV_TypeId_Spectrum);
|
||||
prototype.addOutput("Spectrum", OV_TypeId_Spectrum);
|
||||
|
||||
prototype.addInput("Signal", OV_TypeId_Signal);
|
||||
prototype.addOutput("Signal", OV_TypeId_Signal);
|
||||
|
||||
prototype.addInput("Stimulations", OV_TypeId_Stimulations);
|
||||
prototype.addOutput("Stimulations", OV_TypeId_Stimulations);
|
||||
|
||||
prototype.addInput("XP info", OV_TypeId_ExperimentInfo);
|
||||
prototype.addOutput("XP info", OV_TypeId_ExperimentInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_TestCodecToolkitDesc)
|
||||
};
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
// Boxes
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
#define OVP_ClassId_AlgorithmAddition OpenViBE::CIdentifier(0x75FCE50E, 0x8302FA91)
|
||||
#define OVP_ClassId_AlgorithmAdditionDesc OpenViBE::CIdentifier(0x842E0B85, 0xA59FABC1)
|
||||
#define OVP_ClassId_BoxAlgorithmAdditionTest OpenViBE::CIdentifier(0x534EB140, 0x15F41496)
|
||||
#define OVP_ClassId_BoxAlgorithmAdditionTestDesc OpenViBE::CIdentifier(0xB33EC315, 0xF63BC0C5)
|
||||
#define OVP_ClassId_CrashingBox OpenViBE::CIdentifier(0x00DAFD60, 0x39A58819)
|
||||
#define OVP_ClassId_CrashingBoxDesc OpenViBE::CIdentifier(0x009F54B9, 0x2B6A4922)
|
||||
#define OVP_ClassId_TestCodecToolkit OpenViBE::CIdentifier(0x330E3A87, 0x31565BA6)
|
||||
#define OVP_ClassId_TestCodecToolkitDesc OpenViBE::CIdentifier(0x376A4712, 0x1AA65567)
|
||||
|
||||
// Global defines
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
|
||||
#include "ovp_global_defines.h"
|
||||
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "ovp_defines.h"
|
||||
|
||||
#include "algorithms/ovpCAlgorithmAddition.h"
|
||||
#include "box-algorithms/ovpCBoxAlgorithmAdditionTest.h"
|
||||
|
||||
#include "box-algorithms/ovpCCrashingBox.h"
|
||||
|
||||
#include "box-algorithms/ovpCTestCodecToolkit.h"
|
||||
|
||||
namespace OpenViBE {
|
||||
namespace Plugins {
|
||||
namespace Tests {
|
||||
|
||||
OVP_Declare_Begin()
|
||||
// OVP_Declare_New(CAlgorithmAdditionDesc);
|
||||
// OVP_Declare_New(CBoxAlgorithmAdditionTestDesc);
|
||||
// OVP_Declare_New(CCrashingBoxDesc);
|
||||
OVP_Declare_New(CTestCodecToolkitDesc);
|
||||
OVP_Declare_End()
|
||||
|
||||
} // namespace Tests
|
||||
} // namespace Plugins
|
||||
} // namespace OpenViBE
|
||||
Reference in New Issue
Block a user