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; }
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; }
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; }
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; // 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.cdContainerDef()-> CreateInstance(IID_IAAFContainerDef, (IUnknown **)&pContainerDef)); checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef)); checkResult(pContainerDef->Initialize (TEST_ID1, sName1, sDescription1)); checkResult(pDictionary->RegisterContainerDef(pContainerDef)); pDef->Release(); pDef = NULL; pContainerDef->Release(); pContainerDef = NULL; checkResult(defs.cdContainerDef()-> CreateInstance(IID_IAAFContainerDef, (IUnknown **)&pContainerDef)); checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef)); checkResult(pContainerDef->Initialize (TEST_ID2, sName2, sDescription2)); checkResult(pDictionary->RegisterContainerDef(pContainerDef)); } 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; }