Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
HRESULT STDMETHODCALLTYPE
    CAAFSourceClip::Initialize (IAAFDataDef * pDataDef,
        aafLength_constref  length,
        aafSourceRef_t  sourceRef)
{
  HRESULT hr;

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

  //
  // set up for pDataDef
  //
  ImplAAFDataDef * internalpDataDef = NULL;
  if (pDataDef)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pDataDef->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      assert (SUCCEEDED (hStat));
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpDataDef = static_cast<ImplAAFDataDef*>(arg);
      assert (internalpDataDef);
    }

  try
    {
      hr = ptr->Initialize
       (internalpDataDef,
        length,
        sourceRef);
    }
  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;
    }

  //
  // no cleanup necessary for pDataDef
  //
  return hr;
}
Ejemplo n.º 4
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);
}