212 lines
6.7 KiB
C++
212 lines
6.7 KiB
C++
/*************************************************************************/
|
|
/* File : OutputProperties.cpp */
|
|
/* */
|
|
/* Author : Leïla AIT KACI */
|
|
/* Last Modification : 28/05/03 */
|
|
/*************************************************************************/
|
|
#include "CKAll.h"
|
|
#include "CKVideo.h"
|
|
#include "CKVideoManager.h"
|
|
|
|
void RegisterOutputPropertiesParams (CKParameterManager* pm);
|
|
void UnregisterOutputPropertiesParams (CKParameterManager* pm);
|
|
|
|
CKObjectDeclaration* FillBehaviorOutputPropertiesDecl ();
|
|
CKERROR CreateOutputPropertiesProto (CKBehaviorPrototype **);
|
|
int OutputProperties (const CKBehaviorContext& BehContext);
|
|
CKERROR OutputPropertiesCB (const CKBehaviorContext& BehContext);
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Defines
|
|
//////////////////////////////////////////////////////////////////////
|
|
#define BB_NAME "Video Output Properties"
|
|
#define BB_DESC "Modify a video's output properties (static parameters)."
|
|
#define BB_CAT "Video/Properties"
|
|
#define BB_VERSION 0x00010000
|
|
#define BB_TARGET CKCID_VIDEO
|
|
|
|
#define RETURN_IF_FAILED(index, res) \
|
|
if ( res != CK_OK ) { \
|
|
XString err = "Pin '"; \
|
|
err += beh->GetInputParameter(index)->GetName(); \
|
|
err += "': "; \
|
|
err += video->GetErrorDescrition(res); \
|
|
beh->SetOutputParameterValue(POUT_ERROR, err.Str(), err.Length() + 1 ); \
|
|
beh->ActivateOutput(OUT_ERROR); \
|
|
return CKBR_OK; \
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Enums for Parameter's Indexes
|
|
//////////////////////////////////////////////////////////////////////
|
|
enum BB_IN
|
|
{
|
|
IN_IN
|
|
};
|
|
|
|
enum BB_OUT
|
|
{
|
|
OUT_OUT,
|
|
OUT_ERROR
|
|
};
|
|
|
|
enum BB_LOC
|
|
{
|
|
SET_PROPERTYFLAGS
|
|
};
|
|
|
|
enum BB_PIN
|
|
{
|
|
PIN_TEXTURE,
|
|
PIN_VIDEOFORMAT,
|
|
PIN_NONPOW2
|
|
};
|
|
|
|
enum BB_POUT
|
|
{
|
|
POUT_ERROR
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
#define GUIDOutputProperties CKGUID(0x21545032,0x17717b4e)
|
|
#define PROPERTY_TEXTURE 0x01
|
|
#define PROPERTY_VIDEOFORMAT 0x02
|
|
#define PROPERTY_NONPOW2 0x04
|
|
#define PROPERTY_ALL "Texture,Best Video Format,Non Pow2 Texture"
|
|
|
|
void RegisterOutputPropertiesParams(CKParameterManager* pm)
|
|
{
|
|
pm->RegisterNewFlags(GUIDOutputProperties, "", "Texture=1,Best Video Format=2,Non Pow2 Texture=4");
|
|
|
|
CKParameterTypeDesc* TypeDesc;
|
|
TypeDesc = pm->GetParameterTypeDescription(GUIDOutputProperties);
|
|
TypeDesc->dwFlags |= CKPARAMETERTYPE_HIDDEN;
|
|
}
|
|
|
|
void UnregisterOutputPropertiesParams(CKParameterManager* pm)
|
|
{
|
|
pm->UnRegisterParameterType(GUIDOutputProperties);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKObjectDeclaration *FillBehaviorOutputPropertiesDecl()
|
|
{
|
|
CKObjectDeclaration *od = CreateCKObjectDeclaration(BB_NAME);
|
|
od->SetType(CKDLL_BEHAVIORPROTOTYPE);
|
|
od->SetCompatibleClassId(BB_TARGET);
|
|
od->SetDescription(BB_DESC);
|
|
od->SetVersion(BB_VERSION);
|
|
od->SetCategory(BB_CAT);
|
|
od->SetAuthorName("Virtools");
|
|
od->SetAuthorGuid(VIRTOOLS_GUID);
|
|
od->SetGuid(CKGUID(0x9115240,0x35035e32));
|
|
od->SetCreationFunction(CreateOutputPropertiesProto);
|
|
|
|
return od;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKERROR CreateOutputPropertiesProto(CKBehaviorPrototype** pproto)
|
|
{
|
|
CKBehaviorPrototype *proto = CreateCKBehaviorPrototype(BB_NAME);
|
|
if(!proto) return CKERR_OUTOFMEMORY;
|
|
|
|
//--- Inputs declaration
|
|
proto->DeclareInput("In");
|
|
|
|
//--- Outputs declaration
|
|
proto->DeclareOutput("Out");
|
|
proto->DeclareOutput("Error");
|
|
|
|
//----- Input Parameters Declaration
|
|
proto->DeclareInParameter("Texture", CKPGUID_TEXTURE);
|
|
proto->DeclareInParameter("Best Video Format", CKPGUID_BOOL, "TRUE");
|
|
proto->DeclareInParameter("Non Pow2 Conditional Texture", CKPGUID_BOOL, "TRUE");
|
|
|
|
//--- Output Parameters Declaration
|
|
proto->DeclareOutParameter("Error", CKPGUID_STRING);
|
|
|
|
//---- Settings Declaration
|
|
proto->DeclareSetting("Output Properties", GUIDOutputProperties, PROPERTY_ALL);
|
|
|
|
proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);
|
|
proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE));
|
|
proto->SetFunction(OutputProperties);
|
|
proto->SetBehaviorCallbackFct(OutputPropertiesCB, CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORCREATE, NULL);
|
|
|
|
*pproto = proto;
|
|
return CK_OK;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
int OutputProperties(const CKBehaviorContext& BehContext)
|
|
{
|
|
CKContext* ctx = BehContext.Context;
|
|
CKBehavior* beh = BehContext.Behavior;
|
|
|
|
beh->ActivateInput(IN_IN, FALSE);
|
|
|
|
CKVideo* video = (CKVideo*) beh->GetTarget();
|
|
if ( !video ) {
|
|
XString err = "Invalid Video";
|
|
beh->SetOutputParameterValue(POUT_ERROR, err.Str(), err.Length() + 1 );
|
|
beh->ActivateOutput(OUT_ERROR);
|
|
return CKBR_OK;
|
|
}
|
|
|
|
DWORD PropertyFlags;
|
|
beh->GetLocalParameterValue(SET_PROPERTYFLAGS, &PropertyFlags);
|
|
|
|
// This three calls will only fail if the source already exist,
|
|
// so if the first fail, all will. If the first don't, all won't !
|
|
if ( PropertyFlags & PROPERTY_TEXTURE ) {
|
|
CKTexture* tex = (CKTexture*) beh->GetInputParameterObject(PIN_TEXTURE);
|
|
RETURN_IF_FAILED( PIN_TEXTURE, video->SetTexture(tex) );
|
|
}
|
|
|
|
CKBOOL Set = FALSE;
|
|
CKBOOL AllowFormatChange, AllowConditionalTexture;
|
|
video->GetTextureOptions(AllowFormatChange, AllowConditionalTexture);
|
|
|
|
if ( PropertyFlags & PROPERTY_VIDEOFORMAT ) {
|
|
beh->GetInputParameterValue(PIN_VIDEOFORMAT, &AllowFormatChange);
|
|
Set = TRUE;
|
|
}
|
|
|
|
if ( PropertyFlags & PROPERTY_NONPOW2 ) {
|
|
beh->GetInputParameterValue(PIN_NONPOW2, &AllowConditionalTexture);
|
|
Set = TRUE;
|
|
}
|
|
|
|
if ( Set )
|
|
RETURN_IF_FAILED( PIN_VIDEOFORMAT, video->SetTextureOptions(AllowFormatChange, AllowConditionalTexture) );
|
|
|
|
beh->SetOutputParameterValue(POUT_ERROR, "Success", 8);
|
|
beh->ActivateOutput(OUT_OUT);
|
|
return CKBR_OK;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKERROR OutputPropertiesCB(const CKBehaviorContext& BehContext)
|
|
{
|
|
CKContext* ctx = BehContext.Context;
|
|
CKBehavior* beh = BehContext.Behavior;
|
|
|
|
// Get Settings
|
|
DWORD PropertyFlags;
|
|
beh->GetLocalParameterValue(SET_PROPERTYFLAGS, &PropertyFlags);
|
|
|
|
// Activate / Deactivate Pins
|
|
beh->EnableInputParameter(PIN_TEXTURE, PropertyFlags & PROPERTY_TEXTURE );
|
|
beh->EnableInputParameter(PIN_VIDEOFORMAT, PropertyFlags & PROPERTY_VIDEOFORMAT );
|
|
beh->EnableInputParameter(PIN_NONPOW2, PropertyFlags & PROPERTY_NONPOW2 );
|
|
|
|
return CKBR_OK;
|
|
}
|