📄 hxplay.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 "hxtypes.h"
#if (defined( _WIN32 ) || defined( _WINDOWS )) && !defined(WIN32_PLATFORM_PSPC)
#include <winsock2.h>
#endif /* defined( _WIN32 ) || defined( _WINDOWS ) */
#include "hxcom.h"
#include "hxmime.h"
#include "dbcs.h"
#include "chxxtype.h"
#include "hxresult.h"
#ifndef _WINCE
#include "hlxclib/signal.h"
#endif
#include "conn.h"
#if defined( _WIN32 ) || defined( _WINDOWS )
#include "platform/win/win_net.h"
#elif defined (_MACINTOSH)
#include "mac_net.h"
#elif defined (_UNIX)
#include "unix_net.h"
#elif defined(__TCS__)
#include "platform/tm1/tm1_net.h"
#endif // defined( _WIN32 ) || defined( _WINDOWS )
#include "hxcomm.h"
#include "ihxpckts.h"
#include "hxfiles.h"
#include "hxformt.h"
#include "hxengin.h"
#include "hxcore.h"
#include "hxprefs.h"
#include "hxpref.h"
#include "hxclsnk.h"
#include "hxpends.h"
#include "hxhyper.h"
#include "playhpnv.h"
#include "hxmon.h"
#if defined(HELIX_FEATURE_ASM)
#include "hxasm.h"
#include "hxsmbw.h"
#include "createbwman.h"
#endif /* HELIX_FEATURE_ASM */
#include "hxplugn.h"
#include "chxeven.h"
#include "chxelst.h"
#include "strminfo.h"
#if defined(HELIX_FEATURE_MEDIAMARKER)
#include "hxmmrkr.h"
#endif /* #if defined(HELIX_FEATURE_MEDIAMARKER) */
#if defined(HELIX_FEATURE_EVENTMANAGER)
#include "hxinter.h"
#endif /* #if defined(HELIX_FEATURE_EVENTMANAGER) */
#include "hxslist.h"
#include "hxmap.h"
#include "hxstrutl.h"
//#include "plgnhand.h"
#include "hxrquest.h"
#include "chxelst.h"
#include "hxbsrc.h"
#include "hxsrc.h"
#include "hxflsrc.h"
#include "hxntsrc.h"
#include "hxrendr.h"
#include "hxwin.h"
#include "hxstrm.h"
#include "hxcleng.h"
#include "timeline.h"
#include "hxstring.h"
#include "timeval.h"
#include "hxerror.h"
#include "sinkctl.h"
#include "upgrdcol.h"
#include "chxphook.h"
#include "hxgroup.h"
#include "basgroup.h"
#include "advgroup.h"
// temporary
//#define DEBUG_LOG_INFO 1
#include "hxstat.h"
#include "auderrs.h"
#include "hxausvc.h"
#include "hxaudses.h"
#include "hxaudply.h"
#include "hxplay.h"
#include "hxplugn.h"
#include "hxtick.h"
#include "srcinfo.h"
#include "nxtgrmgr.h"
#include "prefmgr.h"
#include "srcinfo.h"
#include "errdbg.h"
#include "hxthread.h"
#include "hxxrsmg.h"
#include "hxresmgr.h"
#include "portaddr.h"
#if defined(HELIX_FEATURE_SMARTERNETWORK)
#include "preftran.h"
#endif /* HELIX_FEATURE_SMARTERNETWORK */
#include "cookies.h"
#include "viewport.h"
#if defined(HELIX_FEATURE_MEDIAMARKER)
#include "mediamrk.h"
#endif /* #if defined(HELIX_FEATURE_MEDIAMARKER) */
#if defined(HELIX_FEATURE_EVENTMANAGER)
#include "eventmgr.h"
#endif /* #if defined(HELIX_FEATURE_EVENTMANAGER) */
#include "hxtac.h"
#if defined(_STATICALLY_LINKED) || !defined(HELIX_FEATURE_PLUGINHANDLER2)
#include "hxpluginmanager.h"
#else
#include "plghand2.h"
#endif /* _STATICALLY_LINKED */
//#include "../dcondev/dcon.h"
//BOOL g_bRahulLog = FALSE;
#if defined(_MACINTOSH) || defined(_MAC_UNIX)
#include "platform/mac/hx_moreprocesses.h"
#endif
#ifdef _MACINTOSH
#include "hxmm.h"
#endif
#ifdef _UNIX
#include "unix_net.h"
#endif
#include "sitemgr.h"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
#ifdef _WIN16
extern HINSTANCE g_hInstance; // initialized in DLLMAIN.CPP(rmacore.dll)
#endif
#if defined(__TCS__)
#if defined(__cplusplus)
extern "C" {
#endif
void hookRealAudio_ReportError(int err, long errVal);
#ifdef __cplusplus
}
#endif
#endif
#define MIN_DELAYBEFORE_START 2000
#define BEGIN_SYNC_FUDGE_FACTOR 50
#define MAX_LOOP_EXE_TIME 300 //100
#define ALLFS 0xFFFFFFFF
#define GOTOEXITONERROR(theErr, label) if (theErr) goto label
/* Please add any variables to be re-initialized in the ResetPlayer()
* function also.
*/
HXPlayer::HXPlayer() :
m_pURL (0)
,m_lRefCount (0)
,m_pPreferences(0)
,m_pClientRequestSink(0)
,m_pHyperNavigate(0)
,m_pRegistry(0)
,m_pStats(0)
,m_pUpdateStatsCallback(0)
,m_ulStatsGranularity(1000)
,m_pEngine (0)
,m_pPlugin2Handler(0)
,m_pAudioPlayer (0)
,m_uNumSourcesActive(0)
,m_uNumCurrentSourceNotDone(0)
,m_bInitialized (FALSE)
,m_pPendingTrackList(NULL)
,m_ulCurrentPlayTime (0)
#if defined(_MACINTOSH) || defined(_MAC_UNIX)
,m_ulCurrentSystemPlayTime(0)
#endif
,m_ulPresentationDuration(0)
,m_ulTimeBeforeSeek (0)
,m_ulTimeAfterSeek (0)
,m_BufferingReason(BUFFERING_START_UP)
,m_pScheduler(0)
,m_bIsDone(TRUE)
,m_bIsPresentationDone(TRUE)
,m_bIsPresentationClosedToBeSent(FALSE)
,m_bCoreLocked(FALSE)
,m_bPaused(FALSE)
,m_bBeginPending(FALSE)
,m_pClient(0)
,m_ulLowestGranularity(DEFAULT_TIMESYNC_GRANULARITY)
,m_bTimelineToBeResumed (FALSE)
,m_bIsPlaying(FALSE)
,m_bNetInitialized(FALSE)
,m_bPrefTransportInitialized(FALSE)
,m_bIsFirstBegin(TRUE)
,m_bIsFirstBeginPending(FALSE)
,m_bIsLive(FALSE)
,m_bProcessEventsLocked(FALSE)
,m_bTimeSyncLocked(FALSE)
,m_bCurrentPresentationClosed(FALSE)
,m_LastError(HXR_OK)
,m_bInStop(FALSE)
,m_bPlayerWithoutSources(FALSE)
,m_ulMinimumAudioPreroll(0)
,m_ulMinimumTotalPreroll(0)
,m_bInternalPauseResume(FALSE)
,m_bInternalReset(FALSE)
,m_pErrorSinkControl(NULL)
,m_pAdviseSink(NULL)
,m_pSiteManager(NULL)
,m_pSiteSupplier(NULL)
,m_pHXPlayerCallback(0)
,m_pSetupCallback(0)
,m_pAuthenticationCallback(NULL)
,m_pHXPlayerInterruptCallback(NULL)
,m_nGroupCount(0)
,m_nCurrentGroup(0)
,m_bContactingDone(FALSE)
,m_pUpgradeCollection(NULL)
,m_pPacketHookManager(NULL)
,m_bIsFirstTimeSync(TRUE)
,m_ulFirstTimeSync(0)
,m_ulElapsedPauseTime(0)
,m_ulLiveSeekTime(0)
,m_ulTimeOfPause(0)
,m_bLiveSeekToBeDone(FALSE)
,m_bFastStartInProgress(FALSE)
,m_ulFSBufferingEndTime(0)
,m_bAllLocalSources(TRUE)
,m_bFSBufferingEnd(FALSE)
,m_pGroupManager(NULL)
,m_bPartOfNextGroup(FALSE)
,m_pNextGroupManager(NULL)
,m_pPrefetchManager(NULL)
,m_bLastGroup(FALSE)
,m_bNextGroupStarted(FALSE)
,m_bDidWeDeleteAllEvents(FALSE)
,m_bSetupLayoutSiteGroup(TRUE)
,m_pCurrentGroup(NULL)
,m_bBeginChangeLayoutTobeCalled(TRUE)
,m_b100BufferingToBeSent(TRUE)
,m_bUserHasCalledBegin(FALSE)
,m_bCloseAllRenderersPending(FALSE)
,m_uNumSourceToBeInitializedBeforeBegin(0)
,m_pCoreMutex(NULL)
,m_bSetupToBeDone(FALSE)
,m_bPostSetupToBeDone(FALSE)
,m_pRequest(NULL)
,m_pAltURLs(NULL)
,m_bActiveRequest(FALSE)
,m_bUseCoreThread(FALSE)
,m_bAddLayoutSiteGroupCalled(FALSE)
,m_pLastUserString(NULL)
,m_pLastMoreInfoURL(NULL)
,m_bForceStatsUpdate(FALSE)
#if defined(HELIX_FEATURE_ASM)
,m_pBandwidthMgr(NULL)
,m_pASM(NULL)
#endif
,m_pRedirectList(NULL)
,m_bPendingAudioPause(FALSE) // currently used ONLY on Mac
,m_bPlayStateNotified(FALSE)
,m_bResumeOnlyAtSystemTime(FALSE)
,m_bSourceMapUpdated(FALSE)
,m_pPreferredTransportManager(NULL)
,m_pNetInterfaces(NULL)
,m_pClientViewSource(NULL)
,m_pViewPortManager(NULL)
,m_pMediaMarkerManager(NULL)
,m_pEventManager(NULL)
,m_pClientViewRights(NULL)
,m_ulRepeatedRegistryID(0)
,m_ulNextGroupRegistryID(0)
,m_pCookies(NULL)
,m_pParentPlayer(NULL)
,m_pChildPlayerList(NULL)
,m_bSetModal(FALSE)
,m_pPersistentComponentManager(NULL)
,m_pAutheticationValues(NULL)
,m_bDoRedirect(FALSE)
,m_ulActiveSureStreamSource(0)
,m_bFastStartCheckDone(FALSE)
,m_bFastStart(FALSE)
,m_turboPlayOffReason(TP_OFF_BY_UNKNOWN)
,m_pMasterTAC(NULL)
#ifdef _WIN32
,m_bScreenSaverActive(0)
#endif
,m_pRecordService(NULL)
,m_bRecordServiceEnabled(FALSE)
/* Please add any variables to be re-initialized in the ResetPlayer()
* function also.
*/
{
m_pSourceMap = new CHXMapPtrToPtr;
m_pSharedWallClocks = new CHXMapStringToOb;
#if defined(_DEBUG) && defined(DEBUG_LOG_INFO)
HXStaticStatLog::Open_Write("e:\\log.txt");
#endif // DEBUG_LOG_INFO
ResetError();
#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
m_pUpdateStatsCallback = new UpdateStatsCallback;
m_pUpdateStatsCallback->m_pPlayer = this;
m_pUpdateStatsCallback->AddRef();
#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
#if defined (_WIN32) || defined (_MACINTOSH) || defined(THREADS_SUPPORTED)
m_pHXPlayerCallback = new HXPlayerCallback((void*)this, (fGenericCBFunc)PlayerCallback);
m_pHXPlayerInterruptCallback = new HXPlayerCallback((void*)this, (fGenericCBFunc)PlayerCallback);
m_pSetupCallback = new HXPlayerCallback((void*)this, (fGenericCBFunc)SetupCallback);
((HXPlayerCallback*)m_pHXPlayerInterruptCallback)->m_bInterrupSafe = TRUE;
((HXPlayerCallback*)m_pSetupCallback)->m_bInterrupSafe = TRUE;
#else
m_pHXPlayerCallback = new CHXGenericCallback((void*)this, (fGenericCBFunc)PlayerCallback);
m_pHXPlayerInterruptCallback = new CHXGenericCallback((void*)this, (fGenericCBFunc)PlayerCallback);
m_pSetupCallback = new CHXGenericCallback((void*)this, (fGenericCBFunc)SetupCallback);
#endif
m_pHXPlayerCallback->AddRef();
m_pHXPlayerInterruptCallback->AddRef();
m_pSetupCallback->AddRef();
#if defined(HELIX_FEATURE_AUTHENTICATION)
m_pAuthenticationCallback = new CHXGenericCallback((void*)this, (fGenericCBFunc)AuthenticationCallback);
m_pAuthenticationCallback->AddRef();
#endif /* HELIX_FEATURE_AUTHENTICATION */
#if defined(HELIX_FEATURE_SINKCONTROL)
m_pErrorSinkControl = new CHXErrorSinkControl;
m_pAdviseSink = new CHXAdviseSinkControl;
#endif /* HELIX_FEATURE_SINKCONTROL */
#if defined(HELIX_FEATURE_VIDEO)
m_pSiteManager = new CHXSiteManager();
#endif /* HELIX_FEATURE_VIDEO */
#if defined(HELIX_FEATURE_ADVANCEDGROUPMGR)
m_pGroupManager = new HXAdvancedGroupManager(this);
#elif defined(HELIX_FEATURE_BASICGROUPMGR)
m_pGroupManager = new HXBasicGroupManager(this);
#endif /* HELIX_FEATURE_ADVANCEDGROUPMGR */
#if defined(HELIX_FEATURE_NEXTGROUPMGR)
m_pNextGroupManager = new NextGroupManager(this);
#endif /* HELIX_FEATURE_NEXTGROUPMGR */
#if defined(HELIX_FEATURE_MASTERTAC)
m_pMasterTAC = new HXMasterTAC(m_pGroupManager);
#endif /* HELIX_FEATURE_MASTERTAC */
#if defined(HELIX_FEATURE_VIEWPORT)
m_pViewPortManager = new HXViewPortManager(this);
#endif /* HELIX_FEATURE_VIEWPORT */
#if defined(HELIX_FEATURE_MEDIAMARKER)
m_pMediaMarkerManager = new CHXMediaMarkerManager(this);
if (m_pMediaMarkerManager) m_pMediaMarkerManager->AddRef();
#endif /* #if defined(HELIX_FEATURE_MEDIAMARKER) */
#if defined(HELIX_FEATURE_NESTEDMETA)
m_pPersistentComponentManager = new HXPersistentComponentManager(this);
#endif /* HELIX_FEATURE_NESTEDMETA */
HX_ADDREF(m_pErrorSinkControl);
HX_ADDREF(m_pAdviseSink);
#if defined(HELIX_FEATURE_VIDEO)
m_pSiteManager->AddRef();
#endif /* HELIX_FEATURE_VIDEO */
#if defined(HELIX_FEATURE_BASICGROUPMGR)
m_pGroupManager->AddRef();
m_pGroupManager->AddSink(this);
#endif /* HELIX_FEATURE_BASICGROUPMGR */
HX_ADDREF(m_pMasterTAC);
#if defined(HELIX_FEATURE_VIEWPORT)
m_pViewPortManager->AddRef();
#endif /* HELIX_FEATURE_VIEWPORT */
#if defined(HELIX_FEATURE_ADVANCEDGROUPMGR) && defined(HELIX_FEATURE_MASTERTAC)
if (m_pGroupManager && m_pMasterTAC)
{
m_pGroupManager->SetMasterTAC(m_pMasterTAC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -