// set EssenceElementKey from member variables and known consts HRESULT STDMETHODCALLTYPE CAAFEssenceDataStream::SetEssenceElementKey (// @parm [in] essence element key aafUID_constref eek, // @parm [in] essence element kind aafUInt8 eeKind, // @parm [in] essence element count aafUInt8 eeCount, // @parm [in] essence element type aafUInt8 eeType, // @parm [in] essence element index aafUInt8 eeIndex, // @parm [in] logical slot id of source slot aafSlotID_t sourceSlotID ) { plugin_trace("CAAFEssenceDataStream::SetEssenceElementKey()\n"); if (NULL == _data) return AAFRESULT_NOT_INITIALIZED; AAFRESULT hr = AAFRESULT_SUCCESS; try { hr = AAFRESULT_INTERNAL_ERROR; // SetEEK // we know how to set the EssenceElementKey on an EssenceData object // via PlainEssenceData then KLVEssenceDataParameters::SetEssenceElementKey() IAAFKLVEssenceDataParametersSP pParameters; checkResult( _data->QueryInterface(IID_IAAFKLVEssenceDataParameters, (void **)&pParameters) ); aafUID_t Peek; hr = pParameters->GetEssenceElementKey( &Peek ); // only do this is the file kind allows us to if( hr == AAFRESULT_SUCCESS ) { if( true ) // was: if( EqualAUID( &_eek, &NULL_UID ) ) { // if null passed in by caller, preset to what the file kind wants if( EqualAUID( &eek, &NULL_UID ) ) _eek = Peek; else _eek = eek; // make a GC bytes 12..16 aafUInt32 GCeeIndex = ( ( (eeKind&0xff)<<8 | (eeCount&0xff) )<<8 | (eeType&0xff) )<<8 | (eeIndex&0xff); // overwrite eek bytes 12..16 _eek.Data2 = (aafUInt16)(GCeeIndex>>16)&0xffff; _eek.Data3 = (aafUInt16)(GCeeIndex)&0xffff; // set the EssenceElementKey checkResult( pParameters->SetEssenceElementKey( _eek ) ); // set the PhysicalNum in the track of the FileSourceMob IAAFSourceMobSP pSourceMob; checkResult( _data->GetFileMob( &pSourceMob ) ); IAAFMobSP pFileMob; checkResult( pSourceMob->QueryInterface( IID_IAAFMob,(void**)&pFileMob ) ); IAAFMobSlotSP pSlot; checkResult( pFileMob->LookupSlot( 1, &pSlot ) ); checkResult( pSlot->SetPhysicalNum( GCeeIndex ) ); } else { // _eek has been initialized already // we ought to leave it alone } } else if( hr == AAFRESULT_OPERATION_NOT_PERMITTED ) // must be a file kind where eek isn't important hr = AAFRESULT_CODEC_SEMANTIC_WARN; }
static HRESULT ReadAAFFile(aafWChar* pFileName) { IAAFFileSP pFile; IAAFHeaderSP pHeader; IEnumAAFMobsSP pMobIter; IAAFMobSP pMob; IEnumAAFMobSlotsSP pSlotIter; IAAFMobSlotSP pSlot; IAAFComponentSP pComp; IAAFSegmentSP pSegment; IAAFDataDefSP pDataDef; IAAFSequenceSP pSequence; IAAFDictionarySP pDictionary; IEnumAAFComponentsSP pCompIter; aafNumSlots_t numMobs; aafSearchCrit_t criteria; HRESULT hr = S_OK; try { // Open the AAF file checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile)); // Get the AAF file header. checkResult(pFile->GetHeader(&pHeader)); // Validate that there is only one composition mob. checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); // Get the AAF Dictionary so that we can create valid AAF objects. checkResult(pHeader->GetDictionary(&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Check a data definition from a composition MOB in order to test weak references criteria.searchTag = kAAFByMobKind; criteria.tags.mobKind = kAAFCompMob; checkResult(pHeader->GetMobs(&criteria, &pMobIter)); while (pMobIter && pMobIter->NextOne(&pMob) == AAFRESULT_SUCCESS) { // Enumerate the first MOB slot for this MOB checkResult(pMob->GetSlots(&pSlotIter)); checkResult(pSlotIter->NextOne(&pSlot)); checkResult(pSlot->GetSegment(&pSegment)); checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **) &pSequence)); checkResult(pSequence->GetComponents(&pCompIter)); checkResult(pCompIter->NextOne(&pComp)); aafBool testBool; checkResult(pComp->GetDataDef(&pDataDef)); checkResult(pDataDef->IsSoundKind(&testBool)); checkExpression(testBool == kAAFFalse, AAFRESULT_TEST_FAILED); checkResult(pDataDef->IsDataDefOf(defs.ddkAAFPictureWithMatte(), &testBool)); checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED); // Make sure first component is a filler, and is our extended // class. To do that, we'll compare the class def we looked // up in the dict, with the one we got from the new object. // // First get the class from the object. IAAFFillerSP pFill; checkResult(pComp->QueryInterface(IID_IAAFFiller, (void **) &pFill)); assert (pFill); IAAFObjectSP pObj; checkResult(pFill->QueryInterface(IID_IAAFObject, (void **) &pObj)); assert (pObj); IAAFClassDefSP pClassFromObj; checkResult (pObj->GetDefinition (&pClassFromObj)); assert (pClassFromObj); IUnknownSP pUnkFromObj; checkResult(pClassFromObj->QueryInterface(IID_IUnknown, (void **) &pUnkFromObj)); // Now get the class from the dict IAAFClassDefSP pClassFromDict; checkResult (pDictionary->LookupClassDef (kClassAUID_NewFill, &pClassFromDict)); assert (pClassFromDict); IUnknownSP pUnkFromDict; checkResult(pClassFromDict->QueryInterface(IID_IUnknown, (void **) &pUnkFromDict)); // Compare class from object with class from dict. Compare // using IUnknown pointers. assert (((IUnknown*)pUnkFromObj) == ((IUnknown*)pUnkFromDict)); // To test GetClassDefinitions(), try explicit lookup. IEnumAAFClassDefsSP pClassDefEnum; checkResult (pDictionary->GetClassDefs (&pClassDefEnum)); bool found = false; IAAFClassDefSP cd; while (SUCCEEDED (pClassDefEnum->NextOne (&cd))) { IAAFMetaDefinitionSP def; checkResult(cd->QueryInterface(IID_IAAFMetaDefinition, (void **) &def)); aafUID_t classid; checkResult (def->GetAUID (&classid)); if (EqualGUID (&classid, &kClassAUID_NewFill)) { // Found it the hard way. found = true; break; } } // make sure we found it the hard way. checkExpression(found == kAAFTrue, AAFRESULT_TEST_FAILED); // Get the 'odor' property from our new fill clip. Make // sure it is set to the value we think it should be // ('42'). // // First get the property def from the class. IAAFPropertyDefSP pPropDef; checkResult (pClassFromObj->LookupPropertyDef (kPropAUID_NewFill_Odor, &pPropDef)); // // Get the property value from the object IAAFPropertyValueSP pPropVal; checkResult (pObj->GetPropertyValue (pPropDef, &pPropVal)); // // We know the property is int32; get the int32 type def IAAFTypeDefSP ptd; checkResult (pDictionary->LookupTypeDef (kAAFTypeID_UInt32, &ptd)); IAAFTypeDefIntSP pTDUint32; checkResult(ptd->QueryInterface(IID_IAAFTypeDefInt, (void **) &pTDUint32)); assert (pTDUint32); // // Ask the typedef to interpret this property value for us. aafUInt32 odorValue = 0; checkResult (pTDUint32->GetInteger (pPropVal, (aafMemPtr_t) &odorValue, sizeof (odorValue))); // // make sure it's what we expect. assert (42 == odorValue); } checkResult (LookupDefs (pDictionary)); //Test the Lookup KLV and Tagged methods IAAFKLVDataDefinition *pKLVLook = NULL; IAAFTaggedValueDefinition *pTAGDefLook = NULL; IAAFDictionary2 *pDic2 = NULL; IAAFDefObject *pKLVDataDefObj = NULL; IAAFDefObject *pTaggedValueDefObj = NULL; aafUID_t auid; checkResult( pDictionary->QueryInterface( IID_IAAFDictionary2, reinterpret_cast<void**>(&pDic2) ) ); assert(pDic2); //test LookUpKLV() if(pDic2->LookupKLVDataDef(KLVDef_TestData, &pKLVLook) != AAFRESULT_SUCCESS) checkResult(AAFRESULT_TEST_FAILED); checkResult( pKLVLook->QueryInterface( IID_IAAFDefObject, reinterpret_cast<void**>(&pKLVDataDefObj) ) ); assert(pKLVDataDefObj); //ensure the KLVLook auid is equal to KLVDef_TestData auid checkResult(pKLVDataDefObj->GetAUID(&auid)); if(auid != KLVDef_TestData) checkResult(AAFRESULT_TEST_FAILED); //test LookUpTagged() if(pDic2->LookupTaggedValueDef(TAGDef_TestData, &pTAGDefLook) != AAFRESULT_SUCCESS) checkResult(AAFRESULT_TEST_FAILED); checkResult( pTAGDefLook->QueryInterface( IID_IAAFDefObject, reinterpret_cast<void**>(&pTaggedValueDefObj) ) ); assert(pTaggedValueDefObj); //ensure the TAGDefLook auid is equal to TAGDef_TestData auid checkResult(pTaggedValueDefObj->GetAUID(&auid)); if(auid != TAGDef_TestData) checkResult(AAFRESULT_TEST_FAILED); //cleanup pDic2->Release(); pDic2 = NULL; pKLVLook->Release(); pKLVLook = NULL; pTAGDefLook->Release(); pTAGDefLook = NULL; pKLVDataDefObj->Release(); pKLVDataDefObj = NULL; pTaggedValueDefObj->Release(); pTaggedValueDefObj = NULL; } catch (HRESULT& rResult) { hr = rResult; } // Cleanup and return. if (pFile) { pFile->Close(); } return hr; }
static HRESULT CreateAAFFile( aafWChar * pFileName, aafUID_constref fileKind, testRawStorageType_t rawStorageType, aafProductIdentification_constref productID) { HRESULT hr = AAFRESULT_SUCCESS; IAAFFile* pFile = NULL; IAAFHeader * pHeader = NULL; IAAFDictionary * pDict = NULL; try { //Do the usual ... RemoveTestFile (pFileName); checkResult (CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile )); assert (pFile); checkResult (pFile->GetHeader (&pHeader)); assert (pHeader); checkResult (pHeader->GetDictionary (&pDict)); assert (pDict); CAAFBuiltinDefs defs (pDict); /////////////////////// //checkResult(createCHARType (pDict)); checkResult(addCHARTypeToComponent (pDict)); /////////// //Create a concrete subclass of mob IAAFMobSP spMob; checkResult(defs.cdMasterMob()-> CreateInstance(IID_IAAFMob, (IUnknown **)&spMob)); checkResult(spMob->SetMobID(TEST_MobID)); checkResult(spMob->SetName(L"Some Mob")); //Add a slot - make it our Filler /// first, create Filler IAAFFillerSP spFill; checkResult(defs.cdFiller()->CreateInstance(IID_IAAFFiller, (IUnknown**)&spFill)); checkResult(spFill->Initialize(defs.ddkAAFSound(), 10)); checkResult(createCHARFiller(pDict, spFill)); //seg //QI the filler for its segment IAAFSegmentSP spSeg; checkResult(spFill->QueryInterface (IID_IAAFSegment, (void **)&spSeg)); //Create a concrete subclass of mob slot IAAFMobSlotSP spMobSlot; checkResult(defs.cdStaticMobSlot()-> CreateInstance(IID_IAAFMobSlot, (IUnknown **)&spMobSlot)); //Add the segment to the mobslot checkResult(spMobSlot->SetSegment(spSeg)); checkResult(spMobSlot->SetSlotID(TEST_SLOT_ID)); checkResult(spMobSlot->SetName(TEST_SLOT_NAME)); //Append the slot to the Mob .... checkResult(spMob->AppendSlot (spMobSlot)); //FINALLY .... Add mob to header checkResult (pHeader->AddMob (spMob)); //////////////////// done /!!!!!!!!!!!!!!!!!!!!!! //Verify results right away (during this creation process) .... checkResult(verifyContents (pHeader, pDict, kAAFTrue)); //True => minimal testing } catch (HRESULT & rResult) { hr = rResult; } if (pDict) pDict->Release(); if (pHeader) pHeader->Release(); if (pFile) { stopGap(pFile->Save()); stopGap(pFile->Close()); pFile->Release(); } return hr; }//CreateAAFFile()
static HRESULT verifyContents (IAAFHeader* const pHeader, IAAFDictionary* const pDict, const aafBoolean_t bMinimalTesting) { //CAAFBuiltinDefs defs (pDict); ///////////////////////////////////////// // Check the MOb stuff IAAFMobSP spMob; checkResult(pHeader->LookupMob (TEST_MobID, &spMob)); aafNumSlots_t numSlots = 0; checkResult(spMob->CountSlots (&numSlots)); // we only put one in assert (1 == numSlots); IEnumAAFMobSlotsSP spSlotEnum; checkResult(spMob->GetSlots (&spSlotEnum)); // Since we only put one in, just bother with the first one. IAAFMobSlotSP spMobSlot; checkResult(spSlotEnum->NextOne (&spMobSlot)); aafCharacter buf[128] = {0}; checkResult(spMobSlot->GetName(buf, 128*sizeof(aafCharacter))); checkExpression( wcscmp(buf, TEST_SLOT_NAME) == 0, AAFRESULT_TEST_FAILED ); aafSlotID_t slotid = {0}; checkResult(spMobSlot->GetSlotID(&slotid)); checkExpression( slotid == TEST_SLOT_ID, AAFRESULT_TEST_FAILED ); // Get the segment; it's got to be our filler. IAAFSegmentSP spSegment; checkResult(spMobSlot->GetSegment (&spSegment)); // Get filler interface IAAFFillerSP spFill; checkResult(spSegment->QueryInterface(IID_IAAFFiller, (void**)&spFill)); //Make sure Property is preset! Can't do anything without it //handy - QI filler for Object intf. IAAFObjectSP spObj; checkResult(spFill->QueryInterface(IID_IAAFObject, (void**)&spObj)); //Get the property def for Component::CHAR IAAFClassDefSP spCD_comp; checkResult(pDict->LookupClassDef(AUID_AAFComponent, &spCD_comp)); //From Class Def, get the Property Def IAAFPropertyDefSP spPD_comp; checkResult(spCD_comp->LookupPropertyDef(TEST_PROP_ID, &spPD_comp)); //Verify that optional property is present in object aafBoolean_t bIsPresent = kAAFFalse; checkResult(spObj->IsPropertyPresent(spPD_comp, &bIsPresent)); checkExpression(bIsPresent == kAAFTrue, AAFRESULT_TEST_FAILED); ////////////////////////////////////// //get the value IAAFPropertyValueSP spPropVal; checkResult(spObj->GetPropertyValue(spPD_comp, &spPropVal)); //Our CHARING PropVal //Get the typedef //first, get the Type Def from the Property def IAAFTypeDefSP spTypeDef; checkResult(spPD_comp->GetTypeDef(&spTypeDef)); //now get the CHAR intf IAAFTypeDefCharacterSP spCHAR; checkResult(spTypeDef->QueryInterface(IID_IAAFTypeDefCharacter, (void**)&spCHAR)); //get aafCharacter test_char = 0; //init a checking variable; select a reasonable size buffer //IAAFTypeDefCharacter::GetCharacter() checkResult(spCHAR->GetCharacter(spPropVal, &test_char)); //VERIFY values: checkExpression( test_char == TEST_CHAR_VALUE, AAFRESULT_TEST_FAILED ); //At this point, the test is succesful for both the CREATE and READ (unscrambling of .aaf file) routines if (bMinimalTesting) // so, bail if we're called from CREATE return S_OK; ///// READ routine .... continue with more tests .................... //Do a Set/Get character operation pari ... const aafCharacter TEST_Char = 'b'; checkResult(spCHAR->SetCharacter(spPropVal, TEST_Char)); //Now get it back test_char = 0; //reset variable before the readback checkResult(spCHAR->GetCharacter(spPropVal, &test_char)); //verify the read-back checkExpression( test_char == TEST_Char, AAFRESULT_TEST_FAILED ); return S_OK; }//verifyContents()
void CAAFTypeDefWeakObjRef_verify (IAAFHeader * pHeader) { IAAFDictionarySP pDictionary; IAAFPropertyDefSP pWeakRefPropertyDef; checkResult (pHeader->GetDictionary (&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Determine if it is okay to ready/validate weak references from the // test file with the current version of the AAF. bool weakReferencesSupported = false; aafProductVersion_t toolkitVersion, fileToolkitVersion; checkResult(GetAAFVersions(pHeader, &toolkitVersion, &fileToolkitVersion)); if (WeakReferencesSupported(toolkitVersion) && WeakReferencesSupported(fileToolkitVersion)) { weakReferencesSupported = true; } if (weakReferencesSupported) { // // Find and validate the new weak reference. IAAFTypeDefSP pType; checkResult(pDictionary->LookupTypeDef (kAAFTypeID_TestWeakReferenceToType, &pType)); eAAFTypeCategory_t category; checkResult(pType->GetTypeCategory(&category)); checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED); IAAFTypeDefWeakObjRefSP pWeakReferenceType; checkResult(pType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType)); checkResult(defs.cdFiller()->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef)); // Validate the property's type checkResult(pWeakRefPropertyDef->GetTypeDef(&pType)); checkExpression(EqualObjects(pType, pWeakReferenceType), AAFRESULT_TEST_FAILED); // Use GetObjectType to make sure that the target class definitions are // the same. IAAFTypeDefObjectRefSP pObjectReferenceType; checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType)); IAAFClassDefSP pReferencedObjectClass; checkResult(pObjectReferenceType->GetObjectType(&pReferencedObjectClass)); // Find the class definition for all type definitions. IAAFClassDefSP pTypeDefClass; checkResult(pDictionary->LookupClassDef(AUID_AAFTypeDef, &pTypeDefClass)); checkExpression(EqualObjects(pReferencedObjectClass, pTypeDefClass), AAFRESULT_TEST_FAILED); // // Find our composition mob. IAAFMobSP pMob; checkResult(pHeader->LookupMob(TEST_MobID, &pMob)); IAAFMobSlotSP pSlot; checkResult(pMob->LookupSlot(TEST_SlotID, &pSlot)); IAAFSegmentSP pSegment; checkResult(pSlot->GetSegment(&pSegment)); IAAFSequenceSP pSequence; checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **)&pSequence)); aafUInt32 elementCount; checkResult(pSequence->CountComponents(&elementCount)); checkExpression(2 == elementCount, AAFRESULT_TEST_FAILED); IAAFComponentSP pComp1; checkResult(pSequence->GetComponentAt(0, &pComp1)); IAAFFillerSP pFiller1; checkResult(pComp1->QueryInterface(IID_IAAFFiller, (void **)&pFiller1)); IAAFComponentSP pComp2; checkResult(pSequence->GetComponentAt(1, &pComp2)); IAAFFillerSP pFiller2; checkResult(pComp2->QueryInterface(IID_IAAFFiller, (void **)&pFiller2)); CheckWeakReference(pFiller1, defs.tdString()); CheckWeakReference(pFiller2, defs.tdInt32()); #ifndef NO_REFERENCE_TO_MOB_TEST CheckWeakReference(pFiller1, pMob); #endif } else if (!WeakReferencesSupported(toolkitVersion)) { // This version does not support reading weak references. throw AAFRESULT_NOT_IN_CURRENT_VERSION; } }
static HRESULT verifyContents (IAAFHeader* const pHeader, IAAFDictionary* const pDict, const aafBoolean_t bMinimalTesting) { //CAAFBuiltinDefs defs (pDict); HRESULT hr; ///////////////////////////////////////// // Check the MOb stuff IAAFMobSP spMob; checkResult(pHeader->LookupMob (TEST_MobID, &spMob)); aafNumSlots_t numSlots = 0; checkResult(spMob->CountSlots (&numSlots)); // we only put one in assert (1 == numSlots); IEnumAAFMobSlotsSP spSlotEnum; checkResult(spMob->GetSlots (&spSlotEnum)); // Since we only put one in, just bother with the first one. IAAFMobSlotSP spMobSlot; checkResult(spSlotEnum->NextOne (&spMobSlot)); aafCharacter buf[128] = {0}; checkResult(spMobSlot->GetName(buf, 128)); checkExpression( wcscmp(buf, TEST_SLOT_NAME) == 0, AAFRESULT_TEST_FAILED ); aafSlotID_t slotid = {0}; checkResult(spMobSlot->GetSlotID(&slotid)); checkExpression( slotid == TEST_SLOT_ID, AAFRESULT_TEST_FAILED ); // Get the segment; it's got to be our filler. IAAFSegmentSP spSegment; checkResult(spMobSlot->GetSegment (&spSegment)); // Get filler interface IAAFFillerSP spFill; checkResult(spSegment->QueryInterface(IID_IAAFFiller, (void**)&spFill)); //Make sure Property is preset! Can't do anything without it //handy - QI filler for Object intf. IAAFObjectSP spObj; checkResult(spFill->QueryInterface(IID_IAAFObject, (void**)&spObj)); //Get the property def for Component::FA IAAFClassDefSP spCD_comp; checkResult(pDict->LookupClassDef(AUID_AAFComponent, &spCD_comp)); //From Class Def, get the Property Def IAAFPropertyDefSP spPD_comp; checkResult(spCD_comp->LookupPropertyDef(TEST_PROP_ID, &spPD_comp)); //Verify that optional property is not yet present in object aafBoolean_t bIsPresent = kAAFFalse; checkResult(spObj->IsPropertyPresent(spPD_comp, &bIsPresent)); checkExpression(bIsPresent == kAAFTrue, AAFRESULT_TEST_FAILED); ////////////////////////////////////// //get the value IAAFPropertyValueSP spPropVal; checkResult(spObj->GetPropertyValue(spPD_comp, &spPropVal)); //Get the Fixed Array typedef //first, get the Type Def from the Property def IAAFTypeDefSP spTypeDef; checkResult(spPD_comp->GetTypeDef(&spTypeDef)); //now get the FA intf IAAFTypeDefFixedArraySP spFA; checkResult(spTypeDef->QueryInterface(IID_IAAFTypeDefFixedArray, (void**)&spFA)); //get the array out of it ... TEST_ELEM_t check_fa [TEST_FA_COUNT] = {0}; //init a checking variable //IAAFTypeDefFixedArray::GetCount() aafUInt32 check_count = 0; checkResult(spFA->GetCount(&check_count)); checkExpression( check_count == TEST_FA_COUNT, AAFRESULT_TEST_FAILED ); //IAAFTypeDefFixedArray::GetType() IAAFTypeDefSP spTestType; checkResult(spFA->GetType(&spTestType)); //Look up our elem Type def IAAFTypeDefSP spTD_elem; checkResult(pDict->LookupTypeDef (TEST_ELEM_TYPE_ID, &spTD_elem)); //!!! checkExpression( AreUnksSame(spTestType, spTD_elem), AAFRESULT_TEST_FAILED ); //IAAFTypeDefFixedArray::GetCArray() aafUInt32 i=0; checkResult(spFA->GetCArray(spPropVal, (aafMemPtr_t) check_fa, sizeof(check_fa))); //VERIFY values: for (i=0; i<TEST_FA_COUNT; i++) checkExpression( check_fa[i] == TEST_FA_VALUES[i], AAFRESULT_TEST_FAILED ); //At this point, the test is succesful for both the CREATE and READ (unscrambling of .aaf file) routines if (bMinimalTesting) // so, bail if we're called from CREATE return S_OK; ///// READ routine .... continue with more tests .................... //IAAFTypeDefFixedArray::GetElementValue //Get 3rd index out of array aafUInt32 test_index = 2; IAAFPropertyValueSP spSomeVal; checkResult(spFA->GetElementValue(spPropVal, test_index, &spSomeVal)); //Make sure both have same types ... checkResult(spSomeVal->GetType(&spTestType)); //!!! checkExpression( AreUnksSame(spTestType, spTD_elem), AAFRESULT_TEST_FAILED ); //now, test spSomeVal for integer IAAFTypeDefIntSP spSomeInt; checkResult(spTestType->QueryInterface(IID_IAAFTypeDefInt, (void**)&spSomeInt)); TEST_ELEM_t some_int = -1; checkResult(spSomeInt->GetInteger(spSomeVal, (aafMemPtr_t)&some_int, sizeof (some_int))); checkExpression( some_int == TEST_FA_VALUES[test_index], AAFRESULT_TEST_FAILED ); //IAAFTypeDefFixedArray::SetCArray const TEST_ELEM_t newArray[TEST_FA_COUNT] = {99, -99, 22, -22, 120}; checkResult(spFA->SetCArray (spPropVal, (aafMemPtr_t) newArray, sizeof(newArray))); //Verify that the new values are set .... // .... call GetCArray checkResult(spFA->GetCArray(spPropVal, (aafMemPtr_t) check_fa, sizeof(check_fa))); for (i=0; i<TEST_FA_COUNT; i++) checkExpression( check_fa[i] == newArray[i], AAFRESULT_TEST_FAILED ); //Test IAAFTypeDefFixedArray::IAAFTypeDefArray::SetElementValue() .... some_int = -13; checkResult(spSomeInt->CreateValue((aafMemPtr_t)&some_int, sizeof (some_int), &spSomeVal)); //try to set the value out-of-bounds hr = spFA->SetElementValue(spPropVal, 5, spSomeVal); //5 is one elem out of bounds checkExpression( hr == AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED ); //Set the element to last index ... checkResult(spFA->SetElementValue(spPropVal, 4, spSomeVal)); //4 is last index position //Now get back the element ... checkResult(spFA->GetElementValue(spPropVal, 4, &spSomeVal)); some_int = 0; //reset value checkResult(spSomeInt->GetInteger(spSomeVal, (aafMemPtr_t)&some_int, sizeof (some_int))); //verify retrieved integer checkExpression( -13 == some_int , AAFRESULT_TEST_FAILED ); //// //IAAFTypeDefArray::CreateValueFromValues () const TEST_ELEM_t newsize_array[7] = {10, -20, 30, -44, 55, -360, 11}; aafUInt32 bad_count = 7; IAAFPropertyValue * pSourceValArr[7]; //setup for (i=0; i<bad_count; i++) checkResult(spSomeInt->CreateValue((aafMemPtr_t)&newsize_array[i], sizeof (some_int), &pSourceValArr[i])); IAAFPropertyValueSP spTargetValArr; hr = spFA->CreateValueFromValues(pSourceValArr, bad_count, &spTargetValArr ); checkExpression(AAFRESULT_DATA_SIZE == hr, AAFRESULT_TEST_FAILED); //ok try again, with the correct count aafUInt32 good_count = 5; checkResult(spFA->CreateValueFromValues(pSourceValArr, good_count, &spTargetValArr )); //done with creating Target ValArr; release Source ValArr elements for (i=0; i<bad_count; i++) pSourceValArr[i]->Release(); //verify spPropValArr values TEST_ELEM_t check2_fa [5] = {0}; //init a checking variable checkResult(spFA->GetCArray(spTargetValArr, (aafMemPtr_t) check2_fa, sizeof(check2_fa))); for (i=0; i<good_count; i++) checkExpression( check2_fa[i] == newsize_array[i], AAFRESULT_TEST_FAILED ); //another negative test ... //check for bad size request : like, say 6 elements const TEST_ELEM_t badSize_array[TEST_FA_COUNT+1] = {99, -2, 78, -12, 77, -55}; hr = spFA->SetCArray (spPropVal, (aafMemPtr_t) badSize_array, sizeof(badSize_array)); //we should have got back a BAD SIZE!!!! checkExpression( hr == AAFRESULT_BAD_SIZE, AAFRESULT_TEST_FAILED ); return S_OK; }//verifyContents()