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

📄 smlrendr.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* ***** 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 ***** */ 

#if defined (_AIX)
#include <X11/Xlib.h>
#endif
// system
#include <time.h>
// include
#include "hxtypes.h"
#include "hxwintyp.h"
#include "smiltype.h"
#include "hxcom.h"
#include "hxcomm.h"
#include "ihxpckts.h"
#include "hxcore.h"
#include "hxrendr.h"
#include "hxplugn.h"
#include "hxwin.h"
#include "hxgroup.h"
#include "hxsite2.h"
#include "hxupgrd.h"
#include "hxmon.h"
#include "hxver.h"
#include "hxvport.h"
#include "hxclsnk.h"
#include "hxprefs.h"
#include "hxmmrkr.h" // smldoc.h   dependency
#include "hxinter.h" // smldoc.h   dependency
#include "hxsm2sm.h"
#include "hxerror.h"
// cont
#include "hxstring.h"
#include "chxpckts.h"
#include "smlpkt.h"
// misc
#include "hxurl.h"
#include "hxstrutl.h" /* for SafeS---() */
#include "smlelem.h"
#include "smlutil.h"
// smlrendr
#include "evnthook.h"
#include "siteuser.h"
#include "passivsw.h"
#include "layout.h"
#include "smldoc.h"
#include "smlerror.h"
#include "smlrmlog.h"
#include "smlrendr.h"
#include "smlrendr.ver"
// debug
#include "debugout.h"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE		
static const char HX_THIS_FILE[] = __FILE__;
#endif

/* We should really define it in a common header file */
#if defined (_WINDOWS ) || defined (WIN32)
#define OS_SEPARATOR_CHAR	'\\'
#define OS_SEPARATOR_STRING	"\\"
#elif defined (_UNIX)
#define OS_SEPARATOR_CHAR	'/'
#define OS_SEPARATOR_STRING	"/"
#elif defined (_MACINTOSH)
#define OS_SEPARATOR_CHAR	':'
#define OS_SEPARATOR_STRING	":"
#endif // defined (_WINDOWS ) || defined (WIN32)


#ifdef _WINDOWS
extern HINSTANCE g_hInstance;
#endif

static const UINT32 INITIAL_GRANULARITY = 67; // XXXMEH - increased interval to help animation CPU

#define SMIL20_AND_UP_STREAM_MIME_TYPE "application/smil"

const char* const CSmilRenderer::zm_pName	      = "SMIL";
const char* const CSmilRenderer::zm_pDescription    = "RealNetworks RMA Driver Renderer Plugin";
const char* const CSmilRenderer::zm_pCopyright      = HXVER_COPYRIGHT;
const char* const CSmilRenderer::zm_pMoreInfoURL    = HXVER_MOREINFO;
const char* const CSmilRenderer::zm_pStreamMimeTypes[] =
{
#if defined(HANDLE_BETA1_SMIL_1_0_STREAM)
    "application/rma-driver",
#endif
#if defined(HANDLE_SMIL_1_0_STREAM)
    "application/vnd.rn-rmadriver",
#endif
#if defined(HANDLE_SMIL_2_0_LASTCALL_STREAM)
    SMIL20_AND_UP_STREAM_MIME_TYPE,
#endif
#if defined(HANDLE_SMIL_2_0_CANDIDATE_REC_STREAM)
    SMIL20_AND_UP_STREAM_MIME_TYPE,
#endif
#if defined(HANDLE_SMIL_2_0_STREAM)
    SMIL20_AND_UP_STREAM_MIME_TYPE,
#endif
    NULL
};
const char* const CSmilRenderer::zm_pRecognizedDefaultNamespaces[
	NUM_RECOGNIZED_DEFAULT_NAMESPACES+1] =
{
    // /This is the namespace in the <smil...> tag that declares that
    // this is a SMIL 1.0 document that we should handle *correctly* (per
    // spec); the SMIL file format plug-in would have sent any "old"
    // SMIL 1.0 document to the old SMIL 1.0 renderer via the old stream
    // mime type; this is the case for all files that do not contain
    // a default namespace (which is xmlns= as opposed to xmlns:):
    "http://www.w3.org/TR/REC-smil",
    // /This is the SMIL 2.0 Last Call namespace:
    "http://www.w3.org/TR/REC-smil/2000/SMIL20/LC/",
    // /This is the SMIL 2.0 Language Profile Candidate Rec namespace:
    "http://www.w3.org/2000/SMIL20/CR/Language",
    // /This is the SMIL 2.0 Language Profile Proposed Rec namespace
    // created June 2001:  (Fixes PR 55749):
    "http://www.w3.org/2001/SMIL20/PR/Language",
    // /This is the SMIL 2.0 Rec namespace (it became a W3C Rec on 8/7/2001):
#if defined(HANDLE_SMIL_2_0_STREAM)
    // /Adding "/Language" to this string fixes PR 62208:
    "http://www.w3.org/2001/SMIL20/Language",
#endif
    NULL
};



/************************************************************************
 *  Method:
 *    IHXPlugin::InitPlugin
 *  Purpose:
 *    Initializes the plugin for use. This interface must always be
 *    called before any other method is called. This is primarily needed 
 *    so that the plugin can have access to the context for creation of
 *    IHXBuffers and IMalloc.
 */
STDMETHODIMP CSmilRenderer::InitPlugin(IUnknown* /*IN*/ pContext)
{
    m_pContext = pContext;
    m_pContext->AddRef();

    m_pContext->QueryInterface(IID_IHXCommonClassFactory,
	    (void**)&m_pCommonClassFactory);
    HX_RELEASE(m_pErrorMessages);
    m_pContext->QueryInterface(IID_IHXErrorMessages,
                               (void**) &m_pErrorMessages);

    return HXR_OK;
}

/************************************************************************
 *  Method:
 *    IHXPlugin::GetPluginInfo
 *  Purpose:
 *    Returns the basic information about this plugin. Including:
 *
 *    bLoadMultiple	whether or not this plugin DLL can be loaded
 *			multiple times. All File Formats must set
 *			this value to TRUE.
 *    pDescription	which is used in about UIs (can be NULL)
 *    pCopyright	which is used in about UIs (can be NULL)
 *    pMoreInfoURL	which is used in about UIs (can be NULL)
 */
STDMETHODIMP CSmilRenderer::GetPluginInfo
(
    REF(BOOL)        /*OUT*/ bLoadMultiple,
    REF(const char*) /*OUT*/ pDescription,
    REF(const char*) /*OUT*/ pCopyright,
    REF(const char*) /*OUT*/ pMoreInfoURL,
    REF(ULONG32)     /*OUT*/ ulVersionNumber
)
{
    bLoadMultiple = TRUE;   // Must be true for file formats.

    pDescription    = (const char*) zm_pDescription;
    pCopyright	    = (const char*) zm_pCopyright;
    pMoreInfoURL    = (const char*) zm_pMoreInfoURL;
    ulVersionNumber = TARVER_ULONG32_VERSION;

    return HXR_OK;
}

/************************************************************************
 *  Method:
 *    IHXPlugin::GetRendererInfo
 *  Purpose:
 *    If this object is a file format object this method returns
 *    information vital to the instantiation of file format plugins.
 *    If this object is not a file format object, it should return
 *    HXR_UNEXPECTED.
 */
STDMETHODIMP CSmilRenderer::GetRendererInfo
(
    REF(const char**) /*OUT*/ pStreamMimeTypes,
    REF(UINT32)      /*OUT*/ unInitialGranularity
)
{
    pStreamMimeTypes = (const char**) zm_pStreamMimeTypes;
    unInitialGranularity = m_ulGranularity;

    return HXR_OK;
}

CSmilRenderer::CSmilRenderer()
	: m_lRefCount(0)
	, m_pContext(NULL)
	, m_pStream(NULL)
	, m_pPlayer(NULL)
	, m_pHeader(NULL)
	, m_ulLastTime(0)
	, m_pCommonClassFactory(0)
	, m_pPacketParser(0)
	, m_pSmilDocRenderer(0)
	, m_pEngine(0)
        , m_pErrorMessages(NULL)
	, m_pClientContext(0)
	, m_uLayoutRule(0)
	, m_uSourceRule(0)
	, m_ulTotalSMILPackets(0)
	, m_ulGranularity(INITIAL_GRANULARITY)
	, m_pURLFragment(0)
	, m_lastOnPacketResult(HXR_OK)
	, m_bInMetadata(FALSE)
	, m_bUseNestedMeta(TRUE)
	, m_pPersistentComponentManager(NULL)    
	, m_ulPersistentVersion(0)
	, m_persistentType(PersistentSMIL)
	, m_bStreamProxiedByOtherRenderer(FALSE)
	, m_pVersionNamespaceFromProxyRenderer(NULL)
{
    m_ulPersistentVersion = HX_ENCODE_PROD_VERSION(2, 0, 0, 0);
};

CSmilRenderer::~CSmilRenderer()
{
    if(m_pSmilDocRenderer)
    {
	m_pSmilDocRenderer->close(this);
	HX_RELEASE(m_pSmilDocRenderer);
    }

    // /First, see if this player has children who need to be cleaned up:
    if (m_pPlayer)
    {
	IHXPlayerNavigator* pPlayerNavRoot = NULL;
	HX_RESULT pnrslt = m_pPlayer->QueryInterface(IID_IHXPlayerNavigator,
		(void**)&pPlayerNavRoot);
	if (HXR_OK == pnrslt)
	{
	    UINT16 uiNumChildren = pPlayerNavRoot->GetNumChildPlayer();

	    while (uiNumChildren > 0)
	    {
		IHXPlayer* pChildPlayer = NULL;
		// /GetChildPlayer addrefs pChildPlayer:
		pPlayerNavRoot->GetChildPlayer(uiNumChildren-1,pChildPlayer);
		HX_ASSERT(NULL != pChildPlayer);
		if (pChildPlayer)
		{
		    IHXPlayerNavigator* pPlayerNavChild = NULL;

		    // /RemoveChildPlayer decrefs it:
		    pPlayerNavRoot->RemoveChildPlayer(pChildPlayer);
		    IHXPlayer* pParentPlayer = NULL;

		    pnrslt= pChildPlayer->QueryInterface(
			    IID_IHXPlayerNavigator,
			    (void**)&pPlayerNavChild);
		    if (HXR_OK == pnrslt)
		    {
			// /GetParentPlayer addrefs pParentPlayer...
			pPlayerNavChild->GetParentPlayer(pParentPlayer);
			if (pParentPlayer)
			{
			    // /RemoveParentPlayer decrefs it...
			    pPlayerNavChild->RemoveParentPlayer(
				    pParentPlayer);
			    // /And we need one more to kill our use of it:
			    HX_RELEASE(pParentPlayer);
			}
			// /Now, remove it from client engine's list:
			if (m_pEngine)
			{
			    pnrslt= m_pEngine->ClosePlayer(pChildPlayer);
			}
			// /And we need one more to kill our use of it:
			HX_RELEASE(pChildPlayer);
		    }
		    HX_RELEASE(pPlayerNavChild);
		}
		uiNumChildren--;
	    }
	    HX_RELEASE(pPlayerNavRoot);
	}
    }

    HX_RELEASE(m_pContext);
    HX_RELEASE(m_pClientContext);
    HX_RELEASE(m_pStream);
    HX_RELEASE(m_pEngine);
    HX_RELEASE(m_pErrorMessages);
    HX_RELEASE(m_pCommonClassFactory);
    HX_RELEASE(m_pPersistentComponentManager);

    HX_RELEASE(m_pVersionNamespaceFromProxyRenderer);

    HX_DELETE(m_pPacketParser);
    HX_RELEASE(m_pPlayer);
    HX_VECTOR_DELETE(m_pURLFragment);
}


// *** IUnknown methods ***

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::QueryInterface
//  Purpose:
//	Implement this to export the interfaces supported by your 
//	object.
//
STDMETHODIMP CSmilRenderer::QueryInterface(REFIID riid, void** ppvObj)
{
    if (IsEqualIID(riid, IID_IUnknown))
    {
	AddRef();
	*ppvObj = this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXPlugin))
    {
	AddRef();
	*ppvObj = (IHXPlugin*)this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXRenderer))
    {
	AddRef();
	*ppvObj = (IHXRenderer*)this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXSiteUser))
    {
	HX_ASSERT(0  &&  "Huh?!  CSmilRenderer doesn't implement IHXSiteUser");
	AddRef();
	*ppvObj = (IHXSiteUser*)this;
	return HXR_OK;
    }
/*
    else if (IsEqualIID(riid, IID_IHXValues))
    {
	AddRef();
	*ppvObj = (IHXValues*)this;
	return HXR_OK;
    }
*/
    else if (IsEqualIID(riid, IID_IHXStatistics))
    {
	AddRef();
	*ppvObj = (IHXStatistics*)this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXPersistentRenderer))
    {
	AddRef();
	*ppvObj = (IHXPersistentRenderer*)this;
	return HXR_OK;
    }
    else if (IsEqualIID(riid, IID_IHXSmilToSmilRendererCommunicator))
    {
	AddRef();
	*ppvObj = (IHXSmilToSmilRendererCommunicator*)this;
	return HXR_OK;
    }
    else if (m_pSmilDocRenderer &&
	     HXR_OK == m_pSmilDocRenderer->QueryInterface(riid, ppvObj))
    {
	return HXR_OK;
    }

    *ppvObj = NULL;
    return HXR_NOINTERFACE;

⌨️ 快捷键说明

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