void EssenceDataTest::createFileMob(unsigned int mobid_Index) { assert(_pFile && _pHeader && _pDictionary); assert(NULL == _pSourceMob); assert(NULL == _pMob); assert(NULL == _pFileDescriptor); assert(NULL == _pEssenceDescriptor); assert(NULL == _pSourceMob); CAAFBuiltinDefs defs (_pDictionary); // Create a Mob check(defs.cdSourceMob()->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&_pSourceMob)); check(_pSourceMob->QueryInterface (IID_IAAFMob, (void **)&_pMob)); check(_pMob->SetMobID(TEST_MobIDs[mobid_Index])); check(_pMob->SetName(L"EssenceDataTest File Mob")); // instantiate a concrete subclass of FileDescriptor check(defs.cdAIFCDescriptor()-> CreateInstance(IID_IAAFFileDescriptor, (IUnknown **)&_pFileDescriptor)); IAAFAIFCDescriptor* pAIFCDesc = NULL; check(_pFileDescriptor->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; check(_pFileDescriptor->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&_pEssenceDescriptor)); check(_pSourceMob->SetEssenceDescriptor (_pEssenceDescriptor)); check(_pHeader->AddMob(_pMob)); createEssenceData(_pSourceMob); // Cleanup instance data for reuse... _pEssenceDescriptor->Release(); _pEssenceDescriptor = NULL; _pFileDescriptor->Release(); _pFileDescriptor = NULL; _pMob->Release(); _pMob = NULL; _pSourceMob->Release(); _pSourceMob = NULL; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFMob* pMob = NULL; IAAFDataEssenceDescriptor* pDataEssenceDesc = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; HRESULT hr = AAFRESULT_SUCCESS; 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)); // Create a source mob CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); RegisterDataEssenceDescriptorTest( pDictionary ); checkResult(pMob->SetName(L"DataEssenceDescriptorTest")); checkResult( pDictionary->CreateInstance( TestDataEssenceDescriptorClassID, IID_IAAFDataEssenceDescriptor, (IUnknown**)&pDataEssenceDesc ) ); aafUID_t dataEssenceCoding; memset(&dataEssenceCoding, 0, sizeof(aafUID_t)); checkResult(pDataEssenceDesc->SetDataEssenceCoding(dataEssenceCoding)); checkResult(pDataEssenceDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc)); checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc)); // Add the MOB to the file checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pEssDesc) pEssDesc->Release(); if (pDataEssenceDesc) pDataEssenceDesc->Release(); if (pMob) pMob->Release(); if (pSourceMob) pSourceMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { 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; IAAFLocator *pLocator = NULL; IAAFLocator *pLocator2 = NULL; IAAFSourceMob *pSourceMob = NULL; IAAFMob *pMob = NULL; IAAFEssenceDescriptor *edesc = NULL; IEnumAAFLocators *pEnumLocators = NULL; aafUInt32 numLocators, numLocators2; aafUInt32 i; HRESULT hr = AAFRESULT_SUCCESS, localhr = AAFRESULT_SUCCESS; bool bFileOpen = false; // aafUID_t ddef = kAAFDataDef_Sound; 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 Mob checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); // Initialize mob properties: checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"EssenceDescriptorTest")); // Create the descriptor: // instantiate a concrete subclass of EssenceDescriptor 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)); /* CountLocators() ******************************************/ localhr = AAFRESULT_SUCCESS; // Verify AAFRESULT_NULL_PARAM is returned if (edesc->CountLocators(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; // Verify that there are no locators if (edesc->CountLocators(&numLocators) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; if (0 != numLocators) localhr = AAFRESULT_TEST_FAILED; if (localhr == AAFRESULT_SUCCESS) cout<< " CountLocators() ... Passed"<< endl; else { cout<< " CountLocators() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* AppendLocator() ******************************************/ localhr = AAFRESULT_SUCCESS; // Verify AAFRESULT_NULL_PARAM is returned if (edesc->AppendLocator(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; // Append and Count a bunch of Locators for (i=1; i<=10; i++) { // Make a concrete subclass of locator, and attach it to // the EssenceDescriptor checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); if (edesc->AppendLocator(pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Verify the number of locators numLocators = 0; edesc->CountLocators(&numLocators); if (i != numLocators) localhr = AAFRESULT_TEST_FAILED; // Verify that locator was appended edesc->GetLocatorAt(i-1, &pLocator2); if (pLocator2 != pLocator) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; } // Make sure we can't add it again // if (edesc->AppendLocator(pLocator) != AAFRESULT_OBJECT_ALREADY_ATTACHED) // localhr = AAFRESULT_TEST_FAILED; if (localhr == AAFRESULT_SUCCESS) cout<< " AppendLocator() ... Passed"<< endl; else { cout<< " AppendLocator() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* PrependLocator() ******************************************/ localhr = AAFRESULT_SUCCESS; // Verify AAFRESULT_NULL_PARAM is returned if (edesc->PrependLocator(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; for (; i<=20; i++) { // Make a concrete subclass of locator, and attach it to // the EssenceDescriptor checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); if (edesc->PrependLocator(pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Verify the number of locators numLocators = 0; edesc->CountLocators(&numLocators); if (i != numLocators) localhr = AAFRESULT_TEST_FAILED; // Verify that locator was prepended edesc->GetLocatorAt(0, &pLocator2); if (pLocator2 != pLocator) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; } if (localhr == AAFRESULT_SUCCESS) cout<< " PrependLocator() ... Passed"<< endl; else { cout<< " PrependLocator() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* InsertLocatorAt() **************************************/ localhr = AAFRESULT_SUCCESS; // Make a concrete subclass of locator to attach checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); // Verify that we can't remove an index value that is out of range if (edesc->InsertLocatorAt(numLocators+1, pLocator) != AAFRESULT_BADINDEX) localhr = AAFRESULT_TEST_FAILED; // Verify behavior when NULL is passed in if (edesc->InsertLocatorAt(1, NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; edesc->CountLocators(&numLocators); // Insert it if (edesc->InsertLocatorAt(0, pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Check it edesc->GetLocatorAt(0, &pLocator2); if (pLocator2 != pLocator) localhr = AAFRESULT_TEST_FAILED; // Count it edesc->CountLocators(&numLocators2); if (numLocators2 != numLocators+1) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; edesc->CountLocators(&numLocators); // Make a concrete subclass of locator to attach in the middle checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); // Insert it if (edesc->InsertLocatorAt(numLocators/2, pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Check it edesc->GetLocatorAt(numLocators/2, &pLocator2); if (pLocator2 != pLocator) localhr = AAFRESULT_TEST_FAILED; // Count it edesc->CountLocators(&numLocators2); if (numLocators2 != numLocators+1) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; edesc->CountLocators(&numLocators); // Make a concrete subclass of locator to attach to the end checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); // Insert it. note: its 0 based so the end is numLocators - 1 if (edesc->InsertLocatorAt(numLocators-1, pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Check it edesc->GetLocatorAt(numLocators-1, &pLocator2); if (pLocator2 != pLocator) localhr = AAFRESULT_TEST_FAILED; // Count it edesc->CountLocators(&numLocators2); if (numLocators2 != numLocators+1) localhr = AAFRESULT_TEST_FAILED; // Make sure we can't add it again if (edesc->InsertLocatorAt(numLocators+1, pLocator) != AAFRESULT_OBJECT_ALREADY_ATTACHED) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; if (localhr == AAFRESULT_SUCCESS) cout<< " InsertLocatorAt() ... Passed"<< endl; else { cout<< " InsertLocatorAt() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* GetLocatorAt() ******************************************/ localhr = AAFRESULT_SUCCESS; edesc->CountLocators(&numLocators); // Verify that we can't remove an index value that is out of range // note: Locators index is 0 based so the index numLocators is out of range if (edesc->GetLocatorAt(numLocators, &pLocator) != AAFRESULT_BADINDEX) localhr = AAFRESULT_TEST_FAILED; // Verify behavior when NULL is passed in if (edesc->GetLocatorAt(1, NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; for (i=0; i<numLocators; i++) { pLocator = NULL; if (edesc->GetLocatorAt(i, &pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; if (pLocator != NULL) pLocator->Release(); } if (localhr == AAFRESULT_SUCCESS) cout<< " GetLocatorAt() ... Passed"<< endl; else { cout<< " GetLocatorAt() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* GetLocators() ******************************************/ if (edesc->GetLocators(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; pEnumLocators = NULL; if (edesc->GetLocators(&pEnumLocators) == AAFRESULT_SUCCESS) { if (pEnumLocators != NULL) { // Try a simple test to confirm if (pEnumLocators->NextOne(&pLocator) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; edesc->GetLocatorAt(0, &pLocator2); if (pLocator != pLocator2) localhr = AAFRESULT_TEST_FAILED; else pLocator2->Release(); pLocator->Release(); pLocator = 0; pEnumLocators->Release(); } else localhr = AAFRESULT_TEST_FAILED; } else localhr = AAFRESULT_TEST_FAILED; if (localhr == AAFRESULT_SUCCESS) cout<< " GetLocators() ... Passed"<< endl; else { cout<< " GetLocators() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /* RemoveLocatorAt() ******************************************/ localhr = AAFRESULT_SUCCESS; // Verify that we can't remove an index value that is out of range // note: Locators index is 0 based so the index numLocators is out of range if (edesc->RemoveLocatorAt (numLocators) != AAFRESULT_BADINDEX) localhr = AAFRESULT_TEST_FAILED; // Remove locator at beginning, but Release it first edesc->CountLocators(&numLocators); edesc->GetLocatorAt(0, &pLocator); pLocator->Release(); edesc->GetLocatorAt(1, &pLocator); if (edesc->RemoveLocatorAt (0) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Verify the count edesc->CountLocators(&numLocators2); if (numLocators2 != (numLocators - 1)) localhr = AAFRESULT_TEST_FAILED; edesc->GetLocatorAt(0, &pLocator2); // Verify that the locators shifted properly if (pLocator != pLocator2) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; // Remove locator in middle, but Release it first edesc->CountLocators(&numLocators); edesc->GetLocatorAt((numLocators/2), &pLocator); pLocator->Release(); edesc->GetLocatorAt((numLocators/2 +1), &pLocator); if (edesc->RemoveLocatorAt (numLocators/2) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; edesc->CountLocators(&numLocators2); if (numLocators2 != (numLocators - 1)) localhr = AAFRESULT_TEST_FAILED; edesc->GetLocatorAt(numLocators/2, &pLocator2); // Verify that the locators shifted properly if (pLocator != pLocator2) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; // Remove locator at end, but Release it first edesc->CountLocators(&numLocators); edesc->GetLocatorAt(numLocators-1, &pLocator); pLocator->Release(); edesc->GetLocatorAt(numLocators-2, &pLocator); if (edesc->RemoveLocatorAt (numLocators-1) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; edesc->CountLocators(&numLocators2); if (numLocators2 != (numLocators - 1)) localhr = AAFRESULT_TEST_FAILED; edesc->GetLocatorAt(numLocators2-1, &pLocator2); // Verify that the locators shifted properly if (pLocator != pLocator2) localhr = AAFRESULT_TEST_FAILED; pLocator->Release(); pLocator = 0; pLocator2->Release(); pLocator2 = 0; if (localhr == AAFRESULT_SUCCESS) cout<< " RemoveLocatorAt() ... Passed"<< endl; else { cout<< " RemoveLocatorAt() ... FAILED"<< endl; hr = AAFRESULT_TEST_FAILED; } /*************************************************************/ // Add the source mob into the tree checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup object references if (edesc) edesc->Release(); if (pMob) pMob->Release(); if (pSourceMob) pSourceMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file, clean-up and return 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; IAAFLocator * pLocator = NULL; IAAFNetworkLocator * pNetLocator = NULL; IAAFSourceMob *pSourceMob = NULL; IAAFMob *pMob = NULL; IAAFEssenceDescriptor *edesc = NULL; aafUInt32 numLocators; 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 first mob // Create a Mob checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"SourceMOBTest")); // Create a concrete subclass of EssenceDescriptor 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; // Verify that there are no locators checkResult(edesc->CountLocators(&numLocators)); checkExpression(0 == numLocators, AAFRESULT_TEST_FAILED); // Make a locator, and attach it to the EssenceDescriptor checkResult(defs.cdNetworkLocator()-> CreateInstance(IID_IAAFNetworkLocator, (IUnknown **)&pNetLocator)); checkResult(pNetLocator->QueryInterface (IID_IAAFLocator, (void **)&pLocator)); checkResult(pLocator->SetPath (TEST_PATH)); checkResult(edesc->AppendLocator(pLocator)); checkResult(pSourceMob->SetEssenceDescriptor (edesc)); // Verify that there is now one locator checkResult(edesc->CountLocators(&numLocators)); checkExpression(1 == numLocators, AAFRESULT_TEST_FAILED); // Add the source mob into the tree checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // cleanup if (pLocator) pLocator->Release(); if (pNetLocator) pNetLocator->Release(); 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(); } // hr = pSession->EndSession(); // if (AAFRESULT_SUCCESS != hr) // return hr; // if (pSession) pSession->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) { // 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; }
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; IAAFRIFFChunk* pRIFFChunk = NULL; IAAFRIFFChunk* pRIFFChunk2 = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; IAAFBWFImportDescriptor* pBWFImportDesc = NULL; aafUInt32 testNum; HRESULT hr = S_OK; // 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); checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob); pMob->SetMobID(TEST_MobID); pMob->SetName(L"BWFImportDescriptorTest"); //Create BWFImportDescriptor to hold the RIFFChunk checkResult( defs.cdBWFImportDescriptor()-> CreateInstance(IID_IAAFBWFImportDescriptor, (IUnknown **)&pBWFImportDesc)); // Create RIFFChunks and append them to BWFImportDescriptor checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk, (IUnknown **)&pRIFFChunk)); checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk, (IUnknown **)&pRIFFChunk2)); checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk)); checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk2)); checkExpression(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk)==AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->SetFileSecurityReport(TEST_FileSecurityReport)); checkResult(pBWFImportDesc->SetFileSecurityWave(TEST_FileSecurityWave)); checkResult(pBWFImportDesc->SetCodingHistory(TEST_CodingHistory)); checkResult(pBWFImportDesc->SetBasicData(TEST_BasicData)); checkResult(pBWFImportDesc->SetStartOfModulation(TEST_StartOfModulation)); checkResult(pBWFImportDesc->SetQualityEvent(TEST_QualityEvent)); checkResult(pBWFImportDesc->SetEndOfModulation(TEST_EndOfModulation)); checkResult(pBWFImportDesc->SetQualityParameter(TEST_QualityParameter)); checkResult(pBWFImportDesc->SetOperatorComment(TEST_OperatorComment)); checkResult(pBWFImportDesc->SetCueSheet(TEST_CueSheet)); checkResult( pBWFImportDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc)); checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc)); //Add the MOB to the file checkResult(pHeader->AddMob(pMob)); testNum = 0; checkResult(pRIFFChunk->Initialize(chunkID)); checkResult(pRIFFChunk->Write(sizeof(RIFFChunksmiley), (unsigned char *)RIFFChunksmiley, &testNum)); checkExpression(testNum == sizeof(RIFFChunksmiley), AAFRESULT_TEST_FAILED); testNum = 0; checkResult(pRIFFChunk2->Initialize(chunkID2)); checkResult(pRIFFChunk2->Write(sizeof(RIFFChunkfrowney), (unsigned char *)RIFFChunkfrowney, &testNum)); checkExpression(testNum == sizeof(RIFFChunkfrowney), AAFRESULT_TEST_FAILED); pFile->Save(); pEssDesc->Release(); pEssDesc = NULL; pBWFImportDesc->Release(); pBWFImportDesc = NULL; pRIFFChunk->Release(); pRIFFChunk = NULL; pRIFFChunk2->Release(); pRIFFChunk2 = NULL; pMob->Release(); pMob = NULL; pSourceMob->Release(); pSourceMob = NULL; pDictionary->Release(); pDictionary = NULL; pHeader->Release(); pHeader = NULL; pFile->Close(); pFile->Release(); pFile = NULL; 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) { 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; }
extern int main(int argc, char *argv[]) { const char *filename_cstr = "test.aaf"; #ifndef _MSC_VER setlocale (LC_ALL, "en_US.UTF-8"); #endif if (argc >= 2) { filename_cstr = argv[1]; } // convert C str to wide string aafWChar filename[FILENAME_MAX]; size_t status = mbstowcs(filename, filename_cstr, sizeof(filename)); if (status == (size_t)-1) { fprintf(stderr, "mbstowcs failed for \"%s\"\n", filename_cstr); return 1; } remove(filename_cstr); IAAFFile *pFile = NULL; int mode = 0; aafProductIdentification_t productID; aafProductVersion_t TestVersion = {1, 1, 0, 0, kAAFVersionUnknown}; productID.companyName = (aafCharacter*)L"HSC"; productID.productName = (aafCharacter*)L"String Tester"; productID.productVersion = &TestVersion; productID.productVersionString = NULL; productID.productID = TestProductID; productID.platform = (aafCharacter*)L"Linux"; // Create new AAF file check(AAFFileOpenNewModify(filename, mode, &productID, &pFile)); // Create a simple Mob IAAFClassDef *classDef = NULL; IAAFMob *pMob = NULL; IAAFHeader *pHeader = NULL; IAAFDictionary *pDictionary = NULL; check(pFile->GetHeader(&pHeader)); check(pHeader->GetDictionary(&pDictionary)); check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &classDef)); check(classDef->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); classDef->Release(); check(pMob->SetMobID(TEST_MobID)); // UTF-8 for codepoint U+1D11E (musical G Clef): 0xf0,0x9d,0x84,0x9e // UTF-8 for codepoint U+1D122 (musical F Clef): 0xf0,0x9d,0x84,0xa2 // http://unicode.org/charts/PDF/U1D100.pdf // http://en.wikipedia.org/wiki/UTF-8 aafCharacter *mobname; const unsigned char inputStr[] = { 0xf0,0x9d,0x84,0x9e, // U+1D11E 0xf0,0x9d,0x84,0xa2, // U+1D122 0x4d, 0x6f, 0x62, // 'M' 'o' 'b' 0x0 }; // Convert UTF-8 inputStr to native wchar_t representation (UTF-32 Unix, UTF-16 Windows) int wlen = 0, n; #ifndef _MSC_VER int ret; char *p = (char *)inputStr; while ((ret = mblen(p, 4)) > 0) { ++wlen; p+=ret; } mobname = new aafCharacter[wlen+1]; n = mbstowcs(mobname, (const char *)inputStr, wlen+1); if (n == -1) { fprintf (stderr, "mbstowcs returned -1. Invalid multibyte string\n"); exit(1); } #else // Under Windows we must use MultiByteToWideChar() to get correct UTF-8 conversion to UTF-16 // since mbstowcs() is broken for UTF-8. wlen = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, (LPCSTR)inputStr, -1, NULL, 0); if (wlen == 0) { fprintf (stderr, "MultiByteToWideChar returned 0. Invalid multibyte string\n"); exit(1); } mobname = new aafCharacter[wlen]; n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, (LPCSTR)inputStr, -1, mobname, wlen); if (n == 0) { fprintf (stderr, "MultiByteToWideChar returned 0. Invalid multibyte string\n"); exit(1); } #endif // SetName() calls OMSimpleProperty::set() which does a memcpy of the mobname string // to an OMByte* variable 'bits()' at OMProperty.cpp:399 // Found by setting an rwatch on mobname address. check(pMob->SetName(mobname)); aafUInt32 size_before = 0; check(pMob->GetNameBufLen(&size_before)); check(pHeader->AddMob(pMob)); pMob->Release(); pHeader->Release(); pDictionary->Release(); // All the work of storing to disk happens during Save() // The bits() variable is next read in OMType::contract() at OMType.cpp:137 // which is called by ImplAAFTypeDefCharacter::externalize() at ImplAAFTypeDefCharacter.cpp:307 // which is called by ImplAAFTypeDefString::externalize() at ImplAAFTypeDefString.cpp:584 // which is called by OMSSStoredObject::save() at OMSSStoredObject.cpp:382 check(pFile->Save()); check(pFile->Close()); pFile->Release(); // OMCharacterStringProperty<CharacterType>::stringLength() at OMVariableSizePropertyT.h:80 // calculates string length of AAF string properties // Read AAF file back in check(AAFFileOpenExistingRead(filename, mode, &pFile)); // Get the Mob check(pFile->GetHeader(&pHeader)); check(pHeader->LookupMob(TEST_MobID, &pMob)); aafUInt32 size_after = 0; check(pMob->GetNameBufLen(&size_after)); aafCharacter *mobname_after = new aafCharacter[size_after]; check(pMob->GetName(mobname_after, size_after)); // Compare Mob name before storing to disk with Mob name read back from disk int test_result = 0; if (size_before != size_after) { printf("size_before=%d != size_after=%d\n", size_before, size_after); test_result = 1; } else { if (memcmp(mobname, mobname_after, size_before) != 0) { printf("wchar_t* mobname and wchar_t* mobname_after differ:\n"); printf(" %s\n", hexDump(mobname, size_before)); printf(" %s\n", hexDump(mobname_after, size_after)); test_result = 1; } } // Check if the multibyte (UTF-8) versions of mobname and mobname_after match. char *outputStr; #ifndef _MSC_VER wlen = wcslen(mobname_after)*sizeof(aafCharacter) + 1; outputStr = new char [wlen]; n = wcstombs (outputStr, mobname_after, wlen); if (n == -1) { fprintf(stderr, "Could not convert mobname_after to multibyte str\n"); exit(1); } #else wlen = WideCharToMultiByte(CP_UTF8, 0, mobname_after, -1, NULL, 0, NULL, NULL); if (wlen == 0) { fprintf (stderr, "Failed to convert mobname_after to multibyte string\n"); exit(1); } outputStr = new char[wlen]; wlen = WideCharToMultiByte(CP_UTF8, 0, mobname_after, -1, outputStr, wlen, NULL, NULL); #endif if (strlen((char *)inputStr) != strlen(outputStr)) { fprintf(stderr, "UTF-8 version of string: input length(%d) != output length(%d)\n", (int)strlen((char *)inputStr), (int)strlen(outputStr)); test_result = 1; } if (strcmp((char *)inputStr, outputStr) != 0) { fprintf(stderr, "UTF-8 version of string: input and output strings differ\n"); printf(" %s\n", hexDump(inputStr, strlen((char *)inputStr))); printf(" %s\n", hexDump(outputStr, strlen(outputStr))); test_result = 1; } pMob->Release(); pHeader->Release(); check(pFile->Close()); pFile->Release(); delete [] mobname; delete [] mobname_after; return test_result; }
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) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFRIFFChunk* pRIFFChunk = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; IAAFBWFImportDescriptor* pBWFImportDesc = NULL; aafUInt32 byteswritten; aafUInt32 bBytesWrote = 0; HRESULT hr = S_OK; // 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); checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob); pMob->SetMobID(TEST_MobID); pMob->SetName(L"RIFFChunkTest"); //Create BWFImportDescriptor to hold the RIFFChunk checkResult( defs.cdBWFImportDescriptor()-> CreateInstance(IID_IAAFBWFImportDescriptor, (IUnknown **)&pBWFImportDesc)); // Create RIFFChunk and add it to BWFImportDescriptor checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk, (IUnknown **)&pRIFFChunk)); checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk)); checkResult( pBWFImportDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc)); checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc)); //Add the MOB to the file checkResult(pHeader->AddMob(pMob)); bBytesWrote = 0; checkResult(pRIFFChunk->Initialize(chunkID)); checkResult(pRIFFChunk->Write(sizeof(RIFFChunksmiley), (unsigned char *)RIFFChunksmiley, &bBytesWrote)); byteswritten = bBytesWrote; bBytesWrote = 0; checkResult(pRIFFChunk->Write(sizeof(RIFFChunkfrowney), (unsigned char *)RIFFChunkfrowney, &bBytesWrote)); byteswritten += bBytesWrote; checkExpression(byteswritten == sizeof(RIFFChunksmiley) + sizeof(RIFFChunkfrowney), AAFRESULT_TEST_FAILED); pFile->Save(); pEssDesc->Release(); pEssDesc = NULL; pBWFImportDesc->Release(); pBWFImportDesc = NULL; pRIFFChunk->Release(); pRIFFChunk = NULL; pMob->Release(); pMob = NULL; pSourceMob->Release(); pSourceMob = NULL; pDictionary->Release(); pDictionary = NULL; pHeader->Release(); pHeader = NULL; pFile->Close(); pFile->Release(); pFile = NULL; 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) { IAAFFile* pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFSourceMob* pSrcMob = NULL; IAAFSourceMob* pTapeMob = NULL; IAAFEssenceDescriptor* pDesc = NULL; IAAFMob* pTempMob = NULL; HRESULT hr = S_OK; long test; aafSourceRef_t ref; IAAFEssenceDescriptor* pEssDesc = NULL; IAAFTapeDescriptor* pTapeDesc = NULL; 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); // Create a Master Mob checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); // Set the IAAFMob properties checkResult(pMob->SetMobID(TEST_Master_MobID)); checkResult(pMob->SetName(MobName)); checkResult(pMob->QueryInterface(IID_IAAFMasterMob, (void **) &pMasterMob)); // Create source mob to associate with our MasterMob. checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pTapeMob)); hr = defs.cdTapeDescriptor()-> CreateInstance(IID_IAAFTapeDescriptor, (IUnknown **)&pTapeDesc); if (AAFRESULT_SUCCESS == hr) { hr = pTapeDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc); if (AAFRESULT_SUCCESS == hr) { hr = pTapeMob->SetEssenceDescriptor(pEssDesc); if (AAFRESULT_SUCCESS == hr) { hr = pTapeDesc->SetTapeManufacturer( Manufacturer ); if (AAFRESULT_SUCCESS == hr ) { hr = pTapeDesc->SetTapeModel( Model ); if (AAFRESULT_SUCCESS == hr ) { hr = pTapeDesc->SetTapeFormFactor( FormFactor ); if (AAFRESULT_SUCCESS == hr ) { hr = pTapeDesc->SetSignalType( VideoSignalType ); if (AAFRESULT_SUCCESS == hr ) { hr = pTapeDesc->SetTapeFormat( TapeFormat ); if (AAFRESULT_SUCCESS == hr ) hr = pTapeDesc->SetTapeLength( TapeLength ); } } } } } pEssDesc->Release(); pEssDesc = NULL; } pTapeDesc->Release(); pTapeDesc = NULL; } for (test = 0; test < NumMobSlots; test++) { IAAFDataDefSP pDataDef; checkResult (pDictionary->LookupDataDef (*slotDDefs[test], &pDataDef)); checkResult(pTapeMob->AddNilReference (test, TAPE_MOB_LENGTH_ARR[test], pDataDef, slotRates[test])); } checkResult(pTapeMob->QueryInterface(IID_IAAFMob, (void **) &pTempMob)); checkResult(pTempMob->SetName(TAPE_MOB_NAME)); checkResult(pTempMob->SetMobID(tapeMobID)); //save the id for future (test) reference // TAPE_MOB_ID = tapeMobID; checkResult(pHeader->AddMob(pTempMob)); pTempMob->Release(); pTempMob = NULL; // Add some slots for (test = 0; test < NumMobSlots; test++) { // Create source mob to associate with our MasterMob. checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSrcMob)); ref.sourceID = tapeMobID; ref.sourceSlotID = test; ref.startTime = TAPE_MOB_OFFSET_ARR[test]; IAAFDataDefSP pDDef; checkResult(pDictionary->LookupDataDef(*slotDDefs[test], &pDDef)); checkResult(pSrcMob->AppendPhysSourceRef (slotRates[test], test, pDDef, ref, TAPE_MOB_LENGTH_ARR[test])); // Create a concrete subclass of EssenceDescriptor checkResult(defs.cdAIFCDescriptor()-> CreateInstance(IID_IAAFEssenceDescriptor, (IUnknown **)&pDesc)); IAAFAIFCDescriptor* pAIFCDesc = NULL; checkResult(pDesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); checkResult(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; checkResult(pSrcMob->SetEssenceDescriptor(pDesc)); pDesc->Release(); pDesc = NULL; // Append source MOB to header checkResult(pSrcMob->QueryInterface(IID_IAAFMob, (void **) &pTempMob)); checkResult(pTempMob->SetMobID(TEST_Source_MobIDs[test])); checkResult(pTempMob->SetName(L"source mob")); checkResult(pHeader->AddMob(pTempMob)); pTempMob->Release(); pTempMob = NULL; IAAFDataDefSP pDataDef; checkResult (pDictionary->LookupDataDef (*slotDDefs[test], &pDataDef)); checkResult(pMasterMob->AddMasterSlot(pDataDef, test, pSrcMob, test+1, slotNames[test])); pSrcMob->Release(); pSrcMob = NULL; } // Add the master mob to the file and cleanup checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pTempMob) pTempMob->Release(); if (pEssDesc) pEssDesc->Release(); if (pTapeDesc) pTapeDesc->Release(); if (pDesc) pDesc->Release(); if (pSrcMob) pSrcMob->Release(); if (pTapeMob) pTapeMob->Release(); if (pMasterMob) pMasterMob->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 *filename, aafUID_constref fileKind) { TestProductID.companyName = companyName; TestProductID.productName = productName; TestProductID.productVersionString = NULL; TestProductID.productID = UnitTestProductID; TestProductID.platform = NULL; TestProductID.productVersion = &TestVersion; HRESULT hr = S_OK; try { RemoveTestFile(filename); // Open new file IAAFFile *pFile = NULL; TestProductID.productVersionString = const_cast<aafWChar*>(L"CreateAAFFile"); checkResult( AAFFileOpenNewModifyEx( filename, &fileKind, 0, &TestProductID, &pFile) ); // Get the header & dictionary IAAFHeader *pHeader = NULL; IAAFDictionary *pDictionary = NULL; checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); // Create a MasterMob IAAFMob *pMob = NULL; IAAFClassDef *classDef = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFMasterMob, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); classDef->Release(); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"CreateAAFFile - MasterMob")); checkResult(pHeader->AddMob(pMob)); pMob->Release(); // Create a SourceMob IAAFSourceMob *pSourceMob = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFSourceMob, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); classDef->Release(); checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_SourceMobID)); checkResult(pMob->SetName(L"CreateAAFFile - SourceMob")); IAAFEssenceDescriptor *edesc = NULL; IAAFAIFCDescriptor *pAIFCDesc = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFAIFCDescriptor, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFEssenceDescriptor, (IUnknown **)&edesc)); classDef->Release(); checkResult(edesc->QueryInterface(IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); aafUInt8 buf[] = {0x00}; checkResult(pAIFCDesc->SetSummary(sizeof(buf), buf)); checkResult(pSourceMob->SetEssenceDescriptor(edesc)); checkResult(pHeader->AddMob(pMob)); pAIFCDesc->Release(); edesc->Release(); pSourceMob->Release(); pMob->Release(); pDictionary->Release(); pHeader->Release(); // Save & close the file checkResult(pFile->Save()); checkResult(pFile->Close()); checkResult(pFile->Release()); cout << "CreateAAFFile() - created new file" << endl; } catch (HRESULT& rResult) { hr = rResult; cout << "*** CreateAAFFile: caught error hr=0x" << hex << hr << dec << endl; } 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; IAAFContainerDef* pContainer = NULL; IAAFSourceMob *pSourceMob = NULL; IAAFMob *pMob = NULL; IAAFEssenceDescriptor *edesc = NULL; IAAFFileDescriptor *pFileDesc = NULL; IAAFFileDescriptor2 *pFileDesc2 = 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; aafRational_t audioRate = { 44100, 1 }; // Create a Mob checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"FileDescriptorTest")); // Add some slots for(test = 0; test < 2; test++) { checkResult(pSourceMob->AddNilReference (test+1, 0, defs.ddkAAFSound(), audioRate)); } // 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(edesc->QueryInterface(IID_IAAFFileDescriptor, (void **) &pFileDesc)); checkResult(pFileDesc->SetSampleRate (checkSampleRate)); checkResult(pDictionary->LookupContainerDef(checkContainer, &pContainer)); checkResult(pFileDesc->SetContainerFormat (pContainer)); pContainer->Release(); pContainer = NULL; checkResult(pFileDesc->SetLength (checkLength)); checkResult(pFileDesc->QueryInterface(IID_IAAFFileDescriptor2, (void **)&pFileDesc2)); checkResult(pFileDesc2->SetLinkedSlotID (checkLinkedSlotID)); // checkResult(pFileDesc->SetIsInContainer (kAAFTrue)); checkResult(pSourceMob->SetEssenceDescriptor (edesc)); checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } if (pFileDesc) pFileDesc->Release(); if (pFileDesc2) pFileDesc2->Release(); 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; }
void EnumEssenceDataTest::createFileMob(int itemNumber) { assert(_pFile && _pHeader && _pDictionary); assert(NULL == _pSourceMob); assert(NULL == _pMob); assert(NULL == _pFileDescriptor); assert(NULL == _pEssenceDescriptor); assert(NULL == _pSourceMob); // Format the mob name. wchar_t wcBuffer[512]; char cBuffer[256]; sprintf(cBuffer, "EnumEssenceDataTest File Mob %d", itemNumber); size_t count = mbstowcs(wcBuffer, cBuffer, strlen(cBuffer) + 1); if (static_cast<size_t>(-1) == count) check(AAFRESULT_INTERNAL_ERROR); CAAFBuiltinDefs defs (_pDictionary); // Create a Mob check(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&_pSourceMob)); check(_pSourceMob->QueryInterface (IID_IAAFMob, (void **)&_pMob)); check(_pMob->SetMobID(TEST_MobIDs[itemNumber])); check(_pMob->SetName(wcBuffer)); // Create a concrete subclass of FileDescriptor check(defs.cdAIFCDescriptor()-> CreateInstance(IID_IAAFFileDescriptor, (IUnknown **)&_pFileDescriptor)); IAAFAIFCDescriptor* pAIFCDesc = NULL; check(_pFileDescriptor->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; check(_pFileDescriptor->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&_pEssenceDescriptor)); check(_pSourceMob->SetEssenceDescriptor (_pEssenceDescriptor)); check(_pHeader->AddMob(_pMob)); createEssenceData(_pSourceMob); // Cleanup instance data for reuse... _pEssenceDescriptor->Release(); _pEssenceDescriptor = NULL; _pFileDescriptor->Release(); _pFileDescriptor = NULL; _pMob->Release(); _pMob = NULL; _pSourceMob->Release(); _pSourceMob = NULL; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFMob* pMob = NULL; IAAFTIFFDescriptor* pTIFFDesc = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; HRESULT hr = AAFRESULT_SUCCESS; aafUInt8 summary[512]; aafUInt16 numEntries = 2; unsigned long nOffset; #if defined( OS_WINDOWS ) tiffHeader.tiff_byteOrder = TIFF_LITTLEENDIAN; #else tiffHeader.tiff_byteOrder = TIFF_BIGENDIAN; #endif tiffHeader.tiff_identNumber = TIFF_VERSION; tiffHeader.tiff_firstIFD = 0; memcpy(summary, (void *)&tiffHeader, sizeof(tiffHeader)); nOffset = sizeof(tiffHeader); tagImageWidth.tdir_tag = TIFFTAG_IMAGEWIDTH; tagImageWidth.tdir_type = TIFF_LONG; tagImageWidth.tdir_count = 1; tagImageWidth.tdir_offset = 320; tagImageLength.tdir_tag = TIFFTAG_IMAGELENGTH; tagImageLength.tdir_type = TIFF_LONG; tagImageLength.tdir_count = 1; tagImageLength.tdir_offset = 640; // Write IFD data memcpy(summary+nOffset, &numEntries, sizeof(numEntries)); nOffset += sizeof(numEntries); memcpy((void *)(summary+nOffset), (void *)&tagImageWidth, sizeof(tagImageWidth)); nOffset += sizeof(tagImageWidth); memcpy((void *)(summary+nOffset), (void *)&tagImageLength, sizeof(tagImageLength)); nOffset += sizeof(tagImageLength); 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 source mob checkResult(defs.cdSourceMob()-> CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"TIFFDescriptorTest")); checkResult(defs.cdTIFFDescriptor()-> CreateInstance(IID_IAAFTIFFDescriptor, (IUnknown **)&pTIFFDesc)); checkResult(pTIFFDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc)); checkResult(pTIFFDesc->SetIsUniform(kAAFFalse)); checkResult(pTIFFDesc->SetIsContiguous(kAAFTrue)); checkResult(pTIFFDesc->SetLeadingLines((aafInt32)10)); checkResult(pTIFFDesc->SetTrailingLines((aafInt32)20)); checkResult(pTIFFDesc->SetJPEGTableID((aafJPEGTableID_t)0)); checkResult(pTIFFDesc->SetSummary((aafUInt32)nOffset, (aafDataValue_t) summary)); checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc)); // Add the MOB to the file checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pTIFFDesc) pTIFFDesc->Release(); if (pDictionary) pDictionary->Release(); if (pEssDesc) pEssDesc->Release(); if (pMob) pMob->Release(); if (pSourceMob) pSourceMob->Release(); if (pHeader) pHeader->Release(); if (pFile) { 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; IAAFCompositionMob* pCompMob=NULL; IAAFMob* pMob = NULL; IAAFTimelineMobSlot* pNewSlot = NULL; IAAFSourceClip* pSourceClip = NULL; IAAFSourceReference* pSourceRef = NULL; IAAFTransition* pTransition = NULL; IAAFOperationGroup* pOperationGroup = NULL; IAAFSegment* pSegment = NULL; IAAFSegment* pEffectFiller = NULL; IAAFComponent* pComponent = NULL; IAAFFiller* pFiller = NULL; IAAFSequence* pSequence = NULL; IAAFOperationDef* pOperationDef = NULL; IAAFParameter *pParm = NULL; IAAFParameterDef* pParamDef = NULL; IAAFConstantValue* pConstantValue = NULL; HRESULT hr = S_OK; aafLength_t transitionLength; aafPosition_t cutPoint = 0; aafLength_t effectLen = TEST_EFFECT_LEN; aafUID_t effectID = kTestEffectID; aafUID_t parmID = kTestParmID; transitionLength = 100; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Create the effect and parameter definitions checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC)); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational ())); checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS)); checkResult(pDictionary->RegisterParameterDef(pParamDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); // ------------------------------------------------------------ // To test a Transition we need to create a Sequence which will // a Filler, a transition and another Filler. I know this is not // very interesting, but it will let us test the Transition // interface with the least amount of other stuff. // ------------------------------------------------------------ // // Create a CompositionMob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFCompositionMob, (IUnknown **)&pCompMob)); checkResult(pCompMob->Initialize(L"Transition Test")); // Get a MOB interface checkResult(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); // Create a Sequence checkResult(defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **) &pSequence)); // Get a Segment interface checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); // Get a component interface and checkResult(pSequence->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); // set the Data definition for it ! checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create a new Mob Slot that will contain the sequence aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"Transition", 0, &pNewSlot)); // Create a Filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); // Get a component interface checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pFiller->Release(); pFiller = NULL; pComponent->Release(); pComponent = NULL; checkResult(defs.cdTransition()-> CreateInstance(IID_IAAFTransition, (IUnknown **)&pTransition)); // Create an empty EffectGroup object !! checkResult(defs.cdOperationGroup()-> CreateInstance(IID_IAAFOperationGroup, (IUnknown **)&pOperationGroup)); checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), transitionLength, pOperationDef)); // Create a constant value parameter. checkResult(defs.cdConstantValue()-> CreateInstance(IID_IAAFConstantValue, (IUnknown **)&pConstantValue)); aafRational_t testLevel = {1, 2}; checkResult(pConstantValue->Initialize (pParamDef, sizeof(testLevel), (aafDataBuffer_t)&testLevel)); checkResult(pConstantValue->QueryInterface (IID_IAAFParameter, (void **)&pParm)); checkResult(pOperationGroup->AddParameter (pParm)); pParm->Release(); pParm = NULL; pConstantValue->Release(); pConstantValue = NULL; checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFSegment, (IUnknown **) &pEffectFiller)); checkResult(pEffectFiller->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; checkResult(pOperationGroup->AppendInputSegment (pEffectFiller)); // release the filler pEffectFiller->Release(); pEffectFiller = NULL; checkResult(pOperationGroup->SetBypassOverride (1)); checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); aafSourceRef_t sourceRef; sourceRef.sourceID = zeroMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(), effectLen, sourceRef)); checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pOperationGroup->SetRender (pSourceRef)); checkResult(pTransition->Initialize (defs.ddkAAFPicture(), transitionLength, cutPoint, pOperationGroup)); checkResult(pTransition->QueryInterface (IID_IAAFComponent, (void **)&pComponent)); // now append the transition checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create the second filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; pFiller->Release(); pFiller = NULL; // Now, we append the composition mob to the file checkResult(pHeader->AddMob(pMob)); // and we are done ! } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pParm) pParm->Release(); if (pConstantValue) pConstantValue->Release(); if (pParamDef) pParamDef->Release(); if (pSourceClip) pSourceClip->Release(); if (pSourceRef) pSourceRef->Release(); if (pNewSlot) pNewSlot->Release(); if (pSegment) pSegment->Release(); if (pSequence) pSequence->Release(); if (pFiller) pFiller->Release(); if (pOperationDef) pOperationDef->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pMob) pMob->Release(); if (pCompMob) pCompMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pTransition) pTransition->Release(); if (pFile) { if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; 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; }