📄 hxntsrc.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 "hxcom.h"
#include "hlxclib/stdio.h"
#if defined (_UNIX) || defined (_WIN16)
#include <stdlib.h>
#endif
#include "hxcomm.h"
#include "hxplugn.h"
#include "ihxpckts.h"
#include "hxpends.h"
#include "hxfiles.h"
#include "hxengin.h"
#include "hxcore.h"
#include "hxprefs.h"
#include "hxpref.h"
#include "hxausvc.h"
#include "hxasm.h"
#include "hxauthn.h"
#include "hxgroup.h"
#include "hxsmbw.h"
#include "hxrsdbf.h"
#include "hxmime.h"
#include "hxslist.h"
#include "hxstring.h"
#include "portaddr.h"
#include "chxeven.h"
#include "chxelst.h"
#include "strminfo.h"
#include "hxbsrc.h"
#include "hxsrc.h"
#include "hxntsrc.h"
#include "hxstrm.h"
#include "hxplay.h"
#include "rtspif.h"
#include "hxprotocol.h"
#include "dtrvtcon.h"
#include "rtspprotocol.h"
#if defined(HELIX_FEATURE_PNA)
#include "hxpnapro.h"
#endif /* HELIX_FEATURE_PNA */
#include "rmfftype.h"
#include "prefdefs.h"
#include "plprefk.h"
#include "hxtick.h"
#include "netbyte.h"
#include "hxcom.h"
#include "hxstrutl.h"
#include "ihxpckts.h"
#include "chxpckts.h"
#include "hxmap.h"
#include "hxstat.h"
#include "hxmangle.h"
#include "srcinfo.h"
#include "srcerrs.h"
#include "errdbg.h"
#include "ihxcookies.h"
#include "pacutil.h"
#if defined(HELIX_FEATURE_NETCHECK)
#include "netchck.h"
#endif /* defined(HELIX_FEATURE_NETCHECK) */
#include "hxrasyn.h"
#include "hxaudstr.h"
#include "hxaudses.h"
#include "verutil.h"
#include "hxrendr.h"
#include "hxcleng.h"
#include "wmbufctl.h"
#include "fbbufctl.h"
#include "clntcore.ver"
#include "hxver.h"
#include "hxwinver.h"
#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif
// maximum level of statistics that we wanna send back to the server
#define MAX_STATS_MASK 15 // value from server is a bit field
#define MAX_LOGINFO_LENGTH 2048 // maximum of 2K bytes of statistics
/* RTSP Setup may take a lot ot time */
#define NEW_DEF_SETTINGS_TIMEOUT 3000
#define MINIMUM_TIMEOUT 5
const short int MAX_CLOAK_PORTS = 4;
const UINT16 g_uCloakPorts[MAX_CLOAK_PORTS] = {80, 8080, 554, 7070};
#define CLOAKPORT_URL_OPTION "cloakport"
HXNetSource::HXNetSource() :
m_bLossCorrection (FALSE)
, m_pHost (0)
, m_pPath (NULL)
, m_pResource (0)
, m_uPort (0)
, m_bRTSPProtocol (FALSE)
, m_pProxy (0)
, m_uProxyPort (0)
, m_bUseProxy (FALSE)
, m_pCloakPortList(NULL)
, m_nNumberOfCloakPorts(0)
, m_nCurrPortIdx (0)
, m_uCurrCloakedPort(0)
, m_bUseUDPPort (FALSE)
, m_pProto (0)
, m_ulStartBuffering (0)
, m_bSendStatistics (TRUE)
, m_ulServerTimeOut (90)
, m_ulConnectionTimeout(DEFAULT_CONN_TIMEOUT)
, m_bAtInterrupt (FALSE)
, m_fReBufferPercent ((float)0.)
, m_pProtocolStatus (0)
, m_ulMulticastTimeout (NEW_DEF_SETTINGS_TIMEOUT)
, m_ulUDPTimeout (NEW_DEF_SETTINGS_TIMEOUT)
, m_ulTCPTimeout(NEW_DEF_SETTINGS_TIMEOUT)
, m_ulStartDataWait (0)
, m_ulServerVersion(0)
, m_ulTransportPrefMask(0)
, m_bDataWaitStarted(FALSE)
, m_bConnectionWait(TRUE)
, m_ulFirstDataArrives (0)
, m_uProtocolType(unknownProtocol)
, m_bPerfectPlayPreferenceRead(FALSE)
, m_bPerfectPlayErrorChecked(FALSE)
, m_CurrentTransport(UnknownMode)
, m_PreferredTransport(UnknownMode)
, m_bServerHasPerfectPlay(FALSE)
, m_ulSendStatsMask(0)
, m_ulStatsInterval(0)
, m_bServerHasTransportSwitching (FALSE)
, m_bForcePerfectPlay (FALSE)
, mServerSelRecordSupport(FALSE)
, mInterframeControlSupport(FALSE)
, mServerHasBandwidthReport(FALSE)
, mServerHasFrameControl(FALSE)
, m_bInRetryMode(FALSE)
, m_bPushDownSet(FALSE)
, m_pushDownStatus(PUSHDOWN_NONE)
, m_bRARVSource(FALSE)
, m_bRARVSourceVerified(FALSE)
, m_bBruteForceReconnected(FALSE)
, m_bBruteForceConnectToBeDone(FALSE)
, m_lRAStreamNumber(-1)
, m_pLogInfoList(NULL)
, m_ulLogInfoLength(0)
, m_bResendAuthenticationInfo(FALSE)
, m_bUserHasCalledResume(FALSE)
, m_bUserHasCalledStartInit(FALSE)
, m_bTimeBased(FALSE)
, m_uLastBuffering(0)
, m_uLastStatusCode(HX_STATUS_BUFFERING)
, m_bAltURL(FALSE)
, m_bNoLatency(FALSE)
, m_bNoLatencySet(FALSE)
, m_pCookies(NULL)
, m_pCookies2(NULL)
, m_ulSeekPendingTime(0)
, m_bSeekPending(FALSE)
, m_prefTransportState(PTS_UNKNOWN)
, m_pPreferredTransport(NULL)
, m_pPreferredTransportManager(NULL)
, m_pReconnectCallback(NULL)
#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
, m_pStatsCallback(NULL)
#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
, m_bAttemptReconnect(TRUE)
, m_pszReconnectServer(NULL)
, m_pszReconnectProxy(NULL)
, m_pszReconnectURL(NULL)
, m_ulReconnectServerPort(0)
, m_ulReconnectProxyPort(0)
, m_pszRedirectServer(NULL)
, m_pszRedirectResource(NULL)
, m_pszRedirectURL(NULL)
, m_ulRedirectServerPort(0)
, m_pPAC(NULL)
, m_pPACInfoList(NULL)
, m_PACInfoPosition(0)
, m_state(NETSRC_READY)
, m_pBufferCtl(NULL)
, m_pWMBufferCtl(NULL)
{
HX_TRACE("HXNetSource::HXNetSource");
memset(m_szUserName, 0, MAX_DISPLAY_NAME);
memset(m_szPassword, 0, MAX_DISPLAY_NAME);
}
HXNetSource::~HXNetSource()
{
DoCleanup();
HX_DELETE(m_pPACInfoList);
HX_VECTOR_DELETE(m_pHost);
HX_VECTOR_DELETE(m_pPath);
HX_VECTOR_DELETE(m_pResource);
HX_VECTOR_DELETE(m_pCloakPortList);
HX_VECTOR_DELETE(m_pszReconnectServer);
HX_VECTOR_DELETE(m_pszReconnectProxy);
HX_VECTOR_DELETE(m_pszReconnectURL);
HX_VECTOR_DELETE(m_pszRedirectServer);
HX_VECTOR_DELETE(m_pszRedirectResource);
HX_VECTOR_DELETE(m_pszRedirectURL);
HX_RELEASE(m_pProtocolStatus);
HX_RELEASE(m_pCookies);
HX_RELEASE(m_pCookies2);
HX_RELEASE(m_pPreferredTransport);
HX_RELEASE(m_pPreferredTransportManager);
HX_RELEASE(m_pPAC);
HX_TRACE("HXNetSource::~HXNetSource");
}
HX_RESULT
HXNetSource::DoCleanup(EndCode endCode)
{
HX_TRACE("HXNetSource::DoCleanup");
if (m_pBufferCtl)
{
m_pBufferCtl->Close();
}
HX_RELEASE(m_pBufferCtl);
HX_RELEASE(m_pWMBufferCtl);
m_srcEndCode = endCode;
#if defined(HELIX_FEATURE_PAC)
if (NETSRC_PACPENDING == m_state)
{
m_state = NETSRC_READY;
m_pPAC->AbortProxyInfo(this);
}
#endif /* HELIX_FEATURE_PAC */
#if defined(HELIX_FEATURE_SMARTERNETWORK)
// notify the failure of transport detection
if (m_pPreferredTransport)
{
m_pPreferredTransport->RemoveTransportSink(this);
if (m_pPlayer && m_pHost && m_prefTransportState != PTS_READY)
{
m_pPreferredTransport->RemoveTransport();
HX_RELEASE(m_pPreferredTransport);
}
}
#endif /* HELIX_FEATURE_SMARTERNETWORK */
// sends the stats
if (m_pProto)
{
// log stop action
LogInformation("STOP", NULL);
if (m_bSendStatistics)
{
m_pProto->send_statistics(m_ulSendStatsMask);
}
}
HXSource::DoCleanup(endCode);
cleanup_proxy();
/* UnRegister any previously registered source */
if (m_pSourceInfo)
{
m_pSourceInfo->UnRegister();
}
// Close down the net connection
if (m_pProto)
{
m_pProto->stop();
HX_RELEASE (m_pProto);
}
// cleanup the log list
if (m_pLogInfoList)
{
while (m_pLogInfoList->GetCount() > 0)
{
char* pszInfo = (char*) m_pLogInfoList->RemoveHead();
delete [] pszInfo;
}
HX_DELETE(m_pLogInfoList);
}
if (m_pReconnectCallback)
{
m_pReconnectCallback->CancelCallback();
HX_RELEASE(m_pReconnectCallback);
}
#if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
if (m_pStatsCallback)
{
m_pStatsCallback->CancelCallback();
HX_RELEASE(m_pStatsCallback);
}
#endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
#if defined(HELIX_FEATURE_PAC)
while (m_pPACInfoList && m_pPACInfoList->GetCount())
{
PACInfo* pPACInfo = (PACInfo*)m_pPACInfoList->RemoveHead();
HX_DELETE(pPACInfo);
}
#endif /* HELIX_FEATURE_PAC */
return HXR_OK;
}
/////////////////////////////////////////////////////////////////////////
// Method:
// IUnknown::QueryInterface
// Purpose:
// Implement this to export the interfaces supported by your
// object.
//
STDMETHODIMP
HXNetSource::QueryInterface(REFIID riid, void** ppvObj)
{
if (HXSource::QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
else if (IsEqualIID(riid, IID_IHXRegistryID))
{
AddRef();
*ppvObj = (IHXRegistryID*)this;
return HXR_OK;
}
else if (IsEqualIID(riid, IID_IHXPreferredTransportSink))
{
AddRef();
*ppvObj = (IHXPreferredTransportSink*)this;
return HXR_OK;
}
else if (m_pBufferCtl &&
m_pBufferCtl->QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
else if (m_pProto &&
m_pProto->QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
else if (m_pPlayer &&
m_pPlayer->QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
// we don't have m_pPlayer during AutoConfig
else if (m_pEngine &&
m_pEngine->QueryInterface(riid, ppvObj) == HXR_OK)
{
return HXR_OK;
}
*ppvObj = NULL;
return HXR_NOINTERFACE;
}
/////////////////////////////////////////////////////////////////////////
// Method:
// IUnknown::AddRef
// Purpose:
// Everyone usually implements this the same... feel free to use
// this implementation.
//
STDMETHODIMP_(ULONG32)
HXNetSource::AddRef()
{
return InterlockedIncrement(&m_lRefCount);
}
/////////////////////////////////////////////////////////////////////////
// Method:
// IUnknown::Release
// Purpose:
// Everyone usually implements this the same... feel free to use
// this implementation.
//
STDMETHODIMP_(ULONG32)
HXNetSource::Release()
{
if (InterlockedDecrement(&m_lRefCount) > 0)
{
return m_lRefCount;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -