// set EssenceElementKey from member variables and known consts HRESULT STDMETHODCALLTYPE CAAFEssenceDataStream::SetEssenceElementKey (// @parm [in] essence element key aafUID_constref eek, // @parm [in] essence element kind aafUInt8 eeKind, // @parm [in] essence element count aafUInt8 eeCount, // @parm [in] essence element type aafUInt8 eeType, // @parm [in] essence element index aafUInt8 eeIndex, // @parm [in] logical slot id of source slot aafSlotID_t sourceSlotID ) { plugin_trace("CAAFEssenceDataStream::SetEssenceElementKey()\n"); if (NULL == _data) return AAFRESULT_NOT_INITIALIZED; AAFRESULT hr = AAFRESULT_SUCCESS; try { hr = AAFRESULT_INTERNAL_ERROR; // SetEEK // we know how to set the EssenceElementKey on an EssenceData object // via PlainEssenceData then KLVEssenceDataParameters::SetEssenceElementKey() IAAFKLVEssenceDataParametersSP pParameters; checkResult( _data->QueryInterface(IID_IAAFKLVEssenceDataParameters, (void **)&pParameters) ); aafUID_t Peek; hr = pParameters->GetEssenceElementKey( &Peek ); // only do this is the file kind allows us to if( hr == AAFRESULT_SUCCESS ) { if( true ) // was: if( EqualAUID( &_eek, &NULL_UID ) ) { // if null passed in by caller, preset to what the file kind wants if( EqualAUID( &eek, &NULL_UID ) ) _eek = Peek; else _eek = eek; // make a GC bytes 12..16 aafUInt32 GCeeIndex = ( ( (eeKind&0xff)<<8 | (eeCount&0xff) )<<8 | (eeType&0xff) )<<8 | (eeIndex&0xff); // overwrite eek bytes 12..16 _eek.Data2 = (aafUInt16)(GCeeIndex>>16)&0xffff; _eek.Data3 = (aafUInt16)(GCeeIndex)&0xffff; // set the EssenceElementKey checkResult( pParameters->SetEssenceElementKey( _eek ) ); // set the PhysicalNum in the track of the FileSourceMob IAAFSourceMobSP pSourceMob; checkResult( _data->GetFileMob( &pSourceMob ) ); IAAFMobSP pFileMob; checkResult( pSourceMob->QueryInterface( IID_IAAFMob,(void**)&pFileMob ) ); IAAFMobSlotSP pSlot; checkResult( pFileMob->LookupSlot( 1, &pSlot ) ); checkResult( pSlot->SetPhysicalNum( GCeeIndex ) ); } else { // _eek has been initialized already // we ought to leave it alone } } else if( hr == AAFRESULT_OPERATION_NOT_PERMITTED ) // must be a file kind where eek isn't important hr = AAFRESULT_CODEC_SEMANTIC_WARN; }
void CAAFTypeDefWeakObjRef_verify (IAAFHeader * pHeader) { IAAFDictionarySP pDictionary; IAAFPropertyDefSP pWeakRefPropertyDef; checkResult (pHeader->GetDictionary (&pDictionary)); CAAFBuiltinDefs defs (pDictionary); // Determine if it is okay to ready/validate weak references from the // test file with the current version of the AAF. bool weakReferencesSupported = false; aafProductVersion_t toolkitVersion, fileToolkitVersion; checkResult(GetAAFVersions(pHeader, &toolkitVersion, &fileToolkitVersion)); if (WeakReferencesSupported(toolkitVersion) && WeakReferencesSupported(fileToolkitVersion)) { weakReferencesSupported = true; } if (weakReferencesSupported) { // // Find and validate the new weak reference. IAAFTypeDefSP pType; checkResult(pDictionary->LookupTypeDef (kAAFTypeID_TestWeakReferenceToType, &pType)); eAAFTypeCategory_t category; checkResult(pType->GetTypeCategory(&category)); checkExpression(kAAFTypeCatWeakObjRef == category, AAFRESULT_TEST_FAILED); IAAFTypeDefWeakObjRefSP pWeakReferenceType; checkResult(pType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType)); checkResult(defs.cdFiller()->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef)); // Validate the property's type checkResult(pWeakRefPropertyDef->GetTypeDef(&pType)); checkExpression(EqualObjects(pType, pWeakReferenceType), AAFRESULT_TEST_FAILED); // Use GetObjectType to make sure that the target class definitions are // the same. IAAFTypeDefObjectRefSP pObjectReferenceType; checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType)); IAAFClassDefSP pReferencedObjectClass; checkResult(pObjectReferenceType->GetObjectType(&pReferencedObjectClass)); // Find the class definition for all type definitions. IAAFClassDefSP pTypeDefClass; checkResult(pDictionary->LookupClassDef(AUID_AAFTypeDef, &pTypeDefClass)); checkExpression(EqualObjects(pReferencedObjectClass, pTypeDefClass), AAFRESULT_TEST_FAILED); // // Find our composition mob. IAAFMobSP pMob; checkResult(pHeader->LookupMob(TEST_MobID, &pMob)); IAAFMobSlotSP pSlot; checkResult(pMob->LookupSlot(TEST_SlotID, &pSlot)); IAAFSegmentSP pSegment; checkResult(pSlot->GetSegment(&pSegment)); IAAFSequenceSP pSequence; checkResult(pSegment->QueryInterface(IID_IAAFSequence, (void **)&pSequence)); aafUInt32 elementCount; checkResult(pSequence->CountComponents(&elementCount)); checkExpression(2 == elementCount, AAFRESULT_TEST_FAILED); IAAFComponentSP pComp1; checkResult(pSequence->GetComponentAt(0, &pComp1)); IAAFFillerSP pFiller1; checkResult(pComp1->QueryInterface(IID_IAAFFiller, (void **)&pFiller1)); IAAFComponentSP pComp2; checkResult(pSequence->GetComponentAt(1, &pComp2)); IAAFFillerSP pFiller2; checkResult(pComp2->QueryInterface(IID_IAAFFiller, (void **)&pFiller2)); CheckWeakReference(pFiller1, defs.tdString()); CheckWeakReference(pFiller2, defs.tdInt32()); #ifndef NO_REFERENCE_TO_MOB_TEST CheckWeakReference(pFiller1, pMob); #endif } else if (!WeakReferencesSupported(toolkitVersion)) { // This version does not support reading weak references. throw AAFRESULT_NOT_IN_CURRENT_VERSION; } }