150 lines
4.3 KiB
C++
150 lines
4.3 KiB
C++
/*************************************************************************/
|
|
/* File : InputControl.cpp */
|
|
/* */
|
|
/* Author : Leïla AIT KACI */
|
|
/* Last Modification : 28/05/03 */
|
|
/*************************************************************************/
|
|
#include "CKAll.h"
|
|
#include "CKVideo.h"
|
|
#include "CKVideoManager.h"
|
|
|
|
CKObjectDeclaration* FillBehaviorInputControlDecl ();
|
|
CKERROR CreateInputControlProto (CKBehaviorPrototype **);
|
|
int InputControl (const CKBehaviorContext& BehContext);
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Defines
|
|
//////////////////////////////////////////////////////////////////////
|
|
#define BB_NAME "Video Input Control"
|
|
#define BB_DESC "Modify a video's input 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_FORMAT,
|
|
PIN_FREQUENCY,
|
|
};
|
|
|
|
enum BB_POUT
|
|
{
|
|
POUT_ERROR
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKObjectDeclaration *FillBehaviorInputControlDecl()
|
|
{
|
|
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(0x379d35fa,0x226d6971));
|
|
od->SetCreationFunction(CreateInputControlProto);
|
|
|
|
return od;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKERROR CreateInputControlProto(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("Format ID", CKPGUID_INT, "-1");
|
|
proto->DeclareInParameter("Frequency", CKPGUID_FLOAT, "-1.0");
|
|
|
|
//--- Output Parameters Declaration
|
|
proto->DeclareOutParameter("Error", CKPGUID_STRING);
|
|
|
|
//---- Settings Declaration
|
|
|
|
proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);
|
|
proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE));
|
|
proto->SetFunction(InputControl);
|
|
|
|
*pproto = proto;
|
|
return CK_OK;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
int InputControl(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;
|
|
}
|
|
|
|
int FormatID = -1;
|
|
beh->GetInputParameterValue(PIN_FORMAT, &FormatID);
|
|
|
|
float Frequency = -1.0f;
|
|
beh->GetInputParameterValue(PIN_FREQUENCY, &Frequency);
|
|
|
|
CKERROR res = video->SetVideoInputFormat(FormatID, Frequency);
|
|
if ( res != CK_OK ) {
|
|
XString err;
|
|
err.Format("Pin 'Format' & 'Frequency': %s", video->GetErrorDescrition(res).CStr());
|
|
beh->SetOutputParameterValue(POUT_ERROR, err.Str(), err.Length() + 1 );
|
|
beh->ActivateOutput(OUT_ERROR);
|
|
return CKBR_OK;
|
|
}
|
|
|
|
beh->SetOutputParameterValue(POUT_ERROR, "Success", 8);
|
|
beh->ActivateOutput(OUT_OUT);
|
|
return CKBR_OK;
|
|
}
|