smldoc.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:673k
- }
- else if (ulAttr == kAttrNameColor)
- {
- // Get the color we want to set
- UINT32 ulRed = (UINT32) pValue->GetValueDouble(0);
- UINT32 ulGreen = (UINT32) pValue->GetValueDouble(1);
- UINT32 ulBlue = (UINT32) pValue->GetValueDouble(2);
- UINT32 ulAlpha = (UINT32) pValue->GetValueDouble(3);
- UINT32 ulColor = (ulAlpha << 24) | (ulRed << 16) |
- (ulGreen << 8) | ulBlue;
- // Set the color into the renderer
- BOOL bChanged = FALSE;
- retVal = setRendererULONG32Property(pszID, "color",
- ulColor, bChanged);
- if (SUCCEEDED(retVal) && bChanged)
- {
- // Get the renderer site
- IHXSite* pRendererSite = NULL;
- retVal = getRendererSite(pszID, pRendererSite);
- if (SUCCEEDED(retVal))
- {
- // Queue the site for redraw
- queueSiteForAnimationRedraw(pRendererSite);
- }
- HX_RELEASE(pRendererSite);
- }
- }
- else if (ulAttr == kAttrNameMediaOpacity ||
- ulAttr == kAttrNameBackgroundOpacity)
- {
- // Get the correct property string
- const char* pszPropStr = (ulAttr == kAttrNameMediaOpacity ? "mediaOpacity" : "backgroundOpacity");
- // Get the value to set
- UINT32 ulOpacity = (UINT32) pValue->GetValueDouble();
- // Set the property
- BOOL bChanged = FALSE;
- retVal = setRendererULONG32Property(pszID, pszPropStr,
- ulOpacity, bChanged);
- if (SUCCEEDED(retVal) && bChanged)
- {
- // Get the renderer site
- IHXSite* pRendererSite = NULL;
- retVal = getRendererSite(pszID, pRendererSite);
- if (SUCCEEDED(retVal))
- {
- // Queue the site for redraw
- queueSiteForAnimationRedraw(pRendererSite);
- }
- HX_RELEASE(pRendererSite);
- }
- }
- }
- else if (eTag == SMILRootLayout)
- {
- if (m_pRootLayout && m_pRootLayout->m_pRoot)
- {
- switch (ulAttr)
- {
- case kAttrNameWidth:
- if (m_pRootLayout->m_pRoot->m_dWidth != pValue->GetValueDouble(0))
- {
- m_pRootLayout->m_pRoot->m_dWidth = pValue->GetValueDouble(0);
- m_pRootLayout->m_pRoot->m_eWidthType = pValue->GetCSS2Type(0);
- m_bAnimateRootLayout = TRUE;
- }
- break;
- case kAttrNameHeight:
- if (m_pRootLayout->m_pRoot->m_dHeight != pValue->GetValueDouble(0))
- {
- m_pRootLayout->m_pRoot->m_dHeight = pValue->GetValueDouble(0);
- m_pRootLayout->m_pRoot->m_eHeightType = pValue->GetCSS2Type(0);
- m_bAnimateRootLayout = TRUE;
- }
- break;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- else if (eTag == SMILViewport)
- {
- CSmilBasicViewport* pVP = getViewport(pszID);
- if (pVP && pVP->m_pPort)
- {
- BOOL bQueueVP = FALSE;
- switch (ulAttr)
- {
- case kAttrNameWidth:
- if (pVP->m_pPort->m_dWidth != pValue->GetValueDouble(0))
- {
- pVP->m_pPort->m_dWidth = pValue->GetValueDouble(0);
- pVP->m_pPort->m_eWidthType = pValue->GetCSS2Type(0);
- bQueueVP = TRUE;
- }
- break;
- case kAttrNameHeight:
- if (pVP->m_pPort->m_dHeight != pValue->GetValueDouble(0))
- {
- pVP->m_pPort->m_dHeight = pValue->GetValueDouble(0);
- pVP->m_pPort->m_eHeightType = pValue->GetCSS2Type(0);
- bQueueVP = TRUE;
- }
- break;
- }
- if (bQueueVP)
- {
- if (!m_pAnimTopLayoutMap)
- {
- m_pAnimTopLayoutMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimTopLayoutMap)
- {
- m_pAnimTopLayoutMap->SetAt((void*) pVP, (void*) pVP);
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- else if (eTag == SMILParam)
- {
- if (m_pSmilParser)
- {
- CSmilElement* pEl = m_pSmilParser->findElement(pszID);
- if (pEl &&
- pEl->m_pNode &&
- pEl->m_pNode->m_tag == SMILParam &&
- m_pSmilParser->isMediaObject(pEl->m_pNode->m_pParent))
- {
- // Get the CSmilParamElement
- CSmilParamElement* pParam = (CSmilParamElement*) pEl;
- // Get the media element id
- const char* pszMediaID = (const char*) pEl->m_pNode->m_pParent->m_id;
- // Set this property into the renderer
- BOOL bChanged = FALSE;
- retVal = setRendererCStringProperty(pszMediaID,
- (const char*) pParam->m_pName,
- pValue->GetValueString(),
- bChanged);
- if (SUCCEEDED(retVal) && bChanged)
- {
- MLOG_ANIM(m_pErrorMessages,
- "setValue() t=%lu Changed param id=%s value to %sn",
- m_ulCurrentTime, pszID,
- pValue->GetValueString());
- // Get the renderer site
- IHXSite* pRendererSite = NULL;
- retVal = getRendererSite(pszMediaID, pRendererSite);
- if (SUCCEEDED(retVal))
- {
- // Queue the site for redraw
- queueSiteForAnimationRedraw(pRendererSite);
- }
- HX_RELEASE(pRendererSite);
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- return retVal;
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- const char* CSmilDocumentRenderer::getDefaultNamespace()
- {
- const char* pRet = NULL;
- if (m_pSmilParser)
- {
- pRet = m_pSmilParser->getDefaultNamespace();
- }
- return pRet;
- }
- void CSmilDocumentRenderer::resetRendererSites(CSmilBasicRegion* pRegion)
- {
- if (pRegion && pRegion->m_pChildRendererSiteList)
- {
- LISTPOSITION pos = pRegion->m_pChildRendererSiteList->GetHeadPosition();
- while (pos)
- {
- IHXSite* pRndSite =
- (IHXSite*) pRegion->m_pChildRendererSiteList->GetNext(pos);
- if (pRndSite)
- {
- // Reset the size of the site. Note that
- // since we have a site watcher, it doesn't
- // matter what we pass in, because the site
- // watcher will override it.
- HXxSize cSize = {1, 1};
- pRndSite->SetSize(cSize);
- // Reset the position of the site. Note that
- // since we have a site watcher, it doesn't
- // matter what we pass in, because the site
- // watcher will override it.
- HXxPoint cPos = {1, 1};
- pRndSite->SetPosition(cPos);
- }
- }
- }
- }
- CSmilSiteWatcher* CSmilDocumentRenderer::getRendererSiteWatcher(const char* pszMediaID)
- {
- CSmilSiteWatcher* pRet = NULL;
- if (pszMediaID && m_pMediaID2RendererSiteWatcherMap)
- {
- // Look up the site watcher
- void* pVoid = NULL;
- if (m_pMediaID2RendererSiteWatcherMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- pRet = (CSmilSiteWatcher*) pVoid;
- }
- }
- return pRet;
- }
- void CSmilDocumentRenderer::addRendererSiteWatcherToMap(const char* pszMediaID,
- CSmilSiteWatcher* pWatch)
- {
- if (pszMediaID && pWatch)
- {
- // Do we already have the map?
- if (!m_pMediaID2RendererSiteWatcherMap)
- {
- // Create it
- m_pMediaID2RendererSiteWatcherMap = new CHXMapStringToOb();
- }
- if (m_pMediaID2RendererSiteWatcherMap)
- {
- // Is this renderer already in the map?
- void* pVoid = NULL;
- if (!m_pMediaID2RendererSiteWatcherMap->Lookup(pszMediaID, pVoid))
- {
- // AddRef the site
- pWatch->AddRef();
- // Add it to the map
- m_pMediaID2RendererSiteWatcherMap->SetAt(pszMediaID, (void*) pWatch);
- }
- }
- }
- }
- void CSmilDocumentRenderer::removeRendererSiteWatcherFromMap(const char* pszMediaID)
- {
- if (pszMediaID && m_pMediaID2RendererSiteWatcherMap)
- {
- // Is this renderer site in the map
- void* pVoid = NULL;
- if (m_pMediaID2RendererSiteWatcherMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- // Release the renderer site
- CSmilSiteWatcher* pWatch = (CSmilSiteWatcher*) pVoid;
- HX_RELEASE(pWatch);
- // Remove it from the map
- m_pMediaID2RendererSiteWatcherMap->RemoveKey(pszMediaID);
- }
- }
- }
- void CSmilDocumentRenderer::clearRendererSiteWatcherMap()
- {
- if (m_pMediaID2RendererSiteWatcherMap)
- {
- POSITION pos = m_pMediaID2RendererSiteWatcherMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pMediaID2RendererSiteWatcherMap->GetNextAssoc(pos, pszKey, pVoid);
- if (pVoid)
- {
- // Release the renderer site
- CSmilSiteWatcher* pWatch = (CSmilSiteWatcher*) pVoid;
- HX_RELEASE(pWatch);
- }
- }
- // Remove all entries from the map
- m_pMediaID2RendererSiteWatcherMap->RemoveAll();
- }
- }
- HX_RESULT CSmilDocumentRenderer::getRendererSite(const char* pszMediaID,
- REF(IHXSite*) rpSite)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszMediaID && m_pMediaID2RendererSiteMap)
- {
- // Is the media ID in the map?
- void* pVoid = NULL;
- if (m_pMediaID2RendererSiteMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- HX_RELEASE(rpSite);
- rpSite = (IHXSite*) pVoid;
- rpSite->AddRef();
- retVal = HXR_OK;
- }
- }
- return retVal;
- }
- void CSmilDocumentRenderer::addRendererSiteToMap(const char* pszMediaID,
- IHXSite* pSite)
- {
- if (pszMediaID && pSite)
- {
- // Do we already have the map?
- if (!m_pMediaID2RendererSiteMap)
- {
- // Create it
- m_pMediaID2RendererSiteMap = new CHXMapStringToOb();
- }
- if (m_pMediaID2RendererSiteMap)
- {
- // Is this renderer already in the map?
- void* pVoid = NULL;
- if (!m_pMediaID2RendererSiteMap->Lookup(pszMediaID, pVoid))
- {
- // AddRef the site
- pSite->AddRef();
- // Add it to the map
- m_pMediaID2RendererSiteMap->SetAt(pszMediaID, (void*) pSite);
- }
- }
- }
- }
- void CSmilDocumentRenderer::removeRendererSiteFromMap(const char* pszMediaID)
- {
- if (pszMediaID && m_pMediaID2RendererSiteMap)
- {
- // Is this renderer site in the map
- void* pVoid = NULL;
- if (m_pMediaID2RendererSiteMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- // Release the renderer site
- IHXSite* pSite = (IHXSite*) pVoid;
- HX_RELEASE(pSite);
- // Remove it from the map
- m_pMediaID2RendererSiteMap->RemoveKey(pszMediaID);
- }
- }
- }
- void CSmilDocumentRenderer::clearRendererSiteMap()
- {
- if (m_pMediaID2RendererSiteMap)
- {
- POSITION pos = m_pMediaID2RendererSiteMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pMediaID2RendererSiteMap->GetNextAssoc(pos, pszKey, pVoid);
- if (pVoid)
- {
- // Release the renderer site
- IHXSite* pSite = (IHXSite*) pVoid;
- HX_RELEASE(pSite);
- }
- }
- // Remove all entries from the map
- m_pMediaID2RendererSiteMap->RemoveAll();
- }
- }
- HX_RESULT CSmilDocumentRenderer::getRenderer(const char* pszMediaID,
- REF(IHXRenderer*) rpRenderer)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszMediaID && m_pMediaID2RendererMap)
- {
- // Is the media ID in the map?
- void* pVoid = NULL;
- if (m_pMediaID2RendererMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- HX_RELEASE(rpRenderer);
- rpRenderer = (IHXRenderer*) pVoid;
- rpRenderer->AddRef();
- retVal = HXR_OK;
- }
- }
- return retVal;
- }
- void CSmilDocumentRenderer::addRendererToMap(const char* pszMediaID,
- IHXRenderer* pRenderer)
- {
- if (pszMediaID && pRenderer)
- {
- // Do we already have the map?
- if (!m_pMediaID2RendererMap)
- {
- // Create it
- m_pMediaID2RendererMap = new CHXMapStringToOb();
- }
- if (m_pMediaID2RendererMap)
- {
- // Is this renderer already in the map?
- void* pVoid = NULL;
- if (!m_pMediaID2RendererMap->Lookup(pszMediaID, pVoid))
- {
- // AddRef the renderer
- pRenderer->AddRef();
- // Add it to the map
- m_pMediaID2RendererMap->SetAt(pszMediaID, (void*) pRenderer);
- }
- }
- }
- }
- void CSmilDocumentRenderer::removeRendererFromMap(const char* pszMediaID)
- {
- if (pszMediaID && m_pMediaID2RendererMap)
- {
- // Is this entry in the map?
- void* pVoid = NULL;
- if (m_pMediaID2RendererMap->Lookup(pszMediaID, pVoid) && pVoid)
- {
- // Release the renderer
- IHXRenderer* pRend = (IHXRenderer*) pVoid;
- HX_RELEASE(pRend);
- // Remove it from the map
- m_pMediaID2RendererMap->RemoveKey(pszMediaID);
- }
- }
- }
- void CSmilDocumentRenderer::clearRendererMap()
- {
- if (m_pMediaID2RendererMap)
- {
- // Run through the map, and release the renderer
- POSITION pos = m_pMediaID2RendererMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pMediaID2RendererMap->GetNextAssoc(pos, pszKey, pVoid);
- if (pVoid)
- {
- IHXRenderer* pRend = (IHXRenderer*) pVoid;
- HX_RELEASE(pRend);
- }
- }
- // Remove all entries from the map
- m_pMediaID2RendererMap->RemoveAll();
- }
- }
- SMILPlayToAssoc*
- CSmilDocumentRenderer::getPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex)
- {
- 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_uGroupIndex == uGroupIndex) &&
- (pThisAssoc->m_uTrackIndex == uTrackIndex))
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- return pPlayToAssoc;
- }
- SMILPlayToAssoc*
- CSmilDocumentRenderer::getPlayToAssoc(const char* pPlayTo)
- {
- SMILPlayToAssoc* pPlayToAssoc = 0;
- UINT16 uCurGroupIndex = getCurrentGroup();
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if(pThisAssoc->m_playTo == pPlayTo &&
- // /Fixes bug where already-removed media was being
- // returned as active:
- !pThisAssoc->m_bRemovePending &&
- // /Fixes PR 55355 where media from wrong group was
- // being returned since delay values are relative to
- // start of group:
- uCurGroupIndex == pThisAssoc->m_uGroupIndex)
- {
- if (!pPlayToAssoc)
- {
- pPlayToAssoc = pThisAssoc;
- }
- // /Fixes bugs (including PR 55355) where multiple media
- // play to the same region and this function was always
- // returning the first media's playToAssoc even if it had
- // ended or been covered by other media; this resulted in
- // the new media not getting region mouse events:
- else if (pThisAssoc->m_ulDelay >= pPlayToAssoc->m_ulDelay &&
- // /Find the one earlier than but closest to the
- // current time; if none such exists, find the one
- // closest to and later than current time (for pre-
- // scheduling of show/hide event purposes):
- (pThisAssoc->m_ulDelay <= m_ulCurrentTime ||
- (pPlayToAssoc->m_ulDelay > m_ulCurrentTime &&
- pThisAssoc->m_ulDelay < pPlayToAssoc->m_ulDelay)) )
- {
- pPlayToAssoc = pThisAssoc;
- }
- }
- }
- }
- return pPlayToAssoc;
- }
- SMILPlayToAssoc* CSmilDocumentRenderer::getPlayToAssocByMedia(const char* pszMediaID)
- {
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- if (pszMediaID && m_pPlayToAssocList)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pListMember =
- (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pListMember && pListMember->m_id == pszMediaID)
- {
- pPlayToAssoc = pListMember;
- break;
- }
- }
- }
- return pPlayToAssoc;
- }
-
- void
- CSmilDocumentRenderer::setPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex,
- const char* pID,
- const char* pRepeatID,
- const char* pPlayTo,
- const char* pRegionName,
- const char* pBeginTransition,
- const char* pEndTransition,
- UINT32 lexicalOrder,
- BOOL bXMMSource)
- {
- SMILPlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if(!pPlayToAssoc)
- {
- pPlayToAssoc = new SMILPlayToAssoc;
- pPlayToAssoc->m_uGroupIndex = uGroupIndex;
- pPlayToAssoc->m_uTrackIndex = uTrackIndex;
- pPlayToAssoc->m_id = pID;
- pPlayToAssoc->m_repeatid = pRepeatID;
- pPlayToAssoc->m_playTo = pPlayTo;
- pPlayToAssoc->m_ulDelay = 0;
- pPlayToAssoc->m_ulDuration = 0;
- pPlayToAssoc->m_bIsPersistentSource = FALSE;
- pPlayToAssoc->m_bDurationResolved = FALSE;
- pPlayToAssoc->m_bRemoveSite = TRUE; // default is remove
- pPlayToAssoc->m_bRemovePending = FALSE;
- pPlayToAssoc->m_pHyperlinks = new CHXSimpleList;
- pPlayToAssoc->m_pRendererEventHook = NULL;
- pPlayToAssoc->m_pSiteInfoList = new CHXSimpleList;
- pPlayToAssoc->m_ulLexicalOrder = lexicalOrder;
- pPlayToAssoc->m_bXMMSource = bXMMSource;
- pPlayToAssoc->m_bTrackStopped = FALSE;
-
- if (pBeginTransition)
- {
- pPlayToAssoc->m_beginTransition = pBeginTransition;
- }
- if (pEndTransition)
- {
- pPlayToAssoc->m_endTransition = pEndTransition;
- }
- if(pRegionName)
- {
- pPlayToAssoc->m_regionName = pRegionName;
- }
- char cTemp[20]; /* Flawfinder: ignore */
- ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pPlayToAssoc); /* Flawfinder: ignore */
- pPlayToAssoc->m_tunerName = (const char*) cTemp;
- ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pPlayToAssoc+1); /* Flawfinder: ignore */
- pPlayToAssoc->m_childTunerName = (const char*)cTemp;
- // see if the pPlayTo points to a valid CSmilBasicRegion
- BOOL bNoRegion = TRUE;
- if(pPlayTo)
- {
- // First, assume that pPlayTo is an id and see
- // if we can find the region by id
- CSmilBasicRegion* pRegion = getRegionByID(pPlayTo);
- if(pRegion)
- {
- bNoRegion = FALSE;
- }
- else
- {
- // We didn't find it by id, so try and find it
- // by regionName
- pRegion = getFirstRegionByName(pPlayTo);
- if (pRegion)
- {
- bNoRegion = FALSE;
- }
- }
- }
- if(bNoRegion)
- {
- // region name is tuner name if it's anonymous
- pPlayToAssoc->m_playTo = pPlayToAssoc->m_childTunerName;
- }
- else
- {
- pPlayToAssoc->m_playTo = pPlayTo;
- }
- if(!m_pPlayToAssocList)
- {
- m_pPlayToAssocList = new CHXSimpleList;
- }
- m_pPlayToAssocList->AddTail(pPlayToAssoc);
- }
- }
- void
- CSmilDocumentRenderer::removeSourcemap(SMILPlayToAssoc* pPlayToAssoc)
- {
- // get to the site manager and remove event hook
- IHXEventHookMgr* pHookMgr = NULL;
- m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr, (void**)&pHookMgr);
- CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
- for(; j != pPlayToAssoc->m_sourceMap.End(); ++j)
- {
- CHXSimpleList* pRendererList = (CHXSimpleList*)(*j);
- HX_ASSERT(pRendererList);
- // /Check for NULL (fixes part of PR 120999) in case we are flippling
- // back and forth between nested meta clip and another clip in a list:
- if (pRendererList)
- {
- CHXSimpleList::Iterator k = pRendererList->Begin();
- for (; k != pRendererList->End(); ++k)
- {
- SMILSourceInfo* pSMILSourceInfo = (SMILSourceInfo*)(*k);
- if (pSMILSourceInfo->m_pRendererEventHook && pHookMgr)
- {
- pHookMgr->RemoveHook(pSMILSourceInfo->m_pRendererEventHook,
- pSMILSourceInfo->m_pRendererEventHook->GetChannelName(), 0);
- }
- HX_RELEASE(pSMILSourceInfo->m_pRendererEventHook);
- HX_RELEASE(pSMILSourceInfo->m_pStream);
- HX_RELEASE(pSMILSourceInfo->m_pRenderer);
-
- HX_DELETE(pSMILSourceInfo);
- }
- }
- HX_DELETE(pRendererList);
- }
- pPlayToAssoc->m_sourceMap.RemoveAll();
- HX_RELEASE(pHookMgr);
- }
- void
- CSmilDocumentRenderer::removeAllPlayToAssoc()
- {
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)(*i);
-
- HX_DELETE(pPlayToAssoc->m_pHyperlinks);
-
- removeSourcemap(pPlayToAssoc);
- if (pPlayToAssoc->m_pSiteInfoList)
- {
- pPlayToAssoc->m_pSiteInfoList->RemoveAll();
- HX_DELETE(pPlayToAssoc->m_pSiteInfoList);
- }
-
- HX_DELETE(pPlayToAssoc);
- }
- }
- HX_DELETE(m_pPlayToAssocList);
- }
- void
- CSmilDocumentRenderer::removeGroupsPlayToAssoc(UINT16 uGroupIndex)
- {
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)(*i);
-
- /*
- if the PlayToAssoc has the same group number as the group index,
- then remove it.
- */
-
- if ( pPlayToAssoc->m_uGroupIndex == uGroupIndex )
- {
- removeSourcemap(pPlayToAssoc);
- if (pPlayToAssoc->m_pSiteInfoList)
- {
- pPlayToAssoc->m_pSiteInfoList->RemoveAll();
- }
-
- break;
- }
- }
- }
- }
- void
- CSmilDocumentRenderer::removeTracksPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex)
- {
- if (!m_pPlayToAssocList)
- {
- return;
- }
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while(pos)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)m_pPlayToAssocList->GetAt(pos);
- if (pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
- pPlayToAssoc->m_uTrackIndex == uTrackIndex)
- {
- removeSourcemap(pPlayToAssoc);
- HX_DELETE(pPlayToAssoc->m_pHyperlinks);
- HX_DELETE(pPlayToAssoc->m_pSiteInfoList);
- HX_DELETE(pPlayToAssoc);
- m_pPlayToAssocList->RemoveAt(pos);
- break;
- }
- m_pPlayToAssocList->GetNext(pos);
- }
-
- return;
- }
- BOOL
- CSmilDocumentRenderer::isMediaPausedAndDisabled(const char* pID)
- {
- BOOL bIsPausedAndDisabled = FALSE;
- CHXString* pTmpCStr;
- if (m_pPausedAndDisabledIDMap &&
- m_pPausedAndDisabledIDMap->Lookup(pID, (void*&)pTmpCStr))
- {
- bIsPausedAndDisabled = TRUE;
- }
- return bIsPausedAndDisabled;
- }
- BOOL
- CSmilDocumentRenderer::reenablePausedAndDisabledMedia(const char* pID,
- UINT16 uGroupIndex)
- {
- BOOL bWasPausedAndDisabledAndNowIsNot = FALSE;
- CHXString* pTmpCStr;
- if (m_pPausedAndDisabledIDMap &&
- m_pPausedAndDisabledIDMap->Lookup(pID, (void*&)pTmpCStr))
- {
- bWasPausedAndDisabledAndNowIsNot = TRUE;
- if(!m_pPausedAndDisabledIDMap->RemoveKey(pID))
- {
- HX_ASSERT(0); //RemoveKey() should never fail, but...
- (*m_pPausedAndDisabledIDMap)[pID] = NULL;
- }
- HX_DELETE(pTmpCStr);
- }
- float* pfPrePauseBrightness = NULL;
- if (m_pPausedAndDisabledBrightnessMap &&
- m_pPausedAndDisabledBrightnessMap->Lookup(pID,
- (void*&)pfPrePauseBrightness))
- {
- if(!m_pPausedAndDisabledBrightnessMap->RemoveKey(pID))
- {
- HX_ASSERT(0); //RemoveKey() should never fail, but...
- (*m_pPausedAndDisabledBrightnessMap)[pID] = NULL;
- }
- // /Reset it to old brightness. First get the renderer site:
- HX_ASSERT(m_pSiteInfoList);
- if(m_pSiteInfoList)
- {
- CHXSimpleList::Iterator i = m_pSiteInfoList->Begin();
- for(; i != m_pSiteInfoList->End(); ++i)
- {
- SMILSiteInfo* pSiteInfo =(SMILSiteInfo*)(*i);
- if(pSiteInfo->m_uGroupIndex == uGroupIndex &&
- pSiteInfo->m_MediaID == pID)
- {
- IHXVideoControl* pVidCntrls = NULL;
- HX_RESULT pnrVC =
- pSiteInfo->m_pRendererSite->QueryInterface(
- IID_IHXVideoControl, (void**)&pVidCntrls);
- if (SUCCEEDED(pnrVC))
- {
- HX_RESULT rsltSetBrtness = pVidCntrls->SetBrightness(
- *pfPrePauseBrightness);
- pSiteInfo->m_pRendererSite->ForceRedraw();
- HX_RELEASE(pVidCntrls);
- }
- HX_DELETE(pfPrePauseBrightness);
- }
- }
- }
- }
- return bWasPausedAndDisabledAndNowIsNot;
- }
- CSmilAAnchorElement*
- CSmilDocumentRenderer::findHyperlinkElement(const char* pID, // region ID
- const char* pMediaID,
- UINT16 uXPos,
- UINT16 uYPos,
- BOOL bResolveBeginOfFragmentTarget)
- {
- // This code is not needed with new windowless site impl. of fullscreen
- if (IsFullScreen())
- {
- IHXSiteWindowless* pSiteWndless = NULL;
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteWindowless, (void**) &pSiteWndless);
- }
- // need to do this conversion only for the OLD site implementation
- if (m_pRootLayout && m_pRootLayout->m_pSite && pSiteWndless == NULL)
- {
- // If we are at full screen, then we need to scale the x and y
- // mouse locations down to the original size, since for full
- // screen we do not get a resizeSite.
- //
- // Get the current size
- HXxSize cCurSize;
- m_pRootLayout->m_pSite->GetSize(cCurSize);
- // Scale it down
- if (cCurSize.cx && ANCHOR_POS_DONTCARE != uXPos)
- {
- uXPos = (UINT16) (uXPos * m_topSiteOriginalSize.cx / cCurSize.cx);
- }
- if (cCurSize.cy && ANCHOR_POS_DONTCARE != uYPos)
- {
- uYPos = (UINT16) (uYPos * m_topSiteOriginalSize.cy / cCurSize.cy);
- }
- }
-
- HX_RELEASE(pSiteWndless);
- }
- // /In order to fix PR 55110, we need to find the link that is on top in
- // the region, not just the first active link in the list. The one that
- // is on top is the one that has the highest delay time of all those that
- // are active at the time and place of the click:
- CSmilAAnchorElement* pMostRecentValidAnchor = NULL;
- ULONG32 ulMostRecentValidAnchorBegin = (UINT32)-1;
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pAssoc = (SMILPlayToAssoc*)(*i);
- if(strcmp((const char*)pAssoc->m_playTo, pID) == 0 &&
- strcmp((const char*)pAssoc->m_id, pMediaID) == 0 &&
- pAssoc->m_uGroupIndex == m_uCurrentGroupIndex &&
- pAssoc->m_pHyperlinks)
- {
- if(pAssoc->m_ulDelay == (UINT32)-1)
- {
- // not resolved yet
- return NULL;
- }
- // see if this site is current (visible) now;
- // if it isn't then no hyperlinks can be active
- // on that site.
- if (pAssoc->m_pSiteInfoList)
- {
- CHXSimpleList::Iterator j = pAssoc->m_pSiteInfoList->Begin();
- for (; j != pAssoc->m_pSiteInfoList->End(); ++j)
- {
- BOOL bCurrentSite = TRUE; // if no site info, then
- // the site is always current
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*)(*j);
- ULONG32 ulTime = m_ulCurrentTime;
- if (m_bSMILPresentationHasEnded)
- {
- // /1/2 sec grace for last time sync to come
- // after end of presentation:
- ulTime -= (ulTime>500? 500: ulTime);
- }
- if(pSiteInfo->m_bRemoveSite)
- {
- // /Fix for PR 34836:
- // live sources that have 0 dur, which means they play
- // forever, should have MAX_ULONG32, not 0, used as
- // their dur when calculating whether or not they're
- // visible at the current time:
- ULONG32 ulDur = pAssoc->m_ulDuration;
- if (pAssoc->m_bLiveSource && 0 == ulDur)
- {
- ulDur = (ULONG32)(-1);
- }
- bCurrentSite = ulTime >= pSiteInfo->m_ulDelay &&
- ulTime <= pSiteInfo->m_ulDelay +
- ulDur;
- }
- else
- {
- bCurrentSite = ulTime >= pSiteInfo->m_ulDelay;
- }
-
- if(bCurrentSite)
- {
- UINT32 ulRelativeTime = ulTime - pAssoc->m_ulDelay;
- CHXSimpleList::Iterator j = pAssoc->m_pHyperlinks->Begin();
- for(; j != pAssoc->m_pHyperlinks->End(); ++j)
- {
- CSmilAAnchorElement* pAnchor = (CSmilAAnchorElement*)(*j);
- CSmilBasicRegion* pRegion = getRegionByID(pAssoc->m_playTo);
- if (pRegion)
- {
- HXxRect mediaRect;
- mediaRect.left = 0;
- mediaRect.top = 0;
- if(pRegion->m_bMediaSizeSet)
- {
- mediaRect.right = pRegion->m_mediaSize.cx;
- mediaRect.bottom = pRegion->m_mediaSize.cy;
- }
- else
- {
- mediaRect.right = pRegion->m_rect.right;
- mediaRect.bottom = pRegion->m_rect.bottom;
- }
- // /ulRelativeTime is begin of anchor element
- // relative to begin of element that got this
- // mouse event, so we need to adjust for begin
- // offset from its sync-base in the case where
- // this is an 'a' element which actually has
- // the same sync-base, i.e., its sync-base is
- // *not* (its child) element that got the mouse
- // event:
- ULONG32 ulBeginAdjustmentIfIsAAnchor = 0;
- ULONG32 ulCurElementDelay = pAnchor->m_ulDelay;
- if (pAnchor->isAAnchor())
- {
- CSmilElement* pThisElement =
- m_pSmilParser->findElement(pAssoc->m_id);
- if (pThisElement && pThisElement->
- m_bCurBeginIsOffsetFromSyncBase)
- {
- ulBeginAdjustmentIfIsAAnchor =
- pThisElement->
- m_ulBeginOffsetFromSyncBase;
- }
- ulRelativeTime +=
- ulBeginAdjustmentIfIsAAnchor;
- // /If anchor delay isn't set, just use it's
- // child media's delay:
- if ((UINT32)-1 == ulCurElementDelay)
- {
- ulCurElementDelay = pThisElement->m_ulDelay;
- }
- }
- if(pAnchor->isCurrentLink(ulRelativeTime,
- uXPos, uYPos, mediaRect,
- (ResizeZoom == pRegion->m_eResizeBehavior),
- pRegion->m_dZoomScaleFactorX,
- pRegion->m_dZoomScaleFactorY))
- {
- if ((UINT32)-1 ==
- ulMostRecentValidAnchorBegin ||
- ulMostRecentValidAnchorBegin <=
- ulCurElementDelay)
- {
- ulMostRecentValidAnchorBegin = ulCurElementDelay;
- pMostRecentValidAnchor = pAnchor;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (pMostRecentValidAnchor)
- {
- //Now, we have to see if this points to a
- // fragment in the current SMIL presentation and,
- // if so, make sure that the begin time of the
- // associated element has been resolved. If not,
- // we need to resolve it, per the SMIL 2.0 spec,
- // but only if on an activation of this hyperlink,
- // i.e., if bResolveTargetBeginIfFragment==TRUE:
- const char* pFragment = pMostRecentValidAnchor->m_href.GetBuffer(2);
- HX_ASSERT(pFragment);
- //Only do the following if this is a fragment:
- if(pFragment && '#' == *pFragment)
- {
- BOOL bFragFoundAndResolved = TRUE;
- UINT32 ulFragmentOffset = m_pSmilParser->getFragmentOffset(
- &(pFragment[1]),
- /* This is passed by ref:*/
- bFragFoundAndResolved, bResolveBeginOfFragmentTarget,
- m_ulCurrentTime);
- //Fixes PR 22655:
- //Ignore if not found or not yet resolved:
- if (!bFragFoundAndResolved)
- {
- return NULL;
- }
- }
- return pMostRecentValidAnchor;
- }
- return NULL;
- }
- // /Returns NULL if element doesn't have either an alt or a
- // longdesc value, otherwise returns the element with the pID:
- CSmilElement*
- CSmilDocumentRenderer::findIfCurElementHasAltOrLongdesc(const char* pID,
- UINT16 ulXPos, UINT16 ulYPos)
- {
- CSmilElement* pRetElement = NULL;
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- // /We need to return the one who's on top in this region in case there
- // are multiple media playing to this region:
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pAssoc = (SMILPlayToAssoc*)(*i);
- if(strcmp((const char*)pAssoc->m_playTo, pID) == 0 &&
- pAssoc->m_uGroupIndex == m_uCurrentGroupIndex)
- {
- if(pAssoc->m_ulDelay == (UINT32)-1)
- {
- // not resolved yet
- continue; // /Check for other media playing to this region.
- }
- // /Optimization: helps speed up the decision as to whether or not
- // this one should even be considered:
- if (pAssoc->m_ulDuration + pAssoc->m_ulDelay <= m_ulCurrentTime &&
- pAssoc->m_bRemoveSite)
- {
- continue; // /Check for other media playing to this region.
- }
- // /First, see if this (x,y) point is over the media in this
- // region:
- CSmilBasicRegion* pRegion = getRegionByID(pAssoc->m_playTo);
- if (pRegion)
- {
- HXxRect mediaRect;
- mediaRect.left = 0;
- mediaRect.top = 0;
- if(pRegion->m_bMediaSizeSet)
- {
- mediaRect.right = pRegion->m_mediaSize.cx;
- mediaRect.bottom = pRegion->m_mediaSize.cy;
- }
- else
- {
- mediaRect.right = pRegion->m_rect.right;
- mediaRect.bottom = pRegion->m_rect.bottom;
- }
- UINT32 ulWidth =
- mediaRect.right - mediaRect.left;
- UINT32 ulHeight =
- mediaRect.bottom - mediaRect.top;
- if(ulXPos > ulWidth || ulYPos > ulHeight)
- {
- // /It's not in bounds, so keep looking:
- continue;
- }
- }
- // see if this site is current (visible) now;
- // if it isn't then no element can be active
- // in that site:
- if (pAssoc->m_pSiteInfoList)
- {
- CHXSimpleList::Iterator j = pAssoc->m_pSiteInfoList->Begin();
- for (; j != pAssoc->m_pSiteInfoList->End(); ++j)
- {
- BOOL bCurrentSite = TRUE; // if no site info, then
- // the site is always current
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*)(*j);
- if(pSiteInfo->m_bRemoveSite)
- {
- // /Live sources that have 0 dur, meaning they play
- // forever, should have MAX_ULONG32, not 0, used as
- // their dur when calculating whether or not they're
- // visible at the current time:
- ULONG32 ulDur = pAssoc->m_ulDuration;
- if (pAssoc->m_bLiveSource && 0 == ulDur)
- {
- ulDur = (ULONG32)(-1);
- }
- bCurrentSite =
- m_ulCurrentTime >= pSiteInfo->m_ulDelay &&
- m_ulCurrentTime <= pSiteInfo->m_ulDelay+ulDur;
- }
- else
- {
- bCurrentSite = m_ulCurrentTime >= pSiteInfo->m_ulDelay;
- }
-
- if(bCurrentSite)
- {
- CSmilElement* pElement = m_pSmilParser->findElement(
- pAssoc->m_id);
- // /Now, see if element has alt tag:
- if (pElement)
- {
- if (pElement->m_alt.GetLength() > 0 ||
- pElement->m_longdesc.GetLength() > 0)
- {
- // /Found it, so assign it as temp winner:
- pRetElement = pElement;
- // /Fixes PR 53282 by continuing (instead of
- // quitting & returning the first one found):
- // this one is on top of all others in this
- // region so far; resolveZOrder() says it has
- // sorted them so that the highest z-ordered
- // one is the last in the list, so all we
- // have to do is continue looking but keep
- // this one as the temporary winner until
- // another, later one is found:
- continue;
- }
- }
- }
- }
- }
- }
- }
- return pRetElement;
- }
- STDMETHODIMP CSmilDocumentRenderer::HandleMouseMove(
- void* pWindow,
- const char* pID, // Region ID
- const char* pMediaID,
- UINT16 uXPos,
- UINT16 uYPos,
- UINT32 kRMAEvent,
- REF(BOOL) bHandleSetCursor)
- {
- // since IHXStatusMessage::SetStatus() effectively
- // results in a mouse move (and I don't want to loop
- // forever) don't do anything if this mouse move event
- // has the same xy as the previous mouse move event
- bHandleSetCursor = FALSE;
- if(uXPos == m_usOldXPos &&
- uYPos == m_usOldYPos)
- {
- // /We don't want to claim HXR_OK in case media itself needs this
- // mouse event:
- return HXR_CANCELLED;
- }
- m_usOldXPos = uXPos;
- m_usOldYPos = uYPos;
- HX_RESULT rc = HXR_FAIL;
- BOOL bIsMouseLeaveEvent = (HX_MOUSE_LEAVE == kRMAEvent);
- if (pMediaID)
- {
- HX_RESULT rslt = HXR_FAILED;
- switch (kRMAEvent)
- {
- case HX_MOUSE_MOVE:
- {
- }
- break;
- case HX_MOUSE_ENTER:
- {
- rslt = m_pSmilParser->tryToResolveBeginEndEvents(
- "inBoundsEvent", pMediaID, m_ulCurrentTime+1);
- }
- break;
- case HX_MOUSE_LEAVE:
- {
- HX_RESULT rslt = m_pSmilParser->tryToResolveBeginEndEvents(
- "outOfBoundsEvent", pMediaID, m_ulCurrentTime);
- }
- break;
- default:
- {
- HX_ASSERT(kRMAEvent && "unexpected mouse event");
- break;
- }
- }
- if (SUCCEEDED(rslt) &&
- // /Fixes PR 56052: don't do anything after end of
- // presentation otherwise layout
- !m_bSMILPresentationHasEnded)
- {
- handleElements();
- }
- }
- #if defined(_WINDOWS)
- HCURSOR hCurrentCursor = GetCursor();
- #endif
- CSmilAAnchorElement* pAnchor = NULL;
- HX_ASSERT(pMediaID);
- if (pMediaID && !isMediaPausedAndDisabled(pMediaID) &&
- // /For mouse leave event, don't find hyperlink:
- !bIsMouseLeaveEvent)
- {
- pAnchor = findHyperlinkElement(pID, pMediaID, uXPos, uYPos);
- }
- // /Fixes PR 56503: if any element will begin or end when pID is clicked
- // (i.e., if any has begin|end="pID.activateEvent[+|-n]") then we should
- // show the hand cursor:
- BOOL bHasActivateEventListener = FALSE;
- if (!pAnchor && HX_MOUSE_MOVE == kRMAEvent && pMediaID &&
- // /Fixes case where presentation has stopped; we don't want
- // to show the hand cursor for activateEvents because they
- // won't do anything when presentation is done:
- !m_bSMILPresentationHasEnded)
- {
- bHasActivateEventListener = m_pSmilParser->hasActivateEventListener(
- pMediaID, m_uCurrentGroupIndex);
- }
- if(pAnchor || bHasActivateEventListener)
- {
- #if defined(_WINDOWS)
- if(hCurrentCursor != m_hHyperlinkCursor)
- {
- m_bNeedToSetHyperlinkCursor = TRUE;
- }
- #elif defined(_MACINTOSH)
- if (m_hHyperlinkCursor)
- {
- m_bResetCursor = TRUE;
- ::SetCursor(*m_hHyperlinkCursor);
- }
- #endif
- #if defined(_UNIX) && (!(defined(_BEOS))) && defined(USE_XWINDOWS)
- if (m_pDisplay && m_Window && m_hHyperlinkCursor && m_hCurrentCursor != m_hHyperlinkCursor)
- {
- XLockDisplay(m_pDisplay);
- XDefineCursor(m_pDisplay, m_Window, m_hHyperlinkCursor);
- XUnlockDisplay(m_pDisplay);
- m_hCurrentCursor = m_hHyperlinkCursor;
- }
- #endif
- if (m_pStatusMessage && pAnchor)
- {
- // /Override displaying of URL if alt can be shown instead:
- if (pAnchor->m_alt.GetLength() > 0)
- {
- m_pStatusMessage->SetStatus (pAnchor->m_alt);
- }
- else
- {
- m_pStatusMessage->SetStatus (pAnchor->m_href);
- }
- m_bStatusMessageSet = TRUE;
- }
- rc = HXR_OK; // handled
- }
- else
- {
- BOOL bOKToResetStatusMessage = TRUE;
- // /There's no anchor displayed in the status bar, so look to see
- // if this element has an alt tag value (or longdesc) and, if so,
- // display it:
- CSmilElement* pElemAltOrLongdesc =
- findIfCurElementHasAltOrLongdesc(pID, uXPos, uYPos);
- if (pElemAltOrLongdesc)
- {
- if (m_pStatusMessage)
- {
- if (pElemAltOrLongdesc->m_alt.GetLength() > 0)
- {
- m_pStatusMessage->SetStatus(
- pElemAltOrLongdesc->m_alt);
- m_bStatusMessageSet = TRUE;
- bOKToResetStatusMessage = FALSE;
- }
- }
- }
- #if defined(_WINDOWS)
- if(hCurrentCursor == m_hHyperlinkCursor)
- {
- //We need to change it back -- we just moved off of a hyperlink:
- m_bNeedToSetHyperlinkCursor = FALSE;
- // /Do opposite logic for for mouse Leave event:
- if (bIsMouseLeaveEvent)
- {
- // /We need to force a cursor update because
- // handleSetCursor() doesn't get called when we move off of
- // linked media and onto an area where there is no media:
- bHandleSetCursor = TRUE;
- }
- }
- #elif defined(_MACINTOSH)
- if (m_bResetCursor)
- {
- m_bResetCursor = FALSE;
- InitCursor();
- }
- #elif defined(_UNIX) && (!(defined(_BEOS))) && defined(USE_XWINDOWS)
- if (m_pDisplay && m_Window && m_hCurrentCursor == m_hHyperlinkCursor)
- {
- XLockDisplay(m_pDisplay);
- XUndefineCursor(m_pDisplay, m_Window);
- XUnlockDisplay(m_pDisplay);
- m_hCurrentCursor = 0;
- }
- #endif
- if (m_pStatusMessage && bOKToResetStatusMessage &&
- m_bStatusMessageSet)
- {
- m_pStatusMessage->SetStatus(NULL);
- m_bStatusMessageSet = FALSE;
- }
- }
- return rc;
- }
- STDMETHODIMP_(BOOL) CSmilDocumentRenderer::HandleSetCursor()
- {
- BOOL rc = FALSE;
- #ifdef _WINDOWS
- if(m_bNeedToSetHyperlinkCursor)
- {
- // We don't want to overwrite our pre hyperlink cursor
- HCURSOR hTemp = SetCursor(m_hHyperlinkCursor);
- if (hTemp != m_hHyperlinkCursor)
- {
- m_hPreHyperlinkCursor = hTemp;
-
- }
- rc = TRUE;
- }
- else if (m_hPreHyperlinkCursor)
- {
- SetCursor(m_hPreHyperlinkCursor);
- m_hPreHyperlinkCursor = NULL;
- rc = TRUE;
- }
- #endif
- return rc;
- }
- STDMETHODIMP CSmilDocumentRenderer::HandleLButtonUp(const char* pRegionID,
- const char* pMediaID,
- UINT16 uXPos,
- UINT16 uYPos,
- REF(BOOL) rbHandled)
- {
- #if defined(_UNIX) && (!(defined(_BEOS))) && defined(USE_XWINDOWS)
- //Clear the previously set cursors before leaving this window
- if(m_Window)
- {
- XLockDisplay(m_pDisplay);
- XUndefineCursor(m_pDisplay, m_Window);
- XUnlockDisplay(m_pDisplay);
- }
- #endif
- // /Note: "activateEvent" is equivalent to a click event on
- // the primary mouse button or when a series of keystrokes
- // activates the visual element. We got here because of a
- // mouse click, so we need to fire a "focusInEvent" if the
- // element didn't already have the "focus":
- /* // /XXXEH- TODO: add and manage variable that keeps track of
- // which element has the focus, if any, and fire it if this
- // element does not have it when clicked:
- if (!hasSMIL2_20000731Draft_Focus((const char*)pPlayToAssoc->m_playTo))
- {
- rslt = m_pSmilParser->tryToResolveBeginEndEvents(
- "focusInEvent",
- (const char*)pPlayToAssoc->m_id,m_ulCurrentTime);
- }
- */
- HX_RESULT rc = HXR_OK;
- rbHandled = FALSE;
- CSmilAAnchorElement* pAnchor = NULL;
- if (!isMediaPausedAndDisabled(pMediaID))
- {
- BOOL bResolveTargetBeginIfFragment = TRUE;
- pAnchor = findHyperlinkElement(pRegionID, pMediaID, uXPos, uYPos,
- bResolveTargetBeginIfFragment);
- rc = handleNamedEvent(pRegionID, pMediaID, "activateEvent");
- }
- HX_RESULT rcHLT = HXR_OK;
-
- if (pAnchor)
- {
- rcHLT = handleHyperlinkTraversal(pAnchor);
- if (SUCCEEDED(rcHLT))
- {
- rbHandled = TRUE;
- }
- }
- rc = (HXR_OK == rc)? rcHLT : rc;
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleHyperlinkTraversal(CSmilAAnchorElement* pAnchor,
- BOOL bCalledFromCallback)
- {
- HX_RESULT rc = HXR_OK;
- HX_RESULT rsltOfRaisingActivateEvent = HXR_FAIL;
- if(pAnchor && pAnchor->m_href.GetLength() > 0)
- {
- if(m_pParent)
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer)
- {
- const char* pTarget = "_player";
- const char* pSendTo = NULL;
- if (pAnchor->m_sendTo.GetLength())
- {
- pSendTo = (const char*)pAnchor->m_sendTo;
- }
- BOOL bIsOnLoadActuation =
- (0 == strcmp(pAnchor->m_actuate, "onLoad"));
- BOOL bForceCallbackForNonExternalLinks =
- !bCalledFromCallback && !pAnchor->m_bExternal;
- if ((bIsOnLoadActuation &&
- ("pause"==pAnchor->m_show ||
- "replace"==pAnchor->m_show)) ||
- // /Always schedule callback if on Mac and
- // PR84836 conditions exist:
- // /Also, to help fix PR 91817, force callback for non-
- // external links in case this is from accesskey press
- // or some other link-activating event on main thread:
- bForceCallbackForNonExternalLinks)
- {
- if (!bCalledFromCallback)
- {
- if (!m_pHyperlinkCallback)
- {
- m_pHyperlinkCallback = new CHyperlinkCallback(this);
- m_pHyperlinkCallback->AddRef();
- }
- if (!(m_pHyperlinkCallback->IsCallbackPending()))
- {
- m_pHyperlinkCallback->SetAnchor(pAnchor);
- m_pHyperlinkCallback->SetCallbackPending(TRUE);
- CallbackHandle hand = m_pScheduler->RelativeEnter(
- m_pHyperlinkCallback, 0);
- m_pHyperlinkCallback->SetCallbackHandle(hand);
- }
- else
- {
- // /Helps fix problem brought on by fix for PR 67170
- // and PR 67536: allow for multiple simultaneous
- // hurls at the same time. This will only happen
- // right after a seek as long as findNextPendingOn..
- // only returns more than one anchor after a seek:
- HX_RESULT pnrslt =
- m_pHyperlinkCallback->AddAdditionalAnchor(pAnchor);
- HX_ASSERT (HXR_OK == pnrslt);
- }
- return HXR_OK;
- }
- }
- if (pAnchor->m_bExternal)
- {
- if (pAnchor->m_target.GetLength() > 0)
- {
- // /Viper now has control over the "external" browser
- // that is integrated into the Viper player UI.
- // Sending the SMIL-file-specifed link's target value
- // instead of just "_browser" fixes PR 56073:
- pTarget = (const char*)pAnchor->m_target;
- }
- else // /Use old-school value:
- {
- pTarget = "_browser";
- }
- }
- // /This is possibly used in at least two places, below:
- const char* pszEventName = "activateEvent";
- // /In order to decide what to do when pAnchor->m_target is
- // set, we need to figure out if that string matches a region
- // in the current presentation's layout. If so, we need to
- // play the URL in that region, else we need to play it to
- // an external player (or to a browser if external="true"):
- BOOL bNeedToTargetANamedPlayerInstance = FALSE;
- if (pAnchor->m_target.GetLength() > 0)
- {
- HX_ASSERT("replace(ignored)"==pAnchor->m_show);
- if (!pAnchor->m_bTargetIsARegion && !pAnchor->m_bExternal)
- {
- // /Setting this and using it, below, fixes PR 55404:
- bNeedToTargetANamedPlayerInstance = TRUE;
- }
- // /Helps fix PR 52891: pAnchor targets a region, so
- // activate the element that's been set up to play when
- // this link gets activated:
- else if (pAnchor->m_pNode &&
- // /Fixes PR 57845: above if() could have failed
- // for other reasons, so make sure this is TRUE:
- pAnchor->m_bTargetIsARegion)
- {
- HX_RESULT rslt = HXR_OK;
- rslt = m_pSmilParser->tryToResolveBeginEndEvents(
- pszEventName, // /"activateEvent"
- (const char*)pAnchor->m_pNode->m_id,
- m_ulCurrentTime);
- if SUCCEEDED(rslt)
- {
- handleElements();
- }
- goto cleanup;
- }
- }
- // /This fixes PR 77583 so that a, area, anchor all raise
- // activateEvents so that other elements can begin/end on
- // them, but only if the link is going to an external source,
- // i.e., not replacing the current presentation. Some members
- // of the W3C SYMM Working Group that defined SMIL 2.0 said
- // that our implementation was faulty for not raising
- // activateEvents on anchors, but the spec isn't specific
- // about whether or not you need to raise this. It's useful,
- // however, so just do it:
- if (pAnchor->m_bExternal || pAnchor->m_show != "replace")
- {
- rsltOfRaisingActivateEvent =
- m_pSmilParser->tryToResolveBeginEndEvents(
- pszEventName, // /"activateEvent"
- (const char*)pAnchor->m_pNode->m_id,
- m_ulCurrentTime);
- }
- if(pAnchor->m_href[0] == '#')
- {
- pPlayer->AddRef();
- // relative URL, just seek...
- CHXString fragID = pAnchor->m_href.Mid(1);
- seekTo(fragID);
- pPlayer->Release();
- }
- else
- {
- IHXHyperNavigate* pHyper = 0;
- /* Calculate source player's play state noting that
- * show's value can override the m_sourcePlaystate val:
- * The logic comes out to:
- * if (show=="pause" || show="replace")
- * := pause
- * else
- * := m_sourcePlaystate
- */
- SMILLinkPlaystate sourcePlaystate =
- SMILLinkPlaystatePause;
- if ( ("pause"==pAnchor->m_show ||
- "replace"==pAnchor->m_show) &&
- !pAnchor->m_bExternal)
- {
- sourcePlaystate = SMILLinkPlaystatePause;
- }
- else
- {
- sourcePlaystate = pAnchor->m_sourcePlaystate;
- }
- m_bDestPlaystateIsPause = (SMILLinkPlaystatePause ==
- pAnchor->m_destinationPlaystate);
- BOOL bIsOldSMIL1ShowEqualsPause =
- ("pause" == pAnchor->m_show);
- // /If the destination player is different from the
- // source (current) player, and if the source player
- // is going to keep playing, then we need to set its
- // relative audio volume level:
- if (SMILLinkPlaystatePlay == sourcePlaystate ||
- // /Helps fix PR 55120: even if src player pauses,
- // we may need to set dest player's audio level:
- SMILLinkPlaystatePause == sourcePlaystate)
- {
- // /Re-wrote this to implement destinationLevel on new
- // or existing LPPlayer; helps fix PR 55120 & PR 55791:
- if (pAnchor->m_ulSourceLevel_pct != 100 ||
- pAnchor->m_ulDestinationLevel_pct != 100)
- {
- UINT16 uCurVol = 50;
- IHXAudioPlayer* pAudioPlayer = NULL;
- if (HXR_OK== pPlayer->QueryInterface(IID_IHXAudioPlayer,
- (void **)&pAudioPlayer))
- {
- #if 0 /*XXXEH- need TLC work in order to enable this: */
- // /XXXH- as soon as I can figure out how to
- // get at the player (LPP) that gets created
- // by the command:openWindow() call that'll
- // happen, below, we'll be able to use
- // pAudioPlayer->GetAudioVolume() instead, on
- // both it and the current (source) player.
- // With those IHXVolume objects that are
- // returned for the respective players, we'll
- // be able to set each players' volume level
- // independently, & without affecting any other
- // players' volumes in the process.
- IHXVolume* pSourceAudioPlayerVolume =
- pAudioPlayer->GetAudioVolume();
- if (pSourceAudioPlayerVolume)
- {
- uCurVol = pSourceAudioPlayerVolume->GetVolume();
- {
- // /Same, so just set shared-by-all-
- // players volume level to new val:
- double fNewSourceVol = (double)(
- (float)uCurVol * (double(float(
- pAnchor->m_ulSourceLevel_pct)) /
- 100.0) );
- pSourceAudioVPlayerVolume->SetVolume(0);
- }
- }
- HX_ASSERT(pSourceAudioPlayerVolume);
- HX_RELEASE(pSourceAudioPlayerVolume);
- #else
- IHXVolume* pSourceVolume =
- pAudioPlayer->GetDeviceVolume();
- if (pSourceVolume)
- {
- uCurVol = pSourceVolume->GetVolume();
- if (pAnchor->m_ulSourceLevel_pct ==
- pAnchor->m_ulDestinationLevel_pct)
- {
- // /Same, so just set shared-by-all-
- // players volume level to new val:
- double fNewSourceVol = (double)(
- (float)uCurVol * (double(float(
- pAnchor->m_ulSourceLevel_pct)) /
- 100.0) );
- pSourceVolume->SetVolume(
- UINT16(ULONG32(
- (float)fNewSourceVol)));
- }
- else if (100 ==
- pAnchor->m_ulDestinationLevel_pct)
- {
- // /Dest. level==100: just adjust
- // current player's tracks' soundLevels
- // to sourceLevel. Fixed PR 55791:
- AdjustSoundLevelsOfAllCurrentTracks(
- (UINT16)m_uCurrentGroupIndex,
- pAnchor->m_ulSourceLevel_pct, NULL);
- }
- else
- {
- // /Dest. level (d) != current player's
- // audio level (s), so set soundLevel to
- // (s*(100/d)) for all source player
- // tracks, then set IHXAudioPlayer
- // volume to d:
- double fS = double((float)
- pAnchor->m_ulSourceLevel_pct);
- double fD = double((float)
- pAnchor->m_ulDestinationLevel_pct);
- // /Avoid divide/0:
- if (fD < XXXEH_MIN_DEST_AUDIOPLAYER_VOL)
- {
- fD = XXXEH_MIN_DEST_AUDIOPLAYER_VOL;
- }
- UINT32 ulNewSourceLevel_pct =
- UINT32(float(fS * (100.0 / fD)));
- // /Avoid too-loud source player trcks:
- if (ulNewSourceLevel_pct <
- XXXEH_MIN_DEST_AUDIOPLAYER_VOL)
- {
- ulNewSourceLevel_pct =
- XXXEH_MIN_DEST_AUDIOPLAYER_VOL;
- }
- // /Adjust current player's tracks:
- AdjustSoundLevelsOfAllCurrentTracks(
- (UINT16)m_uCurrentGroupIndex,
- ulNewSourceLevel_pct, NULL);
- // /Then adjust shared players'
- // volume to get correct dest player
- // volume (fixes PR 55791 case 3):
- double dNewVolumeOfAllPlayers =
- ((double) fD) * ((double) uCurVol) / 100.0;
- UINT32 ulNewVolumeOfAllPlayers =
- (UINT32) dNewVolumeOfAllPlayers;
- pSourceVolume->SetVolume(ulNewVolumeOfAllPlayers);
- }
- }
- HX_ASSERT(pSourceVolume);
- HX_RELEASE(pSourceVolume);
- #endif
- }
- HX_ASSERT(pAudioPlayer);
- HX_RELEASE(pAudioPlayer);
- }
- }
- // /Changing to "if()" from "else if()", here, fixes
- // PR 85007: sourcePlaystate="pause" code was being
- // ignored due to new soundLevel code, above, that
- // co-opted the prior conditional of the if() statement
- // without allowing this original "pause" handling-code to
- // run:
- if (SMILLinkPlaystatePause == sourcePlaystate)
- {
- // /If external or new player, then just pause the
- // current player, otherwise save our spot and launch
- // the new URL in the current player, then wait until
- // that presentation stops and restart the saved one
- // at the saved spot:
- if (pAnchor->m_bExternal || "new"==pAnchor->m_show ||
- bIsOldSMIL1ShowEqualsPause ||
- bNeedToTargetANamedPlayerInstance)
- {
- pPlayer->Pause();
- }
- // /Else save where we are so we can retart where we
- // left off when the new presentation finishes:
- else
- {
- if (!m_pPlayerResumeStack)
- {
- m_pPlayerResumeStack = new CHXStack;
- }
- if (m_pPlayerResumeStack)
- {
- CSmilPlayerResumePos* pResumePos =
- new CSmilPlayerResumePos(
- m_uCurrentGroupIndex,
- m_ulCurrentTime,
- sourcePlaystate);
- m_pPlayerResumeStack->Push(pResumePos);
- }
- }
- }
- // /sourcePlaystate == stop, so stop it:
- else if (SMILLinkPlaystateStop == sourcePlaystate)
- {
- // /m_show must be "new" (not "pause" or "replace"):
- HX_ASSERT("new"==pAnchor->m_show);
- pPlayer->Stop();
- }
- else
- {
- // /sourcePlaystate had better be play, already
- // handled above in prior if():
- HX_ASSERT(SMILLinkPlaystatePlay == sourcePlaystate);
- }
- CHXString urlString;
- convertURL((const char*) m_pParent->getURLRoot(),
- (const char*) m_pParent->getURLPrefix(),
- (const char*) pAnchor->m_href,
- urlString);
- BOOL bIsMailtoURL = !(strncmp("mailto:", urlString, 7));
- if (bIsMailtoURL)
- {
- pTarget = "_browser";
- }
- BOOL bIsCommandOpenWindowURL = FALSE;
- // /Now, if show="new", we need to create a new player
- // and open the URL in it:
- // This is also true of the old SMIL 1.0 show="pause":
- #if defined(XXXEH_USE_OPENWINDOW_METHOD)
- BOOL bIsCommandURL = !(strncmp("command:", urlString, 8));
- if (bIsCommandURL)
- {
- const char* pCommandAction = ((const char*)urlString)+8;
- // /Look for "command:[s*]openwindow" where [s*] is 0
- // or more white-space characters:
- while (isspace(*pCommandAction))
- {
- pCommandAction++;
- }
- if (*pCommandAction)
- {
- bIsCommandOpenWindowURL = !(strnicmp("openWindow",
- pCommandAction, 10));
- }
- }
- if (!bIsCommandURL &&
- (!strncmp("new", pAnchor->m_show,3) ||
- bIsOldSMIL1ShowEqualsPause ||
- bNeedToTargetANamedPlayerInstance) )
- #else
- if (!strncmp("new", pAnchor->m_show,3) ||
- bIsOldSMIL1ShowEqualsPause ||
- bNeedToTargetANamedPlayerInstance)
- #endif
- {
- // /If show is 'new' then either fire off a new
- // player or send it to the browser, depending on
- // what the value of m_bExternal is:
- if (pAnchor->m_bExternal)
- {
- // /If it's external, then go ahead and open in
- // the browser and let it possibly send the URL
- // back to the current player; the SMIL2 Linking
- // Module Draft is silent on what to do here (as
- // of 2001-02-01):
- if(HXR_OK == pPlayer->QueryInterface(
- IID_IHXHyperNavigate, (void**)&pHyper))
- {
- // XXXMEH - use updated method which checks
- // for <rn:param> children
- GoToURLWithParamCheck(urlString, pTarget, pSendTo,
- pHyper, pAnchor, m_pContext,
- !bIsOnLoadActuation);
- // pHyper->GoToURL(urlString, pTarget);
- pHyper->Release();
- }
- }
- else // /Create new player and open URL in it:
- {
- #if defined(XXXEH_USE_OPENWINDOW_METHOD)
- // /Have the TLC create a new player for us via
- // "command:openWindow(windowName,URL,behavior)":
- CHXString pOpenWindowURL = "command:openWindow(";
- // /Now, add the "target", if specified:
- if (pAnchor->m_target.GetLength() > 0)
- {
- pOpenWindowURL += pAnchor->m_target;
- }
- // /Otherwise, we need to make up a unique name:
- else
- {
- pOpenWindowURL += pAnchor->m_pNode->m_id;
- char* pTmp = new char[64];
- ULONG32 ulCurTime = HX_GET_TICKCOUNT();
- itoa(ulCurTime, pTmp, 16);
- pOpenWindowURL += pTmp;
- delete [] pTmp;
- }
- pOpenWindowURL += ",";
- pOpenWindowURL += urlString;
- // /Set the source (current) player's behavior:
- switch (sourcePlaystate)
- {
- case SMILLinkPlaystatePlay:
- {
- pOpenWindowURL += ",behavior=continue";
- }
- break;
- case SMILLinkPlaystatePause:
- {
- pOpenWindowURL += ",behavior=pause";
- }
- break;
- case SMILLinkPlaystateStop:
- {
- pOpenWindowURL += ",behavior=stop";
- }
- break;
- default:
- {
- HX_ASSERT(0&&"bad sourcePlaystate");
- }
- break;
- }
- pOpenWindowURL += ")";
- if(HXR_OK == pPlayer->QueryInterface(
- IID_IHXHyperNavigate, (void**)&pHyper))
- {
- // XXXMEH - use updated method which checks
- // for <rn:param> children
- GoToURLWithParamCheck(pOpenWindowURL, pTarget,
- // /Ignore sendTo if external="false":
- NULL,
- pHyper, pAnchor, m_pContext,
- !bIsOnLoadActuation);
- // pHyper->GoToURL(pOpenWindowURL, pTarget);
- pHyper->Release();
- }
- #else
- #pragma message(" Non-command:openWindow() new-player creation not finished")
- IHXClientEngine* pClientEngine =
- m_pParent->getClientEngine();
- if (pClientEngine)
- {
- IHXPlayer* pNewPlayer = NULL;
- if (HXR_OK == pClientEngine->CreatePlayer(
- pNewPlayer) && pNewPlayer)
- {
- pNewPlayer->SetClientContext(m_pContext);
- // /XXXEH- delete player when done!
- HX_RESULT openrslt = pNewPlayer->OpenURL(
- (const char*)urlString);
- if (HXR_OK == openrslt)
- {
- // /If playstate is pause, then we
- // don't want to begin the player:
- if (SMILLinkPlaystatePause !=
- pAnchor->m_destinationPlaystate)
- {
- pNewPlayer->Begin();
- }
- return HXR_OK;
- }
- }
- }
- #endif /* (else ndef) XXXEH_USE_OPENWINDOW_METHOD.*/
- }
- }
- else if (pAnchor->m_bExternal ||
- // /This fixes PR 76406, as was done below to
- // fix PR 62276: if it's *any* kind of "command:.."
- // URL, send it through IRMAHypernav:
- bIsCommandURL ||
- // /Fixes PR 78480: if it's a "mailto:..." link
- // it needs to go through IMRAHypernav:
- bIsMailtoURL ||
- // /This fixes PR 62276 by making sure
- // command:openwindow ULRs go through IRMAHypernav
- // and pPlayer->OpenURL(). This could be construed
- // as being contrary to the SMIL 2.0 spec by
- // effectively overriding show="replace", but it is
- // a proprietary URL and thus can be handled in a
- // proprietary way, i.e, won't break interoperability:
- bIsCommandOpenWindowURL)
- {
- if(HXR_OK == pPlayer->QueryInterface(
- IID_IHXHyperNavigate, (void**)&pHyper))
- {
- // XXXMEH - use updated method which checks
- // for <rn:param> children
- GoToURLWithParamCheck(urlString, pTarget, pSendTo,
- pHyper, pAnchor, m_pContext,
- !bIsOnLoadActuation);
- // pHyper->GoToURL(urlString, pTarget);
- HX_RELEASE(pHyper);
- }
- }
- else // /Open in same window:
- {
- // /Fixes PR 67630: OpenURL() call resulted in player
- // destroying our parent CSmilRenderer which in turn
- // destroyed us, and subsequent HandleSetCursor() call
- // was causing hang as "this" has been deleted. Fix
- // is to AddRef the parent before calling OpenURL:
- m_pParent->AddRef();
- // /This fixes the subsequent problem (hang) in PR 91817
- // When multiple links are queued to hurl simultaneously,
- // just hurl the first replace-presentation-in-main-
- // player one we come to and delete all the rest:
- if (m_pHyperlinkCallback)
- {
- m_pHyperlinkCallback->ClearExtraAnchorList();
- }
-
- HX_RESULT openrslt = HXR_FAIL;
- BOOL bHandledByPlayer2 = FALSE;
- IHXCommonClassFactory* pFactory=
- m_pParent->getFactory();
- IHXPlayer2* pPlayer2 = NULL;
- if (pFactory && HXR_OK ==
- pPlayer->QueryInterface(IID_IHXPlayer2,
- (void**)&pPlayer2))
- {
- IHXRequest* pRequest = NULL;
- pFactory->CreateInstance(CLSID_IHXRequest,
- (void**) &pRequest);
- if (pRequest)
- {
- IHXValues* pValues = 0;
- if(HXR_OK == pFactory->CreateInstance(
- CLSID_IHXValues, (void**)&pValues))
- {
- // /Fixes open-in-same-window version of
- // PR 84160: call OpenRequest() (with
- // AutoActivated prop) instead of OpenURL:
- pValues->SetPropertyULONG32("AutoActivated",
- (ULONG32)(bIsOnLoadActuation));
- pRequest->SetRequestHeaders(pValues);
- pRequest->SetURL((const char*)urlString);
- bHandledByPlayer2 = TRUE;
- openrslt = pPlayer2->OpenRequest(pRequest);
- HX_RELEASE(pValues);
- }
- HX_RELEASE(pRequest);
- }
- HX_RELEASE(pPlayer2);
- }
- // /No IHXPlayer2 or other prob; just call OpenURL():
- if (!bHandledByPlayer2)
- {
- openrslt = pPlayer->OpenURL((const char*)urlString);
- }
- if (HXR_OK == openrslt)
- {
- // /First, set cursor back to pre-hyperlink one
- // so that the new presentation doesn't have the
- // link "hand" cursor on it at first:
- #if defined(_WINDOWS)
- m_bNeedToSetHyperlinkCursor = FALSE;
- #endif
- HandleSetCursor();
- pPlayer->Begin();
- // /NOTE: if m_bDestPlaystateIsPause, then we'll
- // pause the player after
- // IHXClientAdviseSink::OnBuffering() has been
- // called with 100% done.
- }
- // /Remove ref added prior to OpenURL(), above:
- m_pParent->Release();
- }
- }
- }
- }
- }
- cleanup:
- if SUCCEEDED(rsltOfRaisingActivateEvent)
- {
- handleElements();
- }
- return rc;
- }
-
- STDMETHODIMP CSmilDocumentRenderer::HandleCharEvent(UINT16 uChar)
- {
- HX_RESULT rc = HXR_FAIL;
- // /XXXEH- TODO: fix this after interop. We should probably treat this
- // separate from events and have a "tryToResolveCharPressEvents()" func.
- // Also, handle wide characters (right???):
- char* pEventName = new char[32];
- sprintf(pEventName,"accesskey(%c)", uChar); /* Flawfinder: ignore */
- // /#define XXXEHODGE_DEBUG_OUTPUT_HANDLECHAREVENT
- #if defined(_DEBUG) && defined(XXXEHODGE_DEBUG_OUTPUT_HANDLECHAREVENT)
- {FILE* f1 = ::fopen("c:\smil2.txt", "a+"); ::fprintf(f1, "nHandleCharEvent(%u), currentTime: %lun", uChar, m_ulCurrentTime);::fclose(f1);}
- #endif
- rc = m_pSmilParser->tryToResolveBeginEndEvents(pEventName,
- // /Fixes PR 69849 (and needed for PR 58290): the new optimized
- // code that uses maps instead of lists didn't take into account
- // the fact that accesskey events have no associated event-element
- // ID since they come from the keyboard, so we now use this string
- //(which is an invalid XML id) as the fake ID:
- ACCESSKEY_EVENT_FAKE_ID_STRING,
- m_ulCurrentTime);
- if SUCCEEDED(rc)
- {
- #if defined(_DEBUG) && defined(XXXEHODGE_DEBUG_OUTPUT_HANDLECHAREVENT)
- {FILE* f1 = ::fopen("c:\smil2.txt", "a+"); ::fprintf(f1, "n HandleCharEvent(%u): calling tryToResolveBeginEndEvents() returned HXR_OK at time: %lun", uChar, m_ulCurrentTime);::fclose(f1);}
- #endif
- handleElements();
- }
- // /Next, let's see if we have an anchor|a|area tag awaiting an
- // accesskey event. Go through all currently-playing media and see if
- // any of their anchors are awaiting a keypress:
- if (m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator indx = m_pPlayToAssocList->Begin();
- for(; indx != m_pPlayToAssocList->End(); ++indx)
- {
- SMILPlayToAssoc* pAssoc = (SMILPlayToAssoc*)(*indx);
- if(pAssoc->m_uGroupIndex == m_uCurrentGroupIndex &&
- pAssoc->m_pHyperlinks)
- {
- if(pAssoc->m_ulDelay == (UINT32)-1)
- {
- // not resolved yet
- break;
- }
- CHXSimpleList::Iterator indxA = pAssoc->m_pHyperlinks->Begin();
- for(; indxA != pAssoc->m_pHyperlinks->End(); ++indxA)
- {
- CSmilAAnchorElement* pAnchor =
- (CSmilAAnchorElement*)(*indxA);
- // /XXXEH- TODO: handle wide chars here:
- if (pAnchor->m_accesskey[0] == uChar)
- {
- HXxRect regionRect;
- regionRect.left = 0;
- regionRect.top = 0;
- regionRect.right = (INT32)ANCHOR_POS_DONTCARE;
- regionRect.bottom = (INT32)ANCHOR_POS_DONTCARE;
- ULONG32 ulTime = m_ulCurrentTime;
- if (m_bSMILPresentationHasEnded)
- {
- // /1/2 sec grace for last time sync to come
- // after end of presentation:
- ulTime -= (ulTime>500? 500: ulTime);
- }
- if (pAnchor->isCurrentLink(ulTime,
- ANCHOR_POS_DONTCARE, ANCHOR_POS_DONTCARE,
- regionRect,
- // /XXXEH- need to maybe deal with resized region
- // if multiple hotspots (links w/coords) exist on
- // same media:
- FALSE, 1.0, 1.0))
- {
- // /BE VERY CAREFUL HERE!!!: the following might
- // cause a replacement of this renderer instance by
- // launching a new presentation, so we need to be
- // sure not to do anything but return after this:
- rc = handleHyperlinkTraversal(pAnchor);
- return rc;
- }
- }
- }
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::handleNamedEvent(const char* pRegionID,
- const char* pMediaID,
- const char* pEventName)
- {
- HX_RESULT rc = HXR_OK;
- if (m_pSmilParser)
- {
- HX_RESULT rslt = HXR_OK;
- rslt = m_pSmilParser->tryToResolveBeginEndEvents(pEventName,
- pMediaID,
- m_ulCurrentTime);
- if (SUCCEEDED(rslt))
- {
- handleElements();
- }
- }
- return rc;
- }
- STDMETHODIMP CSmilDocumentRenderer::HandleGotFocus(const char* pRegionID,
- const char* pMediaID)
- {
- return handleNamedEvent(pRegionID, pMediaID, "focusInEvent");
- }
- STDMETHODIMP CSmilDocumentRenderer::HandleLostFocus(const char* pRegionID,
- const char* pMediaID)
- {
- return handleNamedEvent(pRegionID, pMediaID, "focusOutEvent");
- }
- HX_RESULT
- CSmilDocumentRenderer::detachSite(IHXSite* pSite)
- {
- HX_RESULT rc = HXR_OK;
- // remove site from site info list
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while(pos)
- {
- SMILSiteInfo* pSiteInfo =
- (SMILSiteInfo*)m_pSiteInfoList->GetAt(pos);
- if(pSiteInfo->m_pRendererSite == pSite)
- {
- CSmilBasicRegion* pRegion = getRegionByID(pSiteInfo->m_regionID);
- if(pRegion)
- {
- pRegion->m_pSite->DestroyChild(pSite);
- }
- m_pSiteInfoList->RemoveAt(pos);
- // at this time go through the PlayToAssocList list and
- // change any that reference the soon to be removed
- // site info.
- if (m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)(*i);
-
- LISTPOSITION pos = pPlayToAssoc->m_pSiteInfoList->Find(pSiteInfo);
- pPlayToAssoc->m_pSiteInfoList->RemoveAt(pos);
- }
- }
-
- HX_DELETE(pSiteInfo);
- break;
- }
- m_pSiteInfoList->GetNext(pos);
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::doSourceUpdate(SMILPlayToAssoc* pPlayToAssoc,
- CSmilSourceUpdate* pUpdateElement)
- {
- HX_RESULT rc = HXR_OK;
- BOOL bUpdated = FALSE;
- const char* pID = (const char*)pUpdateElement->m_srcID;
- CSmilElement* pThisElement = m_pSmilParser->findElement(pID);
- if (pUpdateElement->m_updateTag == UpdateDuration)
- {
- if(pThisElement->m_bBeginOffsetSet &&
- // /Helps fix PR 79699 et al:
- !pUpdateElement->m_bDurationIsPureOfDelay)
- {
- if((INT32)pUpdateElement->m_ulUpdatedDuration > pThisElement->m_lBeginOffset)
- {
- pPlayToAssoc->m_ulDuration = pUpdateElement->m_ulUpdatedDuration -
- pThisElement->m_lBeginOffset;
- }
- else
- {
- pPlayToAssoc->m_ulDuration = 0;
- }
- }
- else
- {
- pPlayToAssoc->m_ulDuration = pUpdateElement->m_ulUpdatedDuration;
- }
- bUpdated = TRUE;
- }
- else if (pUpdateElement->m_updateTag == UpdateDelay)
- {
- pPlayToAssoc->m_ulDelay = pUpdateElement->m_ulUpdatedDelay;
- bUpdated = TRUE;
- }
- if (bUpdated)
- {
- CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
- CHXSimpleList* pRendererInfoList = (CHXSimpleList*)(*j);
- SMILSourceInfo* pSourceInfo = (SMILSourceInfo*)pRendererInfoList->GetHead();
- IHXLayoutStream* pLayoutStream = NULL;
-
- if(HXR_OK ==
- pSourceInfo->m_pStream->QueryInterface(IID_IHXLayoutStream,
- (void**)&pLayoutStream))
- {
- IHXValues* pStreamProps = NULL;
- if(HXR_OK == pLayoutStream->GetProperties(pStreamProps))
- {
- if (pUpdateElement->m_updateTag == UpdateDuration)
- {
- #if defined(_DEBUG) && defined(XXXEH_DEBUG_HANDLESOURCE_AND_TRACKDURATIONSET)
- ULONG32 ulPriorDuration = pPlayToAssoc->m_ulDuration;
- BOOL bPriorDuration = TRUE;
- if (HXR_OK != pStreamProps->GetPropertyULONG32("duration", ulPriorDuration))
- {
- bPriorDuration = FALSE;
- }
- {FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "$$$ CSmilDocumentRenderer::doSourceUpdate(pID=%s, "
- "pPlayToAssoc->m_ulDuration=%lu, pThisElement->m_ulDuration=%lu,"
- "prior stream duration=%lu%sn", (const char*)pID,
- pPlayToAssoc->m_ulDuration, pThisElement->m_ulDuration, ulPriorDuration,
- bPriorDuration?"":"(NO PRIOR DUR)"); ::fclose(f1);}
- #endif
- pStreamProps->SetPropertyULONG32("duration",
- pPlayToAssoc->m_ulDuration);
- }
- else if (pUpdateElement->m_updateTag == UpdateDelay)
- {
- #if defined(_DEBUG) && defined(XXXEH_DEBUG_HANDLESOURCE_AND_TRACKDURATIONSET)
- ULONG32 ulPriorDelay = pPlayToAssoc->m_ulDelay;
- BOOL bPriorDelay = TRUE;
- if (HXR_OK != pStreamProps->GetPropertyULONG32("delay", ulPriorDelay))
- {
- bPriorDelay = FALSE;
- }
- {FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "$$$ CSmilDocumentRenderer::doSourceUpdate(pID=%s, "
- "pPlayToAssoc->m_ulDelay=%lu, pThisElement->m_ulDelay=%lu,"
- "prior stream delay=%lu%sn", (const char*)pID,
- pPlayToAssoc->m_ulDelay, pThisElement->m_ulDelay, ulPriorDelay,
- bPriorDelay?"":"(NO PRIOR DELAY)"); ::fclose(f1);}
- #endif
- pStreamProps->SetPropertyULONG32("delay",
- pPlayToAssoc->m_ulDelay);
- }
- pLayoutStream->SetProperties(pStreamProps);
- HX_RELEASE(pStreamProps);
- }
- HX_RELEASE(pLayoutStream);
- }
- updateSiteEvents(pPlayToAssoc->m_uGroupIndex);
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::updateStreamTiming(const char* pElementID,
- UINT32 ulDuration)
- {
- HX_RESULT rc = HXR_OK;
- CSmilElement* pElement = m_pSmilParser->findElement(pElementID);
- if(pElement)
- {
- // find the SMILPlayToAssoc associated with this element ID
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pThisAssoc = (SMILPlayToAssoc*)(*i);
- if(pThisAssoc->m_id == (const char*)pElement->m_pNode->m_id &&
- // /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)
- {
- pPlayToAssoc->m_ulDuration = ulDuration;
- CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
-
- CHXSimpleList* pRendererInfoList = (CHXSimpleList*)(*j);
- SMILSourceInfo* pSourceInfo = (SMILSourceInfo*)pRendererInfoList->GetHead();
- IHXLayoutStream* pLayoutStream = NULL;
- if(HXR_OK ==
- pSourceInfo->m_pStream->QueryInterface(IID_IHXLayoutStream,
- (void**)&pLayoutStream))
- {
- IHXValues* pStreamProps = NULL;
- if(HXR_OK == pLayoutStream->GetProperties(pStreamProps))
- {
- #if defined(_DEBUG) && defined(XXXEH_DEBUG_HANDLESOURCE_AND_TRACKDURATIONSET)
- {FILE* f1 = ::fopen("c:\smil2AddDuration.txt", "a+");
- ::fprintf(f1, "^v^ CSmilDocumentRenderer::updateStreamTiming(%s, duration=%lu),"
- "pPlayToAssoc->m_ulDuration=%lu, pElement->m_ulDuration=%lun",
- (const char*)pElementID, ulDuration, pPlayToAssoc->m_ulDuration, pElement->m_ulDuration);
- ::fclose(f1);}
- #endif
- pStreamProps->SetPropertyULONG32("duration", ulDuration);
- pLayoutStream->SetProperties(pStreamProps);
- pStreamProps->Release();
- // XXX HP THIS IS NO-OP!!
- // update delay for subsequent elements
- //updateStreamDelay(pPlayToAssoc->m_uGroupIndex,
- // pPlayToAssoc->m_ulDelay);
- }
- pLayoutStream->Release();
- }
- updateSiteEvents(pPlayToAssoc->m_uGroupIndex);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::updateStreamDelay(UINT16 uGroupIndex,
- UINT32 ulInitialDelay)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)(*i);
- if(pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
- pPlayToAssoc->m_ulDelay > ulInitialDelay)
- {
- UINT32 ulNewDelay = pPlayToAssoc->m_ulDelay;
- pPlayToAssoc->m_ulDelay = ulNewDelay;
- if(pPlayToAssoc->m_sourceMap.GetCount() > 0)
- {
- CHXMapLongToObj::Iterator j = pPlayToAssoc->m_sourceMap.Begin();
- CHXSimpleList* pRendererList = (CHXSimpleList*)(*j);
- CHXSimpleList::Iterator k = pRendererList->Begin();
- for (; k != pRendererList->End(); ++k)
- {
- SMILSourceInfo* pSMILSourceInfo = (SMILSourceInfo*)(*k);
- IHXLayoutStream* pLayoutStream = NULL;
- if(HXR_OK ==
- pSMILSourceInfo->m_pStream->QueryInterface(
- IID_IHXLayoutStream,
- (void**)&pLayoutStream))
- {
- IHXValues* pStreamProps = NULL;
- if(HXR_OK == pLayoutStream->GetProperties(
- pStreamProps))
- {
- pStreamProps->SetPropertyULONG32("delay",
- pPlayToAssoc->m_ulDelay);
- pLayoutStream->SetProperties(pStreamProps);
- pStreamProps->Release();
- }
- pLayoutStream->Release();
- }
- }
- }
- }
- }
- }
- return rc;
- }
- HX_RESULT CSmilDocumentRenderer::updateSiteEvents(UINT16 uGroupIndex)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pPlayToAssocList)
- {
- #if defined(XXXMEH_OLD_UPDATE_SITE_EVENTS)
- // Save the animation events so we
- // can re-add them later
- // XXXMEH - TODO - if an animation beging is tied
- // to the begin of a media element whose previously-scheduled
- // begin time changes, then we need to be able change
- // the animate event.
- CHXSimpleList cTmp;
- if (m_pEventList)
- {
- LISTPOSITION pos = m_pEventList->GetHeadPosition();
- while (pos)
- {
- CSmilLayoutEvent* pEvent =
- (CSmilLayoutEvent*) m_pEventList->GetNext(pos);
- if (pEvent && pEvent->m_type == CSmilLayoutEvent::eAnimate)
- {
- // Cast this to an animate event
- CSmilAnimateEvent* pAnim = (CSmilAnimateEvent*) pEvent;
- // Create a copy
- CSmilAnimateEvent* pNew = new CSmilAnimateEvent(*pAnim);
- if (pNew)
- {
- // Add this to the temporary list
- cTmp.AddTail((void*) pNew);
- }
- }
- }
- }
- #endif
- // blow away current events
- // XXXMEH - 06/27/2001 Why do we want to do this? I'm going to
- // comment this out now and simply do a *check* below to
- // see if the show or hide time for the event changed. If
- // it didn't, then I'm going to leave the event alone.
- #if defined(XXXMEH_OLD_UPDATE_SITE_EVENTS)
- removeGroupEvents(uGroupIndex);
- #endif
- removeActiveTransitions();
- LISTPOSITION ptPos = m_pPlayToAssocList->GetHeadPosition();
- while (ptPos)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(ptPos);
- if (pPlayToAssoc &&
- pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
- pPlayToAssoc->m_pSiteInfoList)
- {
- LISTPOSITION siPos = pPlayToAssoc->m_pSiteInfoList->GetHeadPosition();
- while (siPos)
- {
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*) pPlayToAssoc->m_pSiteInfoList->GetNext(siPos);
- if (pSiteInfo)
- {
- IHXSite* pRegionSite = NULL;
- CSmilBasicRegion* pRegion = getRegionByID(pSiteInfo->m_regionID);
- if(pRegion)
- {
- pRegionSite = pRegion->m_pSite;
- }
- // Start time is delay
- // End time is delay plus duration
- UINT32 ulStartTime = pPlayToAssoc->m_ulDelay;
- UINT32 ulEndTime = pPlayToAssoc->m_ulDelay + pPlayToAssoc->m_ulDuration;
- // Assign the playTo start and end times to the siteinfo
- // delay and duration
- pSiteInfo->m_ulDelay = ulStartTime;
- pSiteInfo->m_ulDuration = ulEndTime;
- // Get the currently scheduled show event for this media
- CSmilShowSiteEvent* pCurShowEvent = getShowHideEvent(pPlayToAssoc->m_id,
- pSiteInfo->m_regionID,
- TRUE);
- if (pCurShowEvent)
- {
- // Is the currently scheduled show event time different
- // from the current start time? If so, then we need to
- // update the start time.
- if (ulStartTime != pCurShowEvent->m_ulEventTime)
- {
- // /Note: we can get here when x in seq gets
- // duration extended during playback & next-
- // in-seq gets further delayed as a consequence.
- // First remove the event from the list
- removeEvent(pCurShowEvent);
- // Update the event time
- pCurShowEvent->m_ulEventTime = ulStartTime;
- // Add the event back in
- insertEvent(pCurShowEvent);
- }
- }
- // Get the currently scheduled hide event for this media
- CSmilShowSiteEvent* pCurHideEvent = getShowHideEvent(pPlayToAssoc->m_id,
- pSiteInfo->m_regionID,
- FALSE);
- if (pCurHideEvent)
- {
- // Get the remove time for this media
- UINT32 ulRemoveTime = 0;
- HX_RESULT rv = m_pSmilParser->computeRemoveTime((const char*) pPlayToAssoc->m_id,
- ulRemoveTime);
- if (FAILED(rv))
- {
- // We couldn't currently compute the remove
- // time, so we set it way out, assuming it will
- // get pulled back later
- ulRemoveTime = WAY_IN_THE_FUTURE;
- }
- // Is the currently scheduled show event time different
- // from the current start time? If so, then we need to
- // update the start time.
- if (ulRemoveTime != pCurHideEvent->m_ulEventTime)
- {
- // First remove the event from the list
- removeEvent(pCurHideEvent);
- // Update the event time
- pCurHideEvent->m_ulEventTime = ulRemoveTime;
- // Get the this event's group duration
- UINT32 ulGroupDur = 0;
- if (getGroupDuration(pCurHideEvent->m_uGroupIndex, ulGroupDur))
- {
- // Get the fill behavior
- FillType eFill = getMediaFillBehavior((const char*) pCurHideEvent->getMediaID());
- // We got the group duration.
- // Is our new hide time scheduled for the
- // group duration?
- if (pCurHideEvent->m_ulEventTime == ulGroupDur &&
- eFill != FillRemove)
- {
- // Yes, it is, so set the flag that
- // says to ignore the hide
- pCurHideEvent->m_bIgnorEvent = TRUE;
- }
- else
- {
- // No, the hide is NOT scheduled for the group
- // duration, so clear the flag that
- // says to ignore the hide
- pCurHideEvent->m_bIgnorEvent = FALSE;
- }
- }
- // Add the event back in
- insertEvent(pCurHideEvent);
- // Set the event time into the element
- setElementRemoveTime(pPlayToAssoc->m_id, ulRemoveTime);
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
- // Do we have a transIn?
- if (pPlayToAssoc->m_beginTransition.GetLength() > 0)
- {
- CSmilTransitionInfo* pTransInfo = getTransition(pPlayToAssoc->m_beginTransition);
- if (pTransInfo)
- {
- if (pSiteInfo->m_ulDelay < m_ulCurrentTime)
- {
- CSmilTransitionEvent* pTransEvent =
- new CSmilTransitionEvent(pPlayToAssoc->m_ulDelay,
- pPlayToAssoc,
- pSiteInfo,
- TRUE,
- this);
- if (pTransEvent)
- {
- insertEvent(pTransEvent);
- }
- }
- else if (m_ulCurrentTime <
- pSiteInfo->m_ulDelay + pTransInfo->m_pTrans->m_ulDuration)
- {
- // don't schedule the transition... but build a state
- // and start the transition...
- startTransition(pSiteInfo->m_ulDelay,
- pTransInfo,
- pSiteInfo,
- pPlayToAssoc,
- NULL,
- m_ulCurrentTime,
- TRUE);
- }
- }
- }
- // Do we have a transOut?
- if (pPlayToAssoc->m_endTransition.GetLength() > 0)
- {
- CSmilTransitionInfo* pTransInfo = getTransition(pPlayToAssoc->m_endTransition);
- if (pTransInfo)
- {
- // if the end of the clip minus the duration of the
- // transition is greater than the current time...
- if (pSiteInfo->m_ulDuration - pTransInfo->m_pTrans->m_ulDuration > m_ulCurrentTime)
- {
- HX_ASSERT(pSiteInfo->m_ulDelay + pSiteInfo->m_ulDuration < m_ulCurrentTime);
- // simply schedule a transition event to occur when the
- // current time reaches the end of the clip minus the
- // duration of the transition.
- CSmilTransitionEvent* pTransEvent =
- new CSmilTransitionEvent(pSiteInfo->m_ulDuration -
- pTransInfo->m_pTrans->m_ulDuration,
- pPlayToAssoc,
- pSiteInfo,
- FALSE,
- this);
- if (pTransEvent)
- {
- insertEvent(pTransEvent);
- }
- }
- else if (pSiteInfo->m_ulDuration < m_ulCurrentTime)
- {
- startTransition(pSiteInfo->m_ulDelay +
- pSiteInfo->m_ulDuration,
- pTransInfo,
- pSiteInfo,
- pPlayToAssoc,
- NULL,
- m_ulCurrentTime,
- FALSE);
- }
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
- } // if (pSiteInfo)
- }
- }
- }
- #if defined(XXXMEH_OLD_UPDATE_SITE_EVENTS)
- // Now add back in the animate events
- if (cTmp.GetCount() > 0)
- {
- LISTPOSITION pos = cTmp.GetHeadPosition();
- while (pos)
- {
- CSmilAnimateEvent* pAnim = (CSmilAnimateEvent*) cTmp.GetNext(pos);
- if (pAnim)
- {
- insertEvent(pAnim);
- }
- }
- cTmp.RemoveAll();
- }
- #endif
- }
- return rc;
- }
- #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
- HX_RESULT CSmilDocumentRenderer::checkSitesHideTime(SMILSiteInfo* pOtherSiteInfo,
- SMILSiteInfo* pSiteInfo,
- CSmilTransitionInfo* pTransInfo,
- REF(IHXSite*) pSiteToTransition,
- BOOL bBeginTransition)
- {
- HX_RESULT ret = HXR_OK;
- if (pOtherSiteInfo->m_pRegionSite == pSiteInfo->m_pRegionSite &&
- pOtherSiteInfo->m_pRendererSite != pSiteInfo->m_pRendererSite)
- {
- pSiteToTransition = pSiteInfo->m_pRendererSite;
- if (bBeginTransition && pOtherSiteInfo->m_ulDuration == pSiteInfo->m_ulDelay)
- {
- // find the site with the closest but still lowest
- // z-order that and the source must start when we end...
- // we need to move back the hide event for this site
- // by our the duration
- INT32 otherZOrder = getSiteZIndex(pOtherSiteInfo->m_pRendererSite);
- INT32 ourZOrder = getSiteZIndex(pSiteInfo->m_pRendererSite);
- if (otherZOrder < ourZOrder)
- {
- pSiteToTransition = pSiteInfo->m_pRendererSite;
- // we want to transition from/to this site...
- // -- move back its hide event...
- // (change the hide event to only hide the site too.)
- ret = moveHideEventForSiteBack(pOtherSiteInfo,
- pOtherSiteInfo->m_ulDuration,
- pTransInfo->m_pTrans->m_ulDuration, TRUE);
- }
- }
- }
- else if (bBeginTransition &&
- pOtherSiteInfo->m_ulDuration == pSiteInfo->m_ulDelay &&
- SitesOverlap(pOtherSiteInfo->m_pRegionSite, pSiteInfo->m_pRegionSite))
- {
- ret = moveHideEventForSiteBack(pOtherSiteInfo,
- pOtherSiteInfo->m_ulDuration,
- pTransInfo->m_pTrans->m_ulDuration, FALSE);
- }
- return ret;
- }
- CSmilTransitionInfo* CSmilDocumentRenderer::getTransition(const char* pID)
- {
- CSmilTransitionInfo* pTransition = NULL;
- if(m_pRegionMap)
- {
- m_pTransitionMap->Lookup(pID, (void*&)pTransition);
- }
- return pTransition;
- }
- HX_RESULT CSmilDocumentRenderer::makeTransitionValues(CSmilTransitionInfo* pInfo,
- BOOL bTransIn,
- REF(IHXValues*) rpValues)
- {
- HX_RESULT retVal = HXR_OK;
- if (pInfo && pInfo->m_pTrans && m_pContext)
- {
- // Get an IHXCommonClassFactory interface
- IHXCommonClassFactory* pFact = NULL;
- retVal = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pFact);
- if (SUCCEEDED(retVal))
- {
- // Create an IHXValues
- HX_RELEASE(rpValues);
- retVal = pFact->CreateInstance(CLSID_IHXValues, (void**) &rpValues);
- if (SUCCEEDED(retVal))
- {
- addStringProperty(rpValues, m_pContext, "type",
- (const char*) pInfo->m_pTrans->m_Type);
- addStringProperty(rpValues, m_pContext, "subtype",
- (const char*) pInfo->m_pTrans->m_SubType);
- addStringProperty(rpValues, m_pContext, "reverse",
- (pInfo->m_pTrans->m_eDirection == TransitionDirectionReverse ? "1" : "0"));
- addStringProperty(rpValues, m_pContext, "TranIn",
- (bTransIn ? "1" : "0"));
- char szTmp[16]; /* Flawfinder: ignore */
- const char* pszTmp = (const char*) &szTmp[0];
- sprintf(szTmp, "%lu", pInfo->m_pTrans->m_ulVertRepeat); /* Flawfinder: ignore */
- addStringProperty(rpValues, m_pContext, "VerticalRepeat", pszTmp);
- sprintf(szTmp, "%lu", pInfo->m_pTrans->m_ulHorzRepeat); /* Flawfinder: ignore */
- addStringProperty(rpValues, m_pContext, "HorizontalRepeat", pszTmp);
- sprintf(szTmp, "%lu", pInfo->m_pTrans->m_ulBorderWidth); /* Flawfinder: ignore */
- addStringProperty(rpValues, m_pContext, "BorderWidth", pszTmp);
- sprintf(szTmp, "%lu", pInfo->m_pTrans->m_ulBorderColor); /* Flawfinder: ignore */
- addStringProperty(rpValues, m_pContext, "BorderColor", pszTmp);
- addStringProperty(rpValues, m_pContext, "BlendBorder",
- (pInfo->m_pTrans->m_bBlendBorder ? "1" : "0"));
- sprintf(szTmp, "%lu", pInfo->m_pTrans->m_ulFadeColor); /* Flawfinder: ignore */
- addStringProperty(rpValues, m_pContext, "FadeColor", pszTmp);
- }
- }
- HX_RELEASE(pFact);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::startTransition(UINT32 ulStartTime,
- CSmilTransitionInfo* pTransInfo,
- SMILSiteInfo* pSiteInfo,
- SMILPlayToAssoc* pAssoc,
- IHXSite* pSite,
- UINT32 ulActualTime,
- BOOL bBeginTransition)
- {
- HX_RESULT retVal = HXR_OK;
- if (pTransInfo && pTransInfo->m_pTrans && pSiteInfo && pAssoc)
- {
- // Get our transition id
- CHXString cOurID;
- UINT32 ulOurDuration = pTransInfo->m_pTrans->m_ulDuration;
- if (pTransInfo->m_pTrans->m_pNode)
- {
- cOurID = pTransInfo->m_pTrans->m_pNode->m_id;
- }
- // Make sure the duration of the site is greater
- // than the duration of the transition
- if (pSiteInfo->m_ulDuration >= pTransInfo->m_pTrans->m_ulDuration)
- {
- // Get the site which will be doing the transition. If we are
- // not a coordinated transition, then we will do the transition
- // always on the renderer site. If we are a coordinated
- // transition, then we will do the transition on the parent
- // region site.
- //
- // Initially we set the renderer site to be the site
- // we will transition on
- IHXSite* pSiteToTransition = pSiteInfo->m_pRendererSite;
- if (pSiteToTransition)
- {
- // Create a SMILTransitionState struct
- SMILTransitionState* pState = new SMILTransitionState;
- if (pState)
- {
- // Null out the struct's memory
- memset((void*) pState, 0, sizeof(SMILTransitionState));
- // Init the values
- pState->m_bBegin = bBeginTransition;
- pState->m_ulEndPercent = (UINT32) (pTransInfo->m_pTrans->m_dEndProgress * 1000.0);
- pState->m_ulStartPercent = (UINT32) (pTransInfo->m_pTrans->m_dStartProgress * 1000.0);
- pState->m_ulDuration = pTransInfo->m_pTrans->m_ulDuration;
- pState->m_ulEndTime = ulStartTime + pTransInfo->m_pTrans->m_ulDuration;
- pState->m_uGroupIndex = pAssoc->m_uGroupIndex;
- pState->m_id = pTransInfo->m_pTrans->m_pNode->m_id;
- // Now initialize the IHXSiteTransition interface
- retVal = pSiteToTransition->QueryInterface(IID_IHXSiteTransition,
- (void**) &pState->m_pSiteTransition);
- if (SUCCEEDED(retVal))
- {
- IHXValues* pValues = NULL;
- retVal = makeTransitionValues(pTransInfo, bBeginTransition, pValues);
- if (SUCCEEDED(retVal))
- {
- MLOG_TRANS(m_pErrorMessages,
- "%lutIRMASiteTransition::Initialize(0x%08x) m_ulCurrentTime=%lun",
- HX_GET_BETTERTICKCOUNT(), m_ulCurrentTime);
- retVal = pState->m_pSiteTransition->Initialize(pValues);
- if (SUCCEEDED(retVal))
- {
- if (!m_pActiveTransitions)
- {
- m_pActiveTransitions = new CHXSimpleList();
- }
- if (m_pActiveTransitions)
- {
- // Add to the list
- LISTPOSITION pos = m_pActiveTransitions->AddTail((void*) pState);
- // Do the transition the first time
- doTransition(pos, ulActualTime);
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- HX_RELEASE(pValues);
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- }
- else
- {
- HX_ASSERT(FALSE);
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
- BOOL CSmilDocumentRenderer::SitesOverlap(IHXSite* pCanidate, IHXSite* pSite)
- {
- /* calculate if our region overlaps with this region.
- check to see if the site has a lower z-order, than our region.
- if these two tests pass and the region is visible:
- search for a hide event on this current region & site,
- pushing back the hide to the end of our duration if one is
- found.
- */
- BOOL bRet = FALSE;
- HXxPoint pntCan;
- HXxPoint pntSite;
- pCanidate->GetPosition(pntCan);
- pSite->GetPosition(pntSite);
- if (pntSite.x == pntCan.x &&
- pntSite.y == pntCan.y)
- {
- HXxSize sizeCan;
- HXxSize sizeSite;
- pCanidate->GetSize(sizeCan);
- pCanidate->GetSize(sizeSite);
- if (sizeCan.cx == sizeSite.cx &&
- sizeCan.cy == sizeSite.cy)
- {
- // check to make sure canidate is behind us in the z-order.
- INT32 canZ = getSiteZIndex(pCanidate);
- INT32 siteZ = getSiteZIndex(pSite);
- if (canZ < siteZ)
- {
- bRet = TRUE;
- }
- }
- }
- return bRet;
- }
- HX_RESULT
- CSmilDocumentRenderer::moveHideEventForSiteBack(SMILSiteInfo* pInfo, UINT32 ulEndTime,
- UINT32 len,
- BOOL bJustRenderer)
- {
- LISTPOSITION lPos = NULL;
- if (m_ulEventListPosition)
- {
- lPos = m_ulEventListPosition;
- }
- else
- {
- lPos = m_pEventList->GetHeadPosition();
- }
- while (lPos)
- {
- CSmilLayoutEvent* pThisEvent = (CSmilLayoutEvent*)
- m_pEventList->GetAt(lPos);
- // we can consider all events because we are starting at
- // the m_ulEventListPosition, therefore, we should start
- // after all events have been executed...
- // if Events are set to happen at the same time, Transitions
- // always are at the top of the list, therefore we can catch
- // hide events that are set to happen right after us, even
- // though the current time is past the event time.
- // pThisEvent->m_ulEventTime >= m_ulCurrentTime &&
- if (pThisEvent->getRegionSite() == pInfo->m_pRegionSite &&
- pThisEvent->getRendererSite() == pInfo->m_pRendererSite &&
- pThisEvent->m_ulEventTime == ulEndTime)
- {
- if (pThisEvent->m_type == CSmilLayoutEvent::eHideSite)
- {
- m_pEventList->RemoveAt(lPos);
- pThisEvent->m_ulEventTime += len;
- pThisEvent->m_bOnlyHideSite = bJustRenderer;
-
- LISTPOSITION pos = m_ulEventListPosition;
- insertEvent(pThisEvent);
- m_ulEventListPosition = pos;
- break;
- }
- else if (pThisEvent->m_type == CSmilLayoutEvent::eShowSite)
- {
- break;
- }
- }
- m_pEventList->GetNext(lPos);
- }
- return HXR_OK;
- }
- HX_RESULT
- CSmilDocumentRenderer::doTransition(LISTPOSITION pos, UINT32 ulTime)
- {
- HX_RESULT ret = HXR_OK;
- if (m_pActiveTransitions)
- {
- if (pos)
- {
- SMILTransitionState* pState = (SMILTransitionState*)
- m_pActiveTransitions->GetAt(pos);
- if (pState)
- {
- INT32 percent = (((INT32)ulTime - (INT32)pState->m_ulEndTime
- + (INT32)pState->m_ulDuration)*
- ((INT32)pState->m_ulEndPercent - (INT32)pState->m_ulStartPercent)/
- (INT32)pState->m_ulDuration) + (INT32)pState->m_ulStartPercent;
- if (percent < (INT32)pState->m_ulStartPercent)
- {
- percent = pState->m_ulStartPercent;
- }
- else if (percent > (INT32)pState->m_ulEndPercent)
- {
- percent = pState->m_ulEndPercent;
- }
- MLOG_TRANS(m_pErrorMessages, "tIRMATransition::SetPercentage(%ld)n", percent);
- pState->m_pSiteTransition->SetPercentage(percent);
- }
- else
- {
- ret = HXR_FAIL;
- }
- }
- }
- else
- {
- ret = HXR_FAIL;
- }
- return ret;
- }
- HX_RESULT
- CSmilDocumentRenderer::seekTo(const char* pElementID)
- {
- HX_RESULT rc = HXR_OK;
- CSmilElement* pElement = m_pSmilParser->findElement(pElementID);
- if(pElement)
- {
- HX_VECTOR_DELETE(m_pFragment);
- m_pFragment = new_string(pElementID);
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- IHXGroupManager* pMgr = 0;
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager, (void**)&pMgr))
- {
- UINT16 uFragmentGroup = m_pSmilParser->getFragmentGroup(m_pFragment);
- if(uFragmentGroup != m_uCurrentGroupIndex)
- {
- m_bSettingFragment = TRUE;
- m_nFragmentTracks = 0;
- pMgr->SetCurrentGroup(uFragmentGroup);
- }
- else
- {
- BOOL bFragFoundAndResolved =TRUE;
- UINT32 ulFragmentOffset =
- m_pSmilParser->getFragmentOffset(m_pFragment,
- /* This is passed by reference: */
- bFragFoundAndResolved);
- //If getFragmentOffset() failed to find the fragment or
- // found it but it did not yet have a resolved begin time,