IAAFParameterDef *AAFDomainUtils::CreateParameterDefinition(IAAFDictionary *pDict, aafUID_t parmDefID) { IAAFParameterDef *parmDef; IAAFTypeDef *typeDef; AAFRESULT rc; // dprintf("AEffect::CreateParameterDefinition()\n"); rc = pDict->LookupParameterDef(parmDefID,&parmDef); if(rc == AAFRESULT_SUCCESS && parmDef != NULL) return parmDef; CAAFBuiltinDefs defs (pDict); CHECKAAF(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&parmDef)); AutoRelease<IAAFParameterDef> arParmDef(parmDef); if(memcmp(&parmDefID, &kAAFParameterDefLevel, sizeof(aafUID_t)) == 0) { CHECKAAF(pDict->LookupTypeDef(kAAFTypeID_Rational, &typeDef)); AutoRelease<IAAFTypeDef> r1( typeDef ); CHECKAAF(parmDef->Initialize(parmDefID, L"Level", L"fractional 0-1 inclusive", typeDef)); } else if(memcmp(&parmDefID, &kAAFParameterDefSMPTEWipeNumber, sizeof(aafUID_t)) == 0) { CHECKAAF(pDict->LookupTypeDef(kAAFTypeID_Int32, &typeDef)); AutoRelease<IAAFTypeDef> r2( typeDef ); CHECKAAF(parmDef->Initialize(parmDefID, L"WipeCode", L"SMPTE Wipe Code", typeDef)); } else { // Unrecognized parameter definition. Should we emit a log entry? return NULL; } if(parmDef != NULL) { CHECKAAF(pDict->RegisterParameterDef(parmDef)); // Since we are using the "auto release" for the return value that // we just created we need to bump the reference count. parmDef->AddRef(); } //cleanup: return(parmDef); }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFCompositionMob* pCompMob=NULL; IAAFMob* pMob = NULL; IAAFTimelineMobSlot* pNewSlot = NULL; IAAFSourceClip* pSourceClip = NULL; IAAFSourceReference* pSourceRef = NULL; IAAFTransition* pTransition = NULL; IAAFOperationGroup* pOperationGroup = NULL; IAAFSegment* pSegment = NULL; IAAFSegment* pEffectFiller = NULL; IAAFComponent* pComponent = NULL; IAAFFiller* pFiller = NULL; IAAFSequence* pSequence = NULL; IAAFOperationDef* pOperationDef = NULL; IAAFParameter *pParm = NULL; IAAFParameterDef* pParamDef = NULL; IAAFConstantValue* pConstantValue = NULL; HRESULT hr = S_OK; aafLength_t transitionLength; aafPosition_t cutPoint = 0; aafLength_t effectLen = TEST_EFFECT_LEN; aafUID_t effectID = kTestEffectID; aafUID_t parmID = kTestParmID; transitionLength = 100; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Create the effect and parameter definitions checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC)); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational ())); checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS)); checkResult(pDictionary->RegisterParameterDef(pParamDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); // ------------------------------------------------------------ // To test a Transition we need to create a Sequence which will // a Filler, a transition and another Filler. I know this is not // very interesting, but it will let us test the Transition // interface with the least amount of other stuff. // ------------------------------------------------------------ // // Create a CompositionMob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFCompositionMob, (IUnknown **)&pCompMob)); checkResult(pCompMob->Initialize(L"Transition Test")); // Get a MOB interface checkResult(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); // Create a Sequence checkResult(defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **) &pSequence)); // Get a Segment interface checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); // Get a component interface and checkResult(pSequence->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); // set the Data definition for it ! checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create a new Mob Slot that will contain the sequence aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"Transition", 0, &pNewSlot)); // Create a Filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); // Get a component interface checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pFiller->Release(); pFiller = NULL; pComponent->Release(); pComponent = NULL; checkResult(defs.cdTransition()-> CreateInstance(IID_IAAFTransition, (IUnknown **)&pTransition)); // Create an empty EffectGroup object !! checkResult(defs.cdOperationGroup()-> CreateInstance(IID_IAAFOperationGroup, (IUnknown **)&pOperationGroup)); checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), transitionLength, pOperationDef)); // Create a constant value parameter. checkResult(defs.cdConstantValue()-> CreateInstance(IID_IAAFConstantValue, (IUnknown **)&pConstantValue)); aafRational_t testLevel = {1, 2}; checkResult(pConstantValue->Initialize (pParamDef, sizeof(testLevel), (aafDataBuffer_t)&testLevel)); checkResult(pConstantValue->QueryInterface (IID_IAAFParameter, (void **)&pParm)); checkResult(pOperationGroup->AddParameter (pParm)); pParm->Release(); pParm = NULL; pConstantValue->Release(); pConstantValue = NULL; checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFSegment, (IUnknown **) &pEffectFiller)); checkResult(pEffectFiller->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; checkResult(pOperationGroup->AppendInputSegment (pEffectFiller)); // release the filler pEffectFiller->Release(); pEffectFiller = NULL; checkResult(pOperationGroup->SetBypassOverride (1)); checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); aafSourceRef_t sourceRef; sourceRef.sourceID = zeroMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(), effectLen, sourceRef)); checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pOperationGroup->SetRender (pSourceRef)); checkResult(pTransition->Initialize (defs.ddkAAFPicture(), transitionLength, cutPoint, pOperationGroup)); checkResult(pTransition->QueryInterface (IID_IAAFComponent, (void **)&pComponent)); // now append the transition checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create the second filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; pFiller->Release(); pFiller = NULL; // Now, we append the composition mob to the file checkResult(pHeader->AddMob(pMob)); // and we are done ! } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pParm) pParm->Release(); if (pConstantValue) pConstantValue->Release(); if (pParamDef) pParamDef->Release(); if (pSourceClip) pSourceClip->Release(); if (pSourceRef) pSourceRef->Release(); if (pNewSlot) pNewSlot->Release(); if (pSegment) pSegment->Release(); if (pSequence) pSequence->Release(); if (pFiller) pFiller->Release(); if (pOperationDef) pOperationDef->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pMob) pMob->Release(); if (pCompMob) pCompMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pTransition) pTransition->Release(); if (pFile) { if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFParameterDef* pParamDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; aafUID_t testParmID = kParmID; aafInt32 index; IAAFOperationDef *pOperationDef = NULL, *defResults[3] = { NULL, NULL, NULL }; /* long test; */ try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pParamDef->Initialize (testParmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational())); checkResult(pDictionary->RegisterParameterDef(pParamDef)); for(index = 0; index < 3; index++) { checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(pOperationDef->Initialize (effectID[index], effectNames[index], effectDesc[index])); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); defResults[index] = pOperationDef; pOperationDef = NULL; } checkResult(defResults[1]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[2]->AppendDegradeToOperation (defResults[2])); checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[0]->PrependDegradeToOperation (defResults[2])); // Add an extra one to delete for the test //!!! checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(3 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->RemoveDegradeToOperationAt (2)); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); for(index = 0; index < 3; index++) { defResults[index]->Release(); defResults[index] = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pOperationDef) pOperationDef->Release(); if (pParamDef) pParamDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFOperationDefs *pEffectEnum = NULL; IEnumAAFOperationDefs *pDegradeEnum = NULL; IEnumAAFParameterDefs *pParmDefEnum = NULL; IAAFOperationDef *pOperationDef = NULL; IAAFParameterDef *pParmDef = NULL; IAAFDefObject* pDefObject = NULL; bool bFileOpen = false; IAAFDataDefSP pReadDataDef; aafBool readIsTimeWarp; aafInt32 checkNumInputs; aafUInt32 checkBypass; HRESULT hr = S_OK; wchar_t checkName[256]; aafUID_t checkCat; aafBool bResult = kAAFFalse; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(pDictionary->GetOperationDefs(&pEffectEnum)); checkResult(pEffectEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->GetDataDef(&pReadDataDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[0]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[0]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; checkResult(pReadDataDef->IsDataDefOf(defs.ddkAAFPicture(), &bResult)); checkExpression(bResult == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->IsTimeWarp (&readIsTimeWarp)); checkExpression(readIsTimeWarp == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetCategory (&checkCat)); checkExpression(memcmp(&checkCat, &TEST_CATEGORY, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetBypass (&checkBypass)); checkExpression(checkBypass == TEST_BYPASS, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetNumberInputs (&checkNumInputs)); checkExpression(checkNumInputs == TEST_NUM_INPUTS, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetParameterDefs (&pParmDefEnum)); checkResult(pParmDefEnum->NextOne (&pParmDef)); checkResult(pParmDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, TEST_PARAM_NAME) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, TEST_PARAM_DESC) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; checkResult(pOperationDef->GetDegradeToOperations (&pDegradeEnum)); pOperationDef->Release(); pOperationDef = NULL; // Check for prepended one first checkResult(pDegradeEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[2]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[2]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; pOperationDef->Release(); pOperationDef = NULL; // Check for appended one second checkResult(pDegradeEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[1]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[1]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; pOperationDef->Release(); pOperationDef = NULL; } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pHeader) pHeader->Release(); if (pDictionary) pDictionary->Release(); if (pEffectEnum) pEffectEnum->Release(); if (pDegradeEnum) pDegradeEnum->Release(); if (pParmDefEnum) pParmDefEnum->Release(); if (pOperationDef) pOperationDef->Release(); if (pDefObject) pDefObject->Release(); if (pParmDef) pParmDef->Release(); if (pFile) { // Close file if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFOperationDef* pOperationDef = NULL; IAAFParameterDef* pParamDef = NULL; IAAFDefObject* pDefObject = NULL; IAAFOperationGroup *pOperationGroup = NULL; IAAFMob *pMob = NULL; IAAFSegment *pSeg = NULL; IAAFTimelineMobSlot *pSlot = NULL; IAAFParameter *pParm = NULL; IAAFVaryingValue *pVaryingValue = NULL; IAAFSegment *pFiller = NULL; IAAFComponent *pComponent = NULL; IAAFSourceClip *pSourceClip = NULL; IAAFControlPoint *pControlPoint = NULL; IAAFSourceReference *pSourceRef = NULL; IAAFInterpolationDef *pInterpDef = NULL; IAAFPluginManager *pMgr = NULL; IAAFTypeDef *pTypeDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; // aafUID_t testInterpDef = kAAFTypeID_Rational; aafLength_t effectLen = TEST_EFFECT_LEN; aafUID_t effectID = kTestEffectID; aafUID_t parmID = kTestParmID; aafRational_t testLevel1 = kTestLevel1; aafRational_t testLevel2 = kTestLevel2; aafRational_t testTime1 = kTestTime1; aafRational_t testTime2 = kTestTime2; /* long test; */ try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pDictionary->LookupTypeDef (kAAFTypeID_Rational, &pTypeDef)); checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, pTypeDef)); checkResult(AAFGetPluginManager(&pMgr)); checkResult(pMgr->CreatePluginDefinition(LinearInterpolator, pDictionary, &pDefObject)); checkResult(pDefObject->QueryInterface(IID_IAAFInterpolationDef, (void **) &pInterpDef)); pDefObject->Release(); pDefObject = NULL; checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC)); checkResult(pDictionary->RegisterOperationDef (pOperationDef)); checkResult(pDictionary->RegisterParameterDef (pParamDef)); checkResult(pDictionary->RegisterInterpolationDef (pInterpDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS)); //Make the first mob long test; aafRational_t videoRate = { 2997, 100 }; // Create a Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetName(L"AAFOperationGroupTest")); // Add some slots for(test = 0; test < 2; test++) { checkResult(defs.cdOperationGroup()-> CreateInstance(IID_IAAFOperationGroup, (IUnknown **)&pOperationGroup)); checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFSegment, (IUnknown **)&pFiller)); checkResult(pFiller->QueryInterface (IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetLength(effectLen)); CAAFBuiltinDefs defs(pDictionary); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), TEST_EFFECT_LEN, pOperationDef)); checkResult(defs.cdVaryingValue()-> CreateInstance(IID_IAAFVaryingValue, (IUnknown **)&pVaryingValue)); checkResult(pVaryingValue->Initialize (pParamDef, pInterpDef)); checkResult(defs.cdControlPoint()-> CreateInstance(IID_IAAFControlPoint, (IUnknown **)&pControlPoint)); checkResult(pControlPoint->Initialize (pVaryingValue, testTime1, sizeof(testLevel1), (aafDataBuffer_t)&testLevel1)); checkResult(pControlPoint->SetEditHint(kAAFRelativeLeft)); checkResult(pVaryingValue->AddControlPoint(pControlPoint)); pControlPoint->Release(); pControlPoint = NULL; checkResult(defs.cdControlPoint()-> CreateInstance(IID_IAAFControlPoint, (IUnknown **)&pControlPoint)); checkResult(pControlPoint->Initialize (pVaryingValue, testTime2, sizeof(testLevel2), (aafDataBuffer_t)&testLevel2)); checkResult(pControlPoint->SetEditHint(kAAFProportional)); checkResult(pVaryingValue->AddControlPoint(pControlPoint)); pControlPoint->Release(); pControlPoint = NULL; checkResult(pVaryingValue->QueryInterface (IID_IAAFParameter, (void **)&pParm)); checkResult(pOperationGroup->AddParameter (pParm)); checkResult(pOperationGroup->AppendInputSegment (pFiller)); pFiller->Release(); pFiller = NULL; checkResult(pOperationGroup->SetBypassOverride (1)); checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); aafSourceRef_t sourceRef; sourceRef.sourceID = zeroMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(), effectLen, sourceRef)); checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pOperationGroup->SetRender (pSourceRef)); checkResult(pOperationGroup->QueryInterface (IID_IAAFSegment, (void **)&pSeg)); checkResult(pMob->AppendNewTimelineSlot (videoRate, pSeg, test+1, slotNames[test], 0, &pSlot)); pSlot->Release(); pSlot = NULL; pSeg->Release(); pSeg = NULL; pOperationGroup->Release(); pOperationGroup = NULL; pParm->Release(); pParm = NULL; pVaryingValue->Release(); pVaryingValue = NULL; pComponent->Release(); pComponent = NULL; pSourceRef->Release(); pSourceRef = NULL; pSourceClip->Release(); pSourceClip = NULL; } // Add the mob to the file. checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if(pSourceRef) pSourceRef->Release(); if(pControlPoint) pControlPoint->Release(); if(pSourceClip) pSourceClip->Release(); if (pDefObject) pDefObject->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pMob) pMob->Release(); if (pSeg) pSeg->Release(); if (pSlot) pSlot->Release(); if (pComponent) pComponent->Release(); if (pParm) pParm->Release(); // if (pIntDef) // pIntDef->Release(); if (pInterpDef) pInterpDef->Release(); if (pVaryingValue) pVaryingValue->Release(); if (pFiller) pFiller->Release(); if (pOperationDef) pOperationDef->Release(); if (pParamDef) pParamDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if(pMgr) pMgr->Release(); if(pTypeDef) pTypeDef->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFOperationDefs *pOperationGroupEnum = NULL; IEnumAAFParameterDefs *pParmDefEnum = NULL; IAAFOperationDef *pOperationDef = NULL; IAAFParameterDef *pParmDef = NULL; IAAFParameter *pParameter = NULL; IAAFMetaDefinition* pMetaDefinition = NULL; IAAFSegment* pSeg = NULL; IAAFOperationGroup* pOperationGroup = NULL; IEnumAAFMobs *mobIter = NULL; IAAFMob* pMob = NULL; IEnumAAFMobSlots *slotIter = NULL; IAAFMobSlot* pSlot = NULL; IAAFFiller* pFill = NULL; IAAFSourceReference *pSourceRef = NULL; IEnumAAFControlPoints *pEnumCP = NULL; IAAFControlPoint *pControlPoint = NULL; IAAFVaryingValue *pVaryingValue = NULL; IAAFInterpolationDef *pInterpDef = NULL; IAAFTypeDef *pTypeDef = NULL; bool bFileOpen = false; aafBool readIsTimeWarp; aafUInt32 testNumSources, testNumParam; HRESULT hr = S_OK; aafNumSlots_t s; aafNumSlots_t numSlots; aafUInt32 readOverride; aafBool readValidTransition; aafRational_t testTime; aafRational_t sampleValue1 = kTestLevel1, sampleValue2 = kTestLevel2, testValue; aafRational_t checkTime1 = kTestTime1; aafRational_t checkTime2 = kTestTime2; aafEditHint_t checkEditHint; aafUID_t testInterpDef, checkInterpDef = kAAFTypeID_Rational; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); aafSearchCrit_t criteria; criteria.searchTag = kAAFNoSearch; checkResult(pHeader->GetMobs (&criteria, &mobIter)); checkResult(mobIter->NextOne (&pMob)); checkResult(pMob->GetSlots(&slotIter)); checkResult(pMob->CountSlots (&numSlots)); for(s = 0; s < numSlots; s++) { checkResult(slotIter->NextOne (&pSlot)); checkResult(pSlot->GetSegment (&pSeg)); checkResult(pSeg->QueryInterface (IID_IAAFOperationGroup, (void **)&pOperationGroup)); pSeg->Release(); pSeg = NULL; checkResult(pOperationGroup->CountSourceSegments(&testNumSources)); checkExpression(testNumSources == TEST_NUM_INPUTS, AAFRESULT_TEST_FAILED); checkResult(pOperationGroup->CountParameters(&testNumParam)); checkExpression(testNumSources == 1, AAFRESULT_TEST_FAILED); checkResult(pOperationGroup->IsATimeWarp (&readIsTimeWarp)); checkExpression(readIsTimeWarp == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pOperationGroup->GetBypassOverride (&readOverride)); checkExpression(readOverride == 1, AAFRESULT_TEST_FAILED); checkResult(pOperationGroup->IsValidTranOperation (&readValidTransition)); checkExpression(readValidTransition == kAAFFalse, AAFRESULT_TEST_FAILED); /**/ checkResult(pOperationGroup->GetInputSegmentAt (0, &pSeg)); checkResult(pSeg->QueryInterface(IID_IAAFFiller, (void **) &pFill)); pFill->Release(); pFill = NULL; /**/ checkResult(pOperationGroup->LookupParameter (kTestParmID, &pParameter)); checkResult(pParameter->QueryInterface(IID_IAAFVaryingValue, (void **) &pVaryingValue)); /*** Check the VaryingValue methods **/ aafUInt32 testLen, bytesRead; checkResult(pVaryingValue->GetControlPoints(&pEnumCP)); checkResult(pEnumCP->NextOne(&pControlPoint)); checkResult(pControlPoint->GetValueBufLen (&testLen)); checkExpression(testLen == sizeof(sampleValue1), AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetValue (sizeof(sampleValue1), (aafDataBuffer_t)&testValue, &bytesRead)); checkExpression(testValue.numerator == sampleValue1.numerator, AAFRESULT_TEST_FAILED); checkExpression(testValue.denominator == sampleValue1.denominator, AAFRESULT_TEST_FAILED); checkExpression(bytesRead == sizeof(sampleValue1), AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetTime(&testTime)); checkExpression(testTime.numerator == checkTime1.numerator, AAFRESULT_TEST_FAILED); checkExpression(testTime.denominator == checkTime1.denominator, AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetEditHint(&checkEditHint)); checkExpression(checkEditHint == kAAFRelativeLeft, AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetTypeDefinition (&pTypeDef)); checkResult(pTypeDef->QueryInterface(IID_IAAFMetaDefinition, (void **) &pMetaDefinition)); checkResult(pMetaDefinition->GetAUID(&testInterpDef)); checkExpression(memcmp(&testInterpDef, &checkInterpDef, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED); pControlPoint->Release(); pControlPoint = NULL; pTypeDef->Release(); pTypeDef = NULL; pMetaDefinition->Release(); pMetaDefinition = NULL; /**/ checkResult(pEnumCP->NextOne(&pControlPoint)); checkResult(pControlPoint->GetValueBufLen (&testLen)); checkExpression(testLen == sizeof(sampleValue2), AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetValue (sizeof(sampleValue2), (aafDataBuffer_t)&testValue, &bytesRead)); checkExpression(testValue.numerator == sampleValue2.numerator, AAFRESULT_TEST_FAILED); checkExpression(testValue.denominator == sampleValue2.denominator, AAFRESULT_TEST_FAILED); checkExpression(bytesRead == sizeof(sampleValue2), AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetTime(&testTime)); checkExpression(testTime.numerator == checkTime2.numerator, AAFRESULT_TEST_FAILED); checkExpression(testTime.denominator == checkTime2.denominator, AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetEditHint(&checkEditHint)); checkExpression(checkEditHint == kAAFProportional, AAFRESULT_TEST_FAILED); checkResult(pControlPoint->GetTypeDefinition (&pTypeDef)); checkResult(pTypeDef->QueryInterface(IID_IAAFMetaDefinition, (void **) &pMetaDefinition)); checkResult(pMetaDefinition->GetAUID(&testInterpDef)); checkExpression(memcmp(&testInterpDef, &checkInterpDef, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED); pControlPoint->Release(); pControlPoint = NULL; pEnumCP->Release(); pEnumCP = NULL; pTypeDef->Release(); pTypeDef = NULL; pMetaDefinition->Release(); pMetaDefinition = NULL; /*****/ pVaryingValue->Release(); pVaryingValue = NULL; pParameter->Release(); pParameter = NULL; pSeg->Release(); pSeg = NULL; pOperationGroup->Release(); pOperationGroup = NULL; pSlot->Release(); pSlot = NULL; } slotIter->Release(); slotIter = NULL; pMob->Release(); pMob = NULL; } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pFill) pFill->Release(); if(pInterpDef) pInterpDef->Release(); if(pVaryingValue) pVaryingValue->Release(); if (pSourceRef) pSourceRef->Release(); if (mobIter) mobIter->Release(); if (pSlot) pSlot->Release(); if (slotIter) slotIter->Release(); if (pMob) pMob->Release(); if (pHeader) pHeader->Release(); if (pSeg) pSeg->Release(); if (pControlPoint) pControlPoint->Release(); if(pEnumCP) pEnumCP->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pDictionary) pDictionary->Release(); if (pOperationGroupEnum) pOperationGroupEnum->Release(); if (pParameter) pParameter->Release(); if (pParmDefEnum) pParmDefEnum->Release(); if (pOperationDef) pOperationDef->Release(); if (pMetaDefinition) pMetaDefinition->Release(); if (pParmDef) pParmDef->Release(); if (pTypeDef) pTypeDef->Release(); if (pFile) { // Close file if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }