Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
	IAAFCompositionMob * pCMob = NULL;
	IAAFMob * pMob = NULL;
	IAAFObject * pObj = 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);
		
		//Create a composition ...
		checkResult (defs.cdCompositionMob()->
			CreateInstance (IID_IAAFCompositionMob,
			(IUnknown **) &pCMob));
		assert (pCMob);
		checkResult (pCMob->Initialize (TEST_NAME));
		
		//... Get its mob, and add it to the header info
		checkResult (pCMob->QueryInterface (IID_IAAFMob,
										  (void **) &pMob));
		assert (pMob);
		checkResult (pHeader->AddMob (pMob));
		
	}
	catch (HRESULT & rResult)
	{
		hr = rResult;
	}
	
	if (pCMob) pCMob->Release();
	if (pMob) pCMob->Release();
	if (pObj) pObj->Release();
	if (pDict) pDict->Release();
	if (pHeader) pHeader->Release();
	if (pFile)
	{
		AAFRESULT temphr = pFile->Save();
		if (! SUCCEEDED (temphr)) return temphr;
		temphr = pFile->Close();
		if (! SUCCEEDED (temphr)) return temphr;
		pFile->Release();
	}
	
	return hr;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
static HRESULT  ReadAAFFile(aafWChar *  pFileName )
{
	HRESULT hr = AAFRESULT_SUCCESS;
	
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	IAAFCompositionMob *		pCMob = NULL;
	IAAFMob*					pMob = NULL;
	bool bFileOpen = false;
	aafNumSlots_t				numMobs;
	IAAFObject*					pObj = NULL;
	
	IEnumAAFProperties * pEnum = NULL;
	IAAFProperty *pProp = NULL;
	
	IAAFPropertyDef* pPropDef = NULL;
	IAAFPropertyValue* pPropVal = NULL;

	IAAFTypeDef*	pTypeDef  = NULL;

	try
	{
		// Open the file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;
		
		// We can't really do anthing in AAF without the header.
		checkResult(pFile->GetHeader(&pHeader));
		
		// Validate that there is only one composition mob.
		checkResult(pHeader->CountMobs(kAAFCompMob, &numMobs));
		checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
		
		// Enumerate over all Composition Mobs
		aafSearchCrit_t				criteria;
		criteria.searchTag = kAAFByMobKind;
		criteria.tags.mobKind = kAAFCompMob;
		checkResult(pHeader->GetMobs(&criteria, &pMobIter));
		while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
		{		
			//Get the Composition mob
			checkResult (pMob->QueryInterface (IID_IAAFCompositionMob,
				(void **) &pCMob));
			
			//Get the Object
			checkResult (pCMob->QueryInterface (IID_IAAFObject,
				(void **) &pObj));
			
			//From the Object, we can get the properties ....
			aafUInt32 propCount = 0;
			checkResult (pObj->CountProperties (&propCount));
			//A composition should have at least 5 properties ...
 			checkExpression(propCount>=5, AAFRESULT_TEST_FAILED);
			
			//Get Enumeration over properties
			checkResult (pObj->GetProperties (&pEnum));
			checkExpression (pEnum != 0, AAFRESULT_TEST_FAILED);
			while (propCount--)
			{
				//Check for property validity
				checkResult (pEnum->NextOne (&pProp));
				checkExpression (pProp != NULL, AAFRESULT_TEST_FAILED);
				//Now call prop methods
				
				//1.  Get Definition
				checkResult( pProp->GetDefinition(&pPropDef) );
				//2. Get Value
				checkResult( pProp->GetValue(&pPropVal) );

				//deal with prop value
				checkResult( pPropVal->GetType(&pTypeDef) );

				//From propval, get the typedef!!!!!!!!!!!!!!!!!!!!!
				IAAFTypeDefSP spTypeDef;
				checkResult( pPropVal->GetType(&spTypeDef) );

				//get category
				eAAFTypeCategory_t typeCat = kAAFTypeCatUnknown;
				checkResult (spTypeDef->GetTypeCategory(&typeCat));
				//make sure it is not unknown
				checkExpression(kAAFTypeCatUnknown != typeCat, AAFRESULT_TEST_FAILED);
				
				//Deal with our Name  String .... 
				if (typeCat == kAAFTypeCatString)
				{
					IAAFTypeDefStringSP  spTypeDefString;
					checkResult( spTypeDef->QueryInterface(IID_IAAFTypeDefString, 
												(void**)&spTypeDefString) );

					aafUInt32 bufSize = 
						//don't forget the NULL char, and factoring in the size of a wchar
						   (wcslen(TEST_NAME)+1) * sizeof(aafCharacter); 

					aafCharacter *nameBuf = new aafCharacter[bufSize];
					checkResult( spTypeDefString->GetElements(pPropVal, (aafMemPtr_t)nameBuf, bufSize) );
					checkExpression( wcscmp(TEST_NAME, nameBuf) == 0, AAFRESULT_TEST_FAILED );
					delete [] nameBuf;
				}

				//Done ...........

				//release typedef
				pTypeDef->Release();

				//release defintion + value
				pPropDef->Release();
				pPropVal->Release();
				
				//release this prop
				pProp->Release();
				pProp = NULL;

			}//while prop count
		}//while mob iter
	}//try
	
	catch (HRESULT & rResult)
	{
		hr = rResult;
	}
	
	//Release the rest ...
	if (pEnum) 
		pEnum->Release();
	
	if (pObj) 
		pObj->Release();
	if (pCMob) 
		pCMob->Release();
	if (pMob)
		pMob->Release();
	if (pMobIter)
		pMobIter->Release();
	if (pHeader)
		pHeader->Release();
	
	if (pFile) 
	{
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}
	
	return hr;
	
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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;
}