void EventTest::Create( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { assert(NULL == _pFile); // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &_pFile )); _bWritableFile = 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)); // Make a text clip. CreateEvent(); // cleanup Close(); }
void EnumEssenceDataTest::createFile(const wchar_t *pFileName) { // Remove the previous test file if any. removeTestFile(pFileName); check(CreateTestFile( pFileName, _fileKind, _rawStorageType, _productInfo, &_pFile )); _bFileOpen = true; check(_pFile->GetHeader(&_pHeader)); check(_pHeader->GetDictionary(&_pDictionary)); for (aafUInt32 item = 0; item < _maxMobCount; ++item) createFileMob(item); check(_pFile->Save()); cleanupReferences(); }
static HRESULT ReadAAFFile(aafWChar * pFileName ) { HRESULT hr = AAFRESULT_SUCCESS; IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary * pDict = NULL; aafBoolean_t bFileOpen = kAAFFalse; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = kAAFTrue; checkResult (pFile->GetHeader (&pHeader)); assert (pHeader); checkResult (pHeader->GetDictionary (&pDict)); assert (pDict); // Read the mob, slots, etc to verify the contents ... checkResult(verifyContents (pHeader, pDict, kAAFFalse)); //False => NOT minimal testing; i.e. test everything }//try catch (HRESULT & rResult) { hr = rResult; } if (pDict) pDict->Release(); if (pHeader) pHeader->Release(); if (bFileOpen && pFile) { stopGap(pFile->Close()); pFile->Release(); } return hr; }//ReadAAFFile()
void EssenceDataTest::createFile( wchar_t *pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType) { // Delete the test file if it already exists. remove(convert(pFileName)); check(CreateTestFile( pFileName, fileKind, rawStorageType, _productInfo, &_pFile )); _bFileOpen = true; check(_pFile->GetHeader(&_pHeader)); check(_pHeader->GetDictionary(&_pDictionary)); createFileMob(0); //use unique mobid's (without using cocreate guid() createFileMob(1); //use unique mobid's (without using cocreate guid() check(_pFile->Save()); cleanupReferences(); }
void HTMLClipTest::Create(wchar_t *pFileName, aafProductIdentification_t* pinfo) { assert(NULL == _pFile); // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(AAFFileOpenNewModify(pFileName, 0, pinfo, &_pFile)); _bWritableFile = 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)); // Make a html clip. CreateHTMLClip(); // cleanup Close(); }
static HRESULT ModifyAAFFile(aafWChar *filename, int level) { HRESULT hr = S_OK; try { // Open existing file for modification IAAFFile *pFile = NULL; TestProductID.productVersionString = const_cast<aafWChar*>(L"ModifyAAFFile"); checkResult( AAFFileOpenExistingModify( filename, 0, // modeFlags &TestProductID, &pFile) ); cout << "ModifyAAFFile() - appended Identification" << endl; // Get the header & dictionary IAAFHeader *pHeader = NULL; IAAFDictionary *pDictionary = NULL; checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); // Search for Mobs IAAFMob *pFileMob = NULL; IEnumAAFMobs *pFileMobIter = NULL; aafSearchCrit_t criteria; criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFFileMob; // Search by File Mob checkResult(pHeader->GetMobs(&criteria, &pFileMobIter)); while (AAFRESULT_SUCCESS == pFileMobIter->NextOne(&pFileMob)) { if (level == 0) break; IAAFEssenceDescriptor *edesc = NULL; IAAFSourceMob *pSourceMob = NULL; CR(pFileMob->QueryInterface(IID_IAAFSourceMob, (void **)&pSourceMob)); CR(pSourceMob->GetEssenceDescriptor(&edesc)); // Change the Name property CR(pFileMob->SetName(L"ModifyAAFFile - modified Name")); cout << "ModifyAAFFile() - changed FileMob's Name property" << endl; if (level == 1) break; // Change descriptor's properties IAAFAIFCDescriptor *pAIFCDesc = NULL; CR(edesc->QueryInterface(IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); aafUInt8 AIFCsum[] = {0xa1,0xfc}; CR(pAIFCDesc->SetSummary(sizeof(AIFCsum), AIFCsum)); pAIFCDesc->Release(); edesc->Release(); cout << "ModifyAAFFile() - changed AIFCDescriptor's Summary" << endl; if (level == 2) break; // Change descriptor to new one (overwriting old one) IAAFClassDef *classDef = NULL; IAAFFileDescriptor *pFileDesc = NULL; IAAFWAVEDescriptor *pWAVEDesc = NULL; IAAFEssenceDescriptor *pNewEdesc = NULL; CR(pDictionary->LookupClassDef(AUID_AAFWAVEDescriptor, &classDef)); CR(classDef->CreateInstance(IID_IAAFFileDescriptor, (IUnknown **)&pFileDesc)); CR(pFileDesc->QueryInterface(IID_IAAFWAVEDescriptor, (void **)&pWAVEDesc)); CR(pFileDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pNewEdesc)); aafUInt8 WAVEsum[] = {0x1a,0x1e,0xee,0xee}; CR(pWAVEDesc->SetSummary(sizeof(WAVEsum), WAVEsum)); CR(pSourceMob->SetEssenceDescriptor(pNewEdesc)); pNewEdesc->Release(); pWAVEDesc->Release(); pFileDesc->Release(); classDef->Release(); cout << "ModifyAAFFile() - replaced AIFCDescriptor with WAVEDescriptor" << endl; if (level == 3) break; // Add EssenceData IAAFEssenceData *pEssenceData = NULL; IAAFEssenceData2 *pEssenceData2 = NULL; IAAFPlainEssenceData *pPlainEssenceData = NULL; aafUInt32 bytesWritten = 0; aafUInt8 essdata[] = "Zaphod Beeblebrox"; CR(pDictionary->LookupClassDef(AUID_AAFEssenceData, &classDef)); CR(classDef->CreateInstance(IID_IAAFEssenceData, (IUnknown **)&pEssenceData)); CR(pEssenceData->SetFileMob(pSourceMob)); CR(pHeader->AddEssenceData(pEssenceData)); CR(pEssenceData->QueryInterface(IID_IAAFEssenceData2, (void**)&pEssenceData2)); CR(pEssenceData2->GetPlainEssenceData(0, &pPlainEssenceData)); CR(pPlainEssenceData->Write(sizeof(essdata), essdata, &bytesWritten)); pEssenceData->Release(); pEssenceData2->Release(); pPlainEssenceData->Release(); classDef->Release(); cout << "ModifyAAFFile() - added EssenceData" << endl; pSourceMob->Release(); } pFileMob->Release(); pFileMobIter->Release(); pDictionary->Release(); pHeader->Release(); // Save & close the file checkResult(pFile->Save()); checkResult(pFile->Close()); checkResult(pFile->Release()); } catch (HRESULT& rResult) { hr = rResult; cout << "*** ModifyAAFFile: caught error hr=0x" << hex << hr << dec << endl; } 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(const aafWChar * pFileName, testDataFile_t *dataFile, testType_t testType) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFEssenceAccess* pEssenceAccess = NULL; IAAFEssenceFormat* pFormat = NULL; IAAFEssenceFormat *format = NULL; IAAFLocator *pLocator = NULL; aafMobID_t masterMobID; aafProductIdentification_t ProductInfo; aafRational_t editRate = {44100, 1}; aafRational_t sampleRate = {44100, 1}; FILE* pWavFile = NULL; unsigned char dataBuff[4096], *dataPtr; aafUInt32 dataOffset, dataLen; aafUInt16 bitsPerSample, numCh; aafInt32 n, numSpecifiers; aafUID_t essenceFormatCode, testContainer; IAAFClassDef *pMasterMobDef = NULL; IAAFClassDef *pNetworkLocatorDef = NULL; IAAFDataDef *pSoundDef = NULL; aafUInt32 samplesWritten, bytesWritten; // Delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), pFileName); remove(chFileName); if(dataFile != NULL) { // Delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), dataFile->dataFilename); remove(chFileName); } aafProductVersion_t v; v.major = 1; v.minor = 0; v.tertiary = 0; v.patchLevel = 0; v.type = kAAFVersionUnknown; ProductInfo.companyName = companyName; ProductInfo.productName = productName; ProductInfo.productVersion = &v; ProductInfo.productVersionString = NULL; ProductInfo.productID = NIL_UID; ProductInfo.platform = NULL; /* Create a new AAF file */ check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile)); check(pFile->GetHeader(&pHeader)); /* Get the AAF Dictionary from the file */ check(pHeader->GetDictionary(&pDictionary)); /* Lookup class definitions for the objects we want to create. */ check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &pMasterMobDef)); check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator, &pNetworkLocatorDef)); /* Lookup any necessary data definitions. */ check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pSoundDef)); /* Create a Mastermob */ // Get a Master MOB Interface check(pMasterMobDef-> CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pMasterMob)); // Get a Mob interface and set its variables. check(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID(&masterMobID)); check(pMob->SetName(L"A Master Mob")); // Add it to the file check(pHeader->AddMob(pMob)); if(dataFile != NULL) { // Make a locator, and attach it to the EssenceDescriptor check(pNetworkLocatorDef-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); check(pLocator->SetPath (dataFile->dataFilename)); testContainer = dataFile->dataFormat; } else { pLocator = NULL; testContainer = ContainerAAF; } // Open the Essence file to be included in this AAF file("Laser.wav") pWavFile = fopen("Laser.wav", "r"); if (pWavFile) { // Read in the essence data int rc = fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile); (void)rc; check(loadWAVEHeader(dataBuff, &bitsPerSample, &numCh, &sampleRate, &dataOffset, &dataLen)); assert (numCh == 1, "Input file must be mono audio data"); // The testtype is for Internal Standard calls so set dataPtr dataPtr = dataBuff + dataOffset; /* Create the Essence Data specifying the codec, container, edit rate and sample rate */ check(pMasterMob->CreateEssence(1, // Slot ID pSoundDef, // MediaKind kAAFCodecWAVE, // codecID editRate, // edit rate sampleRate, // sample rate kAAFCompressionDisable, pLocator, // In current file testContainer, // In AAF Format &pEssenceAccess)); // Compress disabled check(pEssenceAccess->GetFileFormatParameterList (&format)); check(format->NumFormatSpecifiers (&numSpecifiers)); for(n = 0; n < numSpecifiers; n++) { check(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL)); } format->Release(); format = NULL; // Tell the AAFEssenceAccess what the format is. check(pEssenceAccess->GetEmptyFileFormat (&pFormat)); check(pFormat->NumFormatSpecifiers (&numSpecifiers)); /* Set the properties that describe the essence data, such as audio sample size */ aafInt32 sampleSize = bitsPerSample; check(pFormat->AddFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleSize), (aafUInt8 *)&sampleSize)); check(pEssenceAccess->PutFileFormat (pFormat)); pFormat->Release(); pFormat = NULL; /* Write the samples */ aafInt32 samplesLeft = dataLen; aafUInt32 bytesPerSample = bitsPerSample/8; aafUInt32 samplesToWrite = 0; if (dataLen*bytesPerSample < (sizeof(dataBuff) - dataOffset)) samplesToWrite = dataLen; else samplesToWrite = (sizeof(dataBuff) - dataOffset)/bytesPerSample; //read input wav file in chunks and write them to Essence stream while (true) { check(pEssenceAccess->WriteSamples( samplesToWrite, // Number of Samples sizeof(dataBuff), // buffer size dataPtr, // THE data &samplesWritten, &bytesWritten)); samplesLeft = samplesLeft-samplesToWrite; if (samplesLeft <= 0) break; aafUInt32 bytesToWrite = fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile); samplesToWrite = bytesToWrite/bytesPerSample; dataPtr = dataBuff; } // Close the essence data file fclose(pWavFile); /* Set the essence to indicate that you have finished writing the samples */ check(pEssenceAccess->CompleteWrite()); pEssenceAccess->Release(); pEssenceAccess = NULL; } else { printf("***Failed to open Wave file Laser.wav\n"); } /* Release COM interfaces */ pMob->Release(); pMob = NULL; pMasterMob->Release(); pMasterMob = NULL; pSoundDef->Release(); pSoundDef = NULL; pNetworkLocatorDef->Release(); pNetworkLocatorDef = NULL; pMasterMobDef->Release(); pMasterMobDef = NULL; pDictionary->Release(); pDictionary = NULL; pHeader->Release(); pHeader = NULL; /* Save the AAF file */ pFile->Save(); /* Close the AAF file */ pFile->Close(); pFile->Release(); pFile = NULL; cleanup: // Cleanup and return if(pFormat) pFormat->Release(); if(format) format->Release(); if(pLocator) pLocator->Release(); if (pEssenceAccess) pEssenceAccess->Release(); if (pMasterMob) pMasterMob->Release(); if (pMob) pMob->Release(); if (pSoundDef) pSoundDef->Release(); if (pNetworkLocatorDef) pNetworkLocatorDef->Release(); if (pMasterMobDef) pMasterMobDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { pFile->Close(); pFile->Release(); } return moduleErrorTmp; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFDefObject* pDef = NULL; IAAFContainerDef* pContainerDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; /* 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.cdContainerDef()-> CreateInstance(IID_IAAFContainerDef, (IUnknown **)&pContainerDef)); checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef)); checkResult(pContainerDef->Initialize (testUID, sName, sDescription)); checkResult(pDictionary->RegisterContainerDef(pContainerDef)); // // test Append, Prepend, and enum plugin descriptor using same type def // IAAFPluginDescriptorSP pd1; checkResult (defs.cdPluginDef()-> CreateInstance (IID_IAAFPluginDef, (IUnknown **)&pd1)); checkResult (pd1->Initialize (kTestPluginDescID1, L"PluginDesc1", L"Plugin Descriptor 1 description")); checkResult(pd1->SetDefinitionObjectID(kTestPluginDescID1)); checkResult (pDictionary->RegisterPluginDef (pd1)); IAAFPluginDescriptorSP pd2; checkResult (defs.cdPluginDef()-> CreateInstance (IID_IAAFPluginDef, (IUnknown **)&pd2)); checkResult (pd2->Initialize (kTestPluginDescID2, L"PluginDesc2", L"Plugin Descriptor 2 description")); checkResult(pd2->SetDefinitionObjectID(kTestPluginDescID2)); checkResult (pDictionary->RegisterPluginDef (pd2)); IAAFPluginDescriptorSP pd3; checkResult (defs.cdPluginDef()-> CreateInstance (IID_IAAFPluginDef, (IUnknown **)&pd3)); checkResult (pd3->Initialize (kTestPluginDescID3, L"PluginDesc3", L"Plugin Descriptor 3 description")); checkResult(pd3->SetDefinitionObjectID(kTestPluginDescID3)); checkResult (pDictionary->RegisterPluginDef (pd3)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pDef) pDef->Release(); if (pContainerDef) pContainerDef->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; IAAFSequence *pSequence = 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 number of mobs to force creation of the content storage. // This is temporary as the content storage should be created by // the call to OpenNewModify above. aafNumSlots_t n; checkResult(pHeader->CountMobs(kAAFAllMob, &n)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); // Create a sequence withou attaching it to the file. checkResult(CreateAAFSequence(pDictionary, &pSequence)); // Test the enumeration methods. checkResult(TestEnumerator(pSequence)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pSequence) pSequence->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar * pFileName) { IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFMob* pMob = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; IAAFBWFImportDescriptor* pBWFImportDesc = NULL; IEnumAAFRIFFChunks* pEnum = NULL; IAAFRIFFChunk* pRIFFChunk = NULL; IAAFRIFFChunk* pRIFFChunkTest = NULL; IEnumAAFMobs* pMobIter = NULL; aafUInt32 numData, bytesRead, com, testNum; aafLength_t testRIFFLen; aafNumSlots_t numMobs; char Value[sizeof(RIFFChunksmiley)]; char Value2[sizeof(RIFFChunkfrowney)]; HRESULT hr = AAFRESULT_SUCCESS; wchar_t testString[256]; checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); checkResult( pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create a fake RIFFChunk to test RemoveUnknownBWFChunks. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk, (IUnknown **)&pRIFFChunkTest)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); if (1 == numMobs ) { checkResult(pHeader->GetMobs(NULL, &pMobIter)); checkResult(pMobIter->NextOne(&pMob)); checkResult(pMob->QueryInterface(IID_IAAFSourceMob, (void **)&pSourceMob)); // Back into testing mode checkResult(pSourceMob->GetEssenceDescriptor(&pEssDesc)); checkResult( pEssDesc->QueryInterface( IID_IAAFBWFImportDescriptor, (void**)&pBWFImportDesc )); checkResult(pBWFImportDesc->GetFileSecurityReport(&testNum)); checkExpression(testNum==TEST_FileSecurityReport, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetFileSecurityWave(&testNum)); checkExpression(testNum==TEST_FileSecurityWave, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetCodingHistory(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_CodingHistory) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetBasicData(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_BasicData) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetStartOfModulation(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_StartOfModulation) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetQualityEvent(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_QualityEvent) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetEndOfModulation(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_EndOfModulation) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetQualityParameter(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_QualityParameter) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetOperatorComment(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_OperatorComment) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetCueSheet(testString, sizeof(testString))); checkExpression(wcscmp(testString, TEST_CueSheet) == 0, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->CountUnknownBWFChunks(&numData)); checkExpression(2 == numData, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->GetUnknownBWFChunks(&pEnum)); for(com = 0; com < numData; com++) { checkResult(pEnum->NextOne(&pRIFFChunk)); pRIFFChunk->GetLength(&testRIFFLen); checkExpression(testRIFFLen!=chunkLength /*huh?*/, AAFRESULT_TEST_FAILED); checkResult(pRIFFChunk->GetLength(&testRIFFLen)); pRIFFChunk->GetChunkID(&testNum); if (testNum==1){ checkExpression(sizeof(RIFFChunksmiley) == testRIFFLen, AAFRESULT_TEST_FAILED); checkResult(pRIFFChunk->Read( sizeof(Value), (unsigned char *)Value, &bytesRead)); checkExpression(memcmp(Value, RIFFChunksmiley, sizeof(RIFFChunksmiley)) == 0, AAFRESULT_TEST_FAILED); } else if (testNum==2){ checkExpression(sizeof(RIFFChunkfrowney) == testRIFFLen, AAFRESULT_TEST_FAILED); checkResult(pRIFFChunk->Read( sizeof(Value2), (unsigned char *)Value2, &bytesRead)); checkExpression(memcmp(Value2, RIFFChunkfrowney, sizeof(RIFFChunkfrowney)) == 0, AAFRESULT_TEST_FAILED); } pRIFFChunk->Release(); pRIFFChunk = NULL; } checkResult(pEnum->Reset()); checkResult(pEnum->NextOne(&pRIFFChunk)); checkExpression((pBWFImportDesc->RemoveUnknownBWFChunkAt(2))==AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED); checkResult(pBWFImportDesc->RemoveUnknownBWFChunkAt(0)); checkResult(pBWFImportDesc->CountUnknownBWFChunks(&numData)); checkExpression(1 == numData, AAFRESULT_TEST_FAILED); pRIFFChunk->Release(); pRIFFChunk = NULL; pEnum->Release(); pEnum = NULL; pBWFImportDesc->Release(); pBWFImportDesc = NULL; pEssDesc->Release(); pEssDesc = NULL; pSourceMob->Release(); pSourceMob = NULL; pMobIter->Release(); pMobIter = NULL; } pRIFFChunkTest->Release(); pRIFFChunkTest = NULL; pMob->Release(); pMob = NULL; pHeader->Release(); pHeader = NULL; pDictionary->Release(); pDictionary = NULL; pFile->Close(); pFile->Release(); pFile = NULL; return hr; }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFOperationDefs *pEffectEnum = NULL; IEnumAAFOperationDefs *pDegradeEnum = NULL; IEnumAAFParameterDefs *pParmDefEnum = NULL; IAAFOperationDef *pOperationDef = NULL; IAAFParameterDef *pParmDef = NULL; IAAFDefObject* pDefObject = NULL; bool bFileOpen = false; IAAFDataDefSP pReadDataDef; aafBool readIsTimeWarp; aafInt32 checkNumInputs; aafUInt32 checkBypass; HRESULT hr = S_OK; wchar_t checkName[256]; aafUID_t checkCat; aafBool bResult = kAAFFalse; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(pDictionary->GetOperationDefs(&pEffectEnum)); checkResult(pEffectEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->GetDataDef(&pReadDataDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[0]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[0]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; checkResult(pReadDataDef->IsDataDefOf(defs.ddkAAFPicture(), &bResult)); checkExpression(bResult == kAAFTrue, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->IsTimeWarp (&readIsTimeWarp)); checkExpression(readIsTimeWarp == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetCategory (&checkCat)); checkExpression(memcmp(&checkCat, &TEST_CATEGORY, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetBypass (&checkBypass)); checkExpression(checkBypass == TEST_BYPASS, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetNumberInputs (&checkNumInputs)); checkExpression(checkNumInputs == TEST_NUM_INPUTS, AAFRESULT_TEST_FAILED); checkResult(pOperationDef->GetParameterDefs (&pParmDefEnum)); checkResult(pParmDefEnum->NextOne (&pParmDef)); checkResult(pParmDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, TEST_PARAM_NAME) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, TEST_PARAM_DESC) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; checkResult(pOperationDef->GetDegradeToOperations (&pDegradeEnum)); pOperationDef->Release(); pOperationDef = NULL; // Check for prepended one first checkResult(pDegradeEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[2]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[2]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; pOperationDef->Release(); pOperationDef = NULL; // Check for appended one second checkResult(pDegradeEnum->NextOne (&pOperationDef)); checkResult(pOperationDef->QueryInterface(IID_IAAFDefObject, (void **) &pDefObject)); checkResult(pDefObject->GetName (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectNames[1]) == 0, AAFRESULT_TEST_FAILED); checkResult(pDefObject->GetDescription (checkName, sizeof(checkName))); checkExpression(wcscmp(checkName, effectDesc[1]) == 0, AAFRESULT_TEST_FAILED); pDefObject->Release(); pDefObject = NULL; pOperationDef->Release(); pOperationDef = NULL; } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pHeader) pHeader->Release(); if (pDictionary) pDictionary->Release(); if (pEffectEnum) pEffectEnum->Release(); if (pDegradeEnum) pDegradeEnum->Release(); if (pParmDefEnum) pParmDefEnum->Release(); if (pOperationDef) pOperationDef->Release(); if (pDefObject) pDefObject->Release(); if (pParmDef) pParmDef->Release(); if (pFile) { // Close file if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; 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; 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 bool testRestore(const wchar_t* fileName) { bool passed = true; IAAFFile* pFile = 0; IAAFHeader* pHeader = 0; IAAFDictionary* pDictionary = 0; IAAFContentStorage* pStorage = 0; IEnumAAFMobs* pMobs = 0; IAAFMob* pMob = 0; try { pFile = openFileForReading(fileName); } catch (...) { return false; } try { // get the Mob containing the test data checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pHeader->GetContentStorage(&pStorage)); aafSearchCrit_t searchCrit; searchCrit.searchTag = kAAFByMobKind; searchCrit.tags.mobKind = kAAFAllMob; checkResult(pStorage->GetMobs(&searchCrit, &pMobs)); checkResult(pMobs->NextOne(&pMob)); IAAFObject* pObject = 0; IAAFClassDef* pClassDef = 0; IAAFPropertyDef* pPropertyDef = 0; IAAFPropertyValue* pPropertyValue = 0; IAAFTypeDef* pType = 0; IAAFTypeDefEnum* pEnumType = 0; try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 5; const wchar_t* testName = L"VersionPrivateBuild"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 1 : "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 2 : "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 4 : "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 8 : "); const aafUID_t propId = {0x40000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); } catch (...) { passed = false; } // cleanup release(pMob); release(pMobs); release(pStorage); release(pDictionary); release(pHeader); checkResult(pFile->Close()); release(pFile); report(passed); return passed; }
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 bool testRestore(const wchar_t* fileName) { bool passed = true; IAAFFile* pFile = 0; IAAFHeader* pHeader = 0; IAAFDictionary* pDictionary = 0; IAAFContentStorage* pStorage = 0; IEnumAAFMobs* pMobs = 0; IAAFMob* pMob = 0; try { pFile = openFileForReading(fileName); } catch (...) { return false; } try { // get the Mob containing the test data checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pHeader->GetContentStorage(&pStorage)); aafSearchCrit_t searchCrit; searchCrit.searchTag = kAAFByMobKind; searchCrit.tags.mobKind = kAAFAllMob; checkResult(pStorage->GetMobs(&searchCrit, &pMobs)); checkResult(pMobs->NextOne(&pMob)); IAAFObject* pObject = 0; IAAFClassDef* pClassDef = 0; IAAFPropertyDef* pPropertyDef = 0; IAAFPropertyValue* pPropertyValue = 0; IAAFTypeDef* pType = 0; IAAFTypeDefCharacter* pCharacterType = 0; // test simple try { printf(" * Simple: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; wchar_t testCharacter = L'A'; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType)); aafCharacter value; checkResult(pCharacterType->GetCharacter(pPropertyValue, &value)); if (value == testCharacter) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pCharacterType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test XML escaped try { printf(" * XML escaped: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; wchar_t testCharacter = L'\r'; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType)); aafCharacter value; checkResult(pCharacterType->GetCharacter(pPropertyValue, &value)); if (value == testCharacter) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pCharacterType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test AAF escaped try { printf(" * AAF escaped: "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; wchar_t testCharacter = 0x0; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType)); aafCharacter value; checkResult(pCharacterType->GetCharacter(pPropertyValue, &value)); if (value == testCharacter) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pCharacterType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test AAF escaped of invalid UNICODE character try { printf(" * AAF escaped invalid Unicode character: "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; wchar_t testCharacter = 0xFFFF; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType)); aafCharacter value; checkResult(pCharacterType->GetCharacter(pPropertyValue, &value)); if (value == testCharacter) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pCharacterType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); } catch (...) { passed = false; } // cleanup release(pMob); release(pMobs); release(pStorage); release(pDictionary); release(pHeader); checkResult(pFile->Close()); release(pFile); report(passed); return passed; }
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(const aafWChar * pFileName, testDataFile_t *dataFile, testType_t /* testType */) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFClassDef* pKLVDataCD=NULL; IAAFClassDef* pCommentMarkerCD=NULL; IAAFTypeDef* pUnknownBaseType=NULL; IAAFTypeDef* pInt32BaseType=NULL; // IAAFTypeDef* pASCIIStringBaseType=NULL; IAAFKLVData* pKLVData=NULL; IAAFEssenceAccess* pEssenceAccess = NULL; IAAFEssenceMultiAccess* pMultiEssence = NULL; IAAFEssenceFormat* pFormat = NULL; IAAFEssenceFormat* format = NULL; IAAFLocator* pLocator = NULL; IAAFClassDef* pCDMasterMob = 0; IAAFClassDef *pCDNetworkLocator = 0; IAAFDataDef *pDdefSound = 0; IAAFDataDef* pDDefSceneDesc=0; IAAFEventMobSlot *pEventSlot=0; IAAFMobSlot *pSlot=0; IAAFSequence *pSeqSceneDesc=0; IAAFSegment *pSegment=0; IAAFEvent *pEventSceneDesc=0; IAAFComponent *pComp=0; HRESULT hr = AAFRESULT_SUCCESS; // !!!Previous revisions of this file contained variables here required to handle external essence aafMobID_t masterMobID; aafProductIdentification_t ProductInfo; aafRational_t editRate = {30000, 1001}; aafRational_t sampleRate = {44100, 1}; aafRational_t eventTimebase = {30000, 1001}; aafPosition_t position=0; FILE* pWavFile = NULL; unsigned char dataBuff[4096], *dataPtr; // aafUInt32 bytesWritten; aafUInt32 dataOffset, dataLen; aafUInt16 bitsPerSample, numCh; aafInt32 n, numSpecifiers; aafUID_t essenceFormatCode, testContainer; aafUInt32 samplesWritten, bytesWritten; // delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), pFileName); remove(chFileName); if(dataFile != NULL) { // delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), dataFile->dataFilename); remove(chFileName); } aafProductVersion_t v; v.major = 1; v.minor = 0; v.tertiary = 0; v.patchLevel = 0; v.type = kAAFVersionUnknown; ProductInfo.companyName = companyName; ProductInfo.productName = productName; ProductInfo.productVersion = &v; ProductInfo.productVersionString = NULL; ProductInfo.productID = NIL_UID; ProductInfo.platform = NULL; check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile)); check(pFile->GetHeader(&pHeader)); // test // Get the AAF Dictionary so that we can create valid AAF objects. check(pHeader->GetDictionary(&pDictionary)); check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &pCDMasterMob)); check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator, &pCDNetworkLocator)); check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pDdefSound)); // !!!Previous revisions of this file contained code here required to handle external essence // Get a Master MOB Interface check(pCDMasterMob-> CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pMasterMob)); // Get a Mob interface and set its variables. check(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID(&masterMobID)); check(pMob->SetName(L"A Master Mob")); // Add it to the file check(pHeader->AddMob(pMob)); // !!!Previous revisions of this file contained code here required to handle external essence if(dataFile != NULL) { // Make a locator, and attach it to the EssenceDescriptor check(pCDNetworkLocator-> CreateInstance(IID_IAAFLocator, (IUnknown **)&pLocator)); check(pLocator->SetPath (dataFile->dataFilename)); testContainer = dataFile->dataFormat; } else { pLocator = NULL; testContainer = ContainerAAF; } // open the Essence file to be included in this AAF file("Laser.wav") pWavFile = fopen("Laser.wav", "r"); if (pWavFile) { // read in the essence data fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile); check(loadWAVEHeader(dataBuff, &bitsPerSample, &numCh, &sampleRate, &dataOffset, &dataLen)); dataPtr = dataBuff + dataOffset; // now create the Essence data file check(pMasterMob->CreateEssence(1, // Slot ID pDdefSound, // MediaKind kAAFCodecWAVE, // codecID editRate, // edit rate sampleRate, // sample rate kAAFCompressionDisable, pLocator, // In current file testContainer, // In AAF Format &pEssenceAccess));// Compress disabled check(pEssenceAccess->GetFileFormatParameterList (&format)); check(format->NumFormatSpecifiers (&numSpecifiers)); for(n = 0; n < numSpecifiers; n++) { check(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL)); } format->Release(); format = NULL; // Tell the AAFEssenceAccess what the format is. check(pEssenceAccess->GetEmptyFileFormat (&pFormat)); check(pFormat->NumFormatSpecifiers (&numSpecifiers)); aafInt32 sampleSize = bitsPerSample; check(pFormat->AddFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleSize), (aafUInt8 *)&sampleSize)); check(pEssenceAccess->PutFileFormat (pFormat)); pFormat->Release(); pFormat = NULL; // write out the data check(pEssenceAccess->WriteSamples( dataLen,//!!! hardcoded bytes/sample ==1// Number of Samples sizeof(dataBuff), // buffer size dataPtr, // THE data &samplesWritten, &bytesWritten)); // close essence data file fclose(pWavFile); pWavFile = NULL; // Finish writing the destination check(pEssenceAccess->CompleteWrite()); pEssenceAccess->Release(); pEssenceAccess=NULL; // First register DataDef for SceneDescription // Is SceneDescription in dictionary already // Try using Timecode for MC compat hr = pDictionary->LookupDataDef(kAAFDataDef_Timecode, &pDDefSceneDesc); // hr = pDictionary->LookupDataDef(kAAFDataDef_SceneDescription, // &pDDefSceneDesc); if (hr != AAFRESULT_SUCCESS) { check(pDictionary->CreateInstance(AUID_AAFDataDef,IID_IAAFDataDef, (IUnknown **)&pDDefSceneDesc)); check(pDDefSceneDesc->Initialize(kAAFDataDef_SceneDescription, L"SceneDescEvent",L"DataDefinition for Scene Description Events")); check(pDictionary->RegisterDataDef(pDDefSceneDesc)); } // Add EventSlot to MasterMob // Create Slot check(pDictionary->CreateInstance(AUID_AAFEventMobSlot, IID_IAAFEventMobSlot, (IUnknown **)&pEventSlot)); check(pEventSlot->SetEditRate(&eventTimebase)); // Get the mob slot interface so that we can add the event segment. check(pEventSlot->QueryInterface(IID_IAAFMobSlot, (void **)&pSlot)); pEventSlot->Release(); pEventSlot = NULL; aafSlotID_t eventSlotID=5; check(pSlot->SetSlotID(eventSlotID)); check(pSlot->SetName(L"SceneDescriptions")); // Set up Sequence for Scene Descriptors check(pDictionary->CreateInstance(AUID_AAFSequence,IID_IAAFSequence, (IUnknown **)&pSeqSceneDesc)); check(pSeqSceneDesc->Initialize(pDDefSceneDesc)); // Create first Comment Marker check(pDictionary->LookupClassDef(AUID_AAFCommentMarker, &pCommentMarkerCD)); check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent, (IUnknown **)&pEventSceneDesc)); position=0; check(pEventSceneDesc->SetPosition(position)); check(pEventSceneDesc->SetComment(L"Racers heading up the hill")); check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp)); check(pComp->SetDataDef(pDDefSceneDesc)); // Add it to the sequence check(pSeqSceneDesc->AppendComponent(pComp)); pComp->Release(); pComp = NULL; pEventSceneDesc->Release(); pEventSceneDesc=NULL; // Create second Comment Marker check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent, (IUnknown **)&pEventSceneDesc)); position=100; check(pEventSceneDesc->SetPosition(position)); check(pEventSceneDesc->SetComment(L"Racer pulls away from crowd")); check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp)); check(pComp->SetDataDef(pDDefSceneDesc)); // Add it to the sequence check(pSeqSceneDesc->AppendComponent(pComp)); pComp->Release(); pComp = NULL; pEventSceneDesc->Release(); pEventSceneDesc=NULL; check(pSeqSceneDesc->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); // Create third Comment Marker check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent, (IUnknown **)&pEventSceneDesc)); position=250; check(pEventSceneDesc->SetPosition(position)); check(pEventSceneDesc->SetComment(L"Racer passes finish line")); check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp)); check(pComp->SetDataDef(pDDefSceneDesc)); // Add it to the sequence check(pSeqSceneDesc->AppendComponent(pComp)); pComp->Release(); pComp = NULL; pEventSceneDesc->Release(); pEventSceneDesc=NULL; // Add the event sequence to the event mob slot // Sequence must have at least one component to ensure event mob slot is valid check(pSlot->SetSegment(pSegment)); pSegment->Release(); pSegment = NULL; // Append the event slot to the Master Mob check(pMob->AppendSlot(pSlot)); // Add the KLV data to the Master Mob // Register the two KLVKeys check(pDictionary->LookupTypeDef(kAAFTypeID_UInt8Array, &pUnknownBaseType)); check(pDictionary->RegisterKLVDataKey(KLVKey_BinaryBlob1, pUnknownBaseType)); check(pDictionary->LookupTypeDef(kAAFTypeID_Int32, &pInt32BaseType)); check(pDictionary->RegisterKLVDataKey(KLVKey_Int32_1, pInt32BaseType)); // Next define new ASCII string data def // check(pDictionary->RegisterKLVDataKey(KLVKey_ASCIIString1, // pASCIIStringBaseType)); // Get the KLVData ClassDefinition check(pDictionary->LookupClassDef(AUID_AAFKLVData, &pKLVDataCD)); // Create KLVData and append it to Mob check(pKLVDataCD->CreateInstance(IID_IAAFKLVData, (IUnknown **)&pKLVData)); check(pKLVData->Initialize(KLVKey_BinaryBlob1, sizeof(blobData), (aafUInt8 *)blobData)); check(pMob->AppendKLVData(pKLVData)); pKLVData->Release(); pKLVData=NULL; // Create KLVData and append it to Mob check(pKLVDataCD->CreateInstance(IID_IAAFKLVData, (IUnknown **)&pKLVData)); check(pKLVData->Initialize(KLVKey_Int32_1, sizeof(int32Data), (aafUInt8 *)&int32Data)); check(pMob->AppendKLVData(pKLVData)); pKLVData->Release(); pKLVData=NULL; } else { printf("***Failed to open Wave file Laser.wav\n"); } // Release all unnecesary interfaces if (pInt32BaseType) pInt32BaseType->Release(); pInt32BaseType=NULL; if (pUnknownBaseType) pUnknownBaseType->Release(); pUnknownBaseType=NULL; if (pKLVDataCD) pKLVDataCD->Release(); pKLVDataCD=NULL; if (pCommentMarkerCD) pCommentMarkerCD->Release(); pCommentMarkerCD=NULL; if(pComp) pComp->Release(); pComp=NULL; if(pEventSceneDesc) pEventSceneDesc->Release(); pEventSceneDesc=0; if(pSegment) pSegment->Release(); pSegment=NULL; if(pSeqSceneDesc) pSeqSceneDesc->Release(); pSeqSceneDesc=NULL; if(pSlot) pSlot->Release(); pSlot=NULL; if(pEventSlot) pEventSlot->Release(); pEventSlot=NULL; if(pDDefSceneDesc) pDDefSceneDesc->Release(); pDDefSceneDesc=NULL; if(pMasterMob) pMasterMob->Release(); pMasterMob = NULL; if(pMob) pMob->Release(); pMob = NULL; if(pDictionary) pDictionary->Release(); pDictionary = NULL; if(pHeader) pHeader->Release(); pHeader = NULL; //!!!DebugOnly pFile->Save(); pFile->Close(); pFile->Release(); pFile = NULL; if (pEssenceAccess) { pEssenceAccess->Release(); pEssenceAccess= NULL; } cleanup: // Cleanup and return if(pFormat) pFormat->Release(); if(format) format->Release(); if(pLocator) pLocator->Release(); if (pWavFile) fclose(pWavFile); if (pEssenceAccess) pEssenceAccess->Release(); if (pMultiEssence) pMultiEssence->Release(); if (pMasterMob) pMasterMob->Release(); if (pMob) pMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pCDMasterMob) { pCDMasterMob->Release(); pCDMasterMob = 0; } if (pCDNetworkLocator) { pCDNetworkLocator->Release(); pCDNetworkLocator = 0; } if (pDdefSound) { pDdefSound->Release (); pDdefSound = 0; } if (pFile) { pFile->Close(); pFile->Release(); } return moduleErrorTmp; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFParameterDef* pParamDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; aafUID_t testParmID = kParmID; aafInt32 index; IAAFOperationDef *pOperationDef = NULL, *defResults[3] = { NULL, NULL, NULL }; /* long test; */ try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pParamDef->Initialize (testParmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational())); checkResult(pDictionary->RegisterParameterDef(pParamDef)); for(index = 0; index < 3; index++) { checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(pOperationDef->Initialize (effectID[index], effectNames[index], effectDesc[index])); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); defResults[index] = pOperationDef; pOperationDef = NULL; } checkResult(defResults[1]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[2]->AppendDegradeToOperation (defResults[2])); checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[0]->PrependDegradeToOperation (defResults[2])); // Add an extra one to delete for the test //!!! checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(3 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->RemoveDegradeToOperationAt (2)); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); for(index = 0; index < 3; index++) { defResults[index]->Release(); defResults[index] = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pOperationDef) pOperationDef->Release(); if (pParamDef) pParamDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT TestPropertyValue ( testMode_t mode, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { // HRESULT hr = E_FAIL; long hr = E_FAIL; const size_t fileNameBufLen = 128; aafWChar testFileName[ fileNameBufLen ] = L""; GenerateTestFileName( productID.productName, fileKind, fileNameBufLen, testFileName ); IAAFFile* pFile = NULL; if(mode == kAAFUnitTestReadWrite) { RemoveTestFile (testFileName); checkResult (CreateTestFile( testFileName, fileKind, rawStorageType, productID, &pFile )); assert (pFile); } else { checkResult (AAFFileOpenExistingRead(testFileName, 0, &pFile)); assert (pFile); } IAAFHeader * pHeader = NULL; hr = pFile->GetHeader (&pHeader); if (! SUCCEEDED (hr)) return hr; assert (pHeader); IAAFDictionary * pDict = NULL; hr = pHeader->GetDictionary (&pDict); if (! SUCCEEDED (hr)) return hr; assert (pDict); CAAFBuiltinDefs defs (pDict); // Let's try to do something interesting with a type definition IAAFTypeDefInt * pTypeDef = NULL; hr = defs.tdInt32()->QueryInterface (IID_IAAFTypeDefInt, (void **) &pTypeDef); if (! SUCCEEDED (hr)) return hr; assert (pTypeDef); if(mode == kAAFUnitTestReadWrite) { // Now attempt to create invalid property values; check for errors. const aafInt32 forty_two = 42; IAAFPropertyValue * pv = NULL; // This is what a correct one would look like; we're not ready for that yet: // hr = pTypeDef->CreateValue (&forty_two, 4, &pv); // set this to -1 to see if it gets modified pv = (IAAFPropertyValue *) (-1); // Try null pVal hr = pTypeDef->CreateValue (NULL, 4, &pv); if (AAFRESULT_NULL_PARAM != hr) return AAFRESULT_TEST_FAILED; if ((IAAFPropertyValue *)(-1) != pv) return AAFRESULT_TEST_FAILED; // Try valSize too large hr = pTypeDef->CreateValue ((aafMemPtr_t) &forty_two, 8, &pv); if (AAFRESULT_BAD_SIZE != hr) return AAFRESULT_TEST_FAILED; if ((IAAFPropertyValue *)(-1) != pv) return AAFRESULT_TEST_FAILED; // Now try correct one pv = NULL; hr = pTypeDef->CreateValue ((aafMemPtr_t) &forty_two, 4, &pv); if (! SUCCEEDED (hr)) return hr; if (! pv) return AAFRESULT_TEST_FAILED; // That one worked; let's try one with a smaller init size (should // also work) pv->Release(); pv = NULL; const aafInt16 fifty_seven = 57; hr = pTypeDef->CreateValue ((aafMemPtr_t) &fifty_seven, 2, &pv); if (! SUCCEEDED (hr)) return hr; if (! pv) return AAFRESULT_TEST_FAILED; // cool. Now we should have a good property value whose value is 57. // check GetType() for error condition hr = pv->GetType (NULL); if (AAFRESULT_NULL_PARAM != hr) return AAFRESULT_TEST_FAILED; // this GetType() call should work, and return the original type def. IAAFTypeDef * propType = NULL; hr = pv->GetType (&propType); if (! SUCCEEDED (hr)) return hr; if (! propType) return AAFRESULT_TEST_FAILED; // Convert both to IUnknown for comparison IUnknown * pPropUnknown = NULL; IUnknown * pTypeDefUnknown = NULL; hr = propType->QueryInterface(IID_IUnknown, (void **)&pPropUnknown); if (! SUCCEEDED (hr)) return hr; assert (pPropUnknown); hr = pTypeDef->QueryInterface(IID_IUnknown, (void **)&pTypeDefUnknown); if (! SUCCEEDED (hr)) return hr; assert (pTypeDefUnknown); if (pPropUnknown != pTypeDefUnknown) return AAFRESULT_TEST_FAILED; // Test IsDefinedType () // (Currently only returns true.) aafBool b = kAAFFalse; hr = pv->IsDefinedType (&b); if (! SUCCEEDED (hr)) return hr; if (kAAFTrue != b) return AAFRESULT_TEST_FAILED; pTypeDefUnknown->Release(); pPropUnknown->Release(); pTypeDef->Release(); propType->Release(); pv->Release(); pDict->Release(); pHeader->Release(); hr = pFile->Save(); } if (! SUCCEEDED (hr)) return hr; hr = pFile->Close(); if (! SUCCEEDED (hr)) return hr; pFile->Release(); return AAFRESULT_SUCCESS; }
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; }
extern "C" HRESULT CAAFPluginManager_test( testMode_t mode, aafUID_t fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_t productID) { HRESULT hr = AAFRESULT_SUCCESS; IEnumAAFLoadedPlugins *pEnum = NULL; IAAFPluginManager *pMgr = NULL; aafUID_t testUID; IAAFFile* pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFDefObject *pPluginDef = NULL; IAAFPlugin *plugin = NULL; const size_t fileNameBufLen = 128; aafWChar pFileName[ fileNameBufLen ] = L""; GenerateTestFileName( productID.productName, fileKind, fileNameBufLen, pFileName ); try { if(mode != kAAFUnitTestReadWrite) return AAFRESULT_SUCCESS; // Can't run this test read-only // Remove the previous test file if any. RemoveTestFile(pFileName); checkResult(AAFGetPluginManager (&pMgr)); // 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)); checkResult(pMgr->EnumLoadedPlugins (AUID_AAFCodecDef, &pEnum)); while(pEnum->NextOne (&testUID) == AAFRESULT_SUCCESS) { checkResult(pMgr->CreatePluginDefinition (testUID, pDictionary, &pPluginDef)); pPluginDef->Release(); pPluginDef = NULL; } hr = AAFRESULT_SUCCESS; checkResult(pMgr->CreateInstance(CLSID_AAFBasicInterp, NULL, IID_IAAFPlugin, (void **)&plugin)); } catch (HRESULT& rhr) { hr = rhr; } if (plugin) plugin->Release(); if (pEnum) pEnum->Release(); if (pMgr) pMgr->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } // JeffB: RegisterPluginDirectory and RegisterPluginFile have their implementations tested // by the RegisterStandard() function, and will require a special local plugin to test. Therefore // I'm pushing the test off post 1.0 and declaring success here. // When all of the functionality of this class is tested, we can return success. // When a method and its unit test have been implemented, remove it from the list. // if (SUCCEEDED(hr)) // { // cout << "The following IAAFPluginManager tests have not been implemented:" << endl; ////!!! cout << " RegisterPluginDirectory" << endl; ////!!! cout << " RegisterPluginFile" << endl; //// cout << " EnumLoadedPlugins" << endl; // cout << " CreateInstance" << endl; // hr = AAFRESULT_TEST_PARTIAL_SUCCESS; // } return hr; }
static HRESULT ReadAAFFile(const aafWChar * pFileName, testType_t testType) { IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFEssenceAccess* pEssenceAccess = NULL; IAAFEssenceMultiAccess* pMultiEssence = NULL; IAAFEssenceFormat *fmtTemplate = NULL; IEnumAAFMobs* pMobIter = NULL; IAAFMob* pMob = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFEssenceFormat* pFormat = NULL; aafNumSlots_t numMobs, numSlots; aafSearchCrit_t criteria; aafRational_t readSampleRate; aafMobID_t mobID; aafWChar namebuf[1204]; unsigned char AAFDataBuf[4096]; aafUInt32 AAFBytesRead, samplesRead; FILE* pWavFile = NULL; unsigned char WAVDataBuf[4096], *dataPtr; size_t WAVBytesRead; aafUInt32 dataOffset, dataLen; aafUInt16 bitsPerSample, numCh; check(AAFFileOpenExistingRead ( pFileName, 0, &pFile)); check(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. check(pHeader->GetDictionary(&pDictionary)); // Here we check on the number of mobs in the file. // Get the number of master mobs in the file (should be one) check(pHeader->CountMobs(kAAFMasterMob, &numMobs)); // ** causes leak if (1 == numMobs ) { printf("Found %d Master Mobs\n", numMobs); criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFMasterMob; check(pHeader->GetMobs(&criteria, &pMobIter)); while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)) { char mobIDstr[256]; char mobName[256]; check(pMob->GetMobID (&mobID)); check(pMob->GetName (namebuf, sizeof(namebuf))); convert(mobName, sizeof(mobName), namebuf); MobIDtoString(mobID, mobIDstr); printf(" MasterMob Name = '%s'\n", mobName); printf(" (mobID %s)\n", mobIDstr); // Make sure we have two slots check(pMob->CountSlots(&numSlots)); if (2 == numSlots) { // The essence data is in SlotID 1 // Get a Master Mob interface check(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob)); // Open the Essence Data check(pMasterMob->OpenEssence( 1, // SlotID 1 NULL, // mediaCriteria (Don't care) kAAFMediaOpenReadOnly, // Open mode kAAFCompressionDisable,// Compress disabled &pEssenceAccess)); // Open and read the Wave file (for comparison) pWavFile = fopen("Laser.wav", "r"); if (pWavFile) { // read in the essence data WAVBytesRead = fread(WAVDataBuf, sizeof(unsigned char), sizeof(WAVDataBuf), pWavFile); fclose(pWavFile); pWavFile = NULL; check(loadWAVEHeader(WAVDataBuf, &bitsPerSample, &numCh, &readSampleRate, &dataOffset, &dataLen)); dataPtr = WAVDataBuf + dataOffset; aafUInt32 sampleBits; aafInt32 bytesRead; check(pEssenceAccess->GetEmptyFileFormat (&fmtTemplate)); check(fmtTemplate->AddFormatSpecifier (kAAFAudioSampleBits, 0, NULL)); check(pEssenceAccess->GetFileFormat (fmtTemplate, &pFormat)); fmtTemplate->Release(); fmtTemplate = NULL; check(pFormat->GetFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleBits), (aafDataBuffer_t)&sampleBits, &bytesRead)); pFormat->Release(); pFormat = NULL; if(sampleBits != bitsPerSample) { printf("***Wrong sample size read ( was %d , should be %d)\n", sampleBits, bitsPerSample); } // Read the Data from the AAF file if(testType == testStandardCalls) { check(pEssenceAccess->ReadSamples( dataLen, //!!! Hardcoded // Number of Samples sizeof(AAFDataBuf), // Maximum buffer size AAFDataBuf, // Buffer for the data &samplesRead, // Actual number of samples read &AAFBytesRead)); // Actual number of bytes read } else if(testType == testMultiCalls) { aafmMultiXfer_t xfer; aafmMultiResult_t result; check(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence)); xfer.numSamples = dataLen; //!!! Hardcoded // Number of Samples xfer.buflen = sizeof(AAFDataBuf); xfer.buffer = AAFDataBuf; result.bytesXfered = 0; check(pMultiEssence->ReadMultiSamples(1, &xfer, &result)); samplesRead = result.samplesXfered; AAFBytesRead = result.bytesXfered; pMultiEssence->Release(); pMultiEssence = NULL; } // Now compare the data read from the AAF file to the actual WAV file if (dataLen != AAFBytesRead) { printf("***Wrong number of bytes read (was %u , should be %zu)\n", AAFBytesRead, WAVBytesRead); } if (memcmp( dataPtr, AAFDataBuf, dataLen) != 0) { printf("*** Data Read is different than the data in the WAV file ***\n"); } } else { printf("***Failed to open Wave file Laser.wav for comparison\n"); } } else { printf("***Wrong number of slots in the Master Mob (was %d should be %d)\n", numSlots, 2); } if (pMasterMob) { pMasterMob->Release(); pMasterMob = NULL; } pMob->Release(); pMob = NULL; if (pEssenceAccess) { pEssenceAccess->Release(); pEssenceAccess = NULL; } } // while pMobIter->NextOne pMobIter->Release(); pMobIter = NULL; } else { printf("***Wrong number of Master mobs in the file (was %d should be %d)\n", numMobs, 1); } printf("--------\n"); cleanup: // Cleanup and return if (pWavFile) fclose(pWavFile); if (pMultiEssence) pMultiEssence->Release(); pMultiEssence=NULL; if(fmtTemplate) { fmtTemplate->Release(); fmtTemplate = NULL; } if (pEssenceAccess) { pEssenceAccess->Release(); pEssenceAccess = NULL; } if (pDictionary) pDictionary->Release(); pDictionary=NULL; if (pHeader) pHeader->Release(); pHeader=NULL; if (pMobIter) pMobIter->Release(); pMobIter=NULL; if (pFormat) pFormat->Release(); pFormat=NULL; if (pFile) { pFile->Close(); pFile->Release(); pFile=NULL; } return moduleErrorTmp; }
static void ReadAAFFile(aafWChar * pFileName) { HRESULT hr = S_OK; IAAFFile * pFile = NULL; hr = AAFFileOpenExistingRead (pFileName, AAF_FILE_MODE_LAZY_LOADING, &pFile); if (SUCCEEDED(hr)) { IAAFHeader * pHeader = NULL; hr = pFile->GetHeader(&pHeader); check(hr); // display error message if (SUCCEEDED(hr)) { IAAFIdentification * pIdent = NULL; hr = pHeader->GetLastIdentification(&pIdent); check(hr); // display error message if (SUCCEEDED(hr)) { printIdentification(pIdent); pIdent->Release(); pIdent = NULL; // count Mobs aafNumSlots_t n; hr = pHeader->CountMobs(kAAFAllMob, &n); check(hr); printf("\nNumber of Mobs = %d\n", n); // Header::Version, Header::ObjectModelVersion aafVersionType_t version = {0}; check(pHeader->GetFileRevision (&version) ); printf("\nHeader::Version = %d.%d\n", version.major, version.minor); aafFileRev_t fileVersion = kAAFRev1; check(pFile->GetRevision (&fileVersion) ); printf("\nHeader::ObjectModelVersion = %d", fileVersion); if (fileVersion == kAAFRev1) printf(" (recognized as kAAFRev1)\n"); else if (fileVersion == kAAFRev2) printf(" (recognized as kAAFRev2)\n"); else printf("\n"); // Show datadefs, with version IEnumAAFDataDefsSP pEnumDataDef; IAAFDictionarySP pDictionary; check(pHeader->GetDictionary(&pDictionary)); check(pDictionary->GetDataDefs(&pEnumDataDef)); IAAFDataDef* pDataDef; printf("\nDatadefs = "); while (SUCCEEDED(pEnumDataDef->NextOne(&pDataDef))) { IAAFDefObjectSP pDefObject; check(pDataDef->QueryInterface(IID_IAAFDefObject, (void**)&pDefObject)); pDataDef->Release(); pDataDef = NULL; aafUID_t id = {0}; check(pDefObject->GetAUID(&id)); aafWChar wchName[500]; char chName[1000]; check( pDefObject->GetName(wchName, sizeof (wchName)) ); convert(chName, sizeof(chName), wchName); if (memcmp( &id, &kAAFDataDef_LegacyPicture, sizeof(id)) == 0) printf("\"%s\" (recognized as legacy Picture)\n", chName); else if (memcmp( &id, &kAAFDataDef_Picture, sizeof(id)) == 0) printf("\"%s\" (recognized as Picture)\n", chName); else if (memcmp( &id, &kAAFDataDef_LegacySound, sizeof(id)) == 0) printf("\"%s\" (recognized as legacy Sound)\n", chName); else if (memcmp( &id, &kAAFDataDef_Sound, sizeof(id)) == 0) printf("\"%s\" (recognized as Sound)\n", chName); else if (memcmp( &id, &kAAFDataDef_LegacyTimecode, sizeof(id)) == 0) printf("\"%s\" (recognized as legacy Timecode)\n", chName); else if (memcmp( &id, &kAAFDataDef_Timecode, sizeof(id)) == 0) printf("\"%s\" (recognized as Timecode)\n", chName); else if (memcmp( &id, &kAAFDataDef_PictureWithMatte, sizeof(id)) == 0) printf("\"%s\" (recognized as PictureWithMatte)\n", chName); else if (memcmp( &id, &kAAFDataDef_Edgecode, sizeof(id)) == 0) printf("\"%s\" (recognized as Edgecode)\n", chName); else if (memcmp( &id, &kAAFDataDef_Auxiliary, sizeof(id)) == 0) printf("\"%s\" (recognized as Auxiliary)\n", chName); else if (memcmp( &id, &kAAFDataDef_DescriptiveMetadata, sizeof(id)) == 0) printf("\"%s\" (recognized as DescriptiveMetadata)\n", chName); else if (memcmp( &id, &kAAFDataDef_Matte, sizeof(id)) == 0) printf("\"%s\" (recognized as Matte)\n", chName); else printf("\"%s\"\n", chName); printf(" "); } // Check if file contains TypeDefs known to cause a v1.0 reader to assert. // Known instances of this are UInt32Set and AUIDSet added to the v1.1 SDK. // Cannot use Dictionary::LookupTypeDef to check for them, because this // has the side effect of registering the typedef we are checking for // from the built-in model. Instead, iterate through typedefs (in file) // and check for the known instances. printf("\nTypes incompatible with SDK v1.0.x ="); IEnumAAFTypeDefsSP pEnumTypeDef; check(pDictionary->GetTypeDefs(&pEnumTypeDef)); IAAFTypeDef* pTypeDef; bool foundToxic = false; while (SUCCEEDED(pEnumTypeDef->NextOne(&pTypeDef))) { IAAFMetaDefinitionSP pMetaDef; check(pTypeDef->QueryInterface(IID_IAAFMetaDefinition, (void**)&pMetaDef)); pTypeDef->Release(); pTypeDef = NULL; aafUID_t typeUID; check(pMetaDef->GetAUID(&typeUID)); aafWChar wchName[500]; char chName[1000]; check( pMetaDef->GetName(wchName, sizeof (wchName)) ); convert(chName, sizeof(chName), wchName); if ((memcmp( &typeUID, &kAAFTypeID_AUIDSet, sizeof(typeUID)) == 0) || (memcmp( &typeUID, &kAAFTypeID_UInt32Set, sizeof(typeUID)) == 0)) { printf(" %s", chName); foundToxic = true; } } if (!foundToxic) printf(" (none)"); printf("\n\n"); } pHeader->Release(); pHeader = NULL; } hr = pFile->Close(); check(hr); pFile->Release(); pFile = NULL; // Get file kind. // Since AAF SDK v1.0.2, the file kind actually identifies the implementation // of the file kind, from which the file kind is inferred. aafUID_t fileKind = {0}; aafBool isAAFFile = kAAFFalse; check(AAFFileIsAAFFile(pFileName, &fileKind, &isAAFFile)); if (isAAFFile) { if (memcmp( &fileKind, &kAAFFileKind_AafM512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with Microsoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafS512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with Schemasoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafG512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with GSF)\n"); else if (memcmp( &fileKind, &kAAFFileKind_Aaf512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with default implementation)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafM4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with Microsoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafS4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with Schemasoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafG4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with GSF)\n"); else if (memcmp( &fileKind, &kAAFFileKind_Aaf4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with default implementation)\n"); else printf("Filekind = Recognized by SDK but unknown to AAFInfo\n"); } } else { fprintf(stderr, "Error : Failed to open file (result = %0x).\n", hr); exit(1); } }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFContainerDefs *pPlug = NULL; IAAFDefObject* pDef = NULL; IAAFContainerDef* pContainerDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; aafUID_t readUID; wchar_t testString[256]; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pDictionary->GetContainerDefs(&pPlug)); while(pPlug->NextOne (&pContainerDef) == AAFRESULT_SUCCESS) { checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef)); checkResult(pDef->GetAUID(&readUID)); if(memcmp(&readUID, &testUID, sizeof(aafUID_t)) == 0) { checkResult(pDef->GetName (testString, sizeof(testString))); checkExpression (wcscmp(testString, sName) == 0, AAFRESULT_TEST_FAILED); aafUInt32 nameLen; checkResult (pDef->GetNameBufLen (&nameLen)); checkExpression (((wcslen (sName)+1) * sizeof (aafCharacter) == nameLen), AAFRESULT_TEST_FAILED); checkResult(pDef->GetDescription (testString, sizeof(testString))); checkExpression (wcscmp(testString, sDescription) == 0, AAFRESULT_TEST_FAILED); checkResult (pDef->GetDescriptionBufLen (&nameLen)); checkExpression (((wcslen (sDescription)+1) * sizeof (aafCharacter) == nameLen), AAFRESULT_TEST_FAILED); break; } pDef->Release(); pDef = NULL; pContainerDef->Release(); pContainerDef = NULL; }// checkResult(pPlug->NextOne(&pContainerDef)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pHeader) pHeader->Release(); if (pPlug) pPlug->Release(); if (pDef) pDef->Release(); if (pContainerDef) pContainerDef->Release(); if (pDictionary) pDictionary->Release(); if (pFile) { // Close file if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static bool testRestore(const wchar_t* fileName) { bool passed = true; IAAFFile* pFile = 0; IAAFHeader* pHeader = 0; IAAFDictionary* pDictionary = 0; IAAFContentStorage* pStorage = 0; IEnumAAFMobs* pMobs = 0; IAAFMob* pMob = 0; try { pFile = openFileForReading(fileName); } catch (...) { return false; } try { // get the Mob containing the test data checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pHeader->GetContentStorage(&pStorage)); aafSearchCrit_t searchCrit; searchCrit.searchTag = kAAFByMobKind; searchCrit.tags.mobKind = kAAFAllMob; checkResult(pStorage->GetMobs(&searchCrit, &pMobs)); checkResult(pMobs->NextOne(&pMob)); IAAFObject* pObject = 0; IAAFClassDef* pClassDef = 0; IAAFPropertyDef* pPropertyDef = 0; IAAFPropertyValue* pPropertyValue = 0; IAAFTypeDef* pType = 0; IAAFTypeDefExtEnum* pExtEnumType = 0; // test baseline ext. enum try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x0D010102,0x0101,0x0500,{0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01}}; const wchar_t* testName = L"Usage_SubClip"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test Int8 enum try { printf(" * Non-baseline Ext Enum: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x6f9685a4,0x0a0d,0x447b,{0x89,0xf3,0x1b,0x75,0x0b,0xc5,0xc7,0xde}}; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test baseline extension try { printf(" * Baseline extension: "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x197e78ac,0xb464,0x4bd1,{0x86,0x11,0xb6,0xf2,0xdf,0x0d,0x03,0xfe}}; const wchar_t* testName = L"MyUsage"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test non-baseline extension try { printf(" * Non-baseline extension: "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0xe54f0efa,0x15c1,0x468f,{0xb7,0x43,0x9b,0xfd,0x12,0x94,0x04,0x49}}; const wchar_t* testName = L"CCC"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); } catch (...) { passed = false; } // cleanup release(pMob); release(pMobs); release(pStorage); release(pDictionary); release(pHeader); checkResult(pFile->Close()); release(pFile); report(passed); return passed; }
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) { 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; }