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

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 _RTSPCLNT_H_
  36. #define _RTSPCLNT_H_
  37. #include "rtspif.h"
  38. #include "rtspbase.h"
  39. #include "rtsptran.h"
  40. #include "rtptran.h"
  41. #include "rtspmdsc.h"
  42. #include "sdptypes.h" // SdpFileType
  43. #include "hxpreftr.h"
  44. #include "hxbufctl.h" // IHXTransportBufferLimit
  45. #include "hxrtsp2.h"
  46. class RTSPClientState;
  47. class RTSPOptionsMessage;
  48. class RTSPTeardownMessage;
  49. class RTSPGetParamMessage;
  50. class RTSPSetParamMessage;
  51. class RTSPSetupMessage;
  52. class RTSPAnnounceMessage;
  53. class RTSPPlayMessage;
  54. class RTSPRedirectMessage;
  55. class RTSPParser;
  56. class RTSPClientProtocol;
  57. class CByteGrowingQueue;
  58. class HXMutex;
  59. class MIMEHeader;
  60. struct IHXKeyValueList;
  61. struct IHXValues;
  62. struct IHXStreamDescription;
  63. struct IHXPacket;
  64. struct IHXConnectionlessControl;
  65. struct IHXInterruptState;
  66. #if defined(HELIX_CONFIG_NOSTATICS)
  67. #include "globals/hxglobalptr.h"
  68. #define RTSPClientSessionManagerType const RTSPClientSessionManager* const
  69. #else
  70. #define RTSPClientSessionManagerType RTSPClientSessionManager*
  71. #endif /* defined(HELIX_CONFIG_NOSTATICS) */
  72. typedef enum
  73. {    
  74.     ALTERNATE_SERVER,
  75.     ALTERNATE_PROXY
  76. } ReconnectType;
  77. typedef enum
  78. {
  79.     ENTER_PREFETCH = 0,
  80.     LEAVE_PREFETCH,
  81.     ENTER_FASTSTART,
  82.     LEAVE_FASTSTART,
  83.     PAUSE_BUFFER,
  84.     RESUME_BUFFER
  85. } TRANSPORT_MSG;
  86. typedef struct _ReconnectInfo
  87. {
  88.     CHXString m_server;
  89.     UINT32 m_ulPort;
  90. } ReconnectInfo;
  91. typedef struct _RTSPClientProtocolInfo
  92. {
  93.     RTSPClientProtocol* m_pProt;
  94.     CHXSimpleList m_seqNoList;
  95.     CHXMapLongToObj     m_interleaveMap;
  96. } RTSPClientProtocolInfo;
  97. typedef enum _RTSPIndex
  98. {
  99.     SETUP     = 0,
  100.     REDIRECT     = 1,
  101.     PLAY     = 2,
  102.     PAUSE     = 3,
  103.     SET_PARAM     = 4,
  104.     GET_PARAM     = 5,
  105.     OPTIONS     = 6,
  106.     DESCRIBE     = 7, 
  107.     TEARDOWN     = 8,
  108.     RECORD     = 9,
  109.     ANNOUNCE     = 10
  110. } RTSPIndex;
  111. const UINT32 RTSP_TABLE_SIZE = 11;
  112. struct RTSPTableEntry
  113. {
  114.     const char* pMethod;
  115.     RTSPIndex index;
  116. };
  117. class RTSPTransportInfo
  118. {
  119. public:
  120.     RTSPTransportInfo           ();
  121.     ~RTSPTransportInfo          ();
  122.     BOOL containsStreamNumber (UINT16 streamNumber);
  123.     void addStreamNumber (UINT16 streamNumber);
  124.     RTSPTransport*              m_pTransport;
  125.     RTCPBaseTransport* m_pRTCPTransport;
  126.     UINT16                      m_sPort;
  127.     UINT16                      m_sResendPort;
  128. private:
  129.     CHXSimpleList               m_streamNumberList;
  130. };
  131. class RTSPTransportRequest
  132. {
  133. public:
  134.     RTSPTransportRequest        (RTSPTransportTypeEnum tType, UINT16 sPort);
  135.     ~RTSPTransportRequest       ();
  136.     HX_RESULT addTransportInfo  (RTSPTransport* pTransport, 
  137. RTCPBaseTransport* pRTCPTransport,
  138. UINT16 streamNumber,
  139. UINT16 sPort);
  140.     RTSPTransportInfo* getTransportInfo(UINT16 streamNumber);
  141.     void ResetTransports();
  142.     RTSPTransportInfo* getFirstTransportInfo();
  143.     RTSPTransportInfo* getNextTransportInfo();
  144.     RTSPTransportTypeEnum       m_lTransportType;
  145.     UINT16                      m_sPort;
  146.     UINT16 m_sResendPort;
  147.     INT8 m_tcpInterleave;
  148.     BOOL m_bDelete;
  149. private:
  150.     CHXSimpleList               m_transportInfoList;
  151.     LISTPOSITION m_lListPos;
  152. };
  153. class RTSPClientSession : public IHXTCPResponse, 
  154.   public IHXInterruptSafe
  155. {
  156. public:
  157.     RTSPClientSession     ();
  158.     virtual ~RTSPClientSession     ();
  159.     HX_RESULT Done     ();
  160.     HX_RESULT Init     (IUnknown* pContext,
  161.      RTSPClientProtocol* pProt,
  162.      const char* pHostName,
  163. UINT16 uPort, 
  164. UINT32 ulActualAddr,
  165. BOOL bUseProxy,
  166. BOOL bHTTPCloak,
  167. UINT16 uCloakPort);
  168.     /*
  169.      * IUnknown methods
  170.      */
  171.     STDMETHOD(QueryInterface)           (THIS_
  172. REFIID riid,
  173. void** ppvObj);
  174.     STDMETHOD_(ULONG32,AddRef)          (THIS);
  175.     STDMETHOD_(ULONG32,Release)         (THIS);
  176.     /*
  177.      *  IHXTCPResponse methods
  178.      */
  179.     STDMETHOD(ConnectDone)              (THIS_
  180. HX_RESULT status);
  181.     STDMETHOD(ReadDone)                 (THIS_
  182. HX_RESULT status,
  183. IHXBuffer* pBuffer);
  184.     STDMETHOD(WriteReady)               (THIS_
  185. HX_RESULT status);
  186.     STDMETHOD(Closed)                   (THIS_
  187. HX_RESULT status);
  188.     /*
  189.      * IHXInterruptSafe methods
  190.      */
  191.     STDMETHOD_(BOOL,IsInterruptSafe) (THIS) {return TRUE;};
  192.     HX_RESULT addProtocol     (RTSPClientProtocol* pProt);
  193.     HX_RESULT removeProtocol     (RTSPClientProtocol* pProt);
  194.     int getProtocolCount     ();
  195.     HX_RESULT setProtocolInterleave     (RTSPClientProtocol* pProt, 
  196.     INT8 interleave);
  197.     HX_RESULT setProtocolSeqNo     (RTSPClientProtocol* pProt, 
  198.     UINT32 seqNo);
  199.     HX_RESULT removeProtocolSeqNo     (RTSPClientProtocol* pProt,
  200.     UINT32 seqNo);
  201.     BOOL isEmpty     ();
  202.     IHXTCPSocket* getSocket     ();
  203.     HX_RESULT closeSocket     ();
  204.     HX_RESULT reopenSocket     (RTSPClientProtocol* pProt);
  205.     UINT32 getNextSeqNo     (RTSPClientProtocol* pProt);
  206.     BOOL HttpOnly     ();
  207.     BOOL     m_bIgnoreSession;
  208.     BOOL     m_bUseProxy;
  209.     char*     m_pForeignHost;
  210.     UINT16     m_uForeignPort;
  211.     UINT32     m_ulActualAddr;
  212.     char*     m_pActualHost;
  213.     UINT16     m_uActualPort;
  214.     UINT16     m_uCloakPort;
  215.     BOOL     m_bReopenSocket;
  216.     IUnknown*     m_pContext;
  217.     BOOL     m_bHTTPOnly;
  218.     BOOL     m_bChallengeDone;
  219.     BOOL     m_bChallengeMet;
  220.     VOLATILE BOOL     m_bIsValidChallengeT;
  221.     void ReportError(HX_RESULT);
  222. private:
  223.     HX_RESULT handleInput     (BYTE* pData, UINT32 dataLen);
  224.     RTSPClientProtocol* 
  225. findProtocolFromInterleave     (INT8 interleave);
  226.     RTSPClientProtocol* 
  227. findProtocolFromSeqNo     (UINT32 seqNo);
  228.     RTSPClientProtocol*
  229. findProtocolFromSessionID     (CHXString* pszSessionID);
  230.     void getSessionID     (RTSPMessage* pMsg, CHXString* pszSessionID);
  231.     IHXNetworkServices*     m_pNetworkServices;
  232.     IHXTCPSocket*     m_pSessionSocket;
  233.     CHXSimpleList     m_protList;
  234.     INT32             m_lRefCount;
  235.     UINT32     m_ulLastSeqNo;
  236.     CByteGrowingQueue*     m_pInQueue;
  237.     RTSPParser*     m_pParser;
  238.     BOOL     m_bSessionDone;
  239.     BOOL     m_bSetSessionCalled;
  240.     // used in Connect/ConnectDone
  241.     RTSPClientProtocol*     m_pConnectingProt;
  242.     HXMutex*     m_pMutex;
  243. };
  244. class RTSPClientSessionManager : public IUnknown
  245. {
  246. public:
  247.      ~RTSPClientSessionManager();
  248.     static RTSPClientSessionManager* instance();
  249.     BOOL isValid () { return SessionManGlobal() != NULL; }
  250.     /*
  251.      * IUnknown methods
  252.      */
  253.     STDMETHOD(QueryInterface)           (THIS_
  254. REFIID riid,
  255. void** ppvObj);
  256.     STDMETHOD_(ULONG32,AddRef)          (THIS);
  257.     STDMETHOD_(ULONG32,Release)         (THIS);
  258.     /*
  259.      * RTSPClientSessionManager methods
  260.      */
  261.     virtual HX_RESULT newSession (IUnknown* pContext,
  262.      RTSPClientProtocol* pProt,
  263.      const char* pHostName,
  264. UINT16 uPort, 
  265. UINT32 ulActualAddr,
  266. BOOL bUseProxy,
  267. BOOL bHTTPOnly,
  268. UINT16 uCloakPort);
  269.     HX_RESULT removeFromSession (RTSPClientProtocol* pProt,
  270. RTSPClientSession* pSessionRemoved);
  271.     RTSPClientSession* 
  272. findSession (UINT32 ulActualAddr,
  273. UINT16 uActualPort,
  274. BOOL bUseProxy,
  275. const char* pForeignHost,
  276. UINT16 uForeignPort,
  277. IUnknown* pContext = NULL);
  278.     CHXSimpleList* getSessionList () { return &m_sessionList; }
  279.     int     getSessionCount ();
  280.     BOOL    MatchPlayerContext (IUnknown* pNewContext, IUnknown* pKnownContext);
  281. protected:
  282. RTSPClientSessionManager();
  283.     static RTSPClientSessionManagerType zm_pSessionManager;
  284.     static RTSPClientSessionManager*& SessionManGlobal();
  285.     HXMutex* m_pMutex;
  286.     CHXSimpleList m_sessionList;
  287. private:
  288.     IHXResolver*         m_pResolver;
  289.     INT32 m_lRefCount;
  290. };
  291. class RTSPClientProtocol: public RTSPBaseProtocol, 
  292.                           public IHXRTSPClientProtocol,
  293.                           public IHXRTSPClientTransportResponse,
  294.                           public IHXPendingStatus,
  295.                           public IHXStatistics,
  296.   public IHXResolverResponse,
  297.   public IHXThinnableSource,
  298.   public IHXPacketResend,
  299.   public IHXInterruptSafe,
  300.   public IHXResendBufferControl,
  301.   public IHXTransportSyncServer,
  302.   public IHXTransportBufferLimit
  303. {
  304. public:
  305.     RTSPClientProtocol ();
  306.     ~RTSPClientProtocol ();
  307.     enum State
  308.     {
  309. INIT,
  310. READY,
  311. PLAYING,
  312. RECORDING
  313.     };
  314.     class UDPResponseHelper: public IHXUDPResponse,
  315.      public IHXInterruptSafe
  316.     {
  317.     private:
  318. LONG32 m_lRefCount;
  319. UINT16 m_nPort;
  320. RTSPClientProtocol*  m_pOwner;
  321.     public:
  322. UDPResponseHelper(RTSPClientProtocol* pParent, UINT16 nPort);
  323. ~UDPResponseHelper();
  324. /* IUnknown Interfaces */
  325. STDMETHOD(QueryInterface) (THIS_
  326. REFIID riid,
  327. void** ppvObj);
  328. STDMETHOD_(ULONG32,AddRef) (THIS);
  329. STDMETHOD_(ULONG32,Release) (THIS);
  330. /*
  331. * IHXInterruptSafe methods
  332. */
  333. STDMETHOD_(BOOL,IsInterruptSafe)(THIS) {return TRUE;};
  334. /*
  335. * IHXUDPSocket methods
  336. */
  337. STDMETHOD(ReadDone) (THIS_
  338.      HX_RESULT status,
  339. IHXBuffer* pBuffer,
  340. UINT32 ulAddr,
  341. UINT16 nPort);
  342.     };
  343.     class ConnectionCheckCallback : public IHXCallback
  344.     {
  345.     public:
  346. ConnectionCheckCallback(RTSPClientProtocol* pOwner);
  347. ~ConnectionCheckCallback();
  348.     /* IUnknown Interfaces */
  349. STDMETHOD(QueryInterface) (THIS_
  350. REFIID riid,
  351. void** ppvObj);
  352. STDMETHOD_(ULONG32,AddRef) (THIS);
  353. STDMETHOD_(ULONG32,Release) (THIS);
  354. STDMETHOD(Func) (THIS);
  355.     private:
  356. LONG32 m_lRefCount;
  357. RTSPClientProtocol*  m_pOwner;
  358.     };
  359. #ifdef _MACINTOSH
  360.     class RTSPClientProtocolCallback : public IHXCallback
  361.     {
  362.     public:
  363. RTSPClientProtocolCallback(RTSPClientProtocol* pOwner);
  364. ~RTSPClientProtocolCallback();
  365.     /* IUnknown Interfaces */
  366. STDMETHOD(QueryInterface) (THIS_
  367. REFIID riid,
  368. void** ppvObj);
  369. STDMETHOD_(ULONG32,AddRef) (THIS);
  370. STDMETHOD_(ULONG32,Release) (THIS);
  371. STDMETHOD(Func) (THIS);
  372. LONG32 m_lRefCount;
  373. RTSPClientProtocol*  m_pOwner;
  374. BOOL m_bIsCallbackPending;
  375. CallbackHandle m_Handle;
  376. IHXValues* m_pPendingRequestHeaders;
  377. CHXString m_PendingDescURL;
  378.     };
  379.     friend class RTSPClientProtocolCallback;
  380. #endif /* _MACINTOSH */
  381.     /*
  382.      * IUnknown methods
  383.      */
  384.     STDMETHOD(QueryInterface)           (THIS_
  385.                                         REFIID riid,
  386.                                         void** ppvObj);
  387.     STDMETHOD_(ULONG32,AddRef)          (THIS);
  388.     STDMETHOD_(ULONG32,Release)         (THIS);
  389.     /*
  390.      * IHXRTSPClientProtocol methods
  391.      */
  392.     STDMETHOD(Init) (THIS_
  393. IUnknown*   pContext,
  394. const char* pHostName,
  395. UINT16     foreignPort,
  396. IHXRTSPClientProtocolResponse* pClient,
  397. UINT32     initializationType,
  398. IHXValues* pSessionHeaders,
  399. IHXValues* pInfo,
  400. BOOL     bHTTPCloak,
  401. UINT16     uCloakPort,
  402. BOOL     bNoReuseConnection);
  403.     STDMETHOD(SetBuildVersion) (THIS_
  404.      const char* pVersionString);
  405.     STDMETHOD(Done) (THIS);
  406.     STDMETHOD(SendStreamDescriptionRequest)
  407. (THIS_
  408.      const char* pURL,
  409. IHXValues* pRequestHeaders);
  410.     STDMETHOD(SendStreamRecordDescriptionRequest)
  411.      (THIS_
  412. const char* pURL,
  413. IHXValues* pFileHeader,
  414. CHXSimpleList* pStreams,
  415. IHXValues* pRequestHeaders);
  416.     STDMETHOD(SendSetupRequest)
  417.     (
  418. THIS_
  419. RTSPTransportType* pTransType,
  420. UINT16 nTransTypes,
  421. IHXValues* pIHXValuesRequestHeaders
  422.     );
  423.     STDMETHOD(SendPlayRequest) (THIS_
  424. UINT32 lFrom,
  425. UINT32 lTo,
  426. CHXSimpleList* pSubscriptions);
  427.     STDMETHOD(SendRecordRequest) (THIS);
  428.     STDMETHOD(SendPauseRequest) (THIS);
  429.     STDMETHOD(SendResumeRequest) (THIS);
  430.     STDMETHOD(SendTeardownRequest) (THIS);
  431.     STDMETHOD(SendSetParameterRequest) (THIS_
  432.      UINT32 lParamType,
  433. const char* pParamName,
  434. IHXBuffer* pParamValue);
  435.     STDMETHOD(SendSetParameterRequest) (THIS_
  436.      const char* pParamName,
  437. const char* pParamValue,
  438. const char* pMimeType,
  439. const char* pContent);
  440.     STDMETHOD(SendGetParameterRequest) (THIS_
  441.      UINT32 lParamType,
  442. const char* pParamName);
  443.     STDMETHOD(SendPacket) (THIS_
  444. BasePacket* pPacket);
  445.     STDMETHOD(SendStreamDone) (THIS_
  446. UINT16 streamNumber);
  447.     STDMETHOD(SendPlayerStats) (THIS_
  448. const char* pStats);
  449.     STDMETHOD(SendKeepAlive) (THIS);
  450.     STDMETHOD(GetPacket) (THIS_
  451. UINT16 uStreamNumber,
  452. REF(IHXPacket*) pPacket);
  453.     STDMETHOD(StartPackets) (THIS_
  454. UINT16 uStreamNumber);
  455.     STDMETHOD(StopPackets) (THIS_
  456. UINT16 uStreamNumber);
  457.     STDMETHOD(SetProxy) (THIS_
  458. const char* pProxyHost,
  459. UINT16 proxyPort);
  460.     STDMETHOD(SetResponse) (THIS_
  461. IHXRTSPClientProtocolResponse* pResp);
  462.     /*
  463.      * IHXThinnableSource methods.
  464.      */
  465.     /************************************************************************
  466.      * Method:
  467.      *     IHXThinnableSource::DropByN
  468.      *  Purpose:
  469.      *
  470.      * Implemented by protocols that allow infinite thinnability through
  471.      *      LimitBandwidthByDropping
  472.      */
  473.     STDMETHOD(LimitBandwidthByDropping) (THIS_
  474. UINT32 ulStreamNo,
  475. UINT32 ulBandwidthLimit);
  476.     STDMETHOD(SetDeliveryBandwidth) (THIS_
  477. UINT32 ulBandwidth,
  478. UINT32 ulMsBackoff);
  479.     /*
  480.      * XXX...The following 3 functions had better be removed under
  481.      *       full IRMA
  482.      */
  483.     STDMETHOD_(IHXPendingStatus*, GetPendingStatus) (THIS);
  484.     STDMETHOD_(IHXStatistics*, GetStatistics) (THIS);
  485.     STDMETHOD_(BOOL, HttpOnly) (THIS);
  486.     STDMETHOD(Subscribe) (THIS_
  487.      CHXSimpleList* pSubscriptions);
  488.     STDMETHOD(Unsubscribe) (THIS_
  489.      CHXSimpleList* pUnsubscriptions);
  490.     STDMETHOD(RuleChange) (THIS_
  491.      CHXSimpleList* pRuleChanges);
  492.     STDMETHOD(BackChannelPacketReady) (THIS_
  493.      IHXPacket* pPacket);
  494.     STDMETHOD(SendRTTRequest) (THIS);
  495.     STDMETHOD(SendBWReport) (THIS_
  496.      INT32 aveBandwidth,
  497. INT32 packetLoss,
  498. INT32 bandwidthWanted);
  499.     STDMETHOD(SetFirstSeqNum) (THIS_
  500. UINT16 uStreamNumber,
  501. UINT16 uSeqNum);
  502.     STDMETHOD(SetRTPInfo) (THIS_
  503. UINT16 uStreamNumber,
  504. UINT16 uSeqNum,
  505. UINT32 ulRTPTime,
  506. RTPInfoEnum info
  507. );
  508.     STDMETHOD(InitSockets) (THIS);
  509.     STDMETHOD(GetCurrentBuffering) (THIS_
  510. UINT16     uStreamNumber,
  511. REF(INT64)  llLowestTimestamp, 
  512. REF(INT64)  llHighestTimestamp,
  513. REF(UINT32) ulNumBytes,
  514. REF(BOOL)   bDone);
  515.     STDMETHOD(SeekFlush) (THIS);
  516.     STDMETHOD_(BOOL, IsDataReceived) (THIS);
  517.     
  518.     STDMETHOD_(BOOL,IsSourceDone) (THIS);
  519.     /*
  520.      * IHXInterruptSafe methods
  521.      */
  522.     STDMETHOD_(BOOL,IsInterruptSafe) (THIS) {return TRUE;};
  523.     /*
  524.      * IHXRTSPClientTransportResponse methods
  525.      */
  526.     STDMETHOD(PacketReady) (THIS_
  527. HX_RESULT status,
  528. const char* pSessionID,
  529. IHXPacket* pPacket);
  530.     STDMETHOD(OnRTTRequest)      (THIS_
  531.                                  HX_RESULT status,
  532. const char* pSessionID
  533. );
  534.     STDMETHOD(OnRTTResponse) (THIS_
  535.      HX_RESULT status,
  536. const char* pSessionID,
  537. UINT32 ulSecs,
  538. UINT32 ulUSecs);
  539.     STDMETHOD(OnBWReport)       (THIS_
  540.                                  HX_RESULT status,
  541. const char* pSessionID,
  542. INT32 aveBandwidth,
  543. INT32 packetLoss,
  544. INT32 bandwidthWanted
  545. );
  546.     STDMETHOD(OnCongestion) (THIS_
  547.      HX_RESULT status,
  548. const char* pSessionID,
  549. INT32 xmitMultiplier,
  550. INT32 recvMultiplier);
  551.     STDMETHOD(OnACK) (THIS_
  552. HX_RESULT status,
  553. RTSPResendBuffer* pResendBuffer,
  554. UINT16 uStreamNumber,
  555. const char* pSessionID,
  556. UINT16* pAckList,
  557. UINT32 uAckListCount,
  558. UINT16* pNakList,
  559. UINT32 uNakListCount);
  560.     STDMETHOD(OnStreamDone) (THIS_
  561. HX_RESULT status,
  562. UINT16 uStreamNumber);
  563.     STDMETHOD(OnSourceDone) (THIS);
  564.     STDMETHOD(OnProtocolError) (THIS_
  565. HX_RESULT status);
  566.     /*
  567.      * IHXPendingStatus methods
  568.      */
  569.     STDMETHOD(GetStatus) (THIS_
  570. REF(UINT16) uStatusCode, 
  571. REF(IHXBuffer*) pStatusDesc, 
  572. REF(UINT16) ulPercentDone);
  573.     /*
  574.      * IHXResolverResponse methods
  575.      */
  576.     STDMETHOD(GetHostByNameDone) (THIS_
  577. HX_RESULT status,
  578. UINT32 ulAddr);
  579.     /*
  580.      * IHXStatistics methods
  581.      */
  582.     STDMETHOD (InitializeStatistics) (THIS_
  583. UINT32 /*IN*/ ulRegistryID);
  584.     STDMETHOD (UpdateStatistics) (THIS);
  585.     STDMETHOD(OnPacket) (THIS_
  586. UINT16 uStreamNumber,
  587. BasePacket** ppPacket);
  588.     STDMETHOD(SetConnectionTimeout) (THIS_
  589. UINT32 uSeconds);
  590.     STDMETHOD_(UINT16, GetProtocolType) (THIS) {return m_uProtocolType;};
  591.     STDMETHOD(InitPacketFilter) (THIS_
  592. RawPacketFilter* pFilter);
  593.     STDMETHOD(SetResendBufferDepth) (THIS_
  594. UINT32 uSeconds);
  595.     /*
  596.      * IHXTransportSyncServer methods
  597.      */
  598.     STDMETHOD(DistributeSyncAnchor) (THIS_
  599.     ULONG32 ulHXTime, 
  600.     ULONG32 ulNTPTime);
  601.     STDMETHOD(DistributeSync)     (ULONG32 ulHXTime, 
  602.     LONG32 lHXTimeOffset);
  603.     STDMETHOD(DistributeStartTime)  (ULONG32 ulHXRefTime);
  604.     /*
  605.      * IHXTransportBufferLimit methods
  606.      */
  607.     /************************************************************************
  608.      * Method:
  609.      *     IHXTransportBufferLimit::SetByteLimit
  610.      * Purpose:
  611.      *      Sets the maximum number of bytes that can be buffered in the
  612.      *      transport buffer. If incomming packets would put us over this
  613.      *      limit, then they are replaced with lost packets. A byte limit
  614.      *      of 0 means unlimited buffering.
  615.      */
  616.     STDMETHOD(SetByteLimit) (THIS_ UINT16 uStreamNumber, 
  617.      UINT32 uByteLimit);
  618.     /************************************************************************
  619.      * Method:
  620.      *     IHXTransportBufferLimit::GetByteLimit
  621.      * Purpose:
  622.      *      Returns the current byte limit in effect. A value of 0 means
  623.      *      unlimited buffering is allowed
  624.      */
  625.     STDMETHOD_(UINT32,GetByteLimit) (THIS_ UINT16 uStreamNumber);
  626.     /*
  627.      *  RTSPClientProtocol public methods
  628.      */
  629.     HX_RESULT(ReadDoneWithToPort) (
  630.      HX_RESULT status,
  631. IHXBuffer* pBuffer,
  632. UINT32 ulAddr,
  633. UINT16 nFromPort,
  634. UINT16 nToPort);
  635.     HX_RESULT HandleUnexpected (RTSPMessage* pMsg);
  636.     HX_RESULT HandleBadVersion (RTSPMessage* pMsg);
  637.     HX_RESULT HandleOptions (RTSPOptionsMessage* pMsg);
  638.     HX_RESULT HandleTeardown (RTSPTeardownMessage* pMsg);
  639.     HX_RESULT HandleGetParam (RTSPGetParamMessage* pMsg);
  640.     HX_RESULT HandleSetParam (RTSPSetParamMessage* pMsg);
  641.     HX_RESULT HandleRedirect (RTSPRedirectMessage* pMsg);
  642.     HX_RESULT HandleUseProxy (RTSPResponseMessage* pMsg);
  643.     void      SessionCreated (RTSPClientSession* pSession);
  644.     void      SessionSucceeded (RTSPClientSession* pSession, 
  645. IHXTCPSocket* pSocket);
  646.     void      SessionFailed (RTSPClientSession* pSession,
  647. IHXTCPSocket* pSocket);
  648.     HX_RESULT InitDone (HX_RESULT status);
  649.     void DoConnectionCheck ();
  650.     void GetForeignHostPort (char*& pHost, UINT16* pPort);
  651.     void SetSplitterConsumer (BOOL);
  652.     void EnterPrefetch (void) { m_bPrefetch = TRUE; };
  653.     void LeavePrefetch (void);
  654.     void EnterFastStart (void);
  655.     void LeaveFastStart (void);
  656.     void InitCloak (UINT16* pCloakPorts, UINT8 nCloakPorts, IHXValues* pValues);
  657.     UINT16 GetCloakPortSucceeded (void);
  658.     HX_RESULT SetStatistics (UINT16 uStreamNumber, STREAM_STATS* pStats);
  659.     BOOL   IsSessionSucceeded()         {return m_bSessionSucceeded;};
  660.     
  661.     HX_RESULT InitExt(IUnknown*   pContext,
  662. const char* pHostName,
  663. UINT16     foreignPort,
  664. IHXRTSPClientProtocolResponse* pClient,
  665. UINT32     initializationType,
  666. IHXValues* pSessionHeaders,
  667. IHXValues* pInfo,
  668. BOOL     bHTTPCloak,
  669. UINT16     uCloakPort,
  670. BOOL     bNoReuseConnection);
  671.     virtual UINT16 GetRDTFeatureLevel(void){ return 0; };
  672.     friend class RTSPClientSession;
  673.     void ReportError( HX_RESULT theErr );
  674. protected:
  675.     HX_RESULT handleMessage (RTSPMessage* pMsg);
  676.     HX_RESULT handleTCPData (BYTE* pData, UINT16 dataLen, UINT16 channel);
  677.     HX_RESULT handleOptionsResponse (RTSPResponseMessage* pMsg);
  678.     HX_RESULT handleGetParamResponse (RTSPResponseMessage* pMsg);
  679.     HX_RESULT handleSetParamResponse (RTSPResponseMessage* pMsg);
  680.     HX_RESULT handleTeardownResponse (RTSPResponseMessage* pMsg);
  681.     HX_RESULT handlePlayResponse (RTSPResponseMessage* pMsg,
  682. RTSPPlayMessage* pPlayMsg);
  683.     HX_RESULT handleRecordResponse (RTSPResponseMessage* pMsg);
  684.     HX_RESULT handlePauseResponse (RTSPResponseMessage* pMsg);
  685.     HX_RESULT handleSetupResponse (RTSPResponseMessage* pMsg,
  686.      RTSPSetupMessage* pSetupMsg);
  687.     HX_RESULT handleDescribeResponse (RTSPResponseMessage* pMsg);
  688.     HX_RESULT handleAnnounceResponse (RTSPResponseMessage* pMsg);
  689.     HX_RESULT HandleRedirectResponse (RTSPResponseMessage* pMsg);   
  690.     HX_RESULT sendInitialMessage (RTSPClientSession* pSession,
  691. IHXTCPSocket* pSocket);
  692.     HX_RESULT addTransportMimeType (MIMEHeaderValue* pValue,
  693. UINT16 streamNumber);
  694.     HX_RESULT sendFirstSetupRequest
  695.     (
  696. IHXValues* pIHXValuesRequestHeaders
  697.     );
  698.     HX_RESULT sendRemainingSetupRequests();
  699.     HX_RESULT sendSetupRequestMessage
  700.     (
  701. RTSPStreamInfo* pStreamInfo,
  702. IHXValues* pIHXValuesRequestHeaders,
  703. BOOL bFirstSetup
  704.     );
  705.     const char* allowedMethods ();
  706.     void messageDebugFileOut            (const char* pMsg, BOOL bIncoming);
  707.     RTSPTransportRequest* getTransportRequest(MIMEHeaderValue* pValue);
  708.     void reset();
  709.     void clearTransportRequestList ();
  710.     void clearStreamInfoList ();
  711.     void clearUDPResponseHelperList ();
  712.     void clearSocketStreamMap(CHXMapLongToObj*& pSocketStreamMap);
  713.     HX_RESULT getStreamDescriptionMimeType  (char*& pMimeType);
  714.     IHXStreamDescription* 
  715.               getStreamDescriptionInstance(const char* pMimeType);
  716.     HX_RESULT closeSocket ();
  717.     HX_RESULT reopenSocket ();
  718.     HX_RESULT ReopenSocketDone (HX_RESULT status);
  719.     HX_RESULT sendPendingStreamDescription(const char* pURL,
  720.    IHXValues* pRequestHeaders);
  721.     // only for [RTP|RDT]/TCP
  722.     void mapTransportChannel (RTSPTransport* pTran, UINT16 nChannel);
  723.     // Interop - control number could be anything...
  724.     void mapControlToStreamNo (const char* pControl, UINT16 uStreamNo);
  725.     BOOL getStreamNoFromControl (const char* pControl, REF(UINT16) uStreamNo);
  726.     void    setSetupRequestURL (RTSPSetupMessage* pMsg, RTSPStreamInfo* );
  727.     RTSPStreamInfo* getStreamInfoFromSetupRequestURL(const char* pUrl);
  728.     /* interop        */
  729.     /* since Allow doesn't deal with encoder stuff, just do it here    */
  730.     /* depending on the result, we will use either old or new sdp file */
  731.     SdpFileType     GetSdpFileTypeWeNeed(IHXValues* pHeaders);
  732.     HX_RESULT       GetStreamDescriptionInfo(IUnknown* pUnknown, CHXString& mimeTypes);
  733.     void            SendMsgToTransport(TRANSPORT_MSG msg);
  734.     void            AddCommonHeaderToMsg(RTSPRequestMessage* pMsg);
  735.     HX_RESULT       SendMsgToServer(RTSPMethod msg);
  736.     HX_RESULT extractRealmInformation(RTSPResponseMessage* pMsg);
  737.     HX_RESULT extractExistingAuthorizationInformation(IHXValues* pIHXValuesRequestHeaders);
  738.     void appendAuthorizationHeaders(/*RTSPDescribeMessage*/ RTSPMessage* pMsg);
  739.     HX_RESULT RetrieveReconnectInfo(MIMEHeader*   pHeader,
  740.       ReconnectType reconnectType,
  741.       IHXValues*&  pReconnectValues);
  742.     HX_RESULT handleAuthentication(RTSPResponseMessage* pMsg);
  743.     HX_RESULT   ParseSDP(const char* pszContentType, IHXBuffer* pSDPBuffer);
  744.     void        RemoveSDPHeaders(void);
  745. #if defined(HELIX_FEATURE_TRANSPORT_MULTICAST)
  746.     BOOL        DetermineIfRMPresentation(IHXValues** ppStrmHeaders,
  747.           UINT32 ulNumStreams);
  748.     BOOL        GetSubscriptionBW(IHXValues*    pFileHeader, 
  749.           IHXValues**   ppStrmHeaders,
  750.           UINT16        unNumStrmHeaders,
  751.           REF(UINT32*)  pulSubscriptionBW,
  752.           UINT32        ulNumStreams);   
  753.     BOOL        GetRightHeaders(REF(IHXValues**)    ppRealHeaders, // out
  754.               UINT32     ulNumStreams,
  755.               IHXValues**     ppHeaders,
  756.               UINT32     cHeaders,
  757.               UINT32*             pulSubscriptionBW);
  758. #endif /* HELIX_FEATURE_TRANSPORT_MULTICAST */
  759.     BOOL        GetStreamCountNoTrust(IHXValues**   ppHeaders, 
  760.       UINT16        unNumHeader,
  761.       REF(UINT32)   ulNumStream);
  762.     HX_RESULT   CreateUDPSockets(UINT32 ulStream, UINT16 ulPort);
  763.     virtual BOOL IsRealServer(void);
  764.     virtual HX_RESULT   RetrieveChallenge(RTSPResponseMessage* pMessage);
  765.     virtual HX_RESULT sendSetupRequestMessageExt(RTSPStreamInfo* pStreamInfo, 
  766.    IHXValues*& pIHXValuesRequestHeaders,
  767.    BOOL bFirstSetup,
  768.    RTSPSetupMessage*& pMsg);
  769.     virtual HX_RESULT handleSetupResponseExt(RTSPStreamInfo* pStreamInfo,
  770.        RTSPResponseMessage* pMsg, 
  771.        RTSPSetupMessage* pSetupMsg);
  772.     virtual HX_RESULT DoSendRTTRequest(void);
  773.     virtual HX_RESULT DoSendBWReport(INT32 aveBandwidth,
  774.        INT32 packetLoss,
  775.        INT32 bandwidthWanted);
  776.     void addUAProfHeaders(IHXValues *pHeaders);
  777.     RTSPTransportBuffer* getTransportBuffer(UINT16 uStreamNumber);
  778.     virtual HX_RESULT sendRequest(RTSPRequestMessage* pMsg, UINT32 seqNo);
  779.     virtual HX_RESULT sendRequest(RTSPRequestMessage* pMsg,
  780.                                     const char* pContent,
  781.                                     const char* pMimeType, UINT32 seqNo);
  782.     LONG32                              m_lRefCount;
  783.     UINT16 m_foreignPort;
  784.     UINT32 m_foreignAddr;
  785.     UINT32                              m_ulConnectToAddr;
  786.     UINT16 m_setupResponseCount;    
  787.     IHXInterruptState* m_pInterruptState;
  788.     IHXRTSPClientProtocolResponse* m_pResp;
  789.     RTSPClientSessionManager* m_pSessionManager;
  790.     RTSPClientSession*  m_pSession;
  791.     RTSPClientProtocol::State m_state;
  792.     IHXScheduler* m_pScheduler;
  793.     IHXValues* m_pSessionHeaders;
  794.     IHXValues* m_pCloakValues;
  795.     IHXKeyValueList* m_pResponseHeaders;
  796.     IHXResolver* m_pResolver;
  797.     IHXRegistry* m_pRegistry;
  798.     CHXString m_versionString;
  799.     CHXString m_url;
  800.     CHXString m_contentBase;
  801.     CHXString m_headerControl;
  802.     CHXString m_challenge;
  803.     CHXString m_hostName;
  804.     CHXString m_proxyHost;
  805.     CHXString                           m_sessionHost;
  806.     UINT16 m_proxyPort;
  807.     UINT16* m_pCloakPorts;
  808.     UINT8 m_nCloakPorts;
  809.     CHXString m_sessionID;
  810.     IHXValues* m_pFileHeader;
  811.     CHXSimpleList m_streamInfoList;
  812.     CHXSimpleList  m_transportRequestList;
  813.     CHXSimpleList m_UDPResponseHelperList;
  814.     CHXSimpleList m_sessionList;
  815.     CHXMapLongToObj* m_pTransportStreamMap; // map streamID->trans
  816.     CHXMapLongToObj* m_pTransportPortMap; // map port->trans
  817.     CHXMapLongToObj* m_pTransportMPortMap; // map multicast port->trans
  818.     CHXMapLongToObj* m_pTransportChannelMap; // map channel->trans (only in TCP)
  819.     CHXMapLongToObj* m_pUDPSocketStreamMap; // map streamID->socket
  820.     CHXMapLongToObj* m_pRTCPSocketStreamMap; // map streamID->socket
  821.     CHXMapStringToOb* m_pControlToStreamNoMap; // streamID->streamNumber
  822.     BOOL m_bSeqValueReceived;
  823.     BOOL m_bSetupRecord;
  824.     BOOL m_bClientDone;
  825.     BOOL                                m_bMessageDebug;
  826.     BOOL m_bUseProxy;
  827.     BOOL m_bUseHTTPProxy;
  828.     BOOL m_bHTTPOnly;
  829.     BOOL m_bNoReuseConnection;
  830.     BOOL m_bLoadTest;
  831.     BOOL m_bKeepLiveResponsed;
  832.     BOOL m_bPrefetch;
  833.     BOOL m_bFastStart;
  834.     BOOL                                m_bPaused;
  835.     BOOL m_bSessionSucceeded;
  836.     IHXConnectionlessControl* m_pConnectionlessControl;
  837.     BOOL m_bConnectionlessControl;
  838.     ConnectionCheckCallback* m_pConnectionCheckCallback;    
  839.     UINT32 m_uConnectionCheckCallbackHandle;
  840.     BOOL m_bConnectionAlive;
  841.     UINT32 m_uConnectionTimeout;
  842.     BOOL m_bEntityRequired;
  843.     UINT16 m_uCloakPort;
  844.     CHXString                           m_messageDebugFileName;
  845.     HXMutex* m_pMutex;
  846.     UINT16 m_uProtocolType;
  847.     TransportMode m_currentTransport;
  848.     UINT32 m_ulBufferDepth;
  849.     BOOL m_bSplitterConsumer;
  850.     RawPacketFilter*  m_pPacketFilter;
  851.     BOOL m_bHasSyncMasterStream;
  852.     IHXNetworkServices*         m_pNetworkServices;
  853.     IHXPreferences* m_pPreferences;
  854.     IHXBuffer* m_pUAProfURI;
  855.     IHXBuffer* m_pUAProfDiff;
  856.     /* Interop */
  857.     
  858.     // TRUE iff a server we are talking is not RS...This implies RTP..
  859.     BOOL m_bNonRSRTP;
  860.     IHXValues* m_pSetupRequestHeader;
  861.     BOOL m_bPlayJustSent;
  862.     BOOL m_bIPTV;
  863.     BOOL m_bColumbia;
  864.     BOOL m_bNoKeepAlive;   
  865.     BOOL m_bForceUCaseTransportMimeType;
  866.     BOOL m_bReportedSuccessfulTransport;
  867.     
  868.     BOOL                                m_bSDPInitiated;
  869.     BOOL                                m_bMulticast;
  870.     UINT32                              m_ulMulticastAddress;
  871.     IHXValues*                          m_pSDPFileHeader;
  872.     CHXSimpleList*                      m_pSDPStreamHeaders;
  873.     BOOL m_pIsMethodSupported[RTSP_TABLE_SIZE];
  874.     static const RTSPTableEntry zm_pRTSPTable[RTSP_TABLE_SIZE];
  875.     class TimeoutCallback : public IHXCallback
  876.     {
  877.     public:
  878. TimeoutCallback(RTSPClientProtocol* pOwner);
  879. ~TimeoutCallback();
  880. STDMETHOD(QueryInterface) (THIS_
  881. REFIID riid,
  882. void** ppvObj);
  883. STDMETHOD_(ULONG32,AddRef) (THIS);
  884. STDMETHOD_(ULONG32,Release) (THIS);
  885. STDMETHOD(Func) (THIS);
  886.     private:
  887. LONG32         m_lRefCount;
  888. RTSPClientProtocol*          m_pOwner;
  889.     };
  890.     CHXKeepAlive*                       m_pSessionTimeout;
  891.     TimeoutCallback*                    m_pTimeoutCallback;
  892.     BOOL                                m_bUseLegacyTimeOutMsg;
  893.     BOOL                                m_bKeepAlivePending;
  894.     UINT32                              m_ulServerTimeOut;
  895.     UINT32                              m_ulCurrentTimeOut;
  896. #if defined(_MACINTOSH)
  897.     RTSPClientProtocolCallback* m_pCallback;
  898. #endif /* _MACINTOSH */
  899. };
  900. #endif /* _RTSPCLNT_H_ */