コード例 #1
0
HRESULT STDMETHODCALLTYPE
    CAAFEssenceFileContainer::GetIndexedDefinitionObject (aafUInt32 /* index */, IAAFDictionary *dict, IAAFDefObject **def)
{
	aafUID_t			uid;
	IAAFContainerDef	*container = NULL;
    IAAFClassDef        *pcd = 0;

	if((dict == NULL) || (def == NULL))
		return AAFRESULT_NULL_PARAM;

	XPROTECT()
	{
		CHECK(dict->LookupClassDef(AUID_AAFContainerDef, &pcd));
		CHECK(pcd->CreateInstance(IID_IAAFContainerDef, 
								  (IUnknown **)&container));
		pcd->Release();
		pcd = 0;
		uid = ContainerFile;
		CHECK(container->SetEssenceIsIdentified(kAAFFalse));
		CHECK(container->Initialize(uid, L"Raw file Container", L"Essence is in a non-container file."));
		CHECK(container->QueryInterface(IID_IAAFDefObject, (void **)def));
		container->Release();
		container = NULL;
	}
	XEXCEPT
	{
		if(container != NULL)
		  {
			container->Release();
			container = 0;
		  }
		if (pcd)
		  {
			pcd->Release();
			pcd = 0;
		  }
	}
	XEND

	return AAFRESULT_SUCCESS;
}
コード例 #2
0
ファイル: CAAFDefObjectTest.cpp プロジェクト: mcanthony/aaf
static HRESULT ReadAAFFile(aafWChar* pFileName)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader*			pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IEnumAAFContainerDefs *pPlug = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
	aafUID_t			readUID;
	wchar_t				testString[256];

	try
	{
		// Open the AAF file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;

		// Get the AAF file header.
		checkResult(pFile->GetHeader(&pHeader));

		checkResult(pHeader->GetDictionary(&pDictionary));
	
		checkResult(pDictionary->GetContainerDefs(&pPlug));
		while(pPlug->NextOne (&pContainerDef) == AAFRESULT_SUCCESS)
		{
			checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef));
			checkResult(pDef->GetAUID(&readUID));
			if(memcmp(&readUID, &testUID, sizeof(aafUID_t)) == 0)
			{
				checkResult(pDef->GetName (testString, sizeof(testString)));
				checkExpression (wcscmp(testString, sName) == 0, AAFRESULT_TEST_FAILED);

				aafUInt32 nameLen;
				checkResult (pDef->GetNameBufLen (&nameLen));
				checkExpression (((wcslen (sName)+1) * sizeof (aafCharacter) == nameLen),
						 AAFRESULT_TEST_FAILED);

				checkResult(pDef->GetDescription (testString, sizeof(testString)));
				checkExpression (wcscmp(testString, sDescription) == 0, AAFRESULT_TEST_FAILED);

				checkResult (pDef->GetDescriptionBufLen (&nameLen));
				checkExpression (((wcslen (sDescription)+1) * sizeof (aafCharacter) == nameLen),
						 AAFRESULT_TEST_FAILED);

				break;
			}

                        pDef->Release();
                        pDef = NULL;
                        pContainerDef->Release();
                        pContainerDef = NULL;

		}//		checkResult(pPlug->NextOne(&pContainerDef));


	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}

	// Cleanup and return
	if (pHeader)
		pHeader->Release();
      
	if (pPlug)
		pPlug->Release();

	if (pDef)
		pDef->Release();
      
	if (pContainerDef)
		pContainerDef->Release();
            
	if (pDictionary)
		pDictionary->Release();
            
	if (pFile)
	{  // Close file
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}

	return hr;
}
コード例 #3
0
ファイル: CAAFDefObjectTest.cpp プロジェクト: mcanthony/aaf
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader *		pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
/*	long				test;
*/

  try
  {
    // Remove the previous test file if any.
    RemoveTestFile(pFileName);


	// Create the AAF file
	checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
	bFileOpen = true;

	// Get the AAF file header.
	checkResult(pFile->GetHeader(&pHeader));

    // Get the AAF Dictionary so that we can create valid AAF objects.
    checkResult(pHeader->GetDictionary(&pDictionary));
	CAAFBuiltinDefs defs (pDictionary);

	checkResult(defs.cdContainerDef()->
				CreateInstance(IID_IAAFContainerDef, 
							   (IUnknown **)&pContainerDef));
    
	checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

	checkResult(pContainerDef->Initialize (testUID, sName, sDescription));
	checkResult(pDictionary->RegisterContainerDef(pContainerDef));


	//
	// test Append, Prepend, and enum plugin descriptor using same type def
	//
	IAAFPluginDescriptorSP pd1;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd1));
	checkResult (pd1->Initialize (kTestPluginDescID1,
							L"PluginDesc1",
							L"Plugin Descriptor 1 description"));
	checkResult(pd1->SetDefinitionObjectID(kTestPluginDescID1));
		checkResult (pDictionary->RegisterPluginDef (pd1));

	IAAFPluginDescriptorSP pd2;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd2));
	checkResult (pd2->Initialize (kTestPluginDescID2,
							L"PluginDesc2",
							L"Plugin Descriptor 2 description"));
	checkResult(pd2->SetDefinitionObjectID(kTestPluginDescID2));
	checkResult (pDictionary->RegisterPluginDef (pd2));

	IAAFPluginDescriptorSP pd3;
	checkResult (defs.cdPluginDef()->
				 CreateInstance (IID_IAAFPluginDef,
								 (IUnknown **)&pd3));
	checkResult (pd3->Initialize (kTestPluginDescID3,
							L"PluginDesc3",
							L"Plugin Descriptor 3 description"));
	checkResult(pd3->SetDefinitionObjectID(kTestPluginDescID3));
	checkResult (pDictionary->RegisterPluginDef (pd3));
  }
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }


  // Cleanup and return
  if (pDef)
    pDef->Release();

  if (pContainerDef)
    pContainerDef->Release();

  if (pDictionary)
    pDictionary->Release();

  if (pHeader)
    pHeader->Release();
      
  if (pFile)
  {  // Close file
    if (bFileOpen)
	{
		pFile->Save();
		pFile->Close();
	}
     pFile->Release();
  }

  return hr;
}
コード例 #4
0
ファイル: CAAFContainerDefTest.cpp プロジェクト: UIKit0/aaf
static HRESULT ReadAAFFile(aafWChar* pFileName)
{
	IAAFFile*		pFile = NULL;
	IAAFHeader*		pHeader = NULL;
	IAAFDictionary*  pDictionary = NULL;
	IEnumAAFContainerDefs *pPlug = NULL;
	IAAFContainerDef		*pPlugDef = NULL;
	IAAFDefObject		*pDef = NULL;
	bool bFileOpen = false;
	aafBool			testBool;
	aafUID_t		readUID;
	HRESULT			hr = S_OK;

	try
	{
	  // Open the AAF file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;

		// Get the AAF file header.
		checkResult(pFile->GetHeader(&pHeader));

		checkResult(pHeader->GetDictionary(&pDictionary));
	
		checkResult(pDictionary->GetContainerDefs(&pPlug));
		while(pPlug->NextOne (&pPlugDef) == AAFRESULT_SUCCESS)
		{
			checkResult(pPlugDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef));
			checkResult(pDef->GetAUID(&readUID));
			if(memcmp(&readUID, &testUID, sizeof(aafUID_t)) == 0)
			{
				checkResult(pPlugDef->EssenceIsIdentified (&testBool));
				checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED);
				break;
			}
			pDef->Release();
			pDef = NULL;
			pPlugDef->Release();
			pPlugDef = NULL;
		}
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}

	// Cleanup and return
	if (pDef)
		pDef->Release();

	if (pPlugDef)
		pPlugDef->Release();

	if (pPlug)
		pPlug->Release();

  if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();
      
	if (pFile)
	{  // Close file
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}

	return hr;
}
コード例 #5
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
    // IAAFSession *				pSession = NULL;
    IAAFFile *					pFile = NULL;
    bool bFileOpen = false;
    IAAFHeader *				pHeader = NULL;
    IEnumAAFMobs *mobIter = NULL;
    IAAFContainerDef*  pContainer = NULL;
    IAAFDefObject	*  pDef = NULL;
    IAAFEssenceDescriptor		*pEdesc = NULL;
    IAAFSourceMob				*pSourceMob = NULL;
    IAAFMob			*aMob = NULL;
    IEnumAAFMobSlots	*slotIter = NULL;
    IAAFMobSlot		*slot = NULL;
    IAAFFileDescriptor *pFileDesc = NULL;
    IAAFFileDescriptor2 *pFileDesc2 = NULL;
    aafNumSlots_t	numMobs, n, s;
    HRESULT						hr = S_OK;
    aafRational_t				testSampleRate;
    aafUID_t					testContainer;
    aafLength_t					testLength;
    aafUInt32					testLinkedSlotID;
//	aafBool						testBool;


    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));

        // Get the number of mobs in the file (should be one)
        checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
        checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);


        checkResult(pHeader->GetMobs (NULL, &mobIter));
        for(n = 0; n < numMobs; n++)
        {
            aafWChar		name[500];
            aafNumSlots_t	numSlots;
            aafMobID_t		mobID;
            aafSlotID_t		trackID;

            checkResult(mobIter->NextOne (&aMob));
            checkResult(aMob->GetName (name, sizeof(name)));
            checkResult(aMob->GetMobID (&mobID));

            checkResult(aMob->CountSlots (&numSlots));
            if (2 != numSlots)
                return AAFRESULT_TEST_FAILED;
            if(numSlots != 0)
            {
                checkResult(aMob->GetSlots(&slotIter));

                for(s = 0; s < numSlots; s++)
                {
                    checkResult(slotIter->NextOne (&slot));
                    checkResult(slot->GetSlotID(&trackID));

                    slot->Release();
                    slot = NULL;
                }
            }
            checkResult(aMob->QueryInterface (IID_IAAFSourceMob, (void **)&pSourceMob));
            checkResult(pSourceMob->GetEssenceDescriptor (&pEdesc));
            checkResult(pEdesc->QueryInterface(IID_IAAFFileDescriptor, (void **) &pFileDesc));
            checkResult(pFileDesc->GetSampleRate (&testSampleRate));
            checkExpression(testSampleRate.numerator == checkSampleRate.numerator, AAFRESULT_TEST_FAILED);
            checkExpression(testSampleRate.denominator == checkSampleRate.denominator, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->GetContainerFormat (&pContainer));
            checkResult(pContainer->QueryInterface(IID_IAAFDefObject, (void **) &pDef));
            checkResult(pDef->GetAUID(&testContainer));
            pContainer->Release();
            pContainer = NULL;
            pDef->Release();
            pDef = NULL;
            checkExpression(memcmp(&testContainer, &checkContainer, sizeof(testContainer)) == 0, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->GetLength (&testLength));
            checkExpression(checkLength == testLength, AAFRESULT_TEST_FAILED);
            checkResult(pFileDesc->QueryInterface(IID_IAAFFileDescriptor2, (void **)&pFileDesc2));
            checkResult(pFileDesc2->GetLinkedSlotID (&testLinkedSlotID));
            checkExpression(checkLinkedSlotID == testLinkedSlotID, AAFRESULT_TEST_FAILED);
//			checkResult(pFileDesc->GetIsInContainer (&testBool));
//			checkExpression(testBool == kAAFTrue, AAFRESULT_TEST_FAILED);

            pEdesc->Release();
            pEdesc = NULL;
            pFileDesc->Release();
            pFileDesc = NULL;
            pFileDesc2->Release();
            pFileDesc2 = NULL;
            pSourceMob->Release();
            pSourceMob = NULL;

            aMob->Release();
            aMob = NULL;
        }
    }
    catch (HRESULT& rResult)
    {
        hr = rResult;
    }


    // Cleanup and return
    if (slot)
        slot->Release();

    if (pFileDesc)
        pFileDesc->Release();

    if (pFileDesc2)
        pFileDesc2->Release();

    if (slotIter)
        slotIter->Release();

    if (pEdesc)
        pEdesc->Release();

    if (pSourceMob)
        pSourceMob->Release();

    if (aMob)
        aMob->Release();

    if(mobIter)
        mobIter->Release();

    if (pHeader)
        pHeader->Release();

    if (pFile)
    {
        if (bFileOpen)
            pFile->Close();
        pFile->Release();
    }

    return hr;
}
コード例 #6
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader *		pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
/*	long				test;
*/

  try
  {
    // Remove the previous test file if any.
    RemoveTestFile(pFileName);


	// Create the AAF file
	checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
	bFileOpen = true;

	// We can't really do anthing in AAF without the header.
	checkResult(pFile->GetHeader(&pHeader));

    // Get the AAF Dictionary so that we can create valid AAF objects.
    checkResult(pHeader->GetDictionary(&pDictionary));
	CAAFBuiltinDefs defs (pDictionary);
    
	checkResult(defs.cdContainerDef()->
				CreateInstance(IID_IAAFContainerDef, 
							   (IUnknown **)&pContainerDef));
    
	checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

	checkResult(pContainerDef->Initialize (TEST_ID1, sName1, sDescription1));
	checkResult(pDictionary->RegisterContainerDef(pContainerDef));
	pDef->Release();
	pDef = NULL;
	pContainerDef->Release();
	pContainerDef = NULL;
	checkResult(defs.cdContainerDef()->
				CreateInstance(IID_IAAFContainerDef, 
							   (IUnknown **)&pContainerDef));
    
	checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

	checkResult(pContainerDef->Initialize (TEST_ID2, sName2, sDescription2));
	checkResult(pDictionary->RegisterContainerDef(pContainerDef));
  }
  catch (HRESULT& rResult)
  {
    hr = rResult;
  }


  // Cleanup and return
  if (pDef)
    pDef->Release();

  if (pContainerDef)
    pContainerDef->Release();

  if (pDictionary)
    pDictionary->Release();

  if (pHeader)
    pHeader->Release();
      
  if (pFile)
  {  // Close file
    if (bFileOpen)
	{
		pFile->Save();
		pFile->Close();
	}
     pFile->Release();
  }

  return hr;
}
コード例 #7
0
static HRESULT ReadAAFFile(aafWChar* pFileName)
{
	IAAFFile*			pFile = NULL;
	IAAFHeader*			pHeader = NULL;
	IAAFDictionary*		pDictionary = NULL;
	IEnumAAFContainerDefs *pPlug = NULL;
	IEnumAAFContainerDefs *pClonePlug = NULL;
	IAAFDefObject*		pDef = NULL;
	IAAFContainerDef*	pContainerDef = NULL;
	IAAFContainerDef*	pArray[2] = { NULL, NULL };
//	IAAFContainerDef**	pArrayDef = pArray;
	bool				bFileOpen = false;
	HRESULT				hr = S_OK;
//	wchar_t				testString[256];
//	aafUInt32			resultCount;

	try
	{
		// Open the AAF file
		checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
		bFileOpen = true;

		// Get the AAF file header.
		checkResult(pFile->GetHeader(&pHeader));

		checkResult(pHeader->GetDictionary(&pDictionary));
	
		checkResult(pDictionary->GetContainerDefs(&pPlug));
		/* Read and check the first element */
		checkResult(pPlug->NextOne(&pContainerDef));
		checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

#if 0	//!!! Can't rely on order any more
		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName1) == 0, AAFRESULT_TEST_FAILED);
		pContainerDef->Release();
		pContainerDef = NULL;
		pDef->Release();
		pDef = NULL;

		/* Read and check the second element */
		checkResult(pPlug->NextOne(&pContainerDef));
		checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName2) == 0, AAFRESULT_TEST_FAILED);
		pContainerDef->Release();
		pContainerDef = NULL;
		pDef->Release();
		pDef = NULL;
		/* Reset, and check the first element again*/
		checkResult(pPlug->Reset());
		checkResult(pPlug->NextOne(&pContainerDef));
		checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName1) == 0, AAFRESULT_TEST_FAILED);
		pContainerDef->Release();
		pContainerDef = NULL;
		pDef->Release();
		pDef = NULL;
		/* Reset, Skip, and check the second element again*/
		checkResult(pPlug->Reset());
		checkResult(pPlug->Skip(1));
		checkResult(pPlug->NextOne(&pContainerDef));
		checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName2) == 0, AAFRESULT_TEST_FAILED);
		pContainerDef->Release();
		pContainerDef = NULL;
		pDef->Release();
		pDef = NULL;
		/* Reset, and read both elements */
		checkResult(pPlug->Reset());
		checkResult(pPlug->Next (2, (IAAFContainerDef **)&pArray, &resultCount));
		checkExpression (resultCount == 2, AAFRESULT_TEST_FAILED);
		checkResult(pArrayDef[0]->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName1) == 0, AAFRESULT_TEST_FAILED);
		pDef->Release();
		pDef = NULL;
		checkResult(pArrayDef[1]->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName2) == 0, AAFRESULT_TEST_FAILED);
		pDef->Release();
		pDef = NULL;
		/* Read one past to make sure that it fails */
		checkExpression(pPlug->NextOne(&pContainerDef) != AAFRESULT_SUCCESS, AAFRESULT_TEST_FAILED);
		/* Clone the enumerator, and read one element */
		checkResult(pPlug->Clone(&pClonePlug));
		checkResult(pClonePlug->Reset());
		checkResult(pClonePlug->NextOne(&pContainerDef));
		checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject,
                                          (void **)&pDef));

		checkResult(pDef->GetName (testString, sizeof(testString)));
		checkExpression (wcscmp(testString, sName1) == 0, AAFRESULT_TEST_FAILED);
		pContainerDef->Release();
		pContainerDef = NULL;
		pDef->Release();
		pDef = NULL;
#endif
	}
	catch (HRESULT& rResult)
	{
		hr = rResult;
	}

	// Cleanup and return
	if (pHeader)
		pHeader->Release();
      
	if (pDictionary)
		pDictionary->Release();
      
	if (pPlug)
		pPlug->Release();

	if (pClonePlug)
		pClonePlug->Release();

	if (pDef)
		pDef->Release();
      
	if (pContainerDef)
		pContainerDef->Release();
            
	if (pArray[0])
		pArray[0]->Release();
	if (pArray[1])
		pArray[1]->Release();
            
	if (pFile)
	{  // Close file
		if (bFileOpen)
			pFile->Close();
		pFile->Release();
	}

	return hr;
}