/*************************************************************************/ /* File : VideoProperties.cpp */ /* */ /* Author : Leïla AIT KACI */ /* Last Modification : 28/05/03 */ /*************************************************************************/ #include "CKAll.h" #include "CKVideo.h" #include "CKVideoManager.h" void RegisterVideoPropertiesParams (CKParameterManager* pm); void UnregisterVideoPropertiesParams (CKParameterManager* pm); CKObjectDeclaration* FillBehaviorVideoPropertiesDecl (); CKERROR CreateVideoPropertiesProto (CKBehaviorPrototype **); int VideoProperties (const CKBehaviorContext& BehContext); CKERROR VideoPropertiesCB (const CKBehaviorContext& BehContext); ////////////////////////////////////////////////////////////////////// // Defines ////////////////////////////////////////////////////////////////////// #define BB_NAME "Video Basic Properties" #define BB_DESC "Modify a video's global properties (static parameters)." #define BB_CAT "Video/Properties" #define BB_VERSION 0x00010000 #define BB_TARGET CKCID_VIDEO #define LOG_IF_FAILED(index, res) \ if ( res != CK_OK ) { \ XString err = "Pin '"; \ err += beh->GetInputParameter(index)->GetName(); \ err += "' - "; \ err += video->GetErrorDescrition(res); \ ctx->OutputToConsole(err.Str(), TRUE); \ } #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_INPUT_TYPE, PIN_OUTPUT_TYPE, PIN_ENABLE_AUDIO }; enum BB_POUT { POUT_ERROR }; ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// #define PROPERTY_GUID CKGUID(0x6c613f27,0x6f167551) #define PROPERTY_INPUT 0x00000001 #define PROPERTY_AUDIO 0x00000002 #define PROPERTY_OUTPUT 0x00000004 #define PROPERTY_DEFAULT "Input Type,Output Type,Enable Audio" void RegisterVideoPropertiesParams(CKParameterManager* pm) { pm->RegisterNewFlags(PROPERTY_GUID, "", "Input Type=1,Enable Audio=2,Output Type=4"); CKParameterTypeDesc* TypeDesc; TypeDesc = pm->GetParameterTypeDescription(PROPERTY_GUID); TypeDesc->dwFlags |= CKPARAMETERTYPE_HIDDEN; } void UnregisterVideoPropertiesParams(CKParameterManager* pm) { pm->UnRegisterParameterType(PROPERTY_GUID); } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// CKObjectDeclaration *FillBehaviorVideoPropertiesDecl() { 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(0x2722761a,0xdf12b01)); od->SetCreationFunction(CreateVideoPropertiesProto); return od; } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// CKERROR CreateVideoPropertiesProto(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("Input Type", CKPGUID_VIDEOINTYPE, "File" ); proto->DeclareInParameter("Output Type", CKPGUID_VIDEOOUTTYPE, "Screen"); proto->DeclareInParameter("Enable Audio", CKPGUID_BOOL, "TRUE" ); //--- Output Parameters Declaration proto->DeclareOutParameter("Error", CKPGUID_STRING); //---- Settings Declaration proto->DeclareSetting("Properties", PROPERTY_GUID, PROPERTY_DEFAULT); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_TARGETABLE)); proto->SetFunction(VideoProperties); proto->SetBehaviorCallbackFct(VideoPropertiesCB, CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORCREATE, NULL); *pproto = proto; return CK_OK; } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// int VideoProperties(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_INPUT ) { CK_VIDEO_TYPE InputType = CK_VIDEO_FILE; beh->GetInputParameterValue(PIN_INPUT_TYPE, &InputType); RETURN_IF_FAILED(PIN_INPUT_TYPE, video->SetType(InputType) ); } if ( PropertyFlags & PROPERTY_OUTPUT ) { CK_VIDEO_DISPLAY OutputType = CK_VIDEO_SCREEN; beh->GetInputParameterValue(PIN_OUTPUT_TYPE, &OutputType); LOG_IF_FAILED(PIN_OUTPUT_TYPE, video->SetDisplayMode(OutputType)); } if ( PropertyFlags & PROPERTY_AUDIO ) { CKBOOL EnableAudio = TRUE; beh->GetInputParameterValue(PIN_ENABLE_AUDIO, &EnableAudio); LOG_IF_FAILED(PIN_ENABLE_AUDIO, video->EnableAudio(EnableAudio)); } beh->SetOutputParameterValue(POUT_ERROR, "Success", 8); beh->ActivateOutput(OUT_OUT); return CKBR_OK; } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// CKERROR VideoPropertiesCB(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_INPUT_TYPE, PropertyFlags & PROPERTY_INPUT ); beh->EnableInputParameter(PIN_OUTPUT_TYPE, PropertyFlags & PROPERTY_OUTPUT ); beh->EnableInputParameter(PIN_ENABLE_AUDIO, PropertyFlags & PROPERTY_AUDIO ); return CKBR_OK; }