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;
  }
}
Example #2
0
void EssenceDataTest::createFileMob(unsigned int mobid_Index)
{
  assert(_pFile && _pHeader && _pDictionary);
  assert(NULL == _pSourceMob);
  assert(NULL == _pMob);
  assert(NULL == _pFileDescriptor);
  assert(NULL == _pEssenceDescriptor);
  assert(NULL == _pSourceMob);

  CAAFBuiltinDefs defs (_pDictionary);

  // Create a Mob
  check(defs.cdSourceMob()->CreateInstance(IID_IAAFSourceMob, 
										   (IUnknown **)&_pSourceMob));

  check(_pSourceMob->QueryInterface (IID_IAAFMob, (void **)&_pMob));
  
  check(_pMob->SetMobID(TEST_MobIDs[mobid_Index]));
  check(_pMob->SetName(L"EssenceDataTest File Mob"));
  
  // instantiate a concrete subclass of FileDescriptor
  check(defs.cdAIFCDescriptor()->
		CreateInstance(IID_IAAFFileDescriptor,
					   (IUnknown **)&_pFileDescriptor));

	IAAFAIFCDescriptor*			pAIFCDesc = NULL;
	check(_pFileDescriptor->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
	check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST"));
	pAIFCDesc->Release();
	pAIFCDesc = NULL;

  check(_pFileDescriptor->QueryInterface (IID_IAAFEssenceDescriptor,
                                          (void **)&_pEssenceDescriptor));
  check(_pSourceMob->SetEssenceDescriptor (_pEssenceDescriptor));

  check(_pHeader->AddMob(_pMob));

  createEssenceData(_pSourceMob);

  // Cleanup instance data for reuse...
  _pEssenceDescriptor->Release();
  _pEssenceDescriptor = NULL;

  _pFileDescriptor->Release();
  _pFileDescriptor = NULL;

  _pMob->Release();
  _pMob = NULL;

  _pSourceMob->Release();
  _pSourceMob = NULL;
}
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*				pFile = NULL;
	IAAFHeader*				pHeader = NULL;
	IAAFDictionary*			pDictionary = NULL;
	IAAFSourceMob*			pSourceMob = NULL;
	IAAFMob*				pMob = NULL;
	IAAFDataEssenceDescriptor*		pDataEssenceDesc = NULL;
	IAAFEssenceDescriptor*	pEssDesc = NULL;

	HRESULT			hr = AAFRESULT_SUCCESS;


	try
	{
		// Remove the previous test file if any.
		RemoveTestFile(pFileName);


		// Create the AAF file
		checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));

		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
 		
		// Create a source mob
		CAAFBuiltinDefs defs (pDictionary);
		checkResult(defs.cdSourceMob()->
					CreateInstance(IID_IAAFSourceMob, 
								   (IUnknown **)&pSourceMob));

		checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob));

		checkResult(pMob->SetMobID(TEST_MobID));
		
		RegisterDataEssenceDescriptorTest( pDictionary );

		checkResult(pMob->SetName(L"DataEssenceDescriptorTest"));
		checkResult( pDictionary->CreateInstance( TestDataEssenceDescriptorClassID,
							   IID_IAAFDataEssenceDescriptor,
							   (IUnknown**)&pDataEssenceDesc ) );		

		aafUID_t		dataEssenceCoding;
   		memset(&dataEssenceCoding, 0, sizeof(aafUID_t));
		checkResult(pDataEssenceDesc->SetDataEssenceCoding(dataEssenceCoding));
		
		checkResult(pDataEssenceDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc));
		checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc));

		// Add the MOB to the file
		checkResult(pHeader->AddMob(pMob));
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	
  
	// Cleanup and return
	if (pEssDesc)
		pEssDesc->Release();

	if (pDataEssenceDesc)
		pDataEssenceDesc->Release();

	if (pMob)
		pMob->Release();

	if (pSourceMob)
		pSourceMob->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();

	if (pFile)
	{
		pFile->Save();
		pFile->Close();
		pFile->Release();
	}

	return hr;
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile *			pFile = NULL;
	bool				bFileOpen = false;
	IAAFHeader *        pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IAAFMob*			pMob = NULL;
	IAAFRIFFChunk*		pRIFFChunk = NULL;
	IAAFSourceMob*				pSourceMob = NULL;
	IAAFEssenceDescriptor*		pEssDesc = NULL;
	IAAFBWFImportDescriptor*			pBWFImportDesc = NULL;
	aafUInt32			byteswritten;
	aafUInt32			bBytesWrote = 0;
	HRESULT				hr = S_OK;



		// Remove the previous test file if any.
		RemoveTestFile(pFileName);

		// Create the file.
		checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
		bFileOpen = true;
 
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		CAAFBuiltinDefs defs (pDictionary);
 		
		checkResult(defs.cdSourceMob()->
			  CreateInstance(IID_IAAFSourceMob, 
							 (IUnknown **)&pSourceMob));
		pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob);
	
		pMob->SetMobID(TEST_MobID);
		pMob->SetName(L"RIFFChunkTest");
		
		//Create BWFImportDescriptor to hold the RIFFChunk
		checkResult( defs.cdBWFImportDescriptor()->
					  CreateInstance(IID_IAAFBWFImportDescriptor, (IUnknown **)&pBWFImportDesc));
					 
		// Create RIFFChunk and add it to BWFImportDescriptor

		checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk, 
							 (IUnknown **)&pRIFFChunk));
		checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk));
								 
		checkResult( pBWFImportDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc));
		checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc));
		
		//Add the MOB to the file
		checkResult(pHeader->AddMob(pMob));

		bBytesWrote = 0;
		checkResult(pRIFFChunk->Initialize(chunkID));
		checkResult(pRIFFChunk->Write(sizeof(RIFFChunksmiley), (unsigned char *)RIFFChunksmiley, &bBytesWrote));
		byteswritten = bBytesWrote;
		bBytesWrote = 0;
		checkResult(pRIFFChunk->Write(sizeof(RIFFChunkfrowney), (unsigned char *)RIFFChunkfrowney, &bBytesWrote));
		byteswritten += bBytesWrote;
		checkExpression(byteswritten == sizeof(RIFFChunksmiley) + sizeof(RIFFChunkfrowney), AAFRESULT_TEST_FAILED);
		
		pFile->Save();

		pEssDesc->Release();
		pEssDesc = NULL;		
		pBWFImportDesc->Release();
		pBWFImportDesc = NULL;
		
		pRIFFChunk->Release();
		pRIFFChunk = NULL;
	
		pMob->Release();
		pMob = NULL;
	
		pSourceMob->Release();
		pSourceMob = NULL;

		pDictionary->Release();
		pDictionary = NULL;

		pHeader->Release();
		pHeader = NULL;


		pFile->Close();	
		pFile->Release();
		pFile = NULL;
		
	return hr;

}
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	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;

}
Example #8
0
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;
}
Example #9
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	IAAFFile*				pFile = NULL;
	IAAFHeader*				pHeader = NULL;
	IEnumAAFMobs*			pMobIter = NULL;
	IAAFMob*				pMob = NULL;
	IAAFSourceMob*			pSourceMob = NULL;
	IAAFEssenceDescriptor*	pEssDesc = NULL;
	IAAFTIFFDescriptor*		pTIFFDesc = NULL;
	aafNumSlots_t			numMobs = 0;
	HRESULT					hr = AAFRESULT_SUCCESS;
	aafBool					isContiguous, isUniform;
	aafInt32				leadingLines, trailingLines;
	aafUInt32				size;
	aafUInt8				summary[512];

	try
	{
		// 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));
		
		checkResult(pEssDesc->QueryInterface(IID_IAAFTIFFDescriptor, (void **)&pTIFFDesc));
		checkResult(pTIFFDesc->GetIsContiguous(&isContiguous));
		checkResult(pTIFFDesc->GetIsUniform(&isUniform));
		checkResult(pTIFFDesc->GetLeadingLines(&leadingLines));
		checkResult(pTIFFDesc->GetTrailingLines(&trailingLines));
		checkResult(pTIFFDesc->GetSummaryBufferSize(&size));
		checkExpression(size == 34, AAFRESULT_TEST_FAILED);
		checkResult(pTIFFDesc->GetSummary(size, summary));
		checkExpression(isContiguous == kAAFTrue, AAFRESULT_TEST_FAILED);
		checkExpression(isUniform == kAAFFalse, AAFRESULT_TEST_FAILED);
		checkExpression(leadingLines == 10, AAFRESULT_TEST_FAILED);
		checkExpression(trailingLines == 20, AAFRESULT_TEST_FAILED);
// The next statement is not true when doing cross-platform tests
//#if defined( OS_WINDOWS )
//		checkExpression(memcmp(summary, "II", 2) == 0, AAFRESULT_TEST_FAILED);
//#else
//		checkExpression(memcmp(summary, "MM", 2) == 0, AAFRESULT_TEST_FAILED);
//#endif

    // NOTE: The elements in the summary structure need to be byte swapped
		//       on Big Endian system (i.e. the MAC).
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	
  
	// Cleanup and return
	if (pEssDesc)
		pEssDesc->Release();

	if (pTIFFDesc)
		pTIFFDesc->Release();

	if (pMob)
		pMob->Release();

	if (pSourceMob)
		pSourceMob->Release();

	if (pHeader)
	    pHeader->Release();

	if (pMobIter)
	    pMobIter->Release();

	if (pFile)
	{
		pFile->Close();
		pFile->Release();
	}

	return hr;
}
Example #10
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*				pFile = NULL;
	IAAFHeader*				pHeader = NULL;
	IAAFDictionary*			pDictionary = NULL;
	IAAFSourceMob*			pSourceMob = NULL;
	IAAFMob*				pMob = NULL;
	IAAFTIFFDescriptor*		pTIFFDesc = NULL;
	IAAFEssenceDescriptor*	pEssDesc = NULL;
	HRESULT					hr = AAFRESULT_SUCCESS;
	aafUInt8				summary[512];
	aafUInt16				numEntries = 2;
	unsigned long			nOffset;

#if defined( OS_WINDOWS )
	tiffHeader.tiff_byteOrder = TIFF_LITTLEENDIAN;
#else
	tiffHeader.tiff_byteOrder = TIFF_BIGENDIAN;
#endif
	tiffHeader.tiff_identNumber = TIFF_VERSION;
	tiffHeader.tiff_firstIFD = 0;
	
	memcpy(summary, (void *)&tiffHeader, sizeof(tiffHeader));
	nOffset = sizeof(tiffHeader);

	tagImageWidth.tdir_tag = TIFFTAG_IMAGEWIDTH;
	tagImageWidth.tdir_type = TIFF_LONG;
	tagImageWidth.tdir_count = 1;
	tagImageWidth.tdir_offset = 320;

	tagImageLength.tdir_tag = TIFFTAG_IMAGELENGTH;
	tagImageLength.tdir_type = TIFF_LONG;
	tagImageLength.tdir_count = 1;
	tagImageLength.tdir_offset = 640;

	// Write IFD data
	memcpy(summary+nOffset, &numEntries, sizeof(numEntries));
	nOffset += sizeof(numEntries);
	memcpy((void *)(summary+nOffset), (void *)&tagImageWidth, sizeof(tagImageWidth));
	nOffset += sizeof(tagImageWidth);
	memcpy((void *)(summary+nOffset), (void *)&tagImageLength, sizeof(tagImageLength));
	nOffset += sizeof(tagImageLength);

	try
	{
		// Remove the previous test file if any.
		RemoveTestFile(pFileName);


		// Create the AAF file
		checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));

		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		CAAFBuiltinDefs defs (pDictionary);
 		
		// Create a source mob
		checkResult(defs.cdSourceMob()->
					CreateInstance(IID_IAAFSourceMob, 
								   (IUnknown **)&pSourceMob));
		checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob));

		checkResult(pMob->SetMobID(TEST_MobID));
		checkResult(pMob->SetName(L"TIFFDescriptorTest"));
		checkResult(defs.cdTIFFDescriptor()->
					CreateInstance(IID_IAAFTIFFDescriptor, 
								   (IUnknown **)&pTIFFDesc));		
		checkResult(pTIFFDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc));
		checkResult(pTIFFDesc->SetIsUniform(kAAFFalse));
		checkResult(pTIFFDesc->SetIsContiguous(kAAFTrue));
		checkResult(pTIFFDesc->SetLeadingLines((aafInt32)10));
		checkResult(pTIFFDesc->SetTrailingLines((aafInt32)20));
		checkResult(pTIFFDesc->SetJPEGTableID((aafJPEGTableID_t)0));
		checkResult(pTIFFDesc->SetSummary((aafUInt32)nOffset, (aafDataValue_t) summary));

		checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc));

		// Add the MOB to the file
		checkResult(pHeader->AddMob(pMob));
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	
  
	// Cleanup and return
	if (pTIFFDesc)
	   pTIFFDesc->Release();

	if (pDictionary)
	   pDictionary->Release();

	if (pEssDesc)
		pEssDesc->Release();

	if (pMob)
		pMob->Release();

	if (pSourceMob)
		pSourceMob->Release();

	if (pHeader)
		pHeader->Release();

	if (pFile)
	{
		pFile->Save();
		pFile->Close();
		pFile->Release();
	}

	return hr;
}
Example #11
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
    IAAFFile *					pFile = NULL;
    bool bFileOpen = false;
    IAAFHeader *				pHeader = NULL;
    IAAFDictionary*  pDictionary = NULL;
    IAAFContainerDef*  pContainer = NULL;
    IAAFSourceMob	*pSourceMob = NULL;
    IAAFMob			*pMob = NULL;
    IAAFEssenceDescriptor *edesc = NULL;
    IAAFFileDescriptor *pFileDesc = NULL;
    IAAFFileDescriptor2 *pFileDesc2 = NULL;

    HRESULT						hr = S_OK;

    try
    {
        // Remove the previous test file if any.
        RemoveTestFile(pFileName);


        // Create the file
        checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
        bFileOpen = true;

        // We can't really do anthing in AAF without the header.
        checkResult(pFile->GetHeader(&pHeader));

        // Get the AAF Dictionary so that we can create valid AAF objects.
        checkResult(pHeader->GetDictionary(&pDictionary));
        CAAFBuiltinDefs defs (pDictionary);

        //Make the first mob
        long			test;
        aafRational_t	audioRate = { 44100, 1 };

        // Create a Mob
        checkResult(defs.cdSourceMob()->
                    CreateInstance(IID_IAAFSourceMob,
                                   (IUnknown **)&pSourceMob));

        checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob));

        checkResult(pMob->SetMobID(TEST_MobID));
        checkResult(pMob->SetName(L"FileDescriptorTest"));

        // Add some slots
        for(test = 0; test < 2; test++)
        {
            checkResult(pSourceMob->AddNilReference (test+1, 0, defs.ddkAAFSound(), audioRate));
        }

        // Create a concrete subclass of FileDescriptor
        checkResult(defs.cdAIFCDescriptor()->
                    CreateInstance(IID_IAAFEssenceDescriptor,
                                   (IUnknown **)&edesc));

        IAAFAIFCDescriptor*			pAIFCDesc = NULL;
        checkResult(edesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
        checkResult(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST"));
        pAIFCDesc->Release();
        pAIFCDesc = NULL;

        checkResult(edesc->QueryInterface(IID_IAAFFileDescriptor, (void **) &pFileDesc));
        checkResult(pFileDesc->SetSampleRate (checkSampleRate));
        checkResult(pDictionary->LookupContainerDef(checkContainer, &pContainer));
        checkResult(pFileDesc->SetContainerFormat (pContainer));
        pContainer->Release();
        pContainer = NULL;

        checkResult(pFileDesc->SetLength (checkLength));
        checkResult(pFileDesc->QueryInterface(IID_IAAFFileDescriptor2, (void **)&pFileDesc2));
        checkResult(pFileDesc2->SetLinkedSlotID (checkLinkedSlotID));
//		checkResult(pFileDesc->SetIsInContainer (kAAFTrue));

        checkResult(pSourceMob->SetEssenceDescriptor (edesc));

        checkResult(pHeader->AddMob(pMob));

    }
    catch (HRESULT& rResult)
    {
        hr = rResult;
    }

    if (pFileDesc)
        pFileDesc->Release();

    if (pFileDesc2)
        pFileDesc2->Release();

    if (edesc)
        edesc->Release();

    if (pMob)
        pMob->Release();

    if (pSourceMob)
        pSourceMob->Release();

    if (pDictionary)
        pDictionary->Release();

    if (pHeader)
        pHeader->Release();

    if (pFile)
    {
        if (bFileOpen)
        {
            pFile->Save();
            pFile->Close();
        }
        pFile->Release();
    }

    return hr;
}
Example #12
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
    // IAAFSession *				pSession = NULL;
    IAAFFile *					pFile = NULL;
    bool bFileOpen = false;
    IAAFHeader *				pHeader = NULL;
    IEnumAAFMobs *mobIter = NULL;
    IAAFContainerDef*  pContainer = NULL;
    IAAFDefObject	*  pDef = NULL;
    IAAFEssenceDescriptor		*pEdesc = NULL;
    IAAFSourceMob				*pSourceMob = NULL;
    IAAFMob			*aMob = NULL;
    IEnumAAFMobSlots	*slotIter = NULL;
    IAAFMobSlot		*slot = NULL;
    IAAFFileDescriptor *pFileDesc = NULL;
    IAAFFileDescriptor2 *pFileDesc2 = NULL;
    aafNumSlots_t	numMobs, n, s;
    HRESULT						hr = S_OK;
    aafRational_t				testSampleRate;
    aafUID_t					testContainer;
    aafLength_t					testLength;
    aafUInt32					testLinkedSlotID;
//	aafBool						testBool;


    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, &mobIter));
        for(n = 0; n < numMobs; n++)
        {
            aafWChar		name[500];
            aafNumSlots_t	numSlots;
            aafMobID_t		mobID;
            aafSlotID_t		trackID;

            checkResult(mobIter->NextOne (&aMob));
            checkResult(aMob->GetName (name, sizeof(name)));
            checkResult(aMob->GetMobID (&mobID));

            checkResult(aMob->CountSlots (&numSlots));
            if (2 != numSlots)
                return AAFRESULT_TEST_FAILED;
            if(numSlots != 0)
            {
                checkResult(aMob->GetSlots(&slotIter));

                for(s = 0; s < numSlots; s++)
                {
                    checkResult(slotIter->NextOne (&slot));
                    checkResult(slot->GetSlotID(&trackID));

                    slot->Release();
                    slot = NULL;
                }
            }
            checkResult(aMob->QueryInterface (IID_IAAFSourceMob, (void **)&pSourceMob));
            checkResult(pSourceMob->GetEssenceDescriptor (&pEdesc));
            checkResult(pEdesc->QueryInterface(IID_IAAFFileDescriptor, (void **) &pFileDesc));
            checkResult(pFileDesc->GetSampleRate (&testSampleRate));
            checkExpression(testSampleRate.numerator == checkSampleRate.numerator, AAFRESULT_TEST_FAILED);
            checkExpression(testSampleRate.denominator == checkSampleRate.denominator, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->GetContainerFormat (&pContainer));
            checkResult(pContainer->QueryInterface(IID_IAAFDefObject, (void **) &pDef));
            checkResult(pDef->GetAUID(&testContainer));
            pContainer->Release();
            pContainer = NULL;
            pDef->Release();
            pDef = NULL;
            checkExpression(memcmp(&testContainer, &checkContainer, sizeof(testContainer)) == 0, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->GetLength (&testLength));
            checkExpression(checkLength == testLength, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->QueryInterface(IID_IAAFFileDescriptor2, (void **)&pFileDesc2));
            checkResult(pFileDesc2->GetLinkedSlotID (&testLinkedSlotID));
            checkExpression(checkLinkedSlotID == testLinkedSlotID, AAFRESULT_TEST_FAILED);
//			checkResult(pFileDesc->GetIsInContainer (&testBool));
//			checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED);

            pEdesc->Release();
            pEdesc = NULL;
            pFileDesc->Release();
            pFileDesc = NULL;
            pFileDesc2->Release();
            pFileDesc2 = NULL;
            pSourceMob->Release();
            pSourceMob = NULL;

            aMob->Release();
            aMob = NULL;
        }
    }
    catch (HRESULT& rResult)
    {
        hr = rResult;
    }


    // Cleanup and return
    if (slot)
        slot->Release();

    if (pFileDesc)
        pFileDesc->Release();

    if (pFileDesc2)
        pFileDesc2->Release();

    if (slotIter)
        slotIter->Release();

    if (pEdesc)
        pEdesc->Release();

    if (pSourceMob)
        pSourceMob->Release();

    if (aMob)
        aMob->Release();

    if(mobIter)
        mobIter->Release();

    if (pHeader)
        pHeader->Release();

    if (pFile)
    {
        if (bFileOpen)
            pFile->Close();
        pFile->Release();
    }

    return hr;
}
Example #13
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*		pFile = NULL;
	bool bFileOpen = false;
	IAAFHeader *        pHeader = NULL;
	IAAFDictionary*  pDictionary = NULL;
	IAAFMob*		pMob = NULL;
	IAAFMasterMob*	pMasterMob = NULL;
	IAAFSourceMob* pSrcMob = NULL;
	IAAFSourceMob* pTapeMob = NULL;
	IAAFEssenceDescriptor*	pDesc = NULL;
	IAAFMob*				pTempMob = NULL;
	HRESULT			hr = S_OK;
	long			test;
	aafSourceRef_t	ref;
	IAAFEssenceDescriptor*		pEssDesc = NULL;
	IAAFTapeDescriptor*			pTapeDesc = NULL;
	
	
	try
	{
		// Remove the previous test file if any.
		RemoveTestFile(pFileName);
		
		
		// Create the AAF file
		checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
		bFileOpen = true;
		
		// Get the AAF file header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		
		CAAFBuiltinDefs defs (pDictionary);
		
		// Create a Master Mob
		checkResult(defs.cdMasterMob()->
			CreateInstance(IID_IAAFMob, 
			(IUnknown **)&pMob));
		
		// Set the IAAFMob properties
		checkResult(pMob->SetMobID(TEST_Master_MobID));
		checkResult(pMob->SetName(MobName));
		
		checkResult(pMob->QueryInterface(IID_IAAFMasterMob, (void **) &pMasterMob));
		
		// Create source mob to associate with our MasterMob.
		checkResult(defs.cdSourceMob()->
			CreateInstance(IID_IAAFSourceMob, 
			(IUnknown **)&pTapeMob));		
		hr = defs.cdTapeDescriptor()->
			CreateInstance(IID_IAAFTapeDescriptor, 
			(IUnknown **)&pTapeDesc);		
		if (AAFRESULT_SUCCESS == hr)
		{
			hr = pTapeDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc);
			if (AAFRESULT_SUCCESS == hr)
			{
				hr = pTapeMob->SetEssenceDescriptor(pEssDesc);
				if (AAFRESULT_SUCCESS == hr)
				{
					hr = pTapeDesc->SetTapeManufacturer( Manufacturer );
					if (AAFRESULT_SUCCESS == hr )
					{
						hr = pTapeDesc->SetTapeModel( Model );
						if (AAFRESULT_SUCCESS == hr )
						{
							hr = pTapeDesc->SetTapeFormFactor( FormFactor );
							if (AAFRESULT_SUCCESS == hr )
							{
								hr = pTapeDesc->SetSignalType( VideoSignalType );
								if (AAFRESULT_SUCCESS == hr )
								{
									hr = pTapeDesc->SetTapeFormat( TapeFormat );
									if (AAFRESULT_SUCCESS == hr )
										hr = pTapeDesc->SetTapeLength( TapeLength );
								}
							}
						}
					}
				}
				pEssDesc->Release();
				pEssDesc = NULL;
			}
			pTapeDesc->Release();
			pTapeDesc = NULL;
		}
		for (test = 0; test < NumMobSlots; test++)
		{
			IAAFDataDefSP pDataDef;
			checkResult (pDictionary->LookupDataDef (*slotDDefs[test], &pDataDef));
			checkResult(pTapeMob->AddNilReference (test, TAPE_MOB_LENGTH_ARR[test], pDataDef, slotRates[test]));
		}
		checkResult(pTapeMob->QueryInterface(IID_IAAFMob, (void **) &pTempMob));
		checkResult(pTempMob->SetName(TAPE_MOB_NAME));
		checkResult(pTempMob->SetMobID(tapeMobID));
		//save the id for future (test) reference
//		TAPE_MOB_ID = tapeMobID;

		checkResult(pHeader->AddMob(pTempMob));
		pTempMob->Release();
		pTempMob = NULL;
		
		// Add some slots
		for (test = 0; test < NumMobSlots; test++)
		{
			// Create source mob to associate with our MasterMob.
			checkResult(defs.cdSourceMob()->
				CreateInstance(IID_IAAFSourceMob, 
				(IUnknown **)&pSrcMob));		
			
			ref.sourceID = tapeMobID;
			ref.sourceSlotID = test;
			ref.startTime = TAPE_MOB_OFFSET_ARR[test];
			IAAFDataDefSP pDDef;
			checkResult(pDictionary->LookupDataDef(*slotDDefs[test], &pDDef));
			checkResult(pSrcMob->AppendPhysSourceRef (slotRates[test],
				test,
				pDDef,
				ref,
				TAPE_MOB_LENGTH_ARR[test]));
			
			// Create a concrete subclass of EssenceDescriptor
			checkResult(defs.cdAIFCDescriptor()->
				CreateInstance(IID_IAAFEssenceDescriptor, 
				(IUnknown **)&pDesc));	

			IAAFAIFCDescriptor*			pAIFCDesc = NULL;
			checkResult(pDesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
			checkResult(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST"));
			pAIFCDesc->Release();
			pAIFCDesc = NULL;

			checkResult(pSrcMob->SetEssenceDescriptor(pDesc));
			pDesc->Release();
			pDesc = NULL;
			
			// Append source MOB to header
			checkResult(pSrcMob->QueryInterface(IID_IAAFMob, (void **) &pTempMob));
			checkResult(pTempMob->SetMobID(TEST_Source_MobIDs[test]));
			checkResult(pTempMob->SetName(L"source mob"));
			
			checkResult(pHeader->AddMob(pTempMob));
			pTempMob->Release();
			pTempMob = NULL;
			
			IAAFDataDefSP pDataDef;
			checkResult (pDictionary->LookupDataDef (*slotDDefs[test], &pDataDef));
			checkResult(pMasterMob->AddMasterSlot(pDataDef, test, pSrcMob, test+1, slotNames[test]));
			
			pSrcMob->Release();
			pSrcMob = NULL;
		}
		
		// Add the master mob to the file and cleanup
		checkResult(pHeader->AddMob(pMob));
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	
	
	// Cleanup and return
	if (pTempMob)
		pTempMob->Release();
	
	if (pEssDesc)
		pEssDesc->Release();
	
	if (pTapeDesc)
		pTapeDesc->Release();
	
	
	if (pDesc)
		pDesc->Release();
	
	if (pSrcMob)
		pSrcMob->Release();
	
	if (pTapeMob)
		pTapeMob->Release();
	
	if (pMasterMob)
		pMasterMob->Release();
	
	if (pMob)
		pMob->Release();
	
	if (pDictionary)
		pDictionary->Release();
	
	if (pHeader)
		pHeader->Release();
	
	if (pFile)
	{  // Close file
		if (bFileOpen)
		{
			pFile->Save();
			pFile->Close();
		}
		pFile->Release();
	}
	
	return hr;
}
Example #14
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IAAFSourceMob*				pSourceMob = NULL;
	IAAFMob*					pMob = NULL;
	IAAFEssenceDescriptor*		pEssDesc = NULL;
	IAAFBWFImportDescriptor*	pBWFImportDesc = NULL;
	IEnumAAFRIFFChunks*		pEnum = NULL;
	IAAFRIFFChunk*				pRIFFChunk = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	aafUInt32		numData, bytesRead, com, testID;
	aafLength_t 				testLength, testRIFFLen;
	aafPosition_t				dataPos;
	aafNumSlots_t				numMobs;
	char			Value[sizeof(RIFFChunksmiley)];
	char			Value2[sizeof(RIFFChunkfrowney)];
	HRESULT						hr = AAFRESULT_SUCCESS;

	checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));

		checkResult( pFile->GetHeader(&pHeader));

		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->CountUnknownBWFChunks(&numData));
			
			checkExpression(1 == numData, AAFRESULT_TEST_FAILED);
			
			checkResult(pBWFImportDesc->GetUnknownBWFChunks(&pEnum));
			
			for(com = 0; com < numData; com++)
			{	
				checkResult(pEnum->NextOne(&pRIFFChunk));
				
				checkResult(pRIFFChunk->GetLength(&testRIFFLen));
				checkExpression((sizeof(RIFFChunksmiley)+sizeof(RIFFChunkfrowney)) == testRIFFLen, AAFRESULT_TEST_FAILED);
				checkResult(pRIFFChunk->Read( sizeof(Value), (unsigned char *)Value, &bytesRead));
				checkExpression(memcmp(Value, RIFFChunksmiley, sizeof(RIFFChunksmiley)) == 0, AAFRESULT_TEST_FAILED);
				checkResult(pRIFFChunk->Read( sizeof(Value2), (unsigned char *)Value2, &bytesRead));
				checkExpression(memcmp(Value2, RIFFChunkfrowney, sizeof(RIFFChunkfrowney)) == 0, AAFRESULT_TEST_FAILED);				
				
				checkResult(pRIFFChunk->GetPosition(&dataPos));
				checkExpression(dataPos==(sizeof(RIFFChunksmiley)+sizeof(RIFFChunkfrowney)), AAFRESULT_TEST_FAILED);
				checkResult(pRIFFChunk->SetPosition(0));
				checkResult(pRIFFChunk->Read( sizeof(Value), (unsigned char *)Value, &bytesRead));
				checkExpression(memcmp(Value, RIFFChunksmiley, sizeof(RIFFChunksmiley)) == 0, AAFRESULT_TEST_FAILED);
				
				pRIFFChunk->GetChunkID(&testID);	
				checkExpression(testID==chunkID, AAFRESULT_TEST_FAILED);
				pRIFFChunk->GetLength(&testLength);	
				checkExpression(testLength == sizeof(RIFFChunksmiley) + sizeof(RIFFChunkfrowney), AAFRESULT_TEST_FAILED);
				pRIFFChunk->Release();
				pRIFFChunk = NULL;
			}
			
			pEnum->Release();
			pEnum = NULL;
			pEssDesc->Release();
			pEssDesc = NULL;
								
			pBWFImportDesc->Release();
			pBWFImportDesc = NULL;

			pSourceMob->Release();
			pSourceMob = NULL;
				
			pMobIter->Release();
			pMobIter = NULL;
	
			
		}
		pMob->Release();
		pMob = NULL;
		
		pHeader->Release();
		pHeader = NULL;
		
		pFile->Close();
    	pFile->Release();
		pFile = NULL;

	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;
}
Example #16
0
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;
}
Example #17
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	// IAAFSession *				pSession = NULL;
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IAAFEssenceDescriptor		*pEdesc = NULL;
	IAAFSourceMob				*pSourceMob = NULL;
	IEnumAAFLocators *			pEnum = NULL;
	IAAFLocator	*				pLocator = NULL;
	IEnumAAFMobs *mobIter = NULL;
	IAAFMob			*aMob = NULL;
	aafUInt32					numLocators;
	aafUInt32					readLen;
	aafNumSlots_t	numMobs, n;
	HRESULT						hr = AAFRESULT_SUCCESS;
	aafWChar					readBuf[1024];
	bool bFileOpen = false;


	try
	{	  
    // Open the file.
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;

  	checkResult(pFile->GetHeader(&pHeader));

		checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
		if (1 != numMobs )
			checkResult(AAFRESULT_TEST_FAILED);


	//!!!	aafSearchCrit_t		criteria;
	//!!!	criteria.searchTag = kAAFNoSearch;

		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));
			if (1 != numLocators)
				checkResult(AAFRESULT_TEST_FAILED);
		
			checkResult(pEdesc->GetLocators(&pEnum));

			// This should read the one real locator
			checkResult(pEnum->NextOne(&pLocator));

			checkResult(pLocator->GetPathBufLen (&readLen));
	//		if(readLen != strlen(TEST_PATH))
				
			checkResult(pLocator->GetPath (readBuf, readLen));

		// This should run off the end
			pLocator->Release();
			pLocator = NULL;
			hr = pEnum->NextOne(&pLocator);
			if (AAFRESULT_NO_MORE_OBJECTS != hr)
				checkResult(hr);
			else
				hr = AAFRESULT_SUCCESS; // reset result
		}


	}
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }

	
	// Cleanup...
	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)
	{
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}

	// hr = pSession->EndSession();
	// if (AAFRESULT_SUCCESS != hr)
	//	return hr;

	// if (pSession) pSession->Release();
	
	return 	hr;
}
Example #18
0
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;
}
Example #19
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile *					pFile = NULL;
  bool bFileOpen = false;
	IAAFHeader *				pHeader = NULL;
  IAAFDictionary*  pDictionary = NULL;
	IAAFLocator	*				pLocator = NULL;
	IAAFNetworkLocator *		pNetLocator = NULL;
	IAAFSourceMob	*pSourceMob = NULL;
	IAAFMob			*pMob = NULL;
	IAAFEssenceDescriptor *edesc = NULL;
	aafUInt32					numLocators;
	HRESULT						hr = AAFRESULT_SUCCESS;


	try
	{
	    // Remove the previous test file if any.
	    RemoveTestFile(pFileName);


		// Create the file.
		checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
		bFileOpen = true;
 
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		CAAFBuiltinDefs defs (pDictionary);
 		
		//Make the first mob
		// Create a Mob
		checkResult(defs.cdSourceMob()->
					CreateInstance(IID_IAAFSourceMob, 
								   (IUnknown **)&pSourceMob));

		checkResult(pSourceMob->QueryInterface (IID_IAAFMob, (void **)&pMob));
		checkResult(pMob->SetMobID(TEST_MobID));
		checkResult(pMob->SetName(L"SourceMOBTest"));
		
		// Create a concrete subclass of EssenceDescriptor
		checkResult(defs.cdAIFCDescriptor()->
					CreateInstance(IID_IAAFEssenceDescriptor, 
								   (IUnknown **)&edesc));
										

		IAAFAIFCDescriptor*			pAIFCDesc = NULL;
		checkResult(edesc->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
		checkResult(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST"));
		pAIFCDesc->Release();
		pAIFCDesc = NULL;

			// Verify that there are no locators
		checkResult(edesc->CountLocators(&numLocators));
		checkExpression(0 == numLocators, AAFRESULT_TEST_FAILED);

  
		// Make a locator, and attach it to the EssenceDescriptor
		checkResult(defs.cdNetworkLocator()->
					CreateInstance(IID_IAAFNetworkLocator, 
								   (IUnknown **)&pNetLocator));		
		checkResult(pNetLocator->QueryInterface (IID_IAAFLocator, (void **)&pLocator));

		checkResult(pLocator->SetPath (TEST_PATH));
		
		checkResult(edesc->AppendLocator(pLocator));
 		checkResult(pSourceMob->SetEssenceDescriptor (edesc));

		// Verify that there is now one locator
		checkResult(edesc->CountLocators(&numLocators));
		checkExpression(1 == numLocators, AAFRESULT_TEST_FAILED);

		// Add the source mob into the tree
		checkResult(pHeader->AddMob(pMob));

	}
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }

	// cleanup
	if (pLocator)
		pLocator->Release();

	if (pNetLocator)
		pNetLocator->Release();

	if (edesc)
		edesc->Release();

	if (pMob)
		pMob->Release();

	if (pSourceMob)
		pSourceMob->Release();

  if (pDictionary)
    pDictionary->Release();

	if (pHeader)
		pHeader->Release();

	if (pFile)
	{
		if (bFileOpen)
		  {
			pFile->Save();
			pFile->Close();
		  }
		pFile->Release();
	}
	// hr = pSession->EndSession();
 	// if (AAFRESULT_SUCCESS != hr)
	//	return hr;

	// if (pSession) pSession->Release();


	return hr;
}
static HRESULT 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;
}
Example #21
0
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;
}
Example #22
0
void EnumEssenceDataTest::createFileMob(int itemNumber)
{
  assert(_pFile && _pHeader && _pDictionary);
  assert(NULL == _pSourceMob);
  assert(NULL == _pMob);
  assert(NULL == _pFileDescriptor);
  assert(NULL == _pEssenceDescriptor);
  assert(NULL == _pSourceMob);

  // Format the mob name.
  wchar_t wcBuffer[512];
  char cBuffer[256];
  sprintf(cBuffer, "EnumEssenceDataTest File Mob %d", itemNumber);
  size_t count = mbstowcs(wcBuffer, cBuffer, strlen(cBuffer) + 1);
  if (static_cast<size_t>(-1) == count)
    check(AAFRESULT_INTERNAL_ERROR);


  CAAFBuiltinDefs defs (_pDictionary);
  // Create a Mob
  check(defs.cdSourceMob()->
		CreateInstance(IID_IAAFSourceMob, 
					   (IUnknown **)&_pSourceMob));

  check(_pSourceMob->QueryInterface (IID_IAAFMob, (void **)&_pMob));
  
  check(_pMob->SetMobID(TEST_MobIDs[itemNumber]));
  check(_pMob->SetName(wcBuffer));
  
  // Create a concrete subclass of FileDescriptor
  check(defs.cdAIFCDescriptor()->
		CreateInstance(IID_IAAFFileDescriptor, 
					   (IUnknown **)&_pFileDescriptor));


	IAAFAIFCDescriptor*			pAIFCDesc = NULL;
	check(_pFileDescriptor->QueryInterface (IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
	check(pAIFCDesc->SetSummary (5, (unsigned char*)"TEST"));
	pAIFCDesc->Release();
	pAIFCDesc = NULL;

  check(_pFileDescriptor->QueryInterface (IID_IAAFEssenceDescriptor,
                                          (void **)&_pEssenceDescriptor));
  check(_pSourceMob->SetEssenceDescriptor (_pEssenceDescriptor));

  check(_pHeader->AddMob(_pMob));

  createEssenceData(_pSourceMob);

  // Cleanup instance data for reuse...
  _pEssenceDescriptor->Release();
  _pEssenceDescriptor = NULL;

  _pFileDescriptor->Release();
  _pFileDescriptor = NULL;

  _pMob->Release();
  _pMob = NULL;

  _pSourceMob->Release();
  _pSourceMob = NULL;
}
Example #23
0
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;
	IEnumAAFLocators *			pCloneEnum = NULL;
	IAAFLocator	*				pLocator = NULL;
	aafUInt32					numLocators;
	aafNumSlots_t	numMobs, n;
	HRESULT						hr = AAFRESULT_SUCCESS;
	bool bFileOpen = false;
	wchar_t						testname[256];
	IAAFLocator				*	pArray[2] = { NULL, NULL };
	IAAFLocator				**	pArrayPoint = pArray;
	aafUInt32			resultCount;


	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 two locators
			checkResult(pEdesc->CountLocators(&numLocators));
		  checkExpression(2 == numLocators, AAFRESULT_TEST_FAILED);
		
			checkResult(pEdesc->GetLocators(&pEnum));

			/* Read and check the first element */
			checkResult(pEnum->NextOne(&pLocator));
			checkResult(pLocator->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator1) == 0, AAFRESULT_TEST_FAILED);
			pLocator->Release();
			pLocator = NULL;

			/**/
			/* Read and check the second element */
			checkResult(pEnum->NextOne(&pLocator));
			checkResult(pLocator->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator2) == 0, AAFRESULT_TEST_FAILED);
			pLocator->Release();
			pLocator = NULL;
			/*****/
			
			/* Reset, and check the first element again*/
			checkResult(pEnum->Reset());
			checkResult(pEnum->NextOne(&pLocator));
			checkResult(pLocator->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator1) == 0, AAFRESULT_TEST_FAILED);
			pLocator->Release();
			pLocator = NULL;
			
			/* Reset, Skip, and check the second element again*/
			checkResult(pEnum->Reset());
			checkResult(pEnum->Skip(1));
			checkResult(pEnum->NextOne(&pLocator));
			checkResult(pLocator->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator2) == 0, AAFRESULT_TEST_FAILED);
			pLocator->Release();
			pLocator = NULL;

			/* Reset, and read both elements */
			checkResult(pEnum->Reset());
			checkResult(pEnum->Next (2, (IAAFLocator **)&pArray, &resultCount));
			checkExpression (resultCount == 2, AAFRESULT_TEST_FAILED);
			checkResult(pArrayPoint[0]->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator1) == 0, AAFRESULT_TEST_FAILED);
			pArrayPoint[0]->Release();
			pArrayPoint[0] = NULL;
			
			checkResult(pArrayPoint[1]->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator2) == 0, AAFRESULT_TEST_FAILED);
			pArrayPoint[1]->Release();
			pArrayPoint[1] = NULL;
			
			/* Read one past to make sure that it fails */
			checkExpression(pEnum->NextOne(&pLocator) != AAFRESULT_SUCCESS, AAFRESULT_TEST_FAILED);
			/* Clone the enumerator, and read one element */
			checkResult(pEnum->Clone(&pCloneEnum));
			checkResult(pCloneEnum->Reset());
			checkResult(pCloneEnum->NextOne(&pLocator));
			checkResult(pLocator->GetPath (testname, sizeof(testname)));
			checkExpression(wcscmp(testname, locator1) == 0, AAFRESULT_TEST_FAILED);
			pLocator->Release();
			pLocator = NULL;

			pEnum->Release();
			pEnum = NULL;

			pEdesc->Release();
			pEdesc = NULL;

			pSourceMob->Release();
			pSourceMob = NULL;

			aMob->Release();
			aMob = NULL;
			pCloneEnum->Release();
			pCloneEnum = 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;
}