Index: /trunk/libfreebob/src/libfreebobavc/avc_function_block.h =================================================================== --- /trunk/libfreebob/src/libfreebobavc/avc_function_block.h (revision 378) +++ /trunk/libfreebob/src/libfreebobavc/avc_function_block.h (revision 379) @@ -1,4 +1,4 @@ /* avc_function_block.h - * Copyright (C) 2006 by Daniel Wagner + * Copyright (C) 2006,07 by Daniel Wagner * * This file is part of FreeBoB. @@ -165,5 +165,5 @@ // Control selector encoding enum EControlSelectorEncoding { - eCSE_Processing_Unknown = 0x00, + eCSE_Processing_Unknown = 0x00, eCSE_Processing_Enable = 0x01, eCSE_Processing_Mode = 0x02, @@ -200,5 +200,5 @@ // CODEC type endcoding enum ECodecTypeEncoding { - eCTE_Unknown = 0x00, + eCTE_Unknown = 0x00, eCTE_Ac3Decoder = 0x01, eCTE_MpegDecoder = 0x02, Index: /trunk/libfreebob/src/bebob/bebob_avdevice.cpp =================================================================== --- /trunk/libfreebob/src/bebob/bebob_avdevice.cpp (revision 378) +++ /trunk/libfreebob/src/bebob/bebob_avdevice.cpp (revision 379) @@ -1232,4 +1232,107 @@ } +template bool serializeVector( Glib::ustring path, + Util::IOSerialize& ser, + const T& vec ) +{ + bool result = true; // if vec.size() == 0 + int i = 0; + for ( typename T::const_iterator it = vec.begin(); it != vec.end(); ++it ) { + std::ostringstream strstrm; + strstrm << path << i; + result &= ( *it )->serialize( strstrm.str() + "/", ser ); + i++; + } + return result; +} + +template bool deserializeVector( Glib::ustring path, + Util::IODeserialize& deser, + AvDevice& avDevice, + VT& vec ) +{ + int i = 0; + bool bFinished = false; + do { + std::ostringstream strstrm; + strstrm << path << i << "/"; + T* ptr = T::deserialize( strstrm.str(), + deser, + avDevice ); + if ( ptr ) { + vec.push_back( ptr ); + i++; + } else { + bFinished = true; + } + } while ( !bFinished ); + + return true; +} + +bool +AvDevice::serializeSyncInfoVector( Glib::ustring basePath, + Util::IOSerialize& ser, + const SyncInfoVector& vec ) +{ + bool result = true; + int i = 0; + + for ( SyncInfoVector::const_iterator it = vec.begin(); + it != vec.end(); + ++it ) + { + const SyncInfo& info = *it; + + std::ostringstream strstrm; + strstrm << basePath << i << "/"; + + result &= ser.write( strstrm.str() + "m_source", info.m_source->getGlobalId() ); + result &= ser.write( strstrm.str() + "m_destination", info.m_destination->getGlobalId() ); + result &= ser.write( strstrm.str() + "m_description", Glib::ustring( info.m_description ) ); + + i++; + } + + return result; +} + +bool +AvDevice::deserializeSyncInfoVector( Glib::ustring basePath, + Util::IODeserialize& deser, + AvDevice& avDevice, + SyncInfoVector& vec ) +{ + int i = 0; + bool bFinished = false; + do { + bool result; + std::ostringstream strstrm; + strstrm << basePath << i << "/"; + + plug_id_t sourceId; + plug_id_t destinationId; + Glib::ustring description; + + result = deser.read( strstrm.str() + "m_source", sourceId ); + result &= deser.read( strstrm.str() + "m_destination", destinationId ); + result &= deser.read( strstrm.str() + "m_description", description ); + + if ( result ) { + SyncInfo syncInfo; + syncInfo.m_source = avDevice.getPlugManager().getPlug( sourceId ); + syncInfo.m_destination = avDevice.getPlugManager().getPlug( destinationId ); + syncInfo.m_description = description; + + vec.push_back( syncInfo ); + i++; + } else { + bFinished = true; + } + } while ( !bFinished ); + + return true; +} + static bool deserializeAvPlugUpdateConnections( Glib::ustring path, @@ -1249,6 +1352,6 @@ bool -AvDevice::serialize( Glib::ustring - basePath, Util::IOSerialize& ser ) const +AvDevice::serialize( Glib::ustring basePath, + Util::IOSerialize& ser ) const { bool result; @@ -1258,6 +1361,20 @@ result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); result &= serializeVector( basePath + "Subunit", ser, m_subunits ); - - // XXX ... + result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); + + int i = 0; + for ( SyncInfoVector::const_iterator it = m_syncInfos.begin(); + it != m_syncInfos.end(); + ++it ) + { + const SyncInfo& info = *it; + if ( m_activeSyncInfo == &info ) { + result &= ser.write( basePath + "m_activeSyncInfo", i ); + break; + } + i++; + } + + result &= ser.write( basePath + "m_id", m_id ); return result; @@ -1292,6 +1409,16 @@ result &= deserializeVector( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); result &= deserializeVector( basePath + "Subunit", deser, *pDev, pDev->m_subunits ); - - // XXX ... + result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, *pDev, pDev->m_syncInfos ); + + unsigned int i; + result &= deser.read( basePath + "m_activeSyncInfo", i ); + + if ( result ) { + if ( i < pDev->m_syncInfos.size() ) { + pDev->m_activeSyncInfo = &pDev->m_syncInfos[i]; + } + } + + result &= deser.read( basePath + "m_id", pDev->m_id ); } Index: /trunk/libfreebob/src/bebob/bebob_avdevice.h =================================================================== --- /trunk/libfreebob/src/bebob/bebob_avdevice.h (revision 378) +++ /trunk/libfreebob/src/bebob/bebob_avdevice.h (revision 379) @@ -89,4 +89,9 @@ , m_description( description ) {} + SyncInfo() + : m_source( 0 ) + , m_destination( 0 ) + , m_description( "" ) + {} AvPlug* m_source; AvPlug* m_destination; @@ -147,4 +152,12 @@ AvPlugVector& prhs, std::string syncDescription ); + + static bool serializeSyncInfoVector( Glib::ustring basePath, + Util::IOSerialize& ser, + const SyncInfoVector& vec ); + static bool deserializeSyncInfoVector( Glib::ustring basePath, + Util::IODeserialize& deser, + AvDevice& avDevice, + SyncInfoVector& vec ); protected: std::auto_ptr( m_pConfigRom ); @@ -170,43 +183,4 @@ }; -template bool serializeVector( Glib::ustring path, - Util::IOSerialize& ser, - const T& vec ) -{ - bool result = true; // if vec.size() == 0 - int i = 0; - for ( typename T::const_iterator it = vec.begin(); it != vec.end(); ++it ) { - std::ostringstream strstrm; - strstrm << path << i; - result &= ( *it )->serialize( strstrm.str() + "/", ser ); - i++; - } - return result; -} - -template bool deserializeVector( Glib::ustring path, - Util::IODeserialize& deser, - AvDevice& avDevice, - VT& vec ) -{ - int i = 0; - bool bFinished = false; - do { - std::ostringstream strstrm; - strstrm << path << i << "/"; - T* ptr = T::deserialize( strstrm.str(), - deser, - avDevice ); - if ( ptr ) { - vec.push_back( ptr ); - i++; - } else { - bFinished = true; - } - } while ( !bFinished ); - - return true; -} - }