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

Symbian

开发平台:

Visual C++

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