예제 #1
0
void EnumEssenceDataTest::openEssenceData()
{
  assert(_pFile && _pHeader);
  assert(NULL == _pEnumEssenceData);
  assert(NULL == _pEssenceData);
  assert(NULL == _pSourceMob);

  aafUInt32 essenceDataCount = 0;
  check(_pHeader->CountEssenceData(&essenceDataCount));
  if (_maxMobCount != essenceDataCount)
    check(AAFRESULT_TEST_FAILED);
 
  check(_pHeader->EnumEssenceData(&_pEnumEssenceData));
  for (aafUInt32 item = 0; item < essenceDataCount; ++item)
  {
    check(_pEnumEssenceData->NextOne(&_pEssenceData));

    // Make sure that the essence data still references
    // a valid mob.
    check(_pEssenceData->GetFileMob(&_pSourceMob));

    _pSourceMob->Release();
    _pSourceMob = NULL;

    _pEssenceData->Release();
    _pEssenceData = NULL;
  }


  _pEnumEssenceData->Release();
  _pEnumEssenceData = NULL;
}
예제 #2
0
void EventTest::Close()
{
  if (_pDictionary)
  {
    _pDictionary->Release();
    _pDictionary = NULL;
  }

  if (_pHeader)
  {
    _pHeader->Release();
    _pHeader = NULL;
  }
  
  if (_pFile)
  {
    if (_bWritableFile)
      checkResult(_pFile->Save());

    checkResult(_pFile->Close());

    _pFile->Release();
    _pFile = NULL;
  }  
}
예제 #3
0
void EventTest::Create(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
  assert(NULL == _pFile);

  // Remove the previous test file if any.
  RemoveTestFile(pFileName);
    
  // Create the file
  checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &_pFile ));
  _bWritableFile = true;

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

  // Get the AAF Dictionary so that we can create valid AAF objects.
  checkResult(_pHeader->GetDictionary(&_pDictionary));

  // Make a text clip.
  CreateEvent();

  // cleanup
  Close();
}
예제 #4
0
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;
  }
}
예제 #5
0
static HRESULT  ReadAAFFile(aafWChar *  pFileName )
{
	HRESULT hr = AAFRESULT_SUCCESS;
	
	IAAFFile* pFile = NULL;
	IAAFHeader * pHeader = NULL;
	IAAFDictionary * pDict = NULL;
	aafBoolean_t  bFileOpen = kAAFFalse;
	
	try
	{
		// Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = kAAFTrue;
		
		checkResult (pFile->GetHeader (&pHeader));
		assert (pHeader);
		checkResult (pHeader->GetDictionary (&pDict));
		assert (pDict);
		
		// Read the mob, slots, etc  to verify the contents ...
		checkResult(verifyContents (pHeader, pDict, kAAFFalse));  //False => NOT minimal testing; i.e. test everything 
		
		
	}//try
	catch (HRESULT & rResult)
	{
		hr = rResult;
	}
	
	if (pDict) pDict->Release();
	if (pHeader) pHeader->Release();
	
	if (bFileOpen && pFile)
	{
		stopGap(pFile->Close());
		pFile->Release();
	}
	
	return hr;
	
}//ReadAAFFile()
예제 #6
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;
}
예제 #7
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	IAAFFile *					pFile = NULL;
	bool bFileOpen = false;
	IAAFHeader *				pHeader = NULL;
	HRESULT						hr = S_OK;

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

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

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


	// Cleanup and return
  if (pHeader)
		pHeader->Release();
			
	if (pFile)
	{	// Close file
		if (bFileOpen)
			pFile->Close();
 		pFile->Release();
	}

	return hr;
}
예제 #8
0
void EnumEssenceDataTest::createFile(const wchar_t *pFileName)
{
  // Remove the previous test file if any.
  removeTestFile(pFileName);


  check(CreateTestFile( pFileName, _fileKind, _rawStorageType, _productInfo, &_pFile ));
  _bFileOpen = true;
  check(_pFile->GetHeader(&_pHeader));
  check(_pHeader->GetDictionary(&_pDictionary));

  for (aafUInt32 item = 0; item < _maxMobCount; ++item)
    createFileMob(item);
 
  check(_pFile->Save());

  cleanupReferences();
}
예제 #9
0
void EnumEssenceDataTest::createEssenceData(IAAFSourceMob *pSourceMob)
{
  assert(_pFile && _pHeader && _pDictionary);
  assert(pSourceMob);
  assert(NULL == _pEssenceData);

  CAAFBuiltinDefs defs (_pDictionary);

  // Attempt to create an AAFEssenceData.
  check(defs.cdEssenceData()->
		CreateInstance(IID_IAAFEssenceData,
					   (IUnknown **)&_pEssenceData));

  check(_pEssenceData->SetFileMob(pSourceMob));
  check(_pHeader->AddEssenceData(_pEssenceData));

  _pEssenceData->Release();
  _pEssenceData = NULL;
}
예제 #10
0
void EssenceDataTest::createFile(
    wchar_t *pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType)
{
  // Delete the test file if it already exists.
  remove(convert(pFileName));

  check(CreateTestFile( pFileName, fileKind, rawStorageType, _productInfo, &_pFile ));
  _bFileOpen = true;
  check(_pFile->GetHeader(&_pHeader));
  check(_pHeader->GetDictionary(&_pDictionary));

  createFileMob(0); //use unique mobid's (without using cocreate guid()
  createFileMob(1); //use unique mobid's (without using cocreate guid()

  check(_pFile->Save());

  cleanupReferences();
}
예제 #11
0
void HTMLClipTest::Create(wchar_t *pFileName, aafProductIdentification_t* pinfo)
{
  assert(NULL == _pFile);

  // Remove the previous test file if any.
  RemoveTestFile(pFileName);
    
  // Create the file
  checkResult(AAFFileOpenNewModify(pFileName, 0, pinfo, &_pFile));
  _bWritableFile = true;

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

  // Get the AAF Dictionary so that we can create valid AAF objects.
  checkResult(_pHeader->GetDictionary(&_pDictionary));

  // Make a html clip.
  CreateHTMLClip();

  // cleanup
  Close();
}
예제 #12
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader *		pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
/*	long				test;
*/

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


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

	// Get the AAF file header.
	checkResult(pFile->GetHeader(&pHeader));

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

	checkResult(defs.cdContainerDef()->
				CreateInstance(IID_IAAFContainerDef, 
							   (IUnknown **)&pContainerDef));
    
	checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

	checkResult(pContainerDef->Initialize (testUID, sName, sDescription));
	checkResult(pDictionary->RegisterContainerDef(pContainerDef));


	//
	// test Append, Prepend, and enum plugin descriptor using same type def
	//
	IAAFPluginDescriptorSP pd1;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd1));
	checkResult (pd1->Initialize (kTestPluginDescID1,
							L"PluginDesc1",
							L"Plugin Descriptor 1 description"));
	checkResult(pd1->SetDefinitionObjectID(kTestPluginDescID1));
		checkResult (pDictionary->RegisterPluginDef (pd1));

	IAAFPluginDescriptorSP pd2;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd2));
	checkResult (pd2->Initialize (kTestPluginDescID2,
							L"PluginDesc2",
							L"Plugin Descriptor 2 description"));
	checkResult(pd2->SetDefinitionObjectID(kTestPluginDescID2));
	checkResult (pDictionary->RegisterPluginDef (pd2));

	IAAFPluginDescriptorSP pd3;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd3));
	checkResult (pd3->Initialize (kTestPluginDescID3,
							L"PluginDesc3",
							L"Plugin Descriptor 3 description"));
	checkResult(pd3->SetDefinitionObjectID(kTestPluginDescID3));
	checkResult (pDictionary->RegisterPluginDef (pd3));
  }
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }


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

  if (pContainerDef)
    pContainerDef->Release();

  if (pDictionary)
    pDictionary->Release();

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

  return hr;
}
예제 #13
0
static HRESULT ReadAAFFile(const aafWChar * pFileName, testType_t testType)
{
  IAAFFile *					pFile = NULL;
  IAAFHeader *				pHeader = NULL;
  IAAFDictionary*					pDictionary = NULL;
  IAAFEssenceAccess*			pEssenceAccess = NULL;
  IAAFEssenceMultiAccess*		pMultiEssence = NULL;
  IAAFEssenceFormat			*fmtTemplate =  NULL;
  IEnumAAFMobs*				pMobIter = NULL;
  IAAFMob*					pMob = NULL;
  IAAFMasterMob*				pMasterMob = NULL;
  IAAFEssenceFormat*			pFormat = NULL;

  aafNumSlots_t				numMobs, numSlots;
  aafSearchCrit_t				criteria;
  aafRational_t				readSampleRate;
  aafMobID_t					mobID;
  aafWChar					namebuf[1204];
  unsigned char				AAFDataBuf[4096];
  aafUInt32					AAFBytesRead, samplesRead;
  FILE*						pWavFile = NULL;
  unsigned char				WAVDataBuf[4096], *dataPtr;
  size_t						WAVBytesRead;
  aafUInt32					dataOffset, dataLen;
  aafUInt16					bitsPerSample, numCh;

  check(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
  check(pFile->GetHeader(&pHeader));

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


  // Here we check on the number of mobs in the file. 
  // Get the number of master mobs in the file (should be one)
  check(pHeader->CountMobs(kAAFMasterMob, &numMobs));
  // ** causes leak

  if (1 == numMobs )
    {
      printf("Found %d Master Mobs\n", numMobs);
      criteria.searchTag = kAAFByMobKind;
      criteria.tags.mobKind = kAAFMasterMob;
      check(pHeader->GetMobs(&criteria, &pMobIter));
      while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
	{
	  char mobIDstr[256];
	  char mobName[256];


	  check(pMob->GetMobID (&mobID));
	  check(pMob->GetName (namebuf, sizeof(namebuf)));
	  convert(mobName, sizeof(mobName), namebuf);
	  MobIDtoString(mobID, mobIDstr);
	  printf("    MasterMob Name = '%s'\n", mobName);
	  printf("        (mobID %s)\n", mobIDstr);
	  // Make sure we have two slots 
	  check(pMob->CountSlots(&numSlots));
	  if (2 == numSlots)
	    {
				// The essence data is in SlotID 1
				// Get a Master Mob interface
	      check(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob));

				// Open the Essence Data
	      check(pMasterMob->OpenEssence(	1,     // SlotID 1
						NULL,  // mediaCriteria (Don't care)
						kAAFMediaOpenReadOnly,	// Open mode
						kAAFCompressionDisable,// Compress disabled
						&pEssenceAccess));

				// Open and read the Wave file (for comparison)
	      pWavFile = fopen("Laser.wav", "r");
	      if (pWavFile)
		{
		  // read in the essence data
		  WAVBytesRead = fread(WAVDataBuf, sizeof(unsigned char), sizeof(WAVDataBuf), pWavFile);
		  fclose(pWavFile);
		  pWavFile = NULL;
		  check(loadWAVEHeader(WAVDataBuf,
				       &bitsPerSample,
				       &numCh,
				       &readSampleRate,
				       &dataOffset,
				       &dataLen));
		  dataPtr = WAVDataBuf + dataOffset;

		  aafUInt32			sampleBits;
		  aafInt32			bytesRead;
					
		  check(pEssenceAccess->GetEmptyFileFormat (&fmtTemplate));
		  check(fmtTemplate->AddFormatSpecifier (kAAFAudioSampleBits, 0, NULL));
		  check(pEssenceAccess->GetFileFormat (fmtTemplate, &pFormat));
		  fmtTemplate->Release();
		  fmtTemplate = NULL;
					
		  check(pFormat->GetFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleBits),
						     (aafDataBuffer_t)&sampleBits, &bytesRead));
		  pFormat->Release();
		  pFormat = NULL;
		  if(sampleBits != bitsPerSample)
		    {
		      printf("***Wrong sample size read ( was %d , should be %d)\n",
			     sampleBits, bitsPerSample);
		    }

		  // Read the Data from the AAF file
		  if(testType == testStandardCalls)
		    {
		      check(pEssenceAccess->ReadSamples( dataLen, //!!! Hardcoded	// Number of Samples 
							 sizeof(AAFDataBuf),	// Maximum buffer size
							 AAFDataBuf,	  // Buffer for the data
							 &samplesRead,      // Actual number of samples read
							 &AAFBytesRead));	// Actual number of bytes read
		    }
		  else if(testType == testMultiCalls)
		    {
		      aafmMultiXfer_t		xfer;
		      aafmMultiResult_t	result;

		      check(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence));
		      xfer.numSamples = dataLen;	//!!! Hardcoded	// Number of Samples 
		      xfer.buflen = sizeof(AAFDataBuf);
		      xfer.buffer = AAFDataBuf;
		      result.bytesXfered = 0;
		      check(pMultiEssence->ReadMultiSamples(1, &xfer, &result));
		      samplesRead = result.samplesXfered;
		      AAFBytesRead = result.bytesXfered;
		      pMultiEssence->Release();
		      pMultiEssence = NULL;
		    }

		  // Now compare the data read from the AAF file to the actual WAV file
		  if (dataLen != AAFBytesRead)
		    {
		      printf("***Wrong number of bytes read (was %u , should be %zu)\n",
			     AAFBytesRead, WAVBytesRead);
		    }
		  if (memcmp( dataPtr, AAFDataBuf, dataLen) != 0)
		    {
		      printf("*** Data Read is different than the data in the WAV file ***\n");
		    }
		}
	      else
		{
		  printf("***Failed to open Wave file Laser.wav for comparison\n");
		}
	    }
	  else
	    {
	      printf("***Wrong number of slots in the Master Mob (was %d should be %d)\n",
		     numSlots, 2);
	    }
	  if (pMasterMob)
	    {
	      pMasterMob->Release();
	      pMasterMob = NULL;
	    }

	  pMob->Release();
	  pMob = NULL;
	  if (pEssenceAccess)
	    {
	      pEssenceAccess->Release();
	      pEssenceAccess = NULL;
	    }
	} // while pMobIter->NextOne
      pMobIter->Release();
      pMobIter = NULL;

    }
  else
    {
      printf("***Wrong number of Master mobs in the file (was %d should be %d)\n",
	     numMobs, 1);
    }
  printf("--------\n");

 cleanup:
  // Cleanup and return

  if (pWavFile)
    fclose(pWavFile);
  if (pMultiEssence)
    pMultiEssence->Release();
  pMultiEssence=NULL;
  if(fmtTemplate)
    {
      fmtTemplate->Release();
      fmtTemplate = NULL;
    }
  if (pEssenceAccess)
    {
      pEssenceAccess->Release();
      pEssenceAccess = NULL;
    }
  if (pDictionary)
    pDictionary->Release();
  pDictionary=NULL;

  if (pHeader)
    pHeader->Release();
  pHeader=NULL;
  if (pMobIter)
    pMobIter->Release();
  pMobIter=NULL;
  if (pFormat)
    pFormat->Release();
  pFormat=NULL;

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

  return moduleErrorTmp;
}
예제 #14
0
static HRESULT CreateAAFFile(const aafWChar * pFileName, testDataFile_t *dataFile, testType_t /* testType */)
{
  IAAFFile*					pFile = NULL;
  IAAFHeader*					pHeader = NULL;
  IAAFDictionary*				pDictionary = NULL;
  IAAFMob*					pMob = NULL;
  IAAFMasterMob*				pMasterMob = NULL;
  IAAFClassDef*   pKLVDataCD=NULL;
  IAAFClassDef*   pCommentMarkerCD=NULL;
  IAAFTypeDef*    pUnknownBaseType=NULL;
  IAAFTypeDef*	pInt32BaseType=NULL;
  // IAAFTypeDef* pASCIIStringBaseType=NULL;
  IAAFKLVData* pKLVData=NULL;

  IAAFEssenceAccess*			pEssenceAccess = NULL;
  IAAFEssenceMultiAccess*		pMultiEssence = NULL;
  IAAFEssenceFormat*			pFormat = NULL;
  IAAFEssenceFormat*	format = NULL;
  IAAFLocator*	pLocator = NULL;
  IAAFClassDef*	pCDMasterMob = 0;
  IAAFClassDef                *pCDNetworkLocator = 0;
  IAAFDataDef                 *pDdefSound = 0;
  IAAFDataDef*	pDDefSceneDesc=0;
  IAAFEventMobSlot  *pEventSlot=0;
  IAAFMobSlot   *pSlot=0;
  IAAFSequence  *pSeqSceneDesc=0;
  IAAFSegment   *pSegment=0;
  IAAFEvent     *pEventSceneDesc=0;
  IAAFComponent *pComp=0;
  HRESULT	      hr = AAFRESULT_SUCCESS;


  // !!!Previous revisions of this file contained variables here required to handle external essence
  aafMobID_t					masterMobID;
  aafProductIdentification_t	ProductInfo;
  aafRational_t   editRate = {30000, 1001};
  aafRational_t	sampleRate = {44100, 1};
  aafRational_t	eventTimebase = {30000, 1001};
  aafPosition_t	position=0;
  FILE*	pWavFile = NULL;
  unsigned char	dataBuff[4096], *dataPtr;
  //	aafUInt32	bytesWritten;
  aafUInt32	dataOffset, dataLen;
  aafUInt16	bitsPerSample, numCh;
  aafInt32	n, numSpecifiers;
  aafUID_t	essenceFormatCode, testContainer;
  aafUInt32 samplesWritten, bytesWritten;
  // delete any previous test file before continuing...
  char chFileName[1000];
  convert(chFileName, sizeof(chFileName), pFileName);
  remove(chFileName);
  if(dataFile != NULL)
    {
      // delete any previous test file before continuing...
      char chFileName[1000];
      convert(chFileName, sizeof(chFileName), dataFile->dataFilename);
      remove(chFileName);
    }


  aafProductVersion_t v;
  v.major = 1;
  v.minor = 0;
  v.tertiary = 0;
  v.patchLevel = 0;
  v.type = kAAFVersionUnknown;

  ProductInfo.companyName = companyName;
  ProductInfo.productName = productName;
  ProductInfo.productVersion = &v;
  ProductInfo.productVersionString = NULL;
  ProductInfo.productID = NIL_UID;
  ProductInfo.platform = NULL;

  check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile));
  check(pFile->GetHeader(&pHeader));

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

  check(pDictionary->LookupClassDef(AUID_AAFMasterMob,
				    &pCDMasterMob));
  check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator,
				    &pCDNetworkLocator));
  check(pDictionary->LookupDataDef(kAAFDataDef_Sound,
				   &pDdefSound));

  // !!!Previous revisions of this file contained code here required to handle external essence

  // Get a Master MOB Interface
  check(pCDMasterMob->
	CreateInstance(IID_IAAFMasterMob, 
		       (IUnknown **)&pMasterMob));
  // Get a Mob interface and set its variables.
  check(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
  check(pMob->GetMobID(&masterMobID));
  check(pMob->SetName(L"A Master Mob"));
	
  // Add it to the file 
  check(pHeader->AddMob(pMob));

  // !!!Previous revisions of this file contained code here required to handle external essence

  if(dataFile != NULL)
    {
      // Make a locator, and attach it to the EssenceDescriptor
      check(pCDNetworkLocator->
	    CreateInstance(IID_IAAFLocator, 
			   (IUnknown **)&pLocator));		
      check(pLocator->SetPath (dataFile->dataFilename));
      testContainer = dataFile->dataFormat;
    }
  else
    {
      pLocator = NULL;
      testContainer = ContainerAAF;
    }


  // open the Essence file to be included in this AAF file("Laser.wav")
  pWavFile = fopen("Laser.wav", "r");
  if (pWavFile)
    {
      // read in the essence data
      fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile);
      check(loadWAVEHeader(dataBuff,
			   &bitsPerSample,
			   &numCh,
			   &sampleRate,
			   &dataOffset,
			   &dataLen));
      dataPtr = dataBuff + dataOffset;
      // now create the Essence data file
     check(pMasterMob->CreateEssence(1,				// Slot ID
				      pDdefSound,		// MediaKind
				      kAAFCodecWAVE,		// codecID
				      editRate,		// edit rate
				      sampleRate,		// sample rate
				      kAAFCompressionDisable,
				      pLocator,	// In current file
				      testContainer,	// In AAF Format
				      &pEssenceAccess));// Compress disabled

      check(pEssenceAccess->GetFileFormatParameterList (&format));
      check(format->NumFormatSpecifiers (&numSpecifiers));
      for(n = 0; n < numSpecifiers; n++)
	{
	  check(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL));
	}
      format->Release();
      format = NULL;

      // Tell the AAFEssenceAccess what the format is.
      check(pEssenceAccess->GetEmptyFileFormat (&pFormat));
      check(pFormat->NumFormatSpecifiers (&numSpecifiers));

      aafInt32	sampleSize = bitsPerSample;
      check(pFormat->AddFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleSize), (aafUInt8 *)&sampleSize));
      check(pEssenceAccess->PutFileFormat (pFormat));
      pFormat->Release();
      pFormat = NULL;
      // write out the data

      check(pEssenceAccess->WriteSamples( dataLen,//!!! hardcoded bytes/sample ==1// Number of Samples
						sizeof(dataBuff), // buffer size
						dataPtr,	// THE data
						&samplesWritten,
						&bytesWritten));

      // close essence data file
      fclose(pWavFile);
      pWavFile = NULL;
      // Finish writing the destination
      check(pEssenceAccess->CompleteWrite());
      pEssenceAccess->Release();
      pEssenceAccess=NULL;
      // First register DataDef for SceneDescription
      // Is SceneDescription in dictionary already
      // Try using Timecode for MC compat
      hr = pDictionary->LookupDataDef(kAAFDataDef_Timecode,
				      &pDDefSceneDesc);
      // hr = pDictionary->LookupDataDef(kAAFDataDef_SceneDescription,
      //					 &pDDefSceneDesc);
      if (hr != AAFRESULT_SUCCESS) 
	{
	  check(pDictionary->CreateInstance(AUID_AAFDataDef,IID_IAAFDataDef,
					    (IUnknown **)&pDDefSceneDesc));
	  check(pDDefSceneDesc->Initialize(kAAFDataDef_SceneDescription,
					   L"SceneDescEvent",L"DataDefinition for Scene Description Events"));
	  check(pDictionary->RegisterDataDef(pDDefSceneDesc));
	}

      // Add EventSlot to MasterMob

      // Create Slot
      check(pDictionary->CreateInstance(AUID_AAFEventMobSlot, IID_IAAFEventMobSlot,
					(IUnknown **)&pEventSlot));

      check(pEventSlot->SetEditRate(&eventTimebase));

      // Get the mob slot interface so that we can add the event segment.
      check(pEventSlot->QueryInterface(IID_IAAFMobSlot, (void **)&pSlot));
      pEventSlot->Release();
      pEventSlot = NULL;
      aafSlotID_t eventSlotID=5;
      check(pSlot->SetSlotID(eventSlotID));
      check(pSlot->SetName(L"SceneDescriptions"));

      // Set up Sequence for Scene Descriptors
      check(pDictionary->CreateInstance(AUID_AAFSequence,IID_IAAFSequence,
					(IUnknown **)&pSeqSceneDesc));
      check(pSeqSceneDesc->Initialize(pDDefSceneDesc));

      // Create first Comment Marker
      check(pDictionary->LookupClassDef(AUID_AAFCommentMarker,
					&pCommentMarkerCD));
      check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent,
					     (IUnknown **)&pEventSceneDesc));
      position=0;
      check(pEventSceneDesc->SetPosition(position));
      check(pEventSceneDesc->SetComment(L"Racers heading up the hill"));
      check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp));
      check(pComp->SetDataDef(pDDefSceneDesc));		
      // Add it to the sequence
      check(pSeqSceneDesc->AppendComponent(pComp));
      pComp->Release();
      pComp = NULL;
      pEventSceneDesc->Release();
      pEventSceneDesc=NULL;

      // Create second Comment Marker
      check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent,
					     (IUnknown **)&pEventSceneDesc));
      position=100;
      check(pEventSceneDesc->SetPosition(position));
      check(pEventSceneDesc->SetComment(L"Racer pulls away from crowd"));
      check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp));
      check(pComp->SetDataDef(pDDefSceneDesc));		
      // Add it to the sequence
      check(pSeqSceneDesc->AppendComponent(pComp));
      pComp->Release();
      pComp = NULL;
      pEventSceneDesc->Release();
      pEventSceneDesc=NULL;
      check(pSeqSceneDesc->QueryInterface(IID_IAAFSegment, (void **)&pSegment));

      // Create third Comment Marker
      check(pCommentMarkerCD->CreateInstance(IID_IAAFEvent,
					     (IUnknown **)&pEventSceneDesc));
      position=250;
      check(pEventSceneDesc->SetPosition(position));
      check(pEventSceneDesc->SetComment(L"Racer passes finish line"));
      check(pEventSceneDesc->QueryInterface(IID_IAAFComponent, (void **)&pComp));
      check(pComp->SetDataDef(pDDefSceneDesc));		
      // Add it to the sequence
      check(pSeqSceneDesc->AppendComponent(pComp));
      pComp->Release();
      pComp = NULL;
      pEventSceneDesc->Release();
      pEventSceneDesc=NULL;
      // Add the event sequence to the event mob slot
      // Sequence must have at least one component to ensure event mob slot is valid
      check(pSlot->SetSegment(pSegment));
      pSegment->Release();
      pSegment = NULL;

      // Append the event slot to the Master Mob
      check(pMob->AppendSlot(pSlot));

      // Add the KLV data to the Master Mob

      // Register the two KLVKeys
      check(pDictionary->LookupTypeDef(kAAFTypeID_UInt8Array,
				       &pUnknownBaseType));
      check(pDictionary->RegisterKLVDataKey(KLVKey_BinaryBlob1,
					    pUnknownBaseType));
      check(pDictionary->LookupTypeDef(kAAFTypeID_Int32,
				       &pInt32BaseType));
      check(pDictionary->RegisterKLVDataKey(KLVKey_Int32_1,
					    pInt32BaseType));
      // Next define new ASCII string data def
      // check(pDictionary->RegisterKLVDataKey(KLVKey_ASCIIString1,
      //				      pASCIIStringBaseType));

      // Get the KLVData ClassDefinition
      check(pDictionary->LookupClassDef(AUID_AAFKLVData,
					&pKLVDataCD));


      // Create KLVData and append it to Mob
      check(pKLVDataCD->CreateInstance(IID_IAAFKLVData, 
				       (IUnknown **)&pKLVData));
		
      check(pKLVData->Initialize(KLVKey_BinaryBlob1,
				 sizeof(blobData), (aafUInt8 *)blobData));
      check(pMob->AppendKLVData(pKLVData));
      pKLVData->Release();
      pKLVData=NULL;

      // Create KLVData and append it to Mob
      check(pKLVDataCD->CreateInstance(IID_IAAFKLVData, 
				       (IUnknown **)&pKLVData));
		
      check(pKLVData->Initialize(KLVKey_Int32_1,
				 sizeof(int32Data), (aafUInt8 *)&int32Data));
      check(pMob->AppendKLVData(pKLVData));
      pKLVData->Release();
      pKLVData=NULL;
    }
  else
    {
      printf("***Failed to open Wave file Laser.wav\n");
    }
  // Release all unnecesary interfaces

  if (pInt32BaseType)
    pInt32BaseType->Release();
  pInt32BaseType=NULL;
  if (pUnknownBaseType)
    pUnknownBaseType->Release();
  pUnknownBaseType=NULL;
  if (pKLVDataCD)
    pKLVDataCD->Release();
  pKLVDataCD=NULL;
  if (pCommentMarkerCD)
    pCommentMarkerCD->Release();
  pCommentMarkerCD=NULL;
  if(pComp)
    pComp->Release();
  pComp=NULL;
  if(pEventSceneDesc)
    pEventSceneDesc->Release();
  pEventSceneDesc=0;
  if(pSegment)
    pSegment->Release();
  pSegment=NULL;
  if(pSeqSceneDesc)
    pSeqSceneDesc->Release();
  pSeqSceneDesc=NULL;
  if(pSlot)
    pSlot->Release();
  pSlot=NULL;
  if(pEventSlot)
    pEventSlot->Release();
  pEventSlot=NULL;
  if(pDDefSceneDesc)
    pDDefSceneDesc->Release();
  pDDefSceneDesc=NULL;

  if(pMasterMob)
    pMasterMob->Release();
  pMasterMob = NULL;
  if(pMob)
    pMob->Release();
  pMob = NULL;

  if(pDictionary)
    pDictionary->Release();
  pDictionary = NULL;
  if(pHeader)
    pHeader->Release();
  pHeader = NULL;
  //!!!DebugOnly
  pFile->Save();
  pFile->Close();
  pFile->Release();
  pFile = NULL;
  if (pEssenceAccess)
    {	
      pEssenceAccess->Release();
      pEssenceAccess= NULL;
    }

 cleanup:
  // Cleanup and return
  if(pFormat)
    pFormat->Release();
  if(format)
    format->Release();
  if(pLocator)
    pLocator->Release();

  if (pWavFile)
    fclose(pWavFile);

  if (pEssenceAccess)
    pEssenceAccess->Release();
	
  if (pMultiEssence)
    pMultiEssence->Release();
	
  if (pMasterMob)
    pMasterMob->Release();

  if (pMob)
    pMob->Release();

  if (pDictionary)
    pDictionary->Release();

  if (pHeader)
    pHeader->Release();

  if (pCDMasterMob)
    {
      pCDMasterMob->Release();
      pCDMasterMob = 0;
    }

  if (pCDNetworkLocator)
    {
      pCDNetworkLocator->Release();
      pCDNetworkLocator = 0;
    }

  if (pDdefSound)
    {
      pDdefSound->Release ();
      pDdefSound = 0;
    }

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


  return moduleErrorTmp;
}
예제 #15
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;
	IAAFMob*					pMob = NULL;
	IAAFMob*					pReferencedMob = NULL;
	IAAFTimelineMobSlot*		newSlot = NULL;
	IAAFSegment*				seg = NULL;
	bool bFileOpen = false;
	HRESULT						hr = AAFRESULT_SUCCESS;
	IAAFComponent*				pComponent = NULL;

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

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

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		CAAFBuiltinDefs defs (pDictionary);
 		
		//Make the MOB to be referenced
		checkResult(defs.cdMasterMob()->
					CreateInstance(IID_IAAFMob, 
								   (IUnknown **)&pReferencedMob));
		checkResult(pReferencedMob->SetMobID(TEST_referencedMobID));
		checkResult(pReferencedMob->SetName(L"AAFSourceClipTest::ReferencedMob"));

		// Create a Mob
		checkResult(defs.cdCompositionMob()->
					CreateInstance(IID_IAAFMob, 
								   (IUnknown **)&pMob));
		checkResult(pMob->SetMobID(TEST_MobID));
		checkResult(pMob->SetName(L"AAFSourceClipTest"));

		// Create a SourceClip
		checkResult(defs.cdSourceClip()->
					CreateInstance(IID_IAAFSegment, 
								   (IUnknown **)&seg));
		 checkResult(seg->QueryInterface(IID_IAAFComponent, (void **)&pComponent));
		 checkResult(pComponent->SetDataDef(defs.ddkAAFPicture()));
		pComponent->Release();
		pComponent = NULL;
								 		
		aafRational_t editRate = { 0, 1};
		checkResult(pMob->AppendNewTimelineSlot (editRate,
												 seg,
												 1,
												 slotName,
												 0,
												 &newSlot));

		checkResult(pHeader->AddMob(pMob));
		checkResult(pHeader->AddMob(pReferencedMob));
	}
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }

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

	if (pComponent)
		pComponent->Release();

	if (seg)
		seg->Release();

	if (pMob)
		pMob->Release();

	if (pReferencedMob)
		pReferencedMob->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();

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


	return hr;
}
예제 #16
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	// IAAFSession *				pSession = NULL;
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	IAAFMob*					pMob = NULL;
	IAAFMob*					pReferencedMob = NULL;
	IEnumAAFMobSlots*			pSlotIter = NULL;
	IAAFMobSlot*				pSlot = NULL;
	IAAFSegment*				pSegment = NULL;
	IAAFSourceClip*				pSourceClip = NULL;
	bool bFileOpen = false;
	aafSearchCrit_t				criteria;
	aafNumSlots_t				numMobs, numSlots;
	HRESULT						hr = AAFRESULT_SUCCESS;

	try
	{ 
    // Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
 
    // We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the number of mobs in the file (should be one)
		checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
		checkExpression(2 == numMobs, AAFRESULT_TEST_FAILED);

		// Enumerate over all Composition Mobs
		criteria.searchTag = kAAFByMobKind;
		criteria.tags.mobKind = kAAFCompMob;
		checkResult(pHeader->GetMobs(&criteria, &pMobIter));
		while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
		{
			checkResult(pMob->CountSlots(&numSlots));
			checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED);

			checkResult(pMob->GetSlots(&pSlotIter));
			while (AAFRESULT_SUCCESS == pSlotIter->NextOne(&pSlot))
			{
				// The segment should be a source clip...
				checkResult(pSlot->GetSegment(&pSegment));
				pSegment->Release();
				pSegment = NULL;
				pSlot->Release();
				pSlot = NULL;
			}

			pMob->Release();
			pMob = NULL;
		}

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

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

	if (pSourceClip)
		pSourceClip->Release();

	if (pSegment)
		pSegment->Release();

	if (pSlot)
		pSlot->Release();

	if (pSlotIter)
		pSlotIter->Release();

	if (pMob)
		pMob->Release();

	if (pMobIter)
		pMobIter->Release();

	if (pHeader)
		pHeader->Release();

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

	return hr;
}
예제 #17
0
static bool testRestore(const wchar_t* fileName)
{
    bool passed = true;
    
    IAAFFile* pFile = 0;
    IAAFHeader* pHeader = 0;
    IAAFDictionary* pDictionary = 0;
    IAAFContentStorage* pStorage = 0;
    IEnumAAFMobs* pMobs = 0;
    IAAFMob* pMob = 0;
    
    try
    {
        pFile = openFileForReading(fileName);
    }
    catch (...)
    {
        return false;
    }
    
    try
    {
        // get the Mob containing the test data
        checkResult(pFile->GetHeader(&pHeader));
        checkResult(pHeader->GetDictionary(&pDictionary));
        checkResult(pHeader->GetContentStorage(&pStorage));
        aafSearchCrit_t searchCrit;
        searchCrit.searchTag = kAAFByMobKind;
        searchCrit.tags.mobKind = kAAFAllMob;
        checkResult(pStorage->GetMobs(&searchCrit, &pMobs));
        checkResult(pMobs->NextOne(&pMob));
        
        IAAFObject* pObject = 0;
        IAAFClassDef* pClassDef = 0;
        IAAFPropertyDef* pPropertyDef = 0;
        IAAFPropertyValue* pPropertyValue = 0;
        IAAFTypeDef* pType = 0;
        IAAFTypeDefCharacter* pCharacterType = 0;

        // test simple
        try
        {
            printf("    * Simple: ");

            const aafUID_t propId = 
                {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
            wchar_t testCharacter = L'A';
            
            checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject));
            
            checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef));
            checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef));
            
            checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue));
            checkResult(pPropertyValue->GetType(&pType));
            checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType));
            
            aafCharacter value;
            checkResult(pCharacterType->GetCharacter(pPropertyValue, &value));

            if (value == testCharacter)
            {
                printf("passed\n");
            }
            else
            {
                printf("FAILED\n");
                passed = false;
            }
        }
        catch (...)
        {
            printf("FAILED\n");
            passed = false;
        }
        release(pCharacterType);
        release(pType);
        release(pPropertyValue);
        release(pPropertyDef);
        release(pClassDef);
        release(pObject);
        
        // test XML escaped
        try
        {
            printf("    * XML escaped: ");

            const aafUID_t propId = 
                {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
            wchar_t testCharacter = L'\r';
            
            checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject));
            
            checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef));
            checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef));
            
            checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue));
            checkResult(pPropertyValue->GetType(&pType));
            checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType));
            
            aafCharacter value;
            checkResult(pCharacterType->GetCharacter(pPropertyValue, &value));

            if (value == testCharacter)
            {
                printf("passed\n");
            }
            else
            {
                printf("FAILED\n");
                passed = false;
            }
        }
        catch (...)
        {
            printf("FAILED\n");
            passed = false;
        }
        release(pCharacterType);
        release(pType);
        release(pPropertyValue);
        release(pPropertyDef);
        release(pClassDef);
        release(pObject);
        
        
        // test AAF escaped
        try
        {
            printf("    * AAF escaped: ");

            const aafUID_t propId = 
                {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
            wchar_t testCharacter = 0x0;
            
            checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject));
            
            checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef));
            checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef));
            
            checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue));
            checkResult(pPropertyValue->GetType(&pType));
            checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType));
            
            aafCharacter value;
            checkResult(pCharacterType->GetCharacter(pPropertyValue, &value));

            if (value == testCharacter)
            {
                printf("passed\n");
            }
            else
            {
                printf("FAILED\n");
                passed = false;
            }
        }
        catch (...)
        {
            printf("FAILED\n");
            passed = false;
        }
        release(pCharacterType);
        release(pType);
        release(pPropertyValue);
        release(pPropertyDef);
        release(pClassDef);
        release(pObject);
        
        // test AAF escaped of invalid UNICODE character
        try
        {
            printf("    * AAF escaped invalid Unicode character: ");

            const aafUID_t propId = 
                {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
            wchar_t testCharacter = 0xFFFF;
            
            checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject));
            
            checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef));
            checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef));
            
            checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue));
            checkResult(pPropertyValue->GetType(&pType));
            checkResult(pType->QueryInterface(IID_IAAFTypeDefCharacter, (void **)&pCharacterType));
            
            aafCharacter value;
            checkResult(pCharacterType->GetCharacter(pPropertyValue, &value));

            if (value == testCharacter)
            {
                printf("passed\n");
            }
            else
            {
                printf("FAILED\n");
                passed = false;
            }
        }
        catch (...)
        {
            printf("FAILED\n");
            passed = false;
        }
        release(pCharacterType);
        release(pType);
        release(pPropertyValue);
        release(pPropertyDef);
        release(pClassDef);
        release(pObject);
        
    }
    catch (...)
    {
        passed = false;
    }

    // cleanup    
    release(pMob);
    release(pMobs);
    release(pStorage);
    release(pDictionary);
    release(pHeader);
    checkResult(pFile->Close());
    release(pFile);

    report(passed);
    
    return passed;
}
예제 #18
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;
}
예제 #19
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	HRESULT hr = AAFRESULT_SUCCESS;
	
	IAAFFile* pFile = NULL;
	IAAFHeader * pHeader = NULL;
	IAAFDictionary * pDict = NULL;
	IAAFCompositionMob * pCMob = NULL;
	IAAFMob * pMob = NULL;
	IAAFObject * pObj = NULL;
	
	try
	{
		//Do the usual ...
		RemoveTestFile (pFileName);
		checkResult (CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
		assert (pFile);
		checkResult (pFile->GetHeader (&pHeader));
		assert (pHeader);
		checkResult (pHeader->GetDictionary (&pDict));
		assert (pDict);
		CAAFBuiltinDefs defs (pDict);
		
		//Create a composition ...
		checkResult (defs.cdCompositionMob()->
			CreateInstance (IID_IAAFCompositionMob,
			(IUnknown **) &pCMob));
		assert (pCMob);
		checkResult (pCMob->Initialize (TEST_NAME));
		
		//... Get its mob, and add it to the header info
		checkResult (pCMob->QueryInterface (IID_IAAFMob,
										  (void **) &pMob));
		assert (pMob);
		checkResult (pHeader->AddMob (pMob));
		
	}
	catch (HRESULT & rResult)
	{
		hr = rResult;
	}
	
	if (pCMob) pCMob->Release();
	if (pMob) pCMob->Release();
	if (pObj) pObj->Release();
	if (pDict) pDict->Release();
	if (pHeader) pHeader->Release();
	if (pFile)
	{
		AAFRESULT temphr = pFile->Save();
		if (! SUCCEEDED (temphr)) return temphr;
		temphr = pFile->Close();
		if (! SUCCEEDED (temphr)) return temphr;
		pFile->Release();
	}
	
	return hr;
}
예제 #20
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	IAAFFile *					pFile = NULL;
	bool 						bFileOpen = false;
	IAAFHeader *				pHeader = NULL;
	aafNumSlots_t				numMobs, i;
	HRESULT						hr = S_OK;
	HRESULT						localhr = S_OK;
	IEnumAAFMobs 				*mobIter = NULL;
	IEnumAAFMobs 				*cloneMobIter = NULL;
	IAAFMob						*aMob = NULL;
	IAAFMob						**mobArray = NULL;
	aafSearchCrit_t				criteria;
	aafUInt32					numFetched = 0;


  try
  {
    // Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
 
    // We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

	  // Make sure that we have one master, one file, and one composition (three total)
	  checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
	  checkExpression (3 == numMobs, AAFRESULT_TEST_FAILED);

	  
	  criteria.searchTag = kAAFNoSearch;
	  checkResult(pHeader->GetMobs (&criteria, &mobIter));
	  

/* Test the Reset method *******************************/
	if (mobIter->Reset() == AAFRESULT_SUCCESS)
		cout<< "	Reset() ...		Passed" << endl;	
	else	{
		cout<< "	Reset() ...		Failed!!!" << endl;	
		hr = AAFRESULT_TEST_FAILED;
	}


/* Test the NextOne method ******************************/
	
	// Call NextOne once for each mob for a total of numMobs times	
	for (i=0; i<numMobs; i++)	{
		if (mobIter->NextOne(&aMob) == AAFRESULT_SUCCESS)	{
			aMob->Release();
			aMob = NULL;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
	}

	// Make sure we are at the end
	if (mobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;
	
	mobIter->Reset();
	// this should return AAFRESULT_NULL_PARAM
	if (mobIter->NextOne(NULL) != AAFRESULT_NULL_PARAM)
			localhr = AAFRESULT_TEST_FAILED;

	if (SUCCEEDED(localhr))
		cout<< "	NextOne() ...	Passed" << endl;	
	else	{
		cout<< "	NextOne() ...	Failed!!!" << endl;	
		hr = AAFRESULT_TEST_FAILED;
	}

/* Test the Skip method ******************************/

	localhr = S_OK;
	mobIter->Reset();
	
	// skip over each Mob one at a time.
	for (i=0; i<numMobs; i++)
		if (mobIter->Skip(1) != AAFRESULT_SUCCESS)
			localhr = AAFRESULT_TEST_FAILED;

	// Make sure we are at the end.
	if (mobIter->Skip(1) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;
	
	mobIter->Reset();
	// Skip over multiple Mobs at a time.		
	for (i=2; i<=numMobs; i++)	{
		if (mobIter->Skip(i) != AAFRESULT_SUCCESS)
			localhr = AAFRESULT_TEST_FAILED;

		mobIter->Reset();
	}

	// Make sure we are at the end.
	if (mobIter->Skip(numMobs+1) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;
			
	if (SUCCEEDED(localhr))
		cout<< "	Skip() ...		Passed" << endl;
	else	{
		cout<< "	Skip() ...		Failed!!!" << endl;
		hr = AAFRESULT_TEST_FAILED;
	}

/* Next()  ******************************************/

	mobArray = new IAAFMob *[numMobs];

	localhr = S_OK;
	numFetched = 1;

	// Iterate thru the Mobs using Next doing 1 at a time
	mobIter->Reset();
	for ( i=0; i<numMobs ;i++)	{
		if (mobIter->Next(1, &aMob, &numFetched) == AAFRESULT_SUCCESS)	{
			aMob->Release();
	 	    aMob = NULL;

			if (1 != numFetched)
				localhr = AAFRESULT_TEST_FAILED;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
	}
			
	// Make sure we are at the end
	if (mobIter->Next(1, &aMob, &numFetched) != AAFRESULT_NO_MORE_OBJECTS)
		localhr = AAFRESULT_TEST_FAILED;
	if(numFetched != 0)
		localhr = AAFRESULT_TEST_FAILED;
		
	// Test the Next method filling out an array of Mobs
	numFetched = 0;
	mobIter->Reset();
	for ( i=2; i<=numMobs ;i++)	{
		if (mobIter->Next(i, mobArray, &numFetched) == AAFRESULT_SUCCESS)	{
			if (i != numFetched)
				localhr = AAFRESULT_TEST_FAILED;

			for (i = 0; i < numFetched; i++)
				if (mobArray[i] != NULL)	// should have been set
				{
					mobArray[i]->Release();
					mobArray[i] = NULL;
				}
				else
					localhr = AAFRESULT_TEST_FAILED;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
			
		mobIter->Reset();
	}

	// Make sure we can't get more Mobs than numMobs	
	if (mobIter->Next(i+1, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS)
		localhr = AAFRESULT_TEST_FAILED;

	if (numMobs != numFetched)
		localhr = AAFRESULT_TEST_FAILED;
		
	for (i = 0; i < numMobs; i++)
		if (mobArray[i] != NULL)	
		{
			mobArray[i]->Release();
			mobArray[i] = NULL;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
		
	
	mobIter->Reset();
	mobIter->Skip(2);

	// Make sure we can't go past the end to fill the array
	if (mobIter->Next(numMobs, mobArray, &numFetched) != AAFRESULT_NO_MORE_OBJECTS)
		localhr = AAFRESULT_TEST_FAILED;

	if ((numMobs-2) != numFetched)
		localhr = AAFRESULT_TEST_FAILED;
		
	for (i = 0; i < numMobs-2; i++)
		if (mobArray[i] != NULL)
		{
			mobArray[i]->Release();
			mobArray[i] = NULL;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
			
	mobIter->Reset();
	// Make sure it returns AAFRESULT_NULL_PARAM
	if (mobIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM)
		localhr = AAFRESULT_TEST_FAILED;

	// Make sure it returns E_INVALIDARG	
	if (mobIter->Next(1, mobArray, &numFetched) != AAFRESULT_SUCCESS)
		localhr = AAFRESULT_TEST_FAILED;
	else
	{
		for (i = 0; i < numFetched; i++)
		if (mobArray[i] != NULL)
		{
			mobArray[i]->Release();
			mobArray[i] = NULL;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;		
	}

	if (SUCCEEDED(localhr))
		cout<< "	Next() ...		Passed" << endl;
	else	{
		cout<< "	Next() ...		Failed!!!" << endl;
		hr = AAFRESULT_TEST_FAILED;
	}


/* Clone() ************************************/

	// Test the Clone method with with enumerator at begining
	localhr = S_OK;
	mobIter->Reset();
	if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS)	{
		for (i=0; i < numMobs; i++)	{
			if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS)	{
				aMob->Release();
    			aMob = NULL;
			}
			else
				localhr = AAFRESULT_TEST_FAILED;		
		}

		if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;

		cloneMobIter->Reset();
		if (cloneMobIter->Next(numMobs, mobArray, &numFetched) 
			!= AAFRESULT_SUCCESS)
			localhr = AAFRESULT_TEST_FAILED;

		if (numMobs != numFetched)
			localhr = AAFRESULT_TEST_FAILED;
		
		for (i = 0; i < numMobs; i++) {
			if (mobArray[i] != NULL)	{
				mobArray[i]->Release();
				mobArray[i] = NULL;
			}
			else
				localhr = AAFRESULT_TEST_FAILED;
		}

		cloneMobIter->Reset();

		if (cloneMobIter->Next(numMobs+1, mobArray, &numFetched) 
			!= AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;

		if (numMobs != numFetched)
			localhr = AAFRESULT_TEST_FAILED;
		
		for (i = 0; i < numMobs; i++) {
			if (mobArray[i] != NULL)	{
				mobArray[i]->Release();
				mobArray[i] = NULL;
			}
			else
				localhr = AAFRESULT_TEST_FAILED;
		}

		cloneMobIter->Reset();
		cloneMobIter->Skip(1);

		if (cloneMobIter->Next(numMobs, mobArray, &numFetched) 
			!= AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;

		if ((numMobs-1) != numFetched)
			localhr = AAFRESULT_TEST_FAILED;
		
		for (i = 0; i < numMobs-1; i++) {
			if (mobArray[i] != NULL)	{
				mobArray[i]->Release();
				mobArray[i] = NULL;
			}
			else
				localhr = AAFRESULT_TEST_FAILED;
		}
	
		cloneMobIter->Release();
	 	cloneMobIter = NULL;
	}
	else
		localhr = AAFRESULT_TEST_FAILED;
	
	// Test the Clone method with with enumerator at end.
	// Indirectly tests the Skip and Reset methods.
	mobIter->Reset();
	mobIter->Skip(numMobs-1);
	if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS) {
		if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS)	{
			aMob->Release();
		    aMob = NULL;
		}
		if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;

		cloneMobIter->Release();
  		cloneMobIter = NULL;
	}
	else
		localhr = AAFRESULT_TEST_FAILED;

	// Test the Clone method with with enumerator in the middle.
	// Indirectly tests the Skip and Reset methods.
	mobIter->Reset();
	mobIter->Skip(numMobs-2);
	if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS)	{
		cloneMobIter->Skip(1);
		if (cloneMobIter->NextOne(&aMob) == AAFRESULT_SUCCESS)	{
			aMob->Release();
		    aMob = NULL;
		}
		else
			localhr = AAFRESULT_TEST_FAILED;
		
		if (cloneMobIter->NextOne(&aMob) != AAFRESULT_NO_MORE_OBJECTS)
			localhr = AAFRESULT_TEST_FAILED;

		cloneMobIter->Release();
  		cloneMobIter = NULL;
	}
	else
		localhr = AAFRESULT_TEST_FAILED;


	mobIter->Reset();
	if (mobIter->Clone(&cloneMobIter) == AAFRESULT_SUCCESS)	{
		if (cloneMobIter->Next(1, NULL, &numFetched) != AAFRESULT_NULL_PARAM)
			localhr = AAFRESULT_TEST_FAILED;
	
		if (cloneMobIter->Next(1, mobArray, &numFetched) != AAFRESULT_SUCCESS)
			localhr = AAFRESULT_TEST_FAILED;
		else
		{
			for (i = 0; i < numFetched; i++) {
				if (mobArray[i] != NULL)
				{
					mobArray[i]->Release();
					mobArray[i] = NULL;
				}
				else
					localhr = AAFRESULT_TEST_FAILED;		
			}
		}

		cloneMobIter->Release();
 		cloneMobIter = NULL;
	}
	else
		localhr = AAFRESULT_TEST_FAILED;

	
	if (SUCCEEDED(localhr))
		cout<< "	Clone() ...		Passed" << endl;
	else	{
		cout<< "	Clone() ...		Failed!!!" << endl;
		hr = AAFRESULT_TEST_FAILED;
	}
	  	  	  
	  checkResult(pHeader->CountMobs(kAAFMasterMob, &numMobs));
	  checkExpression (1 == numMobs, AAFRESULT_TEST_FAILED);

	  checkResult(pHeader->CountMobs(kAAFFileMob, &numMobs));
	  checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);

	  checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs));
	  checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);


	  // Test usageCode search criteria.
	  {
	    // Should find one TopLevel mob, and two Template mobs.

	    // There should be one mob with usage code TopLevel, and it should be
	    // a composition mob.
	    aafSearchCrit_t usageCrit;
	    usageCrit.searchTag = kAAFByUsageCode;
	    usageCrit.tags.usageCode = kAAFUsage_TopLevel; 
	    CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFCompositionMob );

	    // There should be one composition mob with usage code TopLevel.
	    usageCrit.searchTag = kAAFByCompositionMobUsageCode;
	    usageCrit.tags.usageCode = kAAFUsage_TopLevel; 
	    CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFCompositionMob );

	    // There should be two mobs with usage code Template.  They are of difference
	    // types, hence, don't check the type.
	    usageCrit.searchTag = kAAFByUsageCode;
	    usageCrit.tags.usageCode = kAAFUsage_Template; 
	    CheckMobsByUsageCode( pHeader, usageCrit, 2, false, IID_IUnknown );

	    // One of the Template mobs should be a SourceMob, the other should be MasterMob.
	    usageCrit.searchTag = kAAFBySourceMobUsageCode;
	    usageCrit.tags.usageCode = kAAFUsage_Template; 
	    CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFSourceMob );

	    usageCrit.searchTag = kAAFByMasterMobUsageCode;
	    usageCrit.tags.usageCode = kAAFUsage_Template; 
	    CheckMobsByUsageCode( pHeader, usageCrit, 1, true, IID_IAAFMasterMob ); 
	  }

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

	// Cleanup and return
	
	delete [] mobArray;

	if (mobIter)
		mobIter->Release();

	if (pHeader)
		pHeader->Release();

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

	return hr;
}
예제 #21
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;
	IAAFCompositionMob*			pCompMob=NULL;
	IAAFMob*					pMob = NULL;
	IAAFTimelineMobSlot*		pNewSlot = NULL;
	IAAFSourceClip*				pSourceClip = NULL;
	IAAFSourceReference*		pSourceRef = NULL;
	IAAFTransition*				pTransition = NULL;
	IAAFOperationGroup*			pOperationGroup = NULL;
	IAAFSegment*				pSegment = NULL;
	IAAFSegment*				pEffectFiller = NULL;
	IAAFComponent*				pComponent = NULL;
	IAAFFiller*					pFiller = NULL;
	IAAFSequence*				pSequence = NULL;
	IAAFOperationDef*				pOperationDef = NULL;
	IAAFParameter				*pParm = NULL;
	IAAFParameterDef*			pParamDef = NULL;
	IAAFConstantValue*			pConstantValue = NULL;
	
	HRESULT						hr = S_OK;
	aafLength_t					transitionLength;
	aafPosition_t				cutPoint = 0;
	aafLength_t					effectLen = TEST_EFFECT_LEN;
	aafUID_t					effectID = kTestEffectID;
	aafUID_t					parmID = kTestParmID;

	transitionLength = 100;

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


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

		// Get the AAF Dictionary so that we can create valid AAF objects.
		checkResult(pHeader->GetDictionary(&pDictionary));
		CAAFBuiltinDefs defs (pDictionary);
 		
		// Create the effect and parameter definitions
		checkResult(defs.cdOperationDef()->
					CreateInstance(IID_IAAFOperationDef, 
								   (IUnknown **)&pOperationDef));
    
		checkResult(defs.cdParameterDef()->
					CreateInstance(IID_IAAFParameterDef, 
								   (IUnknown **)&pParamDef));

		checkResult(pOperationDef->Initialize (effectID, TEST_EFFECT_NAME, TEST_EFFECT_DESC));
		checkResult(pDictionary->RegisterOperationDef(pOperationDef));
		checkResult(pParamDef->Initialize (parmID, TEST_PARAM_NAME, TEST_PARAM_DESC, defs.tdRational ()));
		checkResult(pParamDef->SetDisplayUnits(TEST_PARAM_UNITS));
		checkResult(pDictionary->RegisterParameterDef(pParamDef));


		checkResult(pOperationDef->SetDataDef (defs.ddkAAFPicture()));
		checkResult(pOperationDef->SetIsTimeWarp (kAAFFalse));
		checkResult(pOperationDef->SetNumberInputs (TEST_NUM_INPUTS));
		checkResult(pOperationDef->SetCategory (TEST_CATEGORY));
		checkResult(pOperationDef->AddParameterDef (pParamDef));
		checkResult(pOperationDef->SetBypass (TEST_BYPASS));


		// ------------------------------------------------------------
		//	To test a Transition we need to create a Sequence which will 
		//	a Filler, a transition and another Filler. I know this is not 
		//  very interesting, but it will let us test the Transition 
		//  interface with the least amount of other stuff.
		// ------------------------------------------------------------
		//
		// Create a CompositionMob
		checkResult(defs.cdCompositionMob()->
					CreateInstance(IID_IAAFCompositionMob, 
								   (IUnknown **)&pCompMob));

		checkResult(pCompMob->Initialize(L"Transition Test"));
		// Get a MOB interface
		checkResult(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob));
		checkResult(pMob->SetMobID(TEST_MobID));

		// Create a Sequence
		checkResult(defs.cdSequence()->
					CreateInstance(IID_IAAFSequence,
								   (IUnknown **) &pSequence));

		// Get a Segment interface
		checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment));
		// Get a component interface and 
		checkResult(pSequence->QueryInterface(IID_IAAFComponent, (void **)&pComponent));
		// set the Data definition for it !
		checkResult(pComponent->SetDataDef(defs.ddkAAFPicture()));
		// Release the component - because we need to reuse the pointer later
		pComponent->Release();
		pComponent = NULL;

		// Create a new Mob Slot that will contain the sequence
		aafRational_t editRate = { 0, 1};
		checkResult(pMob->AppendNewTimelineSlot(editRate,
												pSegment,
												1,
												L"Transition",
												0,
												&pNewSlot));

		// Create a Filler
		checkResult(defs.cdFiller()->
					CreateInstance(IID_IAAFFiller,
								   (IUnknown **) &pFiller));

		// Get a component interface
		checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent));
		// Set values for the filler
	    checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength));
		// append the filler to the sequence
		checkResult(pSequence->AppendComponent(pComponent));

		// Release the component - because we need to reuse the pointer later
		pFiller->Release();
		pFiller = NULL;
		pComponent->Release();
		pComponent = NULL;

		
	    checkResult(defs.cdTransition()->
					CreateInstance(IID_IAAFTransition, 
								   (IUnknown **)&pTransition));

		// Create an empty EffectGroup object !!
		checkResult(defs.cdOperationGroup()->
					CreateInstance(IID_IAAFOperationGroup,
								   (IUnknown **)&pOperationGroup));

		checkResult(pOperationGroup->Initialize(defs.ddkAAFPicture(), transitionLength, pOperationDef));

    // Create a constant value parameter.
		checkResult(defs.cdConstantValue()->
					CreateInstance(IID_IAAFConstantValue, 
								   (IUnknown **)&pConstantValue));
    aafRational_t testLevel = {1, 2};
		checkResult(pConstantValue->Initialize (pParamDef, sizeof(testLevel), (aafDataBuffer_t)&testLevel));

    checkResult(pConstantValue->QueryInterface (IID_IAAFParameter, (void **)&pParm));
    checkResult(pOperationGroup->AddParameter (pParm));
    pParm->Release();
    pParm = NULL;
    pConstantValue->Release();
    pConstantValue = NULL;

		checkResult(defs.cdFiller()->
					CreateInstance(IID_IAAFSegment,
								   (IUnknown **) &pEffectFiller));
		 checkResult(pEffectFiller->QueryInterface(IID_IAAFComponent, (void **)&pComponent));
		 checkResult(pComponent->SetDataDef(defs.ddkAAFPicture()));
		pComponent->Release();
		pComponent = NULL;
		checkResult(pOperationGroup->AppendInputSegment (pEffectFiller));
		// release the filler
		pEffectFiller->Release();
		pEffectFiller  = NULL;

		checkResult(pOperationGroup->SetBypassOverride (1));
		checkResult(defs.cdSourceClip()->
					CreateInstance(IID_IAAFSourceClip, 
								   (IUnknown **)&pSourceClip));
		aafSourceRef_t	sourceRef;
		sourceRef.sourceID = zeroMobID;
		sourceRef.sourceSlotID = 0;
		sourceRef.startTime = 0;
		checkResult(pSourceClip->Initialize (defs.ddkAAFPicture(),
											 effectLen,
											 sourceRef));
		checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference,
												 (void **)&pSourceRef));
		checkResult(pOperationGroup->SetRender (pSourceRef));

		checkResult(pTransition->Initialize (defs.ddkAAFPicture(),
											 transitionLength,
											 cutPoint,
											 pOperationGroup));
		checkResult(pTransition->QueryInterface (IID_IAAFComponent,
												 (void **)&pComponent));

		// now append the transition
		checkResult(pSequence->AppendComponent(pComponent));

		// Release the component - because we need to reuse the pointer later
		pComponent->Release();
		pComponent = NULL;

		// Create the second filler 
		checkResult(defs.cdFiller()->
					CreateInstance(IID_IAAFFiller,
								   (IUnknown **) &pFiller));

		checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent));
		// Set values for the filler
	    checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength));
		// append the filler to the sequence
		checkResult(pSequence->AppendComponent(pComponent));
		pComponent->Release();
		pComponent = NULL;
		pFiller->Release();
		pFiller = NULL;

		// Now, we append the composition mob to the file	
		checkResult(pHeader->AddMob(pMob));
		// and we are done !
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	

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

  if (pConstantValue)
		pConstantValue->Release();

	if (pParamDef)
		pParamDef->Release();

	if (pSourceClip)
		pSourceClip->Release();

	if (pSourceRef)
		pSourceRef->Release();

	if (pNewSlot)
		pNewSlot->Release();

	if (pSegment)
		pSegment->Release();

	if (pSequence)
		pSequence->Release();

	if (pFiller)
		pFiller->Release();
	if (pOperationDef)
		pOperationDef->Release();


	if (pOperationGroup)
		pOperationGroup->Release();

	if (pMob)
		pMob->Release();

	if (pCompMob)
		pCompMob->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();


	if (pTransition)
		pTransition->Release();

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

	return hr;
}
예제 #22
0
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;
}
예제 #23
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;
	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;

}
예제 #24
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;
}
예제 #25
0
static HRESULT ReadAAFFile(aafWChar* pFileName)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader*			pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IEnumAAFContainerDefs *pPlug = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
	aafUID_t			readUID;
	wchar_t				testString[256];

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

		// Get the AAF file header.
		checkResult(pFile->GetHeader(&pHeader));

		checkResult(pHeader->GetDictionary(&pDictionary));
	
		checkResult(pDictionary->GetContainerDefs(&pPlug));
		while(pPlug->NextOne (&pContainerDef) == AAFRESULT_SUCCESS)
		{
			checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef));
			checkResult(pDef->GetAUID(&readUID));
			if(memcmp(&readUID, &testUID, sizeof(aafUID_t)) == 0)
			{
				checkResult(pDef->GetName (testString, sizeof(testString)));
				checkExpression (wcscmp(testString, sName) == 0, AAFRESULT_TEST_FAILED);

				aafUInt32 nameLen;
				checkResult (pDef->GetNameBufLen (&nameLen));
				checkExpression (((wcslen (sName)+1) * sizeof (aafCharacter) == nameLen),
						 AAFRESULT_TEST_FAILED);

				checkResult(pDef->GetDescription (testString, sizeof(testString)));
				checkExpression (wcscmp(testString, sDescription) == 0, AAFRESULT_TEST_FAILED);

				checkResult (pDef->GetDescriptionBufLen (&nameLen));
				checkExpression (((wcslen (sDescription)+1) * sizeof (aafCharacter) == nameLen),
						 AAFRESULT_TEST_FAILED);

				break;
			}

                        pDef->Release();
                        pDef = NULL;
                        pContainerDef->Release();
                        pContainerDef = NULL;

		}//		checkResult(pPlug->NextOne(&pContainerDef));


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

	// Cleanup and return
	if (pHeader)
		pHeader->Release();
      
	if (pPlug)
		pPlug->Release();

	if (pDef)
		pDef->Release();
      
	if (pContainerDef)
		pContainerDef->Release();
            
	if (pDictionary)
		pDictionary->Release();
            
	if (pFile)
	{  // Close file
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}

	return hr;
}
예제 #26
0
static HRESULT  ReadAAFFile(aafWChar *  pFileName )
{
	HRESULT hr = AAFRESULT_SUCCESS;
	
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	IAAFCompositionMob *		pCMob = NULL;
	IAAFMob*					pMob = NULL;
	bool bFileOpen = false;
	aafNumSlots_t				numMobs;
	IAAFObject*					pObj = NULL;
	
	IEnumAAFProperties * pEnum = NULL;
	IAAFProperty *pProp = NULL;
	
	IAAFPropertyDef* pPropDef = NULL;
	IAAFPropertyValue* pPropVal = NULL;

	IAAFTypeDef*	pTypeDef  = NULL;

	try
	{
		// Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
		
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));
		
		// Validate that there is only one composition mob.
		checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs));
		checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
		
		// Enumerate over all Composition Mobs
		aafSearchCrit_t				criteria;
		criteria.searchTag = kAAFByMobKind;
		criteria.tags.mobKind = kAAFCompMob;
		checkResult(pHeader->GetMobs(&criteria, &pMobIter));
		while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
		{		
			//Get the Composition mob
			checkResult (pMob->QueryInterface (IID_IAAFCompositionMob,
				(void **) &pCMob));
			
			//Get the Object
			checkResult (pCMob->QueryInterface (IID_IAAFObject,
				(void **) &pObj));
			
			//From the Object, we can get the properties ....
			aafUInt32 propCount = 0;
			checkResult (pObj->CountProperties (&propCount));
			//A composition should have at least 5 properties ...
 			checkExpression(propCount>=5, AAFRESULT_TEST_FAILED);
			
			//Get Enumeration over properties
			checkResult (pObj->GetProperties (&pEnum));
			checkExpression (pEnum != 0, AAFRESULT_TEST_FAILED);
			while (propCount--)
			{
				//Check for property validity
				checkResult (pEnum->NextOne (&pProp));
				checkExpression (pProp != NULL, AAFRESULT_TEST_FAILED);
				//Now call prop methods
				
				//1.  Get Definition
				checkResult( pProp->GetDefinition(&pPropDef) );
				//2. Get Value
				checkResult( pProp->GetValue(&pPropVal) );

				//deal with prop value
				checkResult( pPropVal->GetType(&pTypeDef) );

				//From propval, get the typedef!!!!!!!!!!!!!!!!!!!!!
				IAAFTypeDefSP spTypeDef;
				checkResult( pPropVal->GetType(&spTypeDef) );

				//get category
				eAAFTypeCategory_t typeCat = kAAFTypeCatUnknown;
				checkResult (spTypeDef->GetTypeCategory(&typeCat));
				//make sure it is not unknown
				checkExpression(kAAFTypeCatUnknown != typeCat, AAFRESULT_TEST_FAILED);
				
				//Deal with our Name  String .... 
				if (typeCat == kAAFTypeCatString)
				{
					IAAFTypeDefStringSP  spTypeDefString;
					checkResult( spTypeDef->QueryInterface(IID_IAAFTypeDefString, 
												(void**)&spTypeDefString) );

					aafUInt32 bufSize = 
						//don't forget the NULL char, and factoring in the size of a wchar
						   (wcslen(TEST_NAME)+1) * sizeof(aafCharacter); 

					aafCharacter *nameBuf = new aafCharacter[bufSize];
					checkResult( spTypeDefString->GetElements(pPropVal, (aafMemPtr_t)nameBuf, bufSize) );
					checkExpression( wcscmp(TEST_NAME, nameBuf) == 0, AAFRESULT_TEST_FAILED );
					delete [] nameBuf;
				}

				//Done ...........

				//release typedef
				pTypeDef->Release();

				//release defintion + value
				pPropDef->Release();
				pPropVal->Release();
				
				//release this prop
				pProp->Release();
				pProp = NULL;

			}//while prop count
		}//while mob iter
	}//try
	
	catch (HRESULT & rResult)
	{
		hr = rResult;
	}
	
	//Release the rest ...
	if (pEnum) 
		pEnum->Release();
	
	if (pObj) 
		pObj->Release();
	if (pCMob) 
		pCMob->Release();
	if (pMob)
		pMob->Release();
	if (pMobIter)
		pMobIter->Release();
	if (pHeader)
		pHeader->Release();
	
	if (pFile) 
	{
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}
	
	return hr;
	
}
예제 #27
0
static HRESULT CreateAAFFile(const aafWChar * pFileName, testDataFile_t *dataFile, testType_t testType)
{
	IAAFFile*					pFile = NULL;
	IAAFHeader*					pHeader = NULL;
	IAAFDictionary*					pDictionary = NULL;
	IAAFMob*					pMob = NULL;
	IAAFMasterMob*				pMasterMob = NULL;
	IAAFEssenceAccess*			pEssenceAccess = NULL;
	IAAFEssenceFormat*			pFormat = NULL;
	IAAFEssenceFormat			*format = NULL;
	IAAFLocator					*pLocator = NULL;
	aafMobID_t					masterMobID;
	aafProductIdentification_t	ProductInfo;
	aafRational_t				editRate = {44100, 1};
	aafRational_t				sampleRate = {44100, 1};
	FILE*						pWavFile = NULL;
	unsigned char				dataBuff[4096], *dataPtr;
	aafUInt32					dataOffset, dataLen;
	aafUInt16					bitsPerSample, numCh;
	aafInt32					n, numSpecifiers;
	aafUID_t					essenceFormatCode, testContainer;
  IAAFClassDef *pMasterMobDef = NULL;
  IAAFClassDef *pNetworkLocatorDef = NULL;
  IAAFDataDef *pSoundDef = NULL;
  aafUInt32 samplesWritten, bytesWritten;


	// Delete any previous test file before continuing...
	char chFileName[1000];
	convert(chFileName, sizeof(chFileName), pFileName);
	remove(chFileName);
	if(dataFile != NULL)
	{
		// Delete any previous test file before continuing...
		char chFileName[1000];
		convert(chFileName, sizeof(chFileName), dataFile->dataFilename);
		remove(chFileName);
	}

	aafProductVersion_t v;
	v.major = 1;
	v.minor = 0;
	v.tertiary = 0;
	v.patchLevel = 0;
	v.type = kAAFVersionUnknown;
	ProductInfo.companyName = companyName;
	ProductInfo.productName = productName;
	ProductInfo.productVersion = &v;
	ProductInfo.productVersionString = NULL;
	ProductInfo.productID = NIL_UID;
	ProductInfo.platform = NULL;

	/* Create a new AAF file */

	check(AAFFileOpenNewModifyEx (pFileName, &kAAFFileKind_Aaf4KBinary, 0, &ProductInfo, &pFile));
	check(pFile->GetHeader(&pHeader));
	
	/* Get the AAF Dictionary from the file */
	check(pHeader->GetDictionary(&pDictionary));
	
  /* Lookup class definitions for the objects we want to create. */
  check(pDictionary->LookupClassDef(AUID_AAFMasterMob, &pMasterMobDef));
  check(pDictionary->LookupClassDef(AUID_AAFNetworkLocator, &pNetworkLocatorDef));

  /* Lookup any necessary data definitions. */
  check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pSoundDef));

	/* Create a Mastermob */
	
	// Get a Master MOB Interface
	check(pMasterMobDef->
		  CreateInstance(IID_IAAFMasterMob, 
						 (IUnknown **)&pMasterMob));
	// Get a Mob interface and set its variables.
	check(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
	check(pMob->GetMobID(&masterMobID));
	check(pMob->SetName(L"A Master Mob"));
	
	// Add it to the file 
	check(pHeader->AddMob(pMob));

	if(dataFile != NULL)
	{
		// Make a locator, and attach it to the EssenceDescriptor
		check(pNetworkLocatorDef->
			  CreateInstance(IID_IAAFLocator, 
							 (IUnknown **)&pLocator));		
		check(pLocator->SetPath (dataFile->dataFilename));
		testContainer = dataFile->dataFormat;
	}
	else
	{
		pLocator = NULL;
		testContainer = ContainerAAF;
	}


	// Open the Essence file to be included in this AAF file("Laser.wav")
	pWavFile = fopen("Laser.wav", "r");
	if (pWavFile)
	{
		// Read in the essence data
		int rc = fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile);
		(void)rc;
		check(loadWAVEHeader(dataBuff,
										&bitsPerSample,
										&numCh,
										&sampleRate,
										&dataOffset,
										&dataLen));


		assert (numCh == 1, "Input file must be mono audio data");
		//  The testtype is for Internal Standard calls so set dataPtr
		dataPtr = dataBuff + dataOffset;
		
		/* Create the Essence Data specifying the codec, container, edit rate and sample rate */
		check(pMasterMob->CreateEssence(1,				// Slot ID
									pSoundDef,			// MediaKind
									kAAFCodecWAVE,			// codecID
									editRate,			// edit rate
									sampleRate,			// sample rate
									kAAFCompressionDisable,
									pLocator,			// In current file
									testContainer,		// In AAF Format
									&pEssenceAccess));	// Compress disabled

		check(pEssenceAccess->GetFileFormatParameterList (&format));
		check(format->NumFormatSpecifiers (&numSpecifiers));
		for(n = 0; n < numSpecifiers; n++)
		{
			check(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL));
		}
		format->Release();
		format = NULL;

		// Tell the AAFEssenceAccess what the format is.
		check(pEssenceAccess->GetEmptyFileFormat (&pFormat));
		check(pFormat->NumFormatSpecifiers (&numSpecifiers));

		/* Set the properties that describe the essence data, such as audio sample size */
		
		aafInt32	sampleSize = bitsPerSample;
		check(pFormat->AddFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleSize), (aafUInt8 *)&sampleSize));
		check(pEssenceAccess->PutFileFormat (pFormat));
		pFormat->Release();
		pFormat = NULL;
		
		/* Write the samples */

		aafInt32 samplesLeft = dataLen;
		aafUInt32 bytesPerSample = bitsPerSample/8;
		aafUInt32 samplesToWrite = 0;
		if (dataLen*bytesPerSample < (sizeof(dataBuff) - dataOffset))
			samplesToWrite = dataLen;
		else
			samplesToWrite  = (sizeof(dataBuff) - dataOffset)/bytesPerSample;

		//read input wav file in chunks and write them to Essence stream
		while (true) 
		{
			check(pEssenceAccess->WriteSamples(	samplesToWrite,	// Number of Samples
												sizeof(dataBuff), // buffer size
												dataPtr,	// THE data
												&samplesWritten,
												&bytesWritten));
			samplesLeft = samplesLeft-samplesToWrite;
			if (samplesLeft <= 0)
				break;
			
			aafUInt32 bytesToWrite = fread(dataBuff, sizeof(unsigned char), sizeof(dataBuff), pWavFile);
			samplesToWrite = bytesToWrite/bytesPerSample;
			dataPtr = dataBuff;
		}

		// Close the essence data file
		fclose(pWavFile);

		/* Set the essence to indicate that you have finished writing the samples */
		check(pEssenceAccess->CompleteWrite());

    pEssenceAccess->Release();
    pEssenceAccess = NULL;
	}
	else
	{
		printf("***Failed to open Wave file Laser.wav\n");
	}

	/* Release COM interfaces */

	pMob->Release();
	pMob = NULL;
	pMasterMob->Release();
	pMasterMob = NULL;

  pSoundDef->Release();
  pSoundDef = NULL;
  pNetworkLocatorDef->Release();
  pNetworkLocatorDef = NULL;
  pMasterMobDef->Release();
  pMasterMobDef = NULL;

	pDictionary->Release();
	pDictionary = NULL;
	pHeader->Release();
	pHeader = NULL;
	
	/* Save the AAF file */
	pFile->Save();
	
	/* Close the AAF file */
	pFile->Close();
	pFile->Release();
	pFile = NULL;


cleanup:
	// Cleanup and return
	if(pFormat)
		pFormat->Release();

	if(format)
		format->Release();

	if(pLocator)
		pLocator->Release();

  if (pEssenceAccess)
		pEssenceAccess->Release();
	
	if (pMasterMob)
		pMasterMob->Release();

	if (pMob)
		pMob->Release();

  if (pSoundDef)
    pSoundDef->Release();

  if (pNetworkLocatorDef)
    pNetworkLocatorDef->Release();

  if (pMasterMobDef)
    pMasterMobDef->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();

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


	return moduleErrorTmp;
}
예제 #28
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;
}
예제 #29
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
    // IAAFSession *				pSession = NULL;
	IAAFFile *					pFile = NULL;
	bool						bFileOpen = false;
	IAAFHeader *				pHeader = NULL;
	IAAFDictionary*				pDictionary = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	IEnumAAFMobSlots*			pEnum = NULL;
	IAAFMob*					pMob = NULL;
	IAAFMobSlot*				pMobSlot = NULL;
	IAAFSegment*				pSegment = NULL;
	IAAFSequence*				pSequence = NULL;
	IAAFTransition*				pTransition = NULL;
	IAAFComponent*				pComponent = NULL;
	IAAFFiller*					pFiller = NULL;
	IAAFOperationGroup*					pOperationGroup = NULL;
	IEnumAAFComponents*			pCompIter = NULL;
	aafLength_t					transitionLength;
	aafPosition_t				cutPoint;

	aafNumSlots_t				numMobs;
	aafUInt32					numComponents = 0;
	HRESULT						hr = S_OK;

	try
	{
		// Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
 
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));

		// Get the number of mobs in the file (should be one)
		checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
		checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);

		checkResult(pHeader->GetMobs( NULL, &pMobIter));
		while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
		{
			checkResult(pMob->GetSlots (&pEnum));

			while (AAFRESULT_SUCCESS == pEnum->NextOne (&pMobSlot))
			{
				checkResult(pMobSlot->GetSegment (&pSegment));
				// Check to see if Segment is a Sequence
				checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **) &pSequence));
				// It is, so get a Component Iterator
				checkResult(pSequence->CountComponents(&numComponents));
				// Verify that all 3 components(Filler, Transition, Filler) are present
				checkExpression(numComponents == 3,  AAFRESULT_TEST_FAILED);
				checkResult(pSequence->GetComponents(&pCompIter));
				// Now visit each and every one of the components.
				while(AAFRESULT_SUCCESS == pCompIter->NextOne(&pComponent))
				{
					// Find out what kind of segment we have
					if ((pComponent->QueryInterface(IID_IAAFTransition, (void **)&pTransition)) == AAFRESULT_SUCCESS)
					{
						// This is the transition 
						checkResult(pTransition->GetCutPoint (&cutPoint));
						checkResult(pComponent->GetLength(&transitionLength));
						checkResult(pTransition->GetOperationGroup(&pOperationGroup));
						// Check results !!
						checkExpression(cutPoint == 0, AAFRESULT_TEST_FAILED);
						checkExpression(transitionLength == 100, AAFRESULT_TEST_FAILED);
						pTransition->Release();
						pTransition = NULL;
					}
					else
					{
						// validate that the other segments are Fillers
						checkResult(pComponent->QueryInterface(IID_IAAFFiller, (void **)&pFiller));
						pFiller->Release();
						pFiller = NULL;
					}
					pComponent->Release();
					pComponent = NULL;
				}
				pSegment->Release();
				pSegment = NULL;
				pSequence->Release();
				pSequence = NULL;
				pCompIter->Release();
				pCompIter = NULL;
			}

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

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

	if (pOperationGroup)
		pOperationGroup->Release();

	if (pComponent)
		pComponent->Release();

	if (pSegment)
		pSegment->Release();

	if (pMobSlot)
		pMobSlot->Release();

	if (pSequence)
		pSequence->Release();

	if (pCompIter)
		pCompIter->Release();

	if (pEnum)
		pEnum->Release();

	if (pFiller)
		pFiller->Release();

	if (pMob)
		pMob->Release();

	if (pMobIter)
		pMobIter->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();

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

	return hr;
}
예제 #30
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;
}