Пример #1
0
HRESULT STDMETHODCALLTYPE
    CAAFEssenceFileContainer::GetIndexedDefinitionObject (aafUInt32 /* index */, IAAFDictionary *dict, IAAFDefObject **def)
{
	aafUID_t			uid;
	IAAFContainerDef	*container = NULL;
    IAAFClassDef        *pcd = 0;

	if((dict == NULL) || (def == NULL))
		return AAFRESULT_NULL_PARAM;

	XPROTECT()
	{
		CHECK(dict->LookupClassDef(AUID_AAFContainerDef, &pcd));
		CHECK(pcd->CreateInstance(IID_IAAFContainerDef, 
								  (IUnknown **)&container));
		pcd->Release();
		pcd = 0;
		uid = ContainerFile;
		CHECK(container->SetEssenceIsIdentified(kAAFFalse));
		CHECK(container->Initialize(uid, L"Raw file Container", L"Essence is in a non-container file."));
		CHECK(container->QueryInterface(IID_IAAFDefObject, (void **)def));
		container->Release();
		container = NULL;
	}
	XEXCEPT
	{
		if(container != NULL)
		  {
			container->Release();
			container = 0;
		  }
		if (pcd)
		  {
			pcd->Release();
			pcd = 0;
		  }
	}
	XEND

	return AAFRESULT_SUCCESS;
}
Пример #2
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*		pFile = NULL;
	IAAFHeader *        pHeader = NULL;
	IAAFDictionary*  pDictionary = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool bFileOpen = false;
	aafUID_t		uid = testUID;
	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->Initialize(uid, L"Test Container", L"Test Container Definition"));

		checkResult(pContainerDef->SetEssenceIsIdentified (kAAFTrue));

		checkResult(pDictionary->RegisterContainerDef(pContainerDef));
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}


  // Cleanup and return
  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;
}