Commit 1803beaf authored by Vincent Carrubba's avatar Vincent Carrubba Committed by Hugo Beauzee-Luyssen
Browse files

Code factorisation in EffectNode static video connection methods



Signed-off-by: default avatarHugo Beauzee-Luyssen <beauze.h@gmail.com>
parent 91b6b60e
......@@ -257,100 +257,56 @@ EffectNode::wasItVisited( void ) const
// ---------------- CONNECT STATIC TO STATIC -------------------
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName, const QString & nodeName, const QString & inName )
EffectNode::primitiveConnectStaticVideoOutputToStaticVideoInput( quint32 outId,
quint32 nodeId,
quint32 inId,
const QString &outName,
const QString &nodeName,
const QString &inName )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outName ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeName ) ) == NULL )
return false;
if ( brother == this )
if ( outId == 0 && outName.isEmpty() == false )
{
if ( ( in = m_staticVideosInputs.getObject( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
if ( ( out = m_staticVideosOutputs.getObject( outName ) ) == NULL )
return false;
}
else
else if ( outId != 0 && outName.isEmpty() == true )
{
if ( ( in = brother->getStaticVideoInput( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
if ( ( out = m_staticVideosOutputs.getObject( outId ) ) == NULL )
return false;
}
return true;
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName, const QString & nodeName, quint32 inId )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outName ) ) == NULL )
else
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeName ) ) == NULL )
return false;
if ( brother == this )
if ( nodeId == 0 && nodeName.isEmpty() == false )
{
if ( ( in = m_staticVideosInputs.getObject( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
if ( ( brother = m_father->getChild( nodeName ) ) == NULL )
return false;
}
else
else if ( nodeId != 0 && nodeName.isEmpty() == true )
{
if ( ( in = brother->getStaticVideoInput( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
if ( ( brother = m_father->getChild( nodeId ) ) == NULL )
return false;
}
return true;
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName, quint32 nodeId, const QString & inName )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outName ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeId ) ) == NULL )
else
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inName ) ) == NULL )
if ( inId == 0 && inName.isEmpty() == false )
{
if ( ( in = m_staticVideosInputs.getObject( inName ) ) == NULL )
return false;
}
else if ( inId != 0 && inName.isEmpty() == true )
{
if ( ( in = m_staticVideosInputs.getObject( inId ) ) == NULL )
return false;
}
else
return false;
if ( out->connect( *in ) == false )
return false;
......@@ -361,7 +317,17 @@ EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName,
}
else
{
if ( ( in = brother->getStaticVideoInput( inName ) ) == NULL )
if ( inId == 0 && inName.isEmpty() == false )
{
if ( ( in = brother->getStaticVideoInput( inName ) ) == NULL )
return false;
}
else if ( inId != 0 && inName.isEmpty() == true )
{
if ( ( in = brother->getStaticVideoInput( inId ) ) == NULL )
return false;
}
else
return false;
if ( out->connect( *in ) == false )
return false;
......@@ -374,198 +340,107 @@ EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName,
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString & outName, quint32 nodeId, quint32 inId )
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString &outName, const QString &nodeName, const QString &inName )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outName ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeId ) ) == NULL )
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
return false;
}
else
{
if ( ( in = brother->getStaticVideoInput( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
return false;
}
return true;
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( 0,
0,
0,
outName,
nodeName,
inName ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, const QString & nodeName, const QString & inName )
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString &outName, const QString &nodeName, quint32 inId )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outId ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeName ) ) == NULL )
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
return false;
}
else
{
if ( ( in = brother->getStaticVideoInput( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
return false;
}
return true;
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( 0,
0,
inId,
outName,
nodeName,
"" ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, const QString & nodeName, quint32 inId )
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString &outName, quint32 nodeId, const QString &inName )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outId ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeName ) ) == NULL )
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
return false;
}
else
{
if ( ( in = brother->getStaticVideoInput( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
return false;
}
return true;
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( 0,
nodeId,
0,
outName,
"",
inName ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, quint32 nodeId, const QString & inName )
EffectNode::connectStaticVideoOutputToStaticVideoInput( const QString &outName, quint32 nodeId, quint32 inId )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outId ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeId ) ) == NULL )
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
return false;
}
else
{
if ( ( in = brother->getStaticVideoInput( inName ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
return false;
}
return true;
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( 0,
nodeId,
inId,
outName,
"",
"" ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, const QString &nodeName, const QString &inName )
{
QWriteLocker wl( &m_rwl );
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( outId,
0,
0,
"",
nodeName,
inName ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, const QString &nodeName, quint32 inId )
{
QWriteLocker wl( &m_rwl );
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( outId,
0,
inId,
"",
nodeName,
"" ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, quint32 nodeId, const QString &inName )
{
QWriteLocker wl( &m_rwl );
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( outId,
nodeId,
0,
"",
"",
inName ) );
}
bool
EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, quint32 nodeId, quint32 inId )
{
QWriteLocker wl( &m_rwl );
OutSlot<LightVideoFrame>* out;
EffectNode* brother;
InSlot<LightVideoFrame>* in;
if ( ( out = m_staticVideosOutputs.getObject( outId ) ) == NULL )
return false;
if ( m_father == NULL )
return false;
if ( ( brother = m_father->getChild( nodeId ) ) == NULL )
return false;
if ( brother == this )
{
if ( ( in = m_staticVideosInputs.getObject( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( m_connectedStaticVideosInputs.addObjectReference( in ) == false )
return false;
}
else
{
if ( ( in = brother->getStaticVideoInput( inId ) ) == NULL )
return false;
if ( out->connect( *in ) == false )
return false;
if ( m_connectedStaticVideosOutputs.addObjectReference( out ) == false )
return false;
if ( brother->referenceStaticVideoInputAsConnected( in ) == false )
return false;
}
return true;
return ( primitiveConnectStaticVideoOutputToStaticVideoInput( outId,
nodeId,
inId,
"",
"",
"" ) );
}
// ---------------- CONNECT STATIC TO DYNAMIC -------------------
......
......@@ -328,6 +328,17 @@ class EffectNode : public IEffectNode
// ---------------- CONNECT STATIC TO STATIC -------------------
private:
// Primitive
bool primitiveConnectStaticVideoOutputToStaticVideoInput( quint32 outId, quint32 nodeId, quint32 inId,
const QString & outName, const QString & nodeName, const QString & inName );
public:
// Overloaded methods
bool connectStaticVideoOutputToStaticVideoInput( const QString & outName, const QString & nodeName, const QString & inName );
bool connectStaticVideoOutputToStaticVideoInput( const QString & outName, const QString & nodeName, quint32 inId );
bool connectStaticVideoOutputToStaticVideoInput( const QString & outName, quint32 nodeId, const QString & inName );
......
......@@ -66,7 +66,6 @@ EffectsEngine::makePatch( void )
qDebug() << "RootNode successfully created!";
m_patch = EffectNode::getRootNode( "RootNode" );
// CREATION DU ROOTNODE ET DE SES SLOTS
for ( i = 0 ; i < 64; ++i)
m_patch->createStaticVideoInput();
m_patch->createStaticVideoOutput();
......@@ -81,34 +80,23 @@ EffectsEngine::makePatch( void )
<< i << " of the mixer with the internal "
<< i << " output of the RootNode failed!";
// // RECUP LE MIXER ET CONNECTE SA SORTIE 1 A L'INTERNAL INPUT DU ROOT NODE
// tmp = m_patch->getChild( 1 );
// if ( tmp->connectChildStaticVideoOutputToParentStaticVideoInput( 1, 1 ) == false )
// qDebug() << "The connection of the mixer output with the BypassRootNode internal input failed!";
// else
// qDebug() << "The connection of the mixer output with the BypassRootNode internal input successed!";
m_patch->createChild( "BlitInRectangle" );
m_patch->createChild( "InvertRNB" );
// RECUP LE MIXER ET CONNECTE SA SORTIE 1 A L'ENTREE 2 DU BLIT
tmp = m_patch->getChild( 1 );
if ( tmp->connectStaticVideoOutputToStaticVideoInput( 1, 2, "dst" ) == false )
qDebug() << "The connection of the mixer output"
<< "with the second input of the blit failed!";
// RECUP LE BLIT ET CONNECT SA SORTIE 2 A L'INTERNAL INPUT DU ROOT NODE
tmp = m_patch->getChild( 2 );
if ( tmp->connectChildStaticVideoOutputToParentStaticVideoInput( "res", 1 ) == false )
qDebug() << "The connection of the second output of the blit"
<< "with the BypassRootNode internal input failed!";
// CONNECT SA SORTIE 1 A SA L'ENTREE 1 DE L'INVERSEUR DE BLEU ET DE ROUGE
if ( tmp->connectStaticVideoOutputToStaticVideoInput( "aux", 3, 1 ) == false )
qDebug() << "The connection of the first output of the blit"
<< "with the InvertRNB input failed!";
// CONNECT LA SORTIE DE L'INVERSEUR A L'ENTREE SRC DU BLIT
tmp = m_patch->getChild( 3 );
if ( tmp->connectStaticVideoOutputToStaticVideoInput( 1, 2, 1 ) == false )
qDebug() << "The connection of the RNBInvert output"
......@@ -133,7 +121,6 @@ EffectsEngine::makeBypassPatch( void )
qDebug() << "BypassRootNode successfully created!";
// CREATION DU BYPASSROOTNODE ET DE SES SLOTS
m_bypassPatch = EffectNode::getRootNode( "BypassRootNode" );
for ( i = 0 ; i < 64; ++i)
m_bypassPatch->createStaticVideoInput();
......@@ -148,7 +135,6 @@ EffectsEngine::makeBypassPatch( void )
<< i << " of the mixer with the internal "
<< i << " output of the BypassRootNode failed!";
// RECUP LE MIXER ET CONNECTE SA SORTIE 1 A L'INTERNAL INPUT DU ROOT NODE
tmp = m_bypassPatch->getChild( 1 );
if ( tmp->connectChildStaticVideoOutputToParentStaticVideoInput( 1, 1 ) == false )
qDebug() << "The connection of the mixer output"
......
Supports Markdown
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