client/compressor.cpp

00001 
00002 /* Copyright (c) 2009, Cedric Stalder <cedric.stalder@gmail.com> 
00003  *               2009, Stefan Eilemann <eile@equalizergraphics.com> 
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #include "compressor.h"
00020 
00021 namespace eq
00022 {
00023 
00024 bool Compressor::init( const std::string& libraryName )
00025 {
00026     if( !_dso.open( libraryName ))
00027         return false;        
00028     
00029     getNumCompressors = ( GetNumCompressors_t )
00030         ( _dso.getFunctionPointer( "EqCompressorGetNumCompressors" ));
00031     
00032     GetInfo_t getInfo = ( GetInfo_t )
00033         ( _dso.getFunctionPointer( "EqCompressorGetInfo" ));
00034     
00035     compress = ( Compress_t )
00036         ( _dso.getFunctionPointer( "EqCompressorCompress" ));
00037        
00038     decompress = ( Decompress_t )
00039         ( _dso.getFunctionPointer( "EqCompressorDecompress" ));
00040 
00041     getNumResults = ( GetNumResults_t )
00042         ( _dso.getFunctionPointer( "EqCompressorGetNumResults" ));
00043     
00044     getResult = ( GetResult_t )
00045         ( _dso.getFunctionPointer( "EqCompressorGetResult" ));
00046     
00047     deleteDecompressor = ( DeleteDecompressor_t )
00048         ( _dso.getFunctionPointer( "EqCompressorDeleteDecompressor" ));
00049     
00050     deleteCompressor = ( DeleteCompressor_t)
00051         ( _dso.getFunctionPointer( "EqCompressorDeleteCompressor" ));
00052     
00053     newCompressor = ( NewCompressor_t)
00054         ( _dso.getFunctionPointer( "EqCompressorNewCompressor" ));
00055     
00056     newDecompressor = ( NewDecompressor_t )
00057         ( _dso.getFunctionPointer( "EqCompressorNewDecompressor" ));
00058 
00059 
00060     if (!( newDecompressor && newCompressor && deleteCompressor && 
00061           deleteDecompressor && getResult && getNumResults && 
00062           decompress && compress && getInfo && getNumCompressors ))
00063     {
00064         EQWARN << "Initializing compression DSO " << libraryName 
00065                << " failed, at least one entry point missing" << std::endl;
00066         return false;
00067     }
00068 
00069     const size_t nCompressors = getNumCompressors();
00070     EQASSERT( nCompressors > 0 );
00071     _infos.resize( nCompressors );
00072 
00073     for( size_t i = 0; i < nCompressors; ++i )
00074         getInfo( i, &_infos[i] );
00075     
00076     return true;
00077 }
00078 
00079 bool Compressor::implementsType( const uint32_t name )
00080 {
00081     for( std::vector<EqCompressorInfo>::const_iterator i = _infos.begin(); 
00082          i != _infos.end(); ++i )
00083     {
00084         if ( i->name == name )
00085             return true;
00086     }
00087 
00088     return false;
00089 }
00090 
00091 void Compressor::exit()
00092 {
00093     _dso.close();
00094     _infos.clear();
00095 
00096     newCompressor = 0;
00097     newDecompressor = 0;     
00098     deleteCompressor = 0;
00099     deleteDecompressor = 0;
00100     compress = 0;
00101     decompress = 0;
00102     getNumResults = 0;
00103     getNumCompressors = 0;
00104     getResult = 0;
00105 
00106 }
00107 
00108 std::ostream& operator << ( std::ostream& os, const EqCompressorInfo& info )
00109 {
00110     os << "v" << info.version << " name " << info.name << " token "
00111        << info.tokenType << " cap " << info.capabilities << " quality "
00112        << info.quality << " ratio " << info.ratio << " speed " << info.speed;
00113     return os;
00114 }
00115 
00116 }
Generated on Sat Feb 6 12:59:50 2010 for Equalizer 0.9.1 by  doxygen 1.6.1