260 lines
7.2 KiB
C++
260 lines
7.2 KiB
C++
/*************************************************************************/
|
|
/* File : InputProperties.cpp */
|
|
/* */
|
|
/* Author : Leïla AIT KACI */
|
|
/* Last Modification : 28/05/03 */
|
|
/*************************************************************************/
|
|
#include "CKAll.h"
|
|
#include "CKVideo.h"
|
|
#include "CKVideoManager.h"
|
|
|
|
void RegisterInputPropertiesParams (CKParameterManager* pm);
|
|
void UnregisterInputPropertiesParams (CKParameterManager* pm);
|
|
|
|
CKObjectDeclaration* FillBehaviorInputPropertiesDecl ();
|
|
CKERROR CreateInputPropertiesProto (CKBehaviorPrototype **);
|
|
int InputProperties (const CKBehaviorContext& BehContext);
|
|
CKERROR InputPropertiesCB (const CKBehaviorContext& BehContext);
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Defines
|
|
//////////////////////////////////////////////////////////////////////
|
|
#define BB_NAME "Video Input Properties"
|
|
#define BB_DESC "Modify a video's input 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_TYPE,
|
|
SET_LIVEFLAGS
|
|
};
|
|
|
|
enum BB_PIN
|
|
{
|
|
PIN_PATH_URL,
|
|
PIN_VIDEOID,
|
|
PIN_AUDIOID,
|
|
};
|
|
|
|
enum BB_POUT
|
|
{
|
|
POUT_ERROR
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
#define LIVE_GUID CKGUID(0x68265c86,0x71d21b60)
|
|
#define LIVE_VIDEOID 0x01
|
|
#define LIVE_AUDIOID 0x02
|
|
#define LIVE_ALL "Video ID,Audio ID"
|
|
|
|
void RegisterInputPropertiesParams(CKParameterManager* pm)
|
|
{
|
|
pm->RegisterNewFlags(LIVE_GUID, "", "Video ID=1,Audio ID=2");
|
|
|
|
CKParameterTypeDesc* TypeDesc;
|
|
TypeDesc = pm->GetParameterTypeDescription(LIVE_GUID);
|
|
TypeDesc->dwFlags |= CKPARAMETERTYPE_HIDDEN;
|
|
}
|
|
|
|
void UnregisterInputPropertiesParams(CKParameterManager* pm)
|
|
{
|
|
pm->UnRegisterParameterType(LIVE_GUID);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKObjectDeclaration *FillBehaviorInputPropertiesDecl()
|
|
{
|
|
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(0x14322354,0x6bd50a97));
|
|
od->SetCreationFunction(CreateInputPropertiesProto);
|
|
|
|
return od;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKERROR CreateInputPropertiesProto(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("File", CKPGUID_STRING);
|
|
proto->DeclareInParameter("Video ID", CKPGUID_VIDEOCAPTURE);
|
|
proto->DeclareInParameter("Audio ID", CKPGUID_AUDIOCAPTURE);
|
|
|
|
//--- Output Parameters Declaration
|
|
proto->DeclareOutParameter("Error", CKPGUID_STRING);
|
|
|
|
//---- Settings Declaration
|
|
proto->DeclareSetting("Input Type", CKPGUID_VIDEOINTYPE, "File");
|
|
proto->DeclareSetting("Live Properties", LIVE_GUID, LIVE_ALL);
|
|
|
|
proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);
|
|
proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE));
|
|
proto->SetFunction(InputProperties);
|
|
proto->SetBehaviorCallbackFct(InputPropertiesCB, CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORCREATE, NULL);
|
|
|
|
*pproto = proto;
|
|
return CK_OK;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
int InputProperties(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 VideoType;
|
|
beh->GetLocalParameterValue(SET_TYPE, &VideoType);
|
|
|
|
switch (VideoType)
|
|
{
|
|
case CK_VIDEO_FILE:
|
|
{
|
|
XString path = (char*) beh->GetInputParameterReadDataPtr(PIN_PATH_URL);
|
|
RETURN_IF_FAILED( PIN_PATH_URL, video->SetFileName(path) );
|
|
}
|
|
break;
|
|
|
|
case CK_VIDEO_LIVE:
|
|
{
|
|
DWORD LiveFlags;
|
|
beh->GetLocalParameterValue(SET_LIVEFLAGS, &LiveFlags);
|
|
|
|
CKERROR res1;
|
|
if ( LiveFlags & LIVE_VIDEOID ) {
|
|
int VideoID = 0;
|
|
beh->GetInputParameterValue(PIN_VIDEOID, &VideoID);
|
|
res1 = video->SetVideoInputID(VideoID);
|
|
}
|
|
|
|
CKERROR res2;
|
|
if ( LiveFlags & LIVE_AUDIOID ) {
|
|
int AudioID = 0;
|
|
beh->GetInputParameterValue(PIN_AUDIOID, &AudioID);
|
|
res2 = video->SetAudioInputID(AudioID);
|
|
}
|
|
|
|
RETURN_IF_FAILED(PIN_VIDEOID, res1);
|
|
RETURN_IF_FAILED(PIN_AUDIOID, res2);
|
|
}
|
|
break;
|
|
|
|
case CK_VIDEO_STREAM:
|
|
{
|
|
XString path = (char*) beh->GetInputParameterReadDataPtr(PIN_PATH_URL);
|
|
RETURN_IF_FAILED( PIN_PATH_URL, video->SetUrl(path) );
|
|
}
|
|
break;
|
|
}
|
|
|
|
beh->SetOutputParameterValue(POUT_ERROR, "Success", 8);
|
|
beh->ActivateOutput(OUT_OUT);
|
|
return CKBR_OK;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////
|
|
CKERROR InputPropertiesCB(const CKBehaviorContext& BehContext)
|
|
{
|
|
CKContext* ctx = BehContext.Context;
|
|
CKBehavior* beh = BehContext.Behavior;
|
|
|
|
int VideoType;
|
|
beh->GetLocalParameterValue(SET_TYPE, &VideoType);
|
|
|
|
switch (VideoType)
|
|
{
|
|
case CK_VIDEO_FILE:
|
|
{
|
|
CKParameterIn* pin = beh->GetInputParameter(PIN_PATH_URL);
|
|
pin->SetName("File");
|
|
|
|
beh->EnableInputParameter(PIN_PATH_URL, TRUE);
|
|
beh->EnableInputParameter(PIN_VIDEOID, FALSE);
|
|
beh->EnableInputParameter(PIN_AUDIOID, FALSE);
|
|
}
|
|
break;
|
|
|
|
case CK_VIDEO_LIVE:
|
|
{
|
|
DWORD LiveFlags;
|
|
beh->GetLocalParameterValue(SET_LIVEFLAGS, &LiveFlags);
|
|
|
|
beh->EnableInputParameter(PIN_PATH_URL, FALSE);
|
|
beh->EnableInputParameter(PIN_VIDEOID, LiveFlags & LIVE_VIDEOID);
|
|
beh->EnableInputParameter(PIN_AUDIOID, LiveFlags & LIVE_AUDIOID);
|
|
}
|
|
break;
|
|
|
|
case CK_VIDEO_STREAM:
|
|
{
|
|
CKParameterIn* pin = beh->GetInputParameter(PIN_PATH_URL);
|
|
pin->SetName("Url");
|
|
|
|
beh->EnableInputParameter(PIN_PATH_URL, TRUE);
|
|
beh->EnableInputParameter(PIN_VIDEOID, FALSE);
|
|
beh->EnableInputParameter(PIN_AUDIOID, FALSE);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return CKBR_OK;
|
|
}
|