Example #1
0
static HRESULT RegisterDefs (IAAFDictionary * pDict)
{
  assert (pDict);

  CAAFBuiltinDefs defs (pDict);

  
//  IAAFTypeDefSP pTypeUInt8;
//  checkResult(pDict->LookupTypeDef(kAAFTypeID_UInt8, &pTypeUInt8));
  { // Create an opaque type and register it in the dictionary.
    IAAFTypeDefSP pOpaqueType;
    IAAFTypeDefRenameSP pOpaqueTestType;
	  checkResult(pDict->CreateMetaInstance(AUID_AAFTypeDefRename, IID_IAAFTypeDefRename, (IUnknown **)&pOpaqueTestType));
    checkResult(pOpaqueTestType->Initialize(kTestTypeID, defs.tdUInt8(), L"TestUInt8"));
    checkResult(pOpaqueTestType->QueryInterface(IID_IAAFTypeDef, (void **)&pOpaqueType));
    checkResult(pDict->RegisterOpaqueTypeDef(pOpaqueType));
  }

  RegisterOneMetaDef (/* dictionary*/      pDict,
				  /* def object's class id */      AUID_AAFTypeDefRename,
				  /* IID of def to pass to Init */ IID_IAAFTypeDefRename,
				  /* SP of def to use with Init */ IAAFTypeDefRenameSP,
				  /* Init() invocation */
				  Initialize (kTestTypeID, defs.tdUInt8(), L"TestUInt8"),
				  /* IID of type to QI */          IID_IAAFMetaDefinition,
				  /* SP for type to QI */          IAAFMetaDefinitionSP,
				  /* IID of def to register */     IID_IAAFTypeDef,
				  /* SP for def to register */     IAAFTypeDefSP,
				  /* reg method on pDict */        RegisterTypeDef);

  { // Make sure that "TestUInt8" is no longer opaque.
    IAAFTypeDefSP pOpaqueTestType;
    checkExpression(FAILED(pDict->LookupOpaqueTypeDef(kTestTypeID, &pOpaqueTestType)),
                    AAFRESULT_TEST_FAILED);
  }

    
  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdDataDef(),
				  /* IID of def to pass to Init */ IID_IAAFDataDef,
				  /* SP of def to use with Init */ IAAFDataDefSP,
				  /* Init() invocation */
				  Initialize (kTestDataDefID, L"TestDataDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFDataDef,
				  /* SP for def to register */     IAAFDataDefSP,
				  /* reg method on pDict */        RegisterDataDef);
  
  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdOperationDef(),
				  /* IID of def to pass to Init */ IID_IAAFOperationDef,
				  /* SP of def to use with Init */ IAAFOperationDefSP,
				  /* Init() invocation */
				  Initialize (kTestOperationDefID, L"TestOperationDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFOperationDef,
				  /* SP for def to register */     IAAFOperationDefSP,
				  /* reg method on pDict */        RegisterOperationDef);

  // Hack!
  {
	IAAFOperationDefSP od;
	checkResult (pDict->LookupOperationDef (kTestOperationDefID,
										    &od));
	checkResult (od->SetDataDef (defs.ddkAAFMatte()));
  }  
  
  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdParameterDef(),
				  /* IID of def to pass to Init */ IID_IAAFParameterDef,
				  /* SP of def to use with Init */ IAAFParameterDefSP,
				  /* Init() invocation */
				  Initialize (kTestParameterDefID, L"TestParameterDef", L"Desc", defs.tdRational()),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFParameterDef,
				  /* SP for def to register */     IAAFParameterDefSP,
				  /* reg method on pDict */        RegisterParameterDef);

				  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdCodecDef(),
				  /* IID of def to pass to Init */ IID_IAAFCodecDef,
				  /* SP of def to use with Init */ IAAFCodecDefSP,
				  /* Init() invocation */
				  Initialize (kTestCodecDefID, L"TestCodecDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFCodecDef,
				  /* SP for def to register */     IAAFCodecDefSP,
				  /* reg method on pDict */        RegisterCodecDef);

  // Hack! Codec defs must have at least one data def appended in
  // order to be saved correctly...
  {
	IAAFCodecDefSP cd;
	IAAFClassDefSP pClassDef;
	checkResult (pDict->LookupCodecDef (kTestCodecDefID,
										&cd));
	checkResult (cd->AddEssenceKind (defs.ddkAAFMatte()));
	checkResult(pDict->LookupClassDef(kAAFClassID_EssenceDescriptor, &pClassDef));
	checkResult(cd->SetFileDescriptorClass (pClassDef));
  }  

  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdContainerDef(),
				  /* IID of def to pass to Init */ IID_IAAFContainerDef,
				  /* SP of def to use with Init */ IAAFContainerDefSP,
				  /* Init() invocation */
				  Initialize (kTestContainerDefID, L"TestContainerDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFContainerDef,
				  /* SP for def to register */     IAAFContainerDefSP,
				  /* reg method on pDict */        RegisterContainerDef);
  
  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdInterpolationDefinition(),
				  /* IID of def to pass to Init */ IID_IAAFInterpolationDef,
				  /* SP of def to use with Init */ IAAFInterpolationDefSP,
				  /* Init() invocation */
				  Initialize (kTestInterpolationDefID, L"TestInterpolationDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFDefObject,
				  /* SP for type to QI */          IAAFDefObjectSP,
				  /* IID of def to register */     IID_IAAFInterpolationDef,
				  /* SP for def to register */     IAAFInterpolationDefSP,
				  /* reg method on pDict */        RegisterInterpolationDef);
  
  RegisterOneDef (/* dictionary*/                  pDict,
				  /* def object's class */         defs.cdPluginDef(),
				  /* IID of def to pass to Init */ IID_IAAFPluginDef,
				  /* SP of def to use with Init */ IAAFPluginDefSP,
				  /* Init() invocation */
				  Initialize (kTestPluginDefID, L"TestPluginDef", L"Desc"),
				  /* IID of type to QI */          IID_IAAFObject,
				  /* SP for type to QI */          IAAFObjectSP,
				  /* IID of def to register */     IID_IAAFPluginDef,
				  /* SP for def to register */     IAAFPluginDefSP,
				  /* reg method on pDict */        RegisterPluginDef);
  
  return AAFRESULT_SUCCESS;
}
Example #2
0
void EventTest::CreateEvent()
{
  assert(_pHeader && _pDictionary);

  HRESULT hr = S_OK;
  IAAFEvent *pEvent = NULL;
  IAAFEventMobSlot *pEventMobSlot = NULL;
  IAAFSegment *pSegment = NULL;
  IAAFMobSlot *pMobSlot = NULL;
  IAAFDataDef *pDataDef = NULL;
  IAAFComponent *pComp = NULL;
  IAAFMob *pMob = NULL;

  CAAFBuiltinDefs defs (_pDictionary);

  try
  {
	  // not already in dictionary
		checkResult(defs.cdDataDef()->
					CreateInstance (IID_IAAFDataDef,
									(IUnknown **)&pDataDef));
	  hr = pDataDef->Initialize (kAAFDataDef_Test, L"Test", L"Test data");
	  hr = _pDictionary->RegisterDataDef (pDataDef);

	// Create a concrete subclass of event
    checkResult(defs.cdCommentMarker()->
				CreateInstance(IID_IAAFEvent, 
							   (IUnknown **)&pEvent));
    checkResult(pEvent->SetPosition(_position));
    checkResult(pEvent->SetComment(const_cast<wchar_t*>(_eventComment)));
	checkResult(pEvent->QueryInterface(IID_IAAFComponent, (void **)&pComp));
	checkResult(pComp->SetDataDef(pDataDef));
	pComp->Release();
	pComp = NULL;

    // Get the segment inteface to the event to install into the mob slot.
    checkResult(pEvent->QueryInterface(IID_IAAFSegment, (void **)&pSegment));

    // Create and initialize an EventMobSlot
    checkResult(defs.cdEventMobSlot()->
				CreateInstance(IID_IAAFEventMobSlot, 
							   (IUnknown **)&pEventMobSlot));
    checkResult(pEventMobSlot->SetEditRate(const_cast<aafRational_t *>(&_editRate)));

    // Get the mob slot interface so that we can add the event segment.
    checkResult(pEventMobSlot->QueryInterface(IID_IAAFMobSlot, (void **)&pMobSlot));

    // Add the event segment to the event mob slot.
    checkResult(pMobSlot->SetSegment(pSegment));

    // Create the mob to hold the new event mob slot.
    checkResult(defs.cdCompositionMob()->
				CreateInstance(IID_IAAFMob, 
							   (IUnknown **)&pMob));
    checkResult(pMob->SetName(L"CompositionMob::Name:Test mob to hold an event mob slot"));

    // Append event slot to the composition mob.
    checkResult(pMob->AppendSlot(pMobSlot));

    // Save the id of the composition mob that contains our test
    // event mob slot.
    checkResult(pMob->SetMobID(gMobID));
    
    // Attach the mob to the header...
    checkResult(_pHeader->AddMob(pMob));

  }
  catch (HRESULT& rHR)
  {
    hr = rHR;
    // fall through and handle cleanup
  }

  // Cleanup local references
  if (pMob)
  {
    pMob->Release();
    pMob = NULL;
  }

  if (pDataDef)
  {
    pDataDef->Release();
    pDataDef = NULL;
  }

  if (pComp)
  {
    pComp->Release();
    pComp = NULL;
  }

  if (pMobSlot)
  {
    pMobSlot->Release();
    pMobSlot = NULL;
  }

  if (pEventMobSlot)
  {
    pEventMobSlot->Release();
    pEventMobSlot = NULL;
  }

  if (pSegment)
  {
    pSegment->Release();
    pSegment = NULL;
  }

  if (pEvent)
  {
    pEvent->Release();
    pEvent = NULL;
  }



  // Propogate the error if necessary.
  checkResult(hr);
}