⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sitemgr.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	hresFinal = hresTemp;
	goto exit;
    }

    /*
     * let's see if this is a persistent site...
     */
    hresTemp = pProps->GetPropertyCString("Persistent",pValue);
    if(HXR_OK == hresTemp)
    {
	bIsPersistent = TRUE;
	HX_RELEASE(pValue);
    }

    /*
     * Now let's determine if it's by LSGName or by playtofrom.
     * If one of these is not available then barf up an error.
     */

    /*
     * If the "LayoutGroup" property exists than this is 
     * a site for layout groups by LSGName.
     */
    hresTemp = pProps->GetPropertyCString("LayoutGroup",pValue);
    if (HXR_OK == hresTemp)
    {
	pActualString = (char*)pValue->GetBuffer();
	if(bIsPersistent)
	{
	    hresFinal = AddSiteByStringHelper(pActualString, pSite, m_PersistentLSGNamesToLists);
	}
	else
	{
	    hresFinal = AddSiteByStringHelper(pActualString, pSite, m_LSGNamesToLists);
	}
	goto exit;
    }

    /*
     * If the "channel" property exists than this is 
     * a site for renderers playing to a channel.
     */
    hresTemp = pProps->GetPropertyCString("channel",pValue);
    if (HXR_OK == hresTemp)
    {
	pActualString = (char*)pValue->GetBuffer();
	if(bIsPersistent)
	{
	    hresFinal = AddSiteByStringHelper(pActualString, pSite, m_PersistentChannelsToLists);
	}
	else
	{
	    hresFinal = AddSiteByStringHelper(pActualString, pSite, m_ChannelsToLists);
	}
	goto exit;
    }

#if 0 ////// NOT YET SUPPORTED ////////
    /*
     * If the "playfrom" property exists than this is 
     * a site for renderers playing from a source/stream combo.
     * Notice that more properties than just "playfrom" are needed
     * to do the actual hookup so we pass the properties in as well.
     */
    hresTemp = pProps->GetPropertyCString("playfrom",pValue);
    if (HXR_OK == hresTemp)
    {
	hresFinal = AddSiteByPlayFrom(pProperties,pSite);
	goto exit;
    }
#endif

exit:
    /*
     * Cleanup any temporary objects....
     */
    HX_RELEASE(pProps);
    HX_RELEASE(pValue);

    // hookup any leftover orphan value/sites (pending)...

    // first process the LSG list	       
    HookupHelper(&m_PendingValueToSULSG, pActualString, bIsPersistent, 
                 SITE_USER_SUPPLIER, HOOKUP_BY_LSGNAMEWITHSTRING);

    // next process the Single LSG list
    HookupHelper(&m_PendingValueToSUSingleLSG, pActualString, bIsPersistent, 
                 SITE_USER, HOOKUP_SINGLESITE_BY_LSGNAMEWITHSTRING);
    
    // next process play to list
    HookupHelper(&m_PendingValueToSUPlayTo, pActualString, bIsPersistent, 
                 SITE_USER_SUPPLIER, HOOKUP_BY_PLAYTOFROMWITHSTRING);

    // next process the Single LSG list
    HookupHelper(&m_PendingValueToSUSinglePlayTo, pActualString, bIsPersistent, 
                 SITE_USER, HOOKUP_SINGLESITE_BY_PLAYTOFROMWITHSTRING);

#ifdef _WINDOWS
    if (m_bNeedFocus && pSite)
    {
	IHXSiteWindowless* pWindowLess = NULL;
	IHXSiteWindowed*   pWindowed	= NULL;

	pSite->QueryInterface(IID_IHXSiteWindowless, (void**) &pWindowLess);
	if (pWindowLess)
	{
	    pWindowLess->QueryInterface(IID_IHXSiteWindowed, (void**) &pWindowed);
	}

	if (pWindowed)
	{
	    HXxWindow* pWindow = pWindowed->GetWindow();
	    if (pWindow && pWindow->window)
	    {
		// same logic exists in pnvideo/win/winsite.cpp: _SetFocus()
		HWND hTmp = ::GetForegroundWindow();
		if( ::IsChild(hTmp, (HWND)pWindow->window ))
		{
		    ::SetFocus((HWND)pWindow->window);
		}
	    }
	}

	HX_RELEASE(pWindowLess);
	HX_RELEASE(pWindowed);
    }
#endif

    return hresFinal;
}

/************************************************************************
 *  Method:`
 *    IHXSiteManager::RemoveSite
 */
STDMETHODIMP 
CHXSiteManager::RemoveSite(IHXSite* pSite)
{
    void*	    pVoid	    = NULL;
    CHXMapPtrToPtr* pSiteCollection = NULL;
    IHXValues*	    pProps	    = NULL;
    IHXBuffer*	    pValue	    = NULL;
    BOOL	    bIsPersistent   = FALSE;
    const char*	    pChannelName    = NULL;

    /*
     * This site must have been previously added and therefore
     * should be in the master list of sites.
     */
    if (!m_MasterListOfSites.Lookup(pSite,pVoid)) 
    {
	return HXR_INVALID_PARAMETER;
    }

    /*
     * determine whether the site is persistent, and get the name of
     * the site so it can be removed from the channel list
     */
    if(HXR_OK == pSite->QueryInterface(IID_IHXValues,(void**)&pProps))
    {
	if(HXR_OK == pProps->GetPropertyCString("Persistent", pValue))
	{
	    bIsPersistent = TRUE;
	    HX_RELEASE(pValue);
	}
	HX_RELEASE(pProps);
    }

    /*
     *
     */

    /* If we are unhooking all sites, we do not want to unhook site here */
    if (!m_bInUnHookAll)
    {
	UnhookSite(pSite, bIsPersistent);
    }

    /*
     * We need to remove the site from whatever collection of
     * sites it is in. This means we are removing it from the
     * collection of sites for it's LSGName if that is how it
     * was added. Instead of determining the properties supported
     * by the site to determine which collection to remove it from
     * we stored the site collection in our master list. Cool, eh?
     */
    pSiteCollection = (CHXMapPtrToPtr*)pVoid;
    HX_ASSERT(pSiteCollection->Lookup(pSite,pVoid));
    pSiteCollection->RemoveKey(pSite);

    /*
     * Of course we also need to remove it from the master site
     * list as well.
     */
    m_MasterListOfSites.RemoveKey(pSite);

    return HXR_OK;
}


STDMETHODIMP
CHXSiteManager::AddEventHookElement
(
    CHXSimpleList*	    pList,
    CHXEventHookElement*    pHookElement
)
{
    // insert element into pList
    // in region/uLayer order (greater uLayer
    // before lesser uLayer)

    HX_RESULT rc = HXR_OK;

    BOOL bInserted = FALSE;

    LISTPOSITION pos = pList->GetHeadPosition();
    while(pos)
    {
	CHXEventHookElement* pElement = 
	    (CHXEventHookElement*)pList->GetAt(pos);
	if(pElement->m_uLayer <= pHookElement->m_uLayer)
	{
	    pList->InsertBefore(pos, pHookElement);
	    bInserted = TRUE;
	    break;
	}
	pList->GetNext(pos);
    }
    if(!bInserted)
    {
	pList->AddTail(pHookElement);
    }

    return rc;
}

STDMETHODIMP
CHXSiteManager::RemoveEventHookElement
(
    CHXSimpleList* pList,
    IHXEventHook* pHook,
    UINT16 uLayer
)
{
    HX_RESULT rc = HXR_OK;

    LISTPOSITION pos = pList->GetHeadPosition();
    while(pos)
    {
	CHXEventHookElement* pThisElement = 
	    (CHXEventHookElement*)pList->GetAt(pos);
	if(pHook == pThisElement->m_pHook && 
	   uLayer == pThisElement->m_uLayer)
	{
	    delete pThisElement;
	    pList->RemoveAt(pos);
	    break;
	}
	pList->GetNext(pos);
    }
    return rc;
}

/************************************************************************
 *  Method:
 *    IHXEventHookMgr::AddHook
 */
STDMETHODIMP 
CHXSiteManager::AddHook
(
    IHXEventHook* 	pHook,
    const char* 	pRegionName,
    UINT16 		uLayer
)
{
    HX_RESULT rc = HXR_OK;

    CHXEventHookElement* pElement = 
	new CHXEventHookElement(pHook, uLayer);

    if(pRegionName && strlen(pRegionName) > 0)
    {
	CHXSimpleList* pList = NULL;
	if (!m_EventHookMap.Lookup(pRegionName, (void*&)pList))
	{
	    pList = new CHXSimpleList;
	    m_EventHookMap[pRegionName] = pList;
	}
	rc = AddEventHookElement(pList, pElement);
    }
    else
    {
	rc = AddEventHookElement(&m_UnnamedEventHookList, pElement);
    }

    return rc;
}

/************************************************************************
 *  Method:
 *    IHXEventHookMgr::RemoveHook
 */
STDMETHODIMP 
CHXSiteManager::RemoveHook
(
    IHXEventHook* 	pHook,
    const char* 	pRegionName,
    UINT16 		uLayer
)
{
    HX_RESULT rc = HXR_OK;

    if(pRegionName && strlen(pRegionName) > 0)
    {
	CHXSimpleList* pList = NULL;
	if (m_EventHookMap.Lookup(pRegionName, (void*&)pList))
	{
	    rc = RemoveEventHookElement(pList, pHook, uLayer);
	}
    }
    else
    {
	rc = RemoveEventHookElement(&m_UnnamedEventHookList, pHook, uLayer);
    }

    return rc;
}

STDMETHODIMP CHXSiteManager::GetNumberOfSites(REF(UINT32) nNumSites )
{
    nNumSites = m_MasterListOfSites.GetCount();
    return HXR_OK;
}

STDMETHODIMP CHXSiteManager::GetSiteAt(UINT32 nIndex, REF(IHXSite*) pSite)
{
    if (!m_MasterListOfSites.GetCount())
    {
        return HXR_FAIL;
    }
    
    POSITION pos = m_MasterListOfSites.GetStartPosition();
    void*   pValue;

    for (UINT32 i = 0; i<=nIndex; i++)
    {
        m_MasterListOfSites.GetNextAssoc(pos, (void*&)pSite, pValue);
    }
    return HXR_OK;
}

/************************************************************************
*	Method:
*	    CHXSiteManager::HandleHookedEvent
*	Purpose:
*	  Pass the event to interested parties
*/
HX_RESULT
CHXSiteManager::HandleHookedEvent
(
    const char* pRegionName,
    IHXSite* pSite,
    HXxEvent* pEvent
)
{
    return HandleSiteEvent(pRegionName, pSite, pEvent, SITE_EVENT_GENERAL);
}

/************************************************************************
*	Method:
*	    CHXSiteManager::HookedSiteAdded
*	Purpose:
*	  Let hooks know about the added site
*/
void
CHXSiteManager::HookedSiteAdded
(
    const char* pRegionName,
    IHXSite* pSite
)
{
    HandleSiteEvent(pRegionName, pSite, NULL, SITE_EVENT_ADDED);
}

/************************************************************************
*	Method:
*	    CHXSiteManager::HookedSiteRemoved
*	Purpose:
*	  Let hooks know about the removed site
*/
void
CHXSiteManager::HookedSiteRemoved
(
    const char* pRegionName,
    IHXSite* pSite
)
{
    HandleSiteEvent(pRegionName, pSite, NULL, SITE_EVENT_REMOVED);
}

/************************************************************************
*	Method:
*	    CHXSiteManager::IsSitePresent
*	Purpose:
*	  
*/
BOOL
CHXSiteManager::IsSitePresent
(
    IHXSite*		    pSite
)
{
    void*   pVoid = NULL;
    return m_MasterListOfSites.Lookup(pSite,pVoid);
}

void 
CHXSiteManager::NeedFocus(BOOL bNeedFocus)
{
    m_bNeedFocus = bNeedFocus;
}

/************************************************************************
 *  Method:
 *    IHXSiteManager::IsSiteAvailableByStringHelper
 */
BOOL
CHXSiteManager::IsSiteAvailableByStringHelper
(
    const char*		pString,
    CHXMapStringToOb&	ByStringMap
)
{
    BOOL	    bAvailable	    = FALSE;
    void*	    pVoid	    = NULL;
    CHXMapPtrToPtr* pSiteCollection = NULL;

    /*
     * The basic data structure is as follows: A map is kept 
     * from names to "lists" of sites. We don't actually use
     * a list because we want to quickly detect if the item is
     * already in the list so we use a map for the sites as well.
     */

    /*
     * Find the list in the name to list map, if there is no
     * list in the map then we know it is surely not available.
     */
    if (!ByStringMap.Lookup(pString,pVoid))
    {
	bAvailable = FALSE;
	goto exit;
    }

    pSiteCollection = (CHXMapPtrToPtr*)pVoid;

    /*
     * Now that we have the collection of sites we want to see
     * if there are any items in the collection. The collection
     * may exist with no items in it.
     */
    if (pSiteCollection->IsEmpty())
    {
	bAvailable = FALSE;
	goto exit;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -