📄 minisite.cpp
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#include "minisite.h"
#include "hxvsurf.h"
#include "hxtick.h"
#include "minisurf.h"
CMiniBaseSite::CMiniBaseSite(IUnknown* pContext,
IUnknown* pUnkOuter,
INT32 lZorder)
: m_pContext(pContext),
m_pCCF(NULL),
m_pUser(NULL),
m_pWatcher(NULL),
m_pValues(NULL),
m_pVideoSurface(NULL),
m_pWindow(NULL),
m_lRefCount(0),
m_lZOrder(lZorder),
#if defined (HELIX_FEATURE_SMIL_SITE)
m_pTopLevelSite(NULL),
m_pParentSite(NULL),
m_Region(NULL),
m_RegionWithoutChildren(NULL),
m_bIsVisible(TRUE),
m_CallbackHandle(0),
m_pScheduler(NULL),
m_bfCallBacks(0),
m_ulCallbackTime(0),
#endif
m_bWindowCreatedByCreate(FALSE)
{
memset(&m_size, 0, sizeof(m_size));
memset(&m_position , 0, sizeof(m_position ));
#if defined (HELIX_FEATURE_SMIL_SITE)
m_pTopLevelSite = this;
memset(&m_topleft , 0, sizeof(m_topleft ));
memset(&m_TopLevelWindow , 0, sizeof(m_TopLevelWindow ));
if( m_pContext )
{
m_pContext->QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler);
}
HX_ASSERT(m_pScheduler);
#endif
if(m_pContext)
{
m_pContext->AddRef();
// get the CCF
m_pContext->QueryInterface(IID_IHXCommonClassFactory,
(void**)&m_pCCF);
if( m_pCCF )
{
m_pCCF->CreateInstance(CLSID_IHXValues, (void**)&m_pValues);
}
}
m_pVideoSurface = CMiniBaseSurface::Create(m_pContext, this);
m_pVideoSurface->AddRef();
}
CMiniBaseSite::~CMiniBaseSite()
{
// release intefaces
HX_RELEASE(m_pValues);
HX_RELEASE(m_pCCF);
HX_RELEASE(m_pContext);
HX_RELEASE(m_pVideoSurface);
#if defined(HELIX_FEATURE_SMIL_SITE)
if( m_CallbackHandle )
{
if( m_pScheduler)
m_pScheduler->Remove(m_CallbackHandle);
m_CallbackHandle = 0;
}
HX_RELEASE(m_pScheduler);
m_ChildrenInZOrder.RemoveAll();
//clean up passive site watchers
while(m_PassiveSiteWatchers.GetCount())
{
IHXPassiveSiteWatcher* pWatcher =
(IHXPassiveSiteWatcher*)m_PassiveSiteWatchers.GetHead();
HX_RELEASE(pWatcher);
m_PassiveSiteWatchers.RemoveHead();
}
#endif
}
/************************************************************************
* Method:
* IUnknown::QueryInterface
*/
STDMETHODIMP CMiniBaseSite::QueryInterface(REFIID riid, void** ppvObj)
{
if(IsEqualIID(riid, IID_IUnknown))
{
*ppvObj = (IUnknown*)(IHXSite*)this;
}
else if (IsEqualIID(riid, IID_IHXSite))
{
*ppvObj = (IHXSite*)this;
}
#if defined (HELIX_FEATURE_SMIL_SITE)
else if (IsEqualIID(riid, IID_IHXSite2))
{
*ppvObj = (IHXSite2*)this;
}
else if (IsEqualIID(riid, IID_IHXSiteControl))
{
*ppvObj = (IHXSiteControl*)this;
}
#endif //HELIX_FEATURE_SMIL_SITE
else if (IsEqualIID(riid, IID_IHXSiteWindowed))
{
*ppvObj = (IHXSiteWindowed*)this;
}
else if (m_pValues &&
m_pValues->QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
else
{
*ppvObj = NULL;
return HXR_NOINTERFACE;
}
AddRef();
return HXR_OK;
}
/************************************************************************
* Method:
* IUnknown::AddRef
*/
STDMETHODIMP_(ULONG32) CMiniBaseSite::AddRef()
{
return InterlockedIncrement(&m_lRefCount);
}
/************************************************************************
* Method:
* IUnknown::Release
*/
STDMETHODIMP_(ULONG32) CMiniBaseSite::Release()
{
if (InterlockedDecrement(&m_lRefCount) > 0)
{
return m_lRefCount;
}
delete this;
return 0;
}
/************************************************************************
* Method:
* CMiniBaseSite::AttachWindow
*/
STDMETHODIMP CMiniBaseSite::AttachWindow(HXxWindow* pWindow)
{
if (m_pWindow && m_pWindow->window)
return HXR_UNEXPECTED;
m_pWindow = pWindow;
#if defined(HELIX_FEATURE_SMIL_SITE)
if (!m_pParentSite)
{
memcpy(&m_TopLevelWindow,
pWindow,
sizeof(HXxWindow)); /* Flawfinder: ignore */
}
#endif
_AttachWindow();
if (m_pUser)
{
// send HX_ATTACH_WINDOW msg to the renderers
void * lpParam1 = NULL;
void * lpParam2 = NULL;
HXxEvent event = {HX_ATTACH_WINDOW,
m_pWindow ? m_pWindow->window : NULL,
lpParam1, lpParam2,
0, 0 };
m_pUser->HandleEvent(&event);
}
return HXR_OK;
}
/************************************************************************
* Method:
* IHXSiteWindowed::DetachWindow
*/
STDMETHODIMP CMiniBaseSite::DetachWindow()
{
if (!m_pWindow || !m_pWindow->window)
return HXR_UNEXPECTED;
if (m_pUser)
{
// send HX_DETACH_WINDOW msg to the renderers
void * lpParam1 = NULL;
void * lpParam2 = NULL;
HXxEvent event = {HX_DETACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
m_pUser->HandleEvent(&event);
}
// let the OS specific site do its cleanup.
_DetachWindow();
m_pWindow = NULL;
#if defined(HELIX_FEATURE_SMIL_SITE)
if (m_pTopLevelSite == this)
{
if (m_CallbackHandle)
{
if( m_pScheduler )
m_pScheduler->Remove(m_CallbackHandle);
m_CallbackHandle = 0;
}
}
#endif
return HXR_OK;
}
/************************************************************************
* Method:
* IHXSiteWindowed::Create
*/
STDMETHODIMP CMiniBaseSite::Create(void* ParentWindow, UINT32 style)
{
HRESULT retVal = HXR_OK;
if( m_pWindow && m_pWindow->window )
{
//We already have one.
return HXR_FAIL;
}
void* hWnd = _Create(ParentWindow, style);
if (!hWnd)
{
retVal = HXR_FAIL;
}
else
{
HXxWindow* pWindow = new HXxWindow;
memset(pWindow,0,sizeof(HXxWindow));
pWindow->window = hWnd;
//This flags tells us if Create was used to make the window
//or not. We use this in SetSize and SetPosition so that we
//never resize or move the TLCs window. But, in TLC that call
//create, like testplay, we need to do the move and resize
//for them.
m_bWindowCreatedByCreate = TRUE;
//This way we always pass through attach window.
AttachWindow(pWindow);
}
return retVal;
}
/************************************************************************
* Method:
* IHXSiteWindowed::Destroy
*/
STDMETHODIMP CMiniBaseSite::Destroy()
{
//This could be the site that owns the overlay even though
//it doesn't have a window. Give it a chance to clean up
//here...
if( m_pVideoSurface )
{
m_pVideoSurface->EndOptimizedBlt();
}
if(!m_pWindow || !m_pWindow->window)
{
return HXR_UNEXPECTED;
}
HXxWindow tempWindow;
memcpy( &tempWindow, m_pWindow, sizeof( HXxWindow ) ); /* Flawfinder: ignore */
DetachWindow();
_Destroy(&tempWindow);
m_pWindow = NULL;
return HXR_OK;
}
STDMETHODIMP_(HXxWindow*) CMiniBaseSite::GetWindow()
{
HXxWindow* pRet = m_pWindow;
#if defined(HELIX_FEATURE_SMIL_SITE)
if( m_pTopLevelSite != this && m_pParentSite )
pRet = m_pParentSite->GetWindow();
#endif
return pRet;
}
/************************************************************************
* Method:
* IHXSite::AttachUser
*/
STDMETHODIMP CMiniBaseSite::AttachUser(IHXSiteUser* /*IN*/ pUser)
{
if (m_pUser)
return HXR_UNEXPECTED;
m_pUser = pUser;
m_pUser->AddRef();
m_pUser->AttachSite(this);
/*if (m_bAttachWindowPending)
{
m_bAttachWindowPending = FALSE;
m_bDetachWndMsgPending = TRUE;
// send HX_ATTACH_WINDOW msg to the renderers
void * lpParam1 = NULL;
void * lpParam2 = NULL;
HXxEvent event = {HX_ATTACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
m_pUser->HandleEvent(&event);
}*/
return HXR_OK;
}
/************************************************************************
* Method:
* IHXSite::DetachUser
*/
STDMETHODIMP CMiniBaseSite::DetachUser()
{
if (!m_pUser)
return HXR_UNEXPECTED;
#if defined(HELIX_FEATURE_SMIL_SITE)
if (m_CallbackHandle)
{
if( m_pScheduler)
m_pScheduler->Remove(m_CallbackHandle);
m_CallbackHandle = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -