TuttleOFX
1
|
00001 #include "HostDescriptor.hpp" 00002 #include "ImageEffectNode.hpp" 00003 #include "attribute/ClipImage.hpp" 00004 00005 // ofx host 00006 #include <tuttle/host/ofx/OfxhBinary.hpp> 00007 #include <tuttle/host/ofx/OfxhMemory.hpp> 00008 #include <tuttle/host/ofx/OfxhImageEffectNode.hpp> 00009 #include <tuttle/host/ofx/OfxhPluginAPICache.hpp> 00010 #include <tuttle/host/ofx/OfxhPluginCache.hpp> 00011 #include <tuttle/host/ofx/OfxhHost.hpp> 00012 #include <tuttle/host/ofx/OfxhImageEffectPlugin.hpp> 00013 #include <tuttle/host/ofx/property/OfxhSet.hpp> 00014 #include <tuttle/host/ofx/attribute/OfxhClip.hpp> 00015 #include <tuttle/host/ofx/attribute/OfxhParam.hpp> 00016 00017 // ofx 00018 #include <ofxCore.h> 00019 #include <ofxImageEffect.h> 00020 00021 #include <iostream> 00022 #include <fstream> 00023 #include <cstring> 00024 00025 /// environment variable to override the host kOfxPropName 00026 /// This is useful if the plugin defines specific behavior depending on the host 00027 #define kHostPropNameEnvVar "TUTTLE_OVERRIDE_HOST_OFXPROPNAME" 00028 00029 namespace tuttle { 00030 namespace host { 00031 00032 Host::Host() 00033 { 00034 /// @todo tuttle set host properties correctly... 00035 const std::string hostPropName( std::getenv( kHostPropNameEnvVar ) ? std::getenv( kHostPropNameEnvVar ) : "TuttleOfx" ); 00036 _properties.setStringProperty( kOfxPropName, hostPropName ); 00037 _properties.setStringProperty( kOfxPropLabel, "TuttleOfx Alpha" ); 00038 _properties.setIntProperty( kOfxImageEffectHostPropIsBackground, false ); 00039 _properties.setIntProperty( kOfxImageEffectPropSupportsOverlays, true ); 00040 _properties.setIntProperty( kOfxImageEffectPropSupportsMultiResolution, true ); 00041 _properties.setIntProperty( kOfxImageEffectPropSupportsTiles, true ); ///< @todo tuttle: we hope to do this ! 00042 _properties.setIntProperty( kOfxImageEffectPropTemporalClipAccess, true ); 00043 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentRGBA, 0 ); 00044 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentRGB, 1 ); 00045 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentAlpha, 2 ); 00046 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextFilter, 0 ); 00047 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextGenerator, 1 ); 00048 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextRetimer, 2 ); 00049 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextTransition, 3 ); 00050 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextGeneral, 4 ); 00051 // _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextReader, 5 ); 00052 // _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextWriter, 6 ); 00053 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthFloat, 0 ); 00054 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthShort, 1 ); 00055 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthByte, 2 ); 00056 _properties.setIntProperty( kOfxImageEffectPropSupportsMultipleClipDepths, true ); 00057 _properties.setIntProperty( kOfxImageEffectPropSupportsMultipleClipPARs, true ); 00058 _properties.setIntProperty( kOfxImageEffectPropSetableFrameRate, true ); 00059 _properties.setIntProperty( kOfxImageEffectPropSetableFielding, false ); 00060 _properties.setIntProperty( kOfxParamHostPropSupportsStringAnimation, false ); 00061 _properties.setIntProperty( kOfxParamHostPropSupportsCustomInteract, true ); 00062 _properties.setIntProperty( kOfxParamHostPropSupportsChoiceAnimation, true ); 00063 _properties.setIntProperty( kOfxParamHostPropSupportsBooleanAnimation, true ); 00064 _properties.setIntProperty( kOfxParamHostPropSupportsCustomAnimation, false ); 00065 _properties.setIntProperty( kOfxParamHostPropMaxParameters, -1 ); 00066 _properties.setIntProperty( kOfxParamHostPropMaxPages, 0 ); 00067 _properties.setIntProperty( kOfxParamHostPropPageRowColumnCount, 0, 0 ); 00068 _properties.setIntProperty( kOfxParamHostPropPageRowColumnCount, 0, 1 ); 00069 } 00070 00071 tuttle::host::ImageEffectNode* Host::newInstance( tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin, 00072 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor& desc, 00073 const std::string& context ) const 00074 { 00075 return new tuttle::host::ImageEffectNode( plugin, desc, context ); 00076 } 00077 00078 /// Override this to create a descriptor, this makes the 'root' descriptor 00079 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00080 { 00081 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* desc = new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( plugin ); 00082 00083 return desc; 00084 } 00085 00086 /// used to construct a context description, rootContext is the main context 00087 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( const tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor& rootContext, 00088 tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00089 { 00090 return new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( rootContext, plugin ); 00091 } 00092 00093 /// used to construct populate the cache 00094 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( const std::string& bundlePath, 00095 tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00096 { 00097 return new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( bundlePath, plugin ); 00098 } 00099 00100 /// message 00101 OfxStatus Host::vmessage( const char* type, 00102 const char* id, 00103 const char* format, 00104 va_list args ) const 00105 { 00106 bool isQuestion = false; 00107 const char* prefix = "Message : "; 00108 00109 if( strcmp( type, kOfxMessageLog ) == 0 ) 00110 { 00111 prefix = "Log : "; 00112 } 00113 else if( strcmp( type, kOfxMessageFatal ) == 0 || 00114 strcmp( type, kOfxMessageError ) == 0 ) 00115 { 00116 prefix = "Error : "; 00117 } 00118 else if( strcmp( type, kOfxMessageQuestion ) == 0 ) 00119 { 00120 prefix = "Question : "; 00121 isQuestion = true; 00122 } 00123 00124 // Just dump our message to stdout, should be done with a proper 00125 // UI in a full ap, and post a dialogue for yes/no questions. 00126 fputs( prefix, stdout ); 00127 vprintf( format, args ); 00128 printf( "\n" ); 00129 00130 if( isQuestion ) 00131 { 00132 /// cant do this properly inour example, as we need to raise a dialogue to ask a question, so just return yes 00133 return kOfxStatReplyYes; 00134 } 00135 else 00136 { 00137 return kOfxStatOK; 00138 } 00139 } 00140 00141 } 00142 }