hxntsrc.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:16k
源码类别:

Symbian

开发平台:

C/C++

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