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

📄 smlparse.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			    {
				ULONG32 ulCurStartTime = 0;
				if (HXR_OK == pPrevSibling->m_pElement->
					getCurrentScheduledStartTime(
					ulCurStartTime)  &&
					ulCurTime > ulCurStartTime)
				{
				    ULONG32 ulNewDuration =
					    ulCurTime - ulCurStartTime;

    				    durationResolved(pPrevSibling->m_id,
					    ulNewDuration);

                                    if (m_pTimelineElementManager)
                                        m_pTimelineElementManager->notify((const char*)pPrevSibling->m_id);
				}
			    }
			}
		    }
		    // /If not child of seq, then just set its delay to now:
		    else
		    {
			pFragmentElement->m_pTimelineElement->setDelay(
				ulCurTime,FALSE);
		    }
		}
		else
		{
		    // /Must just be a mouse move, so return the
		    // unresolved value so mouse cursor can change:
		    return ((UINT32)-1);
		}
	    }
	}
    }
    return 0;
}

SMILNode*
CSmilParser::findFirstNode(SMILNodeList* pNodeList, SMILNodeTag tag)
{
    if(!pNodeList)
    {
	return 0;
    }

    SMILNode* pFoundNode = 0;
    CHXSimpleList::Iterator i;
    for(i=pNodeList->Begin();i!=pNodeList->End();++i)
    {
	SMILNode* pNode = (SMILNode*)(*i);
	if(pNode->m_tag == tag)
	{
	    pFoundNode = pNode;
	}
	else
	{
	    pFoundNode = findFirstNode(pNode->m_pNodeList, tag);
	}
	if(pFoundNode)
	{
	    break;
	}
    }
    return pFoundNode;
}

SMILNode*
CSmilParser::findFirstNode(SMILNodeTag tag)
{
    return findFirstNode(m_pNodeList, tag);
}

SMILNode*
CSmilParser::getFirstNodeChild(SMILNode* pNode)
{
    m_pCurNode = pNode;
    if(!m_pCurNode)
    {
	return 0;
    }
   return m_pCurNode->getFirstChild();
}

SMILNode*
CSmilParser::getNextNodeChild()
{
    if(!m_pCurNode)
    {
	return 0;
    }
    return m_pCurNode->getNextChild();
}

HX_RESULT
CSmilParser::parseClockValue(const char* pValue, UINT32& ulTimeValue)
{
    // try npt
    char* pPtr = (char *)strstr(pValue, "npt=");
    if(pPtr)
    {
	pPtr += 4;  // point to beginning of clock value
	//[SMIL 1.0 compliance] fixes PR 26445: if "npt=4h" is specified,
	// we need to convert to "14400s" otherwise the 4 is treated as
	// seconds:
	char* pHourChar = strchr(pPtr, 'h');
	if (pHourChar  &&  !strchr(pPtr, ':')) //then it's hours without ':'
	{
	    IHXBuffer* pBuf = new CHXBuffer;
	    if (pBuf)
	    {
		pBuf->AddRef();

		*pHourChar = '\0'; //get rid of the 'h' in pPtr.
		pBuf->Set((const unsigned char *)pPtr,
		    strlen(pPtr) + strlen(":00:00") + 1);
		char* pTmp = (char*)pBuf->GetBuffer();
		strcat(pTmp, ":00:00"); /* Flawfinder: ignore */
		NPTime clockTime((const char*)pTmp);
		ulTimeValue = (UINT32)clockTime;
		pBuf->Release();
	    }
	    else
	    {
		return HXR_OUTOFMEMORY;
	    }
	}
	//END fix for PR 26445.
	else
	{
	    NPTime clockTime(pPtr);
	    ulTimeValue = (UINT32)clockTime;
	}
	return HXR_OK;
    }
    // try smpte
    pPtr = (char *)strstr(pValue, "smpte=");
    if(pPtr)
    {
	pPtr += 6;  // point to beginning of clock value
	SMPTETimeCode clockTime(pPtr);
	ulTimeValue = (UINT32)clockTime;
	return HXR_OK;
    }
    pPtr = (char *)strstr(pValue, "smpte-30-drop=");
    if(pPtr)
    {
	pPtr += 14;  // point to beginning of clock value
	SMPTETimeCode clockTime(pPtr);
	ulTimeValue = (UINT32)clockTime;
	return HXR_OK;
    }
    pPtr = (char *)strstr(pValue, "smpte-25=");
    if(pPtr)
    {
	pPtr += 9;  // point to beginning of clock value
	SMPTETimeCode clockTime;
        clockTime.m_framesPerSec = SMPTETimeCode::FPS_25;
        clockTime.fromString(pPtr);
	ulTimeValue = (UINT32)clockTime;
	return HXR_OK;
    }
    else if(strchr(pValue, ':'))     // try just hh:mm:ss with no prefix/suffix
    {
	NPTime clockTime(pValue);
	ulTimeValue = (UINT32)clockTime;
	return HXR_OK;
    }

    // ok, try h/min/s/ms

    char* pEndPtr = 0;
    double dVal = strtod(pValue, &pEndPtr);
    if(strcmp(pEndPtr, "h") == 0)
    {
	ulTimeValue = (UINT32)(dVal * 60.0 * 60.0 * 1000.0);
	return HXR_OK;
    }
    else if(strcmp(pEndPtr, "min") == 0)
    {
	ulTimeValue = (UINT32)(dVal * 60.0 * 1000.0);
	return HXR_OK;
    }
    else if(strcmp(pEndPtr, "s") == 0  ||
	    //[SMIL 1.0 compliance] Fixes PR 22673: the SMIL doc says that we
	    // need to default to seconds if no unit-type is given:
	    //     Timecount-val         ::= Timecount ("." Fraction)?
	    //              ("h" | "min" | "s" | "ms")? ; default is "s"
	    (!strlen(pEndPtr)) )
    {
	ulTimeValue = (UINT32)(dVal * 1000.0);
	return HXR_OK;
    }
    else if(strcmp(pEndPtr, "ms") == 0)
    {
	ulTimeValue = (UINT32)(dVal);
	return HXR_OK;
    }
    //else something other than "h", "min", "s", "", or "ms" was specified:
    else
    {
	return HXR_FAIL;
    }
}

HX_RESULT
CSmilParser::parseSyncBehaviorVal(const char* pSyncBehaviorBuf,
		       CSmilElement* pElement,
		       SMILSyncAttributeTag nTag)
{
    HX_RESULT ret = HXR_OK;
    if (NULL == pSyncBehaviorBuf  ||  (SMILSyncAttrSyncBehavior != nTag  &&
	    SMILSyncAttrSyncBehaviorDefault != nTag))
    {
	HX_ASSERT(FALSE);
	return HXR_UNEXPECTED;
    }

    // First, eat all whitespace:
    const char* pCh = pSyncBehaviorBuf;
    while (*pCh  &&  isspace(*pCh))
    {
	++pCh;
    }

    if (*pCh == '\0')
    {
	// nothing, empty attribute...
	return HXR_OK;
    }

    BOOL bParsedOK = TRUE;
    SMILSyncBehaviorType sbtype = SmilSyncBehaviorInvalid;
    if (strncmp(pCh, "canSlip", 7) == 0)
    {
	pCh += 7;
	sbtype = SmilSyncBehaviorCanSlip;
    }
    else if (strncmp(pCh, "locked", 6) == 0)
    {
	pCh += 6;
	sbtype = SmilSyncBehaviorLocked;
    }
    else if (strncmp(pCh, "independent", 11) == 0)
    {
	pCh += 11;
	sbtype = SmilSyncBehaviorIndependent;
    }
    else if (strncmp(pCh, "default", 7) == 0)
    {
	pCh += 7;
	sbtype = SmilSyncBehaviorDefault;
    }
    else if (strncmp(pCh, "inherit", 7) == 0)
    {
	pCh += 7;
	sbtype = SmilSyncBehaviorInherit;
    }
    else
    {
	bParsedOK = FALSE;
    }

    if (bParsedOK)
    {
	while (*pCh  &&  isspace(*pCh))
	{
	    ++pCh;
	}
	if (*pCh)
	{
	    bParsedOK = FALSE;  // /Should only be whitespace after value.
	}
    }

    if (SMILSyncAttrSyncBehavior == nTag)
    {
	pElement->m_syncBehavior = sbtype;
	// /syncBehavior can not be "inherit":
	bParsedOK = bParsedOK  &&  (SmilSyncBehaviorInherit != sbtype);
    }
    else
    {
	pElement->m_syncBehaviorDefault = sbtype;
	// /syncBehaviorDefault can not be "default":
	bParsedOK = bParsedOK  &&  (SmilSyncBehaviorDefault != sbtype);
    }

    if (SmilSyncBehaviorInvalid == sbtype  ||  !bParsedOK)
    {
	ret = HXR_INVALID_PARAMETER;
    }

    return ret;
}

HX_RESULT
CSmilParser::parsePeersHigherLower(const char* pBuf,
		       CSmilPriorityClassElement* pPCElement,
		       SMILPriorityClassPeersHigherLowerAttrib nAttrib)
{
    HX_RESULT ret = HXR_OK;
    if (NULL == pBuf  ||  (SMILPriorityClassPeers != nAttrib  &&
	    SMILPriorityClassHigher != nAttrib  &&
	    SMILPriorityClassLower != nAttrib))
    {
	HX_ASSERT(FALSE);
	return HXR_UNEXPECTED;
    }

    BOOL bParsedOK = TRUE;
    SMILPriorityClassPeersHigherLowerVal val =
	    SMILPriorityClassPeersHigherLowerInvalid;

    // First, eat all whitespace:
    const char* pCh = pBuf;
    while (*pCh  &&  isspace(*pCh))
    {
	++pCh;
    }

    if (*pCh == '\0')
    {
	ret = HXR_INVALID_PARAMETER;
	goto cleanup;
    }

    if (strncmp(pCh, "stop", 4) == 0)
    {
	pCh += 4;
	val = SMILPriorityClassStop;
    }
    else if (strncmp(pCh, "pause", 5) == 0)
    {
	pCh += 5;
	val = SMILPriorityClassPause;
    }
    else if (strncmp(pCh, "defer", 5) == 0)
    {
	pCh += 5;
	val = SMILPriorityClassDefer;
    }
    else if (strncmp(pCh, "never", 5) == 0)
    {
	pCh += 5;
	val = SMILPriorityClassNever;
    }
    else
    {
	bParsedOK = FALSE;
    }

    if (bParsedOK)
    {
	while (*pCh  &&  isspace(*pCh))
	{
	    ++pCh;
	}
	if (*pCh)
	{
	    bParsedOK = FALSE;  // /Should only be whitespace after value.
	}
    }

    if (SMILPriorityClassPeers == nAttrib)
    {
	pPCElement->m_peers = val;
    }
    else if (SMILPriorityClassHigher == nAttrib)
    {
	pPCElement->m_higher = val;
	// /higher can't be "defer" or "never":
	bParsedOK = bParsedOK  &&  (SMILPriorityClassDefer != val  &&
		SMILPriorityClassNever != val);
    }
    else // /SMILPriorityClassLower
    {
	pPCElement->m_lower = val;
	// /lower can't be "stop" or "pause":
	bParsedOK = bParsedOK  &&  (SMILPriorityClassStop != val  &&
		SMILPriorityClassPause != val);
    }

    if (SMILPriorityClassPeersHigherLowerAttribInvalid== val  ||  !bParsedOK)
    {
	ret = HXR_INVALID_PARAMETER;
    }

cleanup:
    return ret;
}

HX_RESULT
CSmilParser::parsePauseDisplay(const char* pBuf,
		       CSmilPriorityClassElement* pPCElement)
{
    HX_RESULT ret = HXR_OK;
    if (NULL == pBuf)
    {
	HX_ASSERT(FALSE);
	return HXR_UNEXPECTED;
    }

    BOOL bParsedOK = TRUE;

    // First, eat all whitespace:
    const char* pCh = pBuf;
    while (*pCh  &&  isspace(*pCh))
    {
	++pCh;
    }

    if (*pCh == '\0')
    {
	ret = HXR_INVALID_PARAMETER;
	goto cleanup;
    }

    pPCElement->m_pauseDisplay = SMILPriorityClassPauseDisplayInvalid;
    if (strncmp(pCh, "disable", 7) == 0)
    {
	pCh += 7;
	pPCElement->m_pauseDisplay = SMILPriorityClassPauseDisplayDisable;
    }
    else if

⌨️ 快捷键说明

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