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 RegisterDefs (IAAFDictionary * pDict) { assert (pDict); CAAFBuiltinDefs defs (pDict); // IAAFTypeDefSP pTypeUInt8; // checkResult(pDict->LookupTypeDef(kAAFTypeID_UInt8, &pTypeUInt8)); { // Create an opaque type and register it in the dictionary. IAAFTypeDefSP pOpaqueType; IAAFTypeDefRenameSP pOpaqueTestType; checkResult(pDict->CreateMetaInstance(AUID_AAFTypeDefRename, IID_IAAFTypeDefRename, (IUnknown **)&pOpaqueTestType)); checkResult(pOpaqueTestType->Initialize(kTestTypeID, defs.tdUInt8(), L"TestUInt8")); checkResult(pOpaqueTestType->QueryInterface(IID_IAAFTypeDef, (void **)&pOpaqueType)); checkResult(pDict->RegisterOpaqueTypeDef(pOpaqueType)); } RegisterOneMetaDef (/* dictionary*/ pDict, /* def object's class id */ AUID_AAFTypeDefRename, /* IID of def to pass to Init */ IID_IAAFTypeDefRename, /* SP of def to use with Init */ IAAFTypeDefRenameSP, /* Init() invocation */ Initialize (kTestTypeID, defs.tdUInt8(), L"TestUInt8"), /* IID of type to QI */ IID_IAAFMetaDefinition, /* SP for type to QI */ IAAFMetaDefinitionSP, /* IID of def to register */ IID_IAAFTypeDef, /* SP for def to register */ IAAFTypeDefSP, /* reg method on pDict */ RegisterTypeDef); { // Make sure that "TestUInt8" is no longer opaque. IAAFTypeDefSP pOpaqueTestType; checkExpression(FAILED(pDict->LookupOpaqueTypeDef(kTestTypeID, &pOpaqueTestType)), AAFRESULT_TEST_FAILED); } RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdDataDef(), /* IID of def to pass to Init */ IID_IAAFDataDef, /* SP of def to use with Init */ IAAFDataDefSP, /* Init() invocation */ Initialize (kTestDataDefID, L"TestDataDef", L"Desc"), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFDataDef, /* SP for def to register */ IAAFDataDefSP, /* reg method on pDict */ RegisterDataDef); RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdOperationDef(), /* IID of def to pass to Init */ IID_IAAFOperationDef, /* SP of def to use with Init */ IAAFOperationDefSP, /* Init() invocation */ Initialize (kTestOperationDefID, L"TestOperationDef", L"Desc"), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFOperationDef, /* SP for def to register */ IAAFOperationDefSP, /* reg method on pDict */ RegisterOperationDef); // Hack! { IAAFOperationDefSP od; checkResult (pDict->LookupOperationDef (kTestOperationDefID, &od)); checkResult (od->SetDataDef (defs.ddkAAFMatte())); } RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdParameterDef(), /* IID of def to pass to Init */ IID_IAAFParameterDef, /* SP of def to use with Init */ IAAFParameterDefSP, /* Init() invocation */ Initialize (kTestParameterDefID, L"TestParameterDef", L"Desc", defs.tdRational()), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFParameterDef, /* SP for def to register */ IAAFParameterDefSP, /* reg method on pDict */ RegisterParameterDef); RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdCodecDef(), /* IID of def to pass to Init */ IID_IAAFCodecDef, /* SP of def to use with Init */ IAAFCodecDefSP, /* Init() invocation */ Initialize (kTestCodecDefID, L"TestCodecDef", L"Desc"), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFCodecDef, /* SP for def to register */ IAAFCodecDefSP, /* reg method on pDict */ RegisterCodecDef); // Hack! Codec defs must have at least one data def appended in // order to be saved correctly... { IAAFCodecDefSP cd; IAAFClassDefSP pClassDef; checkResult (pDict->LookupCodecDef (kTestCodecDefID, &cd)); checkResult (cd->AddEssenceKind (defs.ddkAAFMatte())); checkResult(pDict->LookupClassDef(kAAFClassID_EssenceDescriptor, &pClassDef)); checkResult(cd->SetFileDescriptorClass (pClassDef)); } RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdContainerDef(), /* IID of def to pass to Init */ IID_IAAFContainerDef, /* SP of def to use with Init */ IAAFContainerDefSP, /* Init() invocation */ Initialize (kTestContainerDefID, L"TestContainerDef", L"Desc"), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFContainerDef, /* SP for def to register */ IAAFContainerDefSP, /* reg method on pDict */ RegisterContainerDef); RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdInterpolationDefinition(), /* IID of def to pass to Init */ IID_IAAFInterpolationDef, /* SP of def to use with Init */ IAAFInterpolationDefSP, /* Init() invocation */ Initialize (kTestInterpolationDefID, L"TestInterpolationDef", L"Desc"), /* IID of type to QI */ IID_IAAFDefObject, /* SP for type to QI */ IAAFDefObjectSP, /* IID of def to register */ IID_IAAFInterpolationDef, /* SP for def to register */ IAAFInterpolationDefSP, /* reg method on pDict */ RegisterInterpolationDef); RegisterOneDef (/* dictionary*/ pDict, /* def object's class */ defs.cdPluginDef(), /* IID of def to pass to Init */ IID_IAAFPluginDef, /* SP of def to use with Init */ IAAFPluginDefSP, /* Init() invocation */ Initialize (kTestPluginDefID, L"TestPluginDef", L"Desc"), /* IID of type to QI */ IID_IAAFObject, /* SP for type to QI */ IAAFObjectSP, /* IID of def to register */ IID_IAAFPluginDef, /* SP for def to register */ IAAFPluginDefSP, /* reg method on pDict */ RegisterPluginDef); 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; 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; }