static HRESULT CreateAAFSequence(IAAFDictionary *pDictionary, IAAFSequence** ppSequence) { IAAFSequence* pSequence = NULL; HRESULT hr = S_OK; aafUInt32 i; CAAFBuiltinDefs defs (pDictionary); hr = defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence); if (SUCCEEDED(hr)) { pSequence->Initialize(defs.ddkAAFSound()); // // Add some segments. Need to test failure conditions // (i.e. starting/ending w/ transition, two trans back // to bacl). // for(i = 0; i < kNumComponents; i++) { IAAFComponent* pComponent = NULL; aafLength_t len = 10; hr = defs.cdFiller()-> CreateInstance(IID_IAAFComponent, (IUnknown **)&pComponent); if (FAILED(hr)) break; pComponent->SetDataDef(defs.ddkAAFSound()); pComponent->SetLength(len); hr = pSequence->AppendComponent(pComponent); pComponent->Release(); pComponent = NULL; if (FAILED(hr)) break; } } if (SUCCEEDED(hr)) { *ppSequence = pSequence; } else { pSequence->Release(); *ppSequence = NULL; } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile * pFile = NULL; bool bFileOpen = false; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFCompositionMob* pCompMob=NULL; IAAFMob* pMob = NULL; IAAFTimelineMobSlot* pNewSlot = NULL; IAAFSourceClip* pSourceClip = NULL; IAAFSourceReference* pSourceRef = NULL; IAAFTransition* pTransition = NULL; IAAFOperationGroup* pOperationGroup = NULL; IAAFSegment* pSegment = NULL; IAAFSegment* pEffectFiller = NULL; IAAFComponent* pComponent = NULL; IAAFFiller* pFiller = NULL; IAAFSequence* pSequence = NULL; IAAFOperationDef* pOperationDef = NULL; IAAFParameter *pParm = NULL; IAAFParameterDef* pParamDef = NULL; IAAFConstantValue* pConstantValue = NULL; HRESULT hr = S_OK; aafLength_t transitionLength; aafPosition_t cutPoint = 0; aafLength_t effectLen = TEST_EFFECT_LEN; aafUID_t effectID = kTestEffectID; aafUID_t parmID = kTestParmID; transitionLength = 100; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); bFileOpen = true; // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Create the effect and parameter definitions checkResult(defs.cdOperationDef()-> CreateInstance(IID_IAAFOperationDef, (IUnknown **)&pOperationDef)); checkResult(defs.cdParameterDef()-> CreateInstance(IID_IAAFParameterDef, (IUnknown **)&pParamDef)); checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC)); checkResult(pDictionary->RegisterOperationDef(pOperationDef)); checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational ())); checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS)); checkResult(pDictionary->RegisterParameterDef(pParamDef)); checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture())); checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse)); checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS)); checkResult(pOperationDef->SetCategory (TEST_CATEGORY)); checkResult(pOperationDef->AddParameterDef (pParamDef)); checkResult(pOperationDef->SetBypass (TEST_BYPASS)); // ------------------------------------------------------------ // To test a Transition we need to create a Sequence which will // a Filler, a transition and another Filler. I know this is not // very interesting, but it will let us test the Transition // interface with the least amount of other stuff. // ------------------------------------------------------------ // // Create a CompositionMob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFCompositionMob, (IUnknown **)&pCompMob)); checkResult(pCompMob->Initialize(L"Transition Test")); // Get a MOB interface checkResult(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); // Create a Sequence checkResult(defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **) &pSequence)); // Get a Segment interface checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment)); // Get a component interface and checkResult(pSequence->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); // set the Data definition for it ! checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create a new Mob Slot that will contain the sequence aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"Transition", 0, &pNewSlot)); // Create a Filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); // Get a component interface checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pFiller->Release(); pFiller = NULL; pComponent->Release(); pComponent = NULL; checkResult(defs.cdTransition()-> CreateInstance(IID_IAAFTransition, (IUnknown **)&pTransition)); // Create an empty EffectGroup object !! checkResult(defs.cdOperationGroup()-> CreateInstance(IID_IAAFOperationGroup, (IUnknown **)&pOperationGroup)); checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), transitionLength, pOperationDef)); // Create a constant value parameter. checkResult(defs.cdConstantValue()-> CreateInstance(IID_IAAFConstantValue, (IUnknown **)&pConstantValue)); aafRational_t testLevel = {1, 2}; checkResult(pConstantValue->Initialize (pParamDef, sizeof(testLevel), (aafDataBuffer_t)&testLevel)); checkResult(pConstantValue->QueryInterface (IID_IAAFParameter, (void **)&pParm)); checkResult(pOperationGroup->AddParameter (pParm)); pParm->Release(); pParm = NULL; pConstantValue->Release(); pConstantValue = NULL; checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFSegment, (IUnknown **) &pEffectFiller)); checkResult(pEffectFiller->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); pComponent->Release(); pComponent = NULL; checkResult(pOperationGroup->AppendInputSegment (pEffectFiller)); // release the filler pEffectFiller->Release(); pEffectFiller = NULL; checkResult(pOperationGroup->SetBypassOverride (1)); checkResult(defs.cdSourceClip()-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); aafSourceRef_t sourceRef; sourceRef.sourceID = zeroMobID; sourceRef.sourceSlotID = 0; sourceRef.startTime = 0; checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(), effectLen, sourceRef)); checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef)); checkResult(pOperationGroup->SetRender (pSourceRef)); checkResult(pTransition->Initialize (defs.ddkAAFPicture(), transitionLength, cutPoint, pOperationGroup)); checkResult(pTransition->QueryInterface (IID_IAAFComponent, (void **)&pComponent)); // now append the transition checkResult(pSequence->AppendComponent(pComponent)); // Release the component - because we need to reuse the pointer later pComponent->Release(); pComponent = NULL; // Create the second filler checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFFiller, (IUnknown **) &pFiller)); checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); // Set values for the filler checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength)); // append the filler to the sequence checkResult(pSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; pFiller->Release(); pFiller = NULL; // Now, we append the composition mob to the file checkResult(pHeader->AddMob(pMob)); // and we are done ! } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pParm) pParm->Release(); if (pConstantValue) pConstantValue->Release(); if (pParamDef) pParamDef->Release(); if (pSourceClip) pSourceClip->Release(); if (pSourceRef) pSourceRef->Release(); if (pNewSlot) pNewSlot->Release(); if (pSegment) pSegment->Release(); if (pSequence) pSequence->Release(); if (pFiller) pFiller->Release(); if (pOperationDef) pOperationDef->Release(); if (pOperationGroup) pOperationGroup->Release(); if (pMob) pMob->Release(); if (pCompMob) pCompMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pTransition) pTransition->Release(); if (pFile) { if (bFileOpen) { pFile->Save(); pFile->Close(); } pFile->Release(); } return hr; }
static HRESULT CreateAAFFile(aafWChar * pFileName, long int N) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFMob* pCompMob = NULL; IAAFEssenceDescriptor* aDesc = NULL; IAAFMasterMob* pMasterMob = NULL; IAAFSourceMob* pFileMob = NULL; IAAFSourceMob* pTapeMob = NULL; IAAFSequence* pSequence = NULL; IAAFComponent* aComponent = NULL; IAAFFileDescriptor* pFileDesc = NULL; IAAFAIFCDescriptor* pAIFCDesc = NULL; IAAFTapeDescriptor* pTapeDesc = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; IAAFSourceClip* fileSclp = NULL; IAAFSourceClip* masterSclp = NULL; IAAFSourceClip* compSclp = NULL; IAAFComponent* compFill = NULL; IAAFLocator* pLocator = NULL; IAAFNetworkLocator* pNetLocator = NULL; IAAFClassDef * pCDCompositionMob = 0; IAAFClassDef * pCDSequence = 0; IAAFClassDef * pCDSourceMob = 0; IAAFClassDef * pCDTapeDescriptor = 0; IAAFClassDef * pCDAIFCDescriptor = 0; IAAFClassDef * pCDNetworkLocator = 0; IAAFClassDef * pCDMasterMob = 0; IAAFClassDef * pCDSourceClip = 0; IAAFClassDef * pCDFiller = 0; IAAFDataDef * pDdefPicture = 0; aafRational_t videoRate = { 30000, 1001 }; aafMobID_t tapeMobID, fileMobID, masterMobID; aafTimecode_t tapeTC = { 108000, kAAFTcNonDrop, 30}; aafLength_t fileLen = FILE1_LENGTH; aafLength_t fillLen = FILL_LENGTH; aafLength_t segLen = SEG_LENGTH; aafProductIdentification_t ProductInfo; long int i = 0; moduleErrorTmp = S_OK; // delete any previous test file before continuing... char chFileName[1000]; convert(chFileName, sizeof(chFileName), pFileName); remove(chFileName); aafProductVersion_t v; v.major = 1; v.minor = 0; v.tertiary = 0; v.patchLevel = 0; v.type = kAAFVersionUnknown; ProductInfo.companyName = companyName; ProductInfo.productName = productName; ProductInfo.productVersion = &v; ProductInfo.productVersionString = NULL; ProductInfo.productID = NIL_UID; ProductInfo.platform = NULL; #if defined(USE_MEMORY_FILE) check(MemoryFileOpenNewModify (0, &ProductInfo, &pFile)); #else check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile)); #endif check(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. check(pHeader->GetDictionary(&pDictionary)); check(pDictionary->LookupClassDef(AUID_AAFCompositionMob, &pCDCompositionMob)); check(pDictionary->LookupClassDef(AUID_AAFSequence, &pCDSequence)); check(pDictionary->LookupClassDef(AUID_AAFSourceMob, &pCDSourceMob)); check(pDictionary->LookupClassDef(AUID_AAFTapeDescriptor, &pCDTapeDescriptor)); check(pDictionary->LookupClassDef(AUID_AAFAIFCDescriptor, &pCDAIFCDescriptor)); check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator, &pCDNetworkLocator)); check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &pCDMasterMob)); check(pDictionary->LookupClassDef(AUID_AAFSourceClip, &pCDSourceClip)); check(pDictionary->LookupClassDef(AUID_AAFFiller, &pCDFiller)); check(pDictionary->LookupDataDef(kAAFDataDef_Picture, &pDdefPicture)); // IMPORTANT: major remodification is from this point onwards... // sequence creation code pulled out of the subsequent loop. // Create a Composition Mob check(pCDCompositionMob->CreateInstance(IID_IAAFMob, (IUnknown **)&pCompMob)); check(pCDSequence->CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence)); check(pSequence->QueryInterface (IID_IAAFSegment, (void **)&seg)); check(pSequence->QueryInterface(IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pDdefPicture)); aComponent->Release(); aComponent = NULL; check(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->AppendNewTimelineSlot(videoRate, seg, i, slotName, 0, &newSlot)); pMob->Release(); pMob = NULL; newSlot->Release(); newSlot = NULL; seg->Release(); seg = NULL; check(pHeader->AddMob(pCompMob)); // now looping around the remainder N times to make N components for (i=0; i < N; i++) { //Make the Tape MOB check(pCDSourceMob->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pTapeMob)); check(pCDTapeDescriptor->CreateInstance(IID_IAAFTapeDescriptor, (IUnknown **)&pTapeDesc)); check(pTapeDesc->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&aDesc)); check(pTapeMob->SetEssenceDescriptor(aDesc)); aDesc->Release(); aDesc = NULL; pTapeDesc->Release(); pTapeDesc = NULL; check(pTapeMob->AppendTimecodeSlot (videoRate, 0, tapeTC, TAPE_LENGTH)); check(pTapeMob->AddNilReference (1,TAPE_LENGTH, pDdefPicture, videoRate)); check(pTapeMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); pTapeMob->Release(); pTapeMob = NULL; // NOTE: TapeMob name is updated to change with number of objects // requested at cli. // In order to fit with the specification, it is made wide char TapeMobNameBuffer[MAX]; sprintf(TapeMobNameBuffer,"Tape Mob %ld",i); aafWChar TapeMobName[MAX]; mbstowcs(TapeMobName,TapeMobNameBuffer,MAX); check(pMob->SetName (TapeMobName)); check(pHeader->AddMob(pMob)); check(pMob->GetMobID (&tapeMobID)); pMob->Release(); pMob = NULL; // Make a FileMob check(pCDSourceMob->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pFileMob)); check(pCDAIFCDescriptor->CreateInstance(IID_IAAFFileDescriptor, (IUnknown **)&pFileDesc)); check(pFileDesc->QueryInterface (IID_IAAFEssenceDescriptor, (void **)&aDesc)); check(pFileDesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc)); check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST")); pAIFCDesc->Release(); pAIFCDesc = NULL; // Make a locator, and attach it to the EssenceDescriptor check(pCDNetworkLocator->CreateInstance(IID_IAAFNetworkLocator, (IUnknown **)&pNetLocator)); check(pNetLocator->QueryInterface (IID_IAAFLocator, (void **)&pLocator)); check(pLocator->SetPath (TEST_PATH)); check(aDesc->AppendLocator(pLocator)); pLocator->Release(); pLocator = NULL; pNetLocator->Release(); pNetLocator = NULL; check(pFileMob->SetEssenceDescriptor(aDesc)); aDesc->Release(); aDesc = NULL; pFileDesc->Release(); pFileDesc = NULL; sourceRef.sourceID = tapeMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(pFileMob->NewPhysSourceRef (videoRate, 1, pDdefPicture, sourceRef, fileLen)); check(pFileMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID (&fileMobID)); check(pHeader->AddMob(pMob)); pMob->Release(); pMob = NULL; //Make the Master MOB check(pCDMasterMob->CreateInstance(IID_IAAFMasterMob, (IUnknown **)&pMasterMob)); sourceRef.sourceID = fileMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(pMasterMob->NewPhysSourceRef(videoRate, 1, pDdefPicture, sourceRef, fileLen)); check(pMasterMob->QueryInterface (IID_IAAFMob, (void **)&pMob)); check(pMob->GetMobID (&masterMobID)); // NOTE: MasterMob name is updated to change with number of objects // requested at cli. // In order to fit with the specification, it is made wide char MasterMobNameBuffer[MAX]; sprintf(MasterMobNameBuffer,"Master Mob %ld",i); aafWChar MasterMobName[MAX]; mbstowcs(MasterMobName,MasterMobNameBuffer,MAX); check(pMob->SetName (MasterMobName)); check(pHeader->AddMob(pMob)); pMob->Release(); pMob = NULL; // the remaining part of the sequence code, adapted for updating slot names // Create a SourceClip check(pCDSourceClip->CreateInstance(IID_IAAFSourceClip, (IUnknown **)&compSclp)); sourceRef.sourceID = masterMobID; sourceRef.sourceSlotID = 1; sourceRef.startTime = 0; check(compSclp->SetSourceReference (sourceRef)); check(compSclp->QueryInterface (IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pDdefPicture)); check(aComponent->SetLength (segLen)); check(pSequence->AppendComponent (aComponent)); // Create a filler - Get the component interface only (IID_IAAFComponent) check(pCDFiller->CreateInstance(IID_IAAFComponent, (IUnknown **)&compFill)); check(compFill->SetLength (fillLen)); check(compFill->SetDataDef(pDdefPicture)); check(pSequence->AppendComponent (compFill)); compFill->Release(); compFill = NULL; aComponent->Release(); aComponent = NULL; compSclp->Release(); compSclp = NULL; pMasterMob->Release(); pMasterMob = NULL; pFileMob->Release(); pFileMob = NULL; // end of loop since only one dictionary and header are needed // the file is then saved, closed and released after all modifications // are complete } cleanup: // Cleanup and return if (pNetLocator) pNetLocator->Release(); if (pLocator) pLocator->Release(); if (compFill) compFill->Release(); if (compSclp) compSclp->Release(); if (masterSclp) masterSclp->Release(); if (fileSclp) fileSclp->Release(); if (pTapeDesc) pTapeDesc->Release(); if (pFileDesc) pFileDesc->Release(); if (pTapeMob) pTapeMob->Release(); if (pFileMob) pFileMob->Release(); if (pMasterMob) pMasterMob->Release(); if (aDesc) aDesc->Release(); if (newSlot) newSlot->Release(); if (pMob) pMob->Release(); if (pCompMob) pCompMob->Release(); if (seg) seg->Release(); if (aComponent) aComponent->Release(); if (pSequence) pSequence->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pCDCompositionMob) { pCDCompositionMob->Release(); pCDCompositionMob = 0; } if (pCDSequence) { pCDSequence->Release(); pCDSequence = 0; } if (pCDSourceMob) { pCDSourceMob->Release(); pCDSourceMob = 0; } if (pCDTapeDescriptor) { pCDTapeDescriptor->Release(); pCDTapeDescriptor = 0; } if (pCDAIFCDescriptor) { pCDAIFCDescriptor->Release(); pCDAIFCDescriptor = 0; } if (pCDNetworkLocator) { pCDNetworkLocator->Release(); pCDNetworkLocator = 0; } if (pCDMasterMob) { pCDMasterMob->Release(); pCDMasterMob = 0; } if (pCDSourceClip) { pCDSourceClip->Release(); pCDSourceClip = 0; } if (pCDFiller) { pCDFiller->Release(); pCDFiller = 0; } if (pDdefPicture) { pDdefPicture->Release(); pDdefPicture = 0; } if (pFile) { clock_t start = clock(); clock_t finish; double duration; pFile->Save(); pFile->Close(); #if defined(USE_MEMORY_FILE) check(MemoryFileSaveToDisk(pFileName, pFile)); #endif finish = clock(); duration = ((double) (finish - start) / CLOCKS_PER_SEC); pFile->Release(); printf("Save time = %f seconds\n", duration); } return moduleErrorTmp; }
static HRESULT ProcessAAFFile(const aafWChar * pFileName, testType_t testType) { IAAFFile * pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary* pDictionary = NULL; IEnumAAFMobs* pMobIter = NULL; aafNumSlots_t numMobs, numSlots; aafSearchCrit_t criteria; aafMobID_t mobID; aafWChar namebuf[1204]; const aafWChar* slotName = L"A slot in Composition Mob"; IAAFComponent* pComponent = NULL; IAAFComponent* aComponent = NULL; IEnumAAFMobSlots* pMobSlotIter = NULL; IAAFMobSlot* pMobSlot = NULL; IAAFTimelineMobSlot* newSlot = NULL; IAAFSegment* seg = NULL; IAAFSegment* pSegment = NULL; IAAFMob* pCompMob = NULL; IAAFMob* pMob = NULL; aafPosition_t zeroPos = 0; IAAFSequence* pAudioSequence = NULL; IAAFSourceClip* pSourceClip = NULL; aafLength_t duration; IAAFTimelineMobSlot* pTimelineMobSlot = NULL; IAAFClassDef *pCompositionMobDef = NULL; IAAFClassDef *pSequenceDef = NULL; IAAFClassDef *pSourceClipDef = NULL; IAAFDataDef *pSoundDef = NULL; IAAFDataDef *pDataDef = NULL; // Set the edit rate information aafRational_t editRate; editRate.numerator = 48000; editRate.denominator = 1; // Set search condition to true bool lookingForAudio = true; // Call the routine (from ExportAudioExample) to make the file for processing check(CreateAAFFile(pwFileName, NULL, testStandardCalls, &pFile)); /* Get the Header and iterate through the Master Mobs in the existing file */ check(pFile->GetHeader(&pHeader)); check(pHeader->GetDictionary(&pDictionary)); /* Lookup class definitions for the objects we want to create. */ check(pDictionary->LookupClassDef(AUID_AAFCompositionMob, &pCompositionMobDef)); check(pDictionary->LookupClassDef(AUID_AAFSequence, &pSequenceDef)); check(pDictionary->LookupClassDef(AUID_AAFSourceClip, &pSourceClipDef)); /* Lookup any necessary data definitions. */ check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pSoundDef)); // Get the number of master mobs in the existing file (must not be zero) check(pHeader->CountMobs(kAAFMasterMob, &numMobs)); if (numMobs != 0) { printf("Found %d Master Mobs\n", numMobs); criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFMasterMob; check(pHeader->GetMobs(&criteria, &pMobIter)); /* Create a Composition Mob */ check(pCompositionMobDef-> CreateInstance(IID_IAAFMob, (IUnknown **)&pCompMob)); /* Append the Mob to the Header */ check(pHeader->AddMob(pCompMob)); /* Create a TimelineMobSlot with an audio sequence */ check(pSequenceDef-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pAudioSequence)); check(pAudioSequence->QueryInterface(IID_IAAFSegment, (void **)&seg)); check(pAudioSequence->QueryInterface(IID_IAAFComponent, (void **)&aComponent)); check(aComponent->SetDataDef(pSoundDef)); check(pCompMob->AppendNewTimelineSlot(editRate, seg, 1, slotName, zeroPos, &newSlot)); seg->Release(); seg = NULL; newSlot->Release(); newSlot = NULL; // This variable is about to be overwritten so we need to release the old interface aComponent->Release(); aComponent = NULL; while((AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))) { // Print out information about the Mob char mobIDstr[256]; char mobName[256]; check(pMob->GetMobID (&mobID)); check(pMob->GetName (namebuf, sizeof(namebuf))); convert(mobName, sizeof(mobName), namebuf); MobIDtoString(mobID, mobIDstr); printf(" MasterMob Name = '%s'\n", mobName); printf(" (mobID %s)\n", mobIDstr); // Add a Source Clip for each Master Mob to the audio sequence by iterating check(pMob->GetSlots(&pMobSlotIter)); /* Iterating through all Mob Slots */ // Get the number of slots check(pMob->CountSlots(&numSlots)); while (lookingForAudio && (AAFRESULT_SUCCESS == pMobSlotIter->NextOne(&pMobSlot))); { /* Check to see if it is an Audio Timeline Mob Slot */ HRESULT hr; hr=pMobSlot->QueryInterface(IID_IAAFTimelineMobSlot,(void **) &pTimelineMobSlot); if (SUCCEEDED(hr)) { printf("Found a timeline mob slot\n"); check(pMobSlot->GetDataDef(&pDataDef)); // Check that we have a sound file by examining its data definition aafBool bIsSoundKind = kAAFFalse; check(pDataDef->IsSoundKind(&bIsSoundKind)); if (kAAFTrue == bIsSoundKind) { printf("Found a sound file\n"); // We are no longer looking for audio data so set boolean lookingForAudio = false; /* Get the information for the new source clip */ check(pMob->GetMobID(&sourceRef.sourceID)); check(pMobSlot->GetSlotID(&sourceRef.sourceSlotID)); check(pTimelineMobSlot->GetOrigin(&sourceRef.startTime)); check(pMobSlot->GetSegment(&pSegment)); check(pSegment->QueryInterface(IID_IAAFComponent, (void **)&pComponent)); check(pComponent->GetLength(&duration)); pComponent->Release(); pComponent = NULL; pSegment->Release(); pSegment = NULL; // this loop is to be removed upon fixing of the bug // in essenceaccess relating to codec definitions... int j = 0; for (j=0; j<10; j++) { /* Create a new Source Clip */ check(pSourceClipDef-> CreateInstance(IID_IAAFSourceClip, (IUnknown **)&pSourceClip)); // Initialize the Source Clip check(pSourceClip->Initialize( pSoundDef, duration, sourceRef)); check(pSourceClip->QueryInterface(IID_IAAFComponent, (void **) &pComponent)); check(pAudioSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; pSourceClip->Release(); pSourceClip = NULL; } } pTimelineMobSlot->Release(); pTimelineMobSlot = NULL; pDataDef->Release(); pDataDef = NULL; } pMobSlot->Release(); pMobSlot = NULL; } pMobSlotIter->Release(); pMobSlotIter = NULL; pMob->Release(); pMob = NULL; } pAudioSequence->Release(); pAudioSequence = NULL; pCompMob->Release(); pCompMob = NULL; pMobIter->Release(); pMobIter = NULL; } else { printf("Error with file: File has no Master mobs.\n"); } cleanup: // Cleanup and return if (pSourceClip) pSourceClip->Release(); if (pComponent) pComponent->Release(); if (pSegment) pSegment->Release(); if (pTimelineMobSlot) pTimelineMobSlot->Release(); if (pMobSlotIter) pMobSlotIter->Release(); if (pMob) pMob->Release(); if (newSlot) newSlot->Release(); if (aComponent) aComponent->Release(); if (seg) seg->Release(); if (pAudioSequence) pAudioSequence->Release(); if (pCompMob) pCompMob->Release(); if (pMobIter) pMobIter->Release(); if (pDataDef) pDataDef->Release(); if (pSoundDef) pSoundDef->Release(); if (pSourceClipDef) pSourceClipDef->Release(); if (pSequenceDef) pSequenceDef->Release(); if (pCompositionMobDef) pCompositionMobDef->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { /* Save the AAF file */ pFile->Save(); /* Close the AAF file */ pFile->Close(); pFile->Release(); } return moduleErrorTmp; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { IAAFFile* pFile = NULL; IAAFHeader* pHeader = NULL; IAAFDictionary* pDictionary = NULL; IAAFMob* pMob = NULL; IAAFTimelineMobSlot* pMobSlot = NULL; IAAFSequence* pSequence = NULL; IAAFSegment* pSegment = NULL; IAAFComponent* pComponent = NULL; int i; HRESULT hr = S_OK; try { // Remove the previous test file if any. RemoveTestFile(pFileName); // Create the AAF file checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); // We can't really do anthing in AAF without the header. checkResult(pFile->GetHeader(&pHeader)); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Create a Composition Mob checkResult(defs.cdCompositionMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&pMob)); checkResult(pMob->SetMobID(TEST_MobID)); checkResult(pMob->SetName(L"EnumAAFDataDefTest")); // Add mob slot w/ Sequence checkResult(defs.cdSequence()-> CreateInstance(IID_IAAFSequence, (IUnknown **)&pSequence)); checkResult(pSequence->Initialize(defs.ddkAAFPicture())); // // Add some segments. Need to test failure conditions // (i.e. starting/ending w/ transition, two trans back // to bacl). // for(i = 0; i < kNumComponents; i++) { aafLength_t len = 10; checkResult(defs.cdFiller()-> CreateInstance(IID_IAAFComponent, (IUnknown **)&pComponent)); if(i == 0) { checkResult(pComponent->SetDataDef(defs.ddkAAFPictureWithMatte())); } else { checkResult(pComponent->SetDataDef(defs.ddkAAFPicture())); } checkResult(pComponent->SetLength(len)); checkResult(pSequence->AppendComponent(pComponent)); pComponent->Release(); pComponent = NULL; } checkResult(pSequence->QueryInterface (IID_IAAFSegment, (void **)&pSegment)); aafRational_t editRate = { 0, 1}; checkResult(pMob->AppendNewTimelineSlot(editRate, pSegment, 1, L"AAF Test Sequence", 0, &pMobSlot)); pMobSlot->Release(); pMobSlot = NULL; pSegment->Release(); pSegment = NULL; // Add the master mob to the file and cleanup pHeader->AddMob(pMob); } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return if (pMobSlot) pMobSlot->Release(); if (pSegment) pSegment->Release(); if (pComponent) pComponent->Release(); if (pSequence) pSequence->Release(); if (pMob) pMob->Release(); if (pDictionary) pDictionary->Release(); if (pHeader) pHeader->Release(); if (pFile) { pFile->Save(); pFile->Close(); pFile->Release(); } return hr; }