deargui-vpl/ref/virtools/Samples/Behaviors/Video/Sources/Output Control.cpp

162 lines
4.5 KiB
C++

/*************************************************************************/
/* File : OutputControl.cpp */
/* */
/* Author : Leïla AIT KACI */
/* Last Modification : 28/05/03 */
/*************************************************************************/
#include "CKAll.h"
#include "CKVideo.h"
#include "CKVideoManager.h"
void RegisterOutputControlParams (CKParameterManager* pm);
void UnregisterOutputControlParams (CKParameterManager* pm);
CKObjectDeclaration* FillBehaviorOutputControlDecl ();
CKERROR CreateOutputControlProto (CKBehaviorPrototype **);
int OutputControl (const CKBehaviorContext& BehContext);
//////////////////////////////////////////////////////////////////////
// Defines
//////////////////////////////////////////////////////////////////////
#define BB_NAME "Video Output Control"
#define BB_DESC "Modify a video's output controls (runtime parameters)."
#define BB_CAT "Video/Controls"
#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
{
};
enum BB_PIN
{
PIN_RECT,
// PIN_COLOR,
};
enum BB_POUT
{
POUT_ERROR
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void RegisterOutputControlParams(CKParameterManager* pm)
{
}
void UnregisterOutputControlParams(CKParameterManager* pm)
{
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
CKObjectDeclaration *FillBehaviorOutputControlDecl()
{
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(0x406d20da,0x23505c81));
od->SetCreationFunction(CreateOutputControlProto);
return od;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
CKERROR CreateOutputControlProto(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("Destination", CKPGUID_RECT);
// proto->DeclareInParameter("Border Color", CKPGUID_COLOR);
//--- Output Parameters Declaration
proto->DeclareOutParameter("Error", CKPGUID_STRING);
//---- Settings Declaration
proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);
proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE));
proto->SetFunction(OutputControl);
*pproto = proto;
return CK_OK;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
int OutputControl(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;
}
CKERROR res1;
VxRect Rect(0,0,0,0);
beh->GetInputParameterValue(PIN_RECT, &Rect);
res1 = video->SetDestination(Rect);
/* CKERROR res2;
VxColor BorderColor(0,0,0,0);
beh->GetInputParameterValue(PIN_COLOR, &BorderColor);
res2 = video->SetBorderColor(Color);
*/
RETURN_IF_FAILED( PIN_RECT, res1 );
// RETURN_IF_FAILED( PIN_COLOR, res2 );
beh->SetOutputParameterValue(POUT_ERROR, "Success", 8);
beh->ActivateOutput(OUT_OUT);
return CKBR_OK;
}