예제 #1
0
node *CACObject :: CreateNode (char *extnames, PIACC accopt )
{
  DBExtend      *dbext;
  node          *nodeptr = NULL;
  TypeKey     tkey(GetDictionary(),extnames);
  if ( (dbext = GetDictionary()->ProvideExtendDef(tkey,GetSchemaVersion())) )
    nodeptr = CreateNode(dbext,accopt);

  return(nodeptr);
}
예제 #2
0
int _tmain(int argc, _TCHAR* argv[])
{
    IDictionary * pD = NULL;
    ET_ReturnCode rc = GetDictionary(pD);

    rc = pD->eSetDbPath(L"C:\\Users\\K\\Documents\\Personal\\Zal-Windows\\ZalData\\zal.db3");
//    rc = pD->eGetLexemesByInitialForm(L"выверт");

//    ILexeme * pL = NULL;
//    rc = pD->eGetFirstLexeme(pL);

//    rc = pL->eGenerateParadigm();

//    IWordForm * pW = NULL;
//    rc = pL->eGetFirstWordForm(pW);

//    while (H_NO_ERROR == rc)
//    {
//        rc = pL->eGetNextWordForm(pW);
//        if (H_NO_ERROR == rc)
//        {
//            CEString sWf = pW->sWordForm();
//            int i = 0;
//        }
//    }

//    CProgressCallback progress; 

    rc = pD->eGenerateAllForms();

    rc = pD->eGenerateFormsForSelectedLexemes();
 
    return 0;
}
예제 #3
0
AAFRESULT ImplAAFSegment::GenerateSequence(ImplAAFSequence **seq)
{
  ImplAAFDictionary *pDictionary = NULL;
	ImplAAFSequence	*tmp = NULL;
// ***	ImplAAFDataDef	*datakind;
				
	XPROTECT( )
	{
// ***	CHECK(GetDatakind(&datakind));
    CHECK(GetDictionary(&pDictionary));
	CHECK(pDictionary->GetBuiltinDefs()->cdSequence()->
		  CreateInstance ((ImplAAFObject**) &tmp));
    pDictionary->ReleaseReference();
    pDictionary = NULL;

		CHECK(tmp->AppendComponent(this));
		*seq = tmp;
	} /* XPROTECT */
	XEXCEPT
	{
    if (tmp)
      tmp->ReleaseReference();
	tmp = 0;
    if(pDictionary != NULL)
      pDictionary->ReleaseReference();
	pDictionary = 0;
	}
	XEND;

	return(AAFRESULT_SUCCESS);
}
예제 #4
0
TEST_FIXTURE(DictionaryCheck_TestFixture, 
             IsWordInDictionary_SuccessfulCheckWithComposedAndDecomposed)
{
    EnchantDict* dict = GetDictionary("fr_FR");
    if(dict && dict->check)
    {
        CHECK( IsWordInDictionary(dict, Convert(L"Fran\x00e7" L"ais")) ); //NFC latin small letter c with cedilla
        CHECK( IsWordInDictionary(dict, Convert(L"Franc\x0327" L"ais")) ); //NFD combining cedilla
    }
    ReleaseDictionary(dict);
}
예제 #5
0
TEST_FIXTURE(DictionarySuggest_TestFixture, 
             Suggest_HandlesNFD)
{
    EnchantDict* dict = GetDictionary("fr_FR");
    if(dict && dict->suggest)
    {
      std::vector<const std::string> suggestions = GetSuggestionsFromWord(dict, Convert(L"franc\x0327" L"ais")); //NFD combining cedilla
      CHECK(suggestions.size() != 0);
    }
    ReleaseDictionary(dict);
}
예제 #6
0
TEST_FIXTURE(DictionarySuggest_TestFixture, 
             Suggest_HandlesNFC)
{
    EnchantDict* dict = GetDictionary("fr_FR");
    if(dict && dict->suggest)
    {
      std::vector<const std::string> suggestions = GetSuggestionsFromWord(dict, Convert(L"fran\x00e7" L"ais")); //NFC latin small letter c with cedilla
      CHECK(suggestions.size() != 0);
    }
    ReleaseDictionary(dict);
}
예제 #7
0
void CustomJoint::Deserialize (NewtonBody* const body0, NewtonBody* const body1, NewtonDeserializeCallback callback, void* const userData)
{
	dCRCTYPE key;
	callback (userData, &key, sizeof (key));
	const SerializeMetaDataDictionary& dictionary = GetDictionary();

	SerializeMetaDataDictionary::dTreeNode* const node = dictionary.Find(key); 
	if (node) {
		SerializeMetaData* const meta = node->GetInfo();
		meta->DeserializeJoint (body0, body1, callback, userData);
	}
}
예제 #8
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFTypeDef::pvtGetUInt8Array8Type (
      ImplAAFTypeDef ** ppRawTypeDef)
{
  if (! ppRawTypeDef)
	return AAFRESULT_NULL_PARAM;
  
  ImplAAFDictionarySP pDict;
  AAFRESULT hr = GetDictionary(&pDict);
  if (AAFRESULT_FAILED (hr)) return hr;
  
  return pDict->LookupTypeDef (kAAFTypeID_UInt8Array, ppRawTypeDef);
}
CDictionaryBasedTempPath CDictionaryBasedTempPath::ReplaceParent
    ( const CDictionaryBasedPath& oldParent
    , const CDictionaryBasedPath& newParent) const
{
    assert (oldParent.IsSameOrParentOf (*this));

    // I admit, this is the most stupid implementation possible ;)

    std::string newPath = newParent.GetPath()
                        + GetPath().substr (oldParent.GetPath().length());

    return CDictionaryBasedTempPath (GetDictionary(), newPath);
}
예제 #10
0
void CustomJoint::Serialize (const NewtonJoint* const me, NewtonSerializeCallback callback, void* const userData)
{
	CustomJoint* const joint = (CustomJoint*) NewtonJointGetUserData (me);  

	dCRCTYPE key = joint->GetSerializeKey();
	callback (userData, &key, sizeof (key));

	const SerializeMetaDataDictionary& dictionary = GetDictionary();
	SerializeMetaDataDictionary::dTreeNode* const node = dictionary.Find(key); 
	if (node) {
		SerializeMetaData* const meta = node->GetInfo();
		meta->SerializeJoint(joint, callback, userData);
	}
}
예제 #11
0
//****************
// AddNilReference()
//
AAFRESULT STDMETHODCALLTYPE
   ImplAAFSourceMob::AddNilReference (aafSlotID_t slotID,
                           const aafLength_t & length,
                           ImplAAFDataDef * pDataDef,
                           const aafRational_t & editRate)
{
	ImplAAFSourceClip *		sub = NULL;
 	aafPosition_t	zeroPos = 0;
	aafSourceRef_t	sourceRef;
	ImplAAFTimelineMobSlot *	newSlot = NULL;		// Need version for non-timeline slots!!!
	ImplAAFDictionary *pDictionary = NULL;
	
	if (editRate.denominator == 0)
		return AAFRESULT_BADRATE;
	
	XPROTECT()
	{
		memset(&sourceRef, 0, sizeof(sourceRef));
		CHECK(GetDictionary(&pDictionary));
		CHECK(pDictionary->GetBuiltinDefs()->cdSourceClip()->
		CreateInstance ((ImplAAFObject**) &sub));
		pDictionary->ReleaseReference();
		pDictionary = NULL;
		CHECK(sub->Initialize (pDataDef, length, sourceRef));
		CHECK(AppendNewTimelineSlot(editRate, sub, slotID, L"Test", zeroPos, 
												&newSlot));
		newSlot->ReleaseReference();
		newSlot = 0;
		sub->ReleaseReference();
		sub = 0;
	}
	XEXCEPT
	{
		if(sub != NULL)
		  sub->ReleaseReference();
		sub = 0;
		if(newSlot != NULL)
		  newSlot->ReleaseReference();
		newSlot = 0;
		if(pDictionary != NULL)
		  pDictionary->ReleaseReference();
		pDictionary = 0;
	}
	XEND;

	return(AAFRESULT_SUCCESS);
}
void CDictionaryBasedTempPath::RepeatLookup()
{
    // optimization

    if (relPathElements.empty())
        return;

    // some preparation ...

    const CPathDictionary* dict = GetDictionary();
    index_t currentIndex = GetIndex();

    typedef std::vector<std::string>::iterator IT;
    IT begin = relPathElements.begin();

    // try to match the relative path elements with cached paths, step by step

    for (IT iter = begin, end = relPathElements.end(); iter != end; ++iter)
    {
        index_t nextIndex = dict->Find (currentIndex, iter->c_str());
        if (nextIndex == NO_INDEX)
        {
            // new dictionary-based path info ends here.
            // update internal data, if we made any progress

            if (iter != begin)
            {
                assert (currentIndex != nextIndex);

                relPathElements.erase (begin, iter);
                SetIndex (currentIndex);
            }
            return;
        }
        else
            currentIndex = nextIndex;
    }

    // cool. a full match

    if (GetIndex() != currentIndex)
    {
        relPathElements.clear();
        SetIndex (currentIndex);
    }
}
예제 #13
0
//****************
// AddStaticNilReference()
//
AAFRESULT STDMETHODCALLTYPE
   ImplAAFSourceMob::AddStaticNilReference (
						aafSlotID_t slotID,
						ImplAAFDataDef * pDataDef)
{
	ImplAAFSourceClip *		sub = NULL;
	aafSourceRef_t	sourceRef;
	ImplAAFStaticMobSlot *	newSlot = NULL;		
	ImplAAFDictionary *pDictionary = NULL;

	
	XPROTECT()
	{
		memset(&sourceRef, 0, sizeof(sourceRef));

		CHECK(GetDictionary(&pDictionary));
		CHECK(pDictionary->GetBuiltinDefs()->cdSourceClip()->
			  CreateInstance ((ImplAAFObject**) &sub));
		pDictionary->ReleaseReference();
		pDictionary = NULL;

		CHECK(sub->Initialize (pDataDef, 0, sourceRef));
		CHECK(AppendNewStaticSlot( sub, slotID, L"Static", 	&newSlot));
		
		newSlot->ReleaseReference();
		newSlot = NULL;
		sub->ReleaseReference();
		sub = NULL;
	}
	XEXCEPT
	{
		if(sub != NULL)
		  sub->ReleaseReference();
		sub = NULL;
		if(newSlot != NULL)
		  newSlot->ReleaseReference();
		newSlot = NULL;
		if(pDictionary != NULL)
		  pDictionary->ReleaseReference();
		pDictionary = NULL;
	}
	XEND;

	return(AAFRESULT_SUCCESS);
}
예제 #14
0
    bool DictionaryValue::Remove(const std::string& path, Value** out_value)
    {
        DCHECK(IsStringUTF8(path));
        std::string current_path(path);
        DictionaryValue* current_dictionary = this;
        size_t delimiter_position = current_path.rfind('.');
        if(delimiter_position != std::string::npos)
        {
            if(!GetDictionary(current_path.substr(0, delimiter_position),
                &current_dictionary))
            {
                return false;
            }
            current_path.erase(0, delimiter_position + 1);
        }

        return current_dictionary->RemoveWithoutPathExpansion(current_path,
            out_value);
    }
logical pc_typ_collection :: SetupCollectionByTyp ( )
{
  PropertyHandle   *typ   = GPH("typ");
  int32             value = 0;
  int32             indx0 = 0;
  logical           term  = NO;
BEGINSEQ
  if ( !typ )                                       ERROR

  PropertyHandle   typs(GetDictionary(),typ->GetType(),PI_Read);
                                                    SDBCERR
  while ( typs.Get(indx0++) )
    if ( value = typs.GetInt("code") ) 
      Provide(Key((char *)&value));
RECOVER
  term = YES;
ENDSEQ
  return(term);
}
예제 #16
0
파일: pathid.cpp 프로젝트: Just4F/behaviac
	void CPathID::SetContentPrivate(const char* content)
	{
		if (content == NULL || content[0] == '\0')
		{
			m_value = InvalidID;
#if STRINGID_USESTRINGCONTENT
			m_content = NULL;
#endif

		}
		else
		{
			m_value = CRC32::CalcCRCNoCase(content);
		}

#if STRINGID_USESTRINGCONTENT
		behaviac::Mutex s_cs;
		behaviac::ScopedLock lock(s_cs);
		StringIdDictionary& dictionary = GetDictionary();
		StringIdDictionary::iterator it = dictionary.find(m_value);

		if (it != dictionary.end())
		{
			if (string_icmp(content, (*it).second))
			{
				BEHAVIAC_ASSERT(0, "There is a conflict between two PathID for the CRC 0x%08X.\n%s\n%s\n\nThe result of that is unpredictable but will probably crash.", m_value, content, (*it).second);
			}

			m_content = (*it).second;

		}
		else
		{
			uint32_t len = strlen(content);
			char* str = (char*)BEHAVIAC_MALLOC_WITHTAG(len + 1, "PathID");
			string_cpy(str, content);
			dictionary[m_value] = str;
			m_content = str;
		}

#endif
	}
예제 #17
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFKLVData::SetValue (aafUInt32 valueSize, aafDataBuffer_t pValue)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
	ImplAAFTypeDef		*pDef = NULL;
	ImplAAFDictionary	*pDict = NULL;
	aafUID_t			keyUID;

	if (!pValue)
		return AAFRESULT_NULL_PARAM;
	
	if (valueSize > OMPROPERTYSIZE_MAX)
		return AAFRESULT_BAD_SIZE;

	if (!_cachedRenameTypeDef)
	{
		// Lookup the type definition from this KLV data. If it fails
		// then the control point is invalid!
		result = GetKey(&keyUID);
    if (AAFRESULT_FAILED(result))
      return result;

    result = GetDictionary(&pDict);
    if (AAFRESULT_FAILED(result))
      return result;

    result = pDict->LookupTypeDef(keyUID, &pDef);
		pDict->ReleaseReference();
		pDict = 0;
    if (AAFRESULT_FAILED(result))
      return result;
    pDef->ReleaseReference(); // This object is owned by the dictionary!

    _cachedRenameTypeDef = dynamic_cast<ImplAAFTypeDefRename*>(pDef);
    if (NULL == _cachedRenameTypeDef)
      return AAFRESULT_INVALID_OBJ;
	}
	
	// Validate the property and get the property definition and type definition, 
	// and the actual length of the data
	return (ImplAAFTypeDefIndirect::SetActualPropertyValue (_value, _cachedRenameTypeDef, pValue, valueSize));
}
예제 #18
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFKLVData::Initialize (
      aafUID_t keyUID, 
      aafUInt32 valueSize, 
      aafDataBuffer_t pValue)
{
	ImplAAFDictionary		*pDict = NULL;
	ImplAAFTypeDef			*pDef = NULL;
	if (!pValue)
		return AAFRESULT_NULL_PARAM;
	if (_initialized)
		return AAFRESULT_ALREADY_INITIALIZED;
	
	XPROTECT()
	{
	// Save the type so that SetValue will know the type of the value data.
		CHECK(GetDictionary(&pDict));
		CHECK(pDict->LookupOpaqueTypeDef(keyUID, &pDef));
    pDef->ReleaseReference(); // This object is owned by the dictionary!

    _cachedRenameTypeDef = dynamic_cast<ImplAAFTypeDefRename*>(pDef);
		ASSERTU(_cachedRenameTypeDef);
    if (NULL == _cachedRenameTypeDef)
      RAISE(AAFRESULT_INVALID_OBJ);

		CHECK(SetValue (valueSize, pValue));
		_initialized = true;
		if(pDict)
		  pDict->ReleaseReference();
		pDict = 0;
	}
	XEXCEPT
	{
		if(pDict)
		  pDict->ReleaseReference();
		pDict = 0;
	}
	XEND
	
	
	return AAFRESULT_SUCCESS;
}
예제 #19
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFPropertyDef::GetTypeDef (
      ImplAAFTypeDef ** ppTypeDef) const
{
  if (! ppTypeDef) return AAFRESULT_NULL_PARAM;

  if (! _cachedType)
	{
	  ImplAAFDictionarySP pDict;
	  AAFRESULT hr;

	  hr = GetDictionary(&pDict);
	  if (AAFRESULT_FAILED (hr)) return hr;
	  ASSERTU (pDict);

	  ImplAAFPropertyDef * pNonConstThis =
		  (ImplAAFPropertyDef *) this;
	  aafUID_t typeId = _Type;

	  ImplAAFTypeDef * tmp = 0;
	  hr = pDict->LookupTypeDef (typeId, &tmp);
	  if (AAFRESULT_FAILED (hr))
		return hr;
	  ASSERTU (tmp);
	  if (!_cachedType) {
		pNonConstThis->_cachedType = tmp;
		_cachedType->AcquireReference();
	  }
	  // If lookup caused this to already be put into the cache, just
	  // throw away the current copy (in tmp)
	  tmp->ReleaseReference ();
	  tmp = 0;
	}
  ASSERTU (ppTypeDef);
  *ppTypeDef = _cachedType;
  ASSERTU (*ppTypeDef);
  (*ppTypeDef)->AcquireReference ();

  return AAFRESULT_SUCCESS;
}
예제 #20
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;
	}
}
예제 #21
0
int COMPRESSION_METHOD::server()
{
  char *service = p._str("service");

  // Global services
  if (strequ (service, "register"))               return FREEARC_OK; //to do: Register();

  // Invocation-specific services
  if (strequ (service, "decompress"))             {parse_method(); return decompress (p._callback("callback"), p);}
#ifndef FREEARC_DECOMPRESS_ONLY
  if (strequ (service, "compress"))               {parse_method(); return compress   (p._callback("callback"), p);}
  if (strequ (service, "canonize"))               {parse_method();                                     char a[1000]; ShowCompressionMethod(a); return p._return(a);}
  if (strequ (service, "SetCompressionMem"))      {parse_method(); SetCompressionMem  (p._int("mem")); char a[1000]; ShowCompressionMethod(a); return p._return(a);}
  if (strequ (service, "SetDictionary"))          {parse_method(); SetDictionary      (p._int("mem")); char a[1000]; ShowCompressionMethod(a); return p._return(a);}
  if (strequ (service, "SetBlockSize"))           {parse_method(); SetBlockSize       (p._int("mem")); char a[1000]; ShowCompressionMethod(a); return p._return(a);}
  if (strequ (service, "SetDecompressionMem"))    {parse_method(); SetDecompressionMem(p._int("mem")); char a[1000]; ShowCompressionMethod(a); return p._return(a);}
  if (strequ (service, "GetCompressionMem"))      {parse_method(); return p._return (GetCompressionMem());}
  if (strequ (service, "GetDictionary"))          {parse_method(); return p._return (GetDictionary());}
  if (strequ (service, "GetBlockSize"))           {parse_method(); return p._return (GetBlockSize());}
#endif
  if (strequ (service, "GetDecompressionMem"))    {parse_method(); return p._return (GetDecompressionMem());}

  return FREEARC_ERRCODE_NOT_IMPLEMENTED;
}
예제 #22
0
AAFRESULT STDMETHODCALLTYPE
   ImplAAFSourceMob::AppendTimecodeSlot (aafRational_t editrate,
                           aafInt32 slotID,
						   aafTimecode_t startTC,
                           aafFrameLength_t length64)
{
	
	ImplAAFTimecodeSP tccp;
	ImplAAFSequenceSP aSequ;
	aafFrameLength_t maxLength;
	aafPosition_t	zeroPos;
	aafLength_t		length;
	ImplAAFTimelineMobSlotSP	newSlot, mobSlot;
	aafBool			fullLength = kAAFFalse;
	ImplAAFDictionarySP pDictionary;

	//!!!Validate tape mobs only, return AAFRESULT_TAPE_DESC_ONLY
	if(length64 == FULL_LENGTH)
	  {
		 fullLength = kAAFTrue;
		 length64 = 1;
	  }
	else
	  fullLength = kAAFFalse;
	
	zeroPos = 0;
 	length = length64;

	XPROTECT()
	{
		CHECK(GetDictionary(&pDictionary));
		CHECK(pDictionary->GetBuiltinDefs()->cdTimecode()->
			  CreateInstance ((ImplAAFObject**) &tccp));
		tccp->Initialize(length, &startTC);	

			CHECK(pDictionary->GetBuiltinDefs()->cdSequence()->
				  CreateInstance((ImplAAFObject**) &aSequ));
			CHECK(aSequ->Initialize(pDictionary->
									GetBuiltinDefs()->
									ddTimecode()));

			 
			CHECK(aSequ->AppendComponent(tccp));

 		if (FindSlotBySlotID(slotID, (ImplAAFMobSlot **)&mobSlot)
			== AAFRESULT_SUCCESS)
		{
			CHECK(mobSlot->SetSegment(aSequ));

		} /* FindTimecodeSlot */
		else
		{
			CHECK(AppendNewTimelineSlot(editrate, aSequ, slotID,
										L"Timecode", zeroPos, &newSlot));
		}

		if(fullLength)
		{
			CHECK(PvtTimecodeToOffset(startTC.fps, 24, 0, 0, 0, 
											 startTC.drop, &maxLength));
			{
				length = maxLength;
				CHECK(tccp->SetLength(length) );
				/* NOTE: What if the sequence already existed? */
				CHECK(aSequ->SetLength(length) );
			}
		}

	} /* XPROTECT */
	XEXCEPT
	{
		
	}
	XEND;
									
	return (AAFRESULT_SUCCESS);
}
예제 #23
0
//****************
// AddPulldownRef()
//
AAFRESULT STDMETHODCALLTYPE
    ImplAAFSourceMob::AddPulldownRef (aafAppendOption_t  /* addType !!!*/,
									  const aafRational_t & editrate,
									  aafSlotID_t  aMobSlot,
									  ImplAAFDataDef * pEssenceKind,
									  aafSourceRef_t  ref,
									  aafLength_t  srcRefLength,
									  aafPulldownKind_t  pulldownKind,
									  aafPhaseFrame_t  phaseFrame,
									  aafPulldownDir_t  direction)
{
	ImplAAFSourceClip	*sclp = NULL;
	ImplAAFTimelineMobSlot		*trkd = NULL;
	aafPosition_t		zeroPos;
	aafSlotID_t 		tmpSlotID;
	ImplAAFMobSlot *	slot = NULL;
	aafBool 			isOneToOne;
	ImplAAFPulldown 	*pdwn = NULL;
	ImplAAFSequence *	sequence = NULL;
	ImplAAFDictionary*	dict = NULL;
	aafLength_t 		outLength, zero;
	aafInt32 			patternLen;
	AAFRESULT			status = AAFRESULT_SUCCESS;
	aafUInt32 			mask;
		
	if (! pEssenceKind)
	  return AAFRESULT_NULL_PARAM;

	XPROTECT()
	{
		GetDictionary(&dict);
		zero = 0;
		XASSERT(direction == kAAFFilmToTapeSpeed || direction == kAAFTapeToFilmSpeed,
				AAFRESULT_PULLDOWN_DIRECTION);

		zeroPos = 0;
		{
			CHECK(dict->GetBuiltinDefs()->cdPulldown()->
				  CreateInstance((ImplAAFObject **)&pdwn));
			CHECK(pdwn->SetDataDef(pEssenceKind));
			CHECK(pdwn->SetPulldownKind(pulldownKind));
			CHECK(pdwn->SetPhaseFrame(phaseFrame));
			CHECK(pdwn->SetPulldownDirection(direction));
			CHECK(pdwn->aafPvtGetPulldownMask(pulldownKind,
										&mask,  &patternLen, &isOneToOne));

			if(isOneToOne)
			{
				CHECK(pdwn->SetLength(srcRefLength));
			}
			else
			{
				/* Remember, this routine is given the OUTPUT length, and must determine
				 * the input length (so the ratios look backwards)
				 */
				CHECK(pdwn->MapOffset(srcRefLength, kAAFTrue, &outLength, NULL));
				CHECK(pdwn->SetLength(outLength));
			}
		}
			
		/* If the slot exists, and there is a SCLP, extract it so that it can be appended
		 * to the mask or pullown object later
		 */
		status = FindSlotBySlotID(aMobSlot, &slot);
		if (status == AAFRESULT_SUCCESS)
		{
			ImplAAFSegment *seg;
			
			CHECK(slot->GetSlotID(&tmpSlotID));
			CHECK(slot->GetSegment(&seg));
			sequence = dynamic_cast<ImplAAFSequence*>(seg);
			if(sequence != NULL)
			{
				aafLength_t			foundLen;
				aafUInt32			numSegments;
				aafUInt32			n;
				ImplAAFComponent 	*subSeg;
				
				CHECK(sequence->CountComponents(&numSegments));
				if(numSegments == 0)
				{
					CHECK(sequence->AppendComponent(pdwn));
					CHECK(dict->GetBuiltinDefs()->cdSourceClip()->
						  CreateInstance((ImplAAFObject **)&sclp));
					CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref));
				}
				for(n = 0; n < numSegments; n++)
				{
					CHECK(sequence->GetNthComponent (0, &subSeg));
					CHECK(subSeg->GetLength(&foundLen));

					if(foundLen != zero)
					{
						CHECK(sequence->SetNthComponent(n, pdwn));
						sclp = dynamic_cast<ImplAAFSourceClip*>(subSeg);
						break;
					}
					subSeg->ReleaseReference();
					subSeg = NULL;
				}
			}
			else
			{
				CHECK(slot->SetSegment(pdwn));
				sclp = dynamic_cast<ImplAAFSourceClip*>(seg);
			}
			
			XASSERT(sclp != NULL, AAFRESULT_NOT_SOURCE_CLIP);
			CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref));
		}
		else
		{
			CHECK(dict->GetBuiltinDefs()->cdSourceClip()->
				  CreateInstance((ImplAAFObject **)&sclp));
			CHECK(sclp->Initialize(pEssenceKind, srcRefLength, ref));
			CHECK(AppendNewTimelineSlot(editrate, pdwn,
								aMobSlot, NULL, zeroPos, &trkd) );
		}

		/* Patch the MASK into the file mob if this is a Film Editrate */
		/* NOTE: This is assuming that there is a source clip on
		 * the file mob - if it is a nested structure (i.e., SEQU),
		 * this code is not patching the nested elements with the new
		 * editrate and length.
		 */
		{
			if(pdwn != NULL)
			{
				CHECK(pdwn->SetInputSegment(sclp));
			}
		}
		dict->ReleaseReference();
		dict = NULL;
	} /* XPROTECT */
	XEXCEPT
	{
		if(dict)
		  dict->ReleaseReference();
		dict = 0;
	}
	XEND;

	return (AAFRESULT_SUCCESS);
}
예제 #24
0
//****************
// ValidateTimecodeRange()
//
AAFRESULT STDMETHODCALLTYPE
    ImplAAFSourceMob::SpecifyValidCodeRange (ImplAAFDataDef * /* pEssenceKind !!!*/,
                           aafSlotID_t  slotID,
                           aafRational_t  editrate,
                           aafFrameOffset_t  startOffset,
                           aafFrameLength_t  length64)
{
	ImplAAFSourceClip		*sclp = NULL;
	ImplAAFTimecode			*timecodeClip = NULL;
	ImplAAFSequence *		aSequ = NULL, *segSequ = NULL;
	ImplAAFFiller *			filler1 = NULL, *filler2 = NULL;
	ImplAAFSegment *		seg = NULL;
	ImplAAFComponent *		subSegment = NULL;
	ImplAAFDictionary *		pDict = NULL;
	aafPosition_t			pos, zeroPos, sequPos, begPos, endPos;
	aafLength_t				length, zeroLen, tcLen, endFillLen, firstFillLen, oldFillLen, segLen;
	aafLength_t				tcSlotLen, sequLen;
  	aafSourceRef_t			sourceRef;
	ImplAAFTimelineMobSlot	*newSlot, *slot;
  	aafFrameOffset_t		tcStartPos;
  	aafTimecode_t			timecode;
  	aafUInt32				sequLoop;
	aafUInt32				numSegs;
    ImplEnumAAFComponents	*sequIter = NULL;

	XPROTECT()
	{
		CHECK(FindTimecodeClip(startOffset, &timecodeClip, &tcStartPos,
								&tcSlotLen));
		CHECK(timecodeClip->GetLength(&tcLen));
		CHECK(timecodeClip->GetTimecode(&timecode));
		if(length64 == FULL_LENGTH)
		{
			CHECK(PvtTimecodeToOffset(timecode.fps, 24, 0, 0, 0,
			  						timecode.drop, &length64));
		}
		length = length64;
		zeroLen = 0;
		
		pos = startOffset;
		zeroPos = 0;
		endFillLen = tcSlotLen;
		endFillLen -= pos;
		endFillLen -= length;
		memset(&sourceRef, 0, sizeof(sourceRef));
		CHECK(GetDictionary(&pDict));
		CHECK(pDict->GetBuiltinDefs()->cdSourceClip()->
			  CreateInstance((ImplAAFObject **)&sclp));

		if(FindSlotBySlotID(slotID, (ImplAAFMobSlot **)&slot) != AAFRESULT_SUCCESS)
		{
			CHECK(pDict->GetBuiltinDefs()->cdSequence()->
				  CreateInstance((ImplAAFObject **)&aSequ));
			CHECK(pDict->GetBuiltinDefs()->cdFiller()->
				  CreateInstance((ImplAAFObject **)&filler1));
			if(aSequ == NULL || filler1 == NULL)
				RAISE(E_FAIL);
			CHECK(aSequ->AppendComponent(filler1));
			CHECK(aSequ->AppendComponent(sclp));
			CHECK(pDict->GetBuiltinDefs()->cdFiller()->
				  CreateInstance((ImplAAFObject **)&filler2));
			CHECK(aSequ->AppendComponent(filler2));

			/* (SPR#343) Change to validate multiple ranges */
			CHECK(AppendNewTimelineSlot(editrate, aSequ, slotID,
												NULL, zeroPos, &newSlot));
		}
	  else
	  	{
			CHECK(slot->GetSegment(&seg));
			CHECK(seg->GenerateSequence(&segSequ));
  			CHECK(segSequ->GetComponents(&sequIter));
  			CHECK(segSequ->CountComponents(&numSegs));
			for (sequLoop=0, sequPos = 0; sequLoop < numSegs; sequLoop++, sequPos += segLen)
			{
				CHECK(sequIter->NextOne(&subSegment));
				CHECK(subSegment->GetLength(&segLen));
				/* Skip zero-length clips, sometimes found in MC files */
				if (segLen == zeroLen)
					continue;
				begPos = sequPos;
				endPos = sequPos + segLen;
				if (pos < endPos &&
					begPos <= pos)
				{
					ImplAAFFiller	*test;		// Used only in test of type
					test = dynamic_cast<ImplAAFFiller*>(subSegment);
					if(test != NULL && (sequLoop == (numSegs-1)))
		 			{
						firstFillLen = pos;
						firstFillLen -= sequPos;
						CHECK(subSegment->GetLength(&oldFillLen));
						endFillLen = oldFillLen;
						endFillLen -= length;
						endFillLen -= firstFillLen;
						/****/
						CHECK(subSegment->SetLength(firstFillLen));
						/* 1.x does not have a Sequence Length property */
						CHECK(segSequ->GetLength(&sequLen));
						sequLen -= oldFillLen;
						sequLen += firstFillLen;
						CHECK(segSequ->SetLength(sequLen));

						CHECK(pDict->GetBuiltinDefs()->cdFiller()->
							  CreateInstance((ImplAAFObject **)&filler2));
//!!!						filler2 = CreateImpl(CLSID_AAFFiller(_file, mediaKind, endFillLen);	
						CHECK(segSequ->AppendComponent(sclp));
						CHECK(segSequ->AppendComponent(filler2));
						break;
					}
					else
						RAISE(AAFRESULT_NOT_IN_CURRENT_VERSION);
				}
			} /* for */
			sequIter->ReleaseReference();
			sequIter = NULL;
			
//!!!			/* Release reference, so the useCount is decremented */
//			if (subSegment)
//			  {
//				 subSegment->ReleaseObject();	
//				 subSegment = NULL;
//			  }
		}
		if(aSequ!= NULL)
		{
			aSequ->ReleaseReference();
			aSequ = NULL;
		}
		if(segSequ!= NULL)
		{
			segSequ->ReleaseReference();
			segSequ = NULL;
		}
		if(filler1!= NULL)
		{
			filler1->ReleaseReference();
			filler1 = NULL;
		}
		if(filler2!= NULL)
		{
			filler2->ReleaseReference();
			filler2 = NULL;
		}
		if(seg!= NULL)
		{
			seg->ReleaseReference();
			seg = NULL;
		}
		if(subSegment!= NULL)
		{
			subSegment->ReleaseReference();
			subSegment = NULL;
		}
		if(pDict!= NULL)
		{
			pDict->ReleaseReference();
			pDict = NULL;
		}
		if(sclp!= NULL)
		{
			sclp->ReleaseReference();
			sclp = NULL;
		}
		if(timecodeClip!= NULL)
		{
			timecodeClip->ReleaseReference();
			timecodeClip = NULL;
		}
	}
	XEXCEPT
	{
		if(aSequ!= NULL)
		  aSequ->ReleaseReference();
		aSequ = 0;
		if(segSequ!= NULL)
		  segSequ->ReleaseReference();
		segSequ = 0;
		if(filler1!= NULL)
		  filler1->ReleaseReference();
		filler1 = 0;
		if(filler2!= NULL)
		  filler2->ReleaseReference();
		filler2 = 0;
		if(seg!= NULL)
		  seg->ReleaseReference();
		seg = 0;
		if(subSegment!= NULL)
		  subSegment->ReleaseReference();
		subSegment = 0;
		if(pDict!= NULL)
		  pDict->ReleaseReference();
		pDict = 0;
		if(sclp!= NULL)
		  sclp->ReleaseReference();
		sclp = 0;
		if(timecodeClip!= NULL)
		  timecodeClip->ReleaseReference();
		timecodeClip = 0;
	}
	XEND;

	return (AAFRESULT_SUCCESS);
}
예제 #25
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFSourceMob::AppendEdgecodeSlot (aafRational_t  editrate,
                           aafInt32  slotID,
                          aafFrameOffset_t  startEC,
                           aafFrameLength_t  length64,
                           aafFilmType_t  filmKind,
                           aafEdgeType_t  codeFormat,
                           aafEdgecodeHeader_t  header)
{
	ImplAAFSequenceSP ecSequence;
	ImplAAFEdgecodeSP edgecodeClip;
	aafPosition_t	startPos, zeroPos;
	aafLength_t		length, zeroLen;
	ImplAAFTimelineMobSlotSP newSlot, mobSlot;
	aafEdgecode_t	edge;
	ImplAAFDictionarySP pDictionary;

	// Validate film mobs only, return AAFRESULT_FILM_DESC_ONLY
	zeroPos = 0;
	zeroLen = 0;
	XPROTECT()
	{
		CHECK(GetDictionary(&pDictionary));

		CHECK(pDictionary->GetBuiltinDefs()->cdSequence()->
			  CreateInstance ((ImplAAFObject**) &ecSequence));
		CHECK(ecSequence->Initialize(pDictionary->
									 GetBuiltinDefs()->
									 ddEdgecode()));	

		length = length64;
		startPos = startEC;
		edge.startFrame = startPos;
		edge.filmKind = filmKind;
		edge.codeFormat = codeFormat;
		strncpy((char *)edge.header, (char *)header, 8);
		
		CHECK(pDictionary->GetBuiltinDefs()->cdEdgecode()->
			  CreateInstance ((ImplAAFObject**) &edgecodeClip));
		CHECK(edgecodeClip->Initialize(length, edge));	
		
		
		CHECK(ecSequence->AppendComponent(edgecodeClip));
		

		if (FindSlotBySlotID(slotID, (ImplAAFMobSlot **)&mobSlot)
			== AAFRESULT_SUCCESS)
		{
			CHECK(mobSlot->SetSegment(ecSequence));
		}
		else
		{
		CHECK(AppendNewTimelineSlot(editrate, ecSequence, slotID,
									L"Edgecode", zeroPos, &newSlot));
		}

	} /* XPROTECT */
	XEXCEPT
	{
		
	}
	XEND;

	return (AAFRESULT_SUCCESS);
}