hxntsrc.h
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:16k
源码类别:

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: hxntsrc.h,v 1.15.2.1 2004/07/09 02:05:57 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #ifndef _HX_NET_SOURCE_
  50. #define _HX_NET_SOURCE_
  51. struct IHXPacket;
  52. struct IHXPendingStatus;
  53. #include "hxpac.h"
  54. #include "pacutil.h"
  55. #include "ihxcookies.h"
  56. #include "ihxcookies2.h"
  57. #include "hxbsrc.h"
  58. #include "hxsrc.h"
  59. #include "hxprotocol.h"
  60. #include "hxstrutl.h"
  61. #include "hxbufctl.h"
  62. typedef enum
  63. {
  64.     NETSRC_READY,
  65.     // PAC
  66.     NETSRC_PACREADY,
  67.     NETSRC_PACPENDING,
  68.     // Preferred Transport
  69.     NETSRC_TRANSPORTREADY,
  70.     NETSRC_TRANSPORTPENDING,
  71.     // Reconnect
  72.     NETSRC_RECONNECTSTARTED,
  73.     NETSRC_RECONNECTPENDING,
  74.     NETSRC_RECONNECTFORCED
  75. } NetSourceState;
  76. typedef enum
  77. {
  78.     PUSHDOWN_NONE = 0,
  79.     PUSHDOWN_AUDIO_DONE,
  80.     PUSHDOWN_VIDEO_DONE,
  81.     PUSHDOWN_ALL_DONE
  82. } PushDownStatus;
  83. class ReconnectCallback;
  84. class HXNetSource :  public HXSource
  85.      ,public IHXPreferredTransportSink
  86.      ,public IHXProxyAutoConfigCallback
  87. {
  88. public:
  89. HXNetSource(void);
  90. STDMETHOD(QueryInterface) (THIS_
  91. REFIID riid,
  92. void** ppvObj);
  93. STDMETHOD_(ULONG32,AddRef) (THIS);
  94. STDMETHOD_(ULONG32,Release) (THIS);
  95. // IHXPendingStatus methods
  96. /************************************************************************
  97. * Method:
  98. *     IHXPendingStatus::GetStatus
  99. * Purpose:
  100. *     Called by the user to get the current pending status from an object
  101. */
  102. STDMETHOD(GetStatus) (THIS_
  103. REF(UINT16) uStatusCode, 
  104. REF(IHXBuffer*) pStatusDesc, 
  105. REF(UINT16) ulPercentDone);
  106. /*
  107.  * IHXRegistryID methods
  108.  */
  109. /************************************************************************
  110.  * Method:
  111.  *     IHXRegistryID::GetID
  112.  * Purpose:
  113.  *     Get registry ID(hash_key) of the objects(player, source and stream)
  114.  *
  115.  */
  116. STDMETHOD(GetID) (THIS_
  117. REF(UINT32) /*OUT*/  ulRegistryID);
  118. /************************************************************************
  119.  * Method:
  120.  *     IHXInfoLogger::LogInformation
  121.  * Purpose:
  122.  *     Logs any user defined information in form of action and 
  123.  *     associated data.
  124.  */
  125. STDMETHOD(LogInformation)     (THIS_
  126.     const char* /*IN*/ pAction,
  127.     const char* /*IN*/ pData);
  128. /*
  129.  * IHXPreferredTransportSink methods
  130.  */
  131. STDMETHOD(TransportSucceeded)     (TransportMode /* IN */   prefTransportType,
  132.     UINT16 /* IN */   uCloakPort);
  133. STDMETHOD(TransportFailed)     (THIS);
  134. HX_RESULT Setup(  const char* host, 
  135. const char* resource,
  136. UINT16  port, 
  137. BOOL  LossCorrection,
  138. const CHXURL* pURL,
  139. BOOL bAltURL);
  140.         /************************************************************************
  141.          * Method:
  142.          *     IHXSourceBufferingStats::GetCurrentBuffering
  143.          * Purpose:
  144.          *     Get the current buffering information
  145.          */
  146.         STDMETHOD(GetCurrentBuffering) (THIS_ 
  147.                                         UINT16  uStreamNumber,
  148.                                         REF(INT64)  llLowestTimestamp, 
  149.                                         REF(INT64)  llHighestTimestamp,
  150.                                         REF(UINT32) ulNumBytes,
  151.                                         REF(BOOL)   bDone);
  152. /*
  153.  *  IHXProxyAutoConfigCallback methods
  154.  */
  155. /************************************************************************
  156. *  Method:
  157. *      IHXProxyAutoConfigCallback::GetProxyInfoDone
  158. *  Purpose:
  159. */
  160. STDMETHOD(GetProxyInfoDone) (THIS_
  161. HX_RESULT   status,
  162. char*     pszProxyInfo);
  163. HXNetSource(HXPlayer* player);
  164.         virtual HX_RESULT DoCleanup(EndCode endCode = END_STOP);
  165. virtual HX_RESULT DoSeek(ULONG32 seekTime);
  166. virtual HX_RESULT DoPause(void);
  167. virtual HX_RESULT DoResume(void);
  168. virtual HX_RESULT StartInitialization(void);
  169. virtual UINT16 GetNumStreams(void);
  170. virtual HX_RESULT GetStreamInfo(ULONG32 ulStreamNumber,
  171.       STREAM_INFO*& theStreamInfo);
  172. virtual HX_RESULT GetEvent(UINT16 usStreamNumber, CHXEvent*& theEvent);
  173. ////// Interface to the Protocol object...
  174. virtual HX_RESULT FileHeaderReady(IHXValues* pHeader);
  175. virtual HX_RESULT TACInfoFromHeader(IHXValues* pValues);
  176.         BOOL CanSendToDataCallback(IHXPacket* packet) const;
  177. virtual HX_RESULT DataCallback(IHXPacket* packet);
  178. virtual HX_RESULT HeaderCallback(IHXValues* header);
  179. // tell about end of source...
  180. virtual void SetEndOfClip(BOOL bForcedEndofClip = FALSE);
  181. // The protocol object needs to know the current playback time
  182. // for a retry()
  183. virtual ULONG32 GetCurrentPlayTime(void);
  184. // set various options received from server...
  185. virtual HX_RESULT SetOption(UINT16 option, void* value);
  186. virtual HX_RESULT SetCookie(IHXBuffer* pCookie);
  187. // for auto transport switch... protocol object needs to tell
  188. // what protocol are we actually using to get data...
  189. virtual HX_RESULT TransportStarted(TransportMode mode);
  190. virtual HX_RESULT HandleRetry(char* pszHost, UINT16 ulPort);
  191. virtual BOOL CheckTransportTimeout(ULONG32 ulTime);
  192. ////// End of Interface to the Protocol object...
  193. virtual BOOL IsLocalSource() { return FALSE; };
  194. virtual BOOL IsPNAProtocol()  {return (BOOL) (!m_bRTSPProtocol);};
  195. virtual void StartDataWait(BOOL bConnectionWait = FALSE);
  196. virtual void StopDataWait();
  197. virtual void FirstDataArrives();
  198. HX_RESULT SetRedirectURL(char* pHost, UINT16 nPort, char* pPath, CHXURL* pURL);
  199. HX_RESULT SetReconnectInfo(IHXValues* pValues);
  200.         BOOL IsSourceDone(void);
  201. BOOL IsPlaying();
  202. void SetNoLatency();
  203. void EnterBufferedPlay(void);
  204. void LeaveBufferedPlay(void);
  205. void statistics_cat(char* stats,LONG32 Data);
  206. void Initialize();
  207. void SetAuthenicationInfo(const char* pszUserName, const char* pszPassword)
  208. {
  209.     memset(m_szUserName, 0, MAX_DISPLAY_NAME);
  210.     memset(m_szPassword, 0, MAX_DISPLAY_NAME);
  211.     if (pszUserName) SafeStrCpy(m_szUserName, pszUserName, MAX_DISPLAY_NAME);
  212.     if (pszPassword) SafeStrCpy(m_szPassword, pszPassword, MAX_DISPLAY_NAME);
  213. };
  214. void GetAuthenicationInfo(char** pszUserName, char** pszPassword)
  215.      {
  216.     *pszUserName = &m_szUserName[0];
  217.     *pszPassword = &m_szPassword[0];
  218.     m_bResendAuthenticationInfo = FALSE;
  219. };
  220. BOOL IsAuthenticationInfoResended(void)
  221. {
  222.     return m_bResendAuthenticationInfo;
  223. };
  224. void AdjustClipBandwidthStats(BOOL bActivate = FALSE);
  225. BOOL CanBeResumed(void);
  226. virtual HX_RESULT UpdateRegistry(UINT32 ulRegistryID);
  227. virtual void LeavePrefetch(void);
  228. virtual BOOL IsPrefetchDone(void) { return !m_bPrefetch; };
  229. virtual void EnterFastStart(void);
  230. virtual void LeaveFastStart(TurboPlayOffReason leftReason);
  231. virtual BOOL CanBeFastStarted(void);
  232. virtual HX_RESULT FillRecordControl();
  233. protected:
  234. virtual  ~HXNetSource(void);
  235. PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
  236. HX_RESULT UpdateStatistics(void);
  237. HX_RESULT _ProcessIdle(BOOL atInterrupt = 0);
  238. virtual HX_RESULT   _ProcessIdleExt(BOOL atInterrupt = 0);
  239. virtual HX_RESULT   PreFileHeaderReadyExt(IHXValues* pHeader);
  240. virtual HX_RESULT   PostFileHeaderReadyExt(void);
  241. virtual HX_RESULT   PreHeaderCallbackExt(IHXValues* theHeader);
  242. virtual HX_RESULT   PostHeaderCallbackExt(IHXValues* theHeader);
  243. HX_RESULT     ReadPreferences(void);
  244. HX_RESULT     CreateProtocol();
  245. HX_RESULT InitializeProtocol(void);
  246. HX_RESULT set_proxy(const char* proxy,UINT16 port);
  247. HX_RESULT cleanup_proxy(void);
  248. HX_RESULT _Initialize(void);
  249. void CalculateCurrentBuffering(void);
  250. UINT32 AdjustEventTime(STREAM_INFO* pStreamInfo, UINT32 ulTime);
  251.         void ReBuffer(void);
  252. void ResetASMSource(void);
  253. BOOL IsInCloakPortList(UINT16 uPort);
  254. BOOL IsPrefetchEnded(void);
  255. HX_RESULT IsFaststartPushdownFullfilled(REF(UINT16) uStatusCode, 
  256.       REF(UINT16) ulPercentDone);
  257. BOOL IsRARVSource(void);
  258. HX_RESULT GetEventFromProtocol(UINT16 usStreamNumber, CHXEvent*& theEvent);
  259. HX_RESULT GetEventFromRecordControl(UINT16 usStreamNumber, CHXEvent*& theEvent);
  260. // stream thinning
  261. BOOL mServerSelRecordSupport;
  262. BOOL mInterframeControlSupport;
  263. BOOL mServerHasBandwidthReport;
  264. BOOL mServerHasFrameControl;
  265. // setup parameters...
  266. char* m_pHost;
  267. char* m_pPath;
  268. char* m_pResource;
  269. UINT16 m_uPort;
  270. // proxy stuff
  271. char* m_pProxy; // host string of proxy
  272. UINT16 m_uProxyPort; // host port of proxy
  273. BOOL m_bUseProxy; // == 1, connect to proxy first
  274. char mClientID[64]; /* Flawfinder: ignore */
  275. CHXSimpleList* m_pUDPPortList;
  276. HXProtocol* m_pProto;
  277. ULONG32 m_ulStartBuffering;
  278. ULONG32 m_ulServerTimeOut;
  279. ULONG32 m_ulConnectionTimeout;
  280. float m_fReBufferPercent;
  281. // level 1, 2 stats
  282. INT32 m_lRAStreamNumber;
  283. // level 3 stats
  284. CHXSimpleList* m_pLogInfoList;
  285. UINT32 m_ulLogInfoLength;
  286. // authenication info.
  287. char m_szUserName[MAX_DISPLAY_NAME]; /* Flawfinder: ignore */
  288. char m_szPassword[MAX_DISPLAY_NAME]; /* Flawfinder: ignore */
  289. UINT16 m_uLastBuffering;
  290.         UINT16          m_uLastStatusCode;
  291. ULONG32 m_ulPerfectPlayDownloadTime;
  292. // reconnect information
  293. BOOL m_bAttemptReconnect;
  294. char* m_pszReconnectServer;
  295. char* m_pszReconnectProxy;
  296. char* m_pszReconnectURL;
  297. UINT32 m_ulReconnectProxyPort;
  298. UINT32 m_ulReconnectServerPort;
  299. // redirect information
  300. char* m_pszRedirectServer;
  301. char* m_pszRedirectResource;
  302. char* m_pszRedirectURL;
  303. UINT32 m_ulRedirectServerPort;
  304. IHXPendingStatus* m_pProtocolStatus;
  305. IHXCookies* m_pCookies;
  306. IHXCookies2* m_pCookies2;
  307. //////////////////////////////////////////////
  308. // Automatic Transport Switching Support...
  309. public:
  310.         ULONG32 m_ulUDPTimeout;
  311. protected:
  312. ULONG32 m_ulMulticastTimeout;
  313. UINT32 m_ulTCPTimeout;
  314. ULONG32 m_ulStartDataWait;
  315. ULONG32 m_ulFirstDataArrives;
  316. ULONG32 m_ulSendStatsMask;
  317. ULONG32 m_ulStatsInterval;
  318. UINT32 m_ulSeekPendingTime;
  319. UINT32 m_ulServerVersion;
  320. UINT32 m_ulTransportPrefMask;
  321.         UINT16          m_uProtocolType;
  322. TransportMode m_PreferredTransport;
  323. TransportMode m_CurrentTransport;
  324. HX_BITFIELD m_bLossCorrection : 1;
  325. HX_BITFIELD m_bAltURL : 1;
  326. HX_BITFIELD m_bRTSPProtocol : 1;
  327. HX_BITFIELD m_bDataWaitStarted : 1;
  328. HX_BITFIELD m_bConnectionWait : 1;
  329. BOOL         m_bSendStatistics;
  330. BOOL     m_bUseUDPPort;
  331. HX_BITFIELD m_bResendAuthenticationInfo : 1;
  332. HX_BITFIELD m_bTimeBased : 1;
  333. HX_BITFIELD m_bUserHasCalledResume : 1;
  334. HX_BITFIELD m_bUserHasCalledStartInit : 1;
  335. HX_BITFIELD m_bAtInterrupt : 1;
  336. HX_BITFIELD m_bBruteForceReconnected : 1;
  337. HX_BITFIELD m_bBruteForceConnectToBeDone : 1;
  338. HX_BITFIELD m_bReconnect : 1;
  339. BOOL     m_bNoLatency;
  340. HX_BITFIELD m_bNoLatencySet : 1;
  341. HX_BITFIELD m_bPerfectPlayPreferenceRead : 1;
  342. BOOL     m_bPerfectPlayErrorChecked;
  343. HX_BITFIELD m_bServerHasPerfectPlay : 1;
  344. HX_BITFIELD m_bServerHasResend : 1;
  345. HX_BITFIELD m_bInRetryMode : 1;
  346. HX_BITFIELD m_bPushDownSet : 1;
  347. HX_BITFIELD m_bRARVSource : 1;
  348. HX_BITFIELD m_bRARVSourceVerified : 1;
  349. PushDownStatus m_pushDownStatus;
  350. BOOL m_bForcePerfectPlay;
  351. BOOL m_bServerHasTransportSwitching;
  352. BOOL m_bSeekPending;
  353. UINT16* m_pCloakPortList;
  354. UINT8 m_nNumberOfCloakPorts;
  355. UINT8 m_nCurrPortIdx;
  356. UINT16 m_uCurrCloakedPort;
  357. PreferredTransportState m_prefTransportState;
  358. IHXPreferredTransport* m_pPreferredTransport;
  359. IHXPreferredTransportManager* m_pPreferredTransportManager;
  360. ReconnectCallback* m_pReconnectCallback;
  361. #if defined(HELIX_FEATURE_STATS) && defined(HELIX_FEATURE_REGISTRY)
  362. ReconnectCallback* m_pStatsCallback;
  363. #endif /* HELIX_FEATURE_STATS && HELIX_FEATURE_REGISTRY */
  364. // PAC
  365. IHXProxyAutoConfig* m_pPAC;
  366. CHXSimpleList* m_pPACInfoList;
  367. LISTPOSITION m_PACInfoPosition;
  368. NetSourceState m_state;
  369. friend class ReconnectCallback;
  370. private:
  371.         IHXBufferControl*                m_pBufferCtl;
  372.         IHXWatermarkBufferControl*       m_pWMBufferCtl;
  373. public:
  374. HX_RESULT FinishSetup();
  375. void ReSetup();
  376. void Reset();
  377.     
  378. char* GetAltURL(BOOL& bDefault);
  379. HX_RESULT switch_out_of_perfectplay();
  380. HX_RESULT handleTransportSwitch(void);
  381. HX_RESULT handleProxySwitch(HX_RESULT inError);
  382. HX_RESULT handleRedirect(void);
  383. HX_RESULT handleReconnect(void);
  384. BOOL IsNetworkAvailable();
  385. HX_RESULT AttemptReconnect();
  386. HX_RESULT StartReconnect();
  387. HX_RESULT ReportStats();
  388. HX_RESULT ProcessReconnect(STREAM_INFO* pStreamInfo);
  389. HX_RESULT EndReconnect();
  390. HX_RESULT AddToPreReconnectEventList(STREAM_INFO* pStreamInfo, CHXEvent* pEvent);
  391. void UpdateReconnectInfo(UINT32 ulPacketTime, 
  392.     BOOL& bFirstEvent,
  393.     UINT32& ulPrevPacketTime,
  394.     UINT32& ulLargestGapInPacketTime,
  395.     UINT32& ulLastPacketTime);
  396. char* GetHost() {return m_pHost;};
  397. INT32 GetRAStreamNumber()
  398. {
  399.     return m_lRAStreamNumber;
  400. };
  401. UINT32 GetFirstDataArriveTime()
  402. {
  403.     return m_ulFirstDataArrives;
  404. };
  405. UINT32 GetLogInfo(CHXSimpleList*& pLogInfoList)
  406. {
  407.     pLogInfoList = m_pLogInfoList;
  408.     return m_ulLogInfoLength;
  409. };
  410. void ReportError (HX_RESULT theErr);
  411. HX_RESULT switch_to_next_transport(HX_RESULT incomingError);
  412. void set_transport(TransportMode mode);
  413. void WritePerfectPlayToRegistry();
  414. void CreateCloakedPortList();
  415. };
  416. class ReconnectCallback : public IHXCallback
  417. {
  418. public:
  419.     HXNetSource* m_pSource;
  420.     CallbackHandle m_PendingHandle;
  421.     BOOL m_bIsStatsReportingCallback;
  422.     IHXScheduler* m_pScheduler;
  423.     UINT32 m_ulScheduleTime;
  424.     UINT32 m_ulTimeout;
  425.     BOOL m_bPaused;
  426. ReconnectCallback(HXNetSource* pSource, 
  427.   BOOL bIsStatsCallback = FALSE);
  428.     HX_RESULT ScheduleCallback(UINT32 uTimeout);
  429.     HX_RESULT PauseCallback();
  430.     HX_RESULT ResumeCallback();
  431.     HX_RESULT CancelCallback();
  432.     BOOL IsPaused() {return m_bPaused;};
  433.     /*
  434.      * IUnknown methods
  435.      */
  436.     STDMETHOD(QueryInterface) (THIS_
  437.     REFIID riid,
  438.     void** ppvObj);
  439.     STDMETHOD_(ULONG32,AddRef) (THIS);
  440.     STDMETHOD_(ULONG32,Release) (THIS);
  441.     /*
  442.      * IHXCallback methods
  443.      */
  444.     STDMETHOD(Func) (THIS);
  445. protected:
  446. ~ReconnectCallback();
  447.     LONG32 m_lRefCount;
  448. };
  449. #endif // _HX_NET_SOURCE