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

📄 smldoc.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	{	    CHXString* pID = (CHXString*)(*i);	    delete pID;	}    }    HX_DELETE(m_pPausedAndDisabledIDMap);        if (m_pPausedAndDisabledBrightnessMap)    {	CHXMapStringToOb::Iterator i =		m_pPausedAndDisabledBrightnessMap->Begin();	for (; i != m_pPausedAndDisabledBrightnessMap->End(); ++i)	{	    float* pf = (float*)(*i);	    delete pf;	}    }    HX_DELETE(m_pPausedAndDisabledBrightnessMap);    if(m_pStatusMessage)    {	m_pStatusMessage->SetStatus(NULL);    }    HX_RELEASE(m_pStatusMessage);    if (m_pPlayerResumeStack)    {	CSmilPlayerResumePos* pResumePos =		(CSmilPlayerResumePos*)m_pPlayerResumeStack->Pop();	while (pResumePos)	{	    delete pResumePos;	    pResumePos = (CSmilPlayerResumePos*)m_pPlayerResumeStack->Pop();	}    }    HX_DELETE(m_pPlayerResumeStack);    if (m_bRootLayoutSiteDetached)    {        CleanUpSiteInfoContainers();        HX_DELETE(m_pSiteWatcherMap);    }    HX_DELETE(m_pSmilParser);    HX_VECTOR_DELETE(m_pFragment);    HX_RELEASE(m_pScheduler);    HX_RELEASE(m_pContext);    clearRendererMap();    HX_DELETE(m_pMediaID2RendererMap);    clearRendererSiteMap();    HX_DELETE(m_pMediaID2RendererSiteMap);    clearRendererSiteWatcherMap();    HX_DELETE(m_pMediaID2RendererSiteWatcherMap);#ifdef _MACINTOSH    if (m_bResetCursor)    {	m_bResetCursor = FALSE;	::InitCursor();    }#endif    // Set the flag indicating that close has been called    m_bCloseCalled = TRUE;    // Release the sound level mutex    HX_RELEASE(m_pSoundLevelMutex);    return HXR_OK;}HX_RESULTCSmilDocumentRenderer::onHeader(IHXValues* pHeader){    m_bSMILPresentationHasEnded = FALSE;    m_pRegionMap = new CHXMapStringToOb;    m_pSiteInfoByRendererMap = new CHXMapPtrToPtr;    m_pSmilParser = new CSmilParser(m_pContext);    m_pSmilParser->init();        if (m_pPersistentParentRenderer &&	HXR_OK == m_pPersistentParentRenderer->GetElementProperties(m_uPersistentGroupID,								    m_uPersistentTrackID,								    m_pPersistentProperties))    {	m_pSmilParser->InitPersistent(m_ulPersistentComponentID, m_pPersistentProperties);    }    // Create a root-layout object    HX_DELETE(m_pRootLayout);    m_pRootLayout = new CSmilBasicRootLayout();    // The SMIL default namespace is stored in the    // "MimeType" property of the stream header    if (pHeader)    {        HX_RELEASE(m_pSMILDefaultNamespaceStr);	if (m_pParent  &&  !m_pParent->isStreamProxiedByOtherRenderer())	{	    pHeader->GetPropertyCString("MimeType", m_pSMILDefaultNamespaceStr);	}	else // /Use value passed in via IHXSmilToSmilRendererCommunicator	{	    HX_ASSERT(m_pParent);	    if (m_pParent  &&  m_pParent->m_pVersionNamespaceFromProxyRenderer)	    {		m_pSMILDefaultNamespaceStr =			m_pParent->m_pVersionNamespaceFromProxyRenderer;		m_pSMILDefaultNamespaceStr->AddRef();	    }	}    }    // Get the group we are starting on    m_usAnimBaseGroupIndex = getCurrentGroup();    return HXR_OK;}HX_RESULTCSmilDocumentRenderer::getErrorInfo(REF(UINT32) ulLineNumber,				    REF(UINT32) ulColumnNumber,				    REF(IHXBuffer*) pErrorText){    ulLineNumber = m_pSmilParser->m_ulErrorLineNumber;    ulColumnNumber = m_pSmilParser->m_ulErrorColumnNumber;    pErrorText = m_pSmilParser->m_pErrorText;    if(pErrorText)    {	pErrorText->AddRef();    }    return HXR_OK;}HX_RESULT CSmilDocumentRenderer::getErrorInterface(REF(IHXErrorMessages*) rpErrMsgs){    HX_RESULT retVal = HXR_OK;    if (m_pErrorMessages)    {        HX_RELEASE(rpErrMsgs);        rpErrMsgs = m_pErrorMessages;        rpErrMsgs->AddRef();    }    else    {        retVal = HXR_FAIL;    }    return retVal;}HX_RESULTCSmilDocumentRenderer::onPacket(IHXBuffer* pBuffer, BOOL bIsLast){    HX_RESULT rc = HXR_OK;    BOOL bDumpToFile = FALSE;    ::getBooleanPreference(m_pContext,                           "NonObviousKeyName",                           bDumpToFile);    BOOL bShowPacketBoundaries = FALSE;    ::getBooleanPreference(m_pContext,                           "NonObviousKeyNameOption1",                           bShowPacketBoundaries);    if (bDumpToFile)    {#ifdef _WINDOWS        const char* pszFile = "c:\\smildump.txt";#else        const char* pszFile = "smildump.txt";#endif        FILE* pFoo = fopen(pszFile, m_ulPktnum > 0L ? "a" : "w");        if (pFoo)        {            char* pBuf = (char*) pBuffer->GetBuffer();            if(pBuf && strlen(pBuf) > 0)            {                if (bShowPacketBoundaries)                {                    fprintf(pFoo, "[[[packet # %lu]]]:{{{", m_ulPktnum);                }                fwrite(pBuf, 1, pBuffer->GetSize(), pFoo);                if (bShowPacketBoundaries)                {                    fprintf(pFoo, "}}}\n");                }            }            else            {                if (bShowPacketBoundaries)                {                    fprintf(pFoo, "\n[[[Packet %lu empty in onPacket()]]]\n",                            m_ulPktnum);                }            }        }        fclose(pFoo);        if (bIsLast)            m_ulPktnum = 0L;        else            m_ulPktnum++;    }    rc = m_pSmilParser->parse(pBuffer, bIsLast);    return rc;}HX_RESULT CSmilDocumentRenderer::setDocument(const char* pFragment){    BOOL bDisableValidation = FALSE;    ::getBooleanPreference(m_pContext,                           "DisableSMILValidation",                           bDisableValidation);    HX_RESULT rc = HXR_OK;    if (!bDisableValidation)    {#if defined(HELIX_FEATURE_SMIL2_VALIDATION)        rc = m_pSmilParser->validateAgainstDTD();#endif /* #if defined(HELIX_FEATURE_SMIL2_VALIDATION) */    }    if (SUCCEEDED(rc))    {        rc = m_pSmilParser->createElements();        if(HXR_OK == rc)        {            rc = m_pSmilParser->setAllElementHandlers(this);            rc = handleElements();            if (SUCCEEDED(rc))            {                rc = postParseSetup();            }            // The player may need to know about the URLs             // we will hurl in advance. Therefore, we will            // throw all the potential URLs we may throw            // to the IHXHyperNavigateHint interface.            SendHyperlinkHints();            // Handle any references to external media marker files            m_pSmilParser->handleAllXMMFReferences();            BOOL bContainsSource = m_pSmilParser->presentationContainsASource();	    BOOL bContainsInitiallyScheduledTrack =		    m_pSmilParser->presentationContainsInitiallyScheduledTrack();            ULONG32 ulDurIfNoInitialTracksScheduled =                    m_pSmilParser->presentationDurIfNoInitialTracksScheduled();            // If we have a source in the tree but no source has            // been scheduled, then we'll go ahead and create a group            // XXXMEH - temporary fix. The core does not call DoneChangeLayout            // on the TLC if there is no source scheduled. The real fix for            // this should be done in the core/TLC but may be involved.            // This fix should do in the meantime.            if (!bContainsSource || !bContainsInitiallyScheduledTrack)            {                setupDummySource();            }            IHXPlayer* pPlayer = m_pParent->getPlayer();            IHXGroupManager* pMgr = 0;            if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, (void**)&pMgr))            {                if(pFragment)                {                    m_pFragment = new_string(pFragment);                    m_bSettingFragment = TRUE;                    m_nFragmentTracks = 0;                    UINT16 uFragmentGroup =                         m_pSmilParser->getFragmentGroup(m_pFragment);                    pMgr->SetCurrentGroup(uFragmentGroup);                }                else if (bContainsInitiallyScheduledTrack)                {		    if (m_pParent->m_bUseNestedMeta && m_uCurrentGroupIndex == -1)		    {			pMgr->GetCurrentGroup((UINT16&)m_uCurrentGroupIndex);		    }                    else                    {                        pMgr->SetCurrentGroup(0);                    }                }		// /No sources were scheduled to play, so we have to manually		// keep the presentation open for others like animate elements		// (which can animate regions and thus no sources are needed		// for a SMIL presentation to be (arguably) interesting.  Also,		// a track (source) could begin on an event during playback:                else if (ulDurIfNoInitialTracksScheduled>0  &&			SMILTIME_INVALID != ulDurIfNoInitialTracksScheduled)                {                    HX_ASSERT(m_pPersistentLayoutStream);                    if (m_pPersistentLayoutStream)                    {                        IHXValues* pStreamProps = NULL;                        if(HXR_OK == m_pPersistentLayoutStream->GetProperties(pStreamProps))                        {                            pStreamProps->SetPropertyULONG32("duration",                                    ulDurIfNoInitialTracksScheduled);                            m_pPersistentLayoutStream->SetProperties(pStreamProps);                            HX_RELEASE(pStreamProps);                        }                    }                    // XXXMEH - since there are no sources, the only sites will                    // be region sites, so unless they have an explicit                    // showBackground="whenActive", then we need to show them here                    showAllSites(m_pRootLayout, TRUE);                }                pMgr->Release();            }        }    }    return rc;}HX_RESULT CSmilDocumentRenderer::setupDummySource(){    HX_RESULT retVal = HXR_FAIL;    // Our dummy source is a <brush>, so if <brush> is    // not supported, then we fail.#if defined(HELIX_FEATURE_SMIL2_BRUSH)    if (m_pParent)    {        // Get the player        IHXPlayer* pPlayer = m_pParent->getPlayer();        if (pPlayer)        {            // Get the group manager            IHXGroupManager* pMgr = NULL;            pPlayer->QueryInterface(IID_IHXGroupManager, (void**) &pMgr);            if (pMgr)            {                // Get the current group                UINT16 usGroup = 0;	        if (m_pParent->m_bUseNestedMeta && m_uCurrentGroupIndex == -1)	        {		    pMgr->GetCurrentGroup(usGroup);	        }                // Get an IHXCommonClassFactory                IHXCommonClassFactory* pFactory = m_pParent->getFactory();                if (pFactory)                {                    // Create an IHXValues for the track properties                    IHXValues* pValues = NULL;                    pFactory->CreateInstance(CLSID_IHXValues, (void**) &pValues);                    if (pValues)                    {                        // Create an IHXValues for the 822 headers                        IHXValues* pReqHeaders = NULL;                        pFactory->CreateInstance(CLSID_IHXValues, (void**) &pReqHeaders);                        if (pReqHeaders)                        {                            // Create the base of our src string                            CHXString cSrc("data:text/brush;base64,");                            // Now we need to create our brush string                            CHXString cBrushText("<brush color=\"black\"/>");                            // Allocate an output string big enough to hold the                            // base-64-encoded string                            char* pStr64 = new char [cBrushText.GetLength() << 1];                            if (pStr64)                            {                                // Encode to base-64                                INT32 lEncodedLen = BinTo64((const BYTE*)(const char*) cBrushText,                                                            cBrushText.GetLength(),                                                            pStr64);                                // Create a string out of this encoded data                                CHXString cEncodedBrushText((const char*) pStr64, lEncodedLen);                                // Append this string to our src string                                cSrc += cEncodedBrushText;                            }                            HX_VECTOR_DELETE(pStr64);                            // Assign the "url" property                            setProperty(pValues, "url", (const char*) cSrc);                            // Assign the "id" property                            setProperty(pValues, "id", "dummy_brush_07241965");                            // Assign the delay property                            pValues->SetPropertyULONG32("delay", 0);                            // Assign the duration property to 1ms                            pValues->SetPropertyULONG32("duration", 1);                                                        //Set the PersistentComponentID.                            pValues->SetPropertyULONG32("PersistentComponentID", m_ulPersistentComponentID);                            //Tell the core this we don't want any                            //TrackAdded callbacks because we don't                            //have any groups.                            pValues->SetPropertyULONG32("NoGroupsPresent", 1);                            // Add the "NullBrush" property to the request headers                            setProperty(pReqHeaders, "NullBrush", "1");                            // Get the current group                            IHXGroup* pGroup = NULL;                            pMgr->GetGroup(usGroup, pGroup);                            if (pGroup)

⌨️ 快捷键说明

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