smldoc.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:673k
- (float)fDur / 1000.0 );
- urlString += extraURLparams;
- extraURLparams = "";
- chDelimiter = '&';
- }
- if ((UINT32)-1 !=
- pElement->m_ulClipBegin)
- {
- extraURLparams.Format(
- "%cstart=%.3f", chDelimiter,
- (float)pElement->m_ulClipBegin/
- 1000.0 );
- urlString += extraURLparams;
- extraURLparams = "";
- chDelimiter = '&';
- }
- if ((UINT32)-1 !=
- pElement->m_ulClipEnd)
- {
- extraURLparams.Format(
- "%cend=%.3f", chDelimiter,
- (float)pElement->m_ulClipEnd/
- 1000.0 );
- urlString += extraURLparams;
- extraURLparams = "";
- chDelimiter = '&';
- }
- if (HXR_OK ==
- pChildPlayer->QueryInterface(
- IID_IHXPlayer2,
- (void**)&pPlayer2_Child))
- {
- IHXRequest* pRequest = NULL;
- IHXCommonClassFactory* pFactory=
- m_pParent->getFactory();
- if (pFactory)
- {
- IHXRequest* pRequest = NULL;
- pFactory->CreateInstance(
- CLSID_IHXRequest,
- (void**) &pRequest);
- if (pRequest)
- {
- pRequest->
- SetRequestHeaders(
- pValues);
- pRequest->SetURL((const
- char*)urlString);
- openrslt =
- pPlayer2_Child->
- OpenRequest(
- pRequest);
- }
- }
- }
- else // /No IHXPlayer2, so just call
- // OpenURL() & see what happens:
- {
- openrslt = pChildPlayer->
- OpenURL((const char*)
- urlString);
- }
- if (HXR_OK == openrslt)
- {
- pChildPlayer->Begin();
- }
- }
- }
- }
- }
- // Release the request parameters
- HX_RELEASE(pReqVal);
- }
- }
- }
- pValues->Release();
- }
- }
- cleanup:
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleSourceUpdate(CSmilSourceUpdate* pElement)
- {
- HX_RESULT rc = HXR_OK;
- const char* pszID = (const char*)pElement->m_srcID;
- // determine whether this source has been initialized yet...
- SMILPlayToAssoc* pPlayToAssoc = 0;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if(pThisAssoc->m_id == pszID &&
- // /Added this while re-fixing PR 69639; be sure to
- // ignore already-stopped track & keep looking in
- // case element restart made new track w/same id:
- !pThisAssoc->m_bTrackStopped)
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- if(pPlayToAssoc &&
- pPlayToAssoc->m_sourceMap.GetCount() > 0)
- {
- rc = doSourceUpdate(pPlayToAssoc, pElement);
- }
- else
- {
- // stick it into the deferred map,
- // it will be handled in RendererInitialized()
- if(!m_pDeferredSourceMap)
- {
- m_pDeferredSourceMap = new CHXMapStringToOb;
- }
-
- SMILDeferredSourceInfo* pInfo = new SMILDeferredSourceInfo;
- // /XXXEH- if duration is pure of delay, here, tell pInfo so (need pInfo to have new flag var):
- pInfo->m_ulDuration = pElement->m_ulUpdatedDuration;
- pInfo->m_ulDelay = 0;
- // /Fixes mem leak when pszID is already in the map:
- SMILDeferredSourceInfo* pTmpInfo;
- if (m_pDeferredSourceMap->Lookup(pszID, (void*&)pTmpInfo))
- {
- HX_DELETE(pTmpInfo);
- }
- (*m_pDeferredSourceMap)[pszID] = pInfo;
- }
- return rc;
- }
- // /Immediately removes a track that's associated with the source:
- // Returns HXR_OK only if the track was found and RemoveTrack(n)
- // succeeded:
- HX_RESULT CSmilDocumentRenderer::handleTrackRemoval(const char* pszID, INT32 nGroupNum)
- {
- HX_RESULT retVal = HXR_FAIL;
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- // First we have to check if this is an animation
- if (pszID && m_pAnimationMap)
- {
- void* pVoid = NULL;
- m_pAnimationMap->Lookup(pszID, pVoid);
- if (pVoid)
- {
- // Yes, this is an animation, so clear the return value
- retVal = HXR_OK;
- // Now call removeAnimation with this element
- CSmilAnimateElement* pAnim = (CSmilAnimateElement*) pVoid;
- removeAnimation(pAnim);
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- // If we are still currently in a failed state, then
- // it wasn't an animation.
- if (FAILED(retVal))
- {
- IHXGroup* pGroup = 0;
- if(m_pGroupMap &&
- m_pGroupMap->Lookup(nGroupNum, (void*&)pGroup))
- {
- // determine whether this source has been started yet:
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();
- i!=m_pPlayToAssocList->End();++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if (pThisAssoc->m_id == pszID &&
- // /Added this while re-fixing PR 69639; be sure to
- // ignore already-stopped track & keep looking in
- // case element restart made new track w/same id:
- !pThisAssoc->m_bTrackStopped)
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- if (pPlayToAssoc)
- {
- #if defined(_DEBUG) && defined(XXXEH_DEBUGOUT_TRACKSTOPPAUSERESUME)
- {
- FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "CSmilDocumentRenderer::handleTrackRemoval(ID=%s, group=%ld)n",
- (const char*)pszID, nGroupNum);
- ::fclose(f1);
- }
- #endif
- // /Fixes PR 81253: old value in m_pDeferredSourceMap
- // has old (first-play) duration so updateStreamTiming() was
- // getting called with that (now-wrong) value when
- // rendererInitialized() got called if this track restarted,
- // resulting in wrong presentation duration. So, remove old
- // reference to that element from the map here:
- if (m_pDeferredSourceMap)
- {
- SMILDeferredSourceInfo* pDeferredInfo = NULL;
- const char* pDeferredID = (const char*)pPlayToAssoc->m_id;
- if (m_pDeferredSourceMap->Lookup(pDeferredID,
- (void*&)pDeferredInfo))
- {
- CSmilElement* pThisElement =
- m_pSmilParser->findElement(pDeferredID);
- HX_ASSERT(pThisElement);
- HX_DELETE(pDeferredInfo);
- BOOL bRemovedKeyOK =
- m_pDeferredSourceMap->RemoveKey(pDeferredID);
- HX_ASSERT(bRemovedKeyOK);
- }
- }
- pPlayToAssoc->m_bRemovePending = TRUE;
- if (m_bInTrackDurationSetCall)
- {
- retVal = HXR_OK;
- // /Helps fix PR 66391: call RemoveTrack() later, after
- // TrackDurationSet() has finished, otherwise core crashes
- // when it continues to use the removed-and-deleted
- // pStream in SourceInfo::SetupRenderer():
- if (!m_pDeferrededRemoveTrackMap)
- {
- m_pDeferrededRemoveTrackMap = new CHXMapStringToOb();
- }
- if (m_pDeferrededRemoveTrackMap)
- {
- // /Don't add it if it's already in the map:
- if (!(*m_pDeferrededRemoveTrackMap)[pszID])
- {
- // /Add remove-track ID to the map for deferring
- // calling RemoveTrack() until the core is ready:
- CHXString* pCPNStrID = new CHXString(pszID);
- if (pCPNStrID)
- {
- (*m_pDeferrededRemoveTrackMap)[pszID] =
- (void*)pCPNStrID;
- }
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = pGroup->RemoveTrack(pPlayToAssoc->m_uTrackIndex);
- }
- }
- }
- }
- return retVal;
- }
- // /Immediately pauses a track that's associated with the source:
- // Returns HXR_OK only if the track was found and PauseTrack(n)
- // succeeded:
- // /pTimeVal gets created and filled with data that makes it a watcher
- // for the endEvent of the "pauser" so that the element getting paused
- // here can resume at that time, if and when it happens:
- HX_RESULT
- CSmilDocumentRenderer::handleTrackPausing(SMILNode* pNode,
- LONG32 lTimeOfPause,
- SMILPriorityClassPauseDisplay pauseDisplay,
- const char* pIdOfPauser)
- {
- HX_RESULT rc = HXR_FAILED;
- IHXGroup* pGroup = 0;
- if(m_pGroupMap &&
- m_pGroupMap->Lookup((INT32)pNode->m_nGroup, (void*&)pGroup))
- {
- // /QI for IHXGroup2
- IHXGroup2* pGroup2 = NULL;
- pGroup->QueryInterface(IID_IHXGroup2, (void**) &pGroup2);
- if (pGroup2)
- {
- // /Determine whether this source has been started yet:
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();
- i!=m_pPlayToAssocList->End();++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if(pThisAssoc->m_id == pNode->m_id &&
- // /Helps re-fix PR 69639; be sure to ignore
- // already-stopped track & keep looking in case
- // element restart made new track w/same id:
- !pThisAssoc->m_bTrackStopped)
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- if (pPlayToAssoc)
- {
- IHXTrack* pHXTrack = NULL;
- rc = pGroup2->GetIHXTrack(pPlayToAssoc->m_uTrackIndex,
- pHXTrack);
- if (pHXTrack)
- {
- #if defined(_DEBUG) && defined(XXXEH_DEBUGOUT_TRACKSTOPPAUSERESUME)
- {
- FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "CSmilDocumentRenderer::handleTrackPausing(ID=%s,"
- " timeOfPause=%ld, ID of pauser=%s)n",
- (const char*)pNode->m_id, lTimeOfPause, (const char*)pIdOfPauser);
- ::fclose(f1);
- }
- #endif
- rc = pHXTrack->Pause();
- // /Ceate a new SmilTimeValue watching for endEvent
- // on pIdOfPauser
- SmilTimeValue* pTimeVal = new SmilTimeValue(m_pContext,
- /* Don't care what start line is:*/ 0,
- pNode->m_pElement);
- if(pTimeVal)
- {
- CHXString pStr = pIdOfPauser;
- pStr += ".resumeEvent";
- HX_RESULT pnr1 = pTimeVal->parseValue(pStr,
- SMILSyncAttrBegin, (const char*)pNode->m_id);
- HX_RESULT pnr2= pTimeVal->setPauseTime(lTimeOfPause);
- HX_ASSERT(HXR_OK == pnr2);
- // /Note: this function takes care of getting rid of
- // any existing resumeEvent on this element; since it
- // can only be in the "resume stack" once:
- BOOL bOldResumeEventWasRemoved = FALSE;
- HX_RESULT rslt = m_pSmilParser->addResumeEvent(
- pTimeVal, bOldResumeEventWasRemoved);
- #if defined(_DEBUG)
- if (bOldResumeEventWasRemoved)
- {
- bOldResumeEventWasRemoved = 1;// /DEBUG-ONLY CODE
- }
- #endif
- }
- }
- HX_RELEASE(pHXTrack);
- }
- }
- HX_RELEASE(pGroup2);
- }
- return rc;
- }
- // /Immediately resumes a track that's associated with the source:
- // Returns HXR_OK only if the track was found and PlayTrack(n)
- // succeeded:
- HX_RESULT
- CSmilDocumentRenderer::handleTrackResuming(const char* pID, INT32 nGroupNum)
- {
- HX_RESULT rc = HXR_FAILED;
- IHXGroup* pGroup = 0;
- if(m_pGroupMap &&
- m_pGroupMap->Lookup(nGroupNum, (void*&)pGroup))
- {
- // /QI for IHXGroup2
- IHXGroup2* pGroup2 = NULL;
- pGroup->QueryInterface(IID_IHXGroup2, (void**) &pGroup2);
- if (pGroup2)
- {
- // /XXXEH- TODO: OPTIMIZATION: use "getPlayToAssocByMedia(pID)"
- // here instead (?):
- // /Determine whether this source has been started yet:
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();
- i!=m_pPlayToAssocList->End();++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if (pThisAssoc->m_id == pID &&
- // /Added this while re-fixing PR 69639; be sure to
- // ignore already-stopped track & keep looking in
- // case element restart made new track w/same id:
- !pThisAssoc->m_bTrackStopped)
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- HX_ASSERT(pPlayToAssoc);
- if (pPlayToAssoc)
- {
- IHXTrack* pHXTrack = NULL;
- rc = pGroup2->GetIHXTrack(pPlayToAssoc->m_uTrackIndex,
- pHXTrack);
- HX_ASSERT(pHXTrack);
- if (pHXTrack)
- {
- if (isMediaPausedAndDisabled(pID))
- {
- // /Handle un-blocking of mouse events and changing
- // site appearance back to normal:
- if (!reenablePausedAndDisabledMedia(pID,
- (UINT16)nGroupNum))
- {
- HX_ASSERT(0);
- }
- }
- // /XXXEH- TODO- OPTIMIZATION: only need to do this if
- // pauseDisplay == "hide" but we'll need a map for that,
- // as well:
- else
- {
- CSmilBasicRegion* pRegion = NULL;
- if(pPlayToAssoc)
- {
- // First, assume that pPlayTo is an id and see
- // if we can find the region by id:
- pRegion = getRegionByID(pPlayToAssoc->m_playTo);
- if (!pRegion)
- {
- // We didn't find it by id, so try to find it
- // by regionName:
- pRegion = getFirstRegionByName(
- pPlayToAssoc->m_playTo);
- }
- }
- if (pRegion && m_pSiteInfoList)
- {
- CHXSimpleList::Iterator i =
- m_pSiteInfoList->Begin();
- for(; i != m_pSiteInfoList->End(); ++i)
- {
- SMILSiteInfo* pSiteInfo =(SMILSiteInfo*)(*i);
- if(pSiteInfo->m_uGroupIndex ==
- m_uCurrentGroupIndex &&
- pSiteInfo->m_MediaID ==
- pPlayToAssoc->m_id)
- {
- IHXSite* pRegionSite = NULL;
- CSmilBasicRegion* pCurRegion =
- getRegionByID(
- pSiteInfo->m_regionID);
- if (pCurRegion != pRegion)
- {
- HX_ASSERT(pRegion);
- continue;
- }
- // /Helps fix PR 81510 (& dup. PR 83796):
- // z-ordering code can put it at top of
- // z-order of siblings who have already
- // played to same region or otherwise have
- // same z-index, by looking at this value:
- if (m_ulCurrentTime > 0)
- {
- pSiteInfo->m_ulResumeTime =
- m_ulCurrentTime-1;
- }
- if(pRegion->m_eBackgroundColorType ==
- CSS2TypeTransparent)
- {
- pRegionSite =
- pSiteInfo->m_pRegionSite;
- }
- // /Show site as it resumes:
- CSmilShowSiteEvent* pShowEvent =
- new CSmilShowSiteEvent(
- pPlayToAssoc->m_uGroupIndex,
- // /Add a few millisec so it
- // won't re-hide when it starts:
- m_ulCurrentTime + 10,
- pSiteInfo->m_pRendererSite,
- pRegion->m_pSite,
- TRUE, // /ShowSite=TRUE
- FALSE,
- this,
- pPlayToAssoc->m_id,
- pRegion->m_region,
- pRegion->m_eShowBackground);
- insertEvent(pShowEvent);
- }
- }
- }
- }
- #if defined(_DEBUG) && defined(XXXEH_DEBUGOUT_TRACKSTOPPAUSERESUME)
- {
- FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "CSmilDocumentRenderer::handleTrackResuming(ID=%s, group=%ld)n",
- (const char*)pID, nGroupNum);
- ::fclose(f1);
- }
- #endif
- rc = pHXTrack->Begin();
- }
- HX_RELEASE(pHXTrack);
- }
- }
- HX_RELEASE(pGroup2);
- }
- return rc;
- }
- HX_RESULT CSmilDocumentRenderer::handleEndLayout(CSmilEndLayout* pElement)
- {
- HX_RESULT retVal = HXR_OK;
- // Set the flag saying we DO have a <layout> element
- m_bLayoutElementPresent = TRUE;
- // Decide if we have an "empty layout" condition, which
- // is where we just have:
- // <layout>
- // </layout>
- // but nothing inside it. So therefore we have empty layout
- // if at this point all of the following are true:
- // a) we have no <root-layout> element
- // b) we have no <region> elements
- // c) we have no <regPoint> elements
- // d) we have no <topLayout> elements
- if ((!m_pRegionMap ||
- (m_pRegionMap && m_pRegionMap->GetCount() == 0)) &&
- (!m_pRootLayout ||
- (m_pRootLayout && !m_pRootLayout->IsRootLayoutElementPresent())) &&
- (!m_pRegPointMap ||
- (m_pRegPointMap && m_pRegPointMap->GetCount() == 0)) &&
- (!m_pViewportList ||
- (m_pViewportList && m_pViewportList->GetCount() == 0)))
- {
- m_bEmptyLayout = TRUE;
- }
- // Decide if we need to set up the root-layout at
- // this point or later. We should only attempt to
- // setup the root layout here if either: a) both
- // root layout width and height are valid; OR
- // b) we have some <region> children of the root layout
- // defined. If we have (a), we know we will succeed,
- // but if (b) we may or may not succeed.
- if (m_pRootLayout &&
- ((m_pRootLayout->IsWidthSet() &&
- m_pRootLayout->IsHeightSet()) ||
- (m_pRootLayout->m_pChildList &&
- m_pRootLayout->m_pChildList->GetCount() > 0)))
- {
- // We need to attempt to set up the root layout
- // without yet assigning defaults
- HX_RESULT rv = setupRootLayout(FALSE);
- if (SUCCEEDED(rv))
- {
- // Set the flag saying we've done the
- // root-layout setup
- m_bIsRootLayoutSetup = TRUE;
- }
- else
- {
- // Ok, we have regions which are children
- // of the root-layout, but we could not
- // groc the size of the root-layout from
- // the regions. So we will try again, this
- // time assigning defaults if necessary.
- // This should succeed.
- rv = setupRootLayout(TRUE);
- if (SUCCEEDED(rv))
- {
- // Set the flag saying we've done the
- // root-layout setup
- m_bIsRootLayoutSetup = TRUE;
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- // Decide if we need to do viewport setup here.
- // We should only attempt to do viewport setup
- // here if, of course, there is at least one
- // viewport defined.
- if (m_pViewportList &&
- m_pViewportList->GetCount() > 0)
- {
- // Setup any viewports
- HX_RESULT rv = setupViewports();
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- return retVal;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleMeta(CSmilMeta* pElement)
- {
- HX_RESULT rc = HXR_OK;
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- IHXGroupManager* pMgr = NULL;
- IHXValues* pValues = NULL;
- if(pElement->m_name.GetLength() > 0)
- {
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, (void**)&pMgr))
- {
- pValues = pMgr->GetPresentationProperties();
- if(!pValues)
- {
- pValues = new CHXOrderedValues;
- pValues->AddRef();
- pMgr->SetPresentationProperties(pValues);
- }
- IHXBuffer* pBuf = new CHXBuffer;
- pBuf->AddRef();
- pBuf->Set((BYTE*)(const char*)pElement->m_content,
- pElement->m_content.GetLength()+1);
- pValues->SetPropertyCString((const char*)pElement->m_name,
- pBuf);
- pBuf->Release();
- pValues->Release();
- pMgr->Release();
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleMetadata(CSmilMetadata* pElement)
- {
- HX_RESULT rc = HXR_OK;
- if (m_bMetadataPassedOffAlready) // /We send all metadata in one big chunk.
- {
- return rc;
- }
- m_bMetadataPassedOffAlready = TRUE;
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- IHXGroupManager* pMgr = NULL;
- IHXValues* pValues = NULL;
- if(m_metadata.GetLength() > 0)
- {
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, (void**)&pMgr))
- {
- pValues = pMgr->GetPresentationProperties();
- if(!pValues)
- {
- pValues = new CHXOrderedValues;
- pValues->AddRef();
- pMgr->SetPresentationProperties(pValues);
- }
- IHXBuffer* pBuf = new CHXBuffer;
- pBuf->AddRef();
- pBuf->Set((BYTE*)(const char*)m_metadata,
- m_metadata.GetLength()+1);
- pValues->SetPropertyCString("metadata", pBuf);
- pBuf->Release();
- pValues->Release();
- pMgr->Release();
- }
- }
- #if defined (XXX_DUMP_METADATA_TO_FILE)
- {FILE* f = ::fopen("c:\temp\metadata.txt", "w");
- if (f)
- {
- ::fprintf(f,"METADATA:{{{n%sn}}}n", (const char*)m_metadata);
- ::fclose(f);
- }
- }
- #endif
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleRendererPreFetch(CSmilRendererPreFetch *pRend)
- {
- HX_RESULT rc = HXR_OK;
- const char* pMimeType = (const char*)pRend->m_mimeType;
- IHXRendererUpgrade* pUpgrade = 0;
- if(m_pContext)
- {
- IHXSystemRequired* pISystemRequired = NULL;
- m_pContext->QueryInterface(IID_IHXSystemRequired,
- (void**)&pISystemRequired);
- CHXBuffer* pBuffer = new CHXBuffer;
- pBuffer->AddRef();
- pBuffer->Set((BYTE*)pMimeType, strlen(pMimeType)+1);
- if (pISystemRequired)
- {
- IHXUpgradeCollection* pUpgradeCollection = NULL;
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer)
- pPlayer->QueryInterface(IID_IHXUpgradeCollection, (void**)&pUpgradeCollection);
- if(pUpgradeCollection)
- {
- pUpgradeCollection->Add(eUT_Required, pBuffer, 0, 0);
- // HasFeatures() calls removes all existing features from pUpgradeCollection.
- pISystemRequired->HasFeatures(pUpgradeCollection);
- }
- HX_RELEASE(pUpgradeCollection);
- HX_RELEASE(pISystemRequired);
- }
- HX_RELEASE(pBuffer);
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::insertEvent(CSmilLayoutEvent* pEvent)
- {
- const char* pszMediaID = "NULL";
- const char* pszRegionID = "NULL";
- if (pEvent &&
- (pEvent->m_type == CSmilLayoutEvent::eShowSite ||
- pEvent->m_type == CSmilLayoutEvent::eHideSite))
- {
- CSmilShowSiteEvent* pShow = (CSmilShowSiteEvent*) pEvent;
- pszMediaID = pShow->getMediaID();
- pszRegionID = pShow->getRegionID();
- }
- MLOG_EVENT(m_pErrorMessages,
- "insertEvent() (%s,%lu,%u,%lu,%lu,%s,%s) tick=%lun",
- pEvent->getEventTypeName(),
- pEvent->m_ulEventTime,
- pEvent->m_uGroupIndex,
- pEvent->m_bOnlyHideSite,
- pEvent->m_bIgnorEvent,
- pszMediaID,
- pszRegionID,
- HX_GET_BETTERTICKCOUNT());
- if(!m_pEventList)
- {
- m_pEventList = new CHXSimpleList;
- }
- LISTPOSITION lPos = m_pEventList->GetHeadPosition();
- LISTPOSITION lPrev = lPos;
- BOOL bInserted = FALSE;
- BOOL bFoundOurShow = FALSE;
- while(lPos)
- {
- CSmilLayoutEvent* pThisEvent =
- (CSmilLayoutEvent*)m_pEventList->GetNext(lPos);
- if((pThisEvent->m_type == CSmilLayoutEvent::eShowSite ||
- pThisEvent->m_type == CSmilLayoutEvent::eHideSite) &&
- pThisEvent->m_ulEventTime == pEvent->m_ulEventTime &&
- pThisEvent->getRegionSite() == pEvent->getRegionSite())
- {
- if(pEvent->m_type == CSmilLayoutEvent::eShowSite)
- {
- if(!lPos)
- {
- m_pEventList->AddTail(pEvent);
- bInserted = TRUE;
- break;
- }
- // find position of last 'hide' event at this time
- // move past all non show events at this time...
- while(lPos &&
- pThisEvent->m_ulEventTime == pEvent->m_ulEventTime &&
- pThisEvent->getRegionSite() == pEvent->getRegionSite() &&
- pThisEvent->m_type != CSmilLayoutEvent::eShowSite)
- {
- lPrev = lPos;
- pThisEvent = (CSmilLayoutEvent*)m_pEventList->GetNext(lPos);
- }
- }
- // move past any Transition events at this time...
- while (lPos &&
- pThisEvent->m_ulEventTime == pEvent->m_ulEventTime &&
- (pThisEvent->m_type == CSmilLayoutEvent::eBeginTransition ||
- pThisEvent->m_type == CSmilLayoutEvent::eEndTransition) )
- {
- lPrev = lPos;
- pThisEvent = (CSmilLayoutEvent*)m_pEventList->GetNext(lPos);
- }
-
- m_pEventList->InsertBefore(lPrev, pEvent);
- bInserted = TRUE;
- break;
- }
- if ((pEvent->m_type == CSmilLayoutEvent::eBeginTransition ||
- pEvent->m_type == CSmilLayoutEvent::eEndTransition) &&
- pThisEvent->m_ulEventTime == pEvent->m_ulEventTime)
- {
- // we want transitions to be put before this event..
- m_pEventList->InsertBefore(lPrev, pEvent);
- bInserted = TRUE;
- break;
- }
- else if(pThisEvent->m_ulEventTime > pEvent->m_ulEventTime)
- {
- if (pEvent->m_type == CSmilLayoutEvent::eHideSite)
- {
- // if we are a hide event, check to see if there is
- // a hide event in the future for our same region, and
- // a different renderer site, if so, modifiy this
- // event so it will only hide the renderer...
- // lPos -- position of pThisEvent (past were we want to be inserted)
- // lPrev -- start here so we will also consider pThisEvent..
- LISTPOSITION next = lPrev;
- while (next)
- {
- CSmilLayoutEvent* pFutureEvent = (CSmilLayoutEvent*)m_pEventList->GetAt(next);
-
- if (pFutureEvent->getRegionSite() == pEvent->getRegionSite() &&
- pFutureEvent->getRendererSite() != pEvent->getRendererSite())
- {
- if (pFutureEvent->m_type == CSmilLayoutEvent::eHideSite)
- {
- pEvent->m_bOnlyHideSite = TRUE;
- break;
- }
- // as soon as we find a show event for this same region
- // and a different site, we can stop.
- else if (pFutureEvent->m_type == CSmilLayoutEvent::eShowSite)
- {
- break;
- }
- }
- m_pEventList->GetNext(next);
- }
- }
-
- m_pEventList->InsertBefore(lPrev, pEvent);
- bInserted = TRUE;
- break;
- }
- else if (pEvent->m_type == CSmilLayoutEvent::eHideSite &&
- pThisEvent->m_type == CSmilLayoutEvent::eShowSite &&
- pThisEvent->getRegionSite() == pEvent->getRegionSite() &&
- pThisEvent->getRendererSite() == pEvent->getRendererSite())
- {
- // note that we have passed the show event for our site
- bFoundOurShow = TRUE;
- }
- else if (pEvent->m_type == CSmilLayoutEvent::eHideSite &&
- pThisEvent->m_type == CSmilLayoutEvent::eHideSite &&
- pThisEvent->getRegionSite() == pEvent->getRegionSite() &&
- pThisEvent->getRendererSite() != pEvent->getRendererSite()
- && bFoundOurShow)
- {
- // if we are inserting a hide event, after the current hide event,
- // and the current hide event goes to the same region as the current
- // hide event, && the renderer sites are different, then we need
- // to modify this event so that it does not hide the region's site...
- pThisEvent->m_bOnlyHideSite = TRUE;
- }
- lPrev = lPos;
- }
- if(!bInserted)
- {
- // not inserted, stick it on the end of the list
- m_pEventList->AddTail(pEvent);
- }
- // set list position member
- m_ulEventListPosition = m_pEventList->GetHeadPosition();
- MLOG_EVENT(m_pErrorMessages, "tdumping event queue after insertionn");
- // DumpEventQueue();
- return HXR_OK;
- }
- CSmilShowSiteEvent* CSmilDocumentRenderer::getShowHideEvent(const char* pszMediaID,
- const char* pszRegionID,
- BOOL bShowEvent)
- {
- CSmilShowSiteEvent* pRet = NULL;
- if (m_pEventList && pszMediaID && pszRegionID)
- {
- LISTPOSITION pos = m_pEventList->GetHeadPosition();
- while (pos)
- {
- CSmilLayoutEvent* pEvent =
- (CSmilLayoutEvent*) m_pEventList->GetNext(pos);
- if (pEvent &&
- (pEvent->m_type == CSmilLayoutEvent::eShowSite ||
- pEvent->m_type == CSmilLayoutEvent::eHideSite))
- {
- CSmilShowSiteEvent* pShowEvent = (CSmilShowSiteEvent*) pEvent;
- if (pShowEvent->getShowSite() == bShowEvent &&
- !strcmp(pszMediaID, pShowEvent->getMediaID()) &&
- !strcmp(pszRegionID, pShowEvent->getRegionID()))
- {
- pRet = pShowEvent;
- break;
- }
- }
- }
- }
- return pRet;
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- CSmilAnimateEvent* CSmilDocumentRenderer::getAnimateEvent(CSmilAnimateElement* pAnim)
- {
- CSmilAnimateEvent* pRet = NULL;
- if (m_pEventList && pAnim)
- {
- LISTPOSITION pos = m_pEventList->GetHeadPosition();
- while (pos)
- {
- CSmilLayoutEvent* pEvent =
- (CSmilLayoutEvent*) m_pEventList->GetNext(pos);
- if (pEvent &&
- pEvent->m_type == CSmilLayoutEvent::eAnimate)
- {
- CSmilAnimateEvent* pAnimEvent = (CSmilAnimateEvent*) pEvent;
- if (pAnimEvent->isSameElement(pAnim))
- {
- pRet = pAnimEvent;
- break;
- }
- }
- }
- }
- return pRet;
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- void CSmilDocumentRenderer::removeEvent(CSmilLayoutEvent* pEvent)
- {
- if (pEvent && m_pEventList)
- {
- LISTPOSITION pos = m_pEventList->GetHeadPosition();
- while (pos)
- {
- CSmilLayoutEvent* pListEvent =
- (CSmilLayoutEvent*) m_pEventList->GetAt(pos);
- if (pListEvent == pEvent)
- {
- m_pEventList->RemoveAt(pos);
- break;
- }
- m_pEventList->GetNext(pos);
- }
- }
- }
- HX_RESULT
- CSmilDocumentRenderer::insertSiteInfo(void* pVoidInfo)
- {
- if(!m_pSiteInfoList)
- {
- m_pSiteInfoList = new CHXSimpleList;
- }
- SMILSiteInfo* pInfo = (SMILSiteInfo*)pVoidInfo;
- LISTPOSITION lPos = m_pSiteInfoList->GetHeadPosition();
- LISTPOSITION lPrev = lPos;
- BOOL bInserted = FALSE;
- while(lPos)
- {
- SMILSiteInfo* pThisInfo =
- (SMILSiteInfo*)m_pSiteInfoList->GetNext(lPos);
- if(pThisInfo->m_ulDelay > pInfo->m_ulDelay)
- {
- m_pSiteInfoList->InsertBefore(lPrev, pInfo);
- bInserted = TRUE;
- break;
- }
- lPrev = lPos;
- }
- if(!bInserted)
- {
- // not inserted, stick it on the end of the list
- m_pSiteInfoList->AddTail(pInfo);
- }
- return HXR_OK;
- }
- void CSmilDocumentRenderer::removeSiteInfo(SMILSiteInfo* pSiteInfo)
- {
- if (m_pSiteInfoList && pSiteInfo)
- {
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo =
- (SMILSiteInfo*) m_pSiteInfoList->GetAt(pos);
- if (pInfo == pSiteInfo)
- {
- m_pSiteInfoList->RemoveAt(pos);
- break;
- }
- m_pSiteInfoList->GetNext(pos);
- }
- }
- }
- HX_RESULT
- CSmilDocumentRenderer::onTimeSync(UINT32 ulTimeValue)
- {
- MLOG_TIMESYNC(m_pErrorMessages, "onTimeSync(%lu) tick=%lun", ulTimeValue,
- HX_GET_BETTERTICKCOUNT());
- HX_RESULT rc = HXR_OK;
- m_ulCurrentTime = ulTimeValue;
- if(!m_bFirstTimeSync)
- {
- // draw background and regions
- m_bFirstTimeSync = TRUE;
- // now I should force a background redraw...
- if(m_pRootLayout->m_pSite)
- {
- forceFullRedraw(m_pRootLayout->m_pSite);
- if(m_pRegionMap)
- {
- CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
- for(; i != m_pRegionMap->End(); ++i)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*)(*i);
- if (pRegion)
- {
- forceFullRedraw(pRegion->m_pSite);
- }
- }
- }
- }
- }
- rc = flushAllEvents( ulTimeValue, TRUE );
- // /Helps fix PR 66391: it should now be OK to call RemoveTrack() on each
- // track that was added and subsequently found to begin too late to play
- // once its parent's duration became resolved:
- if (m_pDeferrededRemoveTrackMap)
- {
- CHXMapStringToOb::Iterator i = m_pDeferrededRemoveTrackMap->Begin();
- for(; i != m_pDeferrededRemoveTrackMap->End(); ++i)
- {
- CHXString* pID = (CHXString*)(*i);
- // Get the playTo for this media and then the group and track#:
- SMILPlayToAssoc* pPlayToAsso = pID?
- // /Changing to (*pID) instead of (pID) properly fixes
- // PR 66391 which wasn't working for implicit IDs. It's a
- // bit scary that the prior code *worked* for explicit IDs
- // which were stored in the smallString of the CHXString:
- getPlayToAssocByMedia((const char*)(*pID)) : NULL;
- HX_ASSERT(pPlayToAsso);
- if (pPlayToAsso)
- {
- UINT16 usGroup = pPlayToAsso->m_uGroupIndex;
- IHXGroup* pGroup = 0;
- if (m_pGroupMap && m_pGroupMap->Lookup(usGroup, (void*&)pGroup))
- {
- HX_RESULT pnrRemoveTrackRetVal =
- pGroup->RemoveTrack(pPlayToAsso->m_uTrackIndex);
- HX_ASSERT(HXR_OK == pnrRemoveTrackRetVal);
- }
- }
- HX_DELETE(pID); // /Whole list gets deleted, below.
- }
- // /Delete the whole list:
- HX_DELETE(m_pDeferrededRemoveTrackMap);
- }
- if (m_pActiveTransitions)
- {
- // cycle through all the active transitions...
- LISTPOSITION lpos = m_pActiveTransitions->GetHeadPosition();
- while (lpos)
- {
- SMILTransitionState* pState =
- (SMILTransitionState*)m_pActiveTransitions->GetAt(lpos);
- if (ulTimeValue < pState->m_ulEndTime)
- {
- doTransition(lpos, ulTimeValue);
- m_pActiveTransitions->GetNext(lpos);
- }
- else
- {
- doTransition(lpos, pState->m_ulEndTime);
- lpos = m_pActiveTransitions->RemoveAt(lpos);
- HX_RELEASE(pState->m_pSiteTransition);
- HX_DELETE(pState);
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- // We want to cap the time at the duration of
- // the current group - we don't want to send
- // a timesync that is greater than the duration.
- UINT32 ulAnimTime = ulTimeValue;
- if (ulAnimTime > m_ulCurGroupDuration &&
- m_ulCurGroupDuration > 0)
- {
- ulAnimTime = m_ulCurGroupDuration;
- }
- // Do all the active animations
- if (m_pActiveAnimations && m_pActiveAnimations->GetCount() > 0)
- {
- if (atLeastOneActiveAnimation(ulAnimTime))
- {
- if (!isSiteCompositionModeON())
- {
- turnSiteCompositionModeON();
- }
- }
- // m_pAnimSiteRedrawMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- // m_pAnimRegionRecomputeMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // m_pAnimTopLayoutMap is a collection of topLayout's
- // which have been animated programmatically and
- // need resizing.
- if (m_pAnimTopLayoutMap)
- {
- m_pAnimTopLayoutMap->RemoveAll();
- }
- // Clear the animate root layout flag
- m_bAnimateRootLayout = FALSE;
- // If there is a soundlevel animation going on, then
- // we need to try to grab the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- // Send this time to all active animations
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pInfo = (CSmilAnimateInfo*) m_pActiveAnimations->GetAt(pos);
- if (pInfo && pInfo->m_pSandwich &&
- pInfo->m_pSandwich->GetAttributeName() != kAttrNameSoundLevel)
- {
- // Execute the animation at this time
- doAnimation(pInfo, ulAnimTime);
- // Are there any layers left in the sandwich?
- if (pInfo->m_pSandwich->GetNumLayers())
- {
- // There are still some layers left, so
- // leave the sandwich alone and just advance
- // to the next animation
- m_pActiveAnimations->GetNext(pos);
- }
- else
- {
- // There are no more layers left in the
- // sandwich, so this animation is done. So,
- // we need to restore whatever original values
- // were present
- setValue(pInfo, pInfo->m_pUnder, pInfo->m_pDepend, TRUE);
- // Now we need to delete this info object
- HX_DELETE(pInfo);
- // And remove it from the list
- // We have to do the following hack since
- // CHXSimpleList does not advance the position to
- // NULL if you RemoveAt() the last element in the list.
- BOOL bLast = (m_pActiveAnimations->GetAt(pos) ==
- m_pActiveAnimations->GetTail());
- pos = m_pActiveAnimations->RemoveAt(pos);
- if (bLast && pos)
- {
- m_pActiveAnimations->GetNext(pos);
- }
- }
- }
- else
- {
- m_pActiveAnimations->GetNext(pos);
- }
- }
- // If there is a soundlevel animation going on, then
- // we can now release the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Unlock();
- // Recompute the root-layout if necessary
- if (m_bAnimateRootLayout && m_pRootLayout && m_pRootLayout->m_pRoot)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(m_pRootLayout->m_pRoot->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(m_pRootLayout->m_pRoot->m_dHeight + 0.5);
- SiteSizeChanged(m_pRootLayout->m_pSite, &cNewRootSize);
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- // Animate any topLayout's
- if (m_pAnimTopLayoutMap &&
- m_pAnimTopLayoutMap->GetCount() > 0)
- {
- POSITION mpos = m_pAnimTopLayoutMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimTopLayoutMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicViewport* pVP = (CSmilBasicViewport*) pKey;
- if (pVP && pVP->m_pPort)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(pVP->m_pPort->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(pVP->m_pPort->m_dHeight + 0.5);
- SiteSizeChanged(pVP->m_pSite, &cNewRootSize);
- }
- }
- }
- // Clear the map
- m_pAnimTopLayoutMap->RemoveAll();
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- // We've collected all the regions for which
- // we need to call recomputeBoxLayout()
- if (m_pAnimRegionRecomputeMap)
- {
- POSITION mpos = m_pAnimRegionRecomputeMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimRegionRecomputeMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pKey;
- recomputeBoxLayout(pRegion, TRUE);
- }
- }
- // Clear the map
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // We've collected all the sites which need
- // a ForceRedraw(), so do that now
- if (m_pAnimSiteRedrawMap)
- {
- POSITION mpos = m_pAnimSiteRedrawMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimSiteRedrawMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- IHXSite* pSite = (IHXSite*) pKey;
- forceFullRedraw(pSite);
- }
- }
- // Clear the map
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- unlockSiteComposition();
- bltSiteComposition();
- lockSiteComposition();
- }
- if (!atLeastOneActiveAnimation(ulAnimTime))
- {
- if (isSiteCompositionModeON())
- {
- turnSiteCompositionModeOFF();
- // forceFullRecursiveRedraw(m_pRootLayout);
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- BOOL bSomeElementScheduleWasChanged = FALSE;
- CHXSimpleList pauseDisplayHideElementList;
- CHXSimpleList pauseDisplayDisableElementList;
- if (m_pHandlePendingSchedulingCallback &&
- m_pHandlePendingSchedulingCallback->m_bIsCallbackPending)
- {
- m_pHandlePendingSchedulingCallback->m_bIsCallbackPending = FALSE;
- m_pScheduler->Remove(m_pHandlePendingSchedulingCallback->m_PendingHandle);
- m_pHandlePendingSchedulingCallback->m_PendingHandle = 0;
- }
- HX_RESULT tmprslt =
- m_pSmilParser->handlePendingScheduling(m_ulCurrentTime,
- m_uCurrentGroupIndex,
- bSomeElementScheduleWasChanged,
- &pauseDisplayHideElementList,
- &pauseDisplayDisableElementList);
- if (SUCCEEDED(tmprslt) && bSomeElementScheduleWasChanged)
- {
- CHXSimpleList* pWhichList = NULL;
- BOOL bDoHide = TRUE;
- if (!pauseDisplayHideElementList.IsEmpty())
- {
- pWhichList = &pauseDisplayHideElementList;
- bDoHide = TRUE;
- }
- else if (!pauseDisplayDisableElementList.IsEmpty())
- {
- pWhichList = &pauseDisplayDisableElementList;
- bDoHide = FALSE;
- }
- if (pWhichList)
- {
- LISTPOSITION listPos =
- pWhichList->GetHeadPosition();
- while (listPos)
- {
- LISTPOSITION lPosOfCurTmpVal = listPos;
- // /Gets val at listPos and then moves listPos to next node:
- CHXString* pCStrId = (CHXString*)pWhichList->GetNext(listPos);
- if (pCStrId)
- {
- SMILPlayToAssoc* pPlayToAssoc = getPlayToAssocByMedia(
- (const char*)(*pCStrId));
- CSmilBasicRegion* pRegion = NULL;
- if(pPlayToAssoc)
- {
- // First, assume that pPlayTo is an id and see
- // if we can find the region by id:
- pRegion = getRegionByID(pPlayToAssoc->m_playTo);
- if (!pRegion)
- {
- // We didn't find it by id, so try to find it
- // by regionName:
- pRegion = getFirstRegionByName(
- pPlayToAssoc->m_playTo);
- }
- }
- HX_ASSERT(pRegion && m_pSiteInfoList);
- if (pRegion)
- {
- if(m_pSiteInfoList)
- {
- CHXSimpleList::Iterator i =
- m_pSiteInfoList->Begin();
- for(; i != m_pSiteInfoList->End(); ++i)
- {
- SMILSiteInfo* pSiteInfo =(SMILSiteInfo*)(*i);
- if(pSiteInfo->m_uGroupIndex ==
- m_uCurrentGroupIndex &&
- pSiteInfo->m_MediaID ==
- pPlayToAssoc->m_id)
- {
- IHXSite* pRegionSite = NULL;
- CSmilBasicRegion* pCurRegion =
- getRegionByID(
- pSiteInfo->m_regionID);
- if (pCurRegion != pRegion)
- {
- HX_ASSERT(pRegion);
- continue;
- }
- if(pRegion->m_eBackgroundColorType ==
- CSS2TypeTransparent)
- {
- pRegionSite =
- pSiteInfo->m_pRegionSite;
- }
- if (bDoHide)
- {
- // /Hide site while it's paused:
- CSmilShowSiteEvent* pHideEvent =
- new CSmilShowSiteEvent(
- pPlayToAssoc->m_uGroupIndex,
- // /Add a few millisec so it
- // won't "unhide" when other
- // track starts (fixes
- // PR 50708):
- m_ulCurrentTime + 10,
- pSiteInfo->m_pRendererSite,
- pRegion->m_pSite,
- FALSE, // /ShowSite=FALSE
- FALSE,
- this,
- pPlayToAssoc->m_id,
- pRegion->m_region,
- pRegion->m_eShowBackground);
- insertEvent(pHideEvent);
- // /Note: don't break here as there
- // might be multiple sites to which
- // this media is currently playing:
- }
- else // /pauseDisplay == "disable":
- {
- #if defined(XXXEH_NEED_TO_ADD_51_PRCNT_OPAQUE_SITE_ON_TOP_TO_DISABLE)
- // /Create a child of the region site
- IHXSite* pTempSite = NULL;
- HX_RESULT retVal = pSiteInfo->
- m_pRendererSite->CreateChild(
- pTempSite);
- if (SUCCEEDED(retVal))
- {
- // /Add the site to the manager:
- retVal = m_pSiteMgr->AddSite(
- pTempSite);
- HXxSize cSize;
- pSiteInfo->m_pRendererSite->GetSize(cSize);
- HXxPoint cPos;
- pSiteInfo->m_pRendererSite->GetPosition(cPos);
- pTempSite->SetSize(cSize);
- pTempSite->SetPosition(cPos);
- if (SUCCEEDED(retVal))
- {
- showSite(pTempSite, TRUE);
- // /Do we need to do this too?!:
- HXxRect cRect = {0, 0, cSize.cx, cSize.cy};
- pTempSite->DamageRect(cRect);
- pTempSite->ForceRedraw();
- }
- }
- #else /* Otherwise just disable the site so it won't handle mouse events: */
- /*Also, QI the renderer site for IHXVideoControl (YUV renderers only)
- and adjust the brightness down by 50% */
- // /Put media ID into the map:
- if(!m_pPausedAndDisabledIDMap)
- {
- m_pPausedAndDisabledIDMap =
- new CHXMapStringToOb;
- }
-
- CHXString* pCStr = new CHXString;
- const char* pID = (const char*)
- (*pCStrId);
- if (pCStr)
- {
- *pCStr = pID;
- // /Prevents mem leak when pID is
- // already in the map:
- CHXString* pTmpCStr;
- if (m_pPausedAndDisabledIDMap->
- Lookup(pID,
- (void*&)pTmpCStr))
- {
- HX_DELETE(pTmpCStr);
- }
- (*m_pPausedAndDisabledIDMap)[pID] =
- pCStr;
- }
- // /Now, adjust the brightness of the
- // site if we can:
- IHXVideoControl* pVidCntrls = NULL;
- HX_RESULT pnrVC =
- pSiteInfo->m_pRendererSite->
- QueryInterface(IID_IHXVideoControl,
- (void**)&pVidCntrls);
- if (SUCCEEDED(pnrVC))
- {
- // /Save this and reset it in
- // during handleTrackResuming():
- float fBrightness =
- pVidCntrls->GetBrightness();
- // /Put media ID into the map:
- if(!m_pPausedAndDisabledBrightnessMap)
- {
- m_pPausedAndDisabledBrightnessMap =
- new CHXMapStringToOb;
- }
-
- float* pfPrePauseBrightness =
- new float;
- if (pfPrePauseBrightness)
- {
- *pfPrePauseBrightness =
- fBrightness;
- // /Prevents mem leak when pID
- // is already in the map:
- float* pfTmp;
- if (m_pPausedAndDisabledBrightnessMap->
- Lookup(pID,
- (void*&)pfTmp))
- {
- HX_DELETE(pfTmp);
- }
- (*m_pPausedAndDisabledBrightnessMap)[pID] =
- pfPrePauseBrightness;
- }
- float fPausedBrightness =
- (fBrightness < -25? -90:
- fBrightness - 75);
- HX_RESULT rsltSetBrtness =
- pVidCntrls->SetBrightness(
- fPausedBrightness);
- pSiteInfo->m_pRendererSite->
- ForceRedraw();
- HX_RELEASE(pVidCntrls);
- }
- #endif
- }
- }
- }
- }
- }
- }
- // /Remove it from the list:
- HX_DELETE(pCStrId);
- pWhichList->RemoveAt(lPosOfCurTmpVal);
- }
- }
- handleElements();
- }
- if (SUCCEEDED(rc))
- {
- rc = tmprslt;
- }
- // /Don't do this at time zero otherwise current player doesn't have
- // time to get up and running:
- if (m_ulCurrentTime > 100)
- {
- // /findNextPendingOnLoadURL finds next "automatic" hyperlink, i.e.,
- // hyperlink whose a/anchor/area tags has 'actuate="onLoad"' in it:
- CHXMapStringToOb* pMapOfAnchorsToLaunchAtCurTime =
- m_pSmilParser->findNextPendingOnLoadURL(m_ulCurrentTime);
- if (pMapOfAnchorsToLaunchAtCurTime)
- {
- // /Now, go through all onLoad anchors found and launch them all:
- CHXMapStringToOb::Iterator i =
- pMapOfAnchorsToLaunchAtCurTime->Begin();
- for(; i != pMapOfAnchorsToLaunchAtCurTime->End(); ++i)
- {
- CSmilAAnchorElement* pAnchor = (CSmilAAnchorElement*)(*i);
- if (!pAnchor)
- {
- HX_ASSERT(pAnchor);
- continue;
- }
- // /NOTE: be sure to do the following LAST in this function in
- // case the launching of an URL replaces this smlrendr instance.
- // /Launch the URL;
- HX_RESULT rcHLT = handleHyperlinkTraversal(pAnchor);
- }
- HX_DELETE(pMapOfAnchorsToLaunchAtCurTime);
- }
- }
- return rc;
- }
- void
- CSmilDocumentRenderer::RemoveEvents(UINT32 ulGroupIndex, IHXSite* pSite)
- {
- // handle all events up to time ulFlushToTime + ulGranularity
- HX_RESULT rc = HXR_OK;
- if(m_pEventList)
- {
- LISTPOSITION lPos = m_pEventList->GetHeadPosition();
- while(lPos && m_pEventList->GetCount())
- {
- // handle all events at or before ulTimeValue
- CSmilLayoutEvent* pEvent = (CSmilLayoutEvent*)m_pEventList->GetAt(lPos);
- if(pEvent->m_uGroupIndex == ulGroupIndex &&
- pEvent->getRendererSite() == pSite)
- {
- HX_DELETE(pEvent);
- lPos = m_pEventList->RemoveAt(lPos);
- }
- else
- {
- m_pEventList->GetNext(lPos);
- }
- }
- // set list position member
- m_ulEventListPosition = m_pEventList->GetHeadPosition();
- }
- return;
- }
- HX_RESULT CSmilDocumentRenderer::flushAllEvents( UINT32 ulFlushToTime, BOOL bBreak)
- {
- // handle all events up to time ulFlushToTime + ulGranularity
- HX_RESULT rc = HXR_OK;
- if(m_pEventList && m_pEventList->GetCount() > 0)
- {
- //LISTPOSITION lPos = m_pEventList->GetHeadPosition();
- while(m_ulEventListPosition)
- {
- // handle events which have eventTime<=ulFlushToTime+ulGranularity
- // also only handle events that are in the current group, in case
- // events for the next group have been added to the event list.
- CSmilLayoutEvent* pEvent
- = (CSmilLayoutEvent*) m_pEventList->GetAt(m_ulEventListPosition);
-
- #ifdef _MACINTOSH
- // XXXBobClark:
- // On the Mac side, our site's ShowSite implementation
- // draws synchronously: right then. On Windows, it draws
- // asynchronously by setting up a callback. The upshot is
- // that on Windows you can get away with a ShowSite(TRUE)
- // followed immediately by a ShowSite(FALSE), because the
- // actual screen won't get updated while the site is
- // briefly visible. But on the Mac it will show a visible
- // flicker. So the interim workaround here is to check the
- // events we're flushing; if we're showing a site that will
- // be hidden by the time the flush is done (or vice versa),
- // we ignore that event.
- // XXXMEH - Note that this code was written when there was
- // only show and hide events. Now that there are other events,
- // we need to make sure we only operate on show and hide events
- LISTPOSITION tempPos = m_ulEventListPosition;
- BOOL bCurrentEventCancelledOutByFutureEvent = FALSE;
- if (pEvent->IsShowOrHideEvent())
- {
- CSmilShowSiteEvent* pCurrentEvent = (CSmilShowSiteEvent*)pEvent;
- m_pEventList->GetNext(tempPos); // to start with the next position...
- while (tempPos)
- {
- CSmilLayoutEvent* pFutureLayoutEvent = (CSmilLayoutEvent*) m_pEventList->GetAt(tempPos);
- if (!pFutureLayoutEvent || !pFutureLayoutEvent->IsShowOrHideEvent())
- {
- break;
- }
- CSmilShowSiteEvent* pFutureEvent = (CSmilShowSiteEvent*)m_pEventList->GetAt(tempPos);
- if ( !pFutureEvent
- || pFutureEvent->m_ulEventTime > ulFlushToTime)
- {
- break;
- }
-
- if ( pFutureEvent && pCurrentEvent
- && pCurrentEvent->getRendererSite() == pFutureEvent->getRendererSite()
- && pCurrentEvent->getRegionSite() == pFutureEvent->getRegionSite()
- && pCurrentEvent->getShowSite() != pFutureEvent->getShowSite() )
- {
- bCurrentEventCancelledOutByFutureEvent = TRUE;
- break;
- }
-
- m_pEventList->GetNext(tempPos);
- }
- }
- #endif
- // no need of granularity since the core will
- // ensure we call OnTimeSync at the end of its duration
- if (pEvent &&
- (m_uCurrentGroupIndex == -1 || pEvent->m_uGroupIndex == m_uCurrentGroupIndex) &&
- pEvent->m_ulEventTime <= ulFlushToTime) //XXXMERGE
- {
- #ifdef _MACINTOSH
- if (!bCurrentEventCancelledOutByFutureEvent)
- {
- #endif
- if (!pEvent->getHandledFlag())
- {
- rc = pEvent->handleEvent(ulFlushToTime);
- pEvent->setHandledFlag(TRUE);
- }
- #ifdef _MACINTOSH
- }
- #endif
- }
- else if( bBreak )
- {
- break;
- }
- BOOL bRemoveEvent = FALSE;
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- // If this is an animate event and it begins
- // an animation on some SMIL event, then we
- // should remove this CSmilLayoutEvent from
- // the queue after executing it.
- if (pEvent->m_type == CSmilLayoutEvent::eAnimate)
- {
- CSmilAnimateEvent* pAnimEvent = (CSmilAnimateEvent*) pEvent;
- if (pAnimEvent->hasEventBasedBegin())
- {
- bRemoveEvent = TRUE;
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- if (bRemoveEvent)
- {
- // Remove the event from the queue
- m_ulEventListPosition = m_pEventList->RemoveAt(m_ulEventListPosition);
- // Delete the event
- HX_DELETE(pEvent);
- }
- else
- {
- m_pEventList->GetNext(m_ulEventListPosition);
- }
- }
- }
- return rc;
- }
- BOOL
- CSmilDocumentRenderer::IsFullScreen()
- {
- BOOL bRet = FALSE;
- if (m_pRootLayout->m_pSite)
- {
- IHXSiteFullScreen* pFull = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteFullScreen, (void**) &pFull);
- if (pFull)
- {
- bRet = pFull->IsFullScreen();
- }
- HX_RELEASE(pFull);
- }
- return bRet;
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- void CSmilDocumentRenderer::startSoundLevelAnimation(CSmilAnimateInfo* pInfo)
- {
- MLOG_ANIM(m_pErrorMessages,"startSoundLevelAnimation(0x%08x) m_ulCurrentTime=%lu tick=%lun",
- pInfo, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (pInfo && m_pPlayToAssocList)
- {
- // Get the sound level to set
- UINT16 usSoundLevel = 100;
- if (pInfo->m_pSandwich)
- {
- CAttr cRet = pInfo->m_pSandwich->GetValue(m_ulCurrentTime,
- pInfo->m_pUnder, pInfo->m_pDepend);
- INT32 lLevel = (INT32) (cRet.GetValueDouble() + 0.5);
- if (lLevel < 0) lLevel = 0;
- usSoundLevel = (UINT16) lLevel;
- }
- // Find the right IHXTrack
- SMILPlayToAssoc* pPlayTo = NULL;
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pListPlayTo = (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pListPlayTo &&
- pListPlayTo->m_playTo == pInfo->m_pSandwich->GetTargetElementID())
- {
- IHXTrack* pTrack = NULL;
- HX_RESULT rv = getTrack(pListPlayTo->m_uGroupIndex,
- pListPlayTo->m_uTrackIndex,
- pTrack);
- if (SUCCEEDED(rv))
- {
- // Start the sound level animation
- MLOG_ANIM(m_pErrorMessages,"I call BeginSoundLevelAnimation(%u) at m_ulCurrentTime=%luttick=%lun",
- usSoundLevel, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- pTrack->BeginSoundLevelAnimation(usSoundLevel);
- }
- HX_RELEASE(pTrack);
- }
- }
- }
- MLOG_ANIM(m_pErrorMessages,"exit startSoundLevelAnimation(0x%08x) m_ulCurrentTime=%lu tick=%lun",
- pInfo, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- }
- void CSmilDocumentRenderer::finishSoundLevelAnimation(CSmilAnimateInfo* pInfo,
- BOOL bUseCurrentLevel)
- {
- MLOG_ANIM(m_pErrorMessages,"finishSoundLevelAnimation(0x%08x,%lu) at m_ulCurrentTime=%luttick=%lun",
- pInfo, bUseCurrentLevel, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (pInfo && pInfo->m_pUnder && m_pPlayToAssocList)
- {
- // Get the sound level from the underlying value
- INT32 lLevel = (INT32) (pInfo->m_pUnder->GetValueDouble() + 0.5);
- // Clip at 0 if necessary
- if (lLevel < 0)
- {
- lLevel = 0;
- }
- UINT16 usSoundLevel = (UINT16) lLevel;
- // Call on all IHXTrack's playing to this region
- SMILPlayToAssoc* pPlayTo = NULL;
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pListPlayTo = (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pListPlayTo &&
- pListPlayTo->m_playTo == pInfo->m_pSandwich->GetTargetElementID())
- {
- IHXTrack* pTrack = NULL;
- HX_RESULT rv = getTrack(pListPlayTo->m_uGroupIndex,
- pListPlayTo->m_uTrackIndex,
- pTrack);
- if (SUCCEEDED(rv))
- {
- if (bUseCurrentLevel)
- {
- // If this flag is set, we should end the
- // soundLevel animation with whatever the
- // current value of the soundLevel is, instead
- // of reverting back to the underlying value
- // of the animation. This will be used when we
- // are ending one animation with the intention
- // of immediately beginning another.
- usSoundLevel = pTrack->GetSoundLevel();
- }
- MLOG_ANIM(m_pErrorMessages,"I call EndSoundLevelAnimation(%u) at m_ulCurrentTime=%luttick=%lun",
- usSoundLevel, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- // Start the sound level animation
- pTrack->EndSoundLevelAnimation(usSoundLevel);
- }
- HX_RELEASE(pTrack);
- }
- }
- }
- MLOG_ANIM(m_pErrorMessages,"exit finishSoundLevelAnimation(0x%08x,%lu) at m_ulCurrentTime=%luttick=%lun",
- pInfo, bUseCurrentLevel, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- BOOL CSmilDocumentRenderer::isAttributeAnimated(const char* pszElementID,
- UINT32 ulAttrName)
- {
- BOOL bRet = FALSE;
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- if (pszElementID && m_pAnimationMap)
- {
- POSITION pos = m_pAnimationMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pAnimationMap->GetNextAssoc(pos, pszKey, pVoid);
- if (pszKey && pVoid)
- {
- CSmilAnimateElement* pAnim = (CSmilAnimateElement*) pVoid;
- if (pAnim &&
- pAnim->m_pTargetElementID &&
- *pAnim->m_pTargetElementID == pszElementID &&
- ((UINT32) pAnim->m_ucAttributeName) == ulAttrName)
- {
- bRet = TRUE;
- break;
- }
- }
- }
- }
- // Did we find a currently scheduled animation?
- if (!bRet && m_pSmilParser)
- {
- // We didn't find a currently scheduled
- // animation, but we need to check if the
- // parser knows about any animations on this
- // element/attribute, since animations which
- // start on events won't show up in the document
- // until the time they actually start. This is
- // especially important for soundLevel animations,
- // since we need to know about any possible animations
- // on the soundLevel before we add the track.
- bRet = m_pSmilParser->isAttributeAnimated(pszElementID, ulAttrName);
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- return bRet;
- }
- BOOL CSmilDocumentRenderer::isRegionBackgroundColorOverridden(CSmilBasicRegion* pRegion)
- {
- BOOL bRet = FALSE;
- if (pRegion && m_pPlayToAssocList)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pAssoc =
- (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pAssoc &&
- pAssoc->m_playTo == pRegion->m_region)
- {
- CSmilSource* pSrc = getSource(pAssoc->m_id);
- if (pSrc &&
- pSrc->m_bBackgroundColorSpecified)
- {
- bRet = TRUE;
- break;
- }
- }
- }
- }
- return bRet;
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- CSmilAnimateElement* CSmilDocumentRenderer::getFirstAnimationElement(const char* pszElementID,
- UINT32 ulAttrName)
- {
- CSmilAnimateElement* pRet = NULL;
- if (pszElementID && m_pAnimationMap)
- {
- // Initialize the iterator
- m_AnimationIterator = m_pAnimationMap->GetStartPosition();
- // Get the first element in the map
- pRet = getNextAnimationElement(pszElementID, ulAttrName);
- }
- return pRet;
- }
- CSmilAnimateElement* CSmilDocumentRenderer::getNextAnimationElement(const char* pszElementID,
- UINT32 ulAttrName)
- {
- CSmilAnimateElement* pRet = NULL;
- if (pszElementID && m_pAnimationMap)
- {
- while (m_AnimationIterator)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pAnimationMap->GetNextAssoc(m_AnimationIterator, pszKey, pVoid);
- if (pszKey && pVoid)
- {
- CSmilAnimateElement* pAnim = (CSmilAnimateElement*) pVoid;
- if (pAnim &&
- pAnim->m_pTargetElementID &&
- *pAnim->m_pTargetElementID == pszElementID &&
- ((UINT32) pAnim->m_ucAttributeName) == ulAttrName)
- {
- pRet = pAnim;
- break;
- }
- }
- }
- }
- return pRet;
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- BOOL CSmilDocumentRenderer::getGroupDuration(UINT16 usGroupIndex,
- REF(UINT32) rulDuration)
- {
- BOOL bRet = FALSE;
- if (m_pGroupInfoMap)
- {
- void* pVoid = NULL;
- if(m_pGroupInfoMap->Lookup((INT32) usGroupIndex, pVoid))
- {
- SMILGroupInfo* pGroupInfo = (SMILGroupInfo*) pVoid;
- if (pGroupInfo &&
- pGroupInfo->m_bDurationSet)
- {
- rulDuration = pGroupInfo->m_ulDuration;
- bRet = TRUE;
- }
- }
- }
- return bRet;
- }
- HX_RESULT CSmilDocumentRenderer::getTrack(UINT16 uGroupIndex, UINT16 uTrackIndex, REF(IHXTrack*) rpTrack)
- {
- HX_RESULT retVal = HXR_FAIL;
- SMILPlayToAssoc* pPT = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if (pPT && m_pGroupMap)
- {
- // Get the current group
- void* pVoid = NULL;
- if(m_pGroupMap->Lookup(pPT->m_uGroupIndex, pVoid) && pVoid)
- {
- // QI for IHXGroup2
- IHXGroup* pGroup = (IHXGroup*) pVoid;
- IHXGroup2* pGroup2 = NULL;
- pGroup->QueryInterface(IID_IHXGroup2, (void**) &pGroup2);
- if (pGroup2)
- {
- // Get the right IHXTrack
- IHXTrack* pTrack = NULL;
- pGroup2->GetIHXTrack(pPT->m_uTrackIndex, pTrack);
- if (pTrack)
- {
- retVal = HXR_OK;
- HX_RELEASE(rpTrack);
- rpTrack = pTrack;
- rpTrack->AddRef();
- }
- HX_RELEASE(pTrack);
- }
- HX_RELEASE(pGroup2);
- }
- }
- return retVal;
- }
- void CSmilDocumentRenderer::forceFullRedraw(IHXSite* pSite)
- {
- if (pSite)
- {
- HXxSize cSize;
- pSite->GetSize(cSize);
- HXxRect cRect = {0, 0, cSize.cx, cSize.cy};
- pSite->DamageRect(cRect);
- pSite->ForceRedraw();
- }
- }
- void CSmilDocumentRenderer::forceFullRecursiveRedraw(CSmilBasicBox* pBox)
- {
- if (pBox)
- {
- // Force a redraw of this box's site
- forceFullRedraw(pBox->m_pSite);
- // Force an update on any child renderer sites
- if (pBox->m_pChildRendererSiteList)
- {
- LISTPOSITION pos = pBox->m_pChildRendererSiteList->GetHeadPosition();
- while (pos)
- {
- IHXSite* pChildRendSite =
- (IHXSite*) pBox->m_pChildRendererSiteList->GetNext(pos);
- forceFullRedraw(pChildRendSite);
- }
- }
- // Now recursively force updates on any children
- if (pBox->m_pChildList)
- {
- LISTPOSITION pos = pBox->m_pChildList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicBox* pChildBox =
- (CSmilBasicBox*) pBox->m_pChildList->GetNext(pos);
- forceFullRecursiveRedraw(pChildBox);
- }
- }
- }
- }
- void CSmilDocumentRenderer::destroyRendererSites(CSmilBasicBox* pBox)
- {
- #if 0
- if (pBox)
- {
- // Take care of all the renderers which are
- // children of this box's site
- if (pBox->m_pChildRendererSiteList)
- {
- // Since we know no renderers are playing to a
- // root-level site box, then we know that this box
- // has to be a region, so we can cast to a CSmilBasicRegion
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pBox;
- // Loop through the child renderer sites
- LISTPOSITION pos = pBox->m_pChildRendererSiteList->GetHeadPosition();
- while (pos)
- {
- IHXSite* pRendSite =
- (IHXSite*) pBox->m_pChildRendererSiteList->GetNext(pos);
- if (pRendSite)
- {
- // Remove the site from the site manager
- if (m_pSiteMgr)
- {
- m_pSiteMgr->RemoveSite(pRendSite);
- }
- // Destroy the parent-child relationship between
- // region site and renderer site
- if (pRegion->m_pSite)
- {
- pRegion->m_pSite->DestroyChild(pRendSite);
- }
- // Detach the connection between the
- // site and the site watcher. Note that this
- // only causes the site to remove its ref on
- // the site watcher - it doesn't delete it.
- pRendSite->DetachWatcher();
- // Get the site watcher from the site watcher map
- if (m_pSiteWatcherMap)
- {
- void* pVoid = NULL;
- if (m_pSiteWatcherMap->Lookup((void*) pRendSite, pVoid) && pVoid)
- {
- // Get the CSmilSiteWatcher pointer
- CSmilSiteWatcher* pWatcher = (CSmilSiteWatcher*) pVoid;
- // Remove the site watcher from the site watcher map
- m_pSiteWatcherMap->RemoveKey((void*) pRendSite);
- // Release our ref on the site watcher
- HX_RELEASE(pWatcher);
- }
- }
- // Remove this renderer from the m_pSiteInfoByRendererMap
- if (m_pSiteInfoByRendererMap)
- {
- m_pSiteInfoByRendererMap->RemoveKey((void*) pRendSite);
- }
- // Release the site info's ref
- // on the renderer site
- HX_RELEASE(pRendSite);
- }
- }
- }
- }
- #else
- HX_ASSERT(m_pSiteInfoList); // /Fix for PR 116482 in player core should
- // ensure that we don't get here w/NULL m_p...
- // Here we want to destroy all the renderer sites
- // which were playing to a region in this top-level
- // box. The top level box could be the root-layout or
- // it could be a viewport.
- if (pBox && m_pSiteInfoByRendererMap &&
- // /This check fixes PR 101285 crash. If m_pSiteInfoList has been
- // deleted, then m_pSiteInfoByRendererMap points at deleted items:
- m_pSiteInfoList)
- {
- // Create a list which keeps track of which
- // keys we have operated on
- CHXSimpleList cKeyList;
- // Loop through all of the renderers
- POSITION pos = m_pSiteInfoByRendererMap->GetStartPosition();
- while (pos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pSiteInfoByRendererMap->GetNextAssoc(pos, pKey, pVal);
- if (pVal)
- {
- // Get the site info pointer
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*) pVal;
- if (pSiteInfo->m_pRendererSite)
- {
- // Get the playback region
- CSmilBasicRegion* pRegion = getRegionByID(pSiteInfo->m_regionID);
- if (pRegion)
- {
- // Now get the top-level box which this
- // region is under
- CSmilBasicBox* pTop = getTopLevelBox(pRegion);
- // Only do this operation for those renderers
- // playing to regions which are in *this* top-level box.
- if (pTop == pBox)
- {
- // XXX HP this is to fix PR63462.
- // pSiteInfo->m_pRendererSite is added by addRendererSiteChild()
- // and we need to call its corresponding removeRendererSiteChild()
- // before we destroying the site.
- pRegion->removeRendererSiteChild(pSiteInfo->m_pRendererSite);
- // Remove the site from the site manager
- m_pSiteMgr->RemoveSite(pSiteInfo->m_pRendererSite);
- // Destroy the parent-child relationship between
- // region site and renderer site
- if (pRegion->m_pSite)
- {
- pRegion->m_pSite->DestroyChild(pSiteInfo->m_pRendererSite);
- }
- // Detach the connection between the
- // site and the site watcher. Note that this
- // only causes the site to remove its ref on
- // the site watcher - it doesn't delete it.
- pSiteInfo->m_pRendererSite->DetachWatcher();
- // Get the site watcher from the site watcher map
- if (m_pSiteWatcherMap)
- {
- void* pVoid = NULL;
- if (m_pSiteWatcherMap->Lookup((void*) pSiteInfo->m_pRendererSite, pVoid) &&
- pVoid)
- {
- // Get the CSmilSiteWatcher pointer
- CSmilSiteWatcher* pWatcher = (CSmilSiteWatcher*) pVoid;
- // Remove the site watcher from the site watcher map
- m_pSiteWatcherMap->RemoveKey((void*) pSiteInfo->m_pRendererSite);
- // Release our ref on the site watcher
- HX_RELEASE(pWatcher);
- }
- }
- // Remove the site watcher from the map
- removeRendererSiteWatcherFromMap((const char*) pSiteInfo->m_MediaID);
- // Remove the site from the map
- removeRendererSiteFromMap((const char*) pSiteInfo->m_MediaID);
- // Release the site info's ref
- // on the renderer site
- HX_RELEASE(pSiteInfo->m_pRendererSite);
- // Add this key to the list
- cKeyList.AddTail((void*) pKey);
- }
- }
- }
- }
- }
- // Now loop through the keys we operated on
- // and remove them from the map
- LISTPOSITION lpos = cKeyList.GetHeadPosition();
- while (lpos)
- {
- void* pKey = cKeyList.GetNext(lpos);
- if (pKey)
- {
- m_pSiteInfoByRendererMap->RemoveKey(pKey);
- }
- }
-
- // Delete these only if close has already been called.
- // In that case, this is our last line of defense
- // against a leak.
- if (m_bCloseCalled)
- {
- // Now if we have deleted all the renderers in the map,
- // then delete the whole map
- if (m_pSiteInfoByRendererMap &&
- m_pSiteInfoByRendererMap->GetCount() == 0)
- {
- HX_DELETE(m_pSiteInfoByRendererMap);
- }
- // If we have deleted all the watchers in the
- // site watcher map, then delete the map itself.
- if (m_pSiteWatcherMap &&
- m_pSiteWatcherMap->GetCount() == 0)
- {
- HX_DELETE(m_pSiteWatcherMap);
- }
- }
- }
- #endif
- }
- HX_RESULT CSmilDocumentRenderer::setupRootLayout(BOOL bAssignDefaults)
- {
- HX_RESULT retVal = HXR_OK;
- if (m_pRootLayout)
- {
- // Are we supposed to assign defaults?
- if (bAssignDefaults)
- {
- // If we haven't resolved the root-layout width,
- // then assign a default root layout width
- if (!m_pRootLayout->m_bWidthResolved)
- {
- m_pRootLayout->m_Rect.left = 0;
- m_pRootLayout->m_Rect.right = DEFAULT_ROOT_LAYOUT_WIDTH;
- m_pRootLayout->m_bWidthResolved = TRUE;
- m_pRootLayout->m_bDefaultWidthAssigned = TRUE;
- if (!m_pRootLayout->m_bOriginalWidthSet)
- {
- m_pRootLayout->m_OriginalSize.cx = DEFAULT_ROOT_LAYOUT_WIDTH;
- m_pRootLayout->m_bOriginalWidthSet = TRUE;
- }
- }
- // If we haven't resolved the root-layout height,
- // then assign a default root layout height
- if (!m_pRootLayout->m_bHeightResolved)
- {
- m_pRootLayout->m_Rect.top = 0;
- m_pRootLayout->m_Rect.bottom = DEFAULT_ROOT_LAYOUT_HEIGHT;
- m_pRootLayout->m_bHeightResolved = TRUE;
- m_pRootLayout->m_bDefaultHeightAssigned = TRUE;
- if (!m_pRootLayout->m_bOriginalHeightSet)
- {
- m_pRootLayout->m_OriginalSize.cy = DEFAULT_ROOT_LAYOUT_HEIGHT;
- m_pRootLayout->m_bOriginalHeightSet = TRUE;
- }
- }
- }
- // Compute left and right of the region rects
- HX_RESULT rvW = computeBoxDimension(m_pRootLayout, BoxDimensionWidth);
- // Compute top and bottom of the region rects
- HX_RESULT rvH = computeBoxDimension(m_pRootLayout, BoxDimensionHeight);
- if (SUCCEEDED(rvW) && SUCCEEDED(rvH))
- {
- // Get the root layout id
- const char* pszRootID = "root-layout";
- if (m_pRootLayout->m_pRoot &&
- m_pRootLayout->m_pRoot->m_pNode)
- {
- pszRootID = m_pRootLayout->m_pRoot->m_pNode->m_id;
- }
- // Create a site user for the root layout
- HX_RELEASE(m_pRootLayout->m_pSiteUser);
- m_pRootLayout->m_pSiteUser = new CSmilSiteUser(this,
- m_pRootLayout->GetBackgroundColor(),
- m_pContext,
- TRUE,
- pszRootID);
- if (m_pRootLayout->m_pSiteUser)
- {
- // AddRef the site user
- m_pRootLayout->m_pSiteUser->AddRef();
- // Set several properties in the site user
- //
- // First, get an IHXValues interface
- IHXValues* pSiteUserValues = NULL;
- m_pRootLayout->m_pSiteUser->QueryInterface(IID_IHXValues,
- (void**) &pSiteUserValues);
- if (pSiteUserValues)
- {
- // Set the "name" CString property
- addStringProperty(pSiteUserValues, m_pContext,
- "name", "TopLevelSite");
- // Set the "contextWindow" CString property
- const char* pszCWVal = NULL;
- if (m_pRootLayout->m_pRoot)
- {
- if (m_pRootLayout->m_pRoot->m_eContextWindow == ContextWindowAuto)
- {
- pszCWVal = "auto";
- }
- else
- {
- pszCWVal = "openAtStart";
- }
- }
- addStringProperty(pSiteUserValues, m_pContext,
- "contextWindow", pszCWVal);
- }
- HX_RELEASE(pSiteUserValues);
- // QI for IUnknown
- IUnknown* pThisUnk = NULL;
- m_pRootLayout->m_pSiteUser->QueryInterface(IID_IUnknown, (void**) &pThisUnk);
- if (pThisUnk)
- {
- // This is a call back to CSmilRenderer, which in turn
- // calls IHXLayoutSiteGroupManager::AddLayoutSiteGroup()
- // with CSmilDocumentRenderer as the callback interface.
- // This call results in our AttachSite method being called,
- // which sets the top level site member (m_pRootLayout->m_pSite).
- m_pParent->HandleAddLayoutSiteGroup(pThisUnk);
- m_bSiteLayoutComplete = TRUE;
- }
- HX_RELEASE(pThisUnk);
- // Create sites for each of the regions
- // under the root-layout
- retVal = createRegionSites(m_pRootLayout->m_pChildList);
- if (SUCCEEDED(retVal))
- {
- // We will initially set the z-orders
- resolveZOrder(m_pRootLayout, m_ulCurrentTime);
- // force initial redraw
- forceFullRedraw(m_pRootLayout->m_pSite);
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- HX_RESULT CSmilDocumentRenderer::setupViewports()
- {
- HX_RESULT retVal = HXR_OK;
- // Do we have any viewports?
- if (m_pViewportList && m_pViewPortManager)
- {
- // Loop through each viewport, setting it up
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos && SUCCEEDED(retVal))
- {
- // Get the viewport
- CSmilBasicViewport* pVP =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- if (pVP && pVP->m_pPort)
- {
- // Compute left and right of the region rects
- retVal = computeBoxDimension(pVP, BoxDimensionWidth);
- if (SUCCEEDED(retVal))
- {
- // Compute top and bottom of the region rects
- retVal = computeBoxDimension(pVP, BoxDimensionHeight);
- if (SUCCEEDED(retVal))
- {
- // Create a site user for this viewport
- HX_RELEASE(pVP->m_pSiteUser);
- pVP->m_pSiteUser = new CSmilSiteUser(this,
- pVP->m_pPort->m_ulBackgroundColor,
- m_pContext,
- TRUE,
- pVP->m_pPort->m_pNode->m_id);
- if (pVP->m_pSiteUser)
- {
- // AddRef the site user
- pVP->m_pSiteUser->AddRef();
- // Create an IHXValues
- IHXCommonClassFactory* pFactory = NULL;
- retVal = m_pContext->QueryInterface(IID_IHXCommonClassFactory,
- (void**) &pFactory);
- if (SUCCEEDED(retVal))
- {
- IHXValues* pValues = NULL;
- retVal = pFactory->CreateInstance(CLSID_IHXValues,
- (void**) &pValues);
- if (SUCCEEDED(retVal))
- {
- // Set the "playto" property to be the
- // id of this viewport
- setProperty(pValues, "playto", (const char*) pVP->m_id);
- // Get the IHXSiteUser interface from CSmilSiteUser
- IHXSiteUser* pSiteUser = NULL;
- retVal = pVP->m_pSiteUser->QueryInterface(IID_IHXSiteUser,
- (void**) &pSiteUser);
- if (SUCCEEDED(retVal))
- {
- // Create the viewport. This is an asynchronous
- // call - it will call us back with AttachSite.
- retVal = m_pViewPortManager->OpenViewPort(pValues, pSiteUser);
- }
- HX_RELEASE(pSiteUser);
- }
- HX_RELEASE(pValues);
- }
- HX_RELEASE(pFactory);
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::finishOneViewportSetup(CSmilBasicViewport* pPort)
- {
- HX_RESULT retVal = HXR_OK;
- if (pPort && pPort->m_pPort)
- {
- // Create all the sites which are children of this site
- retVal = createRegionSites(pPort->m_pChildList);
- if (SUCCEEDED(retVal))
- {
- // We will initially set the z-orders
- resolveZOrder(pPort, m_ulCurrentTime);
- // If the open property of the viewport is
- // onStart, then we will go ahead and show the
- // window. If it is whenActive, then we will
- // hide the window now.
- BOOL bShow = TRUE;
- if (pPort->m_pPort->m_eOpen == ViewportOpenWhenActive)
- {
- bShow = FALSE;
- }
- showHideViewport((const char*) pPort->m_id, bShow);
- // force initial redraw
- forceFullRedraw(pPort->m_pSite);
- // Set the setup flag
- pPort->m_bViewportIsSetup = TRUE;
- // Now we need to check if all the viewport sites
- // have been setup. If they have, then we will call
- // setupViewportsDone().
- BOOL bAllAreSetup = TRUE;
- if(m_pViewportList)
- {
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicViewport* pListPort =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- if (pListPort && pListPort->m_bViewportIsSetup == FALSE)
- {
- bAllAreSetup = FALSE;
- break;
- }
- }
- }
- if (bAllAreSetup)
- {
- // All the viewports are now setup
- setupViewportsDone(retVal);
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::setupViewportsDone(HX_RESULT status)
- {
- HX_RESULT retVal = HXR_OK;
- return retVal;
- }
- void CSmilDocumentRenderer::closeViewports()
- {
- if (m_pViewportList && m_pViewPortManager)
- {
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicViewport* pVP =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- if (pVP && pVP->m_bOpen)
- {
- #ifdef XXXMEH_DO_VIEWPORT_TLC
- m_bSMILViewportClose = TRUE;
- #endif
- // Close the viewport
- m_pViewPortManager->CloseViewPort((const char*) pVP->m_id);
- #ifdef XXXMEH_DO_VIEWPORT_TLC
- m_bSMILViewportClose = FALSE;
- #endif
- }
- }
- }
- }
- void CSmilDocumentRenderer::showHideViewport(const char* pszID, BOOL bShow)
- {
- if (m_pViewPortManager && pszID)
- {
- IHXViewPort* pPort = NULL;
- m_pViewPortManager->GetViewPort(pszID, pPort);
- if (pPort)
- {
- if (bShow)
- {
- pPort->Show();
- }
- else
- {
- pPort->Hide();
- }
- }
- HX_RELEASE(pPort);
- }
- }
- void CSmilDocumentRenderer::showHideViewport(CSmilBasicViewport* pPort,
- BOOL bShow)
- {
- if (pPort &&
- pPort->m_pPort &&
- pPort->m_pPort->m_pNode)
- {
- showHideViewport((const char*) pPort->m_id, bShow);
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- void CSmilDocumentRenderer::destroyRegions(CHXSimpleList* pChildList)
- {
- if (pChildList)
- {
- // Loop through the children regions
- LISTPOSITION pos = pChildList->GetHeadPosition();
- while (pos)
- {
- // Since these are children, they have to be
- // regions, as top-level boxes (root-layout
- // and viewport) cannot be children.
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pChildList->GetNext(pos);
- if (pRegion)
- {
- // First we must destroy the children of this
- // region, since they hold links to their ancestors
- destroyRegions(pRegion->m_pChildList);
- // Now we can destroy this region.
- if (m_pRegionMap)
- {
- // First, remove the key from the region map
- m_pRegionMap->RemoveKey((const char*) pRegion->m_region);
- }
- // Now we can delete the region
- HX_DELETE(pRegion);
- }
- }
- }
- }
- void CSmilDocumentRenderer::destroyAllRegions()
- {
- if (m_pRegionMap)
- {
- // Run through the map
- POSITION pos = m_pRegionMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVal = NULL;
- m_pRegionMap->GetNextAssoc(pos, pszKey, pVal);
- if (pVal)
- {
- // Get the region pointer
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pVal;
- // Delete this region
- HX_DELETE(pRegion);
- }
- }
- // Remove all the entries
- m_pRegionMap->RemoveAll();
- // Delete the map
- HX_DELETE(m_pRegionMap);
- }
- }
- void CSmilDocumentRenderer::setElementRemoveTime(const char* pszID,
- UINT32 ulRemoveTime)
- {
- if (pszID && m_pSmilParser)
- {
- CSmilElement* pElement = m_pSmilParser->findElement(pszID);
- if (pElement)
- {
- pElement->m_ulRemoveTime = ulRemoveTime;
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) && defined(XXXMEH_DO_VIEWPORT_TLC)
- void CSmilDocumentRenderer::clearViewportMap()
- {
- if (m_pViewPortSiteMap)
- {
- POSITION pos = m_pViewPortSiteMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pObj = NULL;
- m_pViewPortSiteMap->GetNextAssoc(pos, pszKey, pObj);
- if (pObj)
- {
- IHXSite* pSite = (IHXSite*) pObj;
- HX_RELEASE(pSite);
- }
- }
- m_pViewPortSiteMap->RemoveAll();
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) && defined(XXXMEH_DO_VIEWPORT_TLC) */
- void CSmilDocumentRenderer::showAllSites(CSmilBasicBox* pBox, BOOL bShow)
- {
- if (pBox && pBox->m_pSite)
- {
- ShowBackground eShow = ShowBackgroundAlways;
- if (pBox->m_pParent)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pBox;
- eShow = pRegion->m_eShowBackground;
- }
- if (eShow == ShowBackgroundAlways)
- {
- BOOL bVisible = isSiteVisible(pBox->m_pSite);
- showSite(pBox->m_pSite, bShow);
- }
- // Process the children
- if (pBox->m_pChildList)
- {
- LISTPOSITION pos = pBox->m_pChildList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicBox* pChildBox =
- (CSmilBasicBox*) pBox->m_pChildList->GetNext(pos);
- showAllSites(pChildBox, bShow);
- }
- }
- }
- }
- void CSmilDocumentRenderer::showSite(IHXSite* pSite, BOOL bShow)
- {
- if(pSite)
- {
- IHXSite2* pSite2 = NULL;
- pSite->QueryInterface(IID_IHXSite2, (void**) &pSite2);
- if (pSite2)
- {
- pSite2->ShowSite(bShow);
- }
- HX_RELEASE(pSite2);
- }
- }
- BOOL CSmilDocumentRenderer::isSiteVisible(IHXSite* pSite)
- {
- BOOL bRet = FALSE;
- if (pSite)
- {
- IHXSite2* pSite2 = NULL;
- pSite->QueryInterface(IID_IHXSite2, (void**) &pSite2);
- if (pSite2)
- {
- bRet = pSite2->IsSiteVisible();
- }
- HX_RELEASE(pSite2);
- }
- return bRet;
- }
- void CSmilDocumentRenderer::setSiteZIndex(IHXSite* pSite, INT32 lZIndex)
- {
- if (pSite)
- {
- IHXSite2* pSite2 = NULL;
- pSite->QueryInterface(IID_IHXSite2, (void**) &pSite2);
- if (pSite2)
- {
- INT32 lCurZOrder = 0;
- HX_RESULT rv = pSite2->GetZOrder(lCurZOrder);
- if (FAILED(rv) ||
- (SUCCEEDED(rv) && lZIndex != lCurZOrder))
- {
- pSite2->SetZOrder(lZIndex);
- }
- }
- HX_RELEASE(pSite2);
- }
- }
- INT32 CSmilDocumentRenderer::getSiteZIndex(IHXSite* pSite)
- {
- INT32 lRet = 0;
- if (pSite)
- {
- IHXSite2* pSite2 = NULL;
- pSite->QueryInterface(IID_IHXSite2, (void**) &pSite2);
- if (pSite2)
- {
- pSite2->GetZOrder(lRet);
- }
- HX_RELEASE(pSite2);
- }
- return lRet;
- }
- UINT32 CSmilDocumentRenderer::getNumberOfChildSites(IHXSite* pSite)
- {
- UINT32 ulRet = 0;
- if (pSite)
- {
- IHXSite2* pSite2 = NULL;
- pSite->QueryInterface(IID_IHXSite2, (void**) &pSite2);
- if (pSite2)
- {
- ulRet = pSite2->GetNumberOfChildSites();
- }
- HX_RELEASE(pSite2);
- }
- return ulRet;
- }
- HX_RESULT
- CSmilDocumentRenderer::onPreSeek(UINT32 ulOldTime, UINT32 ulNewTime)
- {
- HX_RESULT rc = HXR_OK;
- //{FILE* f1 = ::fopen("c:\temp\out.txt", "a+"); ::fprintf(f1, "onPreSeekn");::fclose(f1);}
- if(m_pSiteInfoList && m_pSiteInfoList->GetCount() > 0)
- {
- // hide all regions/sites in current group
- CHXSimpleList::Iterator i = m_pSiteInfoList->Begin();
- for(; i != m_pSiteInfoList->End(); ++i)
- {
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*)(*i);
- if(pSiteInfo->m_uGroupIndex == m_uCurrentGroupIndex)
- {
- // /Reset resumeTime of site infos if seek is back before they
- // occurred so wrong one isn't on top (after fix for PR 81510
- // (& dup. PR 83796)):
- if (pSiteInfo->m_ulResumeTime > ulNewTime)
- {
- pSiteInfo->m_ulResumeTime = 0;
- }
- IHXSite* pRegionSite = NULL;
- CSmilBasicRegion* pRegion = getRegionByID(pSiteInfo->m_regionID);
- if (!pRegion)
- {
- HX_ASSERT(pRegion);
- continue;
- }
- if(pRegion->m_eBackgroundColorType == CSS2TypeTransparent)
- {
- pRegionSite = pSiteInfo->m_pRegionSite;
- }
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- showSite(pRegionSite, FALSE);
- }
- }
- // remove all the transitions...
- removeActiveTransitions();
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- // remove all the animations
- removeActiveAnimations();
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- // Clear the "handled" flag on all events
- clearAllEventHandledFlags();
- // /Notify rmasmil so its data structures can prep for a seek, e.g.,
- // re-loading all old actuate="onLoad" links that were removed when
- // used already, prior to this (backwards) seek; fixes PR 67170:
- if (m_pSmilParser)
- {
- m_pSmilParser->prepForSeek(ulOldTime, ulNewTime);
- }
- // show/hide sites up to ulNewTime
- // events at the same time for the same region
- // are ordererd 'hide' first, then 'show' so
- // a hide doesn't override a show.
- m_ulEventListPosition = m_pEventList->GetHeadPosition();
- flushAllEvents( ulNewTime, TRUE );
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::endStream()
- {
- m_bSMILPresentationHasEnded = TRUE;
- flushAllEvents(); // flush all remaining events
- if(m_pGroupMap)
- {
- CHXMapLongToObj::Iterator i;
- for(i=m_pGroupMap->Begin();i!=m_pGroupMap->End();++i)
- {
- IHXGroup* pGroup = (IHXGroup*)(*i);
- pGroup->Release();
- }
- HX_DELETE(m_pGroupMap);
- }
- HX_RELEASE(m_pPersistentLayoutStream);
- closeOldRenderers(TRUE);
- HX_RELEASE(m_pPersistentProperties);
- HX_RELEASE(m_pPersistentParentRenderer);
- if (isSiteCompositionModeON())
- {
- turnSiteCompositionModeOFF();
- }
- return HXR_OK;
- }
- CSmilBasicRegion* CSmilDocumentRenderer::setupDefaultLayout()
- {
- CSmilBasicRegion* pRet = NULL;
- // First we need to check if we have already created
- // a default region.
- // XXXMEH - later, we might want to something more sophisticated
- // here and make sure that the default region name we create
- // is unique. For now, we make it a weird string.
- const char* pszDefRegID = "jgje4u5kd845prhd94";
- // Do we already have a default region?
- CSmilBasicRegion* pRegion = getRegionByID(pszDefRegID);
- if (!pRegion)
- {
- // We don't already have a default region - create one.
- pRegion = new CSmilBasicRegion(NULL);
- if (pRegion)
- {
- // Assign the default id to this region
- pRegion->m_region = pszDefRegID;
- // Set the root-layout as the parent
- pRegion->m_pParent = m_pRootLayout;
- // Add this region as a child of the root-layout
- HX_RESULT retVal = m_pRootLayout->addChild(pRegion);
- if (SUCCEEDED(retVal))
- {
- // Add the default region to the region map
- m_pRegionMap->SetAt(pszDefRegID, (void*) pRegion);
- // Do we need to set up the root-layout?
- if (!m_bIsRootLayoutSetup)
- {
- // We need to set up the root-layout. This can
- // happen if either there WAS no root-layout element
- // or if the root-layout element was missing either
- // a "width" or "height" property
- retVal = setupRootLayout(TRUE);
- if (SUCCEEDED(retVal))
- {
- // Set the flag
- m_bIsRootLayoutSetup = TRUE;
- // Assign the out parameter
- pRet = pRegion;
- }
- }
- else
- {
- // <root-layout> is already set up, but we need to resolve
- // the width and height of this region.
- retVal = computeBoxDimension(pRegion, BoxDimensionWidth);
- if (SUCCEEDED(retVal))
- {
- retVal = computeBoxDimension(pRegion, BoxDimensionHeight);
- if (SUCCEEDED(retVal))
- {
- // Now we need to do the regular setup of this region
- retVal = createRegionSite(pRegion);
- if (SUCCEEDED(retVal))
- {
- // Assign the out parameter
- pRet = pRegion;
- }
- }
- }
- }
- }
- }
- }
- else
- {
- // We have a default region, so we assume that
- // we don't have to do any additional setup.
- pRet = pRegion;
- }
- return pRet;
- }
- CSmilBasicRegion* CSmilDocumentRenderer::getRegionByID(const char* pID)
- {
- CSmilBasicRegion* pRegion = 0;
- if(m_pRegionMap)
- {
- m_pRegionMap->Lookup(pID, (void*&)pRegion);
- }
- return pRegion;
- }
- UINT32 CSmilDocumentRenderer::getNumRegionsByName(const char* pszName)
- {
- UINT32 ulRet = 0;
- CSmilBasicRegion* pRegion = getFirstRegionByName(pszName);
- while (pRegion)
- {
- ulRet++;
- pRegion = getNextRegionByName(pszName);
- }
- return ulRet;
- }
- CSmilBasicRegion* CSmilDocumentRenderer::getFirstRegionByName(const char* pszName)
- {
- CSmilBasicRegion* pRet = NULL;
- if (m_pRegionMap)
- {
- // Initialize the iterator
- m_pRegionMapIterator = m_pRegionMap->GetStartPosition();
- // Get the region
- pRet = getRegionByName(pszName);
- }
- return pRet;
- }
- CSmilBasicRegion* CSmilDocumentRenderer::getNextRegionByName(const char* pszName)
- {
- return getRegionByName(pszName);
- }
- BOOL CSmilDocumentRenderer::isAncestorRegion(CSmilBasicRegion* pPossibleParent,
- CSmilBasicRegion* pPossibleChild)
- {
- BOOL bRet = FALSE;
- if (pPossibleParent)
- {
- while (pPossibleChild)
- {
- if (pPossibleParent == pPossibleChild)
- {
- bRet = TRUE;
- break;
- }
- // If our parent has a parent, then the
- // CSmilBasicBox is still a region.
- if (pPossibleChild->m_pParent &&
- pPossibleChild->m_pParent->m_pParent)
- {
- pPossibleChild = (CSmilBasicRegion*) pPossibleChild->m_pParent;
- }
- else
- {
- break;
- }
- }
- }
- return bRet;
- }
- HX_RESULT CSmilDocumentRenderer::getCommonAncestorRegion(CSmilBasicRegion* pRegA,
- CSmilBasicRegion* pRegB,
- REF(CSmilBasicRegion*) rpCommon)
- {
- HX_RESULT retVal = HXR_OK;
- if (pRegA && pRegB)
- {
- // First check if B is a child of A,
- // then check if A is a child of B,
- // then check for a common ancestor
- if (isAncestorRegion(pRegA, pRegB))
- {
- rpCommon = pRegA;
- }
- else if (isAncestorRegion(pRegB, pRegA))
- {
- rpCommon = pRegB;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- return retVal;
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- CSmilBasicViewport* CSmilDocumentRenderer::getViewport(const char* pszID)
- {
- CSmilBasicViewport* pRet = NULL;
- if(m_pViewportList)
- {
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicViewport* pPort =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- if (pPort && pPort->m_id == pszID)
- {
- pRet = pPort;
- break;
- }
- }
- }
- return pRet;
- }
- CSmilBasicViewport* CSmilDocumentRenderer::getViewportBySiteUser(CSmilSiteUser* pSiteUser)
- {
- CSmilBasicViewport* pRet = NULL;
- if(m_pViewportList)
- {
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicViewport* pPort =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- if (pPort &&