// // Make sure that this is a valid stream property value. // AAFRESULT ImplAAFTypeDefStream::GetStreamPropertyValue( ImplAAFPropertyValue * pPropertyValue, ImplAAFStreamPropertyValue *& pStreamPropertyValue) { pStreamPropertyValue = NULL; // init out parameter if (NULL == pPropertyValue) return AAFRESULT_NULL_PARAM; // The stream property value's type should be this instance of // ImplAAFTypeDefStream. ImplAAFTypeDefSP pPropertyValueType; pPropertyValue->GetType(&pPropertyValueType); eAAFTypeCategory_t propertyTypeCategory = kAAFTypeCatUnknown; pPropertyValueType->GetTypeCategory(&propertyTypeCategory); eAAFTypeCategory_t thisTypeCategory = kAAFTypeCatUnknown; GetTypeCategory(&thisTypeCategory); if (propertyTypeCategory != thisTypeCategory) return AAFRESULT_INVALID_PARAM; pStreamPropertyValue = dynamic_cast<ImplAAFStreamPropertyValue *>(pPropertyValue); if (NULL == pStreamPropertyValue) return AAFRESULT_INVALID_PARAM; return AAFRESULT_SUCCESS; }
void ImplAAFTypeDefString::internalize(const OMByte* externalBytes, OMUInt32 externalBytesSize, OMByte* internalBytes, OMUInt32 internalBytesSize, OMByteOrder byteOrder) const { ImplAAFTypeDefSP ptd = BaseType(); ASSERTU (ptd); ASSERTU (ptd->IsFixedSize ()); aafUInt32 extElemSize = ptd->PropValSize (); aafUInt32 intElemSize = ptd->ActualSize (); // aafUInt32 intElemSize = ptd->internalSize (0, 0); // aafUInt32 extElemSize = ptd->externalSize (0, 0); aafUInt32 numElems = externalBytesSize / extElemSize; aafInt32 intNumBytesLeft = internalBytesSize; aafInt32 extNumBytesLeft = externalBytesSize; aafUInt32 elem = 0; for (elem = 0; elem < numElems; elem++) { ptd->type()->internalize (externalBytes, extElemSize, internalBytes, intElemSize, byteOrder); internalBytes += intElemSize; externalBytes += extElemSize; intNumBytesLeft -= intElemSize; extNumBytesLeft -= extElemSize; ASSERTU (intNumBytesLeft >= 0); ASSERTU (extNumBytesLeft >= 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; }
// 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; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::ValidateInputParams ( ImplAAFPropertyValue ** ppElementValues, aafUInt32 numElements) { //first validate params + basic stuff ... if (!ppElementValues) return AAFRESULT_NULL_PARAM; //verify that all the individual elem types are the same as each other, HRESULT hr; //get Base TD ImplAAFTypeDefSP spTargetTD; hr = GetType(&spTargetTD); //gets base elem type if (AAFRESULT_FAILED (hr)) return hr; if (! spTargetTD->IsRegistered ()) return AAFRESULT_NOT_REGISTERED; //Get size aafUInt32 targetElemSize = spTargetTD->NativeSize(); for (aafUInt32 i=0; i<numElements; i++) { //get source type ImplAAFTypeDefSP spSourceTD; hr = ppElementValues[i]->GetType (&spSourceTD); if (AAFRESULT_FAILED (hr)) return hr; //verify that spTargetTD == spSourceTD if (spSourceTD != spTargetTD ) return AAFRESULT_BAD_TYPE; //verify FIXED/VARIABLE Arrayable if (! IsArrayable(spSourceTD) ) return AAFRESULT_BAD_TYPE; //verify that the target elem size is equal to that of source aafUInt32 sourceSize = spSourceTD->NativeSize(); if (sourceSize != targetElemSize ) return AAFRESULT_BAD_SIZE; }//for each elem return AAFRESULT_SUCCESS; }//ValidateInputParams()
OMUInt32 ImplAAFTypeDefString::internalSize(const OMByte* /*externalBytes*/, OMUInt32 externalBytesSize) const { ImplAAFTypeDefSP ptd = BaseType(); ASSERTU (ptd); ASSERTU (ptd->IsFixedSize ()); aafUInt32 extElemSize = ptd->PropValSize (); aafUInt32 intElemSize = ptd->ActualSize (); // aafUInt32 extElemSize = ptd->externalSize (0, 0); // aafUInt32 intElemSize = ptd->internalSize (0, 0); ASSERTU (intElemSize); aafUInt32 numElems = externalBytesSize / extElemSize; return numElems * intElemSize; }
void ImplAAFTypeDefString::reorder(OMByte* externalBytes, OMUInt32 externalBytesSize) const { ImplAAFTypeDefSP ptd = BaseType(); ASSERTU (ptd); aafUInt32 extElemSize = ptd->PropValSize (); aafUInt32 numElems = externalBytesSize / extElemSize; aafInt32 numBytesLeft = externalBytesSize; aafUInt32 elem = 0; for (elem = 0; elem < numElems; elem++) { ptd->type()->reorder (externalBytes, extElemSize); externalBytes += extElemSize; numBytesLeft -= extElemSize; ASSERTU (numBytesLeft >= 0); } }
OMProperty * ImplAAFPropertyDef::CreateOMProperty () const { OMProperty * result = 0; if (_OMPropCreateFunc) { result = _OMPropCreateFunc (_pid, name()); } if (! result) { // Either there was no create func, or an existing one deferred // to the type def. ImplAAFTypeDefSP ptd; AAFRESULT hr = GetTypeDef (&ptd); ASSERTU (AAFRESULT_SUCCEEDED (hr)); ASSERTU (ptd); result = ptd->pvtCreateOMProperty (_pid, name()); } return result; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefString::GetCount ( ImplAAFPropertyValue * pPropVal, aafUInt32 * pCount) { ImplAAFTypeDefSP pIncomingType; ImplAAFTypeDefSP ptd; AAFRESULT hr; if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pCount) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; hr = GetType (&ptd); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ptd); ASSERTU (ptd->IsFixedSize()); aafUInt32 elemSize = ptd->ActualSize(); aafUInt32 propSize; ASSERTU (pPropVal); ImplAAFPropValDataSP pvd; pvd = dynamic_cast<ImplAAFPropValData *>(pPropVal); ASSERTU (pvd); hr = pvd->GetBitsSize (&propSize); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (pCount); *pCount = propSize / elemSize; return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::SetCArray ( ImplAAFPropertyValue * pPropVal, aafMemPtr_t pData, aafUInt32 dataSize) { if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pData) return AAFRESULT_NULL_PARAM; if (! IsRegistered ()) return AAFRESULT_NOT_REGISTERED; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; AAFRESULT hr; ImplAAFTypeDefSP pBaseType; hr = GetType (&pBaseType); ASSERTU (pBaseType->IsFixedSize ()); pBaseType->AttemptBuiltinRegistration (); ASSERTU (pBaseType->IsRegistered ()); ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pPropVal); if (NULL != pRefArray) { // 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; } // Size of individual elements aafUInt32 elemSize = pBaseType->NativeSize (); // number of elements in input data. If this is not an integral // number, this will round down and the test below will fail. aafUInt32 elemCount = dataSize / elemSize; // The size of the new property, calculated from number of elements // and the size of each element. aafUInt32 propSize = elemSize * elemCount; // If the given dataSize was not an integral multiple of the size of // each element, then we'll signal an error. if (propSize != dataSize) return AAFRESULT_BAD_SIZE; // In case of fixed-size arrays, we'll also have to see if the data // size matches what we're expecting. if (IsFixedSize ()) { aafUInt32 nativeSize = NativeSize (); if (nativeSize != dataSize) return AAFRESULT_BAD_SIZE; } ImplAAFPropValData * pvd = 0; ASSERTU (pPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pPropVal); ASSERTU (pvd); aafMemPtr_t pBits = 0; hr = pvd->AllocateBits (propSize, &pBits); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pBits); memcpy (pBits, pData, propSize); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::SetElementValue ( ImplAAFPropertyValue * pPropVal, aafUInt32 index, ImplAAFPropertyValue * pMemberPropVal) { //Ensure our input pointers are valid if (!pPropVal || !pMemberPropVal) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pPropVal); if (NULL != pRefArray) { return pRefArray->SetElementAt(pMemberPropVal, index); } //Ensure index is within range if (index >= pvtCount(pPropVal)) //if index is > 0..n-1 return AAFRESULT_BADINDEX; //AAFRESULT_BAD_PARAM; //all parameters validated; proceed .... AAFRESULT hr; //get source size ImplAAFTypeDefSP spSourceTD; hr = pMemberPropVal->GetType (&spSourceTD); if (AAFRESULT_FAILED (hr)) return hr; if (! spSourceTD->IsRegistered ()) return AAFRESULT_NOT_REGISTERED; aafUInt32 sourceSize = spSourceTD->NativeSize(); //get Base TD and size ImplAAFTypeDefSP spTargetTD; hr = GetType (&spTargetTD); //gets base elem type if (AAFRESULT_FAILED (hr)) return hr; aafUInt32 targetElemSize = spTargetTD->NativeSize(); //verify that spTargetTD == spSourceTD if (spTargetTD != spSourceTD) return AAFRESULT_BAD_TYPE; //verify that the target elem size is equal to that of source if (targetElemSize != sourceSize) return AAFRESULT_BAD_SIZE; //// On to data ... //get Source Data ImplAAFPropValData * pvd_Source = dynamic_cast<ImplAAFPropValData*> (pMemberPropVal); ASSERTU (pvd_Source); aafUInt32 source_bitsSize; hr = pvd_Source->GetBitsSize (&source_bitsSize); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (source_bitsSize); ASSERTU ( targetElemSize == source_bitsSize); aafMemPtr_t pSourceData = 0; hr = pvd_Source->GetBits (&pSourceData); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pSourceData); //get Target Data ImplAAFPropValData * pvd_Target = dynamic_cast<ImplAAFPropValData*> (pPropVal); ASSERTU (pvd_Target); aafUInt32 target_bitsSize; hr = pvd_Target->GetBitsSize (&target_bitsSize); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU ( target_bitsSize >= ((index+1) * targetElemSize) ); aafMemPtr_t pTargetData = 0; hr = pvd_Target->GetBits (&pTargetData); //gets the 0th index location if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pTargetData); //make target point to the right element pTargetData += (index * targetElemSize); //finally, copy over the appropriate bits memcpy (pTargetData, pSourceData, sourceSize); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::GetCArray ( ImplAAFPropertyValue * pPropVal, aafMemPtr_t pData, aafUInt32 dataSize) { if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pData) return AAFRESULT_NULL_PARAM; if (! IsRegistered ()) return AAFRESULT_NOT_REGISTERED; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFTypeDefSP pBaseType; HRESULT hr = GetType (&pBaseType); ASSERTU (pBaseType->IsFixedSize ()); pBaseType->AttemptBuiltinRegistration (); ASSERTU (pBaseType->IsRegistered ()); ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pPropVal); if (NULL != pRefArray) { // 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; } aafUInt32 elemSize = pBaseType->NativeSize (); aafUInt32 elemCount = pvtCount (pPropVal); aafUInt32 propSize = elemSize * elemCount; if (dataSize < propSize) return AAFRESULT_BAD_SIZE; ImplAAFPropValData * pvd = 0; ASSERTU (pPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pPropVal); ASSERTU (pvd); aafUInt32 bitsSize; hr = pvd->GetBitsSize (&bitsSize); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (bitsSize >= propSize); aafMemPtr_t pBits = 0; hr = pvd->GetBits (&pBits); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pBits); memcpy (pData, pBits, propSize); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::GetElementValue ( ImplAAFPropertyValue * pInPropVal, aafUInt32 index, 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 pIncomingType; if( AAFRESULT_FAILED( pInPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pInPropVal); if (NULL != pRefArray) { return pRefArray->GetElementAt(index, ppOutPropVal); } if (index >= pvtCount (pInPropVal)) return AAFRESULT_BADINDEX; aafUInt32 inBitsSize; ImplAAFPropValDataSP pOutPVData; ImplAAFPropValDataSP pvd; ImplAAFTypeDefSP ptd; AAFRESULT hr; hr = GetType (&ptd); if (AAFRESULT_FAILED (hr)) return hr; // aafUInt32 elementSize = ptd->PropValSize(); aafUInt32 elementSize = ptd->ActualSize(); // okay for data not to be registered? ASSERTU (pInPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal); hr = pvd->GetBitsSize (&inBitsSize); if (! AAFRESULT_SUCCEEDED (hr)) return hr; ASSERTU ((index+1) * elementSize <= inBitsSize); 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 (); hr = pOutPVData->Initialize (ptd); if (AAFRESULT_FAILED(hr)) return hr; hr = pOutPVData->AllocateFromPropVal (pvd, index * elementSize, elementSize, NULL); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ppOutPropVal); *ppOutPropVal = pOutPVData; ASSERTU (*ppOutPropVal); (*ppOutPropVal)->AcquireReference (); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::CreateValueFromValues ( ImplAAFPropertyValue ** ppElementValues, aafUInt32 numElements, ImplAAFPropertyValue ** ppPropVal) { AAFRESULT hr = AAFRESULT_SUCCESS; //first validate params ... if (!ppPropVal) return AAFRESULT_NULL_PARAM; hr = ValidateInputParams(ppElementValues, numElements); if (AAFRESULT_FAILED (hr)) return hr; // All params validated; proceed .... // PATCH DR4_CPR: transdel. Create the appropriate ImplAAFRefArray without an associated // property. The property value's writeTo method needs to copy (or replace) the contents // of the current property. This a hybrid of the old-pseudo "direct access" and the new // more direct property access. ImplAAFTypeDefSP pElementType; hr = GetType(&pElementType); if (AAFRESULT_FAILED(hr)) return hr; if (dynamic_cast<ImplAAFTypeDefObjectRef*>((ImplAAFTypeDef*) pElementType)) { ImplAAFPropertyValue *pPropertyValue = NULL; hr = CreateEmptyValue(&pPropertyValue); if (AAFRESULT_SUCCEEDED(hr)) { ImplAAFRefArrayValue *pRefArray = dynamic_cast<ImplAAFRefArrayValue *>(pPropertyValue); ASSERTU(NULL != pRefArray); if (NULL == pRefArray) hr = AAFRESULT_INVALID_OBJ; aafUInt32 index; for (index = 0; (index < numElements) && AAFRESULT_SUCCEEDED(hr); ++index) { hr = pRefArray->AppendElement(ppElementValues[index]); } if (AAFRESULT_SUCCEEDED(hr)) *ppPropVal = pPropertyValue; // refcount already incremented else pPropertyValue->ReleaseReference(); pPropertyValue = NULL; } } else { //2nd step - Create the value; defer to base impl //first, calculate the total size needed for allocation, based on type //get Base TD ImplAAFTypeDefSP spTargetTD; hr = GetType(&spTargetTD); //gets base elem type if (AAFRESULT_FAILED (hr)) return hr; //Get Elem size aafUInt32 targetElemSize = spTargetTD->NativeSize(); //Total size ... aafUInt32 totalSize = targetElemSize * numElements; //size based on "n" Elements //create the value hr = ImplAAFTypeDefArray::CreateValue(ppPropVal, totalSize); if (AAFRESULT_FAILED(hr)) return hr; //... Copy the values ; defer to base impl hr = ImplAAFTypeDefArray::CopyValuesIntoValue(ppElementValues,numElements, targetElemSize, ppPropVal); } return hr; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefString::AppendElements ( ImplAAFPropertyValue * pInPropVal, aafMemPtr_t pElements) { if (! pInPropVal) return AAFRESULT_NULL_PARAM; if (! pElements) return AAFRESULT_NULL_PARAM; if (! IsRegistered ()) return AAFRESULT_NOT_REGISTERED; AAFRESULT hr; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pInPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFTypeDefSP pBaseType; hr = GetType (&pBaseType); //do the size thing ... ASSERTU (pBaseType->IsFixedSize ()); pBaseType->AttemptBuiltinRegistration (); ASSERTU (pBaseType->IsRegistered ()); // Size of individual elements aafUInt32 elementSize = pBaseType->NativeSize (); // Get the current size of the property aafUInt32 originalDataSize; ImplAAFPropValDataSP pvd; pvd = dynamic_cast<ImplAAFPropValData *>(pInPropVal); ASSERTU (pvd); hr = pvd->GetBitsSize (&originalDataSize); //get the data aafMemPtr_t pOriginalData = NULL; hr = pvd->GetBits (&pOriginalData); ASSERTU(hr == AAFRESULT_SUCCESS); ///// //Now, find out what additional size we need based on the new data coming in. //first, see how many elements we have aafMemPtr_t pNewData = pElements; aafUInt32 newElemCount =0; //outer loop of the entire memory buffer passed in ... while (pNewData) { aafUInt32 count_of_zeroes = 0; //inner loop - chunking in size of elementSize for (aafUInt32 i=0; i<elementSize; i++, pNewData++) if (*pNewData == 0) count_of_zeroes++; if (count_of_zeroes == elementSize) //we have a null! ... done! break; //otherwise, increment new element count, and move on newElemCount++; }//while //At this point, our newElemCount holds a count of new elements to be added //and the new size of bits is: aafUInt32 newsize = (newElemCount+1/*don't forget EOS*/) * elementSize; //Add this "newsize" to the original originalDataSize to get the new Total buffer size aafUInt32 TotalSize = originalDataSize + newsize; // Make sure that the new size doesn't exceed maximum // size allowed for simple properties. if (TotalSize > OMPROPERTYSIZE_MAX) return AAFRESULT_BAD_SIZE; //Save the orginal buffer, before we re-allocate aafMemPtr_t tmp_buffer = new aafUInt8[originalDataSize+1]; memcpy(tmp_buffer, pOriginalData, originalDataSize); //Allocate the grand total # of bits (orginal + the new stuff) ... aafMemPtr_t pBits = 0; hr = pvd->AllocateBits (TotalSize, &pBits); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pBits); //copy over the first part memcpy (pBits, tmp_buffer, originalDataSize); pBits += originalDataSize; //copy over the second part memcpy (pBits, pElements, newsize); //delete our tmp_buffer delete [] tmp_buffer; return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefString::SetCString ( ImplAAFPropertyValue * pPropVal, aafMemPtr_t pData, aafUInt32 dataSize) { if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pData) return AAFRESULT_NULL_PARAM; if (! IsRegistered ()) return AAFRESULT_NOT_REGISTERED; if (dataSize > OMPROPERTYSIZE_MAX) return AAFRESULT_BAD_SIZE; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; AAFRESULT hr; ImplAAFTypeDefSP pBaseType; hr = GetType (&pBaseType); ASSERTU (pBaseType->IsFixedSize ()); pBaseType->AttemptBuiltinRegistration (); ASSERTU (pBaseType->IsRegistered ()); // Size of individual elements aafUInt32 elemSize = pBaseType->NativeSize (); // number of elements in input data. If this is not an integral // number, this will round down and the test below will fail. aafUInt32 elemCount = dataSize / elemSize; // The size of the new property, calculated from number of elements // and the size of each element. aafUInt32 propSize = elemSize * elemCount; // If the given dataSize was not an integral multiple of the size of // each element, then we'll signal an error. if (propSize != dataSize) return AAFRESULT_BAD_SIZE; ImplAAFPropValData * pvd = 0; ASSERTU (pPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pPropVal); ASSERTU (pvd); aafMemPtr_t pBits = 0; hr = pvd->AllocateBits (propSize, &pBits); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pBits); memcpy (pBits, pData, propSize); return AAFRESULT_SUCCESS; }