TuttleOFX  1
ReaderPlugin.cpp
Go to the documentation of this file.
00001 #include "ReaderPlugin.hpp"
00002 
00003 namespace tuttle {
00004 namespace plugin {
00005 
00006 namespace bfs = boost::filesystem;
00007 
00008 ReaderPlugin::ReaderPlugin( OfxImageEffectHandle handle )
00009         : OFX::ImageEffect( handle )
00010 {
00011         _clipDst       = fetchClip( kOfxImageEffectOutputClipName );
00012         _paramFilepath = fetchStringParam( kTuttlePluginFilename );
00013         _isSequence    = _filePattern.initFromDetection( _paramFilepath->getValue() );
00014         _paramBitDepth = fetchChoiceParam( kTuttlePluginBitDepth );
00015         _paramChannel  = fetchChoiceParam( kTuttlePluginChannel );
00016 }
00017 
00018 ReaderPlugin::~ReaderPlugin()
00019 {}
00020 
00021 void ReaderPlugin::changedParam( const OFX::InstanceChangedArgs& args, const std::string& paramName )
00022 {
00023         if( paramName == kTuttlePluginFilename )
00024         {
00025                 _isSequence = _filePattern.initFromDetection( _paramFilepath->getValue() );
00026         }
00027 }
00028 
00029 void ReaderPlugin::getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences )
00030 {
00031         const std::string filename( getAbsoluteFirstFilename() );
00032 
00033         // If pattern detected (frame varying on time)
00034         clipPreferences.setOutputFrameVarying( varyOnTime() );
00035 
00036         switch( getExplicitBitDepthConversion() )
00037         {
00038                 case eParamReaderBitDepthByte:
00039                 {
00040                         clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthUByte );
00041                         break;
00042                 }
00043                 case eParamReaderBitDepthShort:
00044                 {
00045                         clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthUShort );
00046                         break;
00047                 }
00048                 case eParamReaderBitDepthAuto:
00049                 case eParamReaderBitDepthFloat:
00050                 {
00051                         clipPreferences.setClipBitDepth( *this->_clipDst, OFX::eBitDepthFloat );
00052                         break;
00053                 }
00054         }
00055         switch( getExplicitChannelConversion() )
00056         {
00057                 case eParamReaderChannelGray:
00058                 {
00059                         clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentAlpha );
00060                         break;
00061                 }
00062                 case eParamReaderChannelRGB:
00063                 {
00064                         if( OFX::getImageEffectHostDescription()->supportsPixelComponent( OFX::ePixelComponentRGB ) )
00065                                 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGB );
00066                         else
00067                                 clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGBA );
00068                         break;
00069                 }
00070                 case eParamReaderChannelAuto:
00071                 case eParamReaderChannelRGBA:
00072                 {
00073                         clipPreferences.setClipComponents( *this->_clipDst, OFX::ePixelComponentRGBA );
00074                         break;
00075                 }
00076         }
00077 
00078         clipPreferences.setPixelAspectRatio( *this->_clipDst, 1.0 );
00079 }
00080 
00081 bool ReaderPlugin::getTimeDomain( OfxRangeD& range )
00082 {
00083         range.min = getFirstTime();
00084         range.max = getLastTime();
00085         TUTTLE_TLOG( TUTTLE_INFO, "[Reader plugin] Time Domain : " << range.min << " to " << range.max );
00086         return true;
00087 }
00088 
00089 void ReaderPlugin::render( const OFX::RenderArguments& args )
00090 {
00091         std::string filename =  getAbsoluteFilenameAt( args.time );
00092         TUTTLE_LOG_INFO( "        >-- " << filename );
00093 }
00094 
00095 }
00096 }