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 namespace tuttle { 00026 namespace host { 00027 00028 Host::Host() 00029 { 00030 /// @todo tuttle set host properties correctly... 00031 _properties.setStringProperty( kOfxPropName, "TuttleOfx" ); 00032 _properties.setStringProperty( kOfxPropLabel, "TuttleOfx Alpha" ); 00033 _properties.setIntProperty( kOfxImageEffectHostPropIsBackground, false ); 00034 _properties.setIntProperty( kOfxImageEffectPropSupportsOverlays, true ); 00035 _properties.setIntProperty( kOfxImageEffectPropSupportsMultiResolution, true ); 00036 _properties.setIntProperty( kOfxImageEffectPropSupportsTiles, true ); ///< @todo tuttle: we hope to do this ! 00037 _properties.setIntProperty( kOfxImageEffectPropTemporalClipAccess, true ); 00038 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentRGBA, 0 ); 00039 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentRGB, 1 ); 00040 _properties.setStringProperty( kOfxImageEffectPropSupportedComponents, kOfxImageComponentAlpha, 2 ); 00041 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextFilter, 0 ); 00042 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextGenerator, 1 ); 00043 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextRetimer, 2 ); 00044 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextTransition, 3 ); 00045 _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextGeneral, 4 ); 00046 // _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextReader, 5 ); 00047 // _properties.setStringProperty( kOfxImageEffectPropSupportedContexts, kOfxImageEffectContextWriter, 6 ); 00048 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthFloat, 0 ); 00049 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthShort, 1 ); 00050 _properties.setStringProperty( kOfxImageEffectPropSupportedPixelDepths, kOfxBitDepthByte, 2 ); 00051 _properties.setIntProperty( kOfxImageEffectPropSupportsMultipleClipDepths, true ); 00052 _properties.setIntProperty( kOfxImageEffectPropSupportsMultipleClipPARs, true ); 00053 _properties.setIntProperty( kOfxImageEffectPropSetableFrameRate, true ); 00054 _properties.setIntProperty( kOfxImageEffectPropSetableFielding, false ); 00055 _properties.setIntProperty( kOfxParamHostPropSupportsStringAnimation, false ); 00056 _properties.setIntProperty( kOfxParamHostPropSupportsCustomInteract, true ); 00057 _properties.setIntProperty( kOfxParamHostPropSupportsChoiceAnimation, true ); 00058 _properties.setIntProperty( kOfxParamHostPropSupportsBooleanAnimation, true ); 00059 _properties.setIntProperty( kOfxParamHostPropSupportsCustomAnimation, false ); 00060 _properties.setIntProperty( kOfxParamHostPropMaxParameters, -1 ); 00061 _properties.setIntProperty( kOfxParamHostPropMaxPages, 0 ); 00062 _properties.setIntProperty( kOfxParamHostPropPageRowColumnCount, 0, 0 ); 00063 _properties.setIntProperty( kOfxParamHostPropPageRowColumnCount, 0, 1 ); 00064 } 00065 00066 tuttle::host::ImageEffectNode* Host::newInstance( tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin, 00067 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor& desc, 00068 const std::string& context ) const 00069 { 00070 return new tuttle::host::ImageEffectNode( plugin, desc, context ); 00071 } 00072 00073 /// Override this to create a descriptor, this makes the 'root' descriptor 00074 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00075 { 00076 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* desc = new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( plugin ); 00077 00078 return desc; 00079 } 00080 00081 /// used to construct a context description, rootContext is the main context 00082 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( const tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor& rootContext, 00083 tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00084 { 00085 return new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( rootContext, plugin ); 00086 } 00087 00088 /// used to construct populate the cache 00089 tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor* Host::makeDescriptor( const std::string& bundlePath, 00090 tuttle::host::ofx::imageEffect::OfxhImageEffectPlugin& plugin ) const 00091 { 00092 return new tuttle::host::ofx::imageEffect::OfxhImageEffectNodeDescriptor( bundlePath, plugin ); 00093 } 00094 00095 /// message 00096 OfxStatus Host::vmessage( const char* type, 00097 const char* id, 00098 const char* format, 00099 va_list args ) const 00100 { 00101 bool isQuestion = false; 00102 const char* prefix = "Message : "; 00103 00104 if( strcmp( type, kOfxMessageLog ) == 0 ) 00105 { 00106 prefix = "Log : "; 00107 } 00108 else if( strcmp( type, kOfxMessageFatal ) == 0 || 00109 strcmp( type, kOfxMessageError ) == 0 ) 00110 { 00111 prefix = "Error : "; 00112 } 00113 else if( strcmp( type, kOfxMessageQuestion ) == 0 ) 00114 { 00115 prefix = "Question : "; 00116 isQuestion = true; 00117 } 00118 00119 // Just dump our message to stdout, should be done with a proper 00120 // UI in a full ap, and post a dialogue for yes/no questions. 00121 fputs( prefix, stdout ); 00122 vprintf( format, args ); 00123 printf( "\n" ); 00124 00125 if( isQuestion ) 00126 { 00127 /// cant do this properly inour example, as we need to raise a dialogue to ask a question, so just return yes 00128 return kOfxStatReplyYes; 00129 } 00130 else 00131 { 00132 return kOfxStatOK; 00133 } 00134 } 00135 00136 } 00137 }