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

📄 smlparse.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
CSmilParser::~CSmilParser()
{
    deleteTagAttributes();
    HX_DELETE(m_pRequireTagsMap);
    HX_DELETE(m_pCustomTestMap);
    HX_DELETE(m_pElementMap);
    HX_DELETE(m_pAttributeMap);
#if defined(HELIX_FEATURE_SMIL2_VALIDATION)
    HX_DELETE(m_pExtElementMap);
    HX_DELETE(m_pExtAttributeMap);
    HX_DELETE(m_pNamespaceMap);
    HX_DELETE(m_pLegalAttrMap);
    HX_DELETE(m_pContentModelMap);
    HX_VECTOR_DELETE(m_pAttrType);
    deleteEnumAttrMaps();
    deleteReqAttrLists();
#endif /* #if defined(HELIX_FEATURE_SMIL2_VALIDATION) */
    HX_DELETE(m_pAnimateElementList);
    deleteValidationNamespaceList();

    if (m_pErrors)
    {
	int size = m_pErrors->GetSize();
	for (int i =0; i < size; ++i)
	{
	    IHXBuffer* pBuf = (IHXBuffer*)(*m_pErrors)[i];
	    HX_RELEASE(pBuf);
	    (*m_pErrors)[i] = NULL;
	}
	HX_DELETE(m_pErrors);
    }

    if (m_pActiveNamespaceMap != NULL)
    {
	CHXMapStringToOb::Iterator ndxBuffer = m_pActiveNamespaceMap->Begin();
	for (; ndxBuffer != m_pActiveNamespaceMap->End(); ++ndxBuffer)
	{
	    IHXBuffer* pBuffer = (IHXBuffer*)(*ndxBuffer);
	    HX_RELEASE(pBuffer);
	}
	HX_DELETE(m_pActiveNamespaceMap);
    }

    if (m_pNSConflictList != NULL)
    {
	CHXSimpleList::Iterator ndx = m_pNSConflictList->Begin();
	for (; ndx != m_pNSConflictList->End(); ++ndx)
	{
	    SMILNamespace* pNS = (SMILNamespace*)(*ndx);
	    HX_DELETE(pNS);
	}
	HX_DELETE(m_pNSConflictList);
    }

#if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
    HX_DELETE(m_pTransitionMap);
#endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */

    // /XXXEH- TODO: check mem leaks; should be clean already...
    HX_DELETE(m_pBeginTimeSyncList);
    HX_DELETE(m_pEndTimeSyncList);

    // /XXXEH- TODO: check mem leaks; should be clean already...
    HX_DELETE(m_pBeginEventList);
    HX_DELETE(m_pEndEventList);

    // /XXXEH- TODO: check mem leaks; should be clean already...
    HX_DELETE(m_pBeginMediaMarkerList);
    HX_DELETE(m_pEndMediaMarkerList);
    HX_DELETE(m_pXMMFElementList);
    HX_DELETE(m_pClipBeginMarkerList);
    HX_DELETE(m_pClipEndMarkerList);

    // /XXXEH- TODO: check mem leaks; should be clean already...
    HX_DELETE(m_pPendingBeginTimeList);
    HX_DELETE(m_pPendingEndTimeList);
    HX_DELETE(m_pOnLoadURLList);
    HX_DELETE(m_pOnLoadURLListCopyForPostSeek);

    HX_DELETE(m_pNodeDependencies);
    HX_DELETE(m_pAnchorStack);
    HX_VECTOR_DELETE(m_pEncoding);
    if(m_pLanguagePreferenceList)
    {
	CHXSimpleList::Iterator i = m_pLanguagePreferenceList->Begin();
	for(; i != m_pLanguagePreferenceList->End(); ++i)
	{
	    char* pLang = (char*)(*i);
	    delete[] pLang;
	}
	HX_DELETE(m_pLanguagePreferenceList);
    }
    HX_DELETE(m_pOverdubOrCaptionPreference);
    HX_DELETE(m_pBasePath);

    close();

    HX_RELEASE(m_pClassFactory);
    HX_RELEASE(m_pContext);
    HX_VECTOR_DELETE(m_pVarName);
    HX_DELETE(m_pTimelineElementManager);
}

void
CSmilParser::initRequireTags()
{
    //XXXBAB - add required tags here
#if 0
    m_pRequireTagsMap = new CHXMapStringToOb;
    (*m_pRequireTagsMap)["foo-require"] = 0;
    (*m_pRequireTagsMap)["boo-require"] = 0;
#endif

}


void
CSmilParser::GetSystemScreenInfo(REF(UINT32) rulScreenHeight,
				 REF(UINT32) rulScreenWidth,
				 REF(UINT32) rulScreenBitDepth)
{
    rulScreenHeight = rulScreenWidth = rulScreenBitDepth = 0;
#if defined(_WINDOWS)
    rulScreenHeight = (UINT32)GetSystemMetrics(SM_CYSCREEN);
    rulScreenWidth = (UINT32)GetSystemMetrics(SM_CXSCREEN);
    HDC hDCMain = GetDC(NULL); // /Get screen DC.
    if (hDCMain)
    {
	rulScreenBitDepth = (UINT32)GetDeviceCaps(hDCMain, BITSPIXEL);
	ReleaseDC(NULL, hDCMain);
    }
#elif defined(_UNIX) && (!(defined(_BEOS))) && (!(defined(_MAC_UNIX)))
    // /Pass NULL string to XOpenDisplay to get default display, which
    // is the one that we're playing to:
    Display* pDisplay = XOpenDisplay(NULL);
    if (pDisplay)
    {
	Screen* pScreen = XDefaultScreenOfDisplay(pDisplay);
	rulScreenHeight = (UINT32)HeightOfScreen(pScreen);
	rulScreenWidth = (UINT32)WidthOfScreen(pScreen);
	rulScreenBitDepth = (UINT32)DefaultDepthOfScreen(pScreen);
    }
#elif defined(_MACINTOSH) || defined(_MAC_UNIX)
    // /XXXEH- note: on a Mac, you can have multiple display devices and our
    // player can actually play to more than one at once, and can be dragged
    // from one to the other while running.  Dynamic re-evaluation is needed.
    GDHandle mainGD = ::GetMainDevice();
    rulScreenHeight = (UINT32)((**mainGD).gdRect.bottom - (**mainGD).gdRect.top);
    rulScreenWidth = (UINT32)((**mainGD).gdRect.right - (**mainGD).gdRect.left);
    PixMapHandle pmh = (**mainGD).gdPMap;
    if (pmh)
    {
	rulScreenBitDepth = (UINT32)((**pmh).pixelSize);
    }
#elif defined(_SYMBIAN)
    TInt aValue;
    TReal aTrg1;
    TReal aTrg2;
    TInt log1;
    TInt log2;
    HAL::Get(HALData::EDisplayColors,aValue);
    TScreenInfoV01 screenInfo;
    TPckg<TScreenInfoV01> si(screenInfo);
    UserSvr::ScreenInfo(si);
    rulScreenWidth = screenInfo.iScreenSize.iWidth;
    rulScreenHeight = screenInfo.iScreenSize.iHeight;
    log1 = Math::Ln(aTrg1,aValue);
    log2 = Math::Ln(aTrg2,2);
    rulScreenBitDepth = (TUint32)(aTrg1/aTrg2);
#else

    HX_ASSERT(0  &&  "Contact ehodge: need screen info from this OS");
#endif
}

void
CSmilParser::getPreferences()
{
    IHXPreferences*	pPrefs = 0;
    IHXRegistry*	pRegistry = NULL;

    m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry);

    if(HXR_OK == m_pContext->QueryInterface(
	IID_IHXPreferences, (void**)&pPrefs))
    {
	IHXBuffer* pBuf = 0;
	CHXString strTemp;
	strTemp.Format("%s.%s",HXREGISTRY_PREFPROPNAME,"Language");

	if(pRegistry && HXR_OK == pRegistry->GetStrByName(strTemp, pBuf))
	{
	    // language preference can be a comma-separated list

	    const char* pLang = (const char*)pBuf->GetBuffer();
	    // gonna call strtok, so copy the string...
	    char* pLangCopy = new_string(pLang);
	    m_pLanguagePreferenceList = new CHXSimpleList;
	    char* pTok = strtok(pLangCopy, ",");
	    while(pTok)
	    {
		// /Fixes TLC-set part of PR 58151: sometimes this list will
		// have tokens separated by ", " instead of just ",", so first
		// remove all whitespace chars after the ',' (and, if we run
		// into a whitespace-only string, go past the next comma):
		while (isspace(*pTok)  ||  ',' == *pTok)
		{
		    *pTok++;
		}
		if ('\0' == *pTok)
		{
		    break; // /Whitespace-only or emtpy string is not valid.
		}

		char* pLangString = new_string(pTok);
		m_pLanguagePreferenceList->AddTail(pLangString);
		pTok = strtok(NULL, ",");
	    }
	    delete[] pLangCopy;
	    HX_RELEASE(pBuf);
	}
	if(HXR_OK == pPrefs->ReadPref("bandwidth", pBuf)  ||
		// /Fixes PR 84098 (SMIL 2.0 version): on Mac, player registry
		// is case-sensitive and the registry value is Bandwidth
		// with a capital B:
		HXR_OK == pPrefs->ReadPref("Bandwidth", pBuf))
	{
	    m_ulBandwidthPreference =
		(UINT32)atol((const char*)pBuf->GetBuffer());
	    HX_RELEASE(pBuf);
	}

	UINT32 rulScreenHeight = 0;
	UINT32 rulScreenWidth = 0;
	UINT32 rulScreenBitDepth = 0;
	// /Each value found here will be used if the player prefs does not
	// already contain it.  For PR 58072 and PR 58075:
	GetSystemScreenInfo(rulScreenHeight, rulScreenWidth, rulScreenBitDepth);

	if(HXR_OK == pPrefs->ReadPref("screen_depth", pBuf))
	{
	    m_ulScreenDepthPreference =
		(UINT32)atol((const char*)pBuf->GetBuffer());
	    HX_RELEASE(pBuf);
	}
	// /Fixes PR 58075: if not in the player registry, then use the
	// screen (bit) depth obtained from the OS API call:
	else
	{
	    m_ulScreenDepthPreference = rulScreenBitDepth;
	}

	if(HXR_OK == pPrefs->ReadPref("screen_height", pBuf))
	{
	    m_ulScreenHeightPreference =
		(UINT32)atol((const char*)pBuf->GetBuffer());
	    HX_RELEASE(pBuf);
	}
	// /Fixes height part of PR 58072: if not in the player registry, then
	// use the screen height obtained from the OS API call:
	else
	{
	    m_ulScreenHeightPreference = rulScreenHeight;
	}

	if(HXR_OK == pPrefs->ReadPref("screen_width", pBuf))
	{
	    m_ulScreenWidthPreference =
		(UINT32)atol((const char*)pBuf->GetBuffer());
	    HX_RELEASE(pBuf);
	}
	// /Fixes width part of PR 58072: if not in the player registry, then
	// use the screen width obtained from the OS API call:
	else
	{
	    m_ulScreenWidthPreference = rulScreenWidth;
	}

	if(HXR_OK == pPrefs->ReadPref("caption_switch", pBuf))
	{
	    m_bCaptionsPreference =
		(BOOL)((UINT32)atol((const char*)pBuf->GetBuffer()));
	    HX_RELEASE(pBuf);
	}
	if(HXR_OK == pPrefs->ReadPref("overdub_or_caption", pBuf))
	{
	    const char* pStr = (const char*)pBuf->GetBuffer();
	    m_pOverdubOrCaptionPreference = new_string(pStr);
// /XXXEH- TLC needs to allow BOTH captions and audio descriptions
// so they'll need a "overdub_or_caption" option (choice) AND
// a separate "audio_desc_switch" like "caption_switch", above.
#define XXXEH_NEED_TLC_TO_HAVE_SEPARATE_audio_desc_AND_caption_PREFS
#if defined(XXXEH_NEED_TLC_TO_HAVE_SEPARATE_audio_desc_AND_caption_PREFS)
	    // /In our player (RP8), "caption_switch" is what gets set to
	    // TRUE when *ALL* accessibility features are enabled.  So,
	    // it's possible to have accessibility features disabled but
	    // to have overdub_or_captions set to one or the other; we need
	    // to look at the caption_switch pref to see if we should enable
	    // audio descriptions:
	    if (m_bCaptionsPreference)
	    {
		m_bSystemAudioDescPreference = !strcmp(pStr, "overdub");
		if (m_bSystemAudioDescPreference)
		{
		    m_bCaptionsPreference = FALSE;
		}
	    }
#endif
	    HX_RELEASE(pBuf);
	}
	if(HXR_OK == pPrefs->ReadPref("systemAudioDesc", pBuf))
	{
	    m_bSystemAudioDescPreference =
		    (BOOL)((UINT32)atol((const char*)pBuf->GetBuffer()));
	    HX_RELEASE(pBuf);
	}
	// /Fixes PR 64428:
	if(HXR_OK == pPrefs->ReadPref("UseSystemCPU", pBuf))
	{
	    m_bUseSystemCPU =
		    (BOOL)((UINT32)atol((const char*)pBuf->GetBuffer()));
	    HX_RELEASE(pBuf);
	}
	// /Fixes PR 64428:
	if(HXR_OK == pPrefs->ReadPref("UseSystemOS", pBuf))
	{
	    m_bUseSystemOS =
		    (BOOL)((UINT32)atol((const char*)pBuf->GetBuffer()));
	    HX_RELEASE(pBuf);
	}

	HX_RELEASE(pPrefs);
    }

    HX_RELEASE(pRegistry);
}


void
CSmilParser::close()
{
    HX_DELETE(m_pPacketQueue);
    HX_DELETE(m_pTrackHintList);
    HX_RELEASE(m_pResponse);
    HX_RELEASE(m_pErrorText);
    HX_RELEASE(m_pDefaultNamespace);
    if (m_pParser)
    {
	m_pParser->Close();
	HX_RELEASE(m_pParser);
    }
    HX_RELEASE(m_pISystemRequired);

    if (m_pCustomTestMap)
    {
	CHXMapStringToOb::Iterator i = m_pCustomTestMap->Begin();
	for(; i != m_pCustomTestMap->End(); ++i)
	{
	    SMILNode* pNode = (SMILNode*)(*i);
	    HX_DELETE(pNode->m_pElement);
	}
	HX_DELETE(m_pCustomTestMap);
    }

    if(m_pIDMap)
    {
	CHXMapStringToOb::Iterator i = m_pIDMap->Begin();
	for(; i != m_pIDMap->End(); ++i)
	{
	    SMILNode* pNode = (SMILNode*)(*i);
	    HX_DELETE(pNode->m_pElement);
	}
	HX_DELETE(m_pIDMap);
    }

    if(m_pAddGroupMap)
    {
	CHXMapLongToObj::Iterator i = m_pAddGroupMap->Begin();
	for(; i != m_pAddGroupMap->End(); ++i)
	{
	    CSmilAddGroup* pAddGroup = (CSmilAddGroup*)(*i);
	    delete pAddGroup;
	}
	HX_DELETE(m_pAddGroupMap);
    }

    if(m_pSourceUpdateList)
    {
	CHXSimpleList::Iterator i = m_pSourceUpdateList->Begin();
	for(; i != m_pSourceUpdateList->End(); ++i)
	{
	    CSmilSourceUpdate* pUpdate = (CSmilSourceUpdate*)(*i);
	    delete pUpdate;
	}
	HX_DELETE(m_pSourceUpdateList);
    }

    if (m_pActiveNamespaceMap)
    {
	CHXMapStringToOb::Iterator ndxBuffer = m_pActiveNamespaceMap->Begin();
	for (; ndxBuffer != m_pActiveNamespaceMap->End(); ++ndxBuffer)
	{
	    IHXBuffer* pBuffer = (IHXBuffer*)(*ndxBuffer);
	    HX_RELEASE(pBuffer);
	}
	HX_DELETE(m_pActiveNamespaceMap);
    }

    if (m_pNSConflictList != NULL)
    {
	CHXSimpleList::Iterator ndx = m_pNSConflictList->Begin();
	for (; ndx != m_pNSConflictList->End(); ++ndx)
	{
	    SMILNamespace* pNS = (SMILNamespace*)(*ndx);
	    HX_DELETE(pNS);
	}
	HX_DELETE(m_pNSConflictList);
    }

#if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
    HX_DELETE(m_pTransitionMap);
#endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */

    delete m_pNodeListStack;
    if(m_pNodeList)
    {
	delete m_pNodeList->m_pParentNode;
    }

⌨️ 快捷键说明

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