//*********************************************************** // // SetIntegerPropOnObject() // // Set an integer property to the AAF object specified by pObj. // The value of the property is specified in value. // // Returns: // // On Success: AAFRESULT_SUCCESS // On Failure: An exception. // HRESULT AAFDomainUtils::SetIntegerPropOnObject(IAAFObject* pObj, aafUID_t* pClassID, aafUID_t* pPropID, const aafUID_t* pIntTypeID, aafMemPtr_t pValue, aafUInt32 ValueSize, IAAFDictionary *dict) { AAFCheck hr; // Create a property value from the supplied value (pValue) IAAFTypeDef* pTD; hr = dict->LookupTypeDef(*pIntTypeID, &pTD); AutoRelease<IAAFTypeDef> r1( pTD ); IAAFTypeDefInt* pTDInt; hr = pTD->QueryInterface(IID_IAAFTypeDefInt, (void**)&pTDInt); AutoRelease<IAAFTypeDefInt> r2( pTDInt ); // Now create a property value object with that value. IAAFPropertyValue* pPV; hr = pTDInt->CreateValue(pValue, ValueSize, &pPV); AutoRelease<IAAFPropertyValue> r3( pPV ); // Add the property to the target object. // Get the class def for the object IAAFClassDef* pCD; hr = dict->LookupClassDef(*pClassID, &pCD); AutoRelease<IAAFClassDef> r4( pCD ); IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); AutoRelease<IAAFPropertyDef> r5( pPD ); // Set the propeter value on the target object hr = pObj->SetPropertyValue(pPD, pPV); return AAFRESULT_SUCCESS; }
//*********************************************************** // // GetObjRefPropFromObject() // // Get a object reference property on the AAF object specified // by pObj. The value of the property is returned in ppObject. // // Returns: // // On Success: S_OK // On Failure: A failed HRESULT // HRESULT AAFDomainUtils::GetObjRefPropFromObject(IAAFObject* pObj, aafUID_t* pClassID, const aafUID_t* pPropTypeID, aafUID_t* pPropID, IAAFObject** ppObject) { IAAFPropertyValue* pPV = NULL; IAAFClassDef* pCD; HRESULT hr; // Get the property value for the target property hr = _dict->LookupClassDef(*pClassID, &pCD); if (SUCCEEDED(hr)) { IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); if (SUCCEEDED(hr)) { aafBool present = kAAFFalse; pObj->IsPropertyPresent(pPD, &present); if (present == kAAFTrue) hr = pObj->GetPropertyValue(pPD, &pPV); else hr = AAFRESULT_PROP_NOT_PRESENT; pPD->Release(); } pCD->Release(); } // Get the property type def from the dictionary to interpret this property value // and return the resulting object. if (SUCCEEDED(hr)) { IAAFTypeDef* pTD; hr = _dict->LookupTypeDef(*pPropTypeID, &pTD); if (SUCCEEDED(hr)) { IAAFTypeDefObjectRef* pTDObjectRef; hr = pTD->QueryInterface(IID_IAAFTypeDefObjectRef, (void**)&pTDObjectRef); if (SUCCEEDED(hr)) { IAAFObject* pTempObj; hr = pTDObjectRef->GetObject(pPV, IID_IAAFObject, (IUnknown **)&pTempObj); if (SUCCEEDED(hr)) { *ppObject = pTempObj; } pTDObjectRef->Release(); } pTD->Release(); } } if (pPV) pPV->Release(); return hr; }
//*********************************************************** // // SetObjRefPropOnObject() // // Set an object reference property on the AAF object specified // by pObj. The value of the property is specified in pObject. // // Returns: // // On Success: S_OK // On Failure: A failed HRESULT // HRESULT AAFDomainUtils::SetObjRefPropOnObject(IAAFObject* pObj, aafUID_t* pClassID, const aafUID_t* pPropTypeID, aafUID_t* pPropID, IAAFObject* pValue) { IAAFPropertyValue* pPV = NULL; IAAFTypeDef* pTD; HRESULT hr; // Create a property value from the supplied value (pValue) hr = _dict->LookupTypeDef(*pPropTypeID, &pTD); if (SUCCEEDED(hr)) { IAAFTypeDefObjectRef* pTDObjRef; hr = pTD->QueryInterface(IID_IAAFTypeDefObjectRef, (void**)&pTDObjRef); if (SUCCEEDED(hr)) { hr = pTDObjRef->CreateValue(pValue, &pPV); pTDObjRef->Release(); } pTD->Release(); } // Add the property to the target object. if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) { IAAFClassDef* pCD; // Get the class def for the object hr = _dict->LookupClassDef(*pClassID, &pCD); if (SUCCEEDED(hr)) { IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); if (SUCCEEDED(hr)) { // Set the propeter value on the target object hr = pObj->SetPropertyValue(pPD, pPV); pPD->Release(); } pCD->Release(); } } } if (pPV) pPV->Release(); return hr; }
//*********************************************************** // // GetIntegerPropFromObject() // // Get an integer property from the AAF object specified by pObj. // The value of the property is returned in pValue. // // Returns: // // On Success: AAFRESULT_SUCCESS // On Failure: An exception. // HRESULT AAFDomainUtils::GetIntegerPropFromObject(IAAFObject* pObj, const aafUID_t* pClassID, aafUID_t* pPropID, const aafUID_t* pIntTypeID, aafMemPtr_t pValue, aafUInt32 ValueSize, IAAFDictionary *dict) { AAFCheck hr; // Get the property value for the target property IAAFClassDef* pCD; hr = dict->LookupClassDef(*pClassID, &pCD); AutoRelease<IAAFClassDef> r1(pCD); IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); AutoRelease<IAAFPropertyDef> r2( pPD ); aafBool present = kAAFFalse; pObj->IsPropertyPresent(pPD, &present); IAAFPropertyValue* pPV = NULL; AutoRelease<IAAFPropertyValue> r3; if (present == kAAFTrue) { hr = pObj->GetPropertyValue(pPD, &pPV); r3 = pPV; } else { hr = AAFRESULT_PROP_NOT_PRESENT; } // Get the type def from the dict with which to interpret this // property value. IAAFTypeDef* pTD; hr = dict->LookupTypeDef(*pIntTypeID, &pTD); AutoRelease< IAAFTypeDef > r4 (pTD); IAAFTypeDefInt* pTDInt; hr = pTD->QueryInterface(IID_IAAFTypeDefInt, (void**)&pTDInt); AutoRelease< IAAFTypeDefInt > r5( pTDInt ); pTDInt->GetInteger(pPV, pValue, ValueSize); return AAFRESULT_SUCCESS; }
AAFRESULT GetPropertyType( IUnknown* pUnknown, const aafUID_t& propertyId, IAAFTypeDef** ppPropTypeDef ) { AAFRESULT hr = AAFRESULT_SUCCESS; IAAFObject* pObject = 0; hr = pUnknown->QueryInterface( IID_IAAFObject, (void **)&pObject ); if( hr == AAFRESULT_SUCCESS ) { IAAFClassDef* pClassDef = 0; hr = pObject->GetDefinition( &pClassDef ); if( hr == AAFRESULT_SUCCESS ) { IAAFPropertyDef* pPropDef = 0; hr = pClassDef->LookupPropertyDef( propertyId, &pPropDef ); if( hr == AAFRESULT_SUCCESS ) { hr = pPropDef->GetTypeDef( ppPropTypeDef ); pPropDef->Release(); pPropDef = 0; } pClassDef->Release(); pClassDef = 0; } pObject->Release(); pObject = 0; } return hr; }
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; }
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; IAAFTypeDefExtEnum* pExtEnumType = 0; // test baseline ext. enum try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x0D010102,0x0101,0x0500,{0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01}}; const wchar_t* testName = L"Usage_SubClip"; 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_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test Int8 enum try { printf(" * Non-baseline Ext Enum: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x6f9685a4,0x0a0d,0x447b,{0x89,0xf3,0x1b,0x75,0x0b,0xc5,0xc7,0xde}}; const wchar_t* testName = L"AAA"; 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_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test baseline extension try { printf(" * Baseline extension: "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0x197e78ac,0xb464,0x4bd1,{0x86,0x11,0xb6,0xf2,0xdf,0x0d,0x03,0xfe}}; const wchar_t* testName = L"MyUsage"; 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_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); // test non-baseline extension try { printf(" * Non-baseline extension: "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUID_t testValue = {0xe54f0efa,0x15c1,0x468f,{0xb7,0x43,0x9b,0xfd,0x12,0x94,0x04,0x49}}; const wchar_t* testName = L"CCC"; 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_IAAFTypeDefExtEnum, (void **)&pExtEnumType)); aafUID_t value; aafCharacter name[256]; checkResult(pExtEnumType->GetAUIDValue(pPropertyValue, &value)); checkResult(pExtEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (memcmp(&value, &testValue, sizeof(aafUID_t)) ==0 && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pExtEnumType); 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; }
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; IAAFTypeDefEnum* pEnumType = 0; try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 5; const wchar_t* testName = L"VersionPrivateBuild"; 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_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 1 : "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; 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_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 2 : "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; 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_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 4 : "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; 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_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 8 : "); const aafUID_t propId = {0x40000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; 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_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); 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; }
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; IAAFTypeDefFixedArray* pFixedArrayType = 0; IAAFTypeDefInt* pIntType = 0; IAAFPropertyValue* pIntValue = 0; try { printf(" * Baseline element type: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue[2] = {0,255}; 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_IAAFTypeDefFixedArray, (void **)&pFixedArrayType)); release(pType); checkResult(pFixedArrayType->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefInt, (void **)&pIntType)); aafUInt8 value[2]; checkResult(pFixedArrayType->GetElementValue(pPropertyValue, 0, &pIntValue)); checkResult(pIntType->GetInteger(pIntValue, &value[0], 1)); release(pIntValue); checkResult(pFixedArrayType->GetElementValue(pPropertyValue, 1, &pIntValue)); checkResult(pIntType->GetInteger(pIntValue, &value[1], 1)); if (value[0] == testValue[0] && value[1] == testValue[1]) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pIntValue); release(pIntType); release(pFixedArrayType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Non-Baseline element type: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue[2] = {1,2}; 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_IAAFTypeDefFixedArray, (void **)&pFixedArrayType)); release(pType); checkResult(pFixedArrayType->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefInt, (void **)&pIntType)); aafUInt8 value[2]; checkResult(pFixedArrayType->GetElementValue(pPropertyValue, 0, &pIntValue)); checkResult(pIntType->GetInteger(pIntValue, &value[0], 1)); release(pIntValue); checkResult(pFixedArrayType->GetElementValue(pPropertyValue, 1, &pIntValue)); checkResult(pIntType->GetInteger(pIntValue, &value[1], 1)); if (value[0] == testValue[0] && value[1] == testValue[1]) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pIntValue); release(pIntType); release(pFixedArrayType); 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; }
//*********************************************************** // // GetObjRefArrayPropFromObject() // // Get an object reference array property on the AAF object // specified by pObj. The value of the property is returned // in pArray. // // Returns: // // On Success: S_OK // On Failure: A failed HRESULT // HRESULT AAFDomainUtils::GetObjRefArrayPropFromObject(IAAFObject* pObj, aafUID_t* pClassID, const aafUID_t* pPropTypeID, aafUID_t* pPropID, IAAFObject*** pArray, aafUInt32* pNumObjects) { IAAFTypeDefVariableArray* pTDVarArray = NULL; IAAFPropertyValue* pPVVarArray = NULL; IAAFTypeDefObjectRef* pTDArrayElement = NULL; IAAFClassDef* pCD; HRESULT hr; // Get the property value for the target property hr = _dict->LookupClassDef(*pClassID, &pCD); if (SUCCEEDED(hr)) { IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); if (SUCCEEDED(hr)) { aafBool present = kAAFFalse; pObj->IsPropertyPresent(pPD, &present); if (present == kAAFTrue) hr = pObj->GetPropertyValue(pPD, &pPVVarArray); else hr = AAFRESULT_PROP_NOT_PRESENT; pPD->Release(); } pCD->Release(); } // Get the property type def from the dictionary to interpret this property value. if (SUCCEEDED(hr)) { IAAFTypeDef* pTD; hr = _dict->LookupTypeDef(*pPropTypeID, &pTD); if (SUCCEEDED(hr)) { hr = pTD->QueryInterface(IID_IAAFTypeDefVariableArray, (void**)&pTDVarArray); pTD->Release(); } } // Get the array element type def to interpret the element property value. if (SUCCEEDED(hr)) { IAAFTypeDef* pTDElement; hr = pTDVarArray->GetType(&pTDElement); if (SUCCEEDED(hr)) { pTDElement->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pTDArrayElement); pTDElement->Release(); } } // Get each element out of the property, convert them to an IAAFObject pointer and // add them to the array of object which is returned to the user. if (SUCCEEDED(hr)) { IAAFObject** pTempArray; aafUInt32 count = 0, numElements = 0; pTDVarArray->GetCount(pPVVarArray, &count); pTempArray = new IAAFObject* [count]; if (pTempArray) { for (aafUInt32 i = 0; i < count; i++) { IAAFPropertyValue* pPVElement; hr = pTDVarArray->GetElementValue(pPVVarArray, i, &pPVElement); if (SUCCEEDED(hr)) { IAAFObject* pTempObj; hr = pTDArrayElement->GetObject(pPVElement, IID_IAAFObject, (IUnknown **)&pTempObj); if (SUCCEEDED(hr)) { pTempArray[numElements] = pTempObj; numElements++; } pPVElement->Release(); } } if (numElements == 0) { delete [] pTempArray; pTempArray = NULL; } *pArray = pTempArray; *pNumObjects = numElements; } } if (pTDArrayElement) pTDArrayElement->Release(); if (pTDVarArray) pTDVarArray->Release(); if (pPVVarArray) pPVVarArray->Release(); return hr; }
//*********************************************************** // // SetObjRefArrayPropOnObject() // // Set an object reference array property on the AAF object // specified by pObj. The value of the property is specified // in pArray. // // Returns: // // On Success: S_OK // On Failure: A failed HRESULT // HRESULT AAFDomainUtils::SetObjRefArrayPropOnObject(IAAFObject* pObj, aafUID_t* pClassID, const aafUID_t* pPropTypeID, const aafUID_t* pElementTypeID, aafUID_t* pPropID, IAAFObject** pArray, aafUInt32 numObjects) { IAAFPropertyValue* pPVArray = NULL; IAAFTypeDef* pTD; HRESULT hr; // For each object in the source array, create a property value // and append it to the property value for the variable array. hr = _dict->LookupTypeDef(*pPropTypeID, &pTD); if (SUCCEEDED(hr)) { IAAFTypeDefVariableArray* pTDVarArray; hr = pTD->QueryInterface(IID_IAAFTypeDefVariableArray, (void**)&pTDVarArray); if (SUCCEEDED(hr)) { IAAFTypeDef* pTDElement; hr = _dict->LookupTypeDef(*pElementTypeID, &pTDElement); if (SUCCEEDED(hr)) { IAAFTypeDefObjectRef* pTDObjRef; hr = pTDElement->QueryInterface (IID_IAAFTypeDefObjectRef, (void **)&pTDObjRef); if (SUCCEEDED(hr)) { for (aafUInt32 i = 0; i < numObjects; i++) { IAAFPropertyValue* pPVObject; hr = pTDObjRef->CreateValue(pArray[i], &pPVObject); if (SUCCEEDED(hr)) { if (pPVArray == NULL) pTDVarArray->CreateEmptyValue(&pPVArray); hr = pTDVarArray->AppendElement(pPVArray, pPVObject); pPVObject->Release(); } } pTDObjRef->Release(); } pTDElement->Release(); } pTDVarArray->Release(); } pTD->Release(); } // If the object reference array was successfully created, // set the property value on the target object. if (pPVArray) { IAAFClassDef* pCD; // Get the class def for the object hr = _dict->LookupClassDef(*pClassID, &pCD); if (SUCCEEDED(hr)) { IAAFPropertyDef* pPD; hr = pCD->LookupPropertyDef(*pPropID, &pPD); if (SUCCEEDED(hr)) { hr = pObj->SetPropertyValue(pPD, pPVArray); pPD->Release(); } pCD->Release(); } pPVArray->Release(); } return hr; }
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; IAAFTypeDefIndirect* pIndirectType = 0; IAAFPropertyValue* pActualPropertyValue = 0; IAAFTypeDef* pActualType = 0; IAAFTypeDefInt* pIntType = 0; IAAFTypeDefEnum* pEnumType = 0; IAAFTypeDefRecord* pRecordType = 0; try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafInt8 testValue = -128; 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_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefInt, (void **)&pIntType)); aafInt8 value; checkResult(pIntType->GetInteger(pActualPropertyValue, (aafUInt8*)&value, 1)); if (value == testValue) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Non-baseline: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; 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_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pActualPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pActualPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Baseline record: "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafProductVersion_t testValue = {0,1,0,0,kAAFVersionUnknown}; 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_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefRecord, (void **)&pRecordType)); aafProductVersion_t value; checkResult(pRecordType->GetStruct(pActualPropertyValue, (aafUInt8*)&value, sizeof(aafProductVersion_t))); if (memcmp(&testValue, &value, sizeof(aafProductVersion_t)) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); 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; }