sm1doc.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:173k
- //[SMIL 1.0 Compliance] Fixes PR 26473:
- // We want to add in LIFO fashion so inner
- // (nested) anchors will be found first in
- // CSmil1DocumentRenderer::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);
- // If the TLC starts off in double-size or non-original
- // size, then these anchors can get added AFTER the
- // SizeChanged call. Therefore, we need to check
- // here whether or not they need to be scaled.
- if ((m_topSiteSize.cx != m_topSiteOriginalSize.cx ||
- m_topSiteSize.cy != m_topSiteOriginalSize.cy) &&
- m_topSiteOriginalSize.cx != 0 &&
- m_topSiteOriginalSize.cy != 0)
- {
- // We are getting added when TLC is already scaled,
- // so we need to scale this anchor right off the bat
- //
- // Compute the absolute scale
- double dScaleX = (double) m_topSiteSize.cx / (double) m_topSiteOriginalSize.cx;
- double dScaleY = (double) m_topSiteSize.cy / (double) m_topSiteOriginalSize.cy;
- // Scale the anchor
- pAnchor->rescaleAbsolute(dScaleX, dScaleY);
- }
- }
- }
- bHandleElement = TRUE;
- }
- pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[uStreamNumber];
- pRendererList->AddTail(pSourceInfo);
- 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);
- HX_RELEASE(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(pRegionName);
- pLayoutStream->SetProperties(pValues);
- pValues->Release();
- }
- if(!pRegion->m_bImplicitRegion)
- {
- addSiteForRenderer(pPlayToAssoc, pSourceInfo, pRenderer, bNoRegion);
- }
- }
- }
- setZOrder();
- HX_RELEASE(pLayoutStream);
- }
- else // non-windowed renderer
- {
- pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex,
- (UINT16)ulTrackIndex);
- if(pPlayToAssoc)
- {
- SMIL1SourceInfo* pSourceInfo = NULL;
- CHXSimpleList* pRendererList = NULL;
- if (NULL == pPlayToAssoc->m_sourceMap[uStreamNumber])
- {
- pPlayToAssoc->m_sourceMap[uStreamNumber] = new CHXSimpleList();
- pPlayToAssoc->m_ulDuration = ulDuration - ulDelay;
- bHandleElement = TRUE;
- }
-
- pSourceInfo = new SMIL1SourceInfo;
- pSourceInfo->m_pStream = pStream;
- if(pSourceInfo->m_pStream)
- {
- pSourceInfo->m_pStream->AddRef();
- }
- pSourceInfo->m_pRenderer = pRenderer;
- if(pSourceInfo->m_pRenderer)
- {
- pSourceInfo->m_pRenderer->AddRef();
- }
- pSourceInfo->m_pRendererEventHook = NULL;
- pSourceInfo->m_ulDelay = ulDelay;
- pSourceInfo->m_ulDuration = ulDuration = ulDelay;
-
- pRendererList = (CHXSimpleList*) pPlayToAssoc->m_sourceMap[uStreamNumber];
- pRendererList->AddTail(pSourceInfo);
- }
- }
- // update the stream timing if it's been called in handleSourceUpdate()
- if(m_pDeferredSourceMap)
- {
- SMIL1DeferredSourceInfo* pDeferredInfo = NULL;
- const char* pDeferredID = (const char*)pPlayToAssoc->m_id;
- if(m_pDeferredSourceMap->Lookup(pDeferredID,
- (void*&)pDeferredInfo))
- {
- CSmil1Element* pThisElement =
- m_pSmilParser->findElement(pDeferredID);
- if(pThisElement &&
- pThisElement->m_ulBeginOffset != (UINT32)-1)
- {
- if(pDeferredInfo->m_ulDuration > pThisElement->m_ulBeginOffset)
- {
- updateStreamTiming(pDeferredID,
- pDeferredInfo->m_ulDuration -
- pThisElement->m_ulBeginOffset);
- }
- else
- {
- updateStreamTiming(pDeferredID, 0);
- }
- }
- else
- {
- updateStreamTiming(pDeferredID, pDeferredInfo->m_ulDuration);
- }
- }
- }
- if (bHandleElement)
- {
- handleElements();
- }
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- #if defined(_UNIX) && (!defined(_BEOS)) && defined(USE_XWINDOWS)
- XData* CSmil1DocumentRenderer::InitXVisualSupport(IHXSite* pSite, HXxWindow* pWnd)
- {
- // create new XData object
- XData* pxData = new XData();
- // use the pointer to the X display and window
- // conveniently given us by CHXSiteWindowed::HandleEvent
- m_pPixmapDisplay = (Display*) pWnd->display;
- Window window = (Window) pWnd->window;
- // save ptr to display in XData object also...
- pxData->m_Display = m_pPixmapDisplay;
- // get visual & set depth
- XWindowAttributes attr;
- XGetWindowAttributes(m_pPixmapDisplay, window, &attr);
- // get visual info & depth
- XVisualInfo visInfoMask;
- memset(&visInfoMask, 0, sizeof(XVisualInfo));
- visInfoMask.visualid = attr.visual->visualid;
- if (m_pVisualInfo)
- {
- XFree(m_pVisualInfo);
- m_pVisualInfo = NULL;
- }
- int nv;
- m_pVisualInfo = XGetVisualInfo(m_pPixmapDisplay, VisualIDMask, &visInfoMask, &nv);
- UINT32 nDepth = 32;
- nDepth = (UINT32) m_pVisualInfo->depth;
- // Get Colormap
- pxData->m_colormap = attr.colormap;
- // get bits per pixel information for the best depth we can display
- ULONG32 bitsPerPixel = 32;
- int i, n;
- XPixmapFormatValues *pixmap_formats = XListPixmapFormats(m_pPixmapDisplay, &n);
- if (pixmap_formats)
- {
- for (i = 0; i < n; i++)
- {
- if (pixmap_formats[i].depth == nDepth)
- {
- bitsPerPixel = pixmap_formats[i].bits_per_pixel;
- }
- }
- }
- XFree(pixmap_formats);
- // get site size
- HXxSize siteWinSize;
- pSite->GetSize(siteWinSize);
- pxData->m_backgroundBitmapInfoHeader.biSize = sizeof(HXBitmapInfoHeader);
- pxData->m_backgroundBitmapInfoHeader.biWidth = siteWinSize.cx;
- pxData->m_backgroundBitmapInfoHeader.biHeight = siteWinSize.cy;
- pxData->m_backgroundBitmapInfoHeader.biPlanes = 1; // just seems to be the convention
- pxData->m_backgroundBitmapInfoHeader.biBitCount = bitsPerPixel;
- HX_ASSERT(pxData->m_backgroundBitmapInfoHeader.biBitCount % 8 == 0);
- // BI_RGB just seems to be the convention
- switch (pxData->m_backgroundBitmapInfoHeader.biBitCount)
- {
- case 8:
- case 24:
- case 32:
- pxData->m_backgroundBitmapInfoHeader.biCompression = BI_RGB;
- break;
- case 16:
- pxData->m_backgroundBitmapInfoHeader.biCompression = HXCOLOR_RGB565_ID;
- break;
- default:
- HX_ASSERT(FALSE);
- }
- pxData->m_backgroundBitmapInfoHeader.biSizeImage = //size of image (bytes):
- pxData->m_backgroundBitmapInfoHeader.biWidth * pxData->m_backgroundBitmapInfoHeader.biHeight *
- pxData->m_backgroundBitmapInfoHeader.biBitCount;
- pxData->m_backgroundBitmapInfoHeader.biXPelsPerMeter = 0;
- pxData->m_backgroundBitmapInfoHeader.biYPelsPerMeter = 0;
- pxData->m_backgroundBitmapInfoHeader.biClrUsed = 0;
- pxData->m_backgroundBitmapInfoHeader.biClrImportant = 0;
- pxData->m_backgroundBitmapInfoHeader.rcolor = m_pVisualInfo->red_mask;
- pxData->m_backgroundBitmapInfoHeader.gcolor = m_pVisualInfo->green_mask;
- pxData->m_backgroundBitmapInfoHeader.bcolor = m_pVisualInfo->blue_mask;
- pxData->m_Pixmap = XCreatePixmap(m_pPixmapDisplay,
- window,
- pxData->m_backgroundBitmapInfoHeader.biWidth,
- pxData->m_backgroundBitmapInfoHeader.biHeight,
- nDepth);
- return pxData;
- }
- #endif
- STDMETHODIMP
- CSmil1DocumentRenderer::RendererClosed(IHXRenderer* pRenderer,
- IHXValues* pInfo)
- {
- HX_RESULT rc = HXR_OK;
- UINT32 ulGroupIndex = 0;
- UINT32 ulTrackIndex = 0;
- UINT32 ulStreamNumber = 0;
- CHXSimpleList* pRendererList = NULL;
- SMIL1PlayToAssoc* pPlayToAssoc = NULL;
- SMIL1SiteInfo* pSiteInfo = NULL;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocRendererClosed(
- pRenderer, pInfo);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- pInfo->GetPropertyULONG32("GroupIndex", ulGroupIndex);
- pInfo->GetPropertyULONG32("TrackIndex", ulTrackIndex);
- pInfo->GetPropertyULONG32("StreamNumber", ulStreamNumber);
- if (m_pPlayToAssocList)
- {
- pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex,
- (UINT16)ulTrackIndex);
- if (pPlayToAssoc)
- {
- pPlayToAssoc->m_sourceMap.Lookup(ulStreamNumber, (void*&) pRendererList);
- }
- }
- if (m_pSiteInfoByRendererMap &&
- m_pSiteInfoByRendererMap->Lookup(pRenderer, (void*&) pSiteInfo))
- {
- RemoveEvents(ulGroupIndex, pSiteInfo->m_pRendererSite);
- CSmil1BasicRegion* pRegion = getRegion(pSiteInfo->m_regionID);
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- // we only want to hide the region if there is no more
- // renderer site shares the same region
- if (!pRendererList || pRendererList->GetCount() == 1)
- {
- IHXSite* pRegionSite = NULL;
- if (!pRegion->m_bBgColorSet)
- {
- pRegionSite = pSiteInfo->m_pRegionSite;
- }
- showSite(pRegionSite, FALSE);
- }
- if (pSiteInfo->m_pRendererSite)
- {
- m_pSiteMgr->RemoveSite(pSiteInfo->m_pRendererSite);
- pSiteInfo->m_pRendererSite->DetachWatcher();
-
- if(pRegion && pRegion->m_pSite)
- {
- pRegion->m_pSite->DestroyChild(pSiteInfo->m_pRendererSite);
- }
- }
- HX_RELEASE(pSiteInfo->m_pRendererSite);
- m_pSiteInfoByRendererMap->RemoveKey((void*)pRenderer);
- if(m_pSiteInfoList)
- {
- // remove pSiteInfo from list
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while(pos)
- {
- SMIL1SiteInfo* pThisSiteInfo = (SMIL1SiteInfo*)
- m_pSiteInfoList->GetAt(pos);
- if(pThisSiteInfo == pSiteInfo)
- {
- delete pThisSiteInfo;
- m_pSiteInfoList->RemoveAt(pos);
- break;
- }
- m_pSiteInfoList->GetNext(pos);
- }
- }
- }
- if (pPlayToAssoc)
- {
- LISTPOSITION pos;
- SMIL1SourceInfo* pSMIL1SourceInfo = NULL;
- if (pRendererList)
- {
- CHXSimpleList::Iterator i = pRendererList->Begin();
- for (; i != pRendererList->End(); ++i)
- {
- pSMIL1SourceInfo = (SMIL1SourceInfo*) (*i);
-
- if (pSMIL1SourceInfo->m_pRenderer == pRenderer)
- {
- pos = pRendererList->Find(pSMIL1SourceInfo);
- pRendererList->RemoveAt(pos);
-
- if (pSMIL1SourceInfo->m_pRendererEventHook)
- {
- // get to the site manager and set an event hook
- IHXEventHookMgr* pHookMgr = NULL;
- if(HXR_OK == m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr,
- (void**)&pHookMgr))
- {
- pHookMgr->RemoveHook(pSMIL1SourceInfo->m_pRendererEventHook,
- pSMIL1SourceInfo->m_pRendererEventHook->m_pChannelName, 0);
- }
- pHookMgr->Release();
- }
-
- HX_RELEASE(pSMIL1SourceInfo->m_pRendererEventHook);
- HX_RELEASE(pSMIL1SourceInfo->m_pStream);
- HX_RELEASE(pSMIL1SourceInfo->m_pRenderer);
- HX_DELETE(pSMIL1SourceInfo);
- break;
- }
- }
- if (pRendererList->GetCount())
- {
- pSMIL1SourceInfo = (SMIL1SourceInfo*)pRendererList->GetHead();
-
- pPlayToAssoc->m_tunerName = pSMIL1SourceInfo->m_tunerName;
- pPlayToAssoc->m_childTunerName = pSMIL1SourceInfo->m_childTunerName;
- pPlayToAssoc->m_ulDelay = pSMIL1SourceInfo->m_ulDelay;
- pPlayToAssoc->m_ulDuration = pSMIL1SourceInfo->m_ulDuration;
- pPlayToAssoc->m_pRendererEventHook = pSMIL1SourceInfo->m_pRendererEventHook;
- }
- }
- if (pPlayToAssoc->m_pSiteInfoList->GetCount() > 0 &&
- pSiteInfo)
- {
- pos = pPlayToAssoc->m_pSiteInfoList->Find(pSiteInfo);
- pPlayToAssoc->m_pSiteInfoList->RemoveAt(pos);
- }
- }
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::addSiteForRenderer(SMIL1PlayToAssoc* pPlayToAssoc,
- SMIL1SourceInfo* pSMIL1SourceInfo,
- IHXRenderer* pRenderer,
- BOOL bNoRegion)
- {
- IHXSite* pRendererSite = 0;
- if(!m_pMISUSSite)
- {
- return HXR_UNEXPECTED;
- }
- CSmil1BasicRegion* pRegion = getRegion(pPlayToAssoc->m_playTo);
- HX_ASSERT(pRegion);
- HX_ASSERT(pRegion->m_pSite);
- // now create a child of the parent site
- // to hook to the renderer
- pRegion->m_pSite->CreateChild(pRendererSite);
- HX_ASSERT(pRendererSite);
- #ifdef _DEBUGBAB
- char debugStr[256]; /* Flawfinder: ignore */
- sprintf(debugStr, "region %s z-index %ld site: %p renderer site %pn", /* Flawfinder: ignore */
- (const char*)pPlayToAssoc->m_playTo,
- pRegion->m_lZIndex,
- pRegion->m_pSite,
- pRendererSite);
- OutputDebugString(debugStr);
- #endif
- CSmil1SiteWatcher* pRendererWatch = new CSmil1SiteWatcher(
- this, pPlayToAssoc->m_playTo, TRUE);
- pRendererWatch->AddRef();
- pRendererSite->AttachWatcher(pRendererWatch);
- // map renderer site to the renderer
- if(!m_pSiteWatcherMap)
- {
- m_pSiteWatcherMap = new CHXMapPtrToPtr;
- }
- (*m_pSiteWatcherMap)[pRendererSite] = pRendererWatch;
- IHXValues* pRendererSiteProps = NULL;
- if (HXR_OK == pRendererSite->QueryInterface
- (IID_IHXValues,
- (void**)&pRendererSiteProps))
- {
- CHXBuffer* pTunerValue = new CHXBuffer;
- pTunerValue->AddRef();
- pTunerValue->Set((UCHAR*)(const char*) pSMIL1SourceInfo->m_childTunerName,
- strlen(pSMIL1SourceInfo->m_childTunerName)+1);
- pRendererSiteProps->SetPropertyCString("channel", pTunerValue);
- pTunerValue->Release();
- pRendererSiteProps->Release();
- }
- // This site needs to be added to the Site Manager!!!
- m_pSiteMgr->AddSite(pRendererSite);
- // hide the site initially
- IHXSite* pRegionSite = NULL;
- if(!pRegion->m_bBgColorSet)
- {
- pRegionSite = pRegion->m_pSite;
- }
- if(pSMIL1SourceInfo->m_ulDelay > 0)
- {
- // show site after m_ulDelay
- showSite(pRendererSite, FALSE);
- }
- else
- {
- // show it now, don't wait for first time sync
- showSite(pRegionSite, TRUE);
- showSite(pRendererSite, TRUE);
- }
- // in any case, stick the event on the list...
- CSmil1ShowSiteEvent* pShowEvent =
- new CSmil1ShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
- pSMIL1SourceInfo->m_ulDelay, pRendererSite,
- pRegionSite, TRUE);
- insertEvent(pShowEvent);
- // hide site after m_ulDuration if it isn't live
- if(pPlayToAssoc->m_bRemoveSite &&
- !pPlayToAssoc->m_bLiveSource)
- {
- CSmil1ShowSiteEvent* pHideEvent =
- new CSmil1ShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
- pSMIL1SourceInfo->m_ulDuration + pSMIL1SourceInfo->m_ulDelay,
- pRendererSite, pRegionSite, FALSE);
- insertEvent(pHideEvent);
- }
- SMIL1SiteInfo* pSiteInfo = new SMIL1SiteInfo;
- pSiteInfo->m_pRendererSite = pRendererSite;
- pSiteInfo->m_pRegionSite = pRegionSite;
- pSiteInfo->m_uGroupIndex = pPlayToAssoc->m_uGroupIndex;
- pSiteInfo->m_ulDelay = pSMIL1SourceInfo->m_ulDelay;
- pSiteInfo->m_ulDuration = pSMIL1SourceInfo->m_ulDuration +
- pSMIL1SourceInfo->m_ulDelay;
- pSiteInfo->m_bRemoveSite = pPlayToAssoc->m_bRemoveSite;
- pSiteInfo->m_bNoRegion = bNoRegion;
- pSiteInfo->m_regionID = pPlayToAssoc->m_playTo;
- pSiteInfo->m_pRenderer = pRenderer;
- pPlayToAssoc->m_pSiteInfoList->AddTail(pSiteInfo);
- insertSiteInfo(pSiteInfo);
- m_pSiteInfoByRendererMap->SetAt(pRenderer,
- pSiteInfo);
- return HXR_OK;
- }
- void
- CSmil1DocumentRenderer::insertZOrder(IHXSite* pSite, INT32 lZOrder)
- {
- if(!m_pZOrderList)
- {
- m_pZOrderList = new CHXSimpleList;
- }
- SMIL1ZOrderInfo* pInfo = new SMIL1ZOrderInfo;
- pInfo->m_pSite = pSite;
- pInfo->m_lZIndex = lZOrder;
- LISTPOSITION lPos = m_pZOrderList->GetHeadPosition();
- LISTPOSITION lPrev = lPos;
- BOOL bInserted = FALSE;
- while(lPos)
- {
- SMIL1ZOrderInfo* pThisInfo = (SMIL1ZOrderInfo*)m_pZOrderList->GetNext(lPos);
- if(pThisInfo->m_lZIndex > lZOrder)
- {
- m_pZOrderList->InsertBefore(lPrev, pInfo);
- bInserted = TRUE;
- break;
- }
- lPrev = lPos;
- }
- if(!bInserted)
- {
- // not inserted, stick it on the end of the list
- m_pZOrderList->AddTail(pInfo);
- }
- }
- /*
- * setZOrder - run through all the channels
- * and set the Z ordering for each
- */
- void
- CSmil1DocumentRenderer::setZOrder()
- {
- if(!m_pRegionMap)
- {
- return;
- }
- CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
- for(; i != m_pRegionMap->End(); ++i)
- {
- CSmil1BasicRegion* pRegion = (CSmil1BasicRegion*)(*i);
- HXxWindow* pWindow = NULL;
- IHXSiteWindowed* pSiteWindowed = NULL;
- if(pRegion->m_pSite &&
- HXR_OK == pRegion->m_pSite->QueryInterface(
- IID_IHXSiteWindowed, (void**)&pSiteWindowed))
- {
- pWindow = pSiteWindowed->GetWindow();
- if (!pWindow || !pWindow->window)
- {
- IHXSite2* pSite2 = 0;
- if(HXR_OK == pRegion->m_pSite->QueryInterface(
- IID_IHXSite2, (void**)&pSite2))
- {
- pSite2->SetZOrder(pRegion->m_lZIndex);
- pSite2->Release();
- }
- }
- else
- {
- insertZOrder(pRegion->m_pSite, pRegion->m_lZIndex);
- }
- pSiteWindowed->Release();
- }
- else
- {
- insertZOrder(pRegion->m_pSite, pRegion->m_lZIndex);
- }
- }
- if(m_pZOrderList)
- {
- INT32 idx = 0;
- LISTPOSITION lPos = m_pZOrderList->GetHeadPosition();
- while(lPos)
- {
- SMIL1ZOrderInfo* pInfo =
- (SMIL1ZOrderInfo*)m_pZOrderList->GetAt(lPos);
- IHXSite2* pSite2 = 0;
- if(pInfo->m_pSite &&
- HXR_OK == pInfo->m_pSite->QueryInterface(IID_IHXSite2,
- (void**)&pSite2))
- {
- #ifdef _DEBUGBAB
- char debugStr[256]; /* Flawfinder: ignore */
- sprintf(debugStr, "SMILDocRenderer:: site %p set z-order %ldn", pInfo->m_pSite, idx); /* Flawfinder: ignore */
- OutputDebugString(debugStr);
- #endif
- pSite2->SetZOrder(idx);
- pSite2->Release();
- }
- idx++;
- delete pInfo;
- lPos = m_pZOrderList->RemoveAt(lPos);
- }
- HX_DELETE(m_pZOrderList);
- }
- }
- /*
- * IHXGroupSink methods
- */
- STDMETHODIMP
- CSmil1DocumentRenderer::GroupAdded(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- HX_RESULT rc = HXR_OK;
- SMIL1GroupInfo* pGroupInfo = 0;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocGroupAdded(
- uGroupIndex, pGroup);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- if(!m_pGroupInfoMap)
- {
- m_pGroupInfoMap = new CHXMapLongToObj;
- }
- // save group info
- if(!m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- IHXGroupManager* pMgr = 0;
- UINT32 ulTotalTracks = 0;
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager,
- (void**)&pMgr))
- {
- IHXGroup* pGroup = NULL;
- IHXGroup2* pGroup2 = NULL;
- if (HXR_OK == pMgr->GetGroup(uGroupIndex, pGroup) &&
- HXR_OK == pGroup->QueryInterface(IID_IHXGroup2, (void**)&pGroup2))
- {
- IHXValues* pGroupProperties = NULL;
- pGroup2->GetPersistentComponentProperties(m_ulPersistentComponentID,
- pGroupProperties);
- if(pGroupProperties)
- {
- pGroupProperties->GetPropertyULONG32("total_tracks",
- ulTotalTracks);
- }
- HX_RELEASE(pGroupProperties);
- }
- HX_RELEASE(pGroup2);
- HX_RELEASE(pGroup);
- }
- HX_RELEASE(pMgr);
-
- pGroupInfo = new SMIL1GroupInfo;
- pGroupInfo->m_nTracks = (int)ulTotalTracks;
- pGroupInfo->m_nTracksAdded = 0;
- pGroupInfo->m_nTrackDurationsSet = 0;
- pGroupInfo->m_ulDuration = 0;
- (*m_pGroupInfoMap)[uGroupIndex] = pGroupInfo;
- }
- else
- {
- pGroupInfo->m_nTracksAdded++;
- }
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GroupRemoved(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- HX_RESULT rc = HXR_OK;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocGroupRemoved(
- uGroupIndex, pGroup);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::AllGroupsRemoved()
- {
- HX_RESULT rc = HXR_NOTIMPL;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocAllGroupsRemoved();
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::TrackAdded(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT rc = HXR_OK;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackAdded(
- uGroupIndex, uTrackIndex, pTrack);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- if(pTrack)
- {
- IHXBuffer* pBuf = 0;
- const char* pID = 0;
- const char* pRegionName = 0;
- UINT32 ulDelay = 0;
- const char* pRepeatID = 0; // /For SHAZAM.
- if(HXR_OK == pTrack->GetPropertyCString("id", pBuf))
- {
- pID = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- // /For SHAZAM:
- if(HXR_OK == pTrack->GetPropertyCString("repeatid", pBuf))
- {
- pRepeatID = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("region", pBuf))
- {
- pRegionName = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("playto", pBuf))
- {
- const char* pPlayTo = (const char*)pBuf->GetBuffer();
- setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID,
- pPlayTo, pRegionName);
- pBuf->Release();
- }
- else // non-windowed renderer
- {
- setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID,
- 0, pRegionName);
- }
- SMIL1PlayToAssoc* pAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if(pAssoc)
- {
- if(HXR_OK == pTrack->GetPropertyCString("fill", pBuf))
- {
- const char* pFill = (const char*)pBuf->GetBuffer();
- if(strcmp(pFill, "freeze") == 0) // default is 'remove'
- {
- pAssoc->m_bRemoveSite = FALSE;
- }
- pBuf->Release();
- }
- }
- SMIL1GroupInfo* pGroupInfo = 0;
- if(m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
- {
- pGroupInfo->m_nTracksAdded++;
- }
- }
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::TrackRemoved(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT rc = HXR_NOTIMPL;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackRemoved(
- uGroupIndex, uTrackIndex, pTrack);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::TrackStarted(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT rc = HXR_NOTIMPL;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackStarted(
- uGroupIndex, uTrackIndex, pTrack);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- if(m_bSettingFragment)
- {
- // find out if all tracks for this group have been
- // added, then go ahead and seek
- UINT16 uFragmentGroup = m_pSmilParser->getFragmentGroup(m_pFragment);
- if(uFragmentGroup == uGroupIndex)
- {
- SMIL1GroupInfo* pGroupInfo = 0;
- m_nFragmentTracks++;
- if(m_pGroupInfoMap->Lookup(uFragmentGroup, (void*&)pGroupInfo))
- {
- if(pGroupInfo->m_nTracks == m_nFragmentTracks)
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- BOOL bFragFoundAndResolved = TRUE;
- UINT32 ulFragmentOffset =
- m_pSmilParser->getFragmentOffset(m_pFragment,
- bFragFoundAndResolved /*<--Passed by reference.*/);
- //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(bFragFoundAndResolved)
- {
- pPlayer->Seek(ulFragmentOffset);
- }
- m_bSettingFragment = FALSE;
- }
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::TrackStopped(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT rc = HXR_NOTIMPL;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocTrackStopped(
- uGroupIndex, uTrackIndex, pTrack);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::CurrentGroupSet(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- HX_RESULT rc = HXR_OK;
- INT16 uPrevGroupIndex = m_uCurrentGroupIndex;
- #if defined(HELIX_FEATURE_SMIL2)
- if (m_pParent->isHigherVersionSmilStreamFromOldSMIL1FF())
- {
- HX_ASSERT(m_pParent->m_pNextGenSmilRenderer);
- if (m_pParent->m_pNextGenSmilRenderer)
- {
- rc = m_pParent->m_pNextGenSmilRenderer->SmilDocCurrentGroupSet(
- uGroupIndex, pGroup);
- goto cleanup;
- }
- }
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- m_uCurrentGroupIndex = (INT16)uGroupIndex;
- m_ulCurrentTime = 0;
- if(uPrevGroupIndex != -1)
- {
- m_pSmilParser->resetTimeline();
- removeGroupEvents(uPrevGroupIndex);
-
- removeGroupsPlayToAssoc(uPrevGroupIndex);
-
- m_ulEventListPosition = 0;
- if(m_pStatusMessage)
- {
- m_pStatusMessage->SetStatus(NULL);
- }
- // hide any "transparent" sites
- if(m_pRegionMap)
- {
- CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
- for(; i != m_pRegionMap->End(); ++i)
- {
- CSmil1BasicRegion* pRegion = (CSmil1BasicRegion*)(*i);
- if(!pRegion->m_bBgColorSet)
- {
- showSite(pRegion->m_pSite, FALSE);
- }
- }
- }
- }
-
- #if defined(HELIX_FEATURE_SMIL2)
- cleanup:
- #endif /* defined(HELIX_FEATURE_SMIL2). */
- return rc;
- }
- void
- CSmil1DocumentRenderer::removeGroupEvents(UINT16 uGroupIndex)
- {
- if(m_pEventList)
- {
- LISTPOSITION lPos = m_pEventList->GetHeadPosition();
- while(lPos)
- {
- // handle all events at or before ulTimeValue
- CSmil1LayoutEvent* pEvent = (CSmil1LayoutEvent*)m_pEventList->GetAt(lPos);
- if(pEvent->m_uGroupIndex == uGroupIndex)
- {
- delete pEvent;
- lPos = m_pEventList->RemoveAt(lPos);
- }
- }
- }
- }
- SMIL1PlayToAssoc*
- CSmil1DocumentRenderer::getPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = 0;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
- {
- SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
- if((pThisAssoc->m_uGroupIndex == uGroupIndex) &&
- (pThisAssoc->m_uTrackIndex == uTrackIndex))
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- return pPlayToAssoc;
- }
- SMIL1PlayToAssoc*
- CSmil1DocumentRenderer::getPlayToAssoc(const char* pPlayTo)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = 0;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i;
- for(i=m_pPlayToAssocList->Begin();i!=m_pPlayToAssocList->End();++i)
- {
- SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
- if(pThisAssoc->m_playTo == pPlayTo)
- {
- pPlayToAssoc = pThisAssoc;
- break;
- }
- }
- }
- return pPlayToAssoc;
- }
- void
- CSmil1DocumentRenderer::setPlayToAssoc(UINT16 uGroupIndex, UINT16 uTrackIndex,
- const char* pID,
- const char* pRepeatID, // /For SHAZAM
- const char* pPlayTo,
- const char* pRegionName)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if(!pPlayToAssoc)
- {
- pPlayToAssoc = new SMIL1PlayToAssoc;
- 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_bDurationResolved = FALSE;
- pPlayToAssoc->m_bRemoveSite = TRUE; // default is remove
- pPlayToAssoc->m_pHyperlinks = new CHXSimpleList;
- pPlayToAssoc->m_pRendererEventHook = NULL;
- pPlayToAssoc->m_pSiteInfoList = new CHXSimpleList;
- 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 CSmil1BasicRegion
- BOOL bNoRegion = TRUE;
- if(pPlayTo)
- {
- CSmil1BasicRegion* pRegion = getRegion(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
- CSmil1DocumentRenderer::removeSourcemap(SMIL1PlayToAssoc* 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);
- CHXSimpleList::Iterator k = pRendererList->Begin();
- for (; k != pRendererList->End(); ++k)
- {
- SMIL1SourceInfo* pSMIL1SourceInfo = (SMIL1SourceInfo*)(*k);
- if (pSMIL1SourceInfo->m_pRendererEventHook && pHookMgr)
- {
- pHookMgr->RemoveHook(pSMIL1SourceInfo->m_pRendererEventHook,
- pSMIL1SourceInfo->m_pRendererEventHook->m_pChannelName, 0);
- }
- HX_RELEASE(pSMIL1SourceInfo->m_pRendererEventHook);
- HX_RELEASE(pSMIL1SourceInfo->m_pStream);
- HX_RELEASE(pSMIL1SourceInfo->m_pRenderer);
-
- HX_DELETE(pSMIL1SourceInfo);
- }
- HX_DELETE(pRendererList);
- }
- pPlayToAssoc->m_sourceMap.RemoveAll();
- HX_RELEASE(pHookMgr);
- }
- void
- CSmil1DocumentRenderer::removeAllPlayToAssoc()
- {
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*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
- CSmil1DocumentRenderer::removeGroupsPlayToAssoc(UINT16 uGroupIndex)
- {
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*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
- CSmil1DocumentRenderer::showSite(IHXSite* pSite, BOOL bShow)
- {
- if(pSite)
- {
- IHXSite2* pSite2 = 0;
- if(HXR_OK == pSite->QueryInterface(IID_IHXSite2,
- (void**)&pSite2))
- {
- pSite2->ShowSite(bShow);
- pSite2->Release();
- }
- }
- }
- CSmil1AAnchorElement*
- CSmil1DocumentRenderer::findHyperlinkElement(const char* pID,
- UINT16 uXPos, UINT16 uYPos)
- {
- // This code is not needed with new windowless site impl. of fullscreen
- if (IsFullScreen())
- {
- IHXSiteWindowless* pSiteWndless = NULL;
- if (m_pMISUSSite)
- {
- m_pMISUSSite->QueryInterface(IID_IHXSiteWindowless, (void**) &pSiteWndless);
- }
- // need to do this conversion only for the OLD site implementation
- if (m_pMISUSSite && 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_pMISUSSite->GetSize(cCurSize);
- // Scale it down
- if (cCurSize.cx)
- {
- uXPos = (UINT16) (uXPos * m_topSiteOriginalSize.cx / cCurSize.cx);
- }
- if (cCurSize.cy)
- {
- uYPos = (UINT16) (uYPos * m_topSiteOriginalSize.cy / cCurSize.cy);
- }
- }
-
- HX_RELEASE(pSiteWndless);
- }
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for(; i != m_pPlayToAssocList->End(); ++i)
- {
- SMIL1PlayToAssoc* pAssoc = (SMIL1PlayToAssoc*)(*i);
- if(strcmp((const char*)pAssoc->m_playTo, pID) == 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
- SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)(*j);
- 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 = m_ulCurrentTime >= pSiteInfo->m_ulDelay &&
- m_ulCurrentTime <= pSiteInfo->m_ulDelay +
- ulDur;
- }
- else
- {
- bCurrentSite = m_ulCurrentTime >= pSiteInfo->m_ulDelay;
- }
-
- if(bCurrentSite)
- {
- UINT32 ulRelativeTime = m_ulCurrentTime - pAssoc->m_ulDelay;
- CHXSimpleList::Iterator j = pAssoc->m_pHyperlinks->Begin();
- for(; j != pAssoc->m_pHyperlinks->End(); ++j)
- {
- CSmil1AAnchorElement* pAnchor = (CSmil1AAnchorElement*)(*j);
- CSmil1BasicRegion* pRegion =
- getRegion(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;
- }
- if(pAnchor->isCurrentLink(ulRelativeTime, uXPos, uYPos,
- mediaRect))
- {
- //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 ignore the hyperlink for now:
- const char* pFragment =
- pAnchor->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 reference: */
- bFragFoundAndResolved);
- //Fixes PR 22655:
- //Ignore if not found or not yet resolved:
- if(!bFragFoundAndResolved)
- {
- // begin time not resolved yet
- return NULL;
- }
- }
- return pAnchor;
- }
- }
- }
- }
- }
- }
- }
- }
- return NULL;
- }
- HX_RESULT
- CSmil1DocumentRenderer::handleMouseMove(void* pWindow,
- const char* pID,
- UINT16 uXPos, UINT16 uYPos)
- {
- // 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
- if(uXPos == m_usOldXPos &&
- uYPos == m_usOldYPos)
- {
- return HXR_OK;
- }
- m_usOldXPos = uXPos;
- m_usOldYPos = uYPos;
- HX_RESULT rc = HXR_FAIL;
- #if defined(_WINDOWS)
- HCURSOR hCurrentCursor = GetCursor();
- #endif
- CSmil1AAnchorElement* pAnchor = findHyperlinkElement(pID,
- uXPos, uYPos);
- if(pAnchor)
- {
- #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)
- {
- XDefineCursor(m_pDisplay, m_Window, m_hHyperlinkCursor);
- m_hCurrentCursor = m_hHyperlinkCursor;
- }
- #endif
- if (m_pStatusMessage)
- {
- m_pStatusMessage->SetStatus (pAnchor->m_href);
- m_bStatusMessageSet = TRUE;
- }
- rc = HXR_OK; // handled
- }
- else
- {
- #if defined(_WINDOWS)
- if(hCurrentCursor == m_hHyperlinkCursor)
- {
- //We need to change it back -- we just moved off of a hyperlink:
- m_bNeedToSetHyperlinkCursor = FALSE;
- }
- #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)
- {
- XUndefineCursor(m_pDisplay, m_Window);
- m_hCurrentCursor = 0;
- }
- #endif
- if (m_pStatusMessage &&
- m_bStatusMessageSet)
- {
- m_pStatusMessage->SetStatus(NULL);
- m_bStatusMessageSet = FALSE;
- }
- }
- return rc;
- }
- BOOL
- CSmil1DocumentRenderer::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;
- }
- HX_RESULT
- CSmil1DocumentRenderer::handleLButtonUp(const char* pID,
- UINT16 uXPos, UINT16 uYPos)
- {
- #if defined(_UNIX) && (!defined(_BEOS)) && defined(USE_XWINDOWS)
- //Clear the previously set cursors before leaving this window
- if(m_Window)
- XUndefineCursor(m_pDisplay, m_Window);
- #endif
- HX_RESULT rc = HXR_FAIL;
- CSmil1AAnchorElement* pAnchor = findHyperlinkElement(pID,
- uXPos, uYPos);
- if(pAnchor && pAnchor->m_href.GetLength() > 0)
- {
- if(m_pParent)
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if(pPlayer)
- {
- const char* pTarget = "_player";
- // if show is 'new' or 'pause', spawn a browser
- if(pAnchor->m_show == "new" ||
- pAnchor->m_show == "pause")
- {
- pTarget = 0;
- }
- if(pAnchor->m_href[0] == '#')
- {
- if (!m_pProcessElementCallback)
- {
- m_pProcessElementCallback = new ProcessElementCallback();
- m_pProcessElementCallback->m_pOwner = this;
- m_pProcessElementCallback->AddRef();
- }
- if (m_pScheduler && !m_pProcessElementCallback->m_bIsCallbackPending)
- {
- m_pProcessElementCallback->m_elementID = pAnchor->m_href.Mid(1);
- m_pProcessElementCallback->m_bIsCallbackPending = TRUE;
- m_pProcessElementCallback->m_PendingHandle = m_pScheduler->RelativeEnter(m_pProcessElementCallback, 0);
- }
- else
- {
- HX_ASSERT(FALSE);
- }
- }
- else
- {
- if(pAnchor->m_show == "pause")
- {
- pPlayer->Pause();
- }
- IHXHyperNavigate* pHyper = 0;
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXHyperNavigate,
- (void**)&pHyper))
- {
- CHXString urlString;
- convertURL(pAnchor->m_href, urlString);
- pHyper->GoToURL(urlString, pTarget);
- pHyper->Release();
- }
- }
- }
- rc = HXR_OK;
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::detachSite(IHXSite* pSite)
- {
- HX_RESULT rc = HXR_OK;
- // remove site from site info list
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while(pos)
- {
- SMIL1SiteInfo* pSiteInfo =
- (SMIL1SiteInfo*)m_pSiteInfoList->GetAt(pos);
- if(pSiteInfo->m_pRendererSite == pSite)
- {
- CSmil1BasicRegion* pRegion = getRegion(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)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*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
- CSmil1DocumentRenderer::updateStreamTiming(const char* pElementID,
- UINT32 ulDuration)
- {
- HX_RESULT rc = HXR_OK;
- CSmil1Element* pElement = m_pSmilParser->findElement(pElementID);
- if(pElement)
- {
- // find the SMIL1PlayToAssoc associated with this element ID
- SMIL1PlayToAssoc* pPlayToAssoc = NULL;
- if(m_pPlayToAssocList)
- {
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMIL1PlayToAssoc* pThisAssoc = (SMIL1PlayToAssoc*)(*i);
- if(pThisAssoc->m_id == (const char*)pElement->m_pNode->m_id)
- {
- 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);
- SMIL1SourceInfo* pSourceInfo = (SMIL1SourceInfo*)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))
- {
- 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
- CSmil1DocumentRenderer::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)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*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)
- {
- SMIL1SourceInfo* pSMIL1SourceInfo = (SMIL1SourceInfo*)(*k);
- IHXLayoutStream* pLayoutStream = NULL;
- if(HXR_OK ==
- pSMIL1SourceInfo->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
- CSmil1DocumentRenderer::updateSiteEvents(UINT16 uGroupIndex)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pPlayToAssocList)
- {
- // blow away current events
- removeGroupEvents(uGroupIndex);
- CHXSimpleList::Iterator i = m_pPlayToAssocList->Begin();
- for (; i!=m_pPlayToAssocList->End(); ++i)
- {
- SMIL1PlayToAssoc* pPlayToAssoc = (SMIL1PlayToAssoc*)(*i);
- if(pPlayToAssoc->m_uGroupIndex == uGroupIndex &&
- pPlayToAssoc->m_pSiteInfoList)
- {
- CHXSimpleList::Iterator j = pPlayToAssoc->m_pSiteInfoList->Begin();
- for (; j != pPlayToAssoc->m_pSiteInfoList->End(); ++j)
- {
- SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)(*j);
-
- IHXSite* pRegionSite = NULL;
- CSmil1BasicRegion* pRegion = getRegion(pSiteInfo->m_regionID);
- if(pRegion && !pRegion->m_bBgColorSet)
- {
- pRegionSite = pRegion->m_pSite;
- }
- pSiteInfo->m_ulDelay = pPlayToAssoc->m_ulDelay;
- pSiteInfo->m_ulDuration = pPlayToAssoc->m_ulDuration;
- if(pSiteInfo->m_ulDelay > m_ulCurrentTime)
- {
- // hide site and schedule show and hide events
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- showSite(pRegionSite, FALSE);
- CSmil1ShowSiteEvent* pShowEvent =
- new CSmil1ShowSiteEvent(uGroupIndex,
- pSiteInfo->m_ulDelay, pSiteInfo->m_pRendererSite,
- pRegionSite, TRUE);
- insertEvent(pShowEvent);
- if(pSiteInfo->m_bRemoveSite)
- {
- CSmil1ShowSiteEvent* pHideEvent =
- new CSmil1ShowSiteEvent(uGroupIndex,
- pSiteInfo->m_ulDuration + pSiteInfo->m_ulDelay,
- pSiteInfo->m_pRendererSite,
- pRegionSite, FALSE);
- insertEvent(pHideEvent);
- }
- }
- else if((pSiteInfo->m_ulDelay + pSiteInfo->m_ulDuration)
- < m_ulCurrentTime)
- {
- // XXX HP THIS SHOULD NEVER HAPPEN!!
- HX_ASSERT(FALSE);
- // after this site should be hidden
- if(pSiteInfo->m_bRemoveSite)
- {
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- showSite(pRegionSite, FALSE);
- }
- }
- else
- {
- // schedule both show and hide events
- // so onPreSeek will get all necessary
- // events
- CSmil1ShowSiteEvent* pShowEvent =
- new CSmil1ShowSiteEvent(uGroupIndex,
- pSiteInfo->m_ulDelay, pSiteInfo->m_pRendererSite,
- pRegionSite, TRUE);
- insertEvent(pShowEvent);
- if(pSiteInfo->m_bRemoveSite)
- {
- CSmil1ShowSiteEvent* pHideEvent =
- new CSmil1ShowSiteEvent(uGroupIndex,
- pSiteInfo->m_ulDuration + pSiteInfo->m_ulDelay,
- pSiteInfo->m_pRendererSite,
- pRegionSite, FALSE);
- insertEvent(pHideEvent);
- }
- }
- }
- }
- }
- }
- return rc;
- }
-
- HX_RESULT
- CSmil1DocumentRenderer::seekTo(const char* pElementID)
- {
- HX_RESULT rc = HXR_OK;
- CSmil1Element* 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,
- // 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
- CSmil1DocumentRenderer::resizeRegion(const char* pRegionName,
- HXxSize* pNewSize)
- {
- CSmil1BasicRegion* pRegion = getRegion(pRegionName);
- if(pRegion)
- {
- pRegion->m_rect.right = pRegion->m_rect.left + pNewSize->cx;
- pRegion->m_rect.bottom = pRegion->m_rect.top + pNewSize->cy;
- }
- }
- void
- CSmil1DocumentRenderer::repositionRegion(const char* pRegionName,
- HXxPoint* pNewPosition)
- {
- CSmil1BasicRegion* pRegion = getRegion(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;
- }
- }
- /*
- * IHXValues methods
- */
- STDMETHODIMP
- CSmil1DocumentRenderer::GetPropertyULONG32 (
- const char* pPropertyName,
- REF(ULONG32) uPropertyValue)
- {
- return m_pValues->GetPropertyULONG32(pPropertyName, uPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetPropertyCString (
- const char* pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetPropertyCString(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::SetPropertyULONG32 (
- const char* pPropertyName,
- ULONG32 uPropertyValue)
- {
- return m_pValues->SetPropertyULONG32(pPropertyName, uPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetFirstPropertyULONG32 (
- REF(const char*) pPropertyName,
- REF(ULONG32) uPropertyValue)
- {
- return m_pValues->GetFirstPropertyULONG32(pPropertyName, uPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetNextPropertyULONG32 (
- REF(const char*) pPropertyName,
- REF(ULONG32) uPropertyValue)
- {
- return m_pValues->GetNextPropertyULONG32(pPropertyName, uPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::SetPropertyBuffer (
- const char* pPropertyName,
- IHXBuffer* pPropertyValue)
- {
- return m_pValues->SetPropertyBuffer(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetPropertyBuffer (
- const char* pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetPropertyBuffer(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetFirstPropertyBuffer (
- REF(const char*) pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetFirstPropertyBuffer(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetNextPropertyBuffer (
- REF(const char*) pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetNextPropertyBuffer(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::SetPropertyCString (
- const char* pPropertyName,
- IHXBuffer* pPropertyValue)
- {
- return m_pValues->SetPropertyCString(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetFirstPropertyCString (
- REF(const char*) pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetFirstPropertyCString(pPropertyName, pPropertyValue);
- }
- STDMETHODIMP
- CSmil1DocumentRenderer::GetNextPropertyCString (
- REF(const char*) pPropertyName,
- REF(IHXBuffer*) pPropertyValue)
- {
- return m_pValues->GetNextPropertyCString(pPropertyName, pPropertyValue);
- }
- HX_RESULT
- CSmil1DocumentRenderer::GetElementProperties(UINT16 uGroupID,
- UINT16 uTrackID,
- REF(IHXValues*) pProperties)
- {
- HX_RESULT rc = HXR_OK;
- ElementWithinTag elementWithinTag = WithinUnknown;
- SMIL1PlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupID,
- uTrackID);
- if(pPlayToAssoc)
- {
- elementWithinTag = m_pSmilParser->GetElementWithin(pPlayToAssoc->m_id);
- }
- pProperties = new CHXHeader();
- pProperties->AddRef();
- pProperties->SetPropertyULONG32("ElementWithinTag", elementWithinTag);
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::GetElementStatus(UINT16 uGroupID,
- UINT16 uTrackID,
- UINT32 ulCurrentTime,
- REF(IHXValues*) pStatus)
- {
- HX_RESULT rc = HXR_OK;
- CHXSimpleList* pSiteInfoList = NULL;
- CSmil1Element* pElement = NULL;
- CSmil1ShowSiteEvent* pCurHideEvent = NULL;
- SMIL1PlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
- pStatus = NULL;
- if (pPlayToAssoc && pPlayToAssoc->m_pSiteInfoList)
- {
- pSiteInfoList = pPlayToAssoc->m_pSiteInfoList;
-
- LISTPOSITION pos = pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMIL1SiteInfo* pSiteInfo = (SMIL1SiteInfo*)pSiteInfoList->GetNext(pos);
- if (pSiteInfo)
- {
- pCurHideEvent = getShowHideEvent(pSiteInfo->m_pRegionSite,
- pSiteInfo->m_pRendererSite,
- FALSE);
- if (pCurHideEvent && pCurHideEvent->m_ulEventTime > ulCurrentTime)
- {
- pStatus = new CHXHeader();
- pStatus->AddRef();
- pStatus->SetPropertyULONG32("Show", 1);
- break;
- }
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::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;
- CSmil1BasicRegion* pRegion = NULL;
- CHXSimpleList* pRendererList = NULL;
- SMIL1SourceInfo* pSourceInfo = NULL;
- SMIL1PlayToAssoc* 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();
- HX_ASSERT(HXR_OK == rc);
- }
- pPlayToAssoc = getPlayToAssoc(uGroupID, uTrackID);
- HX_ASSERT(pPlayToAssoc);
- pRegion = getRegion(pPlayToAssoc->m_playTo);
- if (!pRegion)
- {
- // phony one up
- HXxRect rect = {0, 0, 0, 0};
- pRegion = new CSmil1BasicRegion(pPlayToAssoc->m_playTo, rect, 0, "hidden", 0,
- FALSE, TRUE,
- //Default to TRUE for width unspecified and
- // height unspecified:
- TRUE, TRUE);
- (*m_pRegionMap)[pPlayToAssoc->m_playTo] = pRegion;
- }
- if (pStream && pProps)
- {
- pSourceInfo = new SMIL1SourceInfo;
- 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];
- pRendererList->AddTail(pSourceInfo);
- }
- else
- {
- pRendererList = (CHXSimpleList*)pPlayToAssoc->m_sourceMap[0];
- HX_ASSERT(pRendererList->GetCount() == 1);
- pSourceInfo = (SMIL1SourceInfo*)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))
- {
- CSmil1EventHook* pChildEventHook = NULL;
- // create event hook for playto
- pChildEventHook = new CSmil1EventHook(this,
- pPlayToAssoc->m_playTo, pChildTuner, FALSE);
- 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
- CSmil1Element* 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)
- {
- CSmil1AAnchorElement* pAnchor =
- (CSmil1AAnchorElement*)(*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);
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::DetachElementLayout(IUnknown* pLSG)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- HX_RESULT
- CSmil1DocumentRenderer::InitPersistent(UINT32 ulPersistentComponentID,
- UINT16 uPersistentGroupID,
- UINT16 uPersistentTrackID,
- IHXPersistentRenderer* pPersistentParent)
- {
- m_ulPersistentComponentID = ulPersistentComponentID;
- m_uPersistentGroupID = uPersistentGroupID;
- m_uPersistentTrackID = uPersistentTrackID;
- m_pPersistentParentRenderer = pPersistentParent;
- HX_ADDREF(m_pPersistentParentRenderer);
- return HXR_OK;
- }
- BOOL
- CSmil1DocumentRenderer::IsNestedMetaSupported(UINT16& uSupportedType)
- {
- BOOL bResult = TRUE;
- UINT32 ulParentPersistentVersion = 0;
- UINT32 ulParentPersistentMajorVersion = 0;
- UINT32 ulParentPersistentType = PersistentUnknown;
- IHXValues* pProperties = NULL;
- uSupportedType = 0;
- 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 PersistentRAM:
- // RP8 SS3 - limited SMIL in RAM support
- if (ulParentPersistentMajorVersion == 2)
- {
- m_bInRAM20 = TRUE;
- uSupportedType = 1;
- }
- // otherwise - fully nested meta support even though
- // the parent RAM is 1.0
- else
- {
- uSupportedType = 2;
- }
- break;
- case PersistentSMIL:
- if (ulParentPersistentMajorVersion == 1)
- {
- bResult = FALSE;
- }
- else
- {
- uSupportedType = 2;
- }
- break;
- default:
- break;
- }
- }
- HX_RELEASE(pProperties);
-
- return bResult;
- }
- void
- CSmil1DocumentRenderer::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;
- }
- /*
- * CSmil1SiteWatcher methods
- */
- CSmil1SiteWatcher::CSmil1SiteWatcher(CSmil1DocumentRenderer*
- pDoc, const char* pID, BOOL bIsChildSite):
- m_pDoc(pDoc),
- m_lRefCount(0),
- m_id(pID),
- m_bIsChildSite(bIsChildSite),
- m_pSite(0),
- m_bChangingSize(FALSE),
- m_bFirstSetSize(TRUE)
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "CON CSmil1SiteWatcher 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- if(m_pDoc)
- {
- m_pDoc->AddRef();
- }
- }
- CSmil1SiteWatcher::~CSmil1SiteWatcher()
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "DES CSmil1SiteWatcher 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- close();
- }
- HX_RESULT
- CSmil1SiteWatcher::close()
- {
- HX_RELEASE(m_pDoc);
- HX_RELEASE(m_pSite);
- return HXR_OK;
- }
- /*
- * IUnknown methods
- */
- STDMETHODIMP
- CSmil1SiteWatcher::QueryInterface(REFIID riid, void** ppvObj)
- {
- if(IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- else if(IsEqualIID(riid, IID_IHXSiteWatcher))
- {
- AddRef();
- *ppvObj = (IHXSiteWatcher*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32)
- CSmil1SiteWatcher::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmil1SiteWatcher::Release()
- {
- if(InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /*
- * IHXSiteWatcher methods
- */
- STDMETHODIMP
- CSmil1SiteWatcher::AttachSite(IHXSite* pSite)
- {
- m_pSite = pSite;
- if(m_pSite)
- {
- m_pSite->AddRef();
- }
- return HXR_OK;
- }
- STDMETHODIMP
- CSmil1SiteWatcher::DetachSite()
- {
- HX_RELEASE(m_pSite);
- return HXR_OK;
- }
- STDMETHODIMP
- CSmil1SiteWatcher::ChangingPosition(HXxPoint oldPos, REF(HXxPoint) newPos)
- {
- return HXR_OK;
- }
- STDMETHODIMP
- CSmil1SiteWatcher::ChangingSize(HXxSize oldSize, REF(HXxSize) newSize)
- {
- if(m_bChangingSize ||
- (newSize.cx == 0 &&
- newSize.cy == 0))
- {
- return HXR_OK; // don't change size
- }
- CSmil1BasicRegion* pRegion = m_pDoc->getRegion(m_id);
- if(pRegion)
- {
- BOOL bResizeRegion = FALSE;
- if(m_bIsChildSite)
- {
- INT32 lRegionWidth = HXxRECT_WIDTH(pRegion->m_rect);
- INT32 lRegionHeight = HXxRECT_HEIGHT(pRegion->m_rect);
- double xScaleFactor = 1.;
- double yScaleFactor = 1.;
- if (m_pDoc->m_topSiteOriginalSize.cx)
- {
- xScaleFactor = (double) m_pDoc->m_topSiteSize.cx/(double) m_pDoc->m_topSiteOriginalSize.cx;
- }
- if (m_pDoc->m_topSiteOriginalSize.cy)
- {
- yScaleFactor = (double) m_pDoc->m_topSiteSize.cy/(double) m_pDoc->m_topSiteOriginalSize.cy;
- }
- if(m_bFirstSetSize)
- {
- // Clear the flag
- m_bFirstSetSize = FALSE;
- pRegion->m_originalMediaSize.cx = newSize.cx;
- pRegion->m_originalMediaSize.cy = newSize.cy;
- if(pRegion->m_rect.right == pRegion->m_rect.left &&
- //[SMIL 1.0 Compliance] Helps fix PR 16542;
- // only do the following if width="0" or "0%"
- // was not explicitly requested. The fix for
- // PR 16542 is to treat unspecified dimension values
- // as such and not treat them as 0 (which is a valid
- // value and should not be treated as an unspecified
- // value).
- pRegion->m_bWidthUnspecified)
- {
- //[SMIL 1.0 compliance] Fixes PR 26038 (horizontal part
- // of the bug): don't reset the right value to the width
- // when the right value may include an offset as well.
- // Set the right value to the new width **plus the left
- // value**, i.e., no longer assume the left is zero:
- pRegion->m_rect.right =
- pRegion->m_rect.left + newSize.cx;
- pRegion->m_originalRect.right =
- pRegion->m_rect.left + newSize.cx;
- lRegionWidth = newSize.cx;
- //[SMIL 1.0 compliance] more of PR 26038 fix: make sure
- // to account for left offset in overall layout as well
- // since the width of the layout includes the offset since
- // it is a bounding box of all regions:
- if(m_pDoc->m_ulNoRootLayoutWidth <
- (UINT32)(pRegion->m_rect.right) )
- {
- //Only include this region if it is visible:
- if (pRegion->m_rect.right > 0L)
- {
- m_pDoc->m_ulNoRootLayoutWidth =
- pRegion->m_rect.right;
- }
- }
- //[SMIL 1.0 compliance] Fixes PR 27184:
- // Always resize region if no size was explicitly
- // specified for it (not just when the above if () is
- // entered) otherwise it won't show up:
- bResizeRegion = TRUE;
- }
- if(pRegion->m_rect.bottom == pRegion->m_rect.top &&
- //[SMIL 1.0 Compliance] Helps fix PR 16542;
- // only do the following if height="0" or "0%"
- // was not explicitly requested. The fix for
- // PR 16542 is to treat unspecified dimension values
- // as such and not treat them as 0 (which is a valid
- // value and should not be treated as an unspecified
- // value).
- pRegion->m_bHeightUnspecified)
- {
- //[SMIL 1.0 compliance] Fixes PR 26038 (vertical part
- // of the bug): don't reset the bottom value to the
- // height when the bottom value may include an offset as
- // well. Set the bottom value to the new height **plus
- // the top value**, i.e., no longer assume the top is
- // zero:
- pRegion->m_rect.bottom =
- pRegion->m_rect.top + newSize.cy;
- pRegion->m_originalRect.bottom =
- pRegion->m_rect.top + newSize.cy;
- lRegionHeight = newSize.cy;
- //[SMIL 1.0 compliance] more of PR 26038 fix: make sure
- // to account for left offset in overall layout as well
- // since the width of the layout includes the offset since
- // it is a bounding box of all regions:
- if(m_pDoc->m_ulNoRootLayoutHeight <
- (UINT32)(pRegion->m_rect.bottom) )
- {
- //Only include this region if it is visible:
- if (pRegion->m_rect.bottom > 0L)
- {
- m_pDoc->m_ulNoRootLayoutHeight =
- pRegion->m_rect.bottom;
- }
- }
- //[SMIL 1.0 compliance] Fixes PR 27184:
- // Always resize region if no size was explicitly
- // specified for it (not just when the above if () is
- // entered) otherwise it won't show up:
- bResizeRegion = TRUE;
- }
- pRegion->m_bMediaSizeSet = TRUE;
- }
- // check for fit, rescale if necessary
- if(pRegion->m_fit == "fill")
- {
- newSize.cx = lRegionWidth;
- newSize.cy = lRegionHeight;
- }
- else if(pRegion->m_fit == "meet")
- {
- // preserve aspect ratio, don't clip
- double dAspectRatio = 0.0;
- if(pRegion->m_originalMediaSize.cy)
- {
- dAspectRatio = (double)pRegion->m_originalMediaSize.cx /
- (double)pRegion->m_originalMediaSize.cy;
- }
- // first try to meet region width
- if(dAspectRatio > 0.0)
- {
- INT32 lTryHeight = (INT32)((double)lRegionWidth / dAspectRatio + 0.5);
- if(lTryHeight > lRegionHeight)
- {
- newSize.cx = (INT32)((double)lRegionHeight * dAspectRatio + 0.5);
- newSize.cy = lRegionHeight;
- }
- else
- {
- newSize.cx = lRegionWidth;
- newSize.cy = lTryHeight;
- }
- }
- }
- else if(pRegion->m_fit == "slice")
- {
- // preserve aspect ratio, OK to clip
- double dAspectRatio = 0.0;
- double dRegionAspectRatio = 0.0;
- if(pRegion->m_originalMediaSize.cy &&
- pRegion->m_originalMediaSize.cx &&
- lRegionHeight)
- {
- dAspectRatio = (double)pRegion->m_originalMediaSize.cx /
- (double)pRegion->m_originalMediaSize.cy;
- dRegionAspectRatio = (double)lRegionWidth/(double)lRegionHeight;
- }
- // fit to greater of region height or width
- if(dAspectRatio > 0.0)
- {
- if(dRegionAspectRatio > dAspectRatio)
- {
- // the region has a greater aspect ratio than the
- // media. Therefore we want to scale the media's
- // height, and set its width = the region's width...
- newSize.cx = lRegionWidth;
- // /First half of Fix for PR 35268: we want to scale
- // the media's height based on the region's width,
- // not on its height:
- newSize.cy = (INT32)((double)lRegionWidth /
- dAspectRatio + 0.5);
- }
- else
- {
- // set the height = regionHeight && scale the width
- newSize.cy = lRegionHeight;
- // /Other half of Fix for PR 35268: we want to scale
- // the media's width based on the region's height,
- // not on its width:
- newSize.cx = (INT32)((double)lRegionHeight *
- dAspectRatio + 0.5);
- }
- }
- }
- else if(pRegion->m_fit == "scroll")
- {
- // keep intrinsic size, draw scroll bars (some day!)
- newSize.cx = (INT32)((double)pRegion->m_originalMediaSize.cx *
- xScaleFactor + 0.5);
- newSize.cy = (INT32)((double)pRegion->m_originalMediaSize.cy *
- yScaleFactor + 0.5);
- IHXValues* pValues = NULL;
- if ( m_pSite->QueryInterface( IID_IHXValues, (void**) &pValues ) == HXR_OK )
- {
- pValues->SetPropertyULONG32("ScrollingSite", 1);
- }
- }
- else if(pRegion->m_fit == "hidden")
- {
- // keep intrinsic size
- newSize.cx = (INT32)((double)pRegion->m_originalMediaSize.cx *
- xScaleFactor + 0.5);
- newSize.cy = (INT32)((double)pRegion->m_originalMediaSize.cy *
- yScaleFactor + 0.5);
- }
- pRegion->m_mediaSize.cx = newSize.cx;
- pRegion->m_mediaSize.cy = newSize.cy;
- }
- else if(!m_pDoc->m_bSiteChangingSize)
- {
- newSize.cx = HXxRECT_WIDTH(pRegion->m_rect);
- newSize.cy = HXxRECT_HEIGHT(pRegion->m_rect);
- }
- if(bResizeRegion)
- {
- HXxSize size;
- size.cx = HXxRECT_WIDTH(pRegion->m_rect);
- size.cy = HXxRECT_HEIGHT(pRegion->m_rect);
- pRegion->m_pSite->SetSize(size);
- if (!m_pDoc->isRootLayoutWidthSet() ||
- !m_pDoc->isRootLayoutHeightSet())
- {
- m_pDoc->setTopLevelSiteSize();
- }
- }
- }
- // char szDbgStr[128];
- // DEBUGPRINTF(szDbgStr, "tmedia in region %s: ChangingSize((%ld,%ld),(%ld,%ld))n",
- // (const char*) m_id,
- // oldSize.cx, oldSize.cy, newSize.cx, newSize.cy);
- return HXR_OK;
- }
- /*
- * CSmil1EventHook methods
- */
- CSmil1EventHook::CSmil1EventHook(CSmil1DocumentRenderer* pDoc,
- const char* pRegionName,
- const char* pChannelName,
- BOOL bNoRegion):
- m_lRefCount(0),
- m_pDoc(pDoc),
- m_pRegionName(NULL),
- m_pChannelName(NULL),
- m_bNoRegion(bNoRegion),
- m_pSite(NULL),
- m_pSiteWatcher(NULL)
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "CON CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- HX_ASSERT(m_pDoc);
- HX_ASSERT(pRegionName);
- HX_ASSERT(pChannelName);
- m_pDoc->AddRef();
- m_pRegionName = new_string(pRegionName);
- m_pChannelName = new_string(pChannelName);
- }
- CSmil1EventHook::~CSmil1EventHook()
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "DES CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- m_pDoc->Release();
- delete[] m_pRegionName;
- delete[] m_pChannelName;
- }
- /*
- * IUnknown methods
- */
- STDMETHODIMP
- CSmil1EventHook::QueryInterface(REFIID riid, void** ppvObj)
- {
- if(IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- else if(IsEqualIID(riid, IID_IHXEventHook))
- {
- AddRef();
- *ppvObj = (IHXEventHook*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32)
- CSmil1EventHook::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmil1EventHook::Release()
- {
- if(InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- STDMETHODIMP
- CSmil1EventHook::HandleEvent(IHXSite* pSite, HXxEvent* pEvent)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pSite == pSite)
- {
- switch(pEvent->event)
- {
- case HX_MOUSE_MOVE:
- case HX_MOUSE_ENTER:
- case HX_MOUSE_LEAVE:
- {
- HXxPoint* mousePt = (HXxPoint*) pEvent->param1;
- if(HXR_OK == m_pDoc->handleMouseMove(
- pEvent->window,
- m_pRegionName,
- (INT16)mousePt->x,
- (INT16)mousePt->y))
- {
- pEvent->handled = TRUE;
- }
- }
- break;
- case HX_PRIMARY_BUTTON_UP:
- {
- HXxPoint* mousePt = (HXxPoint*) pEvent->param1;
- if(HXR_OK == m_pDoc->handleLButtonUp(
- m_pRegionName,
- (INT16)mousePt->x,
- (INT16)mousePt->y))
- {
- pEvent->handled = TRUE;
- }
- }
- break;
- #ifdef _WINDOWS
- case WM_SETCURSOR:
- {
- pEvent->handled = m_pDoc->handleSetCursor();
- }
- break;
- #endif
- default:
- break;
- }
- }
- return rc;
- }
- STDMETHODIMP
- CSmil1EventHook::SiteAdded(IHXSite* pSite)
- {
- HX_RESULT rc = HXR_OK;
- HX_ASSERT(pSite);
- m_pSite = pSite;
- m_pSite->AddRef();
- // add a passive site watcher to get
- // size and position updates
- m_pSiteWatcher =
- new CSmil1PassiveSiteWatcher(m_pDoc, m_pRegionName);
- m_pSiteWatcher->AddRef();
-
- IHXSite2* pSite2 = NULL;
- if(HXR_OK == m_pSite->QueryInterface(IID_IHXSite2, (void**)&pSite2))
- {
- pSite2->AddPassiveSiteWatcher(m_pSiteWatcher);
- pSite2->Release();
- }
- if(m_bNoRegion)
- {
- m_pDoc->addShowEvents(m_pRegionName, m_pSite);
- }
- return rc;
- }
- STDMETHODIMP
- CSmil1EventHook::SiteRemoved(IHXSite* pSite)
- {
- HX_RESULT rc = HXR_OK;
- HX_ASSERT(m_pSite == pSite);
- IHXSite2* pSite2 = NULL;
- if(m_pSite &&
- HXR_OK == m_pSite->QueryInterface(IID_IHXSite2, (void**)&pSite2))
- {
- pSite2->RemovePassiveSiteWatcher(m_pSiteWatcher);
- pSite2->Release();
- }
- HX_RELEASE(m_pSite);
- HX_RELEASE(m_pSiteWatcher);
- return rc;
- }
- /*
- * CSmil1PassiveSiteWatcher methods
- */
- CSmil1PassiveSiteWatcher::CSmil1PassiveSiteWatcher(CSmil1DocumentRenderer* pDoc,
- const char* pRegionName):
- m_lRefCount(0),
- m_pDoc(pDoc),
- m_pRegionName(NULL)
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "CON CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- HX_ASSERT(m_pDoc);
- HX_ASSERT(pRegionName);
- m_pDoc->AddRef();
- m_pRegionName = new_string(pRegionName);
- }
- CSmil1PassiveSiteWatcher::~CSmil1PassiveSiteWatcher()
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "DES CSmil1EventHook 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- HX_RELEASE(m_pDoc);
- delete[] m_pRegionName;
- }
- /*
- * IUnknown methods
- */
- STDMETHODIMP
- CSmil1PassiveSiteWatcher::QueryInterface(REFIID riid, void** ppvObj)
- {
- if(IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- else if(IsEqualIID(riid, IID_IHXPassiveSiteWatcher))
- {
- AddRef();
- *ppvObj = (IHXSiteWatcher*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32)
- CSmil1PassiveSiteWatcher::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmil1PassiveSiteWatcher::Release()
- {
- if(InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- STDMETHODIMP
- CSmil1PassiveSiteWatcher::PositionChanged(HXxPoint* pPoint)
- {
- // The passive watcher is only attached to renderer
- // sites, therefore we really don't want to resize
- // the region, the regions are scaled and sized
- // already.
- //m_pDoc->repositionRegion(m_pRegionName, pPoint);
- return HXR_OK;
- }
- STDMETHODIMP
- CSmil1PassiveSiteWatcher::SizeChanged(HXxSize* pSize)
- {
- // The passive watcher is only attached to renderer
- // sites, therefore we really don't want to resize
- // the region, the regions are scaled and sized
- // already.
- //m_pDoc->resizeRegion(m_pRegionName, pSize);
- return HXR_OK;
- }
- /*
- * CSmil1SiteUser methods
- */
- CSmil1SiteUser::CSmil1SiteUser(CSmil1DocumentRenderer* pDoc,
- HXxColor ulBGColor):
- m_lRefCount(0),
- m_pDoc(pDoc),
- m_ulBGColor(ulBGColor),
- m_pSite(NULL)
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "CON CSmil1SiteUser 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- HX_ASSERT(m_pDoc);
- m_pDoc->AddRef();
- }
- CSmil1SiteUser::~CSmil1SiteUser()
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "DES CSmil1SiteUser 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- HX_RELEASE(m_pSite);
- HX_RELEASE(m_pDoc);
- }
- /*
- * IUnknown methods
- */
- STDMETHODIMP
- CSmil1SiteUser::QueryInterface(REFIID riid, void** ppvObj)
- {
- if(IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- else if(IsEqualIID(riid, IID_IHXSiteUser))
- {
- AddRef();
- *ppvObj = (IHXSiteUser*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32)
- CSmil1SiteUser::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmil1SiteUser::Release()
- {
- if(InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /*
- * IHXSiteUser methods
- */
- STDMETHODIMP
- CSmil1SiteUser::AttachSite(IHXSite* /*IN*/ pSite)
- {
- HX_RESULT rc = HXR_OK;
- if (m_pSite)
- {
- return rc;
- }
- m_pSite = pSite;
- m_pSite->AddRef();
- return rc;
- }
- STDMETHODIMP
- CSmil1SiteUser::DetachSite()
- {
- HX_RELEASE(m_pSite);
- return HXR_OK;
- }
- STDMETHODIMP_(BOOL)
- CSmil1SiteUser::NeedsWindowedSites()
- {
- return FALSE;
- }
- STDMETHODIMP
- CSmil1SiteUser::HandleEvent(HXxEvent* /*IN*/ pEvent)
- {
- HX_RESULT rc = HXR_OK;
- pEvent->handled = FALSE;
- pEvent->result = 0;
- switch (pEvent->event)
- {
- case HX_SURFACE_UPDATE:
- {
- if(HXR_OK ==
- m_pDoc->HandleSurfaceUpdate(pEvent, m_pSite, m_ulBGColor))
- {
- pEvent->handled = TRUE;
- }
- }
- break;
- }
- return HXR_OK;
- }
- /*
- * CSmil1BasicRegion methods
- */
- CSmil1BasicRegion::CSmil1BasicRegion(const char* pName,
- HXxRect rect, INT32 lZIndex, const char* pFit,
- HXxColor ulBgColor, BOOL bBgColorSet, BOOL bImplicitRegion,
- //[SMIL 1.0 Compliance] Helps fix PR 16542:
- BOOL bWidthUnspecified, BOOL bHeightUnspecified):
- m_region(pName),
- m_rect(rect),
- m_originalRect(rect),
- m_pSite(NULL),
- m_pSiteUser(NULL),
- m_lZIndex(lZIndex),
- m_fit(pFit),
- m_ulBgColor(ulBgColor),
- m_bBgColorSet(bBgColorSet),
- m_bMediaSizeSet(FALSE),
- m_bImplicitRegion(bImplicitRegion)
- //[SMIL 1.0 Compliance] These helps fix PR 16542:
- , m_bWidthUnspecified(bWidthUnspecified)
- , m_bHeightUnspecified(bHeightUnspecified)
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "CON CSmil1BasicRegion 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- }
- CSmil1BasicRegion::~CSmil1BasicRegion()
- {
- #if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)
- char szDbgStr[128]; /* Flawfinder: ignore */
- sprintf(szDbgStr, "DES CSmil1BasicRegion 0x%08xn", this); /* Flawfinder: ignore */
- OutputDebugString(szDbgStr);
- #endif
- if(m_pSite)
- {
- m_pSite->DetachUser();
- }
- HX_RELEASE(m_pSiteUser);
- HX_RELEASE(m_pSite);
- }
- // ProcessElementCallback
- ProcessElementCallback::ProcessElementCallback() :
- m_lRefCount(0)
- ,m_pOwner(0)
- ,m_PendingHandle(0)
- ,m_bIsCallbackPending(FALSE)
- {
- }
- ProcessElementCallback::~ProcessElementCallback()
- {
- }
- /*
- * IUnknown methods
- */
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::QueryInterface
- // Purpose:
- // Implement this to export the interfaces supported by your
- // object.
- //
- STDMETHODIMP ProcessElementCallback::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IHXCallback))
- {
- AddRef();
- *ppvObj = (IHXCallback*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::AddRef
- // Purpose:
- // Everyone usually implements this the same... feel free to use
- // this implementation.
- //
- STDMETHODIMP_(ULONG32) ProcessElementCallback::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::Release
- // Purpose:
- // Everyone usually implements this the same... feel free to use
- // this implementation.
- //
- STDMETHODIMP_(ULONG32) ProcessElementCallback::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /*
- * IHXCallback methods
- */
- STDMETHODIMP ProcessElementCallback::Func(void)
- {
- m_PendingHandle = 0;
- m_bIsCallbackPending = FALSE;
- if (m_pOwner && !m_elementID.IsEmpty())
- {
- m_pOwner->seekTo(m_elementID);
- }
- m_elementID.Empty();
- return HXR_OK;
- }