Commit eff9451d authored by Vincent Carrubba's avatar Vincent Carrubba

Finally the effects engine works

parent 54a197fa
......@@ -8,16 +8,16 @@ EffectsEngine::EffectsEngine( void )
quint32 i;
m_inputLock = new QReadWriteLock;
for (i = 0; i < 64; ++i)
m_videoInputs[i];
for (i = 0; i < 1; ++i)
m_videoOutputs[i];
m_videoInputs = new OutSlot<LightVideoFrame>[64];
m_videoOutputs = new InSlot<LightVideoFrame>[64];
start();
}
EffectsEngine::~EffectsEngine()
{
stop();
delete [] m_videoInputs;
delete [] m_videoOutputs;
delete m_inputLock;
}
......@@ -65,7 +65,7 @@ void EffectsEngine::setInputFrame( LightVideoFrame& frame, quint32 tracknumber )
LightVideoFrame const & EffectsEngine::getOutputFrame( quint32 tracknumber ) const
{
return m_videoOutputs[tracknumber];
return ( m_videoOutputs[tracknumber] );
}
//
......
......@@ -61,8 +61,8 @@ class EffectsEngine
private:
QHash< quint32, GenericEffect* > m_effects;
QHash< quint32, OutSlot<LightVideoFrame> > m_videoInputs; // It's OutSlots because, it's the Outputs of the workflow, that should be connected to InSlots of effects
QHash< quint32, InSlot<LightVideoFrame> > m_videoOutputs; // It's InSlots because, it's the Inputs of the effect engine, that should be connected to OutSlots of the renderer
OutSlot<LightVideoFrame>* m_videoInputs; // It's OutSlots because, it's the Outputs of the workflow, that should be connected to InSlots of effects
InSlot<LightVideoFrame>* m_videoOutputs; // It's InSlots because, it's the Inputs of the effect engine, that should be connected to OutSlots of the renderer
/* OutSlot<LightParameter> m_clockInput; // It's OutSlots because, it's the Outputs of the clock of the workflow, that should be connected to OutSlots */
QReadWriteLock* m_inputLock;
......
......@@ -9,8 +9,8 @@ GenericEffect::GenericEffect( char const * videoinputs[], quint32 const nbvideoi
GenericEffect::~GenericEffect()
{
delete m_videoInputs;
delete m_videoOutputs;
delete [] m_videoInputs;
delete [] m_videoOutputs;
}
......
......@@ -24,38 +24,14 @@
#ifndef INSLOT_HPP_
#define INSLOT_HPP_
#include <cstdlib>
#include <QDebug>
template<typename T> class OutSlot;
template<typename T>
class InSlot
{
public:
enum OUTTYPE // DEFINTION OF MANY OUTPUTS TYPES
{
GUI, // OUTPUTS FROM GUI
DEFAULT, // WHEN NO OUTPUTS ARE CONNECTED
NORMAL, // OUTPUT FROM STREAMING
NBTYPES
}; // IT'S SORTED BY PRIORITY
private:
enum PRIORITY
{
LOWER = DEFAULT,
HIGHER = ( NBTYPES - 1 )
};
enum CONSTANTS
{
INFINITE = 0,
ONLYONE = 1
};
friend class OutSlot<T>;
public:
......@@ -63,36 +39,41 @@ public:
// CTOR & DTOR
InSlot();
InSlot( InSlot const & );
InSlot& operator=( InSlot const & );
~InSlot();
// STREAMING
InSlot<T>& operator>>( T & );
operator T const & () const;
InSlot<T> const& operator>>( T & ) const;
operator T const & () const;
// GETTING INFOS
OutSlot<T>* getOutSlotPtr( void );
private:
// CONNECTION & DISCONNECTION
bool connect( OutSlot<T>& );
bool disconnect( OutSlot<T>& );
bool disconnect( void );
// OTHERS
void switchCurrentShared( void );
void setOutSlotPtr( OutSlot<T>* ptr);
void resetOutSlotPtr( void );
void setCurrentSharedToDefault( void );
void setCurrentSharedToShared( void );
private:
T m_shared[NBTYPES];
unsigned int m_nbOutByType[NBTYPES];
static unsigned int m_outNbLimits[NBTYPES];
OUTTYPE m_currentShared;
};
// STATIC MEMBERS INTIALIZATION
static T m_defaultValue;
OutSlot<T>* m_OutSlotPtr;
T m_shared;
T* m_currentShared;
};
template<typename T>
unsigned int InSlot<T>::m_outNbLimits[] = {InSlot<T>::INFINITE, InSlot<T>::INFINITE, InSlot<T>::ONLYONE} ;
T InSlot<T>::m_defaultValue = 0;
/////////////////////////
//// PUBLICS METHODS ////
......@@ -101,36 +82,55 @@ unsigned int InSlot<T>::m_outNbLimits[] = {InSlot<T>::INFINITE, InSlot<T>::INFI
// CTOR & DTOR
template<typename T>
InSlot<T>::InSlot() : m_currentShared( DEFAULT )
InSlot<T>::InSlot()
{
unsigned int type;
resetOutSlotPtr();
setCurrentSharedToDefault();
}
// m_shared[DEFAULT] = 0; // DEFAULT VALUE SET HERE FOR FORWARD THIS WHEN THERE AREN'T OUTSLOTS CONNECTED
template<typename T>
InSlot<T>::InSlot(InSlot const &)
{
resetOutSlotPtr();
setCurrentSharedToDefault();
}
for (type = static_cast<unsigned int>( InSlot<T>::DEFAULT );
type < static_cast<unsigned int>( InSlot<T>::NBTYPES );
++type)
m_nbOutByType[type] = 0;
template<typename T>
InSlot<T>& InSlot<T>::operator=(InSlot const &)
{
resetOutSlotPtr();
setCurrentSharedToDefault();
}
template<typename T>
InSlot<T>::~InSlot()
{
qDebug() << "destruction d'InSlot";
if ( m_OutSlotPtr != NULL)
disconnect();
}
// READING METHODS
template<typename T>
InSlot<T>& InSlot<T>::operator>>( T& val )
InSlot<T> const & InSlot<T>::operator>>( T& val ) const
{
val = m_shared[m_currentShared];
val = *m_currentShared;
return ( (*this) );
}
template<typename T>
InSlot<T>::operator T const & () const
{
return ( m_shared[m_currentShared] );
return ( *m_currentShared );
}
// GETTING INFOS
template<typename T>
OutSlot<T>* InSlot<T>::getOutSlotPtr( void )
{
return ( m_OutSlotPtr );
}
//////////////////////////
......@@ -147,18 +147,12 @@ InSlot<T>::operator T const & () const
template<typename T>
bool InSlot<T>::connect( OutSlot<T>& toconnect )
{
OUTTYPE type;
type = toconnect.getType();
if ( m_outNbLimits[type] != InSlot<T>::INFINITE)
if ( m_nbOutByType[type] >= m_outNbLimits[type] )
return ( false );
++(m_nbOutByType[type]);
toconnect.setPipe( &m_shared[type] );
if ( m_OutSlotPtr != NULL )
return ( false );
toconnect.setPipe( &m_shared );
toconnect.setInSlotPtr( this );
switchCurrentShared();
setOutSlotPtr( &toconnect );
setCurrentSharedToShared();
return ( true );
}
......@@ -168,32 +162,42 @@ bool InSlot<T>::connect( OutSlot<T>& toconnect )
// So, the OutSlot can be connected and the m_currentShared must be updated
template<typename T>
bool InSlot<T>::disconnect( OutSlot<T>& todisconnect )
bool InSlot<T>::disconnect( void )
{
OUTTYPE type;
if (m_OutSlotPtr == NULL)
return ( false );
m_OutSlotPtr->resetPipe();
m_OutSlotPtr->resetInSlotPtr();
resetOutSlotPtr();
setCurrentSharedToDefault();
return ( true );
}
type = todisconnect.getType();
--(m_nbOutByType[type]);
template<typename T>
void InSlot<T>::setOutSlotPtr( OutSlot<T>* ptr)
{
m_OutSlotPtr = ptr;
return ;
}
todisconnect.resetPipe();
todisconnect.resetInSlotPtr();
template<typename T>
void InSlot<T>::resetOutSlotPtr( void )
{
m_OutSlotPtr = NULL;
return ;
}
switchCurrentShared();
return ( true );
template<typename T>
void InSlot<T>::setCurrentSharedToDefault( void )
{
m_currentShared = &m_defaultValue;
return ;
}
template<typename T>
void InSlot<T>::switchCurrentShared( void )
void InSlot<T>::setCurrentSharedToShared( void )
{
unsigned int priority;
for ( priority = InSlot<T>::HIGHER; priority > InSlot<T>::LOWER; --priority )
{
if ( m_nbOutByType[priority] )
break;
}
m_currentShared = static_cast< typename InSlot<T>::OUTTYPE >( priority );
m_shared[m_currentShared] = m_shared[DEFAULT];
m_currentShared = &m_shared;
return ;
}
......
......@@ -25,7 +25,8 @@
#define OUTSLOT_HPP_
#include "InSlot.hpp"
#include <QtDebug>
#include <QDebug>
template<typename T>
class OutSlot
......@@ -51,15 +52,14 @@ public:
bool connect( InSlot<T>& );
bool disconnect( void );
void setType( typename InSlot<T>::OUTTYPE type );
// GETTING INFOS
InSlot<T>* getInSlotPtr( void );
private:
// OTHERS
typename InSlot<T>::OUTTYPE getType( void ) const;
void setPipe( T* shared );
void resetPipe( void );
void setInSlotPtr( InSlot<T>* );
......@@ -67,8 +67,7 @@ private:
private:
typename InSlot<T>::OUTTYPE m_type;
InSlot<T>* m_connectedTo;
InSlot<T>* m_InSlotPtr;
T m_junk;
T* m_pipe;
};
......@@ -80,28 +79,32 @@ private:
// CTOR & DTOR
template<typename T>
OutSlot<T>::OutSlot() : m_type( InSlot<T>::NORMAL ), m_connectedTo( NULL ), m_pipe( &m_junk )
OutSlot<T>::OutSlot()
{
resetInSlotPtr();
resetPipe();
}
template<typename T>
OutSlot<T>::OutSlot(OutSlot<T> const & tocopy) : m_type( tocopy.m_type ),
m_connectedTo( NULL ),
m_pipe( &m_junk )
OutSlot<T>::OutSlot(OutSlot<T> const & tocopy)
{
resetInSlotPtr();
resetPipe();
}
template<typename T>
OutSlot<T>& OutSlot<T>::operator=(OutSlot<T> const & tocopy)
{
m_type = tocopy.m_type;
m_connectedTo = NULL;
m_pipe = &m_junk;
resetInSlotPtr();
resetPipe();
}
template<typename T>
OutSlot<T>::~OutSlot()
{
qDebug() << "destruction d'OutSlot";
if ( m_InSlotPtr != NULL )
m_InSlotPtr->disconnect();
}
// WRITING METHODS
......@@ -125,30 +128,28 @@ OutSlot<T>& OutSlot<T>::operator<<( T const & val )
template<typename T>
bool OutSlot<T>::connect( InSlot<T>& toconnect )
{
if ( m_connectedTo != NULL )
if ( m_InSlotPtr != NULL )
return ( false );
if ( toconnect.connect( (*this) ) == false)
{
return ( false );
}
return ( false );
return ( true );
}
template<typename T>
bool OutSlot<T>::disconnect( void )
{
if ( m_connectedTo == NULL)
return ( false );
if ( m_connectedTo->disconnect( (*this) ) == false)
if ( m_InSlotPtr == NULL)
return ( false );
m_InSlotPtr->disconnect();
return ( true );
}
// GETTING INFOS
template<typename T>
void OutSlot<T>::setType( typename InSlot<T>::OUTTYPE type )
InSlot<T>* OutSlot<T>::getInSlotPtr( void )
{
m_type = type;
return ;
return ( m_InSlotPtr );
}
//////////////////////////
......@@ -157,12 +158,6 @@ void OutSlot<T>::setType( typename InSlot<T>::OUTTYPE type )
// OTHERS
template<typename T>
typename InSlot<T>::OUTTYPE OutSlot<T>::getType( void ) const
{
return ( m_type );
}
template<typename T>
void OutSlot<T>::setPipe( T* shared )
{
......@@ -180,14 +175,14 @@ void OutSlot<T>::resetPipe( void )
template<typename T>
void OutSlot<T>::setInSlotPtr( InSlot<T>* ptr )
{
m_connectedTo = ptr;
m_InSlotPtr = ptr;
return ;
}
template<typename T>
void OutSlot<T>::resetInSlotPtr( void )
{
m_connectedTo = NULL;
m_InSlotPtr = NULL;
return ;
}
......
......@@ -22,6 +22,10 @@
================= InSlot & OutSlot =================
!!!! voir si il faut permettre une seule lecture et une seule ecriture avec une methode pour
reset ou pas (ce qui permettrais au passage de savoir le status d'un InSlot (pret a la lecture ou non))
OK -les simplifiers en virant la gestion de priorite pour la deporter ailleurs
OK -rajouter un getter pour savoir un out/inslot est connecte
OK -rajouter un getter pour recuper l'InSlot/OutSlot auquel l'OutSlot/InSlot est connecte
......
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