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

📄 sm1doc.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: sm1doc.cpp,v 1.3.12.2 2004/07/26 19:52:31 milko 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 ***** */#include <stdio.h>#include <math.h>#include "hxtypes.h"#include "hxwintyp.h"#include "chxxtype.h"#include "smil1typ.h"   /* renamed for SHAZAM; used to be smiltype.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 "hxcore.h"#include "hxclsnk.h"#include "hxwin.h"#include "hxsite2.h"#include "hxsrc.h"#include "hxgroup.h"#include "hxrendr.h"#include "hxevent.h"#include "hxvsurf.h"#include "hxerror.h"#include "hxupgrd.h"#include "hxvsurf.h"#include "hxhyper.h"#include "hxxres.h"#include "hxxrsmg.h"#include "hxsm2sm.h"#include "hxxml.h"#include "hxxmlprs.h"#include "xmlreslt.h"#include "hxstack.h"#include "hxslist.h"#include "chxpckts.h"#include "hxstring.h"#include "hxurl.h"#include "hxmap.h"#include "hxstrutl.h"#include "errdbg.h"#include "hxordval.h"	// CHXOrderedValues#if defined(_WINDOWS)#include "diballoc.h"#define IDC_HANDCURSOR 102#elif defined (_MACINTOSH)#include "hxmm.h"#include "cresload.h"extern FSSpec g_DLLFSpec;#endif#if defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/cursorfont.h>/* USE_SHM doesn't work yet */#ifdef USE_SHM#undef USE_SHM#endif /* USE_SHM */#endif#include "sm1elem.h"#include "sm1parse.h"#include "sm1error.h"#include "smilres.h"#include "smlrendr.h" /* for SMIL2+ renderer (CSmilRenderer) */#include "sm1rendr.h"#include "sm1doc.h"#include "debugout.h" // XXXMEH#include "hxtick.h"   // XXXMEH#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endif#ifdef _DEBUG#ifdef _WINDOWSstatic const char SMILDEPFILE[] = "\\smildep.txt";#elsestatic const char SMILDEPFILE[] = "smildep.txt";#endif#endif#ifdef _WINDOWSextern HINSTANCE g_hInstance;#endif#ifdef _DEBUG#define MAX_DEBUG_STRING 20000#define SDEBUG_OUT(x, y)	{						\			    char* s;					\			    FILE* f1;					\			    s = new char[MAX_DEBUG_STRING];					\			    sprintf y;					\			    f1 = (x)?(::fopen(x, "a+")):(NULL);			\			    (f1)?(::fprintf(f1, s), ::fclose(f1)):(0);	\			    delete[] s; \		       }#else#define SDEBUG_OUT(x, y)#endif#define SDEBUG_FILE 0//"e:\\temp\\smilout.txt"//// site information - used// to handle site show/hide// behavior in seek and hyperlinking//struct SMIL1SiteInfo{    IHXSite* m_pRendererSite;    IHXSite* m_pRegionSite;    HXxSize m_rendererSize;    UINT16 m_uGroupIndex;    UINT32 m_ulDelay;    UINT32 m_ulDuration;    BOOL m_bRemoveSite;    BOOL m_bNoRegion;    CHXString m_regionID;    IHXRenderer* m_pRenderer;};// source information - contained// in SMIL1PlayToAssoc.m_sourceMapstruct SMIL1SourceInfo{    IUnknown* m_pStream;    IHXRenderer* m_pRenderer;    CHXString m_tunerName;    CHXString m_childTunerName;    CSmil1EventHook* m_pRendererEventHook;    UINT32 m_ulDuration;    UINT32 m_ulDelay;};//// struct that associates group,track,and playto property of a stream//struct SMIL1PlayToAssoc{    UINT16 m_uGroupIndex;    UINT16 m_uTrackIndex;    BOOL m_bDurationResolved;    CHXMapLongToObj m_sourceMap;    CHXString m_playTo;    CHXString m_id;    CHXString m_repeatid;    CHXString m_tunerName;    CHXString m_childTunerName;    CHXString m_regionName;    UINT32 m_ulDelay;    UINT32 m_ulDuration;    BOOL m_bRemoveSite;    CHXSimpleList* m_pHyperlinks;    CSmil1EventHook* m_pRendererEventHook;    CHXSimpleList* m_pSiteInfoList;    BOOL m_bLiveSource;};//// group information//struct SMIL1GroupInfo{    int m_nTracks;    int m_nTracksAdded;    int m_nTrackDurationsSet;    UINT32 m_ulDuration;};//// site/z-order info //struct SMIL1ZOrderInfo{    IHXSite* m_pSite;    INT32 m_lZIndex;};//// event source info (endsync in SMIL)//struct SMIL1DeferredSourceInfo{    UINT32 m_ulDuration;    UINT32 m_ulDelay;};//// event handler classes//class CSmil1LayoutEvent : public CHXBaseCountingObject{public:    CSmil1LayoutEvent		    (UINT16 uGroupIndex,				    UINT32 ulEventTime);    virtual ~CSmil1LayoutEvent	    ();    virtual HX_RESULT handleEvent   () = 0;    UINT32 m_ulEventTime;    UINT16 m_uGroupIndex;};CSmil1LayoutEvent::CSmil1LayoutEvent(UINT16 uGroupIndex, UINT32 ulEventTime):    m_uGroupIndex(uGroupIndex),    m_ulEventTime(ulEventTime){}CSmil1LayoutEvent::~CSmil1LayoutEvent(){}class CSmil1ShowSiteEvent: public CSmil1LayoutEvent{public:    CSmil1ShowSiteEvent		    (UINT16 uGroupIndex,				    UINT32 ulEventTime,				    IHXSite* pSite,				    IHXSite* pRegionSite,				    BOOL bShowSite);    virtual ~CSmil1ShowSiteEvent	    ();    virtual HX_RESULT handleEvent   ();    IHXSite* getRegionSite	    () { return m_pRegionSite; }    IHXSite* getRendererSite	    () { return m_pSite; }    BOOL showSite   		    () { return m_bShowSite; }    IHXSite* m_pSite;    IHXSite* m_pRegionSite;    BOOL m_bShowSite;};CSmil1ShowSiteEvent::CSmil1ShowSiteEvent(UINT16 uGroupIndex,				      UINT32 ulEventTime,				      IHXSite* pSite,				      IHXSite* pRegionSite,				      BOOL bShowSite):    CSmil1LayoutEvent(uGroupIndex, ulEventTime),    m_pSite(pSite),    m_pRegionSite(pRegionSite),    m_bShowSite(bShowSite){#if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)    char szDbgStr[128]; /* Flawfinder: ignore */    sprintf(szDbgStr, "CON CSmil1LayoutEvent 0x%08x\n", this); /* Flawfinder: ignore */    OutputDebugString(szDbgStr);#endif    if (m_pSite)    {        m_pSite->AddRef();    }    if (m_pRegionSite)    {        m_pRegionSite->AddRef();    }}CSmil1ShowSiteEvent::~CSmil1ShowSiteEvent(){#if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)    char szDbgStr[128]; /* Flawfinder: ignore */    sprintf(szDbgStr, "DES CSmil1LayoutEvent 0x%08x\n", this); /* Flawfinder: ignore */    OutputDebugString(szDbgStr);#endif    HX_RELEASE(m_pSite);    HX_RELEASE(m_pRegionSite);}HX_RESULTCSmil1ShowSiteEvent::handleEvent(){    HX_RESULT rc = HXR_OK;    IHXSite2* pRegionSite2 = 0;    IHXSite2* pSite2 = 0;        if (m_pRegionSite)	m_pRegionSite->QueryInterface(IID_IHXSite2,(void**)&pRegionSite2);    if (m_pSite)	m_pSite->QueryInterface(IID_IHXSite2,(void**)&pSite2);        if (m_bShowSite)    {	// if showing, then first show the site before the region site	// to prevent the flash when the region site is shown before the	// site.	if (pSite2) pSite2->ShowSite(m_bShowSite);	if (pRegionSite2) pRegionSite2->ShowSite(m_bShowSite);    }    else    {	// if hiding, then first hide the region so it's a one-step	// process visually.	if (pRegionSite2) pRegionSite2->ShowSite(m_bShowSite);	if (pSite2) pSite2->ShowSite(m_bShowSite);    }        if (pRegionSite2) pRegionSite2->Release();    if (pSite2) pSite2->Release();        return rc;}/* * CSmil1DocumentRenderer methods */CSmil1DocumentRenderer::CSmil1DocumentRenderer(    CSmil1Renderer* pParent, IUnknown* pContext):    m_pParent(pParent),    m_pSmilParser(0),    m_ulParseResult(HXR_OK),    m_lRefCount(0),    m_pContext(pContext),    m_pMISUSSite(0),    m_pRegionMap(0),    m_pSiteInfoByRendererMap(0),    m_pSiteWatcherMap(0),    m_pGroupInfoMap(0),    m_pGroupMap(0),    m_pDeferredSourceMap(0),    m_pRepeatIDMap(0),    m_pSiteInfoList(0),    m_uCurrentGroupIndex(-1),    m_pPlayToAssocList(0),    m_pZOrderList(0),    m_pSiteMgr(0),    m_pScheduler(0),    m_pEventList(0),    m_pValues(0),    m_pFragment(0),    m_ulCurrentTime(0),    m_ulEventListPosition(0),    m_bFirstTimeSync(FALSE),    m_bSiteChangingSize(FALSE),    m_bRootLayoutWidthSet(FALSE),    m_bRootLayoutHeightSet(FALSE),    m_ulRootLayoutHeight(0),    m_ulRootLayoutWidth(0),    m_ulNoRootLayoutHeight(0),    m_ulNoRootLayoutWidth(0),    m_ulRootLayoutBGColor(0),    m_bSettingFragment(FALSE),    m_bInHyperlink(FALSE),    m_pStatusMessage(0),    m_bStatusMessageSet(FALSE),#ifdef _WINDOWS    m_hPreHyperlinkCursor(0),    m_hHyperlinkCursor(0),    m_bNeedToSetHyperlinkCursor(FALSE),#endif#ifdef _MACINTOSH    m_hHyperlinkCursor(0),    m_bResetCursor(FALSE),#endif#if defined(_UNIX)  &&  (!defined(_BEOS))  &&  defined(USE_XWINDOWS)    m_hHyperlinkCursor(0),    m_hCurrentCursor(0),    m_pDisplay(0),    m_Window(0),    m_pPixmapDisplay(NULL),    m_pVisualInfo(NULL),#endif    m_bSiteLayoutComplete(FALSE),    m_nFragmentTracks(0),    m_bShowDependencies(FALSE),    m_dResizeXScale(1.0),    m_dResizeYScale(1.0)    , m_ulGroupIndex(0)    , m_ulTrackIndex(0)    , m_uGroupIndexWithin(0)    , m_bSitesDetached(FALSE)    , m_bInRAM20(FALSE)    , m_bLastGroupInRAM20(FALSE)    , m_ulPersistentComponentDelay(0)    , m_ulPersistentComponentID(0)    , m_uPersistentGroupID(0)    , m_uPersistentTrackID(0)    , m_elementWithinTag(WithinUnknown)    , m_pPersistentProperties(NULL)    , m_pPersistentParentRenderer(NULL)    , m_bCloseCalled(FALSE)    , m_pProcessElementCallback(NULL)    , m_ulPktnum(0)    , m_usOldXPos(0)    , m_usOldYPos(0){#if defined(_DEBUG) && defined(XXXMEH_CHECK_FOR_LEAKS)    char szDbgStr[128]; /* Flawfinder: ignore */    sprintf(szDbgStr, "CON CSmil1DocumentRenderer 0x%08x\n", this); /* Flawfinder: ignore */    OutputDebugString(szDbgStr);#endif    HX_ASSERT( m_pContext );    if(m_pContext)    {	m_pContext->AddRef();		HX_VERIFY(HXR_OK == m_pContext->		  QueryInterface(IID_IHXSiteManager,(void**)&m_pSiteMgr));		HX_VERIFY(HXR_OK == m_pContext->		  QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler));		if (HXR_OK != m_pContext->QueryInterface(IID_IHXStatusMessage,						 (void**)&m_pStatusMessage))	{	    // not an error, just a feature waiting to happen...	    m_pStatusMessage = NULL;	}    }#ifdef _WINDOWS    m_hHyperlinkCursor = LoadCursor(g_hInstance,        MAKEINTRESOURCE(IDC_HANDCURSOR));#endif#ifdef _MACINTOSH    const short HAND_CURSOR  = 1313;    m_pResourceLoader = CResourceLoader::CreateInstance(g_DLLFSpec);    m_hHyperlinkCursor = (CursHandle)m_pResourceLoader->LoadResource('CURS', HAND_CURSOR);#endif    #ifdef _DEBUG    IHXPreferences* pPrefs = NULL;    // get "showdependencies" preference    //IHXPreferences* pPrefs = 0;    if(HXR_OK == m_pContext->QueryInterface(       IID_IHXPreferences, (void**)&pPrefs))    {	IHXBuffer* pBuf = 0;	if(HXR_OK == pPrefs->ReadPref("showdependencies", pBuf))	{

⌨️ 快捷键说明

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