コード例 #1
0
ファイル: ImplAAFSelector.cpp プロジェクト: mcanthony/aaf
AAFRESULT ImplAAFSelector::ChangeContainedReferences(aafMobID_constref from,
													aafMobID_constref to)
{
	aafInt32			n, count;
	ImplAAFSegment		*seg = NULL;
	ImplAAFComponent	*selected;
	
	XPROTECT()
	{
		CHECK(GetNumAlternateSegments (&count));
		for(n = 0; n < count; n++)
		{
			CHECK(GetNthSegment (n, &seg));
			CHECK(seg->ChangeContainedReferences(from, to));
			seg->ReleaseReference();
			seg = NULL;
		}

		selected = _selected;
		if(selected != NULL)
		{
			CHECK(selected->ChangeContainedReferences(from, to));
		}
	}
	XEXCEPT
	{
		if(seg != NULL)
		  seg->ReleaseReference();
		seg = 0;
	}
	XEND;

	return AAFRESULT_SUCCESS;
}
コード例 #2
0
ファイル: ImplAAFSelector.cpp プロジェクト: mcanthony/aaf
AAFRESULT STDMETHODCALLTYPE
    ImplAAFSelector::SetSelectedSegment (ImplAAFSegment* pSelSegment)
{
	ImplAAFSegment*		pPrevSelected = NULL;

	if (pSelSegment == NULL)
		return AAFRESULT_NULL_PARAM;

	pPrevSelected = _selected;
	if (pPrevSelected)
	{
	  if( pPrevSelected == pSelSegment )
		return AAFRESULT_SUCCESS;

	  pPrevSelected->ReleaseReference();
	  pPrevSelected = 0;
	}

	if (pSelSegment->attached())
		return AAFRESULT_OBJECT_ALREADY_ATTACHED;

	_selected = pSelSegment;
	_selected->AcquireReference();


	return AAFRESULT_SUCCESS;
}
コード例 #3
0
ファイル: ImplAAFSelector.cpp プロジェクト: mcanthony/aaf
//***********************************************************
//
// GetNthSegment()
//
// Get the component at the position specified by index from
// the components vector.  This is used by the ImplEnumAAFSegments
// to retrieve the components from the sequence.
//
// NOTES:
//
//    - The vector is 0-based.
//    - AddRef the object being returned.
// 
AAFRESULT
    ImplAAFSelector::GetNthSegment (aafUInt32 index, ImplAAFSegment** ppSegment)
{
	ImplAAFSegment*	obj;
	HRESULT			hr;

	size_t numSegments = _alternates.count();
	if (index < numSegments)
	{
		_alternates.getValueAt(obj, index);
		obj->AcquireReference();
		*ppSegment = obj;
		hr =  AAFRESULT_SUCCESS;
	}
	else
		hr = AAFRESULT_NO_MORE_OBJECTS;

	return hr;
}
コード例 #4
0
ファイル: ImplAAFSelector.cpp プロジェクト: mcanthony/aaf
ImplAAFSelector::~ImplAAFSelector ()
{
	ImplAAFSegment *selected = _selected.clearValue();
	if (selected != NULL)
	{
	  selected->ReleaseReference();
	  selected = 0;
	}

	aafUInt32 count = _alternates.count();
	for (aafUInt32 i = 0; i < count; i++)
	{
		ImplAAFSegment* pSegment = _alternates.clearValueAt(i);
		if (pSegment)
		{
		  pSegment->ReleaseReference();
		  pSegment = 0;
		}
	}
}
コード例 #5
0
ファイル: ImplAAFSelector.cpp プロジェクト: mcanthony/aaf
void ImplAAFSelector::Accept(AAFComponentVisitor& visitor)
{
	ASSERTU(_selected);
	_selected->Accept(visitor);

	aafInt32 count = 0;
	GetNumAlternateSegments(&count);
	for(aafInt32 i=0; i<count; i++)
	{
		ImplAAFSegment* pSegment = 0;
		GetNthSegment(i, &pSegment);

       	        pSegment->Accept(visitor);

		pSegment->ReleaseReference();
		pSegment = NULL;
	}

	// TODO
	// visitor.VisitSelector(this);
}
コード例 #6
0
ファイル: CAAFSelector.cpp プロジェクト: UIKit0/aaf
HRESULT STDMETHODCALLTYPE
    CAAFSelector::GetSelectedSegment (IAAFSegment ** ppSelSegment)
{
  HRESULT hr;

  ImplAAFSelector * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFSelector*> (pO);
  assert (ptr);

  //
  // set up for ppSelSegment
  //
  ImplAAFSegment * internalppSelSegment = NULL;
  ImplAAFSegment ** pinternalppSelSegment = NULL;
  if (ppSelSegment)
    {
      pinternalppSelSegment = &internalppSelSegment;
    }

  try
    {
      hr = ptr->GetSelectedSegment
       (pinternalppSelSegment);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // cleanup for ppSelSegment
  //
  if (SUCCEEDED(hr))
    {
      IUnknown *pUnknown;
      HRESULT hStat;

      if (internalppSelSegment)
        {
          pUnknown = static_cast<IUnknown *> (internalppSelSegment->GetContainer());
          hStat = pUnknown->QueryInterface(IID_IAAFSegment, (void **)ppSelSegment);
          assert (SUCCEEDED (hStat));
          //pUnknown->Release();
          internalppSelSegment->ReleaseReference(); // We are through with this pointer.
        }
    }
  return hr;
}
コード例 #7
0
ファイル: ImplAAFSourceMob.cpp プロジェクト: mcanthony/aaf
/************************
 * Function: omfsReconcileMobLength (INTERNAL)
 *
 * 	Given a master mob or file mob, make sure that all fields
 *		which contain the length of the mob are in agreement.  Currently
 *		only makes sure that mob length references are >= each of
 *		the track lengths.
 *
 * Argument Notes:
 *		<none>.
 *
 * ReturnValue:
 *		Error code (see below).
 *
 * Possible Errors:
 *		Standard errors (see top of file).
 */
AAFRESULT ImplAAFSourceMob::ReconcileMobLength(void)
{
	aafNumSlots_t				numSlots;
	aafUInt32					loop;
	aafLength_t					len;
	ImplAAFMobSlot				*slot = NULL;
	ImplAAFTimelineMobSlot		*timelineSlot = NULL;
	ImplAAFSegment				*seg = NULL;
	ImplEnumAAFMobSlots			*slotIter = NULL;
	aafRational_t				srcRate, destRate;
	ImplAAFEssenceDescriptor	*edesc = NULL;
	ImplAAFFileDescriptor		*physMedia = NULL;
		
	XPROTECT()
	{
		CHECK(GetEssenceDescriptor(&edesc));
		physMedia = dynamic_cast<ImplAAFFileDescriptor*>(edesc);
		if(physMedia != NULL)
		{
			CHECK(GetSlots (&slotIter));
			CHECK(CountSlots(&numSlots));
			for (loop = 1; loop <= numSlots; loop++)
			{
				CHECK(slotIter->NextOne((ImplAAFMobSlot **)&slot));
				timelineSlot = dynamic_cast<ImplAAFTimelineMobSlot*>(slot);
				if(timelineSlot != NULL)
				{
					CHECK(timelineSlot->GetSegment(&seg));
					CHECK(timelineSlot->GetEditRate(&destRate));
					timelineSlot->ReleaseReference();
					timelineSlot = NULL;
					CHECK(physMedia->GetLength(&len));
					CHECK(physMedia->GetSampleRate(&srcRate));

					
					if((srcRate.numerator != destRate.numerator) ||
						(srcRate.denominator != destRate.denominator))
					{
						CHECK(AAFConvertEditRate(	srcRate, len, destRate, kRoundFloor, &len));
					}
					CHECK(seg->SetLength(len));
					seg->ReleaseReference();
					seg = NULL;
				}
				else
				{
					slot->ReleaseReference();
					slot = NULL;
				}
			}
			physMedia->ReleaseReference();
			physMedia = NULL;			
			slotIter->ReleaseReference();
			slotIter = NULL;
		}
	}
	XEXCEPT
	{
		if (slot)
		  slot->ReleaseReference();
		slot = 0;
		if (timelineSlot)
		  timelineSlot->ReleaseReference();
		timelineSlot = 0;
		if (physMedia)
		  physMedia->ReleaseReference();
		physMedia = 0;
		if (seg)
		  seg->ReleaseReference();
		seg = 0;
		if (slotIter)
		  slotIter->ReleaseReference();
		slotIter = 0;
	}
	XEND
		
	return (AAFRESULT_SUCCESS);
}
コード例 #8
0
ファイル: ImplAAFSourceMob.cpp プロジェクト: mcanthony/aaf
//************************
// Function:  FindTimecodeClip	(INTERNAL)
// Finds the primary timecode track.  This will have a physical slot # of 0 (missing) or 1.
//
AAFRESULT ImplAAFSourceMob::FindTimecodeClip(
				aafFrameOffset_t	position,
				ImplAAFTimecode 		**result,
				aafFrameOffset_t	*tcStartPos,
				aafLength_t			*tcSlotLen)
{
	ImplAAFSegment *		seg = NULL;
	aafPosition_t			offset;
	aafPosition_t			sequPos;
	ImplAAFMobSlot			*slot = NULL;
 	ImplEnumAAFMobSlots		*slotIter = NULL;
  	aafBool					found = kAAFFalse;
	aafUInt32				phys;

	XPROTECT()
	{
		offset = position;
		*tcStartPos = 0;
		*result = NULL;
		CHECK(GetSlots (&slotIter));
		while((found != kAAFTrue) && slotIter->NextOne(&slot) == AAFRESULT_SUCCESS)
		{
		  ImplAAFDataDefSP pDataDef;
		  CHECK(slot->GetDataDef (&pDataDef));
		  aafBool isTimecode = kAAFFalse;
		  CHECK(pDataDef->IsTimecodeKind(&isTimecode));
		  if(isTimecode)
			{
			  CHECK(slot->GetPhysicalNum (&phys));
			  if((phys == 0) || (phys == 1))
				found = kAAFTrue;
			}
		}
		if(found != kAAFTrue)
			RAISE(AAFRESULT_MISSING_TRACKID);
		CHECK(slot->GetSegment(&seg));
		CHECK(seg->GetLength(tcSlotLen));
		CHECK(seg->OffsetToTimecodeClip(offset, result, &sequPos));
		*tcStartPos = sequPos;
		slot->ReleaseReference();
		slot = NULL;
		seg->ReleaseReference();
		seg = NULL;
		slotIter->ReleaseReference();
		slotIter = NULL;
	} /* XPROTECT */
	XEXCEPT
	{
		if(XCODE() == AAFRESULT_NO_MORE_OBJECTS)
			RERAISE(AAFRESULT_NO_TIMECODE);
		if(slotIter!= NULL)
		  slotIter->ReleaseReference();
		slotIter = 0;
		if(slot != NULL)
		  slot->ReleaseReference();
		slot = 0;
		if(seg != NULL)
		  seg->ReleaseReference();
		seg = 0;
		*result = NULL;
	}
	XEND;

	return(AAFRESULT_SUCCESS);
}
コード例 #9
0
ファイル: ImplAAFSourceMob.cpp プロジェクト: mcanthony/aaf
//****************
// 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);
}