Ejemplo n.º 1
0
static void CheckMobsByUsageCode( IAAFHeader* pHeader,
				  aafSearchCrit_t& usageCrit,
				  int expectedCount,
				  bool checkIID,
				  const IID& expectedIID )
{
  IAAFSmartPointer<IEnumAAFMobs> pEnumByUsage;
  checkResult( pHeader->GetMobs( &usageCrit, &pEnumByUsage ) );

  // Should get one back, and it should be a composition mob.
  IAAFSmartPointer<IAAFMob> pNextMob;
  HRESULT nextHr;
  int count;
  for( count = 0, nextHr = pEnumByUsage->NextOne( &pNextMob );
       AAFRESULT_SUCCESS == nextHr;
       count++, nextHr = pEnumByUsage->NextOne( &pNextMob ) ) {
    if ( checkIID ) {
      // Quering for one interface but passing a pointer to another
      // interface is not a right thing to do but since it's a pointer
      // to IUnknown, the parent of them all, and all we do is call
      // Release() on it, it's OK.
      IAAFSmartPointer<IUnknown> pUnused;
      checkResult( pNextMob->QueryInterface( expectedIID, (void**)&pUnused ) );
    }
  }
    
  checkExpression( AAFRESULT_NO_MORE_OBJECTS == nextHr,
		   AAFRESULT_TEST_FAILED );
  
  checkExpression( expectedCount == count, AAFRESULT_TEST_FAILED );
}
Ejemplo n.º 2
0
static void RegisterDataEssenceDescriptorTest( IAAFDictionary* pDict )
{

  // Create a new class definition for the TestDescriptiveFramework.

  IAAFSmartPointer<IAAFClassDef> pClassDef;
  checkResult( pDict->CreateMetaInstance( AUID_AAFClassDef, IID_IAAFClassDef,
					  (IUnknown**)&pClassDef ) );

  IAAFSmartPointer<IAAFClassDef> pBaseClassDef;
  checkResult( pDict->LookupClassDef( AUID_AAFDataEssenceDescriptor, &pBaseClassDef ) );

  checkResult( pClassDef->Initialize( TestDataEssenceDescriptorClassID,
				      pBaseClassDef,
				      L"TestDataEssenceDescriptor",
				      kAAFTrue ) );

  checkResult( pDict->RegisterClassDef( pClassDef ) );
}
Ejemplo n.º 3
0
static void RegisterDescriptiveTestFramework( IAAFSmartPointer<IAAFDictionary>& pDict )
{
  using namespace mtc;

  // Create a new class definition for the TestDescriptiveFramework.

  IAAFSmartPointer<IAAFClassDef> pClassDef;
  CheckResult( pDict->CreateMetaInstance( AUID_AAFClassDef, IID_IAAFClassDef,
					  (IUnknown**)&pClassDef ) );

  IAAFSmartPointer<IAAFClassDef> pBaseClassDef;
  CheckResult( pDict->LookupClassDef( AUID_AAFDescriptiveFramework, &pBaseClassDef ) );

  CheckResult( pClassDef->Initialize( TestDesciptiveFrameworkClassID,
				      pBaseClassDef,
				      L"TestDescriptiveFramework",
				      kAAFTrue ) );

  CheckResult( pDict->RegisterClassDef( pClassDef ) );
}
Ejemplo n.º 4
0
aafUInt32 GetNextUInt32( IAAFSmartPointer<IEnumAAFPropertyValues> pEnumSetValues )
{
  using namespace mtc;

  IAAFSmartPointer<IAAFPropertyValue> pPropVal;
  CheckResult( pEnumSetValues->NextOne( &pPropVal ) );

  IAAFSmartPointer<IAAFTypeDef> pElemType;
  CheckResult( pPropVal->GetType( &pElemType ) );

  IAAFSmartPointer<IAAFTypeDefInt> pIntTypeDef;
  CheckResult( pElemType->QueryInterface( IID_IAAFTypeDefInt, (void**)&pIntTypeDef ) );

  aafUInt32 val;
  CheckResult( pIntTypeDef->GetInteger( pPropVal, (aafMemPtr_t)&val, sizeof(val) ) );

  return val;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}