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; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFSourceMob *pSourceMob = NULL; IAAFMob *pMob = NULL; IAAFEssenceDescriptor *edesc = 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 // Create a FileMob checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_File_MobID)); checkResult(pMob->SetName(L"File Mob")); // Check the Mob2 usage code implementations. // Need IAAFMob2 for to do that. { IAAFSmartPointer<IAAFMob2> pMobInterface2; checkResult( pMob->QueryInterface( IID_IAAFMob2, reinterpret_cast<void**>(&pMobInterface2) ) ); checkResult( pMobInterface2->SetUsageCode( kAAFUsage_Template ) ); } // Create a concrete subclass of FileDescriptor checkResult(defs.cdAIFCDescriptor()-> CreateInstance(IID_IAAFEssenceDescriptor, (IUnknown **)&edesc)); IAAFAIFCDescriptor* pAIFCDesc = NULL; checkResult(edesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); checkResult(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; checkResult(pSourceMob->SetEssenceDescriptor (edesc)); checkResult(pHeader->AddMob(pMob)); // Reusing local variable so we need to release the inteface. pMob->Release(); pMob = NULL; // Create a MasterMob checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_Master_MobID)); checkResult(pMob->SetName(L"Master Mob")); // Check the Mob2 usage code implementations. // Need IAAFMob2 for to do that. { IAAFSmartPointer<IAAFMob2> pMobInterface2; checkResult( pMob->QueryInterface( IID_IAAFMob2, reinterpret_cast<void**>(&pMobInterface2) ) ); checkResult( pMobInterface2->SetUsageCode( kAAFUsage_Template ) ); } checkResult(pHeader->AddMob(pMob)); // Reusing local variable so we need to release the inteface. pMob->Release(); pMob = NULL; // Create a CompositionMob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_Composition_MobID)); checkResult(pMob->SetName(L"Composition Mob")); // Check the Mob2 usage code implementations. // Need IAAFMob2 for to do that. IAAFSmartPointer<IAAFMob2> pMobInterface2; checkResult( pMob->QueryInterface( IID_IAAFMob2, reinterpret_cast<void**>(&pMobInterface2) ) ); checkResult( pMobInterface2->SetUsageCode( kAAFUsage_TopLevel ) ); checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (edesc) edesc->Release(); if (pMob) pMob->Release(); if (pSourceMob) pSourceMob->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) { // 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 CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { HRESULT hr = AAFRESULT_SUCCESS; IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary * pDict = NULL; IAAFCompositionMob * pCMob = NULL; IAAFMob * pMob = NULL; IAAFObject * pObj = NULL; try { //Do the usual ... RemoveTestFile (pFileName); checkResult (CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); assert (pFile); checkResult (pFile->GetHeader (&pHeader)); assert (pHeader); checkResult (pHeader->GetDictionary (&pDict)); assert (pDict); CAAFBuiltinDefs defs (pDict); //Create a composition ... checkResult (defs.cdCompositionMob()-> CreateInstance (IID_IAAFCompositionMob, (IUnknown **) &pCMob)); assert (pCMob); checkResult (pCMob->Initialize (TEST_NAME)); //... Get its mob, and add it to the header info checkResult (pCMob->QueryInterface (IID_IAAFMob, (void **) &pMob)); assert (pMob); checkResult (pHeader->AddMob (pMob)); } catch (HRESULT & rResult) { hr = rResult; } if (pCMob) pCMob->Release(); if (pMob) pCMob->Release(); if (pObj) pObj->Release(); if (pDict) pDict->Release(); if (pHeader) pHeader->Release(); if (pFile) { AAFRESULT temphr = pFile->Save(); if (! SUCCEEDED (temphr)) return temphr; temphr = pFile->Close(); if (! SUCCEEDED (temphr)) return temphr; pFile->Release(); } return 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) { IAAFFileSP pFile; IAAFHeaderSP pHeader; IAAFDictionarySP pDictionary; IAAFMobSP pMob; IAAFTimelineMobSlotSP pMobSlot; IAAFSequenceSP pSequence; IAAFSegmentSP pSegment; IAAFComponentSP pComponent; 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 )); // 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)); // Create a new class, and register it in the dictionary. RegisterNewClass (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"AAFDictionaryTest")); // 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 back). // for(i = 0; i < kNumComponents; i++) { aafLength_t len = 10; // For the first component, make it our extended filler. if(i == 0) { IAAFClassDefSP pNewFillClassDef; checkResult(pDictionary->LookupClassDef(kClassAUID_NewFill, &pNewFillClassDef)); checkResult (pNewFillClassDef->CreateInstance(IID_IAAFComponent, (IUnknown**)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPictureWithMatte())); } else { checkResult (defs.cdFiller()->CreateInstance(IID_IAAFComponent, (IUnknown**)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); } checkResult(pComponent->SetLength(len)); checkResult(pSequence->AppendComponent(pComponent)); // For our first component, set the 'odor' value. Must be // done after the component has been inserted in sequence. if (i == 0) { // Set the odor value. // // 1) Get type def for uint32 IAAFTypeDefSP ptd; checkResult (pDictionary->LookupTypeDef (kAAFTypeID_UInt32, &ptd)); assert (ptd); IAAFTypeDefIntSP pTDUint32; checkResult(ptd->QueryInterface (IID_IAAFTypeDefInt, (void **)&pTDUint32)); assert (pTDUint32); // 2) Create a property value for the odor property, and // set it to 42. IAAFPropertyValueSP pVal; const aafUInt32 odorValue = 42; checkResult (pTDUint32->CreateValue ((aafMemPtr_t) &odorValue, sizeof (odorValue), &pVal)); // 3) Look up the property def for the odor property in // the new fill class. IAAFClassDefSP pNewFillClass; checkResult (pDictionary->LookupClassDef (kClassAUID_NewFill, &pNewFillClass)); IAAFPropertyDefSP pPropDef; checkResult (pNewFillClass->LookupPropertyDef (kPropAUID_NewFill_Odor, &pPropDef)); // 4) Get IAAFObject interface for new fill object, and // set the odor property. IAAFObjectSP pObj; checkResult(pComponent->QueryInterface (IID_IAAFObject, (void **)&pObj)); checkResult (pObj->SetPropertyValue (pPropDef, pVal)); } } checkResult(pSequence->QueryInterface (IID_IAAFSegment, (void **)&pSegment)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"AAF Test Sequence", 0, &pMobSlot)); // Add the master mob to the file and cleanup pHeader->AddMob(pMob); checkResult (RegisterDefs (pDictionary)); testKLVDataDefinitions(pDictionary, pMob); testTaggedDefinitions(pDictionary, pMob); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pFile) { pFile->Save(); pFile->Close(); } return hr; }
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); }
// Create the test file. void CAAFTypeDefWeakObjRef_create ( aafCharacter_constptr pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { // Remove the previous test file is one exists RemoveTestFile (pFileName); // Create the file. IAAFFileSP pFile; checkResult (CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); try { IAAFHeaderSP pHeader; checkResult (pFile->GetHeader (&pHeader)); aafProductVersion_t toolkitVersion; checkResult(GetAAFVersions(pHeader, &toolkitVersion, NULL)); bool weakReferencesSupported = WeakReferencesSupported(toolkitVersion); IAAFDictionarySP pDictionary; checkResult (pHeader->GetDictionary (&pDictionary)); CAAFBuiltinDefs defs (pDictionary); if (weakReferencesSupported) { // Create a Weak reference to a type definition. IAAFTypeDefWeakObjRefSP pWeakObjRef; checkResult(pDictionary->CreateMetaInstance(AUID_AAFTypeDefWeakObjRef, IID_IAAFTypeDefWeakObjRef, (IUnknown **)&pWeakObjRef)); // Find the class definition for all type definitions. IAAFClassDefSP pClassDef; checkResult(pDictionary->LookupClassDef(AUID_AAFTypeDef, &pClassDef)); aafUID_t targetSet[2]; targetSet[0] = kAAFPropID_Root_MetaDictionary; targetSet[1] = kAAFPropID_MetaDictionary_TypeDefinitions; checkResult(pWeakObjRef->Initialize(kAAFTypeID_TestWeakReferenceToType, pClassDef, kMyWeakReferenceToTypeDefinitionName, sizeof(targetSet)/sizeof(aafUID_t), targetSet)); // Validate that we make the correct "type" by inspecting the type category. IAAFTypeDefSP pTypeDef; checkResult(pWeakObjRef->QueryInterface(IID_IAAFTypeDef, (void **)&pTypeDef)); eAAFTypeCategory_t category; checkResult(pTypeDef->GetTypeCategory(&category)); checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED); // Add the new type to the dictionary. checkResult(pDictionary->RegisterTypeDef(pTypeDef)); // Now add a new optional weak reference property to an existing class. IAAFClassDefSP pFillerClass; IAAFPropertyDefSP pWeakRefPropertyDef; checkResult(pDictionary->LookupClassDef(AUID_AAFComponent, &pFillerClass)); checkResult(pFillerClass->RegisterOptionalPropertyDef( kAAFPropID_TestWeakReferenceToType, kMyWeakReferenceToTypeDefinitionPropertyName, pTypeDef, &pWeakRefPropertyDef)); } #ifndef NO_REFERENCE_TO_MOB_TEST if (weakReferencesSupported) { // Create a Weak reference to a mob. IAAFTypeDefWeakObjRefSP pWeakObjRef; checkResult(pDictionary->CreateMetaInstance(AUID_AAFTypeDefWeakObjRef, IID_IAAFTypeDefWeakObjRef, (IUnknown **)&pWeakObjRef)); // Find the class definition for all mobs. IAAFClassDefSP pClassDef; checkResult(pDictionary->LookupClassDef(AUID_AAFMob, &pClassDef)); aafUID_t targetSet[3]; targetSet[0] = kAAFPropID_Root_Header; targetSet[1] = kAAFPropID_Header_Content; targetSet[2] = kAAFPropID_ContentStorage_Mobs; checkResult(pWeakObjRef->Initialize(kAAFTypeID_TestWeakReferenceToMob, pClassDef, kMyWeakReferenceToMobName, sizeof(targetSet)/sizeof(aafUID_t), targetSet)); // Validate that we make the correct "type" by inspecting the type category. IAAFTypeDefSP pTypeDef; checkResult(pWeakObjRef->QueryInterface(IID_IAAFTypeDef, (void **)&pTypeDef)); eAAFTypeCategory_t category; checkResult(pTypeDef->GetTypeCategory(&category)); checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED); // Add the new type to the dictionary. checkResult(pDictionary->RegisterTypeDef(pTypeDef)); // Now add a new optional weak reference property to an existing class. IAAFClassDefSP pFillerClass; IAAFPropertyDefSP pWeakRefPropertyDef; checkResult(pDictionary->LookupClassDef(AUID_AAFComponent, &pFillerClass)); checkResult(pFillerClass->RegisterOptionalPropertyDef( kAAFPropID_TestWeakReferenceToMob, kMyWeakReferenceToMobPropertyName, pTypeDef, &pWeakRefPropertyDef)); } #endif // // Create a Composition Mob // IAAFMobSP pMob; checkResult(defs.cdCompositionMob()->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"TestCompMob")); // // Create a sequence to hold our test fillers components. // IAAFSequenceSP pSequence; checkResult (defs.cdSequence()->CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence)); checkResult (pSequence->Initialize (defs.ddkAAFPicture())); IAAFFillerSP pFiller1; checkResult (defs.cdFiller()->CreateInstance(IID_IAAFFiller, (IUnknown **)&pFiller1)); checkResult (pFiller1->Initialize (defs.ddkAAFPicture(), 16)); IAAFFillerSP pFiller2; checkResult (defs.cdFiller()->CreateInstance(IID_IAAFFiller, (IUnknown **)&pFiller2)); checkResult (pFiller2->Initialize (defs.ddkAAFPicture(), 32)); if (weakReferencesSupported) { // Try adding a weak reference before filler is attached to the file. CreateWeakReference(pFiller1, defs.tdInt64()); CheckWeakReference(pFiller1, defs.tdInt64()); ChangeWeakReference(pFiller1, defs.tdString()); CreateWeakReference(pFiller2, defs.tdInt32()); } // // Add the initialized fillers to the sequence. // IAAFComponentSP pComp1; checkResult(pFiller1->QueryInterface(IID_IAAFComponent, (void **)&pComp1)); checkResult(pSequence->AppendComponent(pComp1)); IAAFComponentSP pComp2; checkResult(pFiller2->QueryInterface(IID_IAAFComponent, (void **)&pComp2)); checkResult(pSequence->AppendComponent(pComp2)); // // Append the sequence as the segment in a new timeline mob slot. // IAAFSegmentSP pSegment; checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); aafRational_t editRate = {30000, 1001}; aafCharacter_constptr pSlotName = L"Slot 1"; aafPosition_t origin = 0; IAAFTimelineMobSlotSP pNewSlot; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, TEST_SlotID, pSlotName, origin, &pNewSlot)); // // Add to the set of mobs in the file. // checkResult(pHeader->AddMob(pMob)); #ifndef NO_REFERENCE_TO_MOB_TEST if (weakReferencesSupported) { // The referenced object needs to be attached to the file. CreateWeakReference(pFiller1, pMob); CheckWeakReference(pFiller1, pMob); } #endif // if (weakReferencesSupported) // { // // Try adding a weak reference after filler is attached to the file. // CreateWeakReference(pFiller2, defs.tdInt32()); // } // Verify the data before the save. CAAFTypeDefWeakObjRef_verify (pHeader); checkResult(pFile->Save()); checkResult(pFile->Close()); } catch (HRESULT& rhr) { if (pFile) // only save & close the file if it was actually opened { pFile->Save(); // This may not be safe??? pFile->Close(); } throw rhr; } catch (...) { if (pFile) // only close the file if it was actually opened pFile->Close(); throw; } }
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* pRMob = NULL; IAAFMasterMob* pReferencedMob = NULL; IAAFCompositionMob* pCompMob = NULL; IAAFTimelineMobSlot *newSlot = NULL; IAAFSegment *seg = NULL; IAAFSourceClip *sclp = 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 Composition Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFCompositionMob, (IUnknown **)&pCompMob)); checkResult(pCompMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"AAFTaggedValuesTest")); // append a comment to this mob !! checkResult(pMob->AppendComment(const_cast<aafWChar*>(TagNames), Comments)); checkResult(pMob->AppendComment(const_cast<aafWChar*>(TagNames), AltComment)); // Create a master mob to be referenced checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pReferencedMob)); checkResult(pReferencedMob->QueryInterface(IID_IAAFMob, (void **)&pRMob)); checkResult(pRMob->SetMobID(TEST_referencedMobID)); checkResult(pRMob->SetName(L"AAFTaggedValueTest::ReferencedMob")); // Add some slots for(test = 0; test < 5; test++) { checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&sclp)); // Set the properties for the SourceClip sourceRef.sourceID = TEST_referencedMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; IAAFDataDefSP pDataDef; checkResult(pDictionary->LookupDataDef(*slotDDefs[test], &pDataDef)); checkResult(sclp->Initialize(pDataDef, slotsLength[test], sourceRef)); checkResult(sclp->QueryInterface (IID_IAAFSegment, (void **)&seg)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot (editRate, seg, test+1, slotNames[test], 0, &newSlot)); newSlot->Release(); newSlot = NULL; seg->Release(); seg = NULL; sclp->Release(); sclp = NULL; } // Add the mob to the file. checkResult(pHeader->AddMob(pMob)); checkResult(pHeader->AddMob(pRMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (newSlot) newSlot->Release(); if (seg) seg->Release(); if (sclp) sclp->Release(); if (pCompMob) pCompMob->Release(); if (pMob) pMob->Release(); if (pReferencedMob) pReferencedMob->Release(); if (pRMob) pRMob->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) { // 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; }