void EventTest::Close() { if (_pDictionary) { _pDictionary->Release(); _pDictionary = NULL; } if (_pHeader) { _pHeader->Release(); _pHeader = NULL; } if (_pFile) { if (_bWritableFile) checkResult(_pFile->Save()); checkResult(_pFile->Close()); _pFile->Release(); _pFile = NULL; } }
void EnumEssenceDataTest::cleanupReferences() { if (NULL != _pEssenceData) { _pEssenceData->Release(); _pEssenceData = NULL; } if (NULL != _pEnumEssenceData) { _pEnumEssenceData->Release(); _pEnumEssenceData = NULL; } if (NULL != _pFileDescriptor) { _pFileDescriptor->Release(); _pFileDescriptor = NULL; } if (NULL != _pEssenceDescriptor) { _pEssenceDescriptor->Release(); _pEssenceDescriptor = NULL; } if (NULL != _pSourceMob) { _pSourceMob->Release(); _pSourceMob = NULL; } if (NULL != _pMob) { _pMob->Release(); _pMob = NULL; } if (NULL != _pDictionary) { _pDictionary->Release(); _pDictionary = NULL; } if (NULL != _pHeader) { _pHeader->Release(); _pHeader = NULL; } if (NULL != _pFile) { if (_bFileOpen) _pFile->Close(); _pFile->Release(); _pFile = NULL; } }
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()
static HRESULT ReadAAFFile(aafWChar * pFileName) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; HRESULT hr = S_OK; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pHeader) pHeader->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; 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 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 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 HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { // IAAFSession* pSession = NULL; IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMob* pReferencedMob = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; bool bFileOpen = false; HRESULT hr = AAFRESULT_SUCCESS; IAAFComponent* pComponent = NULL; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); //Make the MOB to be referenced checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pReferencedMob)); checkResult(pReferencedMob->SetMobID(TEST_referencedMobID)); checkResult(pReferencedMob->SetName(L"AAFSourceClipTest::ReferencedMob")); // Create a Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"AAFSourceClipTest")); // Create a SourceClip checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSegment, (IUnknown **)&seg)); checkResult(seg->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot (editRate, seg, 1, slotName, 0, &newSlot)); checkResult(pHeader->AddMob(pMob)); checkResult(pHeader->AddMob(pReferencedMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (newSlot) newSlot->Release(); if (pComponent) pComponent->Release(); if (seg) seg->Release(); if (pMob) pMob->Release(); if (pReferencedMob) pReferencedMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile * pFile = NULL; 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 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 ReadAAFFile(aafWChar * pFileName) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IEnumAAFMobs* pMobIter = NULL; IAAFMob* pMob = NULL; IAAFSourceMob* pSourceMob = NULL; IAAFEssenceDescriptor* pEssDesc = NULL; IAAFDataEssenceDescriptor* pDataEssenceDesc = NULL; aafNumSlots_t numMobs = 0; aafUID_t dataEssenceCoding, dataEssTestVal; HRESULT hr = AAFRESULT_SUCCESS; try { memset(&dataEssTestVal, 0, sizeof(aafUID_t)); // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->GetMobs(NULL, &pMobIter)); checkResult(pMobIter->NextOne(&pMob)); checkResult(pMob->QueryInterface(IID_IAAFSourceMob, (void **)&pSourceMob)); // Back into testing mode checkResult(pSourceMob->GetEssenceDescriptor(&pEssDesc)); // if there is an Essence Descriptor then it MUST be an (essence) DataEssence Descriptor checkResult(pEssDesc->QueryInterface(IID_IAAFDataEssenceDescriptor, (void **) &pDataEssenceDesc)); checkResult(pDataEssenceDesc->GetDataEssenceCoding(&dataEssenceCoding)); checkExpression(memcmp(&dataEssenceCoding, &dataEssTestVal, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pDataEssenceDesc) pDataEssenceDesc->Release(); if (pEssDesc) pEssDesc->Release(); if (pSourceMob) pSourceMob->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { 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 ReadAAFFile(aafWChar * pFileName) { // IAAFSession * pSession = NULL; IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IEnumAAFMobs *mobIter = NULL; IAAFMob *aMob = NULL; IAAFEssenceDescriptor *pEdesc = NULL; IAAFSourceMob *pSourceMob = NULL; IEnumAAFLocators * pEnum = NULL; IAAFLocator * pLocator = NULL; aafUInt32 numLocators; aafNumSlots_t numMobs, n; HRESULT hr = AAFRESULT_SUCCESS; bool bFileOpen = false; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression (1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->GetMobs (NULL, &mobIter)); for(n = 0; n < numMobs; n++) { aafWChar name[500]; aafMobID_t mobID; checkResult(mobIter->NextOne (&aMob)); checkResult(aMob->GetName (name, sizeof(name))); checkResult(aMob->GetMobID (&mobID)); checkResult(aMob->QueryInterface (IID_IAAFSourceMob, (void **)&pSourceMob)); checkResult(pSourceMob->GetEssenceDescriptor (&pEdesc)); // Verify that there is now one locator checkResult(pEdesc->CountLocators(&numLocators)); checkExpression(20 == numLocators, AAFRESULT_TEST_FAILED); checkResult(pEdesc->GetLocators(&pEnum)); // This should read the one real locator for ( n=0; n<numLocators; n++) { checkResult(pEnum->NextOne(&pLocator)); pLocator->Release(); pLocator = NULL; } // We had better not succeed or get an unknown failure. checkExpression(AAFRESULT_NO_MORE_OBJECTS == pEnum->NextOne(&pLocator), AAFRESULT_TEST_FAILED); pEnum->Release(); pEnum = NULL; pEdesc->Release(); pEdesc = NULL; pSourceMob->Release(); pSourceMob = NULL; aMob->Release(); aMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup object references if (pLocator) pLocator->Release(); if (pEnum) pEnum->Release(); if (pEdesc) pEdesc->Release(); if (pSourceMob) pSourceMob->Release(); if (aMob) aMob->Release(); if (mobIter) mobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file, clean-up and return if (bFileOpen) pFile->Close(); pFile->Release(); } /* hr = pSession->EndSession(); if (AAFRESULT_SUCCESS != hr) return hr; */ return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFOperationDef* pOperationDef = NULL; IAAFParameterDef* pParamDef = NULL; IAAFDefObject* pDefObject = NULL; IAAFOperationGroup *pOperationGroup = NULL; IAAFMob *pMob = NULL; IAAFSegment *pSeg = NULL; IAAFTimelineMobSlot *pSlot = NULL; IAAFParameter *pParm = NULL; IAAFVaryingValue *pVaryingValue = NULL; IAAFSegment *pFiller = NULL; IAAFComponent *pComponent = NULL; IAAFSourceClip *pSourceClip = NULL; IAAFControlPoint *pControlPoint = NULL; IAAFSourceReference *pSourceRef = NULL; IAAFInterpolationDef *pInterpDef = NULL; IAAFPluginManager *pMgr = NULL; IAAFTypeDef *pTypeDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; // aafUID_t testInterpDef = kAAFTypeID_Rational; aafLength_t effectLen = TEST_EFFECT_LEN; aafUID_t effectID = kTestEffectID; aafUID_t parmID = kTestParmID; aafRational_t testLevel1 = kTestLevel1; aafRational_t testLevel2 = kTestLevel2; aafRational_t testTime1 = kTestTime1; aafRational_t testTime2 = kTestTime2; /* long test; */ try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pDictionary->LookupTypeDef (kAAFTypeID_Rational, &pTypeDef)); checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, pTypeDef)); checkResult(AAFGetPluginManager(&pMgr)); checkResult(pMgr->CreatePluginDefinition(LinearInterpolator, pDictionary, &pDefObject)); checkResult(pDefObject->QueryInterface(IID_IAAFInterpolationDef, (void **) &pInterpDef)); pDefObject->Release(); pDefObject = NULL; checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC)); checkResult(pDictionary->RegisterOperationDef (pOperationDef)); checkResult(pDictionary->RegisterParameterDef (pParamDef)); checkResult(pDictionary->RegisterInterpolationDef (pInterpDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS)); //Make the first mob long test; aafRational_t videoRate = { 2997, 100 }; // Create a Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetName(L"AAFOperationGroupTest")); // Add some slots for(test = 0; test < 2; test++) { checkResult(defs.cdOperationGroup()-> CreateInstance(IID_IAAFOperationGroup, (IUnknown **)&pOperationGroup)); checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFSegment, (IUnknown **)&pFiller)); checkResult(pFiller->QueryInterface (IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetLength(effectLen)); CAAFBuiltinDefs defs(pDictionary); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), TEST_EFFECT_LEN, pOperationDef)); checkResult(defs.cdVaryingValue()-> CreateInstance(IID_IAAFVaryingValue, (IUnknown **)&pVaryingValue)); checkResult(pVaryingValue->Initialize (pParamDef, pInterpDef)); checkResult(defs.cdControlPoint()-> CreateInstance(IID_IAAFControlPoint, (IUnknown **)&pControlPoint)); checkResult(pControlPoint->Initialize (pVaryingValue, testTime1, sizeof(testLevel1), (aafDataBuffer_t)&testLevel1)); checkResult(pControlPoint->SetEditHint(kAAFRelativeLeft)); checkResult(pVaryingValue->AddControlPoint(pControlPoint)); pControlPoint->Release(); pControlPoint = NULL; checkResult(defs.cdControlPoint()-> CreateInstance(IID_IAAFControlPoint, (IUnknown **)&pControlPoint)); checkResult(pControlPoint->Initialize (pVaryingValue, testTime2, sizeof(testLevel2), (aafDataBuffer_t)&testLevel2)); checkResult(pControlPoint->SetEditHint(kAAFProportional)); checkResult(pVaryingValue->AddControlPoint(pControlPoint)); pControlPoint->Release(); pControlPoint = NULL; checkResult(pVaryingValue->QueryInterface (IID_IAAFParameter, (void **)&pParm)); checkResult(pOperationGroup->AddParameter (pParm)); checkResult(pOperationGroup->AppendInputSegment (pFiller)); pFiller->Release(); pFiller = NULL; checkResult(pOperationGroup->SetBypassOverride (1)); checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); aafSourceRef_t sourceRef; sourceRef.sourceID = zeroMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(), effectLen, sourceRef)); checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pOperationGroup->SetRender (pSourceRef)); checkResult(pOperationGroup->QueryInterface (IID_IAAFSegment, (void **)&pSeg)); checkResult(pMob->AppendNewTimelineSlot (videoRate, pSeg, test+1, slotNames[test], 0, &pSlot)); pSlot->Release(); pSlot = NULL; pSeg->Release(); pSeg = NULL; pOperationGroup->Release(); pOperationGroup = NULL; pParm->Release(); pParm = NULL; pVaryingValue->Release(); pVaryingValue = NULL; pComponent->Release(); pComponent = NULL; pSourceRef->Release(); pSourceRef = NULL; pSourceClip->Release(); pSourceClip = NULL; } // Add the mob to the file. checkResult(pHeader->AddMob(pMob)); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if(pSourceRef) pSourceRef->Release(); if(pControlPoint) pControlPoint->Release(); if(pSourceClip) pSourceClip->Release(); if (pDefObject) pDefObject->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pMob) pMob->Release(); if (pSeg) pSeg->Release(); if (pSlot) pSlot->Release(); if (pComponent) pComponent->Release(); if (pParm) pParm->Release(); // if (pIntDef) // pIntDef->Release(); if (pInterpDef) pInterpDef->Release(); if (pVaryingValue) pVaryingValue->Release(); if (pFiller) pFiller->Release(); if (pOperationDef) pOperationDef->Release(); if (pParamDef) pParamDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if(pMgr) pMgr->Release(); if(pTypeDef) pTypeDef->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT 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 *filename, aafUID_constref fileKind) { TestProductID.companyName = companyName; TestProductID.productName = productName; TestProductID.productVersionString = NULL; TestProductID.productID = UnitTestProductID; TestProductID.platform = NULL; TestProductID.productVersion = &TestVersion; HRESULT hr = S_OK; try { RemoveTestFile(filename); // Open new file IAAFFile *pFile = NULL; TestProductID.productVersionString = const_cast<aafWChar*>(L"CreateAAFFile"); checkResult( AAFFileOpenNewModifyEx( filename, &fileKind, 0, &TestProductID, &pFile) ); // Get the header & dictionary IAAFHeader *pHeader = NULL; IAAFDictionary *pDictionary = NULL; checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); // Create a MasterMob IAAFMob *pMob = NULL; IAAFClassDef *classDef = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFMasterMob, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); classDef->Release(); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"CreateAAFFile - MasterMob")); checkResult(pHeader->AddMob(pMob)); pMob->Release(); // Create a SourceMob IAAFSourceMob *pSourceMob = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFSourceMob, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob)); classDef->Release(); checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_SourceMobID)); checkResult(pMob->SetName(L"CreateAAFFile - SourceMob")); IAAFEssenceDescriptor *edesc = NULL; IAAFAIFCDescriptor *pAIFCDesc = NULL; checkResult(pDictionary->LookupClassDef(AUID_AAFAIFCDescriptor, &classDef)); checkResult(classDef->CreateInstance(IID_IAAFEssenceDescriptor, (IUnknown **)&edesc)); classDef->Release(); checkResult(edesc->QueryInterface(IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); aafUInt8 buf[] = {0x00}; checkResult(pAIFCDesc->SetSummary(sizeof(buf), buf)); checkResult(pSourceMob->SetEssenceDescriptor(edesc)); checkResult(pHeader->AddMob(pMob)); pAIFCDesc->Release(); edesc->Release(); pSourceMob->Release(); pMob->Release(); pDictionary->Release(); pHeader->Release(); // Save & close the file checkResult(pFile->Save()); checkResult(pFile->Close()); checkResult(pFile->Release()); cout << "CreateAAFFile() - created new file" << endl; } catch (HRESULT& rResult) { hr = rResult; cout << "*** CreateAAFFile: caught error hr=0x" << hex << hr << dec << endl; } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFParameterDef* pParamDef = NULL; bool bFileOpen = false; HRESULT hr = S_OK; aafUID_t testParmID = kParmID; aafInt32 index; IAAFOperationDef *pOperationDef = NULL, *defResults[3] = { NULL, NULL, NULL }; /* long test; */ try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pParamDef->Initialize (testParmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational())); checkResult(pDictionary->RegisterParameterDef(pParamDef)); for(index = 0; index < 3; index++) { checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(pOperationDef->Initialize (effectID[index], effectNames[index], effectDesc[index])); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); defResults[index] = pOperationDef; pOperationDef = NULL; } checkResult(defResults[1]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[2]->AppendDegradeToOperation (defResults[2])); checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); checkResult(defResults[0]->PrependDegradeToOperation (defResults[2])); // Add an extra one to delete for the test //!!! checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->AppendDegradeToOperation (defResults[1])); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(3 == numDegrade, AAFRESULT_TEST_FAILED); // checkResult(defResults[0]->RemoveDegradeToOperationAt (2)); // checkResult(defResults[0]->CountDegradeToOperations(&numDegrade)); // checkExpression(2 == numDegrade, AAFRESULT_TEST_FAILED); for(index = 0; index < 3; index++) { defResults[index]->Release(); defResults[index] = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pOperationDef) pOperationDef->Release(); if (pParamDef) pParamDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { // Close file if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar * pFileName) { IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; 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; }
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(aafWChar * pFileName) { // IAAFSession * pSession = NULL; IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IEnumAAFMobs* pMobIter = NULL; IAAFMob* pMob = NULL; IAAFMob* pReferencedMob = NULL; IEnumAAFMobSlots* pSlotIter = NULL; IAAFMobSlot* pSlot = NULL; IAAFSegment* pSegment = NULL; IAAFSourceClip* pSourceClip = NULL; bool bFileOpen = false; aafSearchCrit_t criteria; aafNumSlots_t numMobs, numSlots; HRESULT hr = AAFRESULT_SUCCESS; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the number of mobs in the file (should be one) checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(2 == numMobs, AAFRESULT_TEST_FAILED); // Enumerate over all Composition Mobs criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFCompMob; checkResult(pHeader->GetMobs(&criteria, &pMobIter)); while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)) { checkResult(pMob->CountSlots(&numSlots)); checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED); checkResult(pMob->GetSlots(&pSlotIter)); while (AAFRESULT_SUCCESS == pSlotIter->NextOne(&pSlot)) { // The segment should be a source clip... checkResult(pSlot->GetSegment(&pSegment)); pSegment->Release(); pSegment = NULL; pSlot->Release(); pSlot = NULL; } pMob->Release(); pMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pReferencedMob) pReferencedMob->Release(); if (pSourceClip) pSourceClip->Release(); if (pSegment) pSegment->Release(); if (pSlot) pSlot->Release(); if (pSlotIter) pSlotIter->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
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 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 ReadAAFFile(aafWChar * pFileName ) { HRESULT hr = AAFRESULT_SUCCESS; IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IEnumAAFMobs* pMobIter = NULL; IAAFCompositionMob * pCMob = NULL; IAAFMob* pMob = NULL; bool bFileOpen = false; aafNumSlots_t numMobs; IAAFObject* pObj = NULL; IEnumAAFProperties * pEnum = NULL; IAAFProperty *pProp = NULL; IAAFPropertyDef* pPropDef = NULL; IAAFPropertyValue* pPropVal = NULL; IAAFTypeDef* pTypeDef = NULL; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Validate that there is only one composition mob. checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); // Enumerate over all Composition Mobs aafSearchCrit_t criteria; criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFCompMob; checkResult(pHeader->GetMobs(&criteria, &pMobIter)); while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)) { //Get the Composition mob checkResult (pMob->QueryInterface (IID_IAAFCompositionMob, (void **) &pCMob)); //Get the Object checkResult (pCMob->QueryInterface (IID_IAAFObject, (void **) &pObj)); //From the Object, we can get the properties .... aafUInt32 propCount = 0; checkResult (pObj->CountProperties (&propCount)); //A composition should have at least 5 properties ... checkExpression(propCount>=5, AAFRESULT_TEST_FAILED); //Get Enumeration over properties checkResult (pObj->GetProperties (&pEnum)); checkExpression (pEnum != 0, AAFRESULT_TEST_FAILED); while (propCount--) { //Check for property validity checkResult (pEnum->NextOne (&pProp)); checkExpression (pProp != NULL, AAFRESULT_TEST_FAILED); //Now call prop methods //1. Get Definition checkResult( pProp->GetDefinition(&pPropDef) ); //2. Get Value checkResult( pProp->GetValue(&pPropVal) ); //deal with prop value checkResult( pPropVal->GetType(&pTypeDef) ); //From propval, get the typedef!!!!!!!!!!!!!!!!!!!!! IAAFTypeDefSP spTypeDef; checkResult( pPropVal->GetType(&spTypeDef) ); //get category eAAFTypeCategory_t typeCat = kAAFTypeCatUnknown; checkResult (spTypeDef->GetTypeCategory(&typeCat)); //make sure it is not unknown checkExpression(kAAFTypeCatUnknown != typeCat, AAFRESULT_TEST_FAILED); //Deal with our Name String .... if (typeCat == kAAFTypeCatString) { IAAFTypeDefStringSP spTypeDefString; checkResult( spTypeDef->QueryInterface(IID_IAAFTypeDefString, (void**)&spTypeDefString) ); aafUInt32 bufSize = //don't forget the NULL char, and factoring in the size of a wchar (wcslen(TEST_NAME)+1) * sizeof(aafCharacter); aafCharacter *nameBuf = new aafCharacter[bufSize]; checkResult( spTypeDefString->GetElements(pPropVal, (aafMemPtr_t)nameBuf, bufSize) ); checkExpression( wcscmp(TEST_NAME, nameBuf) == 0, AAFRESULT_TEST_FAILED ); delete [] nameBuf; } //Done ........... //release typedef pTypeDef->Release(); //release defintion + value pPropDef->Release(); pPropVal->Release(); //release this prop pProp->Release(); pProp = NULL; }//while prop count }//while mob iter }//try catch (HRESULT & rResult) { hr = rResult; } //Release the rest ... if (pEnum) pEnum->Release(); if (pObj) pObj->Release(); if (pCMob) pCMob->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; 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) { 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; }
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 ReadAAFFile(aafWChar * pFileName) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; aafNumSlots_t numMobs, i; HRESULT hr = S_OK; HRESULT localhr = S_OK; IEnumAAFMobs *mobIter = NULL; IEnumAAFMobs *cloneMobIter = NULL; IAAFMob *aMob = NULL; IAAFMob **mobArray = NULL; aafSearchCrit_t criteria; aafUInt32 numFetched = 0; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Make sure that we have one master, one file, and one composition (three total) checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression (3 == numMobs, AAFRESULT_TEST_FAILED); criteria.searchTag = kAAFNoSearch; checkResult(pHeader->GetMobs (&criteria, &mobIter)); /* Test the Reset method *******************************/ if (mobIter->Reset() == AAFRESULT_SUCCESS) cout<< " Reset() ... Passed" << endl; else { cout<< " Reset() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Test the NextOne method ******************************/ // Call NextOne once for each mob for a total of numMobs times for (i=0; i<numMobs; i++) { if (mobIter->NextOne(&aMob) == AAFRESULT_SUCCESS) { aMob->Release(); aMob = NULL; } else localhr = AAFRESULT_TEST_FAILED; } // Make sure we are at the end if (mobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); // this should return AAFRESULT_NULL_PARAM if (mobIter->NextOne(NULL) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " NextOne() ... Passed" << endl; else { cout<< " NextOne() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Test the Skip method ******************************/ localhr = S_OK; mobIter->Reset(); // skip over each Mob one at a time. for (i=0; i<numMobs; i++) if (mobIter->Skip(1) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; // Make sure we are at the end. if (mobIter->Skip(1) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); // Skip over multiple Mobs at a time. for (i=2; i<=numMobs; i++) { if (mobIter->Skip(i) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); } // Make sure we are at the end. if (mobIter->Skip(numMobs+1) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " Skip() ... Passed" << endl; else { cout<< " Skip() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Next() ******************************************/ mobArray = new IAAFMob *[numMobs]; localhr = S_OK; numFetched = 1; // Iterate thru the Mobs using Next doing 1 at a time mobIter->Reset(); for ( i=0; i<numMobs ;i++) { if (mobIter->Next(1, &aMob, &numFetched) == AAFRESULT_SUCCESS) { aMob->Release(); aMob = NULL; if (1 != numFetched) localhr = AAFRESULT_TEST_FAILED; } else localhr = AAFRESULT_TEST_FAILED; } // Make sure we are at the end if (mobIter->Next(1, &aMob, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if(numFetched != 0) localhr = AAFRESULT_TEST_FAILED; // Test the Next method filling out an array of Mobs numFetched = 0; mobIter->Reset(); for ( i=2; i<=numMobs ;i++) { if (mobIter->Next(i, mobArray, &numFetched) == AAFRESULT_SUCCESS) { if (i != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numFetched; i++) if (mobArray[i] != NULL) // should have been set { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } else localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); } // Make sure we can't get more Mobs than numMobs if (mobIter->Next(i+1, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (numMobs != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numMobs; i++) if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); mobIter->Skip(2); // Make sure we can't go past the end to fill the array if (mobIter->Next(numMobs, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if ((numMobs-2) != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numMobs-2; i++) if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); // Make sure it returns AAFRESULT_NULL_PARAM if (mobIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; // Make sure it returns E_INVALIDARG if (mobIter->Next(1, mobArray, &numFetched) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; else { for (i = 0; i < numFetched; i++) if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } if (SUCCEEDED(localhr)) cout<< " Next() ... Passed" << endl; else { cout<< " Next() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } /* Clone() ************************************/ // Test the Clone method with with enumerator at begining localhr = S_OK; mobIter->Reset(); if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS) { for (i=0; i < numMobs; i++) { if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS) { aMob->Release(); aMob = NULL; } else localhr = AAFRESULT_TEST_FAILED; } if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; cloneMobIter->Reset(); if (cloneMobIter->Next(numMobs, mobArray, &numFetched) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; if (numMobs != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numMobs; i++) { if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } cloneMobIter->Reset(); if (cloneMobIter->Next(numMobs+1, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if (numMobs != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numMobs; i++) { if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } cloneMobIter->Reset(); cloneMobIter->Skip(1); if (cloneMobIter->Next(numMobs, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; if ((numMobs-1) != numFetched) localhr = AAFRESULT_TEST_FAILED; for (i = 0; i < numMobs-1; i++) { if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } cloneMobIter->Release(); cloneMobIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; // Test the Clone method with with enumerator at end. // Indirectly tests the Skip and Reset methods. mobIter->Reset(); mobIter->Skip(numMobs-1); if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS) { if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS) { aMob->Release(); aMob = NULL; } if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; cloneMobIter->Release(); cloneMobIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; // Test the Clone method with with enumerator in the middle. // Indirectly tests the Skip and Reset methods. mobIter->Reset(); mobIter->Skip(numMobs-2); if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS) { cloneMobIter->Skip(1); if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS) { aMob->Release(); aMob = NULL; } else localhr = AAFRESULT_TEST_FAILED; if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS) localhr = AAFRESULT_TEST_FAILED; cloneMobIter->Release(); cloneMobIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; mobIter->Reset(); if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS) { if (cloneMobIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM) localhr = AAFRESULT_TEST_FAILED; if (cloneMobIter->Next(1, mobArray, &numFetched) != AAFRESULT_SUCCESS) localhr = AAFRESULT_TEST_FAILED; else { for (i = 0; i < numFetched; i++) { if (mobArray[i] != NULL) { mobArray[i]->Release(); mobArray[i] = NULL; } else localhr = AAFRESULT_TEST_FAILED; } } cloneMobIter->Release(); cloneMobIter = NULL; } else localhr = AAFRESULT_TEST_FAILED; if (SUCCEEDED(localhr)) cout<< " Clone() ... Passed" << endl; else { cout<< " Clone() ... Failed!!!" << endl; hr = AAFRESULT_TEST_FAILED; } checkResult(pHeader->CountMobs(kAAFMasterMob, &numMobs)); checkExpression (1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->CountMobs(kAAFFileMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); // Test usageCode search criteria. { // Should find one TopLevel mob, and two Template mobs. // There should be one mob with usage code TopLevel, and it should be // a composition mob. aafSearchCrit_t usageCrit; usageCrit.searchTag = kAAFByUsageCode; usageCrit.tags.usageCode = kAAFUsage_TopLevel; CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFCompositionMob ); // There should be one composition mob with usage code TopLevel. usageCrit.searchTag = kAAFByCompositionMobUsageCode; usageCrit.tags.usageCode = kAAFUsage_TopLevel; CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFCompositionMob ); // There should be two mobs with usage code Template. They are of difference // types, hence, don't check the type. usageCrit.searchTag = kAAFByUsageCode; usageCrit.tags.usageCode = kAAFUsage_Template; CheckMobsByUsageCode( pHeader, usageCrit, 2, false, IID_IUnknown ); // One of the Template mobs should be a SourceMob, the other should be MasterMob. usageCrit.searchTag = kAAFBySourceMobUsageCode; usageCrit.tags.usageCode = kAAFUsage_Template; CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFSourceMob ); usageCrit.searchTag = kAAFByMasterMobUsageCode; usageCrit.tags.usageCode = kAAFUsage_Template; CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFMasterMob ); } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return delete [] mobArray; if (mobIter) mobIter->Release(); if (pHeader) pHeader->Release(); if (pFile) { if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static HRESULT ReadAAFFile(aafWChar * pFileName) { // IAAFSession * pSession = NULL; IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFMobs* pMobIter = NULL; IEnumAAFMobSlots* pEnum = NULL; IAAFMob* pMob = NULL; IAAFMobSlot* pMobSlot = NULL; IAAFSegment* pSegment = NULL; IAAFSequence* pSequence = NULL; IAAFTransition* pTransition = NULL; IAAFComponent* pComponent = NULL; IAAFFiller* pFiller = NULL; IAAFOperationGroup* pOperationGroup = NULL; IEnumAAFComponents* pCompIter = NULL; aafLength_t transitionLength; aafPosition_t cutPoint; aafNumSlots_t numMobs; aafUInt32 numComponents = 0; HRESULT hr = S_OK; try { // Open the file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the number of mobs in the file (should be one) checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); checkResult(pHeader->GetMobs( NULL, &pMobIter)); while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)) { checkResult(pMob->GetSlots (&pEnum)); while (AAFRESULT_SUCCESS == pEnum->NextOne (&pMobSlot)) { checkResult(pMobSlot->GetSegment (&pSegment)); // Check to see if Segment is a Sequence checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **) &pSequence)); // It is, so get a Component Iterator checkResult(pSequence->CountComponents(&numComponents)); // Verify that all 3 components(Filler, Transition, Filler) are present checkExpression(numComponents == 3, AAFRESULT_TEST_FAILED); checkResult(pSequence->GetComponents(&pCompIter)); // Now visit each and every one of the components. while(AAFRESULT_SUCCESS == pCompIter->NextOne(&pComponent)) { // Find out what kind of segment we have if ((pComponent->QueryInterface(IID_IAAFTransition, (void **)&pTransition)) == AAFRESULT_SUCCESS) { // This is the transition checkResult(pTransition->GetCutPoint (&cutPoint)); checkResult(pComponent->GetLength(&transitionLength)); checkResult(pTransition->GetOperationGroup(&pOperationGroup)); // Check results !! checkExpression(cutPoint == 0, AAFRESULT_TEST_FAILED); checkExpression(transitionLength == 100, AAFRESULT_TEST_FAILED); pTransition->Release(); pTransition = NULL; } else { // validate that the other segments are Fillers checkResult(pComponent->QueryInterface(IID_IAAFFiller, (void **)&pFiller)); pFiller->Release(); pFiller = NULL; } pComponent->Release(); pComponent = NULL; } pSegment->Release(); pSegment = NULL; pSequence->Release(); pSequence = NULL; pCompIter->Release(); pCompIter = NULL; } pMob->Release(); pMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pTransition) pTransition->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pComponent) pComponent->Release(); if (pSegment) pSegment->Release(); if (pMobSlot) pMobSlot->Release(); if (pSequence) pSequence->Release(); if (pCompIter) pCompIter->Release(); if (pEnum) pEnum->Release(); if (pFiller) pFiller->Release(); if (pMob) pMob->Release(); if (pMobIter) pMobIter->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { if (bFileOpen) pFile->Close(); pFile->Release(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { // 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; }