Пример #1
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
	IAAFFile				*pFile = NULL;
	bool					bFileOpen = false;
	IAAFHeader				*pHeader = NULL;
	IEnumAAFMobs			*mobIter = NULL;
	IAAFMob					*aMob = NULL;
	IEnumAAFMobSlots		*slotIter = NULL;
	IAAFMobSlot				*slot = NULL;
	IAAFSegment				*pSeg = NULL;
	IAAFSourceClip			*pSourceClip = NULL;
	IAAFDataDef *            pDataDef = 0;
	IAAFDefObject *          pDefObj = 0;
	aafNumSlots_t			numMobs, n;
	aafSlotID_t				s;
	aafUInt32				length;
	HRESULT					hr = S_OK;
	aafUID_t				readUID, typeUID = kAAFDataDef_Picture;
	
	try
	{
		// Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
		
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));
		
		
		checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
		checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
		
		
		aafSearchCrit_t		criteria;
		criteria.searchTag = kAAFNoSearch;
		checkResult(pHeader->GetMobs (&criteria, &mobIter));
		
		for(n = 0; n < numMobs; n++)
		{
			aafWChar		name[500], slotName[500];
			aafNumSlots_t	numSlots;
			aafMobID_t		mobID;
			aafSlotID_t		trackID;
			
			checkResult(mobIter->NextOne (&aMob));
			checkResult(aMob->GetName (name, sizeof(name)));
			checkResult(aMob->GetMobID (&mobID));
			
			checkResult(aMob->CountSlots (&numSlots));
			checkExpression(5 == numSlots, AAFRESULT_TEST_FAILED);
			
			checkResult(aMob->GetSlots(&slotIter));
			
			for(s = 0; s < (aafSlotID_t)numSlots; s++)
			{
				checkResult(slotIter->NextOne (&slot));
				checkResult(slot->GetNameBufLen(&length));
				checkResult(slot->GetName (slotName, length));
				checkExpression (wcscmp(slotName, slotNames[s]) == 0, AAFRESULT_TEST_FAILED);
				checkResult(slot->GetSlotID(&trackID));
				checkExpression (trackID == s+1, AAFRESULT_TEST_FAILED);
				checkResult(slot->GetPhysicalNum(&trackID));
				checkExpression (trackID == s+2, AAFRESULT_TEST_FAILED);
				checkResult(slot->GetPhysicalNum(&trackID));
				checkResult(slot->GetDataDef(&pDataDef));
				checkResult(pDataDef->QueryInterface (IID_IAAFDefObject, (void **)&pDefObj));
				checkResult(pDefObj->GetAUID(&readUID));
				checkExpression (memcmp(&typeUID, &readUID, sizeof(typeUID)) == 0, AAFRESULT_TEST_FAILED);
				checkResult(slot->GetSegment(&pSeg));
				checkResult(pSeg->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip));
				pDataDef->Release();
				pDataDef = 0;
				pDefObj->Release ();
				pDefObj = 0;
				pSourceClip->Release();
				pSourceClip = NULL;
				pSeg->Release();
				pSeg = NULL;
				slot->Release();
				slot = NULL;
			}
			
			aMob->Release();
			aMob = NULL;
		}
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}
	
	// Cleanup object references
	if (slot)
	  {
		slot->Release();
		slot = 0;
	  }
	
	if (pSeg)
	  {
		pSeg->Release();
		pSeg = 0;
	  }
	
	if (pSourceClip)
	  {
		pSourceClip->Release();
		pSourceClip = 0;
	  }
	
	if (slotIter)
	  {
		slotIter->Release();
		slotIter = 0;
	  }
	
	if (aMob)
	  {
		aMob->Release();
		aMob = 0;
	  }
	
	if (mobIter)
	  {
		mobIter->Release();
		mobIter = 0;
	  }
	
	if (pHeader)
	  {
		pHeader->Release();
		pHeader = 0;
	  }
	
	if (pDataDef)	
	  {
		pDataDef->Release();
		pDataDef = 0;
	  }

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

	if (pFile)
	{  // Close file
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
		pFile = 0;
	}
	
	return hr;
}
Пример #2
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
  IAAFDictionary		*pDictionary = NULL;
  IAAFFile 				*pFile = NULL;
  bool 					bFileOpen = false;
  IAAFHeader 			*pHeader = NULL;
  IEnumAAFMobs 			*mobIter = NULL;
  IAAFMob				*aMob = NULL;
  IEnumAAFMobSlots		*slotIter = NULL;
  IAAFMobSlot			*slot = NULL;
  aafNumSlots_t			numMobs, n, s;
  HRESULT				hr = S_OK;
  aafUInt32 			bufLen = 0;
  aafUInt32 			bytesRead = 0;
  aafUInt32				numFound = 0;
  aafWChar				value[500];
  IEnumAAFTaggedValues 	*enumTaggedVal = NULL;
  IAAFTaggedValue		*taggedVal = NULL;
  aafUID_t				testKey;
  IEnumAAFKLVData		*klvEnum = NULL;
  IAAFKLVData			*pKLVData = NULL;
  IAAFTypeDef*			pBaseType = NULL;
  IAAFSourceClip		*pSourceClip = NULL;
  IAAFSourceReference	*pSourceRef = NULL;
  IAAFSegment			*pSegment = NULL;
  aafMobID_t			sourceID;
  int 					i;


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

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


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


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

	  for(n = 0; n < numMobs; n++)
		{
		  aafWChar		name[500], slotName[500];
		  aafNumSlots_t	numSlots;
		  aafMobID_t		mobID;
		  aafSlotID_t		trackID;
		  aafUInt32 nameBufLen = 0;

		  checkResult(mobIter->NextOne (&aMob));
      
	      // Check GetNameBufLen and GetName
	      checkExpression(aMob->GetNameBufLen(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
	      checkResult(aMob->GetNameBufLen(&nameBufLen));
	      checkExpression(((wcslen(mobName) + 1) * sizeof(aafCharacter)) == nameBufLen, AAFRESULT_TEST_FAILED);
		  checkExpression(aMob->GetName (NULL, nameBufLen) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkExpression(aMob->GetName (name, 4) == AAFRESULT_SMALLBUF, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetName (name, nameBufLen));
		  checkExpression (wcscmp(mobName, name) == 0, AAFRESULT_TEST_FAILED);

	      // Check GetMobID
		  checkExpression(aMob->GetMobID (NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetMobID (&mobID));
		  checkExpression(memcmp(&MOBTestID, &mobID, sizeof(mobID)) == 0, AAFRESULT_TEST_FAILED);

		  // Check the time stamps
		  aafTimeStamp_t created = { {0,0,0}, {0,0,0,0} };
		  checkExpression(aMob->GetCreateTime(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetCreateTime(&created));
		  checkTimeStampsAreEqual(creationTimeStamp, created);
		  aafTimeStamp_t modified = { {0,0,0}, {0,0,0,0} };
		  checkExpression(aMob->GetModTime(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetModTime(&modified));
		  checkTimeStampsAreEqual(modificationTimeStamp, modified);

	      // Check the GetMobInfo data.
	      memset(&created, 0, sizeof(created));
	      memset(&modified, 0, sizeof(modified));
	      checkExpression(aMob->GetMobInfo(NULL, &created, 
      								   name, sizeof(name)) == AAFRESULT_NULL_PARAM,
      														  AAFRESULT_TEST_FAILED);
	      checkExpression(aMob->GetMobInfo(&modified, NULL, 
      								   name, sizeof(name)) == AAFRESULT_NULL_PARAM,
      														  AAFRESULT_TEST_FAILED);
	      checkExpression(aMob->GetMobInfo(&modified, &created, 
      								   NULL, sizeof(name)) == AAFRESULT_NULL_PARAM,
      														  AAFRESULT_TEST_FAILED);
		  checkExpression(aMob->GetMobInfo(&modified, &created, 
      								   name, 1) == AAFRESULT_SMALLBUF,
      												AAFRESULT_TEST_FAILED);
	      checkResult(aMob->GetMobInfo(&modified, &created, name, sizeof(name)));
		  checkTimeStampsAreEqual(creationTimeStamp, created);
		  checkTimeStampsAreEqual(modificationTimeStamp, modified);
		  checkExpression (wcscmp(mobName, name) == 0, AAFRESULT_TEST_FAILED);

		  checkExpression(aMob->CountSlots (NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->CountSlots (&numSlots));

		  //seven slots made by IAAFMob and  one static slot and event slot made throught IAAFMOb2
		  checkExpression((7+1+1) == numSlots, AAFRESULT_TEST_FAILED);

		  checkExpression(aMob->GetSlots(NULL) == AAFRESULT_NULL_PARAM, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetSlots(&slotIter));

		  for(s = 0; s < numSlots; s++)
			{
			  checkResult(slotIter->NextOne (&slot));
			  checkResult(slot->GetNameBufLen(&bufLen));
			  checkResult(slot->GetName (slotName, bufLen));
			  checkResult(slot->GetSlotID(&trackID));
			  checkExpression (wcscmp(slotName, slotNames[s]) == 0, AAFRESULT_TEST_FAILED);
			  checkExpression(trackID == (s+1), AAFRESULT_TEST_FAILED);

			  slot->Release();
			  slot = NULL;
			  bufLen = 0;
			  trackID = 0;
			}
			slotIter->Release();
			slotIter = NULL;
			
			// GetSlotAt
			checkExpression(aMob->GetSlotAt(1, NULL) == AAFRESULT_NULL_PARAM,
														AAFRESULT_TEST_FAILED);
			checkExpression(aMob->GetSlotAt(9, &slot) == AAFRESULT_BADINDEX,
														AAFRESULT_TEST_FAILED);
			for (s = 0; s < numSlots; ++s)
			{
				checkResult(aMob->GetSlotAt(s, &slot));
				checkResult(slot->GetNameBufLen(&bufLen));
				checkResult(slot->GetName(slotName, bufLen));
				checkResult(slot->GetSlotID(&trackID));
				checkExpression(wcscmp(slotName, slotNames[s]) == 0, AAFRESULT_TEST_FAILED);
				checkExpression(trackID == (s+1), AAFRESULT_TEST_FAILED);	

				if ( 0 < s && s < 5 ) // These are the SourceClips
				{
					checkResult(slot->GetSegment(&pSegment));
			  		checkResult(pSegment->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip));
				  	checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef));
				    checkResult(pSourceRef->GetSourceID(&sourceID));
				    checkExpression(memcmp(&sourceID, &MOBTestID3, sizeof(aafMobID_t)) == 0,
				    													 AAFRESULT_TEST_FAILED);
			  		pSourceRef->Release();
			  		pSourceRef = NULL;
			  		pSourceClip->Release();
            pSourceClip = NULL;
			  		pSegment->Release();
            pSegment = NULL;
				}
				
				slot->Release();
				slot = NULL;
				bufLen = 0;
				trackID = 0;
			}			

		  // ChangeRef
		  checkResult(aMob->ChangeRef(MOBTestID3, MOBTestID4));

		  for (s = 1; s < 5; ++s) // These are the SourceClips
		  {
				checkResult(aMob->GetSlotAt(s, &slot));
				checkResult(slot->GetSegment(&pSegment));
  		  		checkResult(pSegment->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip));
	  	  		checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef));
	      		checkResult(pSourceRef->GetSourceID(&sourceID));
	      		checkExpression(memcmp(&sourceID, &MOBTestID4, sizeof(aafMobID_t)) == 0,
		   													 AAFRESULT_TEST_FAILED);
			  	pSourceRef->Release();
			  	pSourceRef = NULL;
			  	pSourceClip->Release();
			  	pSourceClip = NULL;
			  	pSegment->Release();
			  	pSegment = NULL;
		  		slot->Release();
			  	slot = NULL;
		  }

		  // try it again with a MobID it won't find.  Make sure nothing changes
		  checkResult(aMob->ChangeRef(MOBTestID3, MOBTestID2));

		  for (s = 1; s < 5; ++s) // These are the SourceClips
		  {
				checkResult(aMob->GetSlotAt(s, &slot));
				checkResult(slot->GetSegment(&pSegment));
  		  		checkResult(pSegment->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip));
	  	  		checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef));
	      		checkResult(pSourceRef->GetSourceID(&sourceID));
	      		checkExpression(memcmp(&sourceID, &MOBTestID4, sizeof(aafMobID_t)) == 0,
		   													 AAFRESULT_TEST_FAILED);
			  	pSourceRef->Release();
			  	pSourceRef = NULL;
			  	pSourceClip->Release();
			  	pSourceClip = NULL;
			  	pSegment->Release();
			  	pSegment = NULL;
		  		slot->Release();
			  	slot = NULL;
		  }

		  // LookUpSlot
		  checkResult(aMob->LookupSlot(4, &slot));
		  checkResult(slot->GetSegment(&pSegment));
		  checkResult(pSegment->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip));
		  checkResult(pSourceClip->QueryInterface (IID_IAAFSourceReference, (void **)&pSourceRef));
		  checkResult(pSourceRef->GetSourceID(&sourceID));

		  checkResult(slot->GetNameBufLen(&bufLen));
		  checkResult(slot->GetName(slotName, bufLen));
		  checkResult(slot->GetSlotID(&trackID));
		  checkExpression(wcscmp(slotName, slotNames[3]) == 0, AAFRESULT_TEST_FAILED);
		  checkExpression(trackID == (4), AAFRESULT_TEST_FAILED);	

		  pSourceRef->Release();
		  pSourceRef = NULL;		
		  pSourceClip->Release();
		  pSourceClip = NULL;		
		  pSegment->Release();
		  pSegment = NULL;		
		  slot->Release();
		  slot = NULL;		

      
      checkExpression(aMob->LookupSlot(10, &slot) == AAFRESULT_SLOT_NOT_FOUND,
													AAFRESULT_TEST_FAILED);

		  checkExpression(aMob->LookupSlot(0, NULL) == AAFRESULT_NULL_PARAM,
													AAFRESULT_TEST_FAILED);
					  												
		  // OffsetToMobTimecode
		  // 7/5/00  - this method is broken so the tests that will 
		  // make it fail have been commented out.  This module test 
		  // will still report Partial Success until implementation has been fixed
		  aafPosition_t		offset = 1;
		  aafTimecode_t		timecode;
		  // initialize timecode values
		  timecode.startFrame = 0;
		  timecode.drop = kAAFTcDrop;
		  timecode.fps = 24;

		  checkResult(aMob->LookupSlot(6, &slot));
		  checkResult(slot->GetSegment(&pSegment));

		  checkResult(aMob->OffsetToMobTimecode(pSegment, &offset, &timecode));
		  checkExpression(timecode.startFrame == (TCstartFrame + offset), AAFRESULT_TEST_FAILED);
		  checkExpression(timecode.drop == TCdrop, AAFRESULT_TEST_FAILED);
		  checkExpression(timecode.fps == TCfps, AAFRESULT_TEST_FAILED);

		  checkExpression(aMob->OffsetToMobTimecode(pSegment, NULL, &timecode) == AAFRESULT_NULL_PARAM,
															AAFRESULT_TEST_FAILED);
		  checkExpression(aMob->OffsetToMobTimecode(pSegment, &offset, NULL) == AAFRESULT_NULL_PARAM,
															AAFRESULT_TEST_FAILED);
															
		  // reinitialize values
		  timecode.startFrame = 0;
		  timecode.drop = kAAFTcDrop;
		  timecode.fps = 24;

		  // According to IDL this should search for the slot containing the timecode segment
		  checkResult(aMob->OffsetToMobTimecode(NULL, &offset, &timecode));
		  checkExpression(timecode.startFrame == (TCstartFrame + offset), AAFRESULT_TEST_FAILED);
		  checkExpression(timecode.drop == TCdrop, AAFRESULT_TEST_FAILED);
		  checkExpression(timecode.fps == TCfps, AAFRESULT_TEST_FAILED);
															
		  pSegment->Release();
		  pSegment = NULL;
		  slot->Release();
		  slot = NULL;
		  
		  // Pass in a segment that is not a timecode and make sure it returns correct hr
		  checkResult(aMob->LookupSlot(1, &slot));
		  checkResult(slot->GetSegment(&pSegment));
		  checkExpression(aMob->OffsetToMobTimecode(pSegment, &offset, &timecode) == AAFRESULT_TIMECODE_NOT_FOUND,
															AAFRESULT_TEST_FAILED);
		  pSegment->Release();
		  pSegment = NULL;
		  slot->Release();
		  slot = NULL;

		  // GetKLVData
		  checkResult(pDictionary->LookupTypeDef (kAAFTypeID_UInt8Array, &pBaseType));
		  checkResult(pDictionary->RegisterKLVDataKey(TEST_KLV, pBaseType));
		  pBaseType->Release();
		  pBaseType = NULL;

		  checkResult(aMob->CountKLVData(&numFound));
		  checkExpression(numFound == 2, AAFRESULT_TEST_FAILED);
		  checkResult(aMob->GetKLVData(&klvEnum));
		  
		  checkResult(klvEnum->NextOne(&pKLVData));
		  checkResult(pKLVData->GetValueBufLen(&bufLen));
		  checkExpression(sizeof(KLVfrowney) == bufLen, AAFRESULT_TEST_FAILED);
		  checkResult(pKLVData->GetValue( sizeof(value), (unsigned char *)value, &bytesRead));
		  checkExpression(memcmp(value, KLVfrowney, sizeof(KLVfrowney)) == 0, AAFRESULT_TEST_FAILED);
		  checkResult(pKLVData->GetKey(&testKey));
		  checkExpression(memcmp(&testKey, &TEST_KLV, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED);
		  pKLVData->Release();
		  pKLVData = NULL;

		  checkResult(klvEnum->NextOne(&pKLVData));
		  checkResult(pKLVData->GetValueBufLen(&bufLen));
		  checkExpression(sizeof(KLVsmiley) == bufLen, AAFRESULT_TEST_FAILED);
		  checkResult(pKLVData->GetValue( sizeof(value), (unsigned char *)value, &bytesRead));
		  checkExpression(memcmp(value, KLVsmiley, sizeof(KLVsmiley)) == 0, AAFRESULT_TEST_FAILED);
		  checkResult(pKLVData->GetKey(&testKey));
		  checkExpression(memcmp(&testKey, &TEST_KLV, sizeof(aafUID_t)) == 0, AAFRESULT_TEST_FAILED);
		  pKLVData->Release();
		  pKLVData = NULL;

		  klvEnum->Release();
		  klvEnum = NULL;

		  checkExpression(aMob->GetKLVData(NULL) == AAFRESULT_NULL_PARAM,
		  												AAFRESULT_TEST_FAILED);	  


		  // Check the comments 
		  checkResult(aMob->GetComments(&enumTaggedVal));
		  for (i = 0; i < 5; ++i)
		  {
 			if (i==2)
 				continue;
 										
			checkResult(enumTaggedVal->NextOne(&taggedVal));
			
			checkResult(taggedVal->GetNameBufLen(&bufLen));
			checkResult(taggedVal->GetName(name, bufLen));
			checkExpression(wcscmp(name, pCategory[i]) == 0, AAFRESULT_TEST_FAILED);
			
			checkResult(taggedVal->GetValueBufLen(&bufLen));
			checkResult(taggedVal->GetValue(bufLen, (aafDataBuffer_t)value, &bytesRead));
			checkExpression(wcscmp(value, pComment[i]) == 0, AAFRESULT_TEST_FAILED);

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



		  // Check attributes and usage code.
		  // Need IAAFMob2 for that;
		  IAAFMob2* aMobInterface2 = 0;
		  checkResult( aMob->QueryInterface( IID_IAAFMob2, reinterpret_cast<void**>(&aMobInterface2) ) );
		  
		  IEnumAAFTaggedValues* pAttributesEnum = 0;
		  checkResult( aMobInterface2->GetAttributes( &pAttributesEnum ) );

		  int attributeCount = 0;
		  HRESULT atthr = AAFRESULT_SUCCESS;
		  IAAFTaggedValue* pAttribute = 0;
		  for( atthr = pAttributesEnum->NextOne( &pAttribute );
		       atthr == AAFRESULT_SUCCESS;
		       atthr = pAttributesEnum->NextOne( &pAttribute ) ) {

		    aafUInt32 bufLen = 0;
		    checkResult( pAttribute->GetNameBufLen(&bufLen) );

		    // "name" is 500 chars long... sized more than
		    // large enough for a simple test.
		    checkExpression( attributeCount < 2, AAFRESULT_TEST_FAILED );
		    checkResult( pAttribute->GetName( name, bufLen ) );
		    checkExpression( wcscmp(name, AttributeNames[attributeCount] ) == 0, AAFRESULT_TEST_FAILED );


		    // check the value

		    IAAFTypeDef* pAttributeTypeDef = NULL;
		    checkResult( pAttribute->GetTypeDefinition( &pAttributeTypeDef ) );
		    // It should be a string.
		    IAAFTypeDefString* pTDString = NULL;
		    checkResult( pAttributeTypeDef->QueryInterface( IID_IAAFTypeDefString, reinterpret_cast<void**>(&pTDString) ) );
		    checkResult( pAttribute->GetValue( sizeof(name),
		    			       reinterpret_cast<aafDataBuffer_t>(name), &bufLen ) );
		    checkExpression( wcscmp( AttributeValues[attributeCount], name ) == 0, AAFRESULT_TEST_FAILED );
		    

		    pAttributeTypeDef->Release();
		    pAttributeTypeDef = NULL;

		    pTDString->Release();
		    pTDString = NULL;

		    pAttribute->Release();
		    pAttribute = NULL;


		    attributeCount++;
		  }

		  checkExpression( 2 == attributeCount && atthr == AAFRESULT_NO_MORE_OBJECTS,
				   AAFRESULT_TEST_FAILED );

		  aafUID_t code;
		  checkResult( aMobInterface2->GetUsageCode( &code ) );
		  checkExpression( memcmp( &code, &kAAFUsage_SubClip, sizeof(code) ) == 0, AAFRESULT_TEST_FAILED );



		  pAttributesEnum->Release();
		  pAttributesEnum = NULL;
		    
		  enumTaggedVal->Release();
		  enumTaggedVal = NULL;
			
		  aMobInterface2->Release();
		  aMobInterface2 = NULL;
		  aMob->Release();
		  aMob = NULL;
		}




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

  // Cleanup object references
  if (slot)
    slot->Release();

  if (slotIter)
    slotIter->Release();

  if (aMob)
    aMob->Release();

  if (mobIter)
    mobIter->Release();

  if (pHeader)
    pHeader->Release();

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

  return hr;
}