static HRESULT CreateAAFSequence(IAAFDictionary *pDictionary, IAAFSequence** ppSequence) { IAAFSequence* pSequence = NULL; HRESULT hr = S_OK; aafUInt32 i; CAAFBuiltinDefs defs (pDictionary); hr = defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence); if (SUCCEEDED(hr)) { pSequence->Initialize(defs.ddkAAFSound()); // // Add some segments. Need to test failure conditions // (i.e. starting/ending w/ transition, two trans back // to bacl). // for(i = 0; i < kNumComponents; i++) { IAAFComponent* pComponent = NULL; aafLength_t len = 10; hr = defs.cdFiller()-> CreateInstance(IID_IAAFComponent, (IUnknown **)&pComponent); if (FAILED(hr)) break; pComponent->SetDataDef(defs.ddkAAFSound()); pComponent->SetLength(len); hr = pSequence->AppendComponent(pComponent); pComponent->Release(); pComponent = NULL; if (FAILED(hr)) break; } } if (SUCCEEDED(hr)) { *ppSequence = pSequence; } else { pSequence->Release(); *ppSequence = NULL; } return hr; }
static HRESULT ReadAAFFile(aafWChar * pFileName) { // IAAFSession * pSession = NULL; IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFMobs* pMobIter = NULL; IEnumAAFMobSlots* pEnum = NULL; IAAFMob* pMob = NULL; IAAFMobSlot* pMobSlot = NULL; IAAFSegment* pSegment = NULL; IAAFSequence* pSequence = NULL; IAAFTransition* pTransition = NULL; IAAFComponent* pComponent = NULL; IAAFFiller* pFiller = NULL; IAAFOperationGroup* pOperationGroup = NULL; IEnumAAFComponents* pCompIter = NULL; aafLength_t transitionLength; aafPosition_t cutPoint; aafNumSlots_t numMobs; aafUInt32 numComponents = 0; HRESULT hr = S_OK; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the number of mobs in the file (should be one) checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->GetMobs( NULL, &pMobIter)); while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)) { checkResult(pMob->GetSlots (&pEnum)); while (AAFRESULT_SUCCESS == pEnum->NextOne (&pMobSlot)) { checkResult(pMobSlot->GetSegment (&pSegment)); // Check to see if Segment is a Sequence checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **) &pSequence)); // It is, so get a Component Iterator checkResult(pSequence->CountComponents(&numComponents)); // Verify that all 3 components(Filler, Transition, Filler) are present checkExpression(numComponents == 3, AAFRESULT_TEST_FAILED); checkResult(pSequence->GetComponents(&pCompIter)); // Now visit each and every one of the components. while(AAFRESULT_SUCCESS == pCompIter->NextOne(&pComponent)) { // Find out what kind of segment we have if ((pComponent->QueryInterface(IID_IAAFTransition, (void **)&pTransition)) == AAFRESULT_SUCCESS) { // This is the transition checkResult(pTransition->GetCutPoint (&cutPoint)); checkResult(pComponent->GetLength(&transitionLength)); checkResult(pTransition->GetOperationGroup(&pOperationGroup)); // Check results !! checkExpression(cutPoint == 0, AAFRESULT_TEST_FAILED); checkExpression(transitionLength == 100, AAFRESULT_TEST_FAILED); pTransition->Release(); pTransition = NULL; } else { // validate that the other segments are Fillers checkResult(pComponent->QueryInterface(IID_IAAFFiller, (void **)&pFiller)); pFiller->Release(); pFiller = NULL; } pComponent->Release(); pComponent = NULL; } pSegment->Release(); pSegment = NULL; pSequence->Release(); pSequence = NULL; pCompIter->Release(); pCompIter = NULL; } pMob->Release(); pMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pTransition) pTransition->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pComponent) pComponent->Release(); if (pSegment) pSegment->Release(); if (pMobSlot) pMobSlot->Release(); if (pSequence) pSequence->Release(); if (pCompIter) pCompIter->Release(); if (pEnum) pEnum->Release(); if (pFiller) pFiller->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { 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; 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) { // IAAFSession* pSession = NULL; IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMob* pReferencedMob = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; bool bFileOpen = false; HRESULT hr = AAFRESULT_SUCCESS; IAAFComponent* pComponent = NULL; 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); //Make the MOB to be referenced checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pReferencedMob)); checkResult(pReferencedMob->SetMobID(TEST_referencedMobID)); checkResult(pReferencedMob->SetName(L"AAFSourceClipTest::ReferencedMob")); // Create a Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"AAFSourceClipTest")); // Create a SourceClip checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSegment, (IUnknown **)&seg)); checkResult(seg->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot (editRate, seg, 1, slotName, 0, &newSlot)); checkResult(pHeader->AddMob(pMob)); checkResult(pHeader->AddMob(pReferencedMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (newSlot) newSlot->Release(); if (pComponent) pComponent->Release(); if (seg) seg->Release(); if (pMob) pMob->Release(); if (pReferencedMob) pReferencedMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->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; 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 TestEnumerator(IAAFSequence* pSequence) { IEnumAAFComponents* pCompIter = NULL; IEnumAAFComponents* pCompCloneIter = NULL; IAAFComponent* pComp = NULL; IAAFComponent* pCompArray[kNumComponents] = {0}; aafUInt32 numFetched, i, j; HRESULT hr = S_OK, localhr = S_OK; aafUInt32 numCpnts; pSequence->CountComponents(&numCpnts); if (numCpnts != kNumComponents) return AAFRESULT_TEST_FAILED; hr = pSequence->GetComponents(&pCompIter); if (FAILED(hr)) return AAFRESULT_TEST_FAILED; /* Test the Reset method *******************************/ if (pCompIter->Reset() == AAFRESULT_SUCCESS) cout<< " Reset() ... Passed" << endl; else { cout<< " Reset() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Test the NextOne method ******************************/ // Call NextOne once for each mob for a total of numCpnts times for (i=0; i<numCpnts; i++) { if (pCompIter->NextOne(&pComp) == AAFRESULT_SUCCESS) { pComp->Release(); pComp = NULL; } else { localhr = AAFRESULT_TEST_FAILED; } } // Make sure we are at the end if (pCompIter->NextOne(&pComp) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); // this should return AAFRESULT_NULL_PARAM if (pCompIter->NextOne(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " NextOne() ... Passed" << endl; else { cout<< " NextOne() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Test the Skip method ******************************/ localhr = S_OK; pCompIter->Reset(); // skip over each Component one at a time. for (i=0; i<numCpnts; i++) if (pCompIter->Skip(1) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Make sure we are at the end. if (pCompIter->Skip(1) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); // Skip over multiple Components at a time. for (i=2; i<=numCpnts; i++) { if (pCompIter->Skip(i) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); } // Make sure we can't skip past the end. if (pCompIter->Skip(i+1) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " Skip() ... Passed" << endl; else { cout<< " Skip() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Next() ******************************************/ localhr = S_OK; pCompIter->Reset(); numFetched = 1; // Iterate thru the Components using Next doing 1 at a time pCompIter->Reset(); for ( i=0; i<numCpnts ;i++) { if (pCompIter->Next(1, &pComp, &numFetched) == AAFRESULT_SUCCESS) { pComp->Release(); pComp = NULL; if (1 != numFetched) localhr = AAFRESULT_TEST_FAILED; } else localhr = AAFRESULT_TEST_FAILED; } // Make sure we are at the end if (pCompIter->Next(1, &pComp, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; // Test the Next method filling out an array of Components numFetched = 0; pCompIter->Reset(); for ( i=2; i<=numCpnts ;i++) { if (pCompIter->Next(i, pCompArray, &numFetched) == AAFRESULT_SUCCESS) { if (i != numFetched) localhr = AAFRESULT_TEST_FAILED; for (j = 0; j < numFetched; j++) { if (pCompArray[j] != NULL) // should have been set { pCompArray[j]->Release(); pCompArray[j] = NULL; } else { localhr = AAFRESULT_TEST_FAILED; } } } else { localhr = AAFRESULT_TEST_FAILED; } pCompIter->Reset(); } // Make sure we can't get more Mobs than numCpnts if (pCompIter->Next(i+1, pCompArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (numCpnts != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numCpnts; i++) if (pCompArray[i] != NULL) { pCompArray[i]->Release(); pCompArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); pCompIter->Skip(2); // Make sure we can't go past the end to fill the array if (pCompIter->Next(numCpnts, pCompArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if ((numCpnts-2) != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numCpnts-2; i++) if (pCompArray[i] != NULL) { pCompArray[i]->Release(); pCompArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); // Make sure it returns AAFRESULT_NULL_PARAM if (pCompIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; // Make sure it returns AAFRESULT_NULL_PARAM if (pCompIter->Next(1, pCompArray, NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " Next() ... Passed" << endl; else { cout<< " Next() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Clone() ************************************/ // Test the Clone method with with enumerator at begining localhr = S_OK; pCompIter->Reset(); if (pCompIter->Clone(&pCompCloneIter) == AAFRESULT_SUCCESS) { for (i=0; i < numCpnts; i++) { if (pCompCloneIter->NextOne(&pComp) == AAFRESULT_SUCCESS) { pComp->Release(); pComp = NULL; } else localhr = AAFRESULT_TEST_FAILED; } if (pCompCloneIter->NextOne(&pComp) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; pCompCloneIter->Reset(); if (pCompCloneIter->Next(numCpnts, pCompArray, &numFetched) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; if (numCpnts != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numCpnts; i++) { if (pCompArray[i] != NULL) { pCompArray[i]->Release(); pCompArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } pCompCloneIter->Reset(); if (pCompCloneIter->Next(numCpnts+1, pCompArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (numCpnts != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numCpnts; i++) { if (pCompArray[i] != NULL) { pCompArray[i]->Release(); pCompArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } pCompCloneIter->Reset(); pCompCloneIter->Skip(1); if (pCompCloneIter->Next(numCpnts, pCompArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if ((numCpnts-1) != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numCpnts-1; i++) { if (pCompArray[i] != NULL) { pCompArray[i]->Release(); pCompArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } pCompCloneIter->Release(); pCompCloneIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; // Test the Clone method with with enumerator at end. // Indirectly tests the Skip and Reset methods. pCompIter->Reset(); pCompIter->Skip(numCpnts-1); if (pCompIter->Clone(&pCompCloneIter) == AAFRESULT_SUCCESS) { if (pCompCloneIter->NextOne(&pComp) == AAFRESULT_SUCCESS) { pComp->Release(); pComp = NULL; } if (pCompCloneIter->NextOne(&pComp) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; pCompCloneIter->Release(); pCompCloneIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; // Test the Clone method with with enumerator in the middle. // Indirectly tests the Skip and Reset methods. pCompIter->Reset(); pCompIter->Skip(numCpnts-2); if (pCompIter->Clone(&pCompCloneIter) == AAFRESULT_SUCCESS) { pCompCloneIter->Skip(1); if (pCompCloneIter->NextOne(&pComp) == AAFRESULT_SUCCESS) { pComp->Release(); pComp = NULL; } else localhr = AAFRESULT_TEST_FAILED; if (pCompCloneIter->NextOne(&pComp) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; pCompCloneIter->Release(); pCompCloneIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; pCompIter->Reset(); if (pCompIter->Clone(&pCompCloneIter) == AAFRESULT_SUCCESS) { if (pCompCloneIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; if (pCompCloneIter->Next(1, pCompArray, NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; pCompCloneIter->Release(); pCompCloneIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " Clone() ... Passed" << endl; else { cout<< " Clone() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } if (pComp) pComp->Release(); if (pCompIter) pCompIter->Release(); if (pCompCloneIter) pCompCloneIter->Release(); for (numCpnts=0; numCpnts < kNumComponents; ++numCpnts) if (pCompArray[numCpnts]) pCompArray[numCpnts]->Release(); return hr; }
static HRESULT CreateAAFFile(aafWChar * pFileName, long int N) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMob* pCompMob = NULL; IAAFEssenceDescriptor* aDesc = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFSourceMob* pFileMob = NULL; IAAFSourceMob* pTapeMob = NULL; IAAFSequence* pSequence = NULL; IAAFComponent* aComponent = NULL; IAAFFileDescriptor* pFileDesc = NULL; IAAFAIFCDescriptor* pAIFCDesc = NULL; IAAFTapeDescriptor* pTapeDesc = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; IAAFSourceClip* fileSclp = NULL; IAAFSourceClip* masterSclp = NULL; IAAFSourceClip* compSclp = NULL; IAAFComponent* compFill = NULL; IAAFLocator* pLocator = NULL; IAAFNetworkLocator* pNetLocator = NULL; IAAFClassDef * pCDCompositionMob = 0; IAAFClassDef * pCDSequence = 0; IAAFClassDef * pCDSourceMob = 0; IAAFClassDef * pCDTapeDescriptor = 0; IAAFClassDef * pCDAIFCDescriptor = 0; IAAFClassDef * pCDNetworkLocator = 0; IAAFClassDef * pCDMasterMob = 0; IAAFClassDef * pCDSourceClip = 0; IAAFClassDef * pCDFiller = 0; IAAFDataDef * pDdefPicture = 0; aafRational_t videoRate = { 30000, 1001 }; aafMobID_t tapeMobID, fileMobID, masterMobID; aafTimecode_t tapeTC = { 108000, kAAFTcNonDrop, 30}; aafLength_t fileLen = FILE1_LENGTH; aafLength_t fillLen = FILL_LENGTH; aafLength_t segLen = SEG_LENGTH; aafProductIdentification_t ProductInfo; long int i = 0; moduleErrorTmp = S_OK; // delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), pFileName); remove(chFileName); aafProductVersion_t v; v.major = 1; v.minor = 0; v.tertiary = 0; v.patchLevel = 0; v.type = kAAFVersionUnknown; ProductInfo.companyName = companyName; ProductInfo.productName = productName; ProductInfo.productVersion = &v; ProductInfo.productVersionString = NULL; ProductInfo.productID = NIL_UID; ProductInfo.platform = NULL; #if defined(USE_MEMORY_FILE) check(MemoryFileOpenNewModify (0, &ProductInfo, &pFile)); #else check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile)); #endif check(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. check(pHeader->GetDictionary(&pDictionary)); check(pDictionary->LookupClassDef(AUID_AAFCompositionMob, &pCDCompositionMob)); check(pDictionary->LookupClassDef(AUID_AAFSequence, &pCDSequence)); check(pDictionary->LookupClassDef(AUID_AAFSourceMob, &pCDSourceMob)); check(pDictionary->LookupClassDef(AUID_AAFTapeDescriptor, &pCDTapeDescriptor)); check(pDictionary->LookupClassDef(AUID_AAFAIFCDescriptor, &pCDAIFCDescriptor)); check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator, &pCDNetworkLocator)); check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &pCDMasterMob)); check(pDictionary->LookupClassDef(AUID_AAFSourceClip, &pCDSourceClip)); check(pDictionary->LookupClassDef(AUID_AAFFiller, &pCDFiller)); check(pDictionary->LookupDataDef(kAAFDataDef_Picture, &pDdefPicture)); // IMPORTANT: major remodification is from this point onwards... // sequence creation code pulled out of the subsequent loop. // Create a Composition Mob check(pCDCompositionMob->CreateInstance(IID_IAAFMob, (IUnknown **)&pCompMob)); check(pCDSequence->CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence)); check(pSequence->QueryInterface (IID_IAAFSegment, (void **)&seg)); check(pSequence->QueryInterface(IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pDdefPicture)); aComponent->Release(); aComponent = NULL; check(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->AppendNewTimelineSlot(videoRate, seg, i, slotName, 0, &newSlot)); pMob->Release(); pMob = NULL; newSlot->Release(); newSlot = NULL; seg->Release(); seg = NULL; check(pHeader->AddMob(pCompMob)); // now looping around the remainder N times to make N components for (i=0; i < N; i++) { //Make the Tape MOB check(pCDSourceMob->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pTapeMob)); check(pCDTapeDescriptor->CreateInstance(IID_IAAFTapeDescriptor, (IUnknown **)&pTapeDesc)); check(pTapeDesc->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&aDesc)); check(pTapeMob->SetEssenceDescriptor(aDesc)); aDesc->Release(); aDesc = NULL; pTapeDesc->Release(); pTapeDesc = NULL; check(pTapeMob->AppendTimecodeSlot (videoRate, 0, tapeTC, TAPE_LENGTH)); check(pTapeMob->AddNilReference (1,TAPE_LENGTH, pDdefPicture, videoRate)); check(pTapeMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); pTapeMob->Release(); pTapeMob = NULL; // NOTE: TapeMob name is updated to change with number of objects // requested at cli. // In order to fit with the specification, it is made wide char TapeMobNameBuffer[MAX]; sprintf(TapeMobNameBuffer,"Tape Mob %ld",i); aafWChar TapeMobName[MAX]; mbstowcs(TapeMobName,TapeMobNameBuffer,MAX); check(pMob->SetName (TapeMobName)); check(pHeader->AddMob(pMob)); check(pMob->GetMobID (&tapeMobID)); pMob->Release(); pMob = NULL; // Make a FileMob check(pCDSourceMob->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pFileMob)); check(pCDAIFCDescriptor->CreateInstance(IID_IAAFFileDescriptor, (IUnknown **)&pFileDesc)); check(pFileDesc->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&aDesc)); check(pFileDesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; // Make a locator, and attach it to the EssenceDescriptor check(pCDNetworkLocator->CreateInstance(IID_IAAFNetworkLocator, (IUnknown **)&pNetLocator)); check(pNetLocator->QueryInterface (IID_IAAFLocator, (void **)&pLocator)); check(pLocator->SetPath (TEST_PATH)); check(aDesc->AppendLocator(pLocator)); pLocator->Release(); pLocator = NULL; pNetLocator->Release(); pNetLocator = NULL; check(pFileMob->SetEssenceDescriptor(aDesc)); aDesc->Release(); aDesc = NULL; pFileDesc->Release(); pFileDesc = NULL; sourceRef.sourceID = tapeMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(pFileMob->NewPhysSourceRef (videoRate, 1, pDdefPicture, sourceRef, fileLen)); check(pFileMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID (&fileMobID)); check(pHeader->AddMob(pMob)); pMob->Release(); pMob = NULL; //Make the Master MOB check(pCDMasterMob->CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pMasterMob)); sourceRef.sourceID = fileMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(pMasterMob->NewPhysSourceRef(videoRate, 1, pDdefPicture, sourceRef, fileLen)); check(pMasterMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID (&masterMobID)); // NOTE: MasterMob name is updated to change with number of objects // requested at cli. // In order to fit with the specification, it is made wide char MasterMobNameBuffer[MAX]; sprintf(MasterMobNameBuffer,"Master Mob %ld",i); aafWChar MasterMobName[MAX]; mbstowcs(MasterMobName,MasterMobNameBuffer,MAX); check(pMob->SetName (MasterMobName)); check(pHeader->AddMob(pMob)); pMob->Release(); pMob = NULL; // the remaining part of the sequence code, adapted for updating slot names // Create a SourceClip check(pCDSourceClip->CreateInstance(IID_IAAFSourceClip, (IUnknown **)&compSclp)); sourceRef.sourceID = masterMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(compSclp->SetSourceReference (sourceRef)); check(compSclp->QueryInterface (IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pDdefPicture)); check(aComponent->SetLength (segLen)); check(pSequence->AppendComponent (aComponent)); // Create a filler - Get the component interface only (IID_IAAFComponent) check(pCDFiller->CreateInstance(IID_IAAFComponent, (IUnknown **)&compFill)); check(compFill->SetLength (fillLen)); check(compFill->SetDataDef(pDdefPicture)); check(pSequence->AppendComponent (compFill)); compFill->Release(); compFill = NULL; aComponent->Release(); aComponent = NULL; compSclp->Release(); compSclp = NULL; pMasterMob->Release(); pMasterMob = NULL; pFileMob->Release(); pFileMob = NULL; // end of loop since only one dictionary and header are needed // the file is then saved, closed and released after all modifications // are complete } cleanup: // Cleanup and return if (pNetLocator) pNetLocator->Release(); if (pLocator) pLocator->Release(); if (compFill) compFill->Release(); if (compSclp) compSclp->Release(); if (masterSclp) masterSclp->Release(); if (fileSclp) fileSclp->Release(); if (pTapeDesc) pTapeDesc->Release(); if (pFileDesc) pFileDesc->Release(); if (pTapeMob) pTapeMob->Release(); if (pFileMob) pFileMob->Release(); if (pMasterMob) pMasterMob->Release(); if (aDesc) aDesc->Release(); if (newSlot) newSlot->Release(); if (pMob) pMob->Release(); if (pCompMob) pCompMob->Release(); if (seg) seg->Release(); if (aComponent) aComponent->Release(); if (pSequence) pSequence->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pCDCompositionMob) { pCDCompositionMob->Release(); pCDCompositionMob = 0; } if (pCDSequence) { pCDSequence->Release(); pCDSequence = 0; } if (pCDSourceMob) { pCDSourceMob->Release(); pCDSourceMob = 0; } if (pCDTapeDescriptor) { pCDTapeDescriptor->Release(); pCDTapeDescriptor = 0; } if (pCDAIFCDescriptor) { pCDAIFCDescriptor->Release(); pCDAIFCDescriptor = 0; } if (pCDNetworkLocator) { pCDNetworkLocator->Release(); pCDNetworkLocator = 0; } if (pCDMasterMob) { pCDMasterMob->Release(); pCDMasterMob = 0; } if (pCDSourceClip) { pCDSourceClip->Release(); pCDSourceClip = 0; } if (pCDFiller) { pCDFiller->Release(); pCDFiller = 0; } if (pDdefPicture) { pDdefPicture->Release(); pDdefPicture = 0; } if (pFile) { clock_t start = clock(); clock_t finish; double duration; pFile->Save(); pFile->Close(); #if defined(USE_MEMORY_FILE) check(MemoryFileSaveToDisk(pFileName, pFile)); #endif finish = clock(); duration = ((double) (finish - start) / CLOCKS_PER_SEC); pFile->Release(); printf("Save time = %f seconds\n", duration); } return moduleErrorTmp; }
static HRESULT ProcessAAFFile(const aafWChar * pFileName, testType_t testType) { IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFMobs* pMobIter = NULL; aafNumSlots_t numMobs, numSlots; aafSearchCrit_t criteria; aafMobID_t mobID; aafWChar namebuf[1204]; const aafWChar* slotName = L"A slot in Composition Mob"; IAAFComponent* pComponent = NULL; IAAFComponent* aComponent = NULL; IEnumAAFMobSlots* pMobSlotIter = NULL; IAAFMobSlot* pMobSlot = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; IAAFSegment* pSegment = NULL; IAAFMob* pCompMob = NULL; IAAFMob* pMob = NULL; aafPosition_t zeroPos = 0; IAAFSequence* pAudioSequence = NULL; IAAFSourceClip* pSourceClip = NULL; aafLength_t duration; IAAFTimelineMobSlot* pTimelineMobSlot = NULL; IAAFClassDef *pCompositionMobDef = NULL; IAAFClassDef *pSequenceDef = NULL; IAAFClassDef *pSourceClipDef = NULL; IAAFDataDef *pSoundDef = NULL; IAAFDataDef *pDataDef = NULL; // Set the edit rate information aafRational_t editRate; editRate.numerator = 48000; editRate.denominator = 1; // Set search condition to true bool lookingForAudio = true; // Call the routine (from ExportAudioExample) to make the file for processing check(CreateAAFFile(pwFileName, NULL, testStandardCalls, &pFile)); /* Get the Header and iterate through the Master Mobs in the existing file */ check(pFile->GetHeader(&pHeader)); check(pHeader->GetDictionary(&pDictionary)); /* Lookup class definitions for the objects we want to create. */ check(pDictionary->LookupClassDef(AUID_AAFCompositionMob, &pCompositionMobDef)); check(pDictionary->LookupClassDef(AUID_AAFSequence, &pSequenceDef)); check(pDictionary->LookupClassDef(AUID_AAFSourceClip, &pSourceClipDef)); /* Lookup any necessary data definitions. */ check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pSoundDef)); // Get the number of master mobs in the existing file (must not be zero) check(pHeader->CountMobs(kAAFMasterMob, &numMobs)); if (numMobs != 0) { printf("Found %d Master Mobs\n", numMobs); criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFMasterMob; check(pHeader->GetMobs(&criteria, &pMobIter)); /* Create a Composition Mob */ check(pCompositionMobDef-> CreateInstance(IID_IAAFMob, (IUnknown **)&pCompMob)); /* Append the Mob to the Header */ check(pHeader->AddMob(pCompMob)); /* Create a TimelineMobSlot with an audio sequence */ check(pSequenceDef-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pAudioSequence)); check(pAudioSequence->QueryInterface(IID_IAAFSegment, (void **)&seg)); check(pAudioSequence->QueryInterface(IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pSoundDef)); check(pCompMob->AppendNewTimelineSlot(editRate, seg, 1, slotName, zeroPos, &newSlot)); seg->Release(); seg = NULL; newSlot->Release(); newSlot = NULL; // This variable is about to be overwritten so we need to release the old interface aComponent->Release(); aComponent = NULL; while((AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))) { // Print out information about the Mob char mobIDstr[256]; char mobName[256]; check(pMob->GetMobID (&mobID)); check(pMob->GetName (namebuf, sizeof(namebuf))); convert(mobName, sizeof(mobName), namebuf); MobIDtoString(mobID, mobIDstr); printf(" MasterMob Name = '%s'\n", mobName); printf(" (mobID %s)\n", mobIDstr); // Add a Source Clip for each Master Mob to the audio sequence by iterating check(pMob->GetSlots(&pMobSlotIter)); /* Iterating through all Mob Slots */ // Get the number of slots check(pMob->CountSlots(&numSlots)); while (lookingForAudio && (AAFRESULT_SUCCESS == pMobSlotIter->NextOne(&pMobSlot))); { /* Check to see if it is an Audio Timeline Mob Slot */ HRESULT hr; hr=pMobSlot->QueryInterface(IID_IAAFTimelineMobSlot,(void **) &pTimelineMobSlot); if (SUCCEEDED(hr)) { printf("Found a timeline mob slot\n"); check(pMobSlot->GetDataDef(&pDataDef)); // Check that we have a sound file by examining its data definition aafBool bIsSoundKind = kAAFFalse; check(pDataDef->IsSoundKind(&bIsSoundKind)); if (kAAFTrue == bIsSoundKind) { printf("Found a sound file\n"); // We are no longer looking for audio data so set boolean lookingForAudio = false; /* Get the information for the new source clip */ check(pMob->GetMobID(&sourceRef.sourceID)); check(pMobSlot->GetSlotID(&sourceRef.sourceSlotID)); check(pTimelineMobSlot->GetOrigin(&sourceRef.startTime)); check(pMobSlot->GetSegment(&pSegment)); check(pSegment->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); check(pComponent->GetLength(&duration)); pComponent->Release(); pComponent = NULL; pSegment->Release(); pSegment = NULL; // this loop is to be removed upon fixing of the bug // in essenceaccess relating to codec definitions... int j = 0; for (j=0; j<10; j++) { /* Create a new Source Clip */ check(pSourceClipDef-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); // Initialize the Source Clip check(pSourceClip->Initialize( pSoundDef, duration, sourceRef)); check(pSourceClip->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); check(pAudioSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; pSourceClip->Release(); pSourceClip = NULL; } } pTimelineMobSlot->Release(); pTimelineMobSlot = NULL; pDataDef->Release(); pDataDef = NULL; } pMobSlot->Release(); pMobSlot = NULL; } pMobSlotIter->Release(); pMobSlotIter = NULL; pMob->Release(); pMob = NULL; } pAudioSequence->Release(); pAudioSequence = NULL; pCompMob->Release(); pCompMob = NULL; pMobIter->Release(); pMobIter = NULL; } else { printf("Error with file: File has no Master mobs.\n"); } cleanup: // Cleanup and return if (pSourceClip) pSourceClip->Release(); if (pComponent) pComponent->Release(); if (pSegment) pSegment->Release(); if (pTimelineMobSlot) pTimelineMobSlot->Release(); if (pMobSlotIter) pMobSlotIter->Release(); if (pMob) pMob->Release(); if (newSlot) newSlot->Release(); if (aComponent) aComponent->Release(); if (seg) seg->Release(); if (pAudioSequence) pAudioSequence->Release(); if (pCompMob) pCompMob->Release(); if (pMobIter) pMobIter->Release(); if (pDataDef) pDataDef->Release(); if (pSoundDef) pSoundDef->Release(); if (pSourceClipDef) pSourceClipDef->Release(); if (pSequenceDef) pSequenceDef->Release(); if (pCompositionMobDef) pCompositionMobDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { /* Save the AAF file */ pFile->Save(); /* Close the AAF file */ pFile->Close(); pFile->Release(); } return moduleErrorTmp; }
void HTMLClipTest::CreateHTMLClip() { assert(_pHeader && _pDictionary); HRESULT hr = S_OK; IAAFMasterMob *pMasterMob = NULL; IAAFMob *pReferencedMob = NULL; IAAFHTMLClip *pHTMLClip = NULL; IAAFSourceReference *pSourceReference = NULL; IAAFCompositionMob *pCompositionMob = NULL; IAAFMob *pReferencingMob = NULL; IAAFSegment *pSegment = NULL; IAAFTimelineMobSlot *pMobSlot = NULL; IAAFComponent *pComponent = NULL; CAAFBuiltinDefs defs (_pDictionary); try { //Make the MOB to be referenced checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pMasterMob)); checkResult(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pReferencedMob)); checkResult(pReferencedMob->GetMobID(&_referencedMobID)); checkResult(pReferencedMob->SetName(L"HTMLClipTest::ReferencedMob")); // Save the master mob. checkResult(_pHeader->AddMob(pReferencedMob)); // Use EssenceAccess to write some html essence // Create a file mob for the html essence. // Create the corresponding html essence. // Write some html essence. // Create a HTMLClip checkResult(defs.cdHTMLClip()-> CreateInstance(IID_IAAFHTMLClip, (IUnknown **)&pHTMLClip)); checkResult(pHTMLClip->SetBeginAnchor(const_cast<wchar_t *>(_beginAnchor))); checkResult(pHTMLClip->SetEndAnchor(const_cast<wchar_t *>(_endAnchor))); checkResult(pHTMLClip->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; // Initialize the source reference data. checkResult(pHTMLClip->QueryInterface(IID_IAAFSourceReference, (void **)&pSourceReference)); checkResult(pSourceReference->SetSourceID(_referencedMobID)); checkResult(pSourceReference->SetSourceMobSlotID(0)); // Create a composition mob to hold the html clip. checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFCompositionMob, (IUnknown **)&pCompositionMob)); checkResult(pCompositionMob->QueryInterface(IID_IAAFMob, (void **)&pReferencingMob)); checkResult(pReferencingMob->SetName(L"CompositionMob_HTMLClipTest")); checkResult(pHTMLClip->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); IAAFMobSlot *pSlot = NULL; aafRational_t editRate = { 0, 1}; checkResult(pReferencingMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"HTMLClipTest", 0, &pMobSlot)); // Save the referencing mob. checkResult(_pHeader->AddMob(pReferencingMob)); } catch (HRESULT& rHR) { hr = rHR; // fall through and handle cleanup } // Cleanup local references if (pMobSlot) { pMobSlot->Release(); pMobSlot = NULL; } if (pComponent) { pComponent->Release(); pComponent = NULL; } if (pSegment) { pSegment->Release(); pSegment = NULL; } if (pReferencingMob) { pReferencingMob->Release(); pReferencingMob = NULL; } if (pCompositionMob) { pCompositionMob->Release(); pCompositionMob = NULL; } if (pSourceReference) { pSourceReference->Release(); pSourceReference = NULL; } if (pHTMLClip) { pHTMLClip->Release(); pHTMLClip = NULL; } if (pReferencedMob) { pReferencedMob->Release(); pReferencedMob = NULL; } if (pMasterMob) { pMasterMob->Release(); pMasterMob = NULL; } // Propogate the error if necessary. checkResult(hr); }
void EventTest::CreateEvent() { assert(_pHeader && _pDictionary); HRESULT hr = S_OK; IAAFEvent *pEvent = NULL; IAAFEventMobSlot *pEventMobSlot = NULL; IAAFSegment *pSegment = NULL; IAAFMobSlot *pMobSlot = NULL; IAAFDataDef *pDataDef = NULL; IAAFComponent *pComp = NULL; IAAFMob *pMob = NULL; CAAFBuiltinDefs defs (_pDictionary); try { // not already in dictionary checkResult(defs.cdDataDef()-> CreateInstance (IID_IAAFDataDef, (IUnknown **)&pDataDef)); hr = pDataDef->Initialize (kAAFDataDef_Test, L"Test", L"Test data"); hr = _pDictionary->RegisterDataDef (pDataDef); // Create a concrete subclass of event checkResult(defs.cdCommentMarker()-> CreateInstance(IID_IAAFEvent, (IUnknown **)&pEvent)); checkResult(pEvent->SetPosition(_position)); checkResult(pEvent->SetComment(const_cast<wchar_t*>(_eventComment))); checkResult(pEvent->QueryInterface(IID_IAAFComponent, (void **)&pComp)); checkResult(pComp->SetDataDef(pDataDef)); pComp->Release(); pComp = NULL; // Get the segment inteface to the event to install into the mob slot. checkResult(pEvent->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); // Create and initialize an EventMobSlot checkResult(defs.cdEventMobSlot()-> CreateInstance(IID_IAAFEventMobSlot, (IUnknown **)&pEventMobSlot)); checkResult(pEventMobSlot->SetEditRate(const_cast<aafRational_t *>(&_editRate))); // Get the mob slot interface so that we can add the event segment. checkResult(pEventMobSlot->QueryInterface(IID_IAAFMobSlot, (void **)&pMobSlot)); // Add the event segment to the event mob slot. checkResult(pMobSlot->SetSegment(pSegment)); // Create the mob to hold the new event mob slot. checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetName(L"CompositionMob::Name:Test mob to hold an event mob slot")); // Append event slot to the composition mob. checkResult(pMob->AppendSlot(pMobSlot)); // Save the id of the composition mob that contains our test // event mob slot. checkResult(pMob->SetMobID(gMobID)); // Attach the mob to the header... checkResult(_pHeader->AddMob(pMob)); } catch (HRESULT& rHR) { hr = rHR; // fall through and handle cleanup } // Cleanup local references if (pMob) { pMob->Release(); pMob = NULL; } if (pDataDef) { pDataDef->Release(); pDataDef = NULL; } if (pComp) { pComp->Release(); pComp = NULL; } if (pMobSlot) { pMobSlot->Release(); pMobSlot = NULL; } if (pEventMobSlot) { pEventMobSlot->Release(); pEventMobSlot = NULL; } if (pSegment) { pSegment->Release(); pSegment = NULL; } if (pEvent) { pEvent->Release(); pEvent = NULL; } // Propogate the error if necessary. checkResult(hr); }
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; IAAFMob *pMob = NULL; IAAFMobSlot *newSlot = NULL; IAAFSegment *seg = NULL; IAAFSourceClip *sclp = NULL; IAAFComponent *pComp = NULL; HRESULT hr = S_OK; 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); //Make the first mob long test; // Create a concrete subclass of Mob checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"MOBTest")); // Add some slots for(test = 0; test < 5; test++) { checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&sclp)); checkResult(sclp->QueryInterface (IID_IAAFComponent, (void **)&pComp)); checkResult(pComp->SetDataDef (defs.ddkAAFPicture())); pComp->Release(); pComp = NULL; checkResult(sclp->QueryInterface (IID_IAAFSegment, (void **)&seg)); // Create a concrete subclass of MobSlot checkResult(defs.cdStaticMobSlot()-> CreateInstance(IID_IAAFMobSlot, (IUnknown **)&newSlot)); checkResult(newSlot->SetSegment(seg)); checkResult(newSlot->SetSlotID(test+1)); checkResult(newSlot->SetPhysicalNum(test+2)); checkResult(newSlot->SetName(slotNames[test])); checkResult(pMob->AppendSlot (newSlot)); newSlot->Release(); newSlot = NULL; seg->Release(); seg = NULL; sclp->Release(); sclp = NULL; } // Add the mob to the file. checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (newSlot) newSlot->Release(); if (seg) seg->Release(); if (sclp) sclp->Release(); if (pComp) pComp->Release(); if (pMob) pMob->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 CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob *pMob = NULL; IAAFMob *pMob2 = NULL; IAAFMob2 *pMobInterface2 = NULL; IAAFTimelineMobSlot *newSlot = NULL; IAAFStaticMobSlot *newStaticSlot=NULL; IAAFEventMobSlot *newEventSlot=NULL; IAAFSegment *seg = NULL; IAAFSourceClip *sclp = NULL; IAAFEvent *event=NULL; IAAFComponent* pComponent = NULL; IAAFClassDef *pcdEventMeta=NULL; IAAFClassDef *pcdEvent=NULL; IAAFClassDef *pcdEventConcrete=NULL; HRESULT hr = S_OK; aafNumSlots_t numMobs; aafUInt32 bufLen = 0; aafUInt32 bytesRead = 0; aafUInt32 numComments = 0; aafUInt32 numFound = 0; aafWChar name[500]; aafWChar value[500]; IEnumAAFTaggedValues *enumTaggedVal = NULL; IAAFTaggedValue *taggedVal = NULL; IAAFMobSlot *mSlot = NULL; IAAFFiller *filler = NULL; IAAFKLVData *pKLVData = NULL; IAAFTypeDef* pBaseType = NULL; IAAFSourceReference *pSourceRef = NULL; IAAFTimecode *pTimecode = NULL; aafTimecode_t timecode; int i; 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); //Make the first mob long test; // Create a concrete subclass of Mob checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult( pMob->QueryInterface(IID_IAAFMob2,(void**)&pMobInterface2)); checkResult(pMob->SetMobID(MOBTestID)); checkExpression(pMob->GetNameBufLen(&bufLen) == AAFRESULT_PROP_NOT_PRESENT, AAFRESULT_TEST_FAILED); checkExpression(pMob->GetName(name, 0) == AAFRESULT_PROP_NOT_PRESENT, AAFRESULT_TEST_FAILED); checkExpression(pMob->SetName(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkResult(pMob->SetName(mobName)); checkResult(pMob->SetCreateTime(creationTimeStamp)); checkResult(pMob->SetModTime(modificationTimeStamp)); // Add some slots for(test = 1; test < 6; test++) { checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&sclp)); checkResult(sclp->QueryInterface(IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pSourceRef->SetSourceID(MOBTestID3)); checkResult(sclp->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); checkResult(sclp->QueryInterface (IID_IAAFSegment, (void **)&seg)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot (editRate, seg, test+1, slotNames[test], 0, &newSlot)); if(test == 5) { checkExpression(pMob->AppendNewTimelineSlot (editRate, NULL, test+1, slotNames[test], 0, &newSlot) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkExpression(pMob->AppendNewTimelineSlot (editRate, seg, test+1, NULL, 0, &newSlot) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkExpression(pMob->AppendNewTimelineSlot (editRate, seg, test+1, slotNames[test], 0, NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); pMob->RemoveSlotAt(4); checkExpression(pMob->RemoveSlotAt(test+1) == AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED); } newSlot->Release(); newSlot = NULL; if(newStaticSlot) newStaticSlot->Release(); newStaticSlot = NULL; seg->Release(); seg = NULL; sclp->Release(); sclp = NULL; pComponent->Release(); pComponent = NULL; pSourceRef->Release(); pSourceRef = NULL; } // PrependSlot checkResult(defs.cdStaticMobSlot()-> CreateInstance(IID_IAAFMobSlot, (IUnknown **)&mSlot)); checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **)&filler)); checkResult(filler->Initialize(defs.ddkAAFSound(), 10)); checkResult(filler->QueryInterface (IID_IAAFSegment, (void **)&seg)); checkResult(mSlot->SetName(slotNames[0])); checkResult(mSlot->SetPhysicalNum(1)); checkResult(mSlot->SetSlotID(1)); checkResult(mSlot->SetSegment(seg)); checkResult(pMob->PrependSlot(mSlot)); checkExpression(pMob->PrependSlot(mSlot) == AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED); checkExpression(pMob->PrependSlot(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); mSlot->Release(); mSlot = NULL; seg->Release(); seg = NULL; filler->Release(); filler = NULL; // AppendSlot checkResult(defs.cdStaticMobSlot()-> CreateInstance(IID_IAAFMobSlot, (IUnknown **)&mSlot)); checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **)&filler)); checkResult(filler->Initialize(defs.ddkAAFSound(), 10)); checkResult(filler->QueryInterface (IID_IAAFSegment, (void **)&seg)); checkResult(mSlot->SetName(slotNames[6])); checkResult(mSlot->SetPhysicalNum(1)); checkResult(mSlot->SetSlotID(7)); checkResult(mSlot->SetSegment(seg)); checkResult(pMob->AppendSlot(mSlot)); checkExpression(pMob->AppendSlot(mSlot) == AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED); checkExpression(pMob->AppendSlot(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); mSlot->Release(); mSlot = NULL; seg->Release(); seg = NULL; filler->Release(); filler = NULL; // InsertSlotAt -- insert a timecode object for OffsetToMobTimecode() testing timecode.startFrame = TCstartFrame; // One hour timecode.drop = TCdrop; timecode.fps = TCfps; checkResult(defs.cdTimecode()-> CreateInstance(IID_IAAFTimecode, (IUnknown **)&pTimecode)); checkResult(pTimecode->Initialize(100, &timecode)); checkResult(pTimecode->QueryInterface (IID_IAAFSegment, (void **)&seg)); assert(pComponent == NULL); checkResult(pTimecode->QueryInterface(IID_IAAFComponent,(void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFTimecode())); pComponent->Release(); pComponent = NULL; checkResult(defs.cdStaticMobSlot()-> CreateInstance(IID_IAAFMobSlot, (IUnknown **)&mSlot)); checkResult(mSlot->SetName(slotNames[5])); checkResult(mSlot->SetPhysicalNum(1)); checkResult(mSlot->SetSlotID(6)); checkResult(mSlot->SetSegment(seg)); checkExpression(pMob->InsertSlotAt(8, mSlot) == AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED); checkResult(pMob->InsertSlotAt(5, mSlot)); checkExpression(pMob->InsertSlotAt(4, mSlot) == AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED); checkExpression(pMob->InsertSlotAt(1, NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); mSlot->Release(); mSlot = NULL; seg->Release(); seg = NULL; pTimecode->Release(); pTimecode = NULL; //now test AppendNewStaticSlot checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&sclp)); checkResult(sclp->QueryInterface(IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pSourceRef->SetSourceID(MOBTestID_Static)); checkResult(sclp->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); checkResult(sclp->QueryInterface (IID_IAAFSegment, (void **)&seg)); checkResult(pMobInterface2->AppendNewStaticSlot ( seg, 8, slotNames[7], &newStaticSlot)); if(newStaticSlot) newStaticSlot->Release(); newStaticSlot = NULL; seg->Release(); seg = NULL; pSourceRef->Release(); pSourceRef = NULL; sclp->Release(); sclp = NULL; pComponent->Release(); pComponent = NULL; //now test AppendNewEventSlot //Create a concrete version of IAAFEvent checkResult (pDictionary->CreateMetaInstance (AUID_AAFClassDef, IID_IAAFClassDef, (IUnknown**) &pcdEventMeta)); checkResult (pDictionary->LookupClassDef (AUID_AAFEvent, &pcdEvent)); checkResult (pcdEventMeta->Initialize (kClassID_ConcreteEvent, pcdEvent, L"COncreteEvent", kAAFTrue)); checkResult (pDictionary->RegisterClassDef (pcdEventMeta)); //Now instantiate it checkResult(pDictionary->LookupClassDef(kClassID_ConcreteEvent, &pcdEventConcrete)); checkResult(pcdEventConcrete->CreateInstance(IID_IAAFEvent, (IUnknown **)&event)); //and initialize reqruied properties checkResult(event->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); event->SetPosition(1); aafRational_t EventeditRate = { 0, 1}; //get the segment checkResult(event->QueryInterface (IID_IAAFSegment, (void **)&seg)); checkResult(pMobInterface2->AppendNewEventSlot ( EventeditRate, seg, 9, slotNames[8], 0, &newEventSlot)); if(newEventSlot) newEventSlot->Release(); newEventSlot = NULL; seg->Release(); seg = NULL; pComponent->Release(); pComponent = NULL; event->Release(); event = NULL; pcdEventConcrete->Release(); pcdEventConcrete = NULL; pcdEvent->Release(); pcdEvent = NULL; pcdEventMeta->Release(); pcdEventMeta = NULL; // Try CountKLVData before any have been attached numFound = 1; checkResult(pMob->CountKLVData(&numFound)); checkExpression(numFound == 0, AAFRESULT_TEST_FAILED); checkExpression(pMob->CountKLVData(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); // AppendKLVData - attach some objects checkResult(pDictionary->LookupTypeDef (kAAFTypeID_UInt8Array, &pBaseType)); checkResult(pDictionary->RegisterKLVDataKey(TEST_KLV, pBaseType)); pBaseType->Release(); pBaseType = NULL; checkExpression(pMob->AppendKLVData(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkResult(defs.cdKLVData()-> CreateInstance(IID_IAAFKLVData, (IUnknown **)&pKLVData)); checkResult(pKLVData->Initialize(TEST_KLV, sizeof(KLVfrowney), (unsigned char *)KLVfrowney)); checkResult(pMob->AppendKLVData(pKLVData)); pKLVData->Release(); pKLVData = NULL; checkResult(defs.cdKLVData()-> CreateInstance(IID_IAAFKLVData, (IUnknown **)&pKLVData)); checkResult(pKLVData->Initialize(TEST_KLV, sizeof(KLVfrowney), (unsigned char *)KLVfrowney)); checkResult(pMob->AppendKLVData(pKLVData)); checkExpression(pMob->AppendKLVData(pKLVData) == AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED); // RemoveKLVData - remove object #2 checkExpression(pMob->RemoveKLVData(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkResult(pMob->CountKLVData(&numFound)); checkExpression(numFound == 2, AAFRESULT_TEST_FAILED); checkResult(pMob->RemoveKLVData(pKLVData)); checkResult(pMob->CountKLVData(&numFound)); checkExpression(numFound == 1, AAFRESULT_TEST_FAILED); pKLVData->Release(); pKLVData = NULL; // Try removing an object that is not attached checkResult(defs.cdKLVData()-> CreateInstance(IID_IAAFKLVData, (IUnknown **)&pKLVData)); checkResult(pKLVData->Initialize(TEST_KLV, sizeof(KLVsmiley), (unsigned char *)KLVsmiley)); checkExpression(pMob->RemoveKLVData(pKLVData) == AAFRESULT_OBJECT_NOT_ATTACHED, AAFRESULT_TEST_FAILED); // Attach it to replace the one removed checkResult(pMob->AppendKLVData(pKLVData)); pKLVData->Release(); pKLVData = NULL; // Comments checkExpression(pMob->GetComments(&enumTaggedVal) == AAFRESULT_PROP_NOT_PRESENT, AAFRESULT_TEST_FAILED); // Check CountComments() checkExpression(pMob->CountComments(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); numComments = 1; checkResult(pMob->CountComments(&numComments)); checkExpression(numComments == 0, AAFRESULT_TEST_FAILED); // Check AppendComments() checkExpression(pMob->AppendComment(NULL, pComment[0]) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkExpression(pMob->AppendComment(const_cast<aafWChar*>(pCategory[0]), NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); for (i = 0; i < 5; ++i) { checkResult(pMob->AppendComment(const_cast<aafWChar*>(pCategory[i]), pComment[i])); } checkResult(pMob->CountComments(&numComments)); checkExpression(numComments == 5, AAFRESULT_TEST_FAILED); // Check GetComments() checkExpression(pMob->GetComments(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkResult(pMob->GetComments(&enumTaggedVal)); for (i = 0; i < 5; ++i) { checkResult(enumTaggedVal->NextOne(&taggedVal)); checkResult(taggedVal->GetNameBufLen(&bufLen)); checkResult(taggedVal->GetName(name, bufLen)); checkExpression(wcscmp(name, pCategory[i]) == 0, AAFRESULT_TEST_FAILED); checkResult(taggedVal->GetValueBufLen(&bufLen)); checkResult(taggedVal->GetValue(bufLen, (aafDataBuffer_t)value, &bytesRead)); checkExpression(wcscmp(value, pComment[i]) == 0, AAFRESULT_TEST_FAILED); taggedVal->Release(); taggedVal = NULL; } checkResult(defs.cdTaggedValue()-> CreateInstance(IID_IAAFTaggedValue, (IUnknown **)&taggedVal)); checkExpression(pMob->RemoveComment(taggedVal) == AAFRESULT_OBJECT_NOT_ATTACHED, AAFRESULT_TEST_FAILED); taggedVal->Release(); taggedVal = NULL; enumTaggedVal->Reset(); enumTaggedVal->Skip(2); checkResult(enumTaggedVal->NextOne(&taggedVal)); checkExpression(pMob->RemoveComment(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED); checkResult(pMob->RemoveComment(taggedVal)); taggedVal->Release(); taggedVal = NULL; enumTaggedVal->Reset(); for (i = 0; i < 5; ++i) { if (i==2) continue; checkResult(enumTaggedVal->NextOne(&taggedVal)); checkResult(taggedVal->GetNameBufLen(&bufLen)); checkResult(taggedVal->GetName(name, bufLen)); checkExpression(wcscmp(name, pCategory[i]) == 0, AAFRESULT_TEST_FAILED); checkResult(taggedVal->GetValueBufLen(&bufLen)); checkResult(taggedVal->GetValue(bufLen, (aafDataBuffer_t)value, &bytesRead)); checkExpression(wcscmp(value, pComment[i]) == 0, AAFRESULT_TEST_FAILED); taggedVal->Release(); taggedVal = NULL; } enumTaggedVal->Release(); enumTaggedVal = NULL; // Check the Mob2 attribute and usage code implementations. // Need IAAFMob2 for that; checkResult( pMobInterface2->AppendAttribute( AttributeNames[0], AttributeValues[0] ) ); checkResult( pMobInterface2->AppendAttribute( AttributeNames[1], AttributeValues[1] ) ); checkResult( pMobInterface2->SetUsageCode( kAAFUsage_SubClip ) ); // Add the mob to the file. checkResult(pHeader->AddMob(pMob)); // Test changing the mob id after the mob is attached to the // content store. Change it, then reset to the original id. checkResult(pMob->SetMobID(MOBTestID2)); checkResult(pMob->SetMobID(MOBTestID)); // Create another Mob, check mob count, then delete and recheck count checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob2)); checkResult(pMob2->SetMobID(MOBTestID2)); checkResult(pMob2->SetName(mobName)); checkResult(pMob2->SetCreateTime(creationTimeStamp)); checkResult(pMob2->SetModTime(modificationTimeStamp)); // Add the mob to the file. checkResult(pHeader->AddMob(pMob2)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(numMobs == 2, AAFRESULT_TEST_FAILED); checkResult(pHeader->RemoveMob(pMob2)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(numMobs == 1, AAFRESULT_TEST_FAILED); //try Copy() const aafCharacter *copy_name = L"Name of Copied Mob"; IAAFMobSP spCopiedMob; checkResult(pMob->Copy(copy_name, &spCopiedMob)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(numMobs == 2, AAFRESULT_TEST_FAILED); checkResult(pHeader->RemoveMob(spCopiedMob)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(numMobs == 1, AAFRESULT_TEST_FAILED); //try CloneExternal IAAFMobSP spClonedMob; IAAFFileSP spDestFile; aafCharacter dest_filename[128]; wcscpy(dest_filename, pFileName); wcscat(dest_filename, L"_clone"); // Remove the previous test file if any. RemoveTestFile(dest_filename); checkResult(CreateTestFile( dest_filename, fileKind, rawStorageType, productID, &spDestFile )); checkResult(pMob->CloneExternal(kAAFNoFollowDepend, kAAFNoIncludeMedia, spDestFile, &spClonedMob)); checkResult(spDestFile->Save()); checkResult(spDestFile->Close()); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (enumTaggedVal) enumTaggedVal->Release(); if (newSlot) newSlot->Release(); if (newStaticSlot) newStaticSlot->Release(); if (seg) seg->Release(); if (pComponent) pComponent->Release(); if (sclp) sclp->Release(); if (pMob) pMob->Release(); if (pMob2) pMob2->Release(); if (pMobInterface2) pMobInterface2->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if(pcdEventMeta) pcdEventMeta->Release(); if(pcdEvent) pcdEvent->Release(); if(pcdEventConcrete) pcdEventConcrete->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { // IAAFSession* pSession = NULL; IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMob* pReferencedMob = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; IAAFComponent* pComponent = NULL; IAAFDescriptiveClip* pDescClip = NULL; bool bFileOpen = false; HRESULT hr = AAFRESULT_SUCCESS; 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); //Make the MOB to be referenced checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pReferencedMob)); checkResult(pReferencedMob->SetMobID(TEST_referencedMobID)); checkResult(pReferencedMob->SetName(L"AAFDescriptiveClipTest::ReferencedMob")); // Create a Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"AAFDescriptiveClipTest")); // Create a DescriptiveClip checkResult(defs.cdDescriptiveClip()-> CreateInstance(IID_IAAFDescriptiveClip, (IUnknown **)&pDescClip)); checkResult(pDescClip->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFSound())); pComponent->Release(); pComponent = NULL; // Set the properties for the SourceClip //checkResult(pDescClip->SetFade( fadeInLen, fadeInType, fadeOutLen, fadeOutType)); sourceRef.sourceID = TEST_referencedMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pDescClip->Initialize(defs.ddkAAFSound(), 1000, sourceRef)); // Get described slots - should not be present. aafUInt32 size = 0; AAFRESULT hr = pDescClip->CountDescribedSlotIDs( &size ); checkExpression( AAFRESULT_PROP_NOT_PRESENT == hr, AAFRESULT_TEST_FAILED ); // Set/Get single described slot id aafUInt32 setSingleDescribedSlotID = 0xdeadbeef; checkResult( pDescClip->AddDescribedSlotID( setSingleDescribedSlotID ) ); aafUInt32 getSingleDescribedSlotID = 0; checkResult( pDescClip->GetDescribedSlotIDs( 1, &getSingleDescribedSlotID ) ); checkExpression( setSingleDescribedSlotID == getSingleDescribedSlotID, AAFRESULT_TEST_FAILED ); // Clear the ID set for the next test checkResult( pDescClip->RemoveDescribedSlotID( setSingleDescribedSlotID ) ); // Set the persistent described slots. for( aafUInt32 i_tid = 0; i_tid < TestDescribedSlotIDsVectorSize; ++i_tid ) { checkResult( pDescClip->AddDescribedSlotID( TestDescribedSlotIDsVector[i_tid] ) ); } aafUInt32 getDescribedSlotIDsVector[TestDescribedSlotIDsVectorSize]; checkResult( pDescClip->GetDescribedSlotIDs( TestDescribedSlotIDsVectorSize, getDescribedSlotIDsVector ) ); checkExpression( 0 == memcmp( getDescribedSlotIDsVector, TestDescribedSlotIDsVector, sizeof(TestDescribedSlotIDsVector) ), AAFRESULT_TEST_FAILED ); checkResult(pDescClip->QueryInterface (IID_IAAFSegment, (void **)&seg)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot (editRate, seg, 1, slotName, 0, &newSlot)); checkResult(pHeader->AddMob(pMob)); checkResult(pHeader->AddMob(pReferencedMob)); } catch( const AAFRESULT& hr ) { return hr; } // Cleanup and return if (seg) seg->Release(); if (newSlot) newSlot->Release(); if (pDescClip) pDescClip->Release(); if (pComponent) pComponent->Release(); if (pMob) pMob->Release(); if (pReferencedMob) pReferencedMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->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; IAAFMob* pMob = NULL; IAAFTimelineMobSlot* pMobSlot = NULL; IAAFSequence* pSequence = NULL; IAAFSegment* pSegment = NULL; IAAFComponent* pComponent = NULL; int i; HRESULT hr = S_OK; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); // 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 a Composition Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"EnumAAFDataDefTest")); // Add mob slot w/ Sequence checkResult(defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence)); checkResult(pSequence->Initialize(defs.ddkAAFPicture())); // // Add some segments. Need to test failure conditions // (i.e. starting/ending w/ transition, two trans back // to bacl). // for(i = 0; i < kNumComponents; i++) { aafLength_t len = 10; checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFComponent, (IUnknown **)&pComponent)); if(i == 0) { checkResult(pComponent->SetDataDef(defs.ddkAAFPictureWithMatte())); } else { checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); } checkResult(pComponent->SetLength(len)); checkResult(pSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; } checkResult(pSequence->QueryInterface (IID_IAAFSegment, (void **)&pSegment)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"AAF Test Sequence", 0, &pMobSlot)); pMobSlot->Release(); pMobSlot = NULL; pSegment->Release(); pSegment = NULL; // Add the master mob to the file and cleanup pHeader->AddMob(pMob); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pMobSlot) pMobSlot->Release(); if (pSegment) pSegment->Release(); if (pComponent) pComponent->Release(); if (pSequence) pSequence->Release(); if (pMob) pMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { pFile->Save(); pFile->Close(); pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IEnumAAFMobs* pMobIter = NULL; IAAFMob* pMob; IEnumAAFMobSlots* pSlotIter = NULL; IAAFMobSlot* pSlot = NULL; IAAFComponent* pComp = NULL; IAAFSegment* pSegment = NULL; IAAFDataDef* pDataDef = NULL; IAAFSequence* pSequence = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFDataDefs* pEnumDataDef = NULL; IEnumAAFDataDefs* pCloneEnum = NULL; IEnumAAFComponents* pCompIter = NULL; IAAFDataDef* pArray[2] = { NULL, NULL }; aafNumSlots_t numMobs; aafInt32 index; aafSearchCrit_t criteria; HRESULT hr = S_OK; aafBool testBool; aafUInt32 resultCount; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Validate that there is only one composition mob. checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); // The test can't check the types on these because the order of adding data definitions // is defined by the toolkit, and not the test. !!!Change this to determine the order on // the first two tests, and then use to test the other functions. checkResult(pDictionary->GetDataDefs(&pEnumDataDef)); /* Read and check the first element */ checkResult(pEnumDataDef->NextOne(&pDataDef)); checkResult(pDataDef->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pDataDef->Release(); pDataDef = NULL; /**/ /* Read and check the second element */ checkResult(pEnumDataDef->NextOne(&pDataDef)); checkResult(pDataDef->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pDataDef->Release(); pDataDef = NULL; /*****/ /* Reset, and check the first element again*/ checkResult(pEnumDataDef->Reset()); checkResult(pEnumDataDef->NextOne(&pDataDef)); checkResult(pDataDef->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pDataDef->Release(); pDataDef = NULL; /* Reset, Skip, and check the second element again*/ checkResult(pEnumDataDef->Reset()); checkResult(pEnumDataDef->Skip(1)); checkResult(pEnumDataDef->NextOne(&pDataDef)); checkResult(pDataDef->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pDataDef->Release(); pDataDef = NULL; /* Reset, and read both elements */ checkResult(pEnumDataDef->Reset()); checkResult(pEnumDataDef->Next (2, (IAAFDataDef **)&pArray, &resultCount)); checkExpression (resultCount == 2, AAFRESULT_TEST_FAILED); checkResult(pArray[0]->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pArray[0]->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pArray[0]->Release(); pArray[0] = NULL; checkResult(pArray[1]->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pArray[1]->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pArray[1]->Release(); pArray[1] = NULL; // /* Read one past to make sure that it fails */ // checkExpression(pEnumDataDef->NextOne(&pDataDef) != AAFRESULT_SUCCESS, AAFRESULT_TEST_FAILED); /* Clone the enumerator, and read one element */ checkResult(pEnumDataDef->Clone(&pCloneEnum)); checkResult(pCloneEnum->Reset()); checkResult(pCloneEnum->NextOne(&pDataDef)); checkResult(pDataDef->IsPictureKind(&testBool)); // checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsSoundKind(&testBool)); // checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pDataDef->Release(); pDataDef = NULL; pCloneEnum->Release(); pCloneEnum = NULL; // Enumerate over Composition MOBs criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFCompMob; checkResult(pHeader->GetMobs(&criteria, &pMobIter)); CAAFBuiltinDefs defs (pDictionary); while (pMobIter && pMobIter->NextOne(&pMob) == AAFRESULT_SUCCESS) { aafNumSlots_t numSlots = 0; checkResult(pMob->CountSlots(&numSlots)); checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED); // Enumerate over all MOB slots for this MOB checkResult(pMob->GetSlots(&pSlotIter)); while (pSlotIter && pSlotIter->NextOne(&pSlot) == AAFRESULT_SUCCESS) { aafUInt32 numCpnts; checkResult(pSlot->GetSegment(&pSegment)); checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **) &pSequence)); checkResult(pSequence->CountComponents(&numCpnts)); checkExpression(numCpnts == kNumComponents, AAFRESULT_TEST_FAILED); checkResult(pSequence->GetComponents(&pCompIter)); numCpnts = 0; index = 0; while (pCompIter && pCompIter->NextOne(&pComp) == AAFRESULT_SUCCESS) { aafBool testBool; numCpnts++; checkResult(pComp->GetDataDef(&pDataDef)); checkResult(pDataDef->IsSoundKind(&testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsMatteKind(&testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); if(index == 0) // First segment is Picture with Matte, converts to picture { checkResult(pDataDef->IsDataDefOf(defs.ddkAAFPictureWithMatte(), &testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureKind(&testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureWithMatteKind(&testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->DoesDataDefConvertTo (defs.ddkAAFPicture(), &testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); } else // First segment is Picture, converts from picture with Matte { checkResult(pDataDef->IsDataDefOf(defs.ddkAAFPicture(), &testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureKind(&testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsPictureWithMatteKind(&testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pDataDef->DoesDataDefConvertFrom (defs.ddkAAFPictureWithMatte(), &testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); } checkResult(pDataDef->DoesDataDefConvertTo (defs.ddkAAFSound(), &testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pDataDef->DoesDataDefConvertFrom (defs.ddkAAFSound(), &testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); pComp->Release(); pComp = NULL; pDataDef->Release(); pDataDef = NULL; index++; } pCompIter->Release(); pCompIter = NULL; pSequence->Release(); pSequence = NULL; pSegment->Release(); pSegment = NULL; pSlot->Release(); pSlot = NULL; } pSlotIter->Release(); pSlotIter = NULL; pMob->Release(); pMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup object references if (pComp) pComp->Release(); if (pEnumDataDef) pEnumDataDef->Release(); if (pCloneEnum) pCloneEnum->Release(); if (pCompIter) pCompIter->Release(); if (pArray[0]) pArray[0]->Release(); if (pArray[1]) pArray[1]->Release(); if (pDataDef) pDataDef->Release(); if (pSequence) pSequence->Release(); if (pSegment) pSegment->Release(); if (pSlot) pSlot->Release(); if (pDictionary) pDictionary->Release(); if (pSlotIter) pSlotIter->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { pFile->Close(); pFile->Release(); } return hr; }