⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smltime.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			(UINT32)(-m_pSourceElement->m_lBeginOffset) : 0;
		UINT32 ulClippedAmt = 0;

		if (ulNegOffset > 0)
		{
		    m_pSourceElement->m_bNegBeginOffsetAlreadyUsed =
			    TRUE;
		}

		m_pSourceElement->m_ulDelay += ulPosOffset;
		if (m_pSourceElement->m_ulDelay >= ulNegOffset)
		{
		    m_pSourceElement->m_ulDelay -= ulNegOffset;
		}
		else
		{
		    // /If set by parent, then we want to use the entire
		    // negative offset FROM OUR PARENT's BEGIN which already
		    // has the delay in it, so <par begin="2s"><ref begin=
		    // "-3s" ...> would begin the ref at 2s w/3s clip-begin:
		    ulClippedAmt = bSetByParent? ulNegOffset : ulNegOffset -
			    m_pSourceElement->m_ulDelay;
		    // /If clip-begin is invalid, set it otherwise add to it:
		    m_pSourceElement->m_ulClipBegin = ((UINT32)-1 ==
			    m_pSourceElement->m_ulAuthoredClipBegin?
			    ulClippedAmt : ulClippedAmt +
			    m_pSourceElement->m_ulAuthoredClipBegin);
		    if ((UINT32)-1 != m_pSourceElement->m_ulDuration)
		    {
			if (m_pSourceElement->m_ulDuration > ulClippedAmt)
			{
			    m_pSourceElement->m_ulDuration -= ulClippedAmt;
			}
			// /else duration is negative; it can't ever play.
			else
			{
			    m_pSourceElement->m_ulDuration = 0;
			}
		    }
		}
	    }
	    // /Fixes most of PR64499: when restarting the parent of a
	    // long-sync-arc-begun element, the begin should still be based on
	    // the long sync-arc's global time:
	    else if ((UINT32)-1 != m_pSourceElement->m_ulLongSyncArcBeginInGroupTime
		    &&  m_pSourceElement->m_bIsRestarting)
	    {
		SMILNode* pSyncNode = !m_pParser? NULL :
		       m_pParser->getSyncAncestor(m_pSourceElement->m_pNode);
		HX_ASSERT(pSyncNode  &&  pSyncNode->m_pElement);
		if (pSyncNode  &&  pSyncNode->m_pElement->m_bIsRestarting)
		{		
		    m_pSourceElement->m_ulDelay =
			    m_pSourceElement->m_ulLongSyncArcBeginInGroupTime;
		}
	    }
	    // /Else we've established that the beginOffset is not set, so
	    // just use the delay:
	    else
	    {
		m_pSourceElement->m_ulDelay = ulDelay;

		// /Fixes PR 71386 and PR 77406: event-based begins with sync-
		// arc ends (that are already resolved, here) should not
		// include the delay twice; use the *end* not the *duration*:
		if (m_pSourceElement->m_bEndOffsetSet  &&
			// /Fixes PR 8XYXZ (broken by original PR 71386 fix);
			// If being set by parent, we don't need to do anything
			// because delay is parent delay, not explicitly-set
			// begin val:
			!bSetByParent)
		{
		    // /If dur was explicitly authored along with end, use the
		    // min(end, dur+delay):
		    if (WAY_IN_THE_FUTURE ==
			    m_pSourceElement->m_ulAuthoredDur  ||
			    (UINT32)-1 == m_pSourceElement->m_ulAuthoredDur  ||
			    // /Fixes PR 71386 Part 3 = version where element
			    // has end="x.end" AND has dur="z"; if z+delay >
			    // x.end, ignore dur:
			    (m_pSourceElement->m_ulAuthoredDur +
			    m_pSourceElement->m_ulDelay >
			    m_pSourceElement->m_lEndOffset))
		    {
			if (m_pSourceElement->m_lEndOffset > 0  &&
				(ULONG32)m_pSourceElement->m_lEndOffset >=
				m_pSourceElement->m_ulDelay)
			{
			    m_pSourceElement->m_bDurationIncludesDelayBeyondSyncbase =
				    FALSE;
			    m_pSourceElement->m_ulDuration =
				    m_pSourceElement->m_lEndOffset -
				    m_pSourceElement->m_ulDelay;
			}
			else
			{
			    HX_ASSERT(0  &&  "pleaseContact_ehodge!");
			    m_pSourceElement->m_ulDuration = 0;
			}
		    }
		}
	    }
	    m_bDelaySet = TRUE;
	    if (HXR_OK == m_pParser->adjustForNegativeOffset(m_pID))
	    {
		m_pParser->insertTimelineElement(m_pID, 
		    m_pSourceElement->m_ulDelay);
	    }
            // XXXMEH - animation can be children of media elements, so when
            // a media element gets its delay set, then we need to
            // set the delay of any children
	    if(m_pChildren)
	    {
                LISTPOSITION pos = m_pChildren->GetHeadPosition();
                while (pos)
                {
                    CSmilTimelineElement* pChildElement =
                        (CSmilTimelineElement*) m_pChildren->GetNext(pos);
                    if (pChildElement)
                    {
                        pChildElement->setDelay(m_pSourceElement->m_ulDelay, TRUE);
                    }

                }
	    }
	}
    }
    else
    {
	HX_ASSERT(WAY_IN_THE_FUTURE > ulDelay); // /PR 59584-related check.

	if(m_pSourceElement->m_bBeginOffsetSet)
	{
	    m_pSourceElement->m_ulDelay = (
		((INT32)ulDelay+m_pSourceElement->m_lBeginOffset > 0) ?
		(UINT32)((INT32)ulDelay+m_pSourceElement->m_lBeginOffset):0);
	}
	else
	{
	    // /There are two cases where we might arrive here with
	    // ulDelay not equalling ulPreviouslySetDelay; one is when the
	    // original delay is based on a sync-arc to an element that never
	    // gets added to the timeline, and the other is when the original
	    // delay is based on a long sync-arc.  The following allows both
	    // to work; we don't want to use the new delay if the orig one
	    // was greater than the new one, otherwise we'll play it too soon
	    // and that happens in SMIL2 Timing interop case 1.15:
	    if (!bSetByParent  ||  ulDelay > ulPreviouslySetDelay)
	    {
		m_pSourceElement->m_ulDelay = ulDelay;
	    }
	}

	// /If we've got a long sync-arc begin delay that is earlier (and
	// also resolved earlier) than our parent's begin delay, then we want
	// to do a clip-begin of the difference, e.g,:
	//   <par begin="3s">
	//     <video begin="someElementBeginningAtTimeZero.begin" .../> ...
	// so the video element should begin at 3s and clip the 1st 3s of it.
	if (bSetByParent  &&
		ulPreviouslySetDelay < m_pSourceElement->m_ulDelay)
	{
	    LONG32 lDiff = m_pSourceElement->m_ulDelay -ulPreviouslySetDelay;
	    HX_ASSERT(lDiff >= 0);
	    ULONG32 ulDiff = (ULONG32)lDiff;
	    // /If clip-begin is invalid, set it otherwise add to it:
	    m_pSourceElement->m_ulClipBegin = ((UINT32)-1 ==
		    m_pSourceElement->m_ulAuthoredClipBegin?
		    ulDiff : ulDiff+m_pSourceElement->m_ulAuthoredClipBegin);
	    if ((UINT32)-1 != m_pSourceElement->m_ulDuration)
	    {
		if (m_pSourceElement->m_ulDuration > ulDiff)
		{
		    m_pSourceElement->m_ulDuration -= ulDiff;
		}
		else
		{
		    m_pSourceElement->m_ulDuration = 0;
		}

		if (m_pSourceElement->m_pNode)
		{
		    m_pParser->resetTimelineElementDuration(
			    (const char*)m_pSourceElement->m_pNode->m_id,
			    m_pSourceElement->getPureDuration(),
			    ulPreviouslySetPureDuration);
		    m_pParser->m_pTimelineElementManager->notify(
			    (const char*)m_pSourceElement->m_pNode->m_id);
		}
	    }
	}
	// /More for PR 50411: if it wasn't inserted yet, do so:
	// /(Also helps fix other long-sync-arc bugs like PR 64498 & PR 64499):
	if (m_pSourceElement->m_bAwaitingSyncAncestorBeginNotification)
	{
	    HX_ASSERT(!m_pSourceElement->m_bInsertedIntoTimeline);
	    m_pParser->insertTimelineElement(m_pID,
		    m_pSourceElement->m_ulDelay);
	    m_pSourceElement->m_bAwaitingSyncAncestorBeginNotification =
		    FALSE;
	}
    }

    // /This helps fix PR 50588 (and other sync-arc-to-x's-begin-where-x-has-
    // resolved-delay-but-not-resolved-duration bugs); notify sync-arc
    // dependents if our delay (or duration) was set or changed:
    if (ulPreviouslySetDelay != m_pSourceElement->m_ulDelay  ||
	    ulPreviouslySetPureDuration != m_pSourceElement->getPureDuration())
    {
	m_pParser->m_pTimelineElementManager->notify(m_pID);
    }
}

void 
CSmilTimelineElement::setDuration(UINT32 ulDuration, BOOL bSetFromParent,
				  BOOL bDurationExtendingDueToPause)
{
#if defined(_DEBUG)  &&  defined(XXXEH_DEBUGOUT_ADDDURATION)
    {
	FILE* f1 = ::fopen("c:\\smil2AddDuration.txt", bFirstTimeAddDurDebugout?
		ADDDURATION_DEBUGOUT_STR_NEW_FILE :
		ADDDURATION_DEBUGOUT_STR_APPEND_TO_FILE );
	::fprintf(f1, "CSmilTimelineElement{%s}::setDuration(ulDuration=%lu, "
		"bSetFromParent=%sE) m_pSourceElement->m_ulDelay=%lu, m_bDelaySet=%s\n",
		(const char*)m_pID, ulDuration,
		bSetFromParent?"TRU":"FALS", m_pSourceElement->m_ulDelay,
		m_bDelaySet?"TRUE":"FALSE-#############!!! DUDE!");
	::fclose(f1);
	bFirstTimeAddDurDebugout = FALSE;
    }
#endif

    BOOL bTrackStartsTooLateSoTrackRemoved = FALSE;

    ULONG32 ulPriorPureDuration = m_pSourceElement->getPureDuration();

    if(bSetFromParent)
    {
	BOOL bOKToOverrideDuration = FALSE;
	if ((UINT32)-1 == m_pSourceElement->m_ulAuthoredDur)
	{
	    if (!m_pSourceElement->m_bHasExplicitEnd  ||  !m_bDurationSet)
	    {
		bOKToOverrideDuration = TRUE;
	    }
	}
	else if (m_pSourceElement->m_ulAuthoredDur == WAY_IN_THE_FUTURE  &&
		m_pSourceElement->m_bHasExplicitEnd  &&  m_bDurationSet  &&
		// /Fixes PR 50676 part 5: if m_bDurationSet but duration was
		// not set to anything but unresolved, then we do want to
		// override the unresolved value; this continues to let the
		// fix work from 5/9/2001's addition of this else-if:
		m_pSourceElement->m_ulDuration != WAY_IN_THE_FUTURE)
	{
	    bOKToOverrideDuration = FALSE;
	}
	else if (m_pSourceElement->m_ulAuthoredDur >= ulDuration  &&
	    ((UINT32)-1 == m_pSourceElement->m_ulMaxActiveDur  ||
	    m_pSourceElement->m_ulMaxActiveDur >= ulDuration) )
	{
	    // /XXXEH- I need to find content that has this feature;
	    // I'm pretty sure I want to add m_ulBeginOffsetFromSyncBase to
	    // m_ulAuthoredDur when comparing with ulDuration, above, since
	    // ulDuration is in syncbase time coordinate system:
	    HX_ASSERT((!m_pSourceElement->m_bCurBeginIsOffsetFromSyncBase  ||
		    (m_pSourceElement->m_ulBeginOffsetFromSyncBase +
		    m_pSourceElement->m_ulAuthoredDur >= ulDuration) )  &&
		    "contact ehodge to fix");
	    bOKToOverrideDuration = TRUE;
	}

	// /If begin="5s" and end|dur|max are explicitly set, don't override
	// the duration (interop #1.1: BeginEndEvents_Case1.smi):
	// /XXXEH- make sure delay is accounted for (if "ulDuration" is
	// really delay+dur):
	if (bOKToOverrideDuration)
	{
	    // /Fixes BUG-20001116_parDurExtended_due_to_syncArc_delay.smi:
	    ULONG32 ulRevisedDur = ulDuration;

	    BOOL bOkToSetDuration = TRUE;

	    BOOL bOKToResetDurationIncludesDelayVar = TRUE;

	    BOOL bRevisedDurDoesNotIncludeDelayBeyondSyncbase = FALSE;

	    // /Note: when we say "parent" in this function, we really
	    // mean sync ancestor (e.g., par when switch is our parent and
	    // par is parent of switch).

	    ULONG32 ulSyncBaseDelay = (UINT32)-1;
	    SMILNode* pSyncNode = !m_pParser? NULL :
		   m_pParser->getSyncAncestor(m_pSourceElement->m_pNode);
	    HX_ASSERT(pSyncNode  &&  pSyncNode->m_pElement);
	    if (pSyncNode  &&  pSyncNode->m_pElement)
	    {
		ulSyncBaseDelay = pSyncNode->m_pElement->m_ulDelay;
		// /XXXEH- in PR 59584 (which works OK with code as-is),
		// syncNode is a Seq but prior sibling should really be
		// treated as the "sync base", not the seq.  There are 3
		// other places in this file where this code is needed,
		// but need content that's broken by this before I fix it: PR 6XXX5:
		if (pSyncNode->m_tag == SMILSeq)
		{
		    ulSyncBaseDelay = m_pParser->
			    getSyncBaseTimeInGroupTimeCoords(
			    m_pSourceElement->m_pNode);
		}
	    }

	    // /We need to make sure that our begin+duration does not exceed
	    // our parent's end; the ulDuration begin passed in is our
	    // syncBase-imposed duration that already includes our syncBase's
	    // delay but does not take into account our begin offset or
	    // delay relative to our syncBase's begin.  To adjust for this,
	    // set the new duration to ulDuration minus (beginOffset set?
	    // beginOffset : (delay-parentDelay):  Note that we can have a
	    // delay that is due to a sync-arc and not due to our syncBase's
	    // delay and thus we may not have a beginOffset set but we still
	    // may begin later than our syncBase:
	    if (m_pSourceElement->m_bBeginOffsetSet)
	    {
		// /Include this code because it fixes
		// <par dur="5s" begin="1s"><ref begin="2s"/></par>
		// as in BUG-20001116_parDurExtended_due_to_syncArc_delay.smi
		// (which broke again due to fix for PR 53514, below, I think):
		if (m_pSourceElement->m_lBeginOffset > 0)
		{
		    ulRevisedDur=((ULONG32)m_pSourceElement->m_lBeginOffset>=
			    ulRevisedDur)? 0 : (ulRevisedDur -
			    (ULONG32)m_pSourceElement->m_lBeginOffset);
		    bRevisedDurDoesNotIncludeDelayBeyondSyncbase = TRUE;


		    // /Fixes PR 58568: if revised dur is 0 or negative
		    // (ULONG32 floor of 0 prevents it from being negative),
		    // then we need to remove the track if it's been added
		    // already, otherwise it'll play in spite of it's
		    // parent ending before that time:
		    if (0 == ulRevisedDur)
		    {
			if (m_pSourceElement->m_pHandler  &&
				m_pSourceElement->m_bInsertedIntoTimeline)
			{
			    // /The following signals subsequent timeline
			    // adjustments to ignore this element in parent
			    // duration computations:
			    m_pSourceElement->m_bCurEndClippedByParent = TRUE;
			    HX_RESULT retval2 = m_pSourceElement->m_pHandler->
				    handleTrackRemoval((const char*)m_pID,
				    (INT32)m_pSourceElement->m_pNode->m_nGroup);
			    if (HXR_OK == retval2)
			    {
				// /XXXEH- verify in SMIL 2.0 spec how to
				// handle syncArcs to element that's beyond
				// its syncBase and thus won't start:
				// /Fixes case where element has sync arc
				// to this end time and we need to notify it
				// that we've ended early:
				m_pParser->m_pTimelineElementManager->notify((const char*)m_pID);
				bTrackStartsTooLateSoTrackRemoved = TRUE;
				goto cleanup;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -