📄 sm1rendr.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: sm1rendr.cpp,v 1.3.2.1 2004/07/09 01:57:37 hubbe Exp $ * * Portions Copyright (c) 1995-2004 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 (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (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. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * 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#include <stdio.h>#include "sm1rendr.ver"#include "hxtypes.h"#include "hxwintyp.h"#include "chxxtype.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxcore.h"#include "hxprefs.h"#include "hxrendr.h"#include "hxasm.h"#include "hxplugn.h"#include "hxengin.h"#include "hxwin.h"#include "hxgroup.h"#include "hxsite2.h"#include "hxclsnk.h"#include "hxerror.h"#include "hxupgrd.h"#include "hxprefs.h"#include "hxvsurf.h"#include "hxcmenu.h"#include "hxhyper.h"#include "hxmon.h" // for IHXRegistry#include "hxxres.h"#include "hxxrsmg.h"#include "hxmeta1.h" /* renamed for SHAZAM; used to be hxmeta.h */#include "hxsm2sm.h"#include "hxxml.h"#include "hxxmlprs.h"#include "xmlreslt.h"#include "hxstack.h"#include "hxslist.h"#include "hxstring.h"#include "hxstrutl.h"#include "hxmap.h"#include "chxpckts.h"#include "hxmap.h"#include "hxurl.h"#include "asmrulep.h"#include "hxver.h"#include "smlpkt.h"#include "sm1elem.h"#include "sm1doc.h"#include "sm1error.h"#include "smilres.h"#include "xmlres.h"#include "smlrendr.h" /* for SMIL2+ renderer (CSmilRenderer) */#include "sm1rendr.h"#include "addupcol.h"/* 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)#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE static const char HX_THIS_FILE[] = __FILE__;#endif#ifdef _WINDOWSextern HINSTANCE g_hInstance;#endif// /Defining the following fixes PR 62481 and seems to work fine with other// SMIL 2.0 content coming from a SMIL 1.0 File Format plug-in:#define DO_INIT_PERSISTENT_ON_NEXTGEN_SMILREND 1static const UINT32 INITIAL_GRANULARITY = 66;/**************************************************************************** * * Method: * * HXCreateInstance() * * Purpose: * * Function implemented by all plugin DLL's to create an instance of * any of the objects supported by the DLL. This method is similar to * Window's CoCreateInstance() in its purpose, except that it only * creates objects from this plugin DLL. * * NOTE: Aggregation is never used. Therefore and outer unknown is * not passed to this function, and you do not need to code for this * situation. * */HX_RESULT STDAPICALLTYPE CSmil1Renderer::HXCreateInstance(IUnknown** ppIUnknown){ HX_RESULT retVal = HXR_FAIL; if (ppIUnknown) { CSmil1Renderer* pObj = new CSmil1Renderer(); if (pObj) { retVal = pObj->QueryInterface(IID_IUnknown, (void**) ppIUnknown); if (FAILED(retVal)) { HX_DELETE(pObj); } } } return retVal;}HX_RESULT STDAPICALLTYPE CSmil1Renderer::CanUnload2(){ return ((CHXBaseCountingObject::ObjectsActive() > 0) ? HXR_FAIL : HXR_OK );}const char* const CSmil1Renderer::zm_pName = "SMIL 1.0";const char* const CSmil1Renderer::zm_pDescription = "RealNetworks RMA Driver Renderer Plugin";const char* const CSmil1Renderer::zm_pCopyright = HXVER_COPYRIGHT;const char* const CSmil1Renderer::zm_pMoreInfoURL = HXVER_MOREINFO;const char* const CSmil1Renderer::zm_pStreamMimeTypes[] = { "application/vnd.rn-rmadriver", "application/rma-driver", 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 CSmil1Renderer::InitPlugin(IUnknown* /*IN*/ pContext){#if defined(HELIX_FEATURE_SMIL2) HX_ASSERT(!m_bIsHigherVersionSmilStreamFromOldSMIL1FF);#endif /* defined(HELIX_FEATURE_SMIL2). */ m_pContext = pContext; m_pContext->AddRef(); m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&m_pCommonClassFactory); 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 CSmil1Renderer::GetPluginInfo( REF(BOOL) /*OUT*/ bLoadMultiple, REF(const char*) /*OUT*/ pDescription, REF(const char*) /*OUT*/ pCopyright, REF(const char*) /*OUT*/ pMoreInfoURL, REF(ULONG32) /*OUT*/ ulVersionNumber){#if defined(HELIX_FEATURE_SMIL2) HX_ASSERT(!m_bIsHigherVersionSmilStreamFromOldSMIL1FF);#endif /* defined(HELIX_FEATURE_SMIL2). */ 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 CSmil1Renderer::GetRendererInfo( REF(const char**) /*OUT*/ pStreamMimeTypes, REF(UINT32) /*OUT*/ unInitialGranularity){#if defined(HELIX_FEATURE_SMIL2) HX_ASSERT(!m_bIsHigherVersionSmilStreamFromOldSMIL1FF);#endif /* defined(HELIX_FEATURE_SMIL2). */ pStreamMimeTypes = (const char**) zm_pStreamMimeTypes; unInitialGranularity = m_ulGranularity; return HXR_OK;}CSmil1Renderer::CSmil1Renderer() : m_lRefCount(0) , m_pContext(NULL) , m_pStream(NULL) , m_pPlayer(NULL) , m_ulLastTime(0) , m_pCommonClassFactory(0) , m_pPacketParser(0) , m_pSmilDocRenderer(0) , m_pEngine(0) , m_pClientContext(0) , m_uLayoutRule(0) , m_uSourceRule(0) , m_ulTotalSMILPackets(0) , m_ulGranularity(INITIAL_GRANULARITY) , m_pURLFragment(0) , m_lastOnPacketResult(HXR_OK)#if defined(HELIX_FEATURE_SMIL2) // /All of the following are needed for handling SMIL 2+ streams: , m_pNextGenSmilRenderer(NULL) , m_bIsHigherVersionSmilStreamFromOldSMIL1FF(FALSE) , m_pHeader(NULL) , m_pDefaultNamespace(NULL) , m_bCSmil1StartStreamHasBeenCalled(FALSE) , m_bCSmil1EndStreamHasBeenCalled(FALSE) , m_bCSmil1GetDisplayTypeHasBeenCalled(FALSE) , m_bCSmil1InitializeStatisticsHasBeenCalled(FALSE) , m_bCSmil1InitPersistenHasBeenCalled(FALSE) , m_bCSmil1GetElementPropertiesHasBeenCalled(FALSE) , m_bCSmil1RemoveLayoutSiteGroupHasBeenCalled(FALSE) , m_ulPersistentComponentID(0) , m_uPersistentGroupID(0) , m_uPersistentTrackID(0) , m_pPersistentParent(NULL) , m_ulRegistryID(0) , m_uGroupID(0) , m_uTrackID(0) // /End "...handling SMIL 2+ streams".#endif /* defined(HELIX_FEATURE_SMIL2). */ , m_bUseNestedMeta(TRUE) , m_pPersistentComponentManager(NULL) , m_ulPersistentVersion(0) , m_persistentType(PersistentSMIL){#if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS) char szDbgStr[128]; /* Flawfinder: ignore */ sprintf(szDbgStr, "CON CSmil1Renderer 0x%08x\n", this); /* Flawfinder: ignore */ OutputDebugString(szDbgStr);#endif m_ulPersistentVersion = HX_ENCODE_PROD_VERSION(1, 0, 0, 0);};CSmil1Renderer::~CSmil1Renderer(){#if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS) char szDbgStr[128]; /* Flawfinder: ignore */ sprintf(szDbgStr, "DES CSmil1Renderer 0x%08x\n", this); /* Flawfinder: ignore */ OutputDebugString(szDbgStr);#endif if(m_pSmilDocRenderer) { m_pSmilDocRenderer->close(this); HX_RELEASE(m_pSmilDocRenderer); }#if defined(HELIX_FEATURE_SMIL2) HX_RELEASE(m_pDefaultNamespace); HX_RELEASE(m_pNextGenSmilRenderer); HX_RELEASE(m_pHeader); HX_RELEASE(m_pPersistentParent);#endif /* defined(HELIX_FEATURE_SMIL2). */ HX_RELEASE(m_pPersistentComponentManager); HX_RELEASE(m_pContext); HX_RELEASE(m_pClientContext); HX_RELEASE(m_pStream); HX_RELEASE(m_pEngine); HX_RELEASE(m_pCommonClassFactory); 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 CSmil1Renderer::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)) { AddRef(); *ppvObj = (IHXSiteUser*)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 (m_pSmilDocRenderer && HXR_OK == m_pSmilDocRenderer->QueryInterface(riid, ppvObj)) { return HXR_OK; }#if defined(HELIX_FEATURE_SMIL2) else if (m_bIsHigherVersionSmilStreamFromOldSMIL1FF) { if (!m_pNextGenSmilRenderer) { return HXR_UNEXPECTED; } if (HXR_OK == m_pNextGenSmilRenderer->QueryInterface(riid, ppvObj)) { return HXR_OK; } }#endif /* defined(HELIX_FEATURE_SMIL2). */ *ppvObj = NULL; return HXR_NOINTERFACE;}/////////////////////////////////////////////////////////////////////////// Method:// IUnknown::AddRef// Purpose:// Everyone usually implements this the same... feel free to use// this implementation.//STDMETHODIMP_(ULONG32) CSmil1Renderer::AddRef(){ return InterlockedIncrement(&m_lRefCount);}/////////////////////////////////////////////////////////////////////////// Method:// IUnknown::Release// Purpose:// Everyone usually implements this the same... feel free to use// this implementation.//STDMETHODIMP_(ULONG32) CSmil1Renderer::Release(){ if (InterlockedDecrement(&m_lRefCount) > 0) { return m_lRefCount; } delete this; return 0;}// *** IHXRenderer methods ***/////////////////////////////////////////////////////////////////////////// Method:// IHXRenderer::StartStream// Purpose:// Called by client engine to inform the renderer of the stream it// will be rendering. The stream interface can provide access to// its source or player. This method also provides access to the // primary client controller interface.//STDMETHODIMP CSmil1Renderer::StartStream( IHXStream* pStream,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -