Commit 52a5ef4b authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Implementing new API methods

parent 857d5ffc
......@@ -934,6 +934,68 @@ CVAStruct CVACoreImpl::GetSearchPaths() const
return oSearchPaths;
}
CVAStruct CVACoreImpl::GetCoreConfiguration( const bool bFilterEnabled ) const
{
VA_NO_REENTRANCE;
VA_CHECK_INITIALIZED;
if( bFilterEnabled )
{
CVAStruct oFilteredCoreConfig;
CVAStruct::const_iterator cit = m_oCoreConfig.GetStruct().Begin();
while( cit != m_oCoreConfig.GetStruct().End() )
{
const CVAStructValue& oVal( cit++->second );
if( oVal.IsStruct() )
{
const CVAStruct& oSection( oVal.GetStruct() );
if( oSection.HasKey( "enabled" ) )
if( bool( oSection[ "enabled" ] ) == false )
continue; // Only skip if explicitly not enabled
oFilteredCoreConfig[ cit->first ] = oVal;
}
}
}
else
{
return m_oCoreConfig.GetStruct();
}
}
CVAStruct CVACoreImpl::GetHardwareConfiguration() const
{
VA_NO_REENTRANCE;
VA_CHECK_INITIALIZED;
return m_oCoreConfig.oHardwareSetup.GetStruct();
}
CVAStruct CVACoreImpl::GetFileList( const bool bRecursive, const std::string& sFileSuffixFilter ) const
{
VA_NO_REENTRANCE;
VA_CHECK_INITIALIZED;
CVAStruct oFileList;
for( size_t i = 0; i < m_oCoreConfig.vsSearchPaths.size(); i++ )
{
if( bRecursive )
{
RecursiveFileList( m_oCoreConfig.vsSearchPaths[ i ], oFileList, sFileSuffixFilter );
}
else
{
std::vector< std::string > vsFileList;
FileList( m_oCoreConfig.vsSearchPaths[ i ], vsFileList, sFileSuffixFilter );
CVAStruct oMoreFiles;
for( size_t j = 0; j < vsFileList.size(); j++ )
oMoreFiles[ std::to_string( long( j ) ) ] = vsFileList[ j ];
oFileList[ m_oCoreConfig.vsSearchPaths[ i ] ] = oMoreFiles;
}
}
return oFileList;
}
int CVACoreImpl::CreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName )
{
VA_NO_REENTRANCE;
......@@ -4238,6 +4300,67 @@ void CVACoreImpl::PatchReproductionModulesToOutput()
}
void CVACoreImpl::RecursiveFileList( const std::string& sBasePath, CVAStruct& oFileList, const std::string sFileSuffixMask ) const
{
std::vector< std::string > vsFileList;
FileList( sBasePath, vsFileList, sFileSuffixMask );
CVAStruct oMoreFiles;
for( size_t j = 0; j < vsFileList.size(); j++ )
oMoreFiles[ std::to_string( long( j ) ) ] = vsFileList[ j ];
oFileList[ sBasePath ] = oMoreFiles;
std::vector< std::string > vsFolderList;
FolderList( sBasePath, vsFolderList );
for( size_t j = 0; j < vsFolderList.size(); j++ )
RecursiveFileList( vsFolderList[ j ], oFileList, sFileSuffixMask );
}
void CVACoreImpl::FolderList( const std::string& sBasePath, std::vector< std::string >& vsFolderList ) const
{
vsFolderList.clear();
VistaFileSystemDirectory oFolder( sBasePath );
if( !oFolder.Exists() || !oFolder.IsDirectory() )
return;
VistaFileSystemDirectory::const_iterator cit = oFolder.begin();
while( cit != oFolder.end() )
{
VistaFileSystemNode* pNode( *cit++ );
if( pNode->IsDirectory() && pNode->GetLocalName() != "." && pNode->GetLocalName() != ".." )
vsFolderList.push_back( pNode->GetName() );
}
}
void CVACoreImpl::FileList( const std::string& sBasePath, std::vector< std::string >& vsFileList, const std::string& sFileSuffixMask ) const
{
vsFileList.clear();
VistaFileSystemDirectory oFolder( sBasePath );
if( !oFolder.Exists() || !oFolder.IsDirectory() )
return;
VistaFileSystemDirectory::const_iterator cit = oFolder.begin();
while( cit != oFolder.end() )
{
VistaFileSystemNode* pNode( *cit++ );
if( pNode->IsFile() )
{
const std::string sFileName = pNode->GetLocalName();
if( sFileSuffixMask != "*" && !sFileSuffixMask.empty() )
{
if( sFileName.substr( sFileName.find_last_of( "." ) + 1 ).compare( sFileSuffixMask ) )
vsFileList.push_back( pNode->GetName() );
}
else
vsFileList.push_back( pNode->GetName() );
}
}
}
// --= Progress =---------------------------------------------------
ITACriticalSection m_csProgress;
......
......@@ -75,6 +75,9 @@ public:
void GetModules( std::vector< CVAModuleInfo >& m_viModuleInfos ) const;
CVAStruct CallModule( const std::string& sModuleName, const CVAStruct& oArgs );
CVAStruct GetSearchPaths() const;
CVAStruct GetCoreConfiguration( const bool ) const;
CVAStruct GetHardwareConfiguration() const;
CVAStruct GetFileList( const bool bRecursive = true, const std::string& sFileSuffixFilter = "*" ) const;
// Directivities
int CreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName = "" );
......@@ -480,6 +483,11 @@ private:
//! Patch reproduction modules and output
void PatchReproductionModulesToOutput();
//! Recursive file search
void RecursiveFileList( const std::string& sBasePath, CVAStruct&, const std::string sFileSuffixMask ) const;
void FileList( const std::string& sBasePath, std::vector< std::string >& vsFileList, const std::string& sFileSuffixMask ) const;
void FolderList( const std::string& sBasePath, std::vector< std::string >& vsFolderList ) const;
friend class CVACoreThread;
friend class CVAAudioSignalSourceManager;
};
......
......@@ -279,6 +279,49 @@ const CVAHardwareOutput* CVAHardwareSetup::GetOutput( const std::string& sOutput
return nullptr;
}
CVAStruct CVAHardwareSetup::GetStruct() const
{
CVAStruct oHWInputs, oHWOutputs, oHWDevice;
for( size_t i = 0; i < voHardwareInputDevices.size(); i++ )
{
const CVAHardwareDevice& oDevice( voHardwareInputDevices[ i ] );
oHWDevice[ "orientation" ] = oDevice.qOrient.GetAsStruct();
oHWDevice[ "position" ] = oDevice.vPos.GetAsStruct();
oHWDevice[ "datafilename" ] = oDevice.sDataFileName;
oHWDevice[ "description" ] = oDevice.sDesc;
oHWDevice[ "identifier" ] = oDevice.sIdentifier;
oHWDevice[ "type" ] = oDevice.sType;
oHWDevice[ "channels" ] = CVAStruct();
for( size_t j = 0; j < oDevice.viChannels.size(); j++ )
oHWDevice[ "channels" ][ std::to_string( long( j ) ) ] = oDevice.viChannels[ j ];
oHWDevice[ "numchannels" ] = int( oDevice.viChannels.size() );
oHWInputs[ oDevice.sIdentifier ] = oHWDevice;
}
for( size_t i = 0; i < voHardwareOutputDevices.size(); i++ )
{
const CVAHardwareDevice& oDevice( voHardwareOutputDevices[ i ] );
oHWDevice[ "orientation" ] = oDevice.qOrient.GetAsStruct();
oHWDevice[ "position" ] = oDevice.vPos.GetAsStruct();
oHWDevice[ "datafilename" ] = oDevice.sDataFileName;
oHWDevice[ "description" ] = oDevice.sDesc;
oHWDevice[ "identifier" ] = oDevice.sIdentifier;
oHWDevice[ "type" ] = oDevice.sType;
oHWDevice[ "channels" ] = CVAStruct();
for( size_t j = 0; j < oDevice.viChannels.size(); j++ )
oHWDevice[ "channels" ][ std::to_string( long( j ) ) ] = oDevice.viChannels[ j ];
oHWDevice[ "numchannels" ] = int( oDevice.viChannels.size() );
oHWOutputs[ oDevice.sIdentifier ] = oHWDevice;
}
CVAStruct oHW;
oHW[ "inputedevices" ] = oHWInputs;
oHW[ "outputdevices" ] = oHWOutputs;
return oHW;
}
std::vector< int > CVAHardwareOutput::GetPhysicalOutputChannels() const
{
std::vector< int > viChannels;
......
......@@ -80,6 +80,8 @@ public:
std::vector< const CVAHardwareDevice* > GetDeviceListFromOutputGroup( const std::string& sOutputIdentifier ) const;
const CVAHardwareOutput* GetOutput( const std::string& sOutput ) const;
CVAStruct GetStruct() const;
private:
std::vector< CVAHardwareDevice > voHardwareInputDevices; //!< Hardware input devices list
std::vector< CVAHardwareDevice > voHardwareOutputDevices; //!< Hardware output devices list
......
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