コード例 #1
0
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
  mtc::SimpleFilePointers filePointers;

  try {
    using namespace mtc;

    ReadSimpleAAFFile( pFileName, &filePointers );

    // Get slot 2 from the composition and verify that that attached
    // segment is a DescriptiveMarker.
    
    IAAFSmartPointer<IAAFMobSlot> pSlot = GetSlotById( filePointers.pCompositionMob, 2 );

    IAAFSmartPointer<IAAFSegment> pSeg;
    CheckResult( pSlot->GetSegment( &pSeg ) );

    IAAFSmartPointer<IAAFDescriptiveMarker> pDescMarker;
    CheckResult( pSeg->QueryInterface( IID_IAAFDescriptiveMarker, (void**)&pDescMarker ) );
    
    IAAFSmartPointer<IAAFDescriptiveFramework> pDescFramework;
    CheckResult( pDescMarker->GetDescriptiveFramework( &pDescFramework ) );

    IAAFSmartPointer<IAAFObject> pDescFrameworkAsObj;
    CheckResult( pDescFramework->QueryInterface( IID_IAAFObject, (void**)&pDescFrameworkAsObj ) );
    
    IAAFSmartPointer<IAAFClassDef> pClassDef;
    CheckResult( pDescFrameworkAsObj->GetDefinition( &pClassDef ) );

    IAAFSmartPointer<IAAFMetaDefinition> pMetaDef;
    CheckResult( pClassDef->QueryInterface( IID_IAAFMetaDefinition, (void**)&pMetaDef ) );

    aafUID_t auid;

    CheckResult( pMetaDef->GetAUID( &auid ) );

    CheckExpression( memcmp( &auid, &TestDesciptiveFrameworkClassID, sizeof(auid) ) == 0,
		     AAFRESULT_TEST_FAILED );

    // Get, and test, the described slots from the marker.
    aafUInt32 getSlotIDsVector[TestDescribedIDsVectorSize];
    aafUInt32 getSlotIDsVectorSize = 0;

    CheckResult( pDescMarker->GetDescribedSlotIDsSize( &getSlotIDsVectorSize ) );
    CheckExpression( TestDescribedIDsVectorSize == getSlotIDsVectorSize, AAFRESULT_TEST_FAILED );

    CheckExpression( AAFRESULT_SMALLBUF ==
		       pDescMarker->GetDescribedSlotIDs( getSlotIDsVectorSize-1, getSlotIDsVector ),
		     AAFRESULT_TEST_FAILED );

    CheckResult( pDescMarker->GetDescribedSlotIDs( getSlotIDsVectorSize, getSlotIDsVector ) );

    CheckExpression( 0 == memcmp( getSlotIDsVector, TestDescribedSlotIDsVector, sizeof(TestDescribedSlotIDsVector) ),
		     AAFRESULT_TEST_FAILED );

    // Check that the described slots set can be accessed using a
    // property value enumerator.
    IAAFSmartPointer<IAAFObject> pDescMarkerObj;
    CheckResult( pDescMarker->QueryInterface( IID_IAAFObject, (void**)&pDescMarkerObj ) );

    CheckResult( pDescMarkerObj->GetDefinition( &pClassDef ) );

    IAAFSmartPointer<IAAFPropertyDef> pPropDef;
    CheckResult( pClassDef->LookupPropertyDef( kAAFPropID_DescriptiveMarker_DescribedSlots,
					       &pPropDef ) );

    IAAFSmartPointer<IAAFPropertyValue> pPropVal;
    CheckResult( pDescMarkerObj->GetPropertyValue( pPropDef, &pPropVal ) );

    IAAFSmartPointer<IAAFTypeDef> pTypeDef;
    CheckResult( pPropDef->GetTypeDef( &pTypeDef ) );

    IAAFSmartPointer<IAAFTypeDefSet> pTypeDefSet;
    CheckResult( pTypeDef->QueryInterface( IID_IAAFTypeDefSet, (void**)&pTypeDefSet ) );

    IAAFSmartPointer<IEnumAAFPropertyValues> pEnumSetValues;
    CheckResult( pTypeDefSet->GetElements( pPropVal, &pEnumSetValues ) );
    
    VerifySetContents( pEnumSetValues );
	
	
    CheckResult( filePointers.pFile->Close() );
  }
  catch( const AAFRESULT& hr ) {
    if(filePointers.pFile) {
      filePointers.pFile->Close();
    }
    cout << "failed hr = " << hr << endl;
    return hr;
  }

  return AAFRESULT_SUCCESS;
}
コード例 #2
0
static HRESULT CreateAAFFile(
    aafWChar * pFileName,
    aafUID_constref fileKind,
    testRawStorageType_t rawStorageType,
    aafProductIdentification_constref productID)
{
  mtc::SimpleFilePointers filePointers;

  try {
    using namespace mtc;

    IAAFSmartPointer<IAAFHeader> pHeader;
    IAAFSmartPointer<IAAFDictionary> pDict;
    CreateSimpleAAFFile( pFileName, 
			 fileKind,
			 rawStorageType,
			 productID,
			 &filePointers );

    // Add add a timeline, and add a DescriptiveMarker to the
    // composition mob.
    IAAFSmartPointer<IAAFDescriptiveMarker> pDescMarker;
    CheckResult( filePointers.pDictionary->CreateInstance( AUID_AAFDescriptiveMarker,
							   IID_IAAFDescriptiveMarker,
							   (IUnknown**)&pDescMarker ));

    CheckResult( pDescMarker->Initialize() );

    IAAFSmartPointer<IAAFSegment> pSeg;
    CheckResult(pDescMarker->QueryInterface( IID_IAAFSegment, (void**)&pSeg ));

    IAAFSmartPointer<IAAFComponent> pComp;
    CheckResult( pDescMarker->QueryInterface( IID_IAAFComponent, (void**)&pComp ));
    CheckResult( pComp->SetDataDef( filePointers.pDataDef ));
	
    IAAFSmartPointer<IAAFTimelineMobSlot> pNewSlot;
    CheckResult( filePointers.pCompositionMob->AppendNewTimelineSlot(TEST_EditRate,
								     pSeg,
								     2,
								     L"Descriptive Content",
								     0,
								     &pNewSlot ));

    // Attach a (concrete) descriptive framework object to the marker.

    RegisterDescriptiveTestFramework( filePointers.pDictionary );

    IAAFSmartPointer<IAAFDescriptiveFramework> pDescFramework;
    CheckResult( filePointers.pDictionary->CreateInstance( TestDesciptiveFrameworkClassID,
							   IID_IAAFDescriptiveFramework,
							   (IUnknown**)&pDescFramework ) );
    CheckResult( pDescMarker->SetDescriptiveFramework( pDescFramework ) );

    // Get described slots - should not be present.
    aafUInt32 size = 0;
    HRESULT hr = pDescMarker->GetDescribedSlotIDsSize( &size );
    CheckExpression( AAFRESULT_PROP_NOT_PRESENT == hr, AAFRESULT_TEST_FAILED );

    // Set/Get single described slot.
    aafUInt32 setSingleSlotID = 0xdeadbeef;
    CheckResult( pDescMarker->SetDescribedSlotIDs( 1, &setSingleSlotID ) );
    aafUInt32 getSingleSlotID = 0;
    CheckResult( pDescMarker->GetDescribedSlotIDs( 1, &getSingleSlotID ) );
    CheckExpression( setSingleSlotID == getSingleSlotID, AAFRESULT_TEST_FAILED );

    // Set the persistent described slots.
    CheckResult( pDescMarker->SetDescribedSlotIDs( TestDescribedIDsVectorSize, TestDescribedSlotIDsVector ) );

    CheckResult( filePointers.pFile->Save() );
    CheckResult( filePointers.pFile->Close() );
  }
  catch( const AAFRESULT& hr ) {
    if(filePointers.pFile) {
      filePointers.pFile->Close();
    }
    return hr;
  }

  return AAFRESULT_SUCCESS;
}