smldoc.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:673k
- // we used to seek to 0 (the returned value), but now we
- // just don't do a seek:
- // (Note: this problem was found while fixing PR 22655.)
- if(bFragFoundAndResolved)
- {
- pPlayer->Seek(ulFragmentOffset);
- pPlayer->Begin();
- }
- }
- pMgr->Release();
- }
- }
- else
- {
- rc = HXR_FAIL;
- }
- return rc;
- }
- void
- CSmilDocumentRenderer::resizeRegion(const char* pRegionName,
- HXxSize* pNewSize)
- {
- CSmilBasicRegion* pRegion = getRegionByID(pRegionName);
- if(pRegion)
- {
- pRegion->m_rect.right = pRegion->m_rect.left + pNewSize->cx;
- pRegion->m_rect.bottom = pRegion->m_rect.top + pNewSize->cy;
- }
- }
- void
- CSmilDocumentRenderer::repositionRegion(const char* pRegionName,
- HXxPoint* pNewPosition)
- {
- CSmilBasicRegion* pRegion = getRegionByID(pRegionName);
- if(pRegion)
- {
- HXxSize size;
- size.cx = HXxRECT_WIDTH(pRegion->m_rect);
- size.cy = HXxRECT_HEIGHT(pRegion->m_rect);
- pRegion->m_rect.left = pNewPosition->x;
- pRegion->m_rect.top = pNewPosition->y;
- pRegion->m_rect.right = pRegion->m_rect.left + size.cx;
- pRegion->m_rect.bottom = pRegion->m_rect.top + size.cy;
- }
- }
- void CSmilDocumentRenderer::setMediaNativeSize(const char* pszID, HXxSize cSize)
- {
- if (pszID &&
- cSize.cx > 0 && cSize.cy > 0)
- {
- if (!m_bLayoutElementPresent ||
- (m_bLayoutElementPresent && m_bEmptyLayout))
- {
- // Get the source for this renderer. Make sure
- // this source is not trying to manipulate the
- // subregion width and height
- CSmilSource* pSource = getSource(pszID);
- if (pSource &&
- pSource->m_Rect.m_eWidthType == CSS2TypeAuto &&
- pSource->m_Rect.m_eHeightType == CSS2TypeAuto)
- {
- // Set the width and height of the subregion
- // to be the media width and height
- pSource->m_Rect.m_eWidthType = CSS2TypeLength;
- pSource->m_Rect.m_dWidth = (double) cSize.cx;
- pSource->m_Rect.m_eHeightType = CSS2TypeLength;
- pSource->m_Rect.m_dHeight = (double) cSize.cy;
- // If we have not set the "top" attribute, then
- // we will explicitly set it here.
- if (pSource->m_Rect.m_eTopType == CSS2TypeAuto)
- {
- // Get the group index for this media
- UINT16 usGroup = 0;
- SMILPlayToAssoc* pThisPT = getPlayToAssocByMedia(pszID);
- if (pThisPT)
- {
- usGroup = pThisPT->m_uGroupIndex;
- }
- // Find the maximum x and y for all media in this
- // group playing to the default region
- double dMaxX = 0.0;
- double dMaxY = 0.0;
- if (m_pPlayToAssocList)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pPT = (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pPT &&
- pPT->m_id != pszID &&
- pPT->m_uGroupIndex == usGroup &&
- pPT->m_playTo == "jgje4u5kd845prhd94")
- {
- // This media is playing to the default region
- // and is not the current media. Get the source for
- // this media
- CSmilSource* pSrc = getSource(pPT->m_id);
- if (pSrc)
- {
- if (pSrc->m_Rect.m_eTopType == CSS2TypeLength &&
- pSrc->m_Rect.m_eHeightType == CSS2TypeLength)
- {
- double dY = pSrc->m_Rect.m_dTop +
- pSrc->m_Rect.m_dHeight;
- if (dY > dMaxY)
- {
- dMaxY = dY;
- }
- }
- if (pSrc->m_Rect.m_eLeftType == CSS2TypeLength &&
- pSrc->m_Rect.m_eWidthType == CSS2TypeLength)
- {
- double dX = pSrc->m_Rect.m_dLeft +
- pSrc->m_Rect.m_dWidth;
- if (dX > dMaxX)
- {
- dMaxX = dX;
- }
- }
- }
- }
- }
- }
- // Set the subregion left of this media
- pSource->m_Rect.m_eLeftType = CSS2TypeLength;
- pSource->m_Rect.m_dLeft = 0.0;
- // Set the subregion top of this media. If we have
- // an empty layout, then we put everything at the top
- // left. If we have NO layout, then we stack the
- // media up.
- pSource->m_Rect.m_eTopType = CSS2TypeLength;
- pSource->m_Rect.m_dTop = (m_bEmptyLayout ? 0.0 : dMaxY);
- // We need to update the site watcher's copy
- // of the subregion rect. So first we have to get
- // the site watcher
- CSmilSiteWatcher* pWatcher = getRendererSiteWatcher(pszID);
- if (pWatcher)
- {
- // Now update the site watcher's subregion rect
- pWatcher->SetSubRegionRect(pSource->m_Rect);
- }
- // Update the x max to include this media
- double dX = pSource->m_Rect.m_dLeft + pSource->m_Rect.m_dWidth;
- if (dX > dMaxX)
- {
- dMaxX = dX;
- }
- // Update the y max to include this media
- double dY = pSource->m_Rect.m_dTop + pSource->m_Rect.m_dHeight;
- if (dY > dMaxY)
- {
- dMaxY = dY;
- }
- // Now may need to update the width and height of the root-layout
- INT32 lMaxX = (INT32) (dMaxX + 0.5);
- INT32 lMaxY = (INT32) (dMaxY + 0.5);
- HXxSize cRootSize = {lMaxX, lMaxY};
- if (m_pRootLayout &&
- m_pRootLayout->m_pSite &&
- (lMaxX != HXxRECT_WIDTH(m_pRootLayout->m_Rect) ||
- lMaxY != HXxRECT_HEIGHT(m_pRootLayout->m_Rect)))
- {
- m_bDoNotZoom = TRUE;
- m_pRootLayout->m_pSite->SetSize(cRootSize);
- m_bDoNotZoom = FALSE;
- // In the root-layout SetSize() above, we are
- // adjusting the size of the root-layout to account
- // for the additional media which has no layout specified.
- // We make sure above to disable zooming, since this
- // SetSize() doesn't come from resizing the player but
- // rather from our direct manipulation. Here, we also
- // need to reset the root-layout's "original size" so
- // that when we do actually zoom (by resizing the
- // player) that we know the correct original size
- m_pRootLayout->m_OriginalSize = cRootSize;
- }
- }
- }
- }
- }
- }
- void CSmilDocumentRenderer::computeRegPoint(HXxRect cRegionRect,
- RegPoint cRegPointInfo,
- REF(HXxPoint) rcRegPoint)
- {
- // Compute regPoint.x
- if (cRegPointInfo.m_eLeftType == CSS2TypeAuto &&
- cRegPointInfo.m_eRightType == CSS2TypeAuto)
- {
- // Both are auto - we'll default to the regionRect left
- rcRegPoint.x = cRegionRect.left;
- }
- else if (cRegPointInfo.m_eLeftType != CSS2TypeAuto)
- {
- // Take left
- INT32 lLeft = 0;
- if (cRegPointInfo.m_eLeftType == CSS2TypePercentage)
- {
- lLeft = (INT32) (cRegPointInfo.m_dLeft * HXxRECT_WIDTH(cRegionRect) / 100.0 + 0.5);
- }
- else
- {
- lLeft = (INT32) (cRegPointInfo.m_dLeft + 0.5);
- }
- rcRegPoint.x = cRegionRect.left + lLeft;
- }
- else if (cRegPointInfo.m_eLeftType == CSS2TypeAuto &&
- cRegPointInfo.m_eRightType != CSS2TypeAuto)
- {
- // Take right
- INT32 lRight = 0;
- if (cRegPointInfo.m_eRightType == CSS2TypePercentage)
- {
- lRight = (INT32) (cRegPointInfo.m_dRight * HXxRECT_WIDTH(cRegionRect) / 100.0 + 0.5);
- }
- else
- {
- lRight = (INT32) (cRegPointInfo.m_dRight + 0.5);
- }
- rcRegPoint.x = cRegionRect.right - lRight;
- }
- // Compute regPoint.y
- if (cRegPointInfo.m_eTopType == CSS2TypeAuto &&
- cRegPointInfo.m_eBottomType == CSS2TypeAuto)
- {
- // Both are auto - we'll default to the regionRect top
- rcRegPoint.y = cRegionRect.top;
- }
- else if (cRegPointInfo.m_eTopType != CSS2TypeAuto)
- {
- // Take top
- INT32 lTop = 0;
- if (cRegPointInfo.m_eTopType == CSS2TypePercentage)
- {
- lTop = (INT32) (cRegPointInfo.m_dTop * HXxRECT_HEIGHT(cRegionRect) / 100.0 + 0.5);
- }
- else
- {
- lTop = (INT32) (cRegPointInfo.m_dTop + 0.5);
- }
- rcRegPoint.y = cRegionRect.top + lTop;
- }
- else if (cRegPointInfo.m_eTopType == CSS2TypeAuto &&
- cRegPointInfo.m_eBottomType != CSS2TypeAuto)
- {
- // Take bottom
- INT32 lBottom = 0;
- if (cRegPointInfo.m_eBottomType == CSS2TypePercentage)
- {
- lBottom = (INT32) (cRegPointInfo.m_dBottom * HXxRECT_HEIGHT(cRegionRect) / 100.0 + 0.5);
- }
- else
- {
- lBottom = (INT32) (cRegPointInfo.m_dBottom + 0.5);
- }
- rcRegPoint.y = cRegionRect.bottom - lBottom;
- }
- }
- HX_RESULT CSmilDocumentRenderer::computeMediaLayout(HXxRect cRegionRect,
- Fit eFit,
- HXxPoint cRegPoint,
- RegAlign eRegAlign,
- HXxSize cMediaSize,
- REF(HXxRect) rcMediaRect,
- BOOL bMediaIsBrush)
- {
- HX_RESULT retVal = HXR_OK;
- if (cRegionRect.right > cRegionRect.left &&
- cRegionRect.bottom > cRegionRect.top &&
- cMediaSize.cx > 0 && cMediaSize.cy > 0)
- {
- // If the media is a brush, then we always have
- // fit="fill" behavior
- if (bMediaIsBrush)
- {
- eFit = FitFill;
- }
- // Switch based on fit
- switch (eFit)
- {
- case FitFill:
- {
- switch (eRegAlign)
- {
- case RegAlignTopLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.right = cRegionRect.right;
- rcMediaRect.bottom = cRegionRect.bottom;
- }
- break;
- case RegAlignTopMid:
- {
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.bottom = cRegionRect.bottom;
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- }
- break;
- case RegAlignTopRight:
- {
- rcMediaRect.left = cRegionRect.left;
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.right = cRegPoint.x;
- rcMediaRect.bottom = cRegionRect.bottom;
- }
- break;
- case RegAlignMidLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.right = cRegionRect.right;
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignCenter:
- {
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignMidRight:
- {
- rcMediaRect.left = cRegionRect.left;
- rcMediaRect.right = cRegPoint.x;
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignBottomLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.top = cRegionRect.top;
- rcMediaRect.right = cRegionRect.right;
- rcMediaRect.bottom = cRegPoint.y;
- }
- break;
- case RegAlignBottomMid:
- {
- rcMediaRect.top = cRegionRect.top;
- rcMediaRect.bottom = cRegPoint.y;
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- }
- break;
- case RegAlignBottomRight:
- {
- rcMediaRect.left = cRegionRect.left;
- rcMediaRect.right = cRegPoint.x;
- rcMediaRect.top = cRegionRect.top;
- rcMediaRect.bottom = cRegPoint.y;
- }
- break;
- }
- }
- break;
- case FitScroll:
- case FitHidden:
- {
- switch (eRegAlign)
- {
- case RegAlignTopLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.right = cRegPoint.x + cMediaSize.cx;
- rcMediaRect.bottom = cRegPoint.y + cMediaSize.cy;
- }
- break;
- case RegAlignTopMid:
- {
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.bottom = cRegPoint.y + cMediaSize.cy;
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- }
- break;
- case RegAlignTopRight:
- {
- rcMediaRect.left = cRegPoint.x - cMediaSize.cx;
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.right = cRegPoint.x;
- rcMediaRect.bottom = cRegPoint.y + cMediaSize.cy;
- }
- break;
- case RegAlignMidLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.right = cRegPoint.x + cMediaSize.cx;
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignCenter:
- {
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignMidRight:
- {
- rcMediaRect.left = cRegPoint.x - cMediaSize.cx;
- rcMediaRect.right = cRegPoint.x;
- computeFillHiddenScaling(eFit, cRegPoint.y, cMediaSize.cy,
- cRegionRect.top, cRegionRect.bottom,
- rcMediaRect.top, rcMediaRect.bottom);
- }
- break;
- case RegAlignBottomLeft:
- {
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.top = cRegPoint.y - cMediaSize.cy;
- rcMediaRect.right = cRegPoint.x + cMediaSize.cx;
- rcMediaRect.bottom = cRegPoint.y;
- }
- break;
- case RegAlignBottomMid:
- {
- rcMediaRect.top = cRegPoint.y - cMediaSize.cy;
- rcMediaRect.bottom = cRegPoint.y;
- computeFillHiddenScaling(eFit, cRegPoint.x, cMediaSize.cx,
- cRegionRect.left, cRegionRect.right,
- rcMediaRect.left, rcMediaRect.right);
- }
- break;
- case RegAlignBottomRight:
- {
- rcMediaRect.left = cRegPoint.x - cMediaSize.cx;
- rcMediaRect.top = cRegPoint.y - cMediaSize.cy;
- rcMediaRect.right = cRegPoint.x;
- rcMediaRect.bottom = cRegPoint.y;
- }
- break;
- }
- }
- break;
- case FitMeet:
- case FitSlice:
- {
- INT32 d = 0; // dummy variable
- BOOL bIsMeet = (eFit == FitMeet ? TRUE : FALSE);
- switch (eRegAlign)
- {
- case RegAlignTopLeft:
- {
- // left and top are fixed
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.top = cRegPoint.y;
- // compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 2,
- cRegPoint.x,
- cRegPoint.x + cMediaSize.cx,
- cRegionRect.right,
- cRegPoint.y,
- cRegPoint.y + cMediaSize.cy,
- cRegionRect.bottom,
- 0, 0, 0, 0, 0, 0,
- rcMediaRect.right,
- rcMediaRect.bottom,
- d, d);
- }
- break;
- case RegAlignTopMid:
- {
- // top is fixed
- rcMediaRect.top = cRegPoint.y;
- // Compute the left and right of the original media
- INT32 lMediaLeft = 0;
- INT32 lMediaRight = 0;
- computeHalfBounds(cRegPoint.x, cMediaSize.cx,
- lMediaLeft, lMediaRight);
- // Compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 3,
- cRegPoint.x,
- lMediaLeft,
- cRegionRect.left,
- cRegPoint.x,
- lMediaRight,
- cRegionRect.right,
- cRegPoint.y,
- cRegPoint.y + cMediaSize.cy,
- cRegionRect.bottom,
- 0, 0, 0,
- rcMediaRect.left,
- rcMediaRect.right,
- rcMediaRect.bottom,
- d);
- }
- break;
- case RegAlignTopRight:
- {
- // right and top are fixed
- rcMediaRect.top = cRegPoint.y;
- rcMediaRect.right = cRegPoint.x;
- // compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 2,
- cRegPoint.x,
- cRegPoint.x - cMediaSize.cx,
- cRegionRect.left,
- cRegPoint.y,
- cRegPoint.y + cMediaSize.cy,
- cRegionRect.bottom,
- 0, 0, 0, 0, 0, 0,
- rcMediaRect.left,
- rcMediaRect.bottom,
- d, d);
- }
- break;
- case RegAlignMidLeft:
- {
- // left is fixed
- rcMediaRect.left = cRegPoint.x;
- // Compute the top and bottom of the original media
- INT32 lMediaTop = 0;
- INT32 lMediaBottom = 0;
- computeHalfBounds(cRegPoint.y, cMediaSize.cy,
- lMediaTop, lMediaBottom);
- // compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 3,
- cRegPoint.y,
- lMediaTop,
- cRegionRect.top,
- cRegPoint.x,
- cRegPoint.x + cMediaSize.cx,
- cRegionRect.right,
- cRegPoint.y,
- lMediaBottom,
- cRegionRect.bottom,
- 0, 0, 0,
- rcMediaRect.top,
- rcMediaRect.right,
- rcMediaRect.bottom,
- d);
- }
- break;
- case RegAlignCenter:
- {
- // Compute the left and right of the original media
- INT32 lMediaLeft = 0;
- INT32 lMediaRight = 0;
- computeHalfBounds(cRegPoint.x, cMediaSize.cx,
- lMediaLeft, lMediaRight);
- // Compute the top and bottom of the original media
- INT32 lMediaTop = 0;
- INT32 lMediaBottom = 0;
- computeHalfBounds(cRegPoint.y, cMediaSize.cy,
- lMediaTop, lMediaBottom);
- // Compute the media rect
- computeMeetSliceScaling(bIsMeet, 4,
- cRegPoint.x,
- lMediaLeft,
- cRegionRect.left,
- cRegPoint.y,
- lMediaTop,
- cRegionRect.top,
- cRegPoint.x,
- lMediaRight,
- cRegionRect.right,
- cRegPoint.y,
- lMediaBottom,
- cRegionRect.bottom,
- rcMediaRect.left,
- rcMediaRect.top,
- rcMediaRect.right,
- rcMediaRect.bottom);
- }
- break;
- case RegAlignMidRight:
- {
- // right is fixed
- rcMediaRect.right = cRegPoint.x;
- // Compute the top and bottom of the original media
- INT32 lMediaTop = 0;
- INT32 lMediaBottom = 0;
- computeHalfBounds(cRegPoint.y, cMediaSize.cy,
- lMediaTop, lMediaBottom);
- // Compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 3,
- cRegPoint.x,
- cRegPoint.x - cMediaSize.cx,
- cRegionRect.left,
- cRegPoint.y,
- lMediaTop,
- cRegionRect.top,
- cRegPoint.y,
- lMediaBottom,
- cRegionRect.bottom,
- 0, 0, 0,
- rcMediaRect.left,
- rcMediaRect.top,
- rcMediaRect.bottom,
- d);
- }
- break;
- case RegAlignBottomLeft:
- {
- // left and bottom are fixed
- rcMediaRect.left = cRegPoint.x;
- rcMediaRect.bottom = cRegPoint.y;
- // Compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 2,
- cRegPoint.y,
- cRegPoint.y - cMediaSize.cy,
- cRegionRect.top,
- cRegPoint.x,
- cRegPoint.x + cMediaSize.cx,
- cRegionRect.right,
- 0, 0, 0, 0, 0, 0,
- rcMediaRect.top,
- rcMediaRect.right,
- d, d);
- }
- break;
- case RegAlignBottomMid:
- {
- // bottom is fixed
- rcMediaRect.bottom = cRegPoint.y;
- // Compute the left and right of the original media
- INT32 lMediaLeft = 0;
- INT32 lMediaRight = 0;
- computeHalfBounds(cRegPoint.x, cMediaSize.cx,
- lMediaLeft, lMediaRight);
- // Compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 3,
- cRegPoint.x,
- lMediaLeft,
- cRegionRect.left,
- cRegPoint.y,
- cRegPoint.y - cMediaSize.cy,
- cRegionRect.top,
- cRegPoint.x,
- lMediaRight,
- cRegionRect.right,
- 0, 0, 0,
- rcMediaRect.left,
- rcMediaRect.top,
- rcMediaRect.right,
- d);
- }
- break;
- case RegAlignBottomRight:
- {
- // right and bottom are fixed
- rcMediaRect.right = cRegPoint.x;
- rcMediaRect.bottom = cRegPoint.y;
- // Compute the rest of the media rect
- computeMeetSliceScaling(bIsMeet, 2,
- cRegPoint.x,
- cRegPoint.x - cMediaSize.cx,
- cRegionRect.left,
- cRegPoint.y,
- cRegPoint.y - cMediaSize.cy,
- cRegionRect.top,
- 0, 0, 0, 0, 0, 0,
- rcMediaRect.left,
- rcMediaRect.top,
- d, d);
- }
- break;
- }
- }
- break;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- void CSmilDocumentRenderer::computeHalfBounds(INT32 lMid, INT32 lSpan,
- REF(INT32) rlMin, REF(INT32) rlMax)
- {
- INT32 lHalfSpan = lSpan >> 1;
- rlMin = lMid - lHalfSpan;
- rlMax = lMid + (lSpan & 1 ? lHalfSpan + 1 : lHalfSpan);
- }
- void CSmilDocumentRenderer::computeFillHiddenScaling(Fit eFit, INT32 lRegPt, INT32 lMediaDim,
- INT32 lRegionLo, INT32 lRegionHi,
- REF(INT32) rlMediaLo,
- REF(INT32) rlMediaHi)
- {
- // Get the min and max bounds of the media
- INT32 lMediaLo = 0;
- INT32 lMediaHi = 0;
- computeHalfBounds(lRegPt, lMediaDim, lMediaLo, lMediaHi);
- // Compute the rect
- if (eFit == FitFill)
- {
- double dLoDiffOld = lMediaLo - lRegPt;
- double dLoDiffNew = lRegionLo - lRegPt;
- double dHiDiffOld = lMediaHi - lRegPt;
- double dHiDiffNew = lRegionHi - lRegPt;
- double dLoScale = (dLoDiffOld != 0.0 ? dLoDiffNew / dLoDiffOld : 1.0);
- double dHiScale = (dHiDiffOld != 0.0 ? dHiDiffNew / dHiDiffOld : 1.0);
- dLoScale = (dLoScale > 0.0 ? dLoScale : -dLoScale);
- dHiScale = (dHiScale > 0.0 ? dHiScale : -dHiScale);
- if (dLoScale != 0.0 && dLoScale < dHiScale)
- {
- rlMediaLo = lRegionLo;
- INT32 lScaledHiDiff = (INT32) (dHiDiffOld * dLoScale + 0.5);
- rlMediaHi = lRegPt + lScaledHiDiff;
- }
- else
- {
- INT32 lScaledLoDiff = (INT32) (dLoDiffOld * dHiScale + 0.5);
- rlMediaLo = lRegPt + lScaledLoDiff;
- rlMediaHi = lRegionHi;
- }
- }
- else if (eFit == FitHidden ||
- eFit == FitScroll)
- {
- rlMediaLo = lMediaLo;
- rlMediaHi = lMediaHi;
- }
- }
- void CSmilDocumentRenderer::computeMeetSliceScaling(BOOL bIsMeet, UINT32 ulNumDim,
- INT32 lA1, INT32 lA2, INT32 lA3,
- INT32 lB1, INT32 lB2, INT32 lB3,
- INT32 lC1, INT32 lC2, INT32 lC3,
- INT32 lD1, INT32 lD2, INT32 lD3,
- REF(INT32) rlA, REF(INT32) rlB,
- REF(INT32) rlC, REF(INT32) rlD)
- {
- // Make sure there's not more than 4 dimensions
- if (ulNumDim > 4) ulNumDim = 4;
- // Compute the scales
- INT32 lBase[4] = {lA1, lB1, lC1, lD1};
- INT32 lOld[4] = {lA2, lB2, lC2, lD2};
- INT32 lNew[4] = {lA3, lB3, lC3, lD3};
- double dOldDiff[4] = {0.0, 0.0, 0.0, 0.0};
- double dScale[4] = {0.0, 0.0, 0.0, 0.0};
- UINT32 i = 0;
- double dMinMax = (bIsMeet ? 10000000.0 : 0.0);
- for (i = 0; i < ulNumDim; i++)
- {
- // Compute the old diff
- dOldDiff[i] = lOld[i] - lBase[i];
- // Compute the new diff
- double dNewDiff = lNew[i] - lBase[i];
- // Compute the scale
- dScale[i] = (dOldDiff[i] != 0 ? dNewDiff / dOldDiff[i] : 1.0);
- // Make sure the scale is not negative
- dScale[i] = (dScale[i] > 0.0 ? dScale[i] : -dScale[i]);
- // Find the min or max
- if ((bIsMeet && dScale[i] < dMinMax) ||
- (!bIsMeet && dScale[i] > dMinMax))
- {
- dMinMax = dScale[i];
- }
- }
- // So now we have either the minimum or maximum scale,
- // so now we need to adjust all of the scales to this scale
- INT32 lOut[4] = {0, 0, 0, 0};
- for (i = 0; i < ulNumDim; i++)
- {
- if (dScale[i] == dMinMax)
- {
- lOut[i] = lNew[i];
- }
- else
- {
- INT32 lNewDiff = (INT32) (dOldDiff[i] * dMinMax + 0.5);
- lOut[i] = lBase[i] + lNewDiff;
- }
- }
- // Assign to the out parameters
- rlA = lOut[0];
- rlB = lOut[1];
- rlC = lOut[2];
- rlD = lOut[3];
- }
- HX_RESULT CSmilDocumentRenderer::processMediaRegionOverrides(const char* pszRegionID,
- const char* pszMediaID,
- BOOL bMediaStart,
- UINT32 ulTime)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszRegionID && pszMediaID)
- {
- // Get the source
- CSmilSource* pSource = getSource(pszMediaID);
- if (pSource)
- {
- // Get the region
- CSmilBasicRegion* pRegion = getRegionByID(pszRegionID);
- if (pRegion)
- {
- // Are there any media overrides?
- if (pSource->m_bBackgroundColorSpecified)
- {
- // Get the site user
- UINT32 ulOldColor = 0;
- UINT32 ulNewColor = 0;
- CSmilSiteUser* pSiteUser = (CSmilSiteUser*) pRegion->m_pSiteUser;
- if (pSiteUser)
- {
- // Are we starting or ending the media?
- if (bMediaStart)
- {
- // We are ending the media - therefore, we need to
- // set the site user's background color to the
- // media's background color
- ulOldColor = pRegion->m_ulBackgroundColor;
- ulNewColor = pSource->m_ulBackgroundColor;
- }
- else
- {
- // We are ending the media - therefore, we need to
- // set the site user's background color to the
- // region's background color
- ulOldColor = pSource->m_ulBackgroundColor;
- ulNewColor = pRegion->m_ulBackgroundColor;
- }
- // Now set the background color into the site user
- UINT32 ulCurColor = pSiteUser->GetBackgroundColor();
- if (ulCurColor != ulNewColor)
- {
- pSiteUser->SetBackgroundColor(ulNewColor);
- pSiteUser->Redraw();
- }
- // If the media is ending and we are resetting
- // the background Color back, then we should
- // note the time, so that an animation ending
- // will not reset it right back to what it is now.
- if (!bMediaStart)
- {
- pSiteUser->SetLastMediaEndOverrideTime(m_ulCurrentTime);
- }
- }
- #if 0
- // XXXMEH - TEST - this is a further optimization, but
- // seems to be blocked by a site bug. So ifdef
- // it out for now.
- // Check if we need to adjust the "SiteNeverBlts"
- // property of the site. If we are switching to or
- // from totally transparent, then we may need to
- // adjust this property
- if (isTransparent(ulNewColor) &&
- !isTransparent(ulOldColor))
- {
- setSiteProperty(pRegion->m_pSite, "SiteNeverBlts", "1");
- }
- else if (!isTransparent(ulNewColor) &&
- isTransparent(ulOldColor))
- {
- setSiteProperty(pRegion->m_pSite, "SiteNeverBlts", "0");
- }
- #endif
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- // Now we need to check if this media is playing
- // to a viewport.
- if (!pRegion->m_bUnderRootLayout)
- {
- // This media is playing to a viewport,
- // so get the viewport.
- CSmilBasicViewport* pPort = getViewportByDescendant(pRegion);
- if (pPort)
- {
- // Check whether we need to increment or
- // decrement the active media count.
- if (bMediaStart)
- {
- // Media is starting, so increment the
- // active media count
- pPort->m_ulNumActiveMedia++;
- // If this is the first media to start AND
- // the viewport has an "open" property of
- // whenActive, then do a show on the viewport
- if (pPort->m_ulNumActiveMedia == 1 &&
- pPort->m_pPort &&
- pPort->m_pPort->m_eOpen == ViewportOpenWhenActive)
- {
- showHideViewport(pPort, TRUE);
- }
- }
- else
- {
- // Media is ending or being hidden, so
- // decrement the active media count, but
- // make sure we don't wrap around
- if (pPort->m_ulNumActiveMedia)
- {
- pPort->m_ulNumActiveMedia--;
- }
- // If this is the last media to end AND
- // the viewport has a "close" property of
- // whenNotActive, then do a hide on the viewport.
- if (pPort->m_ulNumActiveMedia == 0 &&
- pPort->m_pPort &&
- pPort->m_pPort->m_eClose == ViewportCloseWhenNotActive)
- {
- showHideViewport(pPort, FALSE);
- }
- }
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- // Now we need to check whether the starting or ending
- // if this media will cause a parent region to display.
- // For instance, if region B is a child of region A,
- // and region A has showBackground="whenActive", then
- // region A may NOT be visible when media in region B
- // starts. However, "whenActive" means that when media
- // is active in the region OR ANY CHILD REGIONS. Therefore,
- // region A should be made visible at the same time.
- // Conversely, if a media is ending, it may cause a parent
- // to be hidden.
- //
- // Loop up through the region's ancestors. We
- // can know if the CSmilBasicBox is a CSmilBasicRegion
- // by the fact that top-level boxes will have
- // no parents, so if CSmilBasicBox::m_pParent == NULL,
- // then it's a top-level box and not a region.
- CSmilBasicBox* pBox = pRegion->m_pParent;
- while (pBox && pBox->m_pParent)
- {
- // We know this is a region, so cast it
- CSmilBasicRegion* pParReg = (CSmilBasicRegion*) pBox;
- // Are we starting or ending this media?
- if (bMediaStart)
- {
- // We are starting this media, so we need
- // to check if this region has showBackground="whenActive".
- // If it does, then we need to show this site.
- if (pParReg->m_eShowBackground == ShowBackgroundWhenActive)
- {
- showSite(pParReg->m_pSite, TRUE);
- }
- }
- else
- {
- // We are ending this media, so we need to
- // check two things: a) does this region have
- // showBackground="whenActive"; and b) is anything
- // currently playing in this region at this time?
- // If (a) is yes and (b) is no, then we need to
- // hide this site.
- if (pParReg->m_eShowBackground == ShowBackgroundWhenActive &&
- !isRegionActive(pParReg->m_region, (UINT16) m_uCurrentGroupIndex, ulTime))
- {
- showSite(pParReg->m_pSite, FALSE);
- }
- }
- // Get the next ancestor up
- pBox = pBox->m_pParent;
- }
- // We need to resolve the z-order every time media starts
- // or stops. We only need to resolve from the region's parent
- // down.
- resolveZOrder(pRegion->m_pParent, ulTime);
- }
- }
- }
- return retVal;
- }
- void CSmilDocumentRenderer::resolveZOrder(CSmilBasicBox* pBox, UINT32 ulTime)
- {
- // Resolving z-order is really resolving z-order among our
- // children, so if we don't have any children, then there's
- // nothing to do.
- if (pBox)
- {
- // Get the site for this box. This could be a region site
- // or it could be the root-level site.
- IHXSite* pBoxSite = pBox->m_pSite;
- if (pBoxSite)
- {
- // There can be two kinds of child sites of this site -
- // region sites and renderer sites. All the child renderer sites
- // must be lower in z-order than the child region sites.
- // So we must sort them first.
- INT32 lCurZOrder = 0;
- CHXSimpleList cTmpList;
- // Run through the site info list and pick out renderer
- // sites which are playing to this region site (potentially
- // more than one). Note that if this is a root-level
- // site, then there won't be any renderers playing to this
- // site.
- if (m_pSiteInfoList)
- {
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo = (SMILSiteInfo*) m_pSiteInfoList->GetNext(pos);
- if (pInfo && pInfo->m_pRegionSite == pBoxSite)
- {
- // /Helps fix PR 81510 (& duplicate PR 83796); if delay
- // < resume time, use resume time for z-ordering:
- UINT32 ulRelevantInfoDelay = pInfo->m_ulDelay;
- if (pInfo->m_ulResumeTime > pInfo->m_ulDelay)
- {
- ulRelevantInfoDelay = pInfo->m_ulResumeTime;
- }
- // This is a renderer playing to this region, so add it
- // to the list in the proper order (increasing by begin
- // time, begin-time tie-breaker by lexical order)
- BOOL bAdded = FALSE;
- LISTPOSITION pos2 = cTmpList.GetHeadPosition();
- while (pos2)
- {
- SMILSiteInfo* pListInfo = (SMILSiteInfo*) cTmpList.GetAt(pos2);
- if (pListInfo)
- {
- UINT32 ulRelevantListInfoDelay = pListInfo->m_ulDelay;
- if (pListInfo->m_ulResumeTime > pListInfo->m_ulDelay)
- {
- ulRelevantListInfoDelay = pListInfo->m_ulResumeTime;
- }
- if (pListInfo->m_lZIndex > pInfo->m_lZIndex ||
- ulRelevantListInfoDelay > ulRelevantInfoDelay ||
- (ulRelevantListInfoDelay == ulRelevantInfoDelay &&
- pListInfo->m_ulLexicalOrder > pInfo->m_ulLexicalOrder))
- {
- cTmpList.InsertBefore(pos2, (void*) pInfo);
- bAdded = TRUE;
- break;
- }
- }
- cTmpList.GetNext(pos2);
- }
- if (!bAdded)
- {
- cTmpList.AddTail((void*) pInfo);
- }
- }
- }
- // Now we have ordered the renderer sites, we can
- // set the z-order of the renderer sites
- pos = cTmpList.GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo = (SMILSiteInfo*) cTmpList.GetNext(pos);
- if (pInfo)
- {
- setSiteZIndex(pInfo->m_pRendererSite, lCurZOrder++);
- }
- }
- // Now we can clear the temporary list
- cTmpList.RemoveAll();
- }
- // After those, we have to order the region sites which may
- // be children of this site. We know that these must be
- // CSmilBasicRegion's.
- if (pBox->m_pChildList)
- {
- LISTPOSITION pos = pBox->m_pChildList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicRegion* pRegion =
- (CSmilBasicRegion*) pBox->m_pChildList->GetNext(pos);
- if (pRegion)
- {
- // Now insert this into the z-order list
- BOOL bAdded = FALSE;
- LISTPOSITION pos2 = cTmpList.GetHeadPosition();
- while (pos2)
- {
- CSmilBasicRegion* pListRegion =
- (CSmilBasicRegion*) cTmpList.GetAt(pos2);
- if (pListRegion)
- {
- if (pListRegion->m_lZIndex > pRegion->m_lZIndex)
- {
- cTmpList.InsertBefore(pos2, (void*) pRegion);
- bAdded = TRUE;
- break;
- }
- else if (pListRegion->m_lZIndex == pRegion->m_lZIndex)
- {
- UINT32 ulListStartTime = 0;
- UINT32 ulListLexicalOrder = 0;
- HX_RESULT lListRet = getMostRecentInfo(pListRegion->m_pSite,
- ulTime,
- ulListStartTime,
- ulListLexicalOrder);
- if (SUCCEEDED(lListRet))
- {
- UINT32 ulStartTime = 0;
- UINT32 ulLexicalOrder = 0;
- HX_RESULT lRet = getMostRecentInfo(pRegion->m_pSite,
- ulTime,
- ulStartTime,
- ulLexicalOrder);
- if (SUCCEEDED(lRet))
- {
- if (ulListStartTime > ulStartTime ||
- (ulListStartTime == ulStartTime &&
- ulListLexicalOrder > ulLexicalOrder))
- {
- cTmpList.InsertBefore(pos2, (void*) pRegion);
- bAdded = TRUE;
- break;
- }
- }
- }
- }
- }
- cTmpList.GetNext(pos2);
- }
- if (!bAdded)
- {
- cTmpList.AddTail((void*) pRegion);
- }
- }
- }
- // Now that we have ordered the child region sites,
- // we can go through and continue setting the z-index.
- pos = cTmpList.GetHeadPosition();
- while (pos)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) cTmpList.GetNext(pos);
- if (pRegion)
- {
- setSiteZIndex(pRegion->m_pSite, lCurZOrder++);
- }
- }
- // Now we can clear the temporary list
- cTmpList.RemoveAll();
- // Now we must recursively call this method on
- // all the children
- pos = pBox->m_pChildList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicBox* pChildBox = (CSmilBasicBox*) pBox->m_pChildList->GetNext(pos);
- resolveZOrder(pChildBox, ulTime);
- }
- }
- }
- }
- }
- HX_RESULT CSmilDocumentRenderer::getMostRecentInfo(IHXSite* pSite, UINT32 ulTime,
- REF(UINT32) rulStartTime,
- REF(UINT32) rulLexicalOrder)
- {
- HX_RESULT retVal = HXR_OK;
- // Clear flag which says we found anything
- BOOL bFoundOne = FALSE;
- UINT32 ulStart = 0;
- UINT32 ulLexical = 0;
- // Run through the site info list
- if (pSite && m_pSiteInfoList)
- {
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo = (SMILSiteInfo*) m_pSiteInfoList->GetNext(pos);
- // /Helps fix PR 81510 (& duplicate PR 83796); if delay is less than
- // resume time, use resume time as if it were start time:
- UINT32 ulRelevantDelay = pInfo->m_ulDelay;
- if (pInfo->m_ulResumeTime > pInfo->m_ulDelay)
- {
- ulRelevantDelay = pInfo->m_ulResumeTime;
- }
- if (pInfo &&
- pInfo->m_pRegionSite == pSite &&
- ulTime >= ulRelevantDelay)
- {
- if (!bFoundOne)
- {
- ulStart = ulRelevantDelay;
- ulLexical = pInfo->m_ulLexicalOrder;
- bFoundOne = TRUE;
- }
- else
- {
- if (ulRelevantDelay > ulStart ||
- (ulRelevantDelay == ulStart &&
- pInfo->m_ulLexicalOrder > ulLexical))
- {
- ulStart = ulRelevantDelay;
- ulLexical = pInfo->m_ulLexicalOrder;
- }
- }
- }
- }
- }
- // Assign the out parameters
- if (bFoundOne)
- {
- rulStartTime = ulStart;
- rulLexicalOrder = ulLexical;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- void CSmilDocumentRenderer::addStringProperty(IHXValues* pValues,
- IUnknown* pContext,
- const char* pszName,
- const char* pszValue)
- {
- if (pValues && pContext && pszName && pszValue)
- {
- IHXCommonClassFactory* pFact = NULL;
- pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pFact);
- if (pFact)
- {
- IHXBuffer* pBuf = NULL;
- pFact->CreateInstance(CLSID_IHXBuffer, (void**) &pBuf);
- if (pBuf)
- {
- HX_RESULT rv = pBuf->Set((const UCHAR*) pszValue, strlen(pszValue) + 1);
- if (SUCCEEDED(rv))
- {
- pValues->SetPropertyCString(pszName, pBuf);
- }
- }
- HX_RELEASE(pBuf);
- }
- HX_RELEASE(pFact);
- }
- }
- BOOL CSmilDocumentRenderer::hasParamChildren(CSmilElement* pElement,
- BOOL bServerOnly)
- {
- BOOL bRet = FALSE;
- if (pElement && pElement->m_pNode)
- {
- SMILNode* pChild = pElement->m_pNode->getFirstChild();
- while (pChild)
- {
- if (pChild->m_tag == SMILParam)
- {
- if (bServerOnly)
- {
- CSmilParamElement* pParam = (CSmilParamElement*) pChild->m_pElement;
- if (pParam &&
- pParam->m_eDelivery == DeliveryServer)
- {
- bRet = TRUE;
- break;
- }
- }
- else
- {
- bRet = TRUE;
- break;
- }
- }
- pChild = pElement->m_pNode->getNextChild();
- }
- }
- return bRet;
- }
- void CSmilDocumentRenderer::addParamProperties(CSmilElement* pElement,
- IHXValues* pValues,
- IUnknown* pContext,
- BOOL bServerOnly)
- {
- if (pElement && pElement->m_pNode && pValues && pContext)
- {
- SMILNode* pChild = pElement->m_pNode->getFirstChild();
- while (pChild)
- {
- if (pChild->m_tag == SMILParam && pChild->m_pElement)
- {
- CSmilParamElement* pParam = (CSmilParamElement*) pChild->m_pElement;
- if (pParam->m_pName &&
- pParam->m_pValue &&
- ((bServerOnly && pParam->m_eDelivery == DeliveryServer) || !bServerOnly))
- {
- pValues->SetPropertyCString((const char*) pParam->m_pName->GetBuffer(),
- pParam->m_pValue);
- }
- }
- pChild = pElement->m_pNode->getNextChild();
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- void CSmilDocumentRenderer::checkAnimChildren(CSmilElement* pElement, UINT32 ulTrackEnd)
- {
- if (pElement && pElement->m_pNode)
- {
- SMILNode* pChild = pElement->m_pNode->getFirstChild();
- while (pChild)
- {
- if (pChild->m_tag == SMILAnimate ||
- pChild->m_tag == SMILAnimateMotion ||
- pChild->m_tag == SMILAnimateColor ||
- pChild->m_tag == SMILAnimateMotion)
- {
- CSmilAnimateElement* pAnim =
- (CSmilAnimateElement*) pChild->m_pElement;
- if (pAnim)
- {
- if (pAnim->m_ulDelay >= ulTrackEnd)
- {
- // Our parent totally prevents us from
- // starting. Since the event is probably
- // already scheduled, then we will simply
- // mark this to cancel this animation
- pAnim->m_bCancelAnimation = TRUE;
- }
- else if (pAnim->m_ulDelay < ulTrackEnd &&
- pAnim->m_ulDelay + pAnim->m_ulActiveDuration > ulTrackEnd)
- {
- // The delay is less than the track end, but
- // the delay plus active duration is cut off
- // by the track end. Therefore, we will shorten
- // the active duration to match the track end.
- pAnim->m_ulActiveDuration = ulTrackEnd - pAnim->m_ulDelay;
- }
- }
- }
- pChild = pElement->m_pNode->getNextChild();
- }
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
- CSmilTransitionInfo::CSmilTransitionInfo(CSmilTransition* pTrans,
- IUnknown* pContext)
- {
- HX_ASSERT(pTrans);
- HX_ASSERT(pContext);
- m_pTrans = pTrans;
- m_pContext = pContext;
- if (m_pContext)
- {
- // AddRef the context
- m_pContext->AddRef();
- }
- }
- CSmilTransitionInfo::~CSmilTransitionInfo()
- {
- HX_RELEASE(m_pContext);
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
- // /IHXClientAdviseSink Interface Methods:
- STDMETHODIMP
- CSmilDocumentRenderer::OnPosLength(UINT32 ulPosition,
- UINT32 ulLength)
- {
- MLOG_TIMESYNC(m_pErrorMessages, "OnPosLength(%lu,%lu) tick=%lun",
- ulPosition, ulLength, HX_GET_BETTERTICKCOUNT());
- // /Note: this *should* have been done in OnBuffering() when 100%
- // was complete, but the renderers don't get a chance to draw until
- // after OnBuffering(100%) is done, apparently:
- if (ulPosition > 0 && m_bDestPlaystateIsPause)
- {
- // /Done buffering, and we've had a chance to draw the first "frame"
- // of each media stream's data, so let's pause it if
- // "destinationPlaystate" was "pause":
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer)
- {
- pPlayer->Pause();
- }
- m_bDestPlaystateIsPause = FALSE;
- }
- // The ulLength argument is the current duration
- // of the current group. Save this value
- m_ulCurGroupDuration = ulLength;
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnPresentationOpened()
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnPresentationClosed()
- {
- // / HX_ASSERT(0=="XXXEH: implementThis!");
- // /When we get this notification, we need to decide whether or not
- // the caller of this is the player we were playing in or a new
- // player that opened (and may mean we're in a paused state):
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnStatisticsChanged(void)
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime)
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime)
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnStop(void)
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::OnPause(UINT32 ulTime)
- {
- return HXR_NOTIMPL;
- }
- // Called by client engine to inform that a begin OR resume has just occured:
- STDMETHODIMP
- CSmilDocumentRenderer::OnBegin(UINT32 ulTime)
- {
- // /First, if we have a fragment offset in the URL that we're playing,
- // now is the time to do the seek of the player since it isn't ready
- // to be seeked until this point:
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- HX_ASSERT(pPlayer);
- //If getFragmentOffset() found the fragment and it had
- // a resolved begin time (plus offset) of zero,
- // we used to not seek to 0 even though that's a valid
- // value.
- // (Note: this problem was found while fixing PR 22655.)
- if(pPlayer && m_bFragFoundAndResolved)
- {
- pPlayer->Seek(m_ulFragmentTimeOffset);
- }
- return HXR_OK;
- }
- // Called by client engine to inform the client that buffering
- // of data is occuring. The render is informed of the reason for
- // the buffering (start-up of stream, seek has occured, network
- // congestion, etc.), as well as percentage complete of the
- // buffering process.
- STDMETHODIMP
- CSmilDocumentRenderer::OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete)
- {
- // /Note: deciding on whether or not to pause *should* have been
- // done here when 100% was complete, but the renderers don't get
- // a chance to draw until after OnBuffering(100%) is done, apparently,
- // so the code to handle this is in OnPosLength().
- return HXR_NOTIMPL;
- }
- /****************************************************************************
- * IHXClientAdviseSink::OnContacting ref: hxclsnk.h
- *
- * Called by client engine to inform the client is contacting hosts(s).
- */
- STDMETHODIMP
- CSmilDocumentRenderer::OnContacting(const char* pHostName)
- {
- return HXR_NOTIMPL;
- }
- HX_RESULT
- CSmilDocumentRenderer::GetElementProperties(UINT16 uGroupID,
- UINT16 uTrackID,
- REF(IHXValues*) pProperties)
- {
- HX_RESULT rc = HXR_OK;
- CSmilElement* pElement = NULL;
- pProperties = NULL;
- SMILPlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
- if (pPlayToAssoc)
- {
- pElement = m_pSmilParser->findElement(pPlayToAssoc->m_id);
- if (pElement)
- {
- rc = pElement->GetElementProperties(pProperties);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::GetElementStatus(UINT16 uGroupID,
- UINT16 uTrackID,
- UINT32 ulCurrentTime,
- REF(IHXValues*) pStatus)
- {
- HX_RESULT rc = HXR_OK;
- CHXSimpleList* pSiteInfoList = NULL;
- CSmilElement* pElement = NULL;
- CSmilShowSiteEvent* pCurHideEvent = NULL;
- SMILPlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
- pStatus = NULL;
- if (pPlayToAssoc && pPlayToAssoc->m_pSiteInfoList)
- {
- pSiteInfoList = pPlayToAssoc->m_pSiteInfoList;
-
- LISTPOSITION pos = pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*)pSiteInfoList->GetNext(pos);
- if (pSiteInfo)
- {
- pCurHideEvent = getShowHideEvent(pPlayToAssoc->m_id,
- pSiteInfo->m_regionID,
- FALSE);
- if (pCurHideEvent && pCurHideEvent->m_ulEventTime > ulCurrentTime)
- {
- pStatus = new CHXHeader();
- pStatus->AddRef();
- pStatus->SetPropertyULONG32("Show", 1);
- break;
- }
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::AttachElementLayout(UINT16 uGroupID,
- UINT16 uTrackID,
- IHXRenderer* pRenderer,
- IHXStream* pStream,
- IHXValues* pProps)
- {
- HX_RESULT rc = HXR_OK;
- UINT32 ulDelay = 0;
- UINT32 ulDuration = 0;
- IHXLayoutStream* pLayoutStream = NULL;
- CSmilBasicRegion* pRegion = NULL;
- CHXSimpleList* pRendererList = NULL;
- SMILSourceInfo* pSourceInfo = NULL;
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- // setup the Root layout if it has not
- // this could happen when the child SMIL gets initialized
- // ahead of its parent when switching groups
- if (m_bSitesDetached)
- {
- m_bSitesDetached = FALSE;
- rc = setupRootLayout(FALSE);
- HX_ASSERT(HXR_OK == rc);
- }
- pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
- HX_ASSERT(pPlayToAssoc);
- pRegion = getRegionByID(pPlayToAssoc->m_playTo);
- if (!pRegion)
- {
- // We didn't find a <region> by id and we
- // didn't find a <region> by the "regionName"
- // indirection, so we are going to have to
- // fall back to the "default" region.
- pRegion = setupDefaultLayout();
- if (pRegion)
- {
- // Change the parameters
- pPlayToAssoc->m_playTo = pRegion->m_region;
- pPlayToAssoc->m_regionName = pRegion->m_region;
- }
- }
- // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
- // /XXXEH- To do: the code inside this if() and the code after the else is
- // the same code (reordered a bit) as found inside RendererInitialized(),
- // above. To do: Combine into a function noting that the following also
- // calls HandleAttachElementLayout(), not done in RendererInitialized():
- if (pStream && pProps)
- {
- pSourceInfo = new SMILSourceInfo;
- pSourceInfo->m_pStream = pStream;
- if(pSourceInfo->m_pStream)
- {
- pSourceInfo->m_pStream->AddRef();
- }
- pSourceInfo->m_pRenderer = pRenderer;
- if(pSourceInfo->m_pRenderer)
- {
- pSourceInfo->m_pRenderer->AddRef();
- }
-
- pProps->GetPropertyULONG32("Delay", ulDelay);
- pProps->GetPropertyULONG32("Duration", ulDuration);
- pSourceInfo->m_ulDelay = ulDelay;
- pSourceInfo->m_ulDuration = ulDuration - ulDelay;
- pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[0];
- HX_ASSERT(pRendererList);
- // /Check for NULL as happens in PR 120999 when jumping back
- // and forth between clips in a clip list:
- if (pRendererList)
- {
- pRendererList->AddTail(pSourceInfo);
- }
- }
- else
- {
- pRendererList = (CHXSimpleList*)pPlayToAssoc->m_sourceMap[0];
- HX_ASSERT(pRendererList->GetCount() == 1);
- pSourceInfo = (SMILSourceInfo*)pRendererList->GetHead();
- }
- char cTemp[20]; /* Flawfinder: ignore */
- ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pRenderer); /* Flawfinder: ignore */
- pSourceInfo->m_tunerName = (const char*) cTemp;
- ::sprintf(cTemp,"%#010lx",(ULONG32)(void*)pRenderer+1); /* Flawfinder: ignore */
- pSourceInfo->m_childTunerName = (const char*)cTemp;
- const char* pChildTuner = pSourceInfo->m_childTunerName;
- // get to the site manager and set an event hook
- IHXEventHookMgr* pHookMgr = NULL;
- if(HXR_OK ==
- m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr,
- (void**)&pHookMgr))
- {
- CSmilEventHook* pChildEventHook = NULL;
- // create event hook for playto
- pChildEventHook = new CSmilEventHook((CSmilEventHookResponse*) this,
- pPlayToAssoc->m_playTo, pChildTuner, FALSE,
- (const char*) pPlayToAssoc->m_id);
- pChildEventHook->AddRef();
- pHookMgr->AddHook(pChildEventHook, pChildTuner, 0);
- pSourceInfo->m_pRendererEventHook = pChildEventHook;
- pHookMgr->Release();
- }
- else
- {
- pSourceInfo->m_pRendererEventHook = NULL;
- }
- pPlayToAssoc->m_tunerName = pSourceInfo->m_tunerName;
- pPlayToAssoc->m_childTunerName = pSourceInfo->m_childTunerName;
- pPlayToAssoc->m_pRendererEventHook = pSourceInfo->m_pRendererEventHook;
- // add hyperlinks
- CSmilElement* pElement = m_pSmilParser->findElement(
- pPlayToAssoc->m_id);
- if(pElement && pElement->m_pHyperlinks)
- {
- CHXSimpleList::Iterator i =
- pElement->m_pHyperlinks->Begin();
- for(; i != pElement->m_pHyperlinks->End(); ++i)
- {
- CSmilAAnchorElement* pAnchor =
- (CSmilAAnchorElement*)(*i);
- //[SMIL 1.0 Compliance] Fixes PR 26473:
- // We want to add in LIFO fashion so inner
- // (nested) anchors will be found first in
- // CSmilDocumentRenderer::findHyperlinkElement(),
- // below. In other words, we're giving an
- // effective higher link "z-order" to the
- // decendants of other links. This used to
- // call AddTail():
- pPlayToAssoc->m_pHyperlinks->AddHead(pAnchor);
- }
- }
- IHXValues* pValues = 0;
- IHXBuffer* pPlayToBuffer = 0;
- IHXBuffer* pRegionName = 0;
- IHXCommonClassFactory* pFactory = m_pParent->getFactory();
- if ((HXR_OK == pFactory->CreateInstance(CLSID_IHXValues, (void**)&pValues)) &&
- (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pPlayToBuffer)) &&
- (HXR_OK == pFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pRegionName)))
- {
- pPlayToBuffer->Set((BYTE*)pChildTuner, strlen(pChildTuner)+1);
- pValues->SetPropertyCString("playto", pPlayToBuffer);
- if(pPlayToAssoc->m_regionName.GetLength() > 0)
- {
- const char* pName = pPlayToAssoc->m_regionName;
- pRegionName->Set((BYTE*)pName, strlen(pName)+1);
- pValues->SetPropertyCString("region", pRegionName);
- }
- }
- HX_RELEASE(pPlayToBuffer);
- HX_RELEASE(pRegionName);
- if (pStream &&
- HXR_OK == pStream->QueryInterface(IID_IHXLayoutStream, (void**)&pLayoutStream))
- {
- pLayoutStream->SetProperties(pValues);
- }
- HX_RELEASE(pLayoutStream);
- if(!pRegion->m_bImplicitRegion)
- {
- addSiteForRenderer(pPlayToAssoc, pSourceInfo, pRenderer, FALSE);
-
- if (!pStream)
- {
- m_pParent->HandleAttachElementLayout((IUnknown*)pRenderer, pValues);
- }
- }
- HX_RELEASE(pValues);
- // /XXXEH- end of "To do: the code inside this...".
- // /^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- return rc;
- }
- HX_RESULT
- CSmilDocumentRenderer::DetachElementLayout(IUnknown* pLSG)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- BOOL CSmilDocumentRenderer::isRegionActive(const char* pszRegID, UINT16 usGroup, UINT32 ulTime)
- {
- BOOL bRet = FALSE;
- if(m_pPlayToAssocList && pszRegID)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pAssoc =
- (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pAssoc &&
- pAssoc->m_uGroupIndex == usGroup &&
- pAssoc->m_playTo == pszRegID &&
- ulTime >= pAssoc->m_ulDelay &&
- ulTime < pAssoc->m_ulDelay + pAssoc->m_ulDuration)
- {
- bRet = TRUE;
- break;
- }
- }
- }
- return bRet;
- }
- #if defined(BE_SITE_SUPPLIER_20010205)
- // IHXSiteSupplier Interface Methods
- /****************************************************************************
- * IHXSiteSupplier::SitesNeeded ref: hxwin.h
- *
- */
- STDMETHODIMP
- CSmilDocumentRenderer::SitesNeeded(UINT32 uRequestID, IHXValues* pProps)
- {
- HX_RESULT pnrslt = HXR_OK;
- HX_ASSERT(pProps);
- if (!pProps)
- {
- pnrslt = HXR_INVALID_PARAMETER;
- }
- else
- {
- IHXSite* pChildSite = NULL;
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- BOOL bNoRegion = TRUE;
- // See if we need to layout this renderer
- // First check to see if we have a region by id
- CSmilBasicRegion* pRegion =
- getRegionByID((const char*)m_XXXEH_HACK_regionId);
- if(pRegion)
- {
- bNoRegion = FALSE;
- }
- else
- {
- // We didn't find it by id, so try finding a region by regionName:
- pRegion = getFirstRegionByName(m_XXXEH_HACK_regionId);
- if (pRegion)
- {
- bNoRegion = FALSE;
- }
- else
- {
- // Create a CSmilBasicRegion
- pRegion = new CSmilBasicRegion(NULL);
- if (pRegion)
- {
- // Set the playto
- pRegion->m_region = m_XXXEH_HACK_regionId;
- // Set this as an implicit region
- pRegion->m_bImplicitRegion = TRUE;
- // Set width and height as unspecified
- pRegion->m_bWidthUnspecified = TRUE;
- pRegion->m_bHeightUnspecified = TRUE;
- // Add it to the map
- (*m_pRegionMap)[m_XXXEH_HACK_regionId] = pRegion;
- }
- }
- }
- pPlayToAssoc = pRegion? getPlayToAssoc(pRegion->m_region) : NULL;
- HX_ASSERT(pPlayToAssoc);
- if (!pPlayToAssoc)
- {
- pnrslt = HXR_UNEXPECTED;
- }
- else
- {
- const char* pPlayTo = pPlayToAssoc->m_playTo;
- IHXSite* pSite = pRegion->m_pSite;
- // Create a child site within the region:
- pSite->CreateChild(pChildSite);
- // Put this site into this region's list
- // of child renderer sites
- pRegion->addRendererSiteChild(pChildSite);
- // /Create a site watcher for this site
- CSmilSiteWatcher* pSiteWatch = new CSmilSiteWatcher(this,
- pRegion->m_region, TRUE /* <==is a child site */,
- pPlayToAssoc->m_id);
- if (pSiteWatch)
- {
- // AddRef the watcher
- pSiteWatch->AddRef();
- // Get the top-level box
- CSmilBasicBox* pTopBox = getTopLevelBox(pRegion);
- if (pTopBox && pTopBox->m_eResizeBehavior == ResizeZoom &&
- !m_bDoNotZoom)
- {
- // Initialize the watcher with the current zoom factor;
- // is important if the player starts up in some zoom mode
- // other than original size.
- pSiteWatch->SetZoomScaleFactors(pRegion->m_dZoomScaleFactorX,
- pRegion->m_dZoomScaleFactorY);
- }
- // Attach the watcher to the renderer site
- HX_RESULT attchWatchRetVal = pChildSite->AttachWatcher(pSiteWatch);
- if (SUCCEEDED(attchWatchRetVal))
- {
- // Create the site watcher map if necessary
- if (!m_pSiteWatcherMap)
- {
- m_pSiteWatcherMap = new CHXMapPtrToPtr();
- }
- if (m_pSiteWatcherMap)
- {
- // Add the site watcher to the site watcher map
- m_pSiteWatcherMap->SetAt((void*) pChildSite,
- (void*) pSiteWatch);
- }
- }
- }
- HXxSize cCurSize;
- pSite->GetSize(cCurSize);
- cCurSize.cx-=40;
- cCurSize.cy-=40;
- pChildSite->SetSize(cCurSize);
- IHXSite2* pSite2 = NULL;
- if (pChildSite && pChildSite->QueryInterface(IID_IHXSite2,
- (void**)&pSite2) == HXR_OK)
- {
- pSite2->ShowSite(TRUE);
- pSite2->Release();
- }
- HRESULT hresTemp = HXR_OK;
- IHXValues* pSiteProps = NULL;
- IHXBuffer* pValue = NULL;
- UINT32 style = 0;
- HX_VERIFY(HXR_OK == pChildSite->QueryInterface(IID_IHXValues,(void**)&pSiteProps));
- HX_ASSERT(pSiteProps);
- CSmilElement* pElement =
- m_pSmilParser->findElement(pPlayToAssoc->m_id);
- HX_ASSERT(pElement);
- // /Set the "sensitivity" (to mouse events) of the renderer site:
- if (pPlayToAssoc->m_id.GetLength() > 0 && m_pSmilParser)
- {
- ULONG32 ulSensitivityStrLen = 0;
- if (pElement &&
- pElement->m_sensitivityToMouseEvents.GetLength() > 0)
- {
- setSiteProperty(pChildSite, "sensitivity",
- (const char*)pElement->m_sensitivityToMouseEvents);
- }
- }
- hresTemp = pProps->GetPropertyCString("playto",pValue);
- if (HXR_OK == hresTemp)
- {
- pSiteProps->SetPropertyCString("channel",pValue);
- pValue->Release();
- }
- else
- {
- hresTemp = pProps->GetPropertyCString("name",pValue);
- if (HXR_OK == hresTemp)
- {
- pSiteProps->SetPropertyCString("LayoutGroup",pValue);
- pValue->Release();
- }
- }
- pSiteProps->Release();
- // /Use child player site mgr. It works; don't ask:
- IHXSiteManager* pSiteMgrOfIndependentPlayer = NULL;
- if (m_pIndependentPlayer &&
- HXR_OK == m_pIndependentPlayer->
- QueryInterface(IID_IHXSiteManager,
- (void**)&pSiteMgrOfIndependentPlayer))
- {
- // /Properties are set so now it's OK to add the site:
- pSiteMgrOfIndependentPlayer->AddSite(pChildSite);
- if (!m_pChildSiteInfoMap)
- {
- m_pChildSiteInfoMap = new CHXMapLongToObj;
- }
- if (m_pChildSiteInfoMap)
- {
- pChildSite->AddRef();
- pSite->AddRef();
- pSiteMgrOfIndependentPlayer->AddRef();
- SMILChildSiteInfo* pChildSiteInfo = new SMILChildSiteInfo(
- pChildSite, pSite, pSiteMgrOfIndependentPlayer);
- m_pChildSiteInfoMap->SetAt(uRequestID, pChildSiteInfo);
- }
- }
- }
- }
- return pnrslt;
- }
- /****************************************************************************
- * IHXSiteSupplier::SitesNotNeeded ref: hxwin.h
- *
- */
- STDMETHODIMP
- CSmilDocumentRenderer::SitesNotNeeded(UINT32 uRequestID)
- {
- SMILChildSiteInfo* pChildSiteInfo = NULL;
- // Locate the site
- if (!m_pChildSiteInfoMap ||
- !m_pChildSiteInfoMap->Lookup(uRequestID, (void*& )pChildSiteInfo) ||
- !pChildSiteInfo || !pChildSiteInfo->m_pChildSite)
- {
- HX_ASSERT(m_pChildSiteInfoMap && pChildSiteInfo);
- HX_ASSERT(pChildSiteInfo->m_pChildSite);
- return HXR_INVALID_PARAMETER;
- }
- if (m_pSiteWatcherMap)
- {
- void* pVoid = NULL;
- if (m_pSiteWatcherMap->Lookup((void*)pChildSiteInfo->m_pChildSite, pVoid) && pVoid)
- {
- // Get the CSmilSiteWatcher pointer
- CSmilSiteWatcher* pWatcher = (CSmilSiteWatcher*)pVoid;
- // Remove the site watcher from the site watcher map
- m_pSiteWatcherMap->RemoveKey((void*)pChildSiteInfo->m_pChildSite);
- // Release our ref on the site watcher
- HX_RELEASE(pWatcher);
- }
- }
- HX_ASSERT(pChildSiteInfo->m_pSiteMgr);
- HX_ASSERT(pChildSiteInfo->m_pParentSite);
- // Perform cleanup on child site
- pChildSiteInfo->m_pChildSite->DetachWatcher();
- pChildSiteInfo->m_pSiteMgr->RemoveSite(pChildSiteInfo->m_pChildSite);
- pChildSiteInfo->m_pParentSite->DestroyChild(pChildSiteInfo->m_pChildSite);
- pChildSiteInfo->m_pChildSite->Release();
- // Remove from map and free memory
- m_pChildSiteInfoMap->RemoveKey(uRequestID);
- delete pChildSiteInfo;
- return HXR_OK;
- }
- /****************************************************************************
- * IHXSiteSupplier::BeginChangeLayout ref: hxwin.h
- *
- */
- STDMETHODIMP
- CSmilDocumentRenderer::BeginChangeLayout()
- {
- return HXR_OK;
- }
- /****************************************************************************
- * IHXSiteSupplier::DoneChangeLayout ref: hxwin.h
- *
- */
- STDMETHODIMP
- CSmilDocumentRenderer::DoneChangeLayout()
- {
- return HXR_OK;
- }
- #endif /* BE_SITE_SUPPLIER_20010205 */
- STDMETHODIMP CSmilDocumentRenderer::MarkerResolved(IHXBuffer* pURLStr,
- IHXBuffer* pMarkerNameStr,
- UINT32 ulTime,
- IHXValues* pOtherMarkerParams)
- {
- HX_RESULT retVal = HXR_OK;
- // Now we need to run through the playToAssoc list
- // and find any id's which correspond to this URL
- if (pURLStr && pMarkerNameStr && m_pPlayToAssocList)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pAssoc =
- (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pAssoc &&
- !strcmp((const char*) pURLStr->GetBuffer(),
- (const char*) pAssoc->m_URL))
- {
- // Init a temp list
- CHXSimpleList cTmp;
- // First check and see if this URL comes from
- // an external media marker file.
- CExternalMediaMarkerInfo* pInfo = getExternalMediaMarkerInfo(pAssoc->m_URL);
- if (pInfo && pInfo->m_pIDList)
- {
- LISTPOSITION pos = pInfo->m_pIDList->GetHeadPosition();
- while (pos)
- {
- const char* pszID = (const char*) pInfo->m_pIDList->GetNext(pos);
- if (pszID)
- {
- cTmp.AddTail((void*) pszID);
- }
- }
- }
- else
- {
- cTmp.AddTail((void*) (const char*) pAssoc->m_id);
- }
- // Now run through our temporary list and
- // resolve this marker to all id's.
- BOOL bDoHandle = FALSE;
- LISTPOSITION tpos = cTmp.GetHeadPosition();
- while (tpos && SUCCEEDED(retVal))
- {
- const char* pszID = (const char*) cTmp.GetNext(tpos);
- if (pszID)
- {
- BOOL bHandle = FALSE;
- retVal = m_pSmilParser->resolveMediaMarkerTime(pszID,
- (const char*) pMarkerNameStr->GetBuffer(),
- ulTime,
- bHandle);
- if (SUCCEEDED(retVal) && bHandle)
- {
- bDoHandle = TRUE;
- }
- }
- }
- if (SUCCEEDED(retVal) && bDoHandle)
- {
- handleElements();
- }
- }
- }
- }
- return retVal;
- }
- STDMETHODIMP CSmilDocumentRenderer::EventFired(IHXBuffer* pURLStr,
- IHXBuffer* pFragmentStr,
- IHXBuffer* pEventNameStr,
- IHXValues* pOtherValues)
- {
- HX_RESULT retVal = HXR_OK;
- if (pURLStr && pEventNameStr)
- {
- LISTPOSITION pos = m_pPlayToAssocList->GetHeadPosition();
- while (pos)
- {
- SMILPlayToAssoc* pAssoc =
- (SMILPlayToAssoc*) m_pPlayToAssocList->GetNext(pos);
- if (pAssoc &&
- !strcmp((const char*) pAssoc->m_URL,
- (const char*) pURLStr->GetBuffer()))
- {
- retVal = handleNamedEvent((const char*) pAssoc->m_playTo,
- (const char*) pAssoc->m_id,
- (const char*) pEventNameStr->GetBuffer());
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- STDMETHODIMP CSmilDocumentRenderer::ErrorOccurred(const UINT8 unSeverity,
- const ULONG32 ulHXCode,
- const ULONG32 ulUserCode,
- const char* pUserString,
- const char* pMoreInfoURL)
- {
- HX_RESULT retVal = HXR_OK;
- MLOG_FLOW(m_pErrorMessages, "ErrorOccurred(%u,%lu,%lu,%s,%s)n",
- unSeverity, ulHXCode, ulUserCode, pUserString, pMoreInfoURL);
- return retVal;
- }
- HX_RESULT
- CSmilDocumentRenderer::InitPersistent(UINT32 ulPersistentComponentID,
- UINT16 uPersistentGroupID,
- UINT16 uPersistentTrackID,
- IHXPersistentRenderer* pPersistentParent)
- {
- IHXStreamSource* pPersistentSource = NULL;
- IHXStream* pPersistentStream = NULL;
- m_ulPersistentComponentID = ulPersistentComponentID;
- m_uPersistentGroupID = uPersistentGroupID;
- m_uPersistentTrackID = uPersistentTrackID;
- m_pPersistentParentRenderer = pPersistentParent;
- HX_ADDREF(m_pPersistentParentRenderer);
- if (m_pContext &&
- HXR_OK == m_pContext->QueryInterface(IID_IHXStreamSource, (void**)&pPersistentSource))
- {
- if (HXR_OK == pPersistentSource->GetStream(0, (IUnknown*&)pPersistentStream))
- {
- if (HXR_OK != pPersistentStream->QueryInterface(IID_IHXLayoutStream, (void**)&m_pPersistentLayoutStream))
- {
- HX_ASSERT(m_pPersistentLayoutStream);
- }
- }
- HX_RELEASE(pPersistentStream);
- }
- HX_RELEASE(pPersistentSource);
-
- return HXR_OK;
- }
- BOOL
- CSmilDocumentRenderer::IsNestedMetaSupported(void)
- {
- BOOL bResult = TRUE;
- UINT32 ulParentPersistentVersion = 0;
- UINT32 ulParentPersistentMajorVersion = 0;
- UINT32 ulParentPersistentType = PersistentUnknown;
- IHXValues* pProperties = NULL;
- if (!m_pPersistentParentRenderer)
- {
- return bResult;
- }
- if (HXR_OK == m_pPersistentParentRenderer->GetPersistentProperties(pProperties))
- {
- pProperties->GetPropertyULONG32("PersistentType", ulParentPersistentType);
- pProperties->GetPropertyULONG32("PersistentVersion", ulParentPersistentVersion);
- ulParentPersistentMajorVersion = HX_GET_MAJOR_VERSION(ulParentPersistentVersion);
- switch (ulParentPersistentType)
- {
- case PersistentUnknown:
- bResult = FALSE;
- break;
- case PersistentSMIL:
- if (ulParentPersistentMajorVersion == 1)
- {
- bResult = FALSE;
- }
- break;
- default:
- break;
- }
- }
- HX_RELEASE(pProperties);
-
- return bResult;
- }
- void
- CSmilDocumentRenderer::PersistentDurationSet(UINT32 ulDuration,
- UINT32 ulDelay,
- BOOL bIsLive)
- {
- IHXRendererAdviseSink* pRendererAdviseSink = NULL;
- if (m_pPersistentParentRenderer &&
- HXR_OK == m_pPersistentParentRenderer->QueryInterface(IID_IHXRendererAdviseSink, (void**)&pRendererAdviseSink))
- {
- pRendererAdviseSink->TrackDurationSet(m_uPersistentGroupID,
- m_uPersistentTrackID,
- ulDuration,
- ulDelay,
- bIsLive);
- }
- HX_RELEASE(pRendererAdviseSink);
- return;
- }
- FillType CSmilDocumentRenderer::getMediaFillBehavior(const char* pszID)
- {
- FillType eRet = FillDefault;
- if (pszID && m_pSmilParser)
- {
- CSmilElement* pElement = m_pSmilParser->findElement(pszID);
- if (pElement)
- {
- eRet = pElement->m_eActualFill;
- }
- }
- return eRet;
- }
- BOOL CSmilDocumentRenderer::atLeastOneActiveAnimation(UINT32 ulTime)
- {
- BOOL bRet = FALSE;
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- if (m_pActiveAnimations &&
- m_pActiveAnimations->GetCount() > 0)
- {
- // Run through all active animations and check
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pInfo =
- (CSmilAnimateInfo*) m_pActiveAnimations->GetNext(pos);
- if (pInfo &&
- pInfo->m_pSandwich &&
- pInfo->m_pSandwich->GetAttributeName() != kAttrNameSoundLevel &&
- pInfo->m_pSandwich->AtLeastOneActiveLayer(ulTime))
- {
- bRet = TRUE;
- break;
- }
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- return bRet;
- }
- void CSmilDocumentRenderer::clearAllEventHandledFlags()
- {
- if(m_pEventList && m_pEventList->GetCount() > 0)
- {
- LISTPOSITION pos = m_pEventList->GetHeadPosition();
- while(pos)
- {
- CSmilLayoutEvent* pEvent =
- (CSmilLayoutEvent*) m_pEventList->GetNext(pos);
- if (pEvent)
- {
- pEvent->setHandledFlag(FALSE);
- }
- }
- }
- }
- HX_RESULT CSmilDocumentRenderer::setRendererULONG32Property(const char* pszMediaID,
- const char* pszName,
- UINT32 ulValue,
- REF(BOOL) rbSetNewValue)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszMediaID && pszName)
- {
- // Set the default
- rbSetNewValue = FALSE;
- // Get the IHXRenderer
- IHXRenderer* pRenderer = NULL;
- retVal = getRenderer(pszMediaID, pRenderer);
- if (SUCCEEDED(retVal))
- {
- // QI IHXRenderer for IHXValues
- IHXValues* pValues = NULL;
- retVal = pRenderer->QueryInterface(IID_IHXValues, (void**) &pValues);
- if (SUCCEEDED(retVal))
- {
- // Get the current value. If we can't get the value,
- // that's OK, since we are only using this current
- // value to optimize out any unnecessary setting
- // of properties
- UINT32 ulCurValue = 0;
- HX_RESULT rv = pValues->GetPropertyULONG32(pszName, ulCurValue);
- // Is the current value different from the
- // value we're trying to set?
- if ((SUCCEEDED(rv) && ulCurValue != ulValue) || FAILED(rv))
- {
- retVal = pValues->SetPropertyULONG32(pszName, ulValue);
- if (SUCCEEDED(retVal))
- {
- rbSetNewValue = TRUE;
- }
- }
- }
- HX_RELEASE(pValues);
- }
- HX_RELEASE(pRenderer);
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::setRendererCStringProperty(const char* pszMediaID,
- const char* pszName,
- const char* pszValue,
- REF(BOOL) rbSetNewValue)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszMediaID && pszName && pszValue)
- {
- // Set the default
- rbSetNewValue = FALSE;
- // Get the IHXRenderer
- IHXRenderer* pRenderer = NULL;
- retVal = getRenderer(pszMediaID, pRenderer);
- if (SUCCEEDED(retVal))
- {
- // QI IHXRenderer for IHXValues
- IHXValues* pValues = NULL;
- retVal = pRenderer->QueryInterface(IID_IHXValues, (void**) &pValues);
- if (SUCCEEDED(retVal))
- {
- // Get the current value. If we can't get the value,
- // that's OK, since we are only using this current
- // value to optimize out any unnecessary setting
- // of properties
- BOOL bSame = FALSE;
- IHXBuffer* pCurValue = NULL;
- HX_RESULT rv = pValues->GetPropertyCString(pszName, pCurValue);
- if (SUCCEEDED(rv))
- {
- const char* pszCurValue = (const char*) pCurValue->GetBuffer();
- if (pszCurValue)
- {
- if (!strcmp(pszCurValue, pszValue))
- {
- bSame = TRUE;
- }
- }
- }
- // Release the current value buffer
- HX_RELEASE(pCurValue);
- // Is the current value different from the
- // value we're trying to set?
- if ((SUCCEEDED(rv) && !bSame) || FAILED(rv))
- {
- // Set the flag
- rbSetNewValue = TRUE;
- // Set the CString property
- setProperty(pValues, pszName, pszValue);
- }
- }
- HX_RELEASE(pValues);
- }
- HX_RELEASE(pRenderer);
- }
- return retVal;
- }
- void CSmilDocumentRenderer::addRemoveMediaMarkerSink(BOOL bAdd)
- {
- if (m_pContext)
- {
- // QI for IHXMediaMarkerManager
- IHXMediaMarkerManager* pMediaMarkerManager = NULL;
- m_pContext->QueryInterface(IID_IHXMediaMarkerManager,
- (void**) &pMediaMarkerManager);
- if (pMediaMarkerManager)
- {
- // Get our own IHXMediaMarkerSink interface
- IHXMediaMarkerSink* pSink = NULL;
- QueryInterface(IID_IHXMediaMarkerSink, (void**) &pSink);
- if (pSink)
- {
- if (bAdd)
- {
- // Add ourselves as a sink
- pMediaMarkerManager->AddMediaMarkerSink(pSink);
- }
- else
- {
- // Remove ourselves as a sink
- pMediaMarkerManager->RemoveMediaMarkerSink(pSink);
- }
- }
- HX_RELEASE(pSink);
- }
- HX_RELEASE(pMediaMarkerManager);
- }
- }
- void CSmilDocumentRenderer::addRemoveEventSink(BOOL bAdd)
- {
- if (m_pContext)
- {
- // QI for IHXEventManager
- IHXEventManager* pEventManager = NULL;
- m_pContext->QueryInterface(IID_IHXEventManager,
- (void**) &pEventManager);
- if (pEventManager)
- {
- // Get our own IHXEventSink interface
- IHXEventSink* pSink = NULL;
- QueryInterface(IID_IHXEventSink, (void**) &pSink);
- if (pSink)
- {
- if (bAdd)
- {
- // Add ourselves as a sink
- pEventManager->AddEventSink(pSink);
- // Set the flag
- m_bEventSinkWasSetup = TRUE;
- }
- else
- {
- // Remove ourselves as a sink
- pEventManager->RemoveEventSink(pSink);
- // Clera the flag
- m_bEventSinkWasSetup = FALSE;
- }
- }
- HX_RELEASE(pSink);
- }
- HX_RELEASE(pEventManager);
- }
- }
- void CSmilDocumentRenderer::addRemoveErrorSink(BOOL bAdd)
- {
- if (m_pContext)
- {
- // QI for IHXErrorSinkControl
- IHXErrorSinkControl* pErrorSinkControl = NULL;
- m_pContext->QueryInterface(IID_IHXErrorSinkControl,
- (void**) &pErrorSinkControl);
- if (pErrorSinkControl)
- {
- // Get our own IHXEventSink interface
- IHXErrorSink* pSink = NULL;
- QueryInterface(IID_IHXErrorSink, (void**) &pSink);
- if (pSink)
- {
- if (bAdd)
- {
- // Add ourselves as a sink
- pErrorSinkControl->AddErrorSink(pSink,
- HXLOG_EMERG,
- HXLOG_DEBUG);
- }
- else
- {
- // Remove ourselves as a sink
- pErrorSinkControl->RemoveErrorSink(pSink);
- }
- }
- HX_RELEASE(pSink);
- }
- HX_RELEASE(pErrorSinkControl);
- }
- }
- void CSmilDocumentRenderer::addEventSinkFilterRule(const char* pszURL,
- const char* pszFragment,
- const char* pszEventName,
- IHXEventSink* pSink)
- {
- if (m_pContext && m_pParent &&
- (pszURL || pszFragment || pszEventName))
- {
- // QI for IHXEventManager
- IHXEventManager* pEventManager = NULL;
- m_pContext->QueryInterface(IID_IHXEventManager,
- (void**) &pEventManager);
- if (pEventManager)
- {
- // If we have a sink passed in, use it. If
- // not, then get our own event sink interface
- BOOL bOurSink = FALSE;
- if (!pSink)
- {
- // Set the flag so that we'll know this is
- // our interface (and we need to release it
- // at the bottom of this method)
- bOurSink = TRUE;
- // Get our own IHXEventSink interface
- QueryInterface(IID_IHXEventSink, (void**) &pSink);
- }
- if (pSink)
- {
- // Create an IHXValues
- IHXCommonClassFactory* pFact = m_pParent->getFactory();
- if (pFact)
- {
- IHXValues* pRule = NULL;
- pFact->CreateInstance(CLSID_IHXValues, (void**) &pRule);
- if (pRule)
- {
- // Set URL string
- if (pszURL)
- {
- setProperty(pRule, FILTER_RULE_KEY_URL,
- pszURL);
- }
- // Set fragment string
- if (pszFragment)
- {
- setProperty(pRule, FILTER_RULE_KEY_FRAGMENT,
- pszFragment);
- }
- // Set eventName string
- if (pszEventName)
- {
- setProperty(pRule, FILTER_RULE_KEY_EVENTNAME,
- pszEventName);
- }
- // Add the rule
- pEventManager->AddEventSinkFilterRule(pSink, pRule);
- }
- HX_RELEASE(pRule);
- }
- }
- // If this was our sink interface, then
- // we need to release it
- if (bOurSink)
- {
- HX_RELEASE(pSink);
- }
- }
- HX_RELEASE(pEventManager);
- }
- }
- HX_RESULT CSmilDocumentRenderer::getEventSink(const char* pszID,
- REF(IHXEventSink*) rpEventSink)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszID)
- {
- // Get the IHXRenderer interface
- IHXRenderer* pRenderer = NULL;
- retVal = getRenderer(pszID, pRenderer);
- if (SUCCEEDED(retVal))
- {
- // QI for IHXEventSink
- HX_RELEASE(rpEventSink);
- retVal = pRenderer->QueryInterface(IID_IHXEventSink,
- (void**) &rpEventSink);
- }
- HX_RELEASE(pRenderer);
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::addRemoveEventSink(const char* pszID,
- BOOL bAdd)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszID && m_pContext)
- {
- // See if we can get the IHXEventSink interface
- IHXEventSink* pSink = NULL;
- retVal = getEventSink(pszID, pSink);
- if (SUCCEEDED(retVal))
- {
- // Check if the event sink is already setup
- BOOL bSinkIsSetup = FALSE;
- LISTPOSITION pos = NULL;
- if (m_pEventSinkList)
- {
- pos = m_pEventSinkList->GetHeadPosition();
- while (pos)
- {
- IHXEventSink* pListSink =
- (IHXEventSink*) m_pEventSinkList->GetAt(pos);
- if (pListSink && pListSink == pSink)
- {
- bSinkIsSetup = TRUE;
- break;
- }
- m_pEventSinkList->GetNext(pos);
- }
- }
- // We only have work to do if:
- // a) we are adding and it's not already setup; OR
- // b) we are removing and it's already setup.
- if (( bAdd && !bSinkIsSetup) ||
- (!bAdd && bSinkIsSetup))
- {
- // Get the IHXEventManager interface
- IHXEventManager* pMgr = NULL;
- retVal = m_pContext->QueryInterface(IID_IHXEventManager,
- (void**) &pMgr);
- if (SUCCEEDED(retVal))
- {
- // Are we adding or removing?
- if (bAdd)
- {
- // Add the event sink to the event manager
- retVal = pMgr->AddEventSink(pSink);
- if (SUCCEEDED(retVal))
- {
- // Do we have a event sink list yet?
- if (!m_pEventSinkList)
- {
- m_pEventSinkList = new CHXSimpleList();
- }
- if (m_pEventSinkList)
- {
- // AddRef the event sink before it goes on the list
- pSink->AddRef();
- // Add it to the list
- m_pEventSinkList->AddTail((void*) pSink);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- // Remove the event sink from the event manager
- retVal = pMgr->RemoveEventSink(pSink);
- if (SUCCEEDED(retVal))
- {
- // Remove it from the list
- m_pEventSinkList->RemoveAt(pos);
- // Release the list's ref on the sink
- pSink->Release();
- }
- }
- }
- HX_RELEASE(pMgr);
- }
- }
- HX_RELEASE(pSink);
- }
- return retVal;
- }
- void CSmilDocumentRenderer::removeAllEventSinks()
- {
- if (m_pEventSinkList && m_pContext)
- {
- IHXEventManager* pMgr = NULL;
- m_pContext->QueryInterface(IID_IHXEventManager, (void**) &pMgr);
- if (pMgr)
- {
- LISTPOSITION pos = m_pEventSinkList->GetHeadPosition();
- while (pos)
- {
- // Get the sink
- IHXEventSink* pSink =
- (IHXEventSink*) m_pEventSinkList->GetNext(pos);
- // Remove the event sink from the event manager
- pMgr->RemoveEventSink(pSink);
- // Release the list's ref on the sink
- HX_RELEASE(pSink);
- }
- // Remove all entries from the list
- m_pEventSinkList->RemoveAll();
- }
- HX_RELEASE(pMgr);
- }
- }
- HX_RESULT CSmilDocumentRenderer::setupEventPipe(const char* pszSrcID,
- const char* pszDstID,
- const char* pszEventName)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pszSrcID && pszDstID)
- {
- // We have to setup the destination renderer as a event sink.
- // If it's not setup yet OR the renderer doesn't support
- // IHXEventSink, then this call will fail.
- retVal = addRemoveEventSink(pszDstID, TRUE);
- if (SUCCEEDED(retVal))
- {
- // First get the playToAssoc
- SMILPlayToAssoc* pAssoc = getPlayToAssocByMedia(pszSrcID);
- if (pAssoc)
- {
- // Get the src media URL from the playToAssoc
- const char* pszURL = (const char*) pAssoc->m_URL;
- // Get the destination event sink
- IHXEventSink* pSink = NULL;
- retVal = getEventSink(pszDstID, pSink);
- if (SUCCEEDED(retVal))
- {
- // Now we need to add a filter rule that will
- // let this sink get events from the src media
- addEventSinkFilterRule(pszURL, NULL, pszEventName, pSink);
- }
- HX_RELEASE(pSink);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- return retVal;
- }
- void
- CSmilDocumentRenderer::handlePendingScheduling(void)
- {
- // /We need to call handlePendingScheduling in case
- // this endEvent is from the last-active track in which
- // case the core will not give us any more time syncs
- // so we can't do the following in onTimeSync():
- BOOL bSomeElementScheduleWasChanged = FALSE;
- HX_RESULT tmprslt =
- m_pSmilParser->handlePendingScheduling(
- m_ulCurrentTime,
- m_uCurrentGroupIndex,
- bSomeElementScheduleWasChanged,
- // /We don't need to get list of paused elements:
- NULL, NULL);
- if (SUCCEEDED(tmprslt) && bSomeElementScheduleWasChanged)
- {
- handleElements();
- }
- return;
- }
- HX_RESULT
- CSmilDocumentRenderer::AdjustSoundLevelsOfAllCurrentTracks(
- UINT16 uCurGroupIndex,
- // /Adjust each track's sound level by this amount, so if current
- // level of track is 50% and this adjustment_pct is 60%, then new
- // sound level for that track would be 30% (= 60% of 50%):
- UINT32 ulSoundLevelAdjustment_pct,
- // /In case track is being restarted by link-region-target HURL, don't
- // mess with its soundLevel as that will be set in handleSource():
- CSmilSource* pSmilSourceDontAdjustMe)
- {
- HX_RESULT pnrslt = HXR_OK;
- // /Get all currently-playing tracks and adjust their soundLevel values:
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMILPlayToAssoc* pPlayToAssoc = (SMILPlayToAssoc*)(*i);
- // /XXXEH- do this for already-played-and-stopped ones in this
- // group? I think so, in case there's a seek backwards:
- if (pPlayToAssoc->m_uGroupIndex >= uCurGroupIndex)
- {
- if (pSmilSourceDontAdjustMe && pPlayToAssoc->m_id ==
- pSmilSourceDontAdjustMe->m_pNode->m_id)
- {
- continue;
- }
- IHXTrack* pTrack = NULL;
- HX_RESULT rtvlgetTrack = getTrack(pPlayToAssoc->m_uGroupIndex,
- pPlayToAssoc->m_uTrackIndex, pTrack);
- if (SUCCEEDED(rtvlgetTrack))
- {
- UINT16 usPriorSoundLevel_pct = pTrack->GetSoundLevel();
- UINT16 usNewSoundLevel_pct = (usPriorSoundLevel_pct *
- (UINT16)ulSoundLevelAdjustment_pct) / 100;
- if (usNewSoundLevel_pct > (UINT16)MAX_ALLOWED_SOUNDLEVEL)
- {
- usNewSoundLevel_pct = (UINT16)MAX_ALLOWED_SOUNDLEVEL;
- }
- pTrack->SetSoundLevel(usNewSoundLevel_pct);
- }
- HX_RELEASE(pTrack);
- }
- }
- }
- // /To handle all not-yet-added tracks, set this for adjusting their
- // soundLevel values in ::handleSource():
- // /XXXEH- finish this!
-
- return pnrslt;
- }
- void CSmilDocumentRenderer::SendHyperlinkHints()
- {
- if(m_pParent)
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer && m_pSmilParser)
- {
- // Get the <smil> node
- SMILNode* pTopNode = m_pSmilParser->findFirstNode(SMILSmil);
- if (pTopNode)
- {
- // Now recurse down the tree
- HintHyperlinkNodeRecurse(pTopNode);
- }
- }
- }
- }
- void CSmilDocumentRenderer::HintHyperlinkNodeRecurse(SMILNode* pNode)
- {
- if (pNode)
- {
- // Check if it's a hyperlinking node
- if (pNode->m_tag == SMILAAnchor ||
- pNode->m_tag == SMILArea ||
- pNode->m_tag == SMILAnchor)
- {
- // Yep, this is a hyperlinking node, so hint it
- //
- // Get the element
- CSmilAAnchorElement* pAnchor = (CSmilAAnchorElement*) pNode->m_pElement;
- if (pAnchor)
- {
- // Hint this hyperlink
- HintHyperlinkNode(pAnchor);
- }
- }
- // Now recursively check our children
- if (pNode->m_pNodeList)
- {
- LISTPOSITION pos = pNode->m_pNodeList->GetHeadPosition();
- while (pos)
- {
- SMILNode* pChildNode = (SMILNode*) pNode->m_pNodeList->GetNext(pos);
- HintHyperlinkNodeRecurse(pChildNode);
- }
- }
- }
- }
- void CSmilDocumentRenderer::HintHyperlinkNode(CSmilAAnchorElement* pAnchor)
- {
- // Only hint if we actually have an href
- if(pAnchor && pAnchor->m_href.GetLength() > 0 && m_pParent)
- {
- // Get the IHXPlayer
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer)
- {
- // Intialize target and sendTo
- const char* pTarget = "_player";
- if (pAnchor->m_bExternal)
- {
- if (pAnchor->m_target.GetLength() > 0)
- {
- pTarget = (const char*) pAnchor->m_target;
- }
- else
- {
- pTarget = "_browser";
- }
- }
- const char* pSendTo = NULL;
- if (pAnchor->m_sendTo.GetLength() > 0)
- {
- pSendTo = (const char*) pAnchor->m_sendTo;
- }
- BOOL bIsOnLoadActuation = FALSE;
- if (!strcmp(pAnchor->m_actuate, "onLoad"))
- {
- bIsOnLoadActuation = TRUE;
- }
- BOOL bNeedToTargetANamedPlayerInstance = FALSE;
- if (pAnchor->m_target.GetLength() > 0)
- {
- if (!pAnchor->m_bTargetIsARegion && !pAnchor->m_bExternal)
- {
- bNeedToTargetANamedPlayerInstance = TRUE;
- }
- }
- if(pAnchor->m_href[0] != '#')
- {
- IHXHyperNavigate* pHyper = 0;
- SMILLinkPlaystate sourcePlaystate = SMILLinkPlaystatePause;
- if (("pause" == pAnchor->m_show ||
- "replace" == pAnchor->m_show) &&
- !pAnchor->m_bExternal)
- {
- sourcePlaystate = SMILLinkPlaystatePause;
- }
- else
- {
- sourcePlaystate = pAnchor->m_sourcePlaystate;
- }
- BOOL bIsOldSMIL1ShowEqualsPause = FALSE;
- if ("pause" == pAnchor->m_show)
- {
- bIsOldSMIL1ShowEqualsPause = TRUE;
- }
- 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":
- 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))
- {
- if (pAnchor->m_bExternal)
- {
- 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,
- TRUE); // TRUE means we're hinting
- pHyper->Release();
- }
- }
- else
- {
- // /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))
- {
- GoToURLWithParamCheck(pOpenWindowURL, pTarget,
- NULL, pHyper, pAnchor,
- m_pContext, !bIsOnLoadActuation,
- TRUE); // TRUE means we're hinting
- pHyper->Release();
- }
- }
- }
- else if (pAnchor->m_bExternal ||
- bIsCommandURL ||
- bIsMailtoURL ||
- bIsCommandOpenWindowURL)
- {
- if(HXR_OK == pPlayer->QueryInterface(
- IID_IHXHyperNavigate, (void**)&pHyper))
- {
- GoToURLWithParamCheck(urlString, pTarget, pSendTo,
- pHyper, pAnchor, m_pContext,
- !bIsOnLoadActuation,
- TRUE); // TRUE means we're hinting
- HX_RELEASE(pHyper);
- }
- }
- }
- }
- }
- }
- void
- CSmilDocumentRenderer::CleanUpSiteInfoContainers()
- {
- HX_DELETE(m_pSiteInfoByRendererMap);
- // /For PR 116482: this needs to get deleted after
- // m_pSiteInfoByRendererMap, above. In case our close() gets called
- // before our SiteUserDetachSite() gets called, we still might have these
- // objects to delete:
- if (m_pSiteInfoList)
- {
- CHXSimpleList::Iterator i = m_pSiteInfoList->Begin();
- for(; i != m_pSiteInfoList->End(); ++i)
- {
- SMILSiteInfo* pSiteInfo = (SMILSiteInfo*)(*i);
- delete pSiteInfo;
- }
- }
- HX_DELETE(m_pSiteInfoList);
- }