Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}