// Return the type of object references in the container.
ImplAAFTypeDefObjectRef * ImplAAFWeakRefArrayValue::GetElementType(void) const // the result is NOT reference counted.
{
  ImplAAFTypeDefObjectRef * pContainerElementType = NULL;
  ImplAAFTypeDefArray *pContainerType = NULL;
  AAFRESULT result = AAFRESULT_SUCCESS;
  ImplAAFTypeDefSP pType, pElementType;
  
  result = GetType(&pType);
  ASSERTU(AAFRESULT_SUCCEEDED(result));
  if (AAFRESULT_SUCCEEDED(result))
  {
    pContainerType = dynamic_cast<ImplAAFTypeDefArray *>((ImplAAFTypeDef *)pType); // extract obj from smartptr
    ASSERTU(NULL != pContainerType);
    if (NULL != pContainerType)
    {
      result = pContainerType->GetType(&pElementType);
      ASSERTU(AAFRESULT_SUCCEEDED(result));
      if (AAFRESULT_SUCCEEDED(result))
      {
        pContainerElementType = dynamic_cast<ImplAAFTypeDefWeakObjRef *>((ImplAAFTypeDef *)pElementType); // extract obj from smartptr
      }
    }
  }
  
  ASSERTU(pContainerElementType);
  return pContainerElementType;
}
示例#2
0
//
// WriteTo
//
AAFRESULT STDMETHODCALLTYPE ImplAAFWeakRefValue::WriteTo(
  OMProperty* pOmProp)
{
  ASSERTU (isInitialized());
  if (!isInitialized())
    return AAFRESULT_NOT_INITIALIZED;

  AAFRESULT result = ImplAAFRefValue::WriteTo(pOmProp);
  if (AAFRESULT_SUCCEEDED(result))
  {
    // If there is a referenceProperty then the SetObject method has already
    // written the object reference to the property.
  
    if (NULL == referenceProperty())
    {
      OMReferenceProperty* refProperty = dynamic_cast<OMReferenceProperty *>(pOmProp);
      ASSERTU(refProperty);
      if (NULL == refProperty)
        return AAFRESULT_INVALID_OBJ; // ???

      // Use an "indirect access" method of saving a strong object reference.
      // The local object reference must exist! NOTE: GetLocalObject() does NOT increment
      // the reference count of the returned object!
      result = SetNewObjectReference(refProperty, GetLocalObject());
      if (AAFRESULT_SUCCEEDED(result))
      {
        // Install the property direct access and cleanup the local reference.
        SetProperty(pOmProp);
        SetLocalObject(NULL);
      }
    }
  }
  
  return result;
}
示例#3
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateEmptyValue
(ImplAAFPropertyValue ** ppPropVal)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == ppPropVal)
    return AAFRESULT_NULL_PARAM;
      
  ImplAAFTypeDefSP pElementType;
  result = GetType(&pElementType);
  if (AAFRESULT_FAILED(result))
    return result;
      
      
  if (dynamic_cast<ImplAAFTypeDefStrongObjRef*>((ImplAAFTypeDef*) pElementType))
  {
    // element is strong ref
    ImplAAFStrongRefArrayValue* pStrongRefArray = NULL;
    pStrongRefArray = (ImplAAFStrongRefArrayValue*) CreateImpl (CLSID_AAFStrongRefArrayValue);
    if (!pStrongRefArray) 
      return AAFRESULT_NOMEMORY;
    result = pStrongRefArray->Initialize(this, kAAFTrue == IsFixedSize());
    if (AAFRESULT_SUCCEEDED(result))
    {
      *ppPropVal = pStrongRefArray;
    }
    else
    {
      pStrongRefArray->ReleaseReference();
    }
  }
  else if (dynamic_cast<ImplAAFTypeDefWeakObjRef*>((ImplAAFTypeDef*) pElementType))
  {
    // element is weak ref
    ImplAAFWeakRefArrayValue* pWeakRefArray = NULL;
    pWeakRefArray = (ImplAAFWeakRefArrayValue*) CreateImpl (CLSID_AAFWeakRefArrayValue);
    if (!pWeakRefArray) 
      return AAFRESULT_NOMEMORY;
    result = pWeakRefArray->Initialize(this, kAAFTrue == IsFixedSize());
    if (AAFRESULT_SUCCEEDED(result))
    {
      *ppPropVal = pWeakRefArray;
    }
    else
    {
      pWeakRefArray->ReleaseReference();
    }
  }
  else
  { 
  	//simply defer to base impl (size is 0)
  	result = CreateValue(ppPropVal);
  }
  
  return result;
}
示例#4
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFControlPoint::Initialize
    (ImplAAFVaryingValue * pVaryingValue,
     aafRational_constref  time,
     aafUInt32  valueSize,
     aafDataBuffer_t  pValue)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  ImplAAFTypeDef *pType = NULL;


  if (!pVaryingValue || !pValue)
    return (AAFRESULT_NULL_PARAM);
  if (_initialized)
    return (AAFRESULT_ALREADY_INITIALIZED);

  // First initialize the time.
  result = SetTime (time);
  if (AAFRESULT_SUCCEEDED (result))
  {
    // Lookup the type definition from this constrol point. If it fails
    // then the control point is invalid!
    result = pVaryingValue->GetTypeDefinition (&pType);
    if (AAFRESULT_SUCCEEDED (result))
    {
      _cachedTypeDef = pType;
      _cachedTypeDef->AcquireReference ();

      // Install the initial value.
      result = SetValue (valueSize, pValue);
    }
  }
  
  if (AAFRESULT_SUCCEEDED (result))
  {
    _initialized = true;
  }
  else
  {
    if (_cachedTypeDef)
    {
      _cachedTypeDef->ReleaseReference ();
      _cachedTypeDef = NULL;
    }
  }

  // Cleanup
  if (pType)
    pType->ReleaseReference ();

  return result;
}
示例#5
0
STDAPI
ImplAAFCreateRawStorageCached
  (IAAFRawStorage * pRawStorage,
   aafUInt32  pageCount,
   aafUInt32  pageSize,
   ImplAAFRawStorage ** ppNewRawStorage)
{
  if (! pRawStorage)
	return AAFRESULT_NULL_PARAM;
  if (! ppNewRawStorage)
	return AAFRESULT_NULL_PARAM;

  IAAFCachePageAllocator * pCachePageAllocator = 0;
  HRESULT hr = AAFCreateBuiltinCachePageAllocator(pageSize, pageCount, &pCachePageAllocator);
  if (!AAFRESULT_SUCCEEDED(hr))
    return hr;

  hr = ImplAAFCreateRawStorageCached2(pRawStorage,
                                        pageCount,
                                        pageSize,
                                        pCachePageAllocator,
                                        ppNewRawStorage);

  pCachePageAllocator->Release();
  pCachePageAllocator = 0;

  return hr;
}
示例#6
0
文件: AAFInfo.cpp 项目: mcanthony/aaf
int main(int argumentCount, char* argumentVector[])
{
    if (argumentCount != 2) {
        fprintf(stderr, "Error : wrong number of arguments\n");
        fprintf(stderr, "Usage : AAFInfo <file>\n");
        return(1);
    }

    char* inputFileName = argumentVector[1];

    wchar_t wInputFileName[256];
    convert(wInputFileName, 256, inputFileName);

    HRESULT hr = AAFLoad(0);
    if (!AAFRESULT_SUCCEEDED(hr))
    {
        fprintf(stderr, "Error : Failed to load the AAF library, ");
        fprintf(stderr, "check environment variables -\n");
        fprintf(stderr, "  Windows    - $PATH\n");
        fprintf(stderr, "  Unix/Linux - $LD_LIBRARY_PATH\n");
        exit(hr);
    }

    ReadAAFFile(wInputFileName);

    AAFUnload();

    return(0);
}
示例#7
0
// Allocate and initialize the correct subclass of ImplAAFPropertyValue 
// for the given OMProperty.
AAFRESULT STDMETHODCALLTYPE
  ImplAAFTypeDefStream::CreatePropertyValue(
    OMProperty *property,
    ImplAAFPropertyValue ** ppPropertyValue ) const
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  ASSERTU (property && ppPropertyValue);
  if (NULL == property || NULL == ppPropertyValue)
    return AAFRESULT_NULL_PARAM;
  *ppPropertyValue = NULL; // initialize out parameter
 
  ImplAAFStreamPropertyValue *pStreamValue = NULL;
  pStreamValue = (ImplAAFStreamPropertyValue*) CreateImpl (CLSID_AAFStreamPropertyValue);
  if (!pStreamValue) 
    return AAFRESULT_NOMEMORY;

  // Attempt to initialize the stream value. This will fail if given property is not a valid
  // stream property.
  result = pStreamValue->Initialize (this, property);
  if (AAFRESULT_SUCCEEDED(result))
  {
	*ppPropertyValue = pStreamValue; // The reference count is already 1.
	pStreamValue = NULL;
  }
  else
  {
    pStreamValue->ReleaseReference();
  }
  return result;
}
示例#8
0
// Utility to release all old OMObjects from the given container.
AAFRESULT ImplAAFRefContainerValue::ReleaseAllObjects(OMReferenceContainer *pContainerProperty)
{
  ASSERTU(pContainerProperty && usesReferenceCounting());

  OMReferenceContainerIterator* containerIter = pContainerProperty->createIterator();
  if (NULL == containerIter)
    return AAFRESULT_NOMEMORY;
    
  AAFRESULT result = AAFRESULT_SUCCESS;
  while (AAFRESULT_SUCCEEDED(result) && (containerIter->before() || containerIter->valid()))
  {
    if (++(*containerIter))
    {
      OMObject *object = containerIter->currentObject();
      ImplAAFStorable *obj = dynamic_cast<ImplAAFStorable*>(object);
      ASSERTU(NULL != obj);
      if (NULL == obj)
      {
        result = AAFRESULT_INVALID_OBJ;
      }
      else
      {
        obj->ReleaseReference();
      }
    }
  }

  delete containerIter;
  containerIter = NULL;
  
  return AAFRESULT_SUCCESS;
}
示例#9
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFTypeDefRename::GetBaseValue (
      ImplAAFPropertyValue * pInPropVal,
      ImplAAFPropertyValue ** ppOutPropVal)
{
  if (! pInPropVal) return AAFRESULT_NULL_PARAM;
  if (! ppOutPropVal) return AAFRESULT_NULL_PARAM;

  // Get the property value's embedded type and 
  // check if it's the same as the base type.
  ImplAAFTypeDefSP pInPropType;
  if( AAFRESULT_FAILED( pInPropVal->GetType( &pInPropType ) ) )
	return AAFRESULT_BAD_TYPE;
  ASSERTU (pInPropType);
  if( (ImplAAFTypeDef *)pInPropType != this )
	return AAFRESULT_BAD_TYPE;

  aafUInt32 inBitsSize;
  ImplAAFPropValDataSP pOutPVData;
  ImplAAFPropValDataSP pvd;
  ImplAAFTypeDefSP ptd;

  AAFRESULT hr;
  hr = GetBaseType (&ptd);
  if (AAFRESULT_FAILED (hr)) return hr;
  ASSERTU (ptd);
//  aafUInt32 elementSize = ptd->PropValSize();

  ASSERTU (pInPropVal);
  pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal);
  ASSERTU (pvd);

  hr = pvd->GetBitsSize (&inBitsSize);
  if (! AAFRESULT_SUCCEEDED (hr)) return hr;

  pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData);
  if (! pOutPVData) return AAFRESULT_NOMEMORY;

  // Bobt: Hack bugfix! SmartPointer operator= will automatically
  // AddRef; CreateImpl *also* will addref, so we've got one too
  // many.  Put us back to normal.
  pOutPVData->ReleaseReference ();

  ASSERTU (ptd);
  hr = pOutPVData->Initialize (ptd);
  if (AAFRESULT_FAILED(hr)) return hr;

  hr = pOutPVData->AllocateFromPropVal (pvd,
										0,
										inBitsSize,
										NULL);
  if (AAFRESULT_FAILED(hr)) return hr;

  ASSERTU (ppOutPropVal);
  *ppOutPropVal = pOutPVData;
  (*ppOutPropVal)->AcquireReference ();
  ASSERTU (*ppOutPropVal);
  return AAFRESULT_SUCCESS;
}
示例#10
0
ImplAAFTypeDefSP ImplAAFTypeDefRename::BaseType () const
{
  ImplAAFTypeDefSP result;
  AAFRESULT hr = GetBaseType (&result);
  ASSERTU (AAFRESULT_SUCCEEDED (hr));
  ASSERTU (result);
  return result;
}
示例#11
0
wchar_t* ImplAAFTypeDefExtEnum::elementNameFromValue(OMUniqueObjectIdentification value) const
{
    ImplAAFTypeDefExtEnum* pNonConstThis = const_cast<ImplAAFTypeDefExtEnum*>(this);
    
    wchar_t* result = 0;
    aafUID_t valueI = (*reinterpret_cast<aafUID_t*>(&value));
    aafUInt32 len;
    HRESULT hr = pNonConstThis->GetNameBufLenFromAUID(valueI, &len);
    if (AAFRESULT_SUCCEEDED(hr))
    {
        result = (wchar_t*)(new OMByte[len]);
        hr = pNonConstThis->GetNameFromAUID(valueI, result, len);
        ASSERTU(AAFRESULT_SUCCEEDED(hr));
    }
    
    return result;
}
示例#12
0
bool ImplAAFTypeDefExtEnum::isValidValue(OMUniqueObjectIdentification value) const
{
    ImplAAFTypeDefExtEnum* pNonConstThis = const_cast<ImplAAFTypeDefExtEnum*>(this);
    
    aafUID_t valueI = (*reinterpret_cast<aafUID_t*>(&value));
    aafUInt32 len;
    HRESULT hr = pNonConstThis->GetNameBufLenFromAUID(valueI, &len);
    
    return AAFRESULT_SUCCEEDED(hr);
}
示例#13
0
// Method is called after associated class has been added to MetaDictionary.
// If this method fails the class is removed from the MetaDictionary and the
// registration method will fail.
HRESULT ImplAAFTypeDefArray::CompleteClassRegistration(void)
{
  ImplAAFTypeDefSP pElementType;
  AAFRESULT rc = GetType(&pElementType);
  if (AAFRESULT_SUCCEEDED(rc))
  {
    rc = pElementType->CompleteClassRegistration();
  }

  return rc;
}
示例#14
0
  CAAFInitialize(const char *dllname = NULL)
  {
    HRESULT hr = AAFLoad(dllname);
	if (!AAFRESULT_SUCCEEDED(hr)) {
	  fprintf(stderr, "Error : Failed to load the AAF library, ");
	  fprintf(stderr, "check environment variables -\n");
	  fprintf(stderr, "  Windows    - $PATH\n");
	  fprintf(stderr, "  Unix/Linux - $LD_LIBRARY_PATH\n");
	  exit(hr);
	}
  }
示例#15
0
// Method is called after class has been added to MetaDictionary.
// If this method fails the class is removed from the MetaDictionary and the
// registration method will fail.
HRESULT ImplAAFPropertyDef::CompleteClassRegistration(void)
{
  // Make sure the associated type definition can complete.
  //
  ImplAAFTypeDefSP pType;
  AAFRESULT hr = GetTypeDef (&pType);
  if (AAFRESULT_SUCCEEDED(hr))
  {
    hr = pType->CompleteClassRegistration();
  }
  return hr;
}
示例#16
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateValueFromCArray (
											aafMemPtr_t pInitData,
											aafUInt32 initDataSize,
											ImplAAFPropertyValue ** ppPropVal)
{
	if (! pInitData)
		return AAFRESULT_NULL_PARAM;
	
	if (! ppPropVal)
		return AAFRESULT_NULL_PARAM;
	
  ImplAAFTypeDefSP pElementType;
  AAFRESULT result = GetType(&pElementType);
  if (AAFRESULT_FAILED(result))
    return result;     
      
  if (dynamic_cast<ImplAAFTypeDefObjectRef*>((ImplAAFTypeDef*) pElementType))
  {
    // This interface is not type-safe for accessing objects! There is also no
    // mechanism in place to convert between a buffer pointer and an array
    // of interface pointers; this convertion would not be necessary for
    // arrays of non-objects.
    return AAFRESULT_BAD_TYPE;
  }

	ImplAAFPropValDataSP pvd;
	ImplAAFPropValData * tmp;
	tmp = (ImplAAFPropValData*) CreateImpl (CLSID_AAFPropValData);
	if (!tmp) return AAFRESULT_NOMEMORY;
	pvd = tmp;
	// the pvd smart pointer will maintain a reference for us...
	aafUInt32 refCount;
	refCount = tmp->ReleaseReference ();
	// ...make sure it really does
	ASSERTU (1 == refCount);
	
	AAFRESULT hr;
	hr = pvd->Initialize(this);
	if (! AAFRESULT_SUCCEEDED (hr))
		return hr;
	
	hr = SetCArray (pvd, pInitData, initDataSize);
	if (AAFRESULT_FAILED (hr))
		return hr;
	
	ASSERTU (ppPropVal);
	*ppPropVal = pvd;
	ASSERTU (*ppPropVal);
	(*ppPropVal)->AcquireReference ();
	return AAFRESULT_SUCCESS;
}
示例#17
0
ImplAAFTypeDef* ImplAAFTypeDefExtEnum::NonRefCountedBaseType () const
{
	if(_baseTypeIsCached)
	{
		return _cachedBaseType;
	}
	else
	{	
		ImplAAFTypeDef* result;
		AAFRESULT hr;
		ImplAAFDictionarySP pDict;
		hr = GetDictionary (&pDict);
		ASSERTU (AAFRESULT_SUCCEEDED(hr));
		ASSERTU (pDict);
		
		hr = pDict->LookupTypeDef (kAAFTypeID_AUID, &result);
		ASSERTU (AAFRESULT_SUCCEEDED(hr));
		ASSERTU (result);
 		((ImplAAFTypeDefExtEnum*)this)->_cachedBaseType = result;
 		((ImplAAFTypeDefExtEnum*)this)->_baseTypeIsCached = true;
		return result;
	}
}
示例#18
0
static void
dumpLibInfo(std::wostream &wos)
{
	// print library path name
	aafUInt32 bufSize;
	HRESULT hr = AAFGetLibraryPathNameBufLen(&bufSize);
	if (hr != AAFRESULT_DLL_SYMBOL_NOT_FOUND)
	{
		if (AAFRESULT_SUCCEEDED(hr))
		{
			aafCharacter* buffer = (aafCharacter*) new aafUInt8[bufSize];
			hr = AAFGetLibraryPathName (buffer, bufSize);
			wos << L"AAF DLL path name: ";
			if (AAFRESULT_SUCCEEDED(hr)) {
				wos << L"AAF DLL path name: " << buffer << std::endl;
			} else {
				wos << L"<unknown>" << std::endl;
			}
			delete [] buffer;
		}
	}

	// print library version
	aafProductVersion_t vers;
	hr = AAFGetLibraryVersion(&vers);
	if (hr != AAFRESULT_DLL_SYMBOL_NOT_FOUND)
	{
		if (AAFRESULT_SUCCEEDED(hr))
		{
			wos << L"AAF DLL version  : "
				<< static_cast<unsigned int>(vers.major) << L"."
				<< static_cast<unsigned int>(vers.minor) << L"."
				<< static_cast<unsigned int>(vers.tertiary) << L" ("
				<< static_cast<unsigned int>(vers.patchLevel) << L')' << std::endl;
		}
	}
}
示例#19
0
const OMType* ImplAAFPropertyDef::type(void) const
{
  AAFRESULT hr;
  ImplAAFTypeDef * ptd = 0;

  hr = GetTypeDef (&ptd);
  ASSERTU (AAFRESULT_SUCCEEDED (hr));
  ASSERTU (ptd);
  // Don't reference count these!
  aafUInt32 refCount;
  refCount = ptd->ReleaseReference ();
  // make sure our assumption (dict owns a ref) is correct
  ASSERTU (refCount > 0);
  return ptd->type();
}
示例#20
0
AAFRESULT ImplAAFWeakRefValue::Initialize (
  const ImplAAFTypeDefWeakObjRef *referenceType,    
  OMProperty *property)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  
  result = ImplAAFRefValue::Initialize(referenceType, property);
  
  if (AAFRESULT_SUCCEEDED(result))
  {
    // This instance is now fully initialized.
    setInitialized();
  }
  
  return result;
}
示例#21
0
OMUniqueObjectIdentification ImplAAFTypeDefExtEnum::elementValueFromName(
    const wchar_t* name) const
{
    ImplAAFTypeDefExtEnum* pNonConstThis = const_cast<ImplAAFTypeDefExtEnum*>(this);
    
    aafUID_t result;
    HRESULT hr = pNonConstThis->LookupValByName(&result, static_cast<const aafCharacter*>(name));
    if (AAFRESULT_SUCCEEDED(hr))
    {
        return (*reinterpret_cast<const OMUniqueObjectIdentification*>(&result));
    }
    else
    {
        return nullOMUniqueObjectIdentification;
    }
}
示例#22
0
AAFRESULT ImplAAFWeakRefArrayValue::Initialize (
	  const ImplAAFTypeDefArray *containerType,
	  bool fixed)
{
  AAFRESULT result = AAFRESULT_SUCCESS;

  result = ImplAAFRefArrayValue::Initialize(containerType, fixed);
  
  if (AAFRESULT_SUCCEEDED(result))
  {
    // This instance is now fully initialized.
    setInitialized();
  }
  
  return result;
}
示例#23
0
AAFRESULT ImplAAFWeakRefValue::Initialize (
  const ImplAAFTypeDefWeakObjRef *referenceType)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  
  ASSERTU (!isInitialized());
  if (isInitialized())
    return AAFRESULT_ALREADY_INITIALIZED;
    
  result = ImplAAFRefValue::Initialize(referenceType);
  if (AAFRESULT_SUCCEEDED(result))
  {
    // This instance is now fully initialized.
    setInitialized();
  }
  return result;
}
示例#24
0
// Get an enumerator for the given container property
AAFRESULT STDMETHODCALLTYPE ImplAAFRefContainerValue::GetElements(
  ImplEnumAAFPropertyValues** ppEnum)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == ppEnum)
    return AAFRESULT_NULL_PARAM;
  
  *ppEnum = NULL; // initialize the return parameter.

  ASSERTU (isInitialized());
  if (!isInitialized())
    return AAFRESULT_NOT_INITIALIZED;


  ImplAAFRoot* pRoot = CreateImpl(CLSID_EnumAAFStorablePropVals);
  if (NULL == pRoot)
    return AAFRESULT_NOMEMORY;
    
  ImplEnumAAFStorablePropVals* pNewEnum = dynamic_cast<ImplEnumAAFStorablePropVals*>(pRoot);
  if (NULL != pNewEnum)
  {
    OMReferenceContainerIterator* newIterator = referenceContainer()->createIterator();
    if (NULL != newIterator)
    {
      result = pNewEnum->Initialize(this, newIterator);
      if (AAFRESULT_SUCCEEDED(result))
      {
        *ppEnum = pNewEnum;
        pNewEnum->AcquireReference();
      }
    }
    else
    {
      // _containerIterator->copy() failed...
      result = AAFRESULT_NOMEMORY;
    } 
  }

  // This will free the newly created object if the initialzation has failed.
  pRoot->ReleaseReference();


  return result;
}
示例#25
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefString::CreateValueFromCString (
    aafMemPtr_t  pInitData,
    aafUInt32  initDataSize,
    ImplAAFPropertyValue ** ppPropVal)
{
    if (! pInitData)
        return AAFRESULT_NULL_PARAM;

    if (! ppPropVal)
        return AAFRESULT_NULL_PARAM;

    if (! IsRegistered ())
        return AAFRESULT_NOT_REGISTERED;

    if (initDataSize > OMPROPERTYSIZE_MAX)
        return AAFRESULT_BAD_SIZE;

    ImplAAFPropValDataSP pvd;
    ImplAAFPropValData * tmp;
    tmp = (ImplAAFPropValData*) CreateImpl (CLSID_AAFPropValData);
    if (!tmp) return AAFRESULT_NOMEMORY;
    pvd = tmp;
    // the pvd smart pointer will maintain a reference for us...
    aafUInt32 refCount;
    refCount = tmp->ReleaseReference ();
    // ...make sure it really does
    ASSERTU (1 == refCount);

    AAFRESULT hr;
    hr = pvd->Initialize(this);
    if (! AAFRESULT_SUCCEEDED (hr))
        return hr;

    hr = SetCString (pvd, pInitData, initDataSize);
    if (AAFRESULT_FAILED (hr))
        return hr;

    ASSERTU (ppPropVal);
    *ppPropVal = pvd;
    ASSERTU (*ppPropVal);
    (*ppPropVal)->AcquireReference ();
    return AAFRESULT_SUCCESS;
}
示例#26
0
AAFRESULT ImplAAFTypeDef::MergeTo( ImplAAFDictionary* pDstDictionary )
{
  ASSERTU( pDstDictionary );


  AAFRESULT hr = AAFRESULT_SUCCESS;

  aafUID_t  typeID;
  GetAUID( &typeID );

  ImplAAFTypeDef* pDstTypeDef = 0;
  if( AAFRESULT_FAILED( pDstDictionary->LookupTypeDef( typeID, &pDstTypeDef ) ) )
  {
    OMClassFactory* pDstFactory =
        dynamic_cast<OMClassFactory*>( pDstDictionary->metaDictionary() );
    // New storable object returned by shallowCopy() is
    // reference counted ImplAAFTypeDef.
    OMStorable* pDstStorable = shallowCopy( pDstFactory );
    ImplAAFTypeDef* pDstTypeDef =
        dynamic_cast<ImplAAFTypeDef*>( pDstStorable );
    ASSERTU( pDstTypeDef );

    hr = pDstDictionary->RegisterTypeDef( pDstTypeDef );
    if( AAFRESULT_SUCCEEDED(hr) )
    {
      pDstTypeDef->onCopy( 0 );
      deepCopyTo( pDstTypeDef, 0 );
    }

    // pDstTypeDef created by shallowCopy() is reference counted.
    pDstTypeDef->ReleaseReference();
    pDstTypeDef = 0;
  }
  else
  {
      pDstTypeDef->ReleaseReference();
      pDstTypeDef = 0;
  }


  return hr;
}
示例#27
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFTypeDefRename::CreateValue (
      ImplAAFPropertyValue * pInPropVal,
      ImplAAFPropertyValue ** ppOutPropVal)
{
  if (! pInPropVal) return AAFRESULT_NULL_PARAM;
  if (! ppOutPropVal) return AAFRESULT_NULL_PARAM;

  aafUInt32 inBitsSize;
  ImplAAFPropValDataSP pOutPVData;
  ImplAAFPropValDataSP pvd;
  AAFRESULT hr;

  ASSERTU (pInPropVal);
  pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal);
  ASSERTU (pvd);

  hr = pvd->GetBitsSize (&inBitsSize);
  if (! AAFRESULT_SUCCEEDED (hr)) return hr;

  pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData);
  if (! pOutPVData) return AAFRESULT_NOMEMORY;

  // SmartPointer operator= will automatically AddRef; CreateImpl *also* will 
  // addref, so we've got one too many.  Put us back to normal.
  pOutPVData->ReleaseReference ();

  hr = pOutPVData->Initialize (this);
  if (AAFRESULT_FAILED(hr)) return hr;

  hr = pOutPVData->AllocateFromPropVal (pvd,
										0,
										inBitsSize,
										NULL);
  if (AAFRESULT_FAILED(hr)) return hr;

  ASSERTU (ppOutPropVal);
  *ppOutPropVal = pOutPVData;
  (*ppOutPropVal)->AcquireReference ();
  ASSERTU (*ppOutPropVal);
  return AAFRESULT_SUCCESS;
}
示例#28
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFParameterDef::Initialize (
      const aafUID_t & id,
	  const aafWChar * pName,
	  const aafWChar * pDesc,
    ImplAAFTypeDef * pType)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
	if (pName == NULL || pDesc == NULL || pType == NULL)
	{
	  return AAFRESULT_NULL_PARAM;
	}
	else
	{
    AAFRESULT result = pvtInitialize(id, pName, pDesc);
	  if (AAFRESULT_SUCCEEDED (result))
      result = SetTypeDef (pType);
	}
	return result;
}
示例#29
0
// not public
STDAPI
AAFCreateBuiltinCachePageAllocator
  (aafUInt32  /* pageCount */,
   aafUInt32  /* pageSize */,
   IAAFCachePageAllocator ** ppCachePageAllocator)
{
  ImplAAFCachePageAllocator* pImplAllocator = 0;
  HRESULT hr = ImplAAFCreateBuiltinCachePageAllocator(&pImplAllocator);
  if (!(AAFRESULT_SUCCEEDED (hr)))
    return hr;

  IUnknown *pUnknown = static_cast<IUnknown *>(pImplAllocator->GetContainer());
  ASSERTU(pUnknown);
  IAAFCachePageAllocator* pNewAllocator = 0;
  hr = pUnknown->QueryInterface(IID_IAAFCachePageAllocator, (void **)&pNewAllocator);
  ASSERTU (SUCCEEDED (hr));
  pImplAllocator->ReleaseReference();
  *ppCachePageAllocator = pNewAllocator;
  return AAFRESULT_SUCCESS;
}
示例#30
0
HRESULT STDMETHODCALLTYPE
CAAFEssenceDataStream::Init(
            /* [in] */ IUnknown  *essenceData)
{
  if (NULL == essenceData)
    return AAFRESULT_NULL_PARAM;

  if (NULL != _data)
    return AAFRESULT_ALREADY_INITIALIZED;

  IAAFEssenceData2* essenceData2 = NULL;
  AAFRESULT hr = essenceData->QueryInterface (IID_IAAFEssenceData2, (void **)&essenceData2);
  if (AAFRESULT_SUCCEEDED(hr))
  {
    hr = essenceData2->GetPlainEssenceData(0, &_data);
    essenceData2->Release();
    essenceData2 = NULL;
  }

  return hr;
}