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

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 _SINKCTL_
  36. #define _SINKCTL_
  37. struct IHXInterruptState;
  38. struct IHXClientEngine;
  39. struct IHXCallback;
  40. struct IHXScheduler;
  41. class  CHXSimpleList;
  42. class  ErrorCallback;
  43. class  CHXGenericCallback;
  44. class CHXAdviseSinkControl : public IHXClientAdviseSink, public IHXInterruptSafe
  45. {
  46. public:
  47.     CHXAdviseSinkControl();
  48.     ~CHXAdviseSinkControl();
  49.     
  50.     /*
  51.      * IUnknown methods
  52.      */
  53.     STDMETHOD(QueryInterface) (THIS_
  54. REFIID riid,
  55. void** ppvObj);
  56.     STDMETHOD_(ULONG32,AddRef) (THIS);
  57.     STDMETHOD_(ULONG32,Release) (THIS);
  58.     /*
  59.      * IHXClientAdviseSink methods
  60.      */
  61.     /************************************************************************
  62.      * Method:
  63.      *     IHXClientAdviseSink::OnPosLength
  64.      * Purpose:
  65.      *     Called to advise the client that the position or length of the
  66.      *     current playback context has changed.
  67.      */
  68.     STDMETHOD(OnPosLength) (THIS_
  69. UINT32   ulPosition,
  70. UINT32   ulLength);
  71.     /************************************************************************
  72.      * Method:
  73.      *     IHXClientAdviseSink::OnPresentationOpened
  74.      * Purpose:
  75.      *     Called to advise the client a presentation has been opened.
  76.      */
  77.     STDMETHOD(OnPresentationOpened) (THIS);
  78.     /************************************************************************
  79.      * Method:
  80.      *     IHXClientAdviseSink::OnPresentationClosed
  81.      * Purpose:
  82.      *     Called to advise the client a presentation has been closed.
  83.      */
  84.     STDMETHOD(OnPresentationClosed) (THIS);
  85.     /************************************************************************
  86.      * Method:
  87.      *     IHXClientAdviseSink::OnStatisticsChanged
  88.      * Purpose:
  89.      *     Called to advise the client that the presentation statistics
  90.      *     have changed. 
  91.      */
  92.     STDMETHOD(OnStatisticsChanged) (THIS);
  93.     /************************************************************************
  94.      * Method:
  95.      *     IHXClientAdviseSink::OnPreSeek
  96.      * Purpose:
  97.      *     Called by client engine to inform the client that a seek is
  98.      *     about to occur. The render is informed the last time for the 
  99.      *     stream's time line before the seek, as well as the first new
  100.      *     time for the stream's time line after the seek will be completed.
  101.      *
  102.      */
  103.     STDMETHOD (OnPreSeek) (THIS_
  104. ULONG32     ulOldTime,
  105. ULONG32     ulNewTime);
  106.     /************************************************************************
  107.      * Method:
  108.      *     IHXClientAdviseSink::OnPostSeek
  109.      * Purpose:
  110.      *     Called by client engine to inform the client that a seek has
  111.      *     just occured. The render is informed the last time for the 
  112.      *     stream's time line before the seek, as well as the first new
  113.      *     time for the stream's time line after the seek.
  114.      *
  115.      */
  116.     STDMETHOD (OnPostSeek) (THIS_
  117. ULONG32     ulOldTime,
  118. ULONG32     ulNewTime);
  119.     /************************************************************************
  120.      * Method:
  121.      *     IHXClientAdviseSink::OnStop
  122.      * Purpose:
  123.      *     Called by client engine to inform the client that a stop has
  124.      *     just occured. 
  125.      *
  126.      */
  127.     STDMETHOD (OnStop) (THIS);
  128.     /************************************************************************
  129.      * Method:
  130.      *     IHXClientAdviseSink::OnPause
  131.      * Purpose:
  132.      *     Called by client engine to inform the client that a pause has
  133.      *     just occured. The render is informed the last time for the 
  134.      *     stream's time line before the pause.
  135.      *
  136.      */
  137.     STDMETHOD (OnPause) (THIS_
  138. ULONG32     ulTime);
  139.     /************************************************************************
  140.      * Method:
  141.      *     IHXClientAdviseSink::OnBegin
  142.      * Purpose:
  143.      *     Called by client engine to inform the client that a begin or
  144.      *     resume has just occured. The render is informed the first time 
  145.      *     for the stream's time line after the resume.
  146.      *
  147.      */
  148.     STDMETHOD (OnBegin) (THIS_
  149. ULONG32     ulTime);
  150.     /************************************************************************
  151.      * Method:
  152.      *     IHXClientAdviseSink::OnBuffering
  153.      * Purpose:
  154.      *     Called by client engine to inform the client that buffering
  155.      *     of data is occuring. The render is informed of the reason for
  156.      *     the buffering (start-up of stream, seek has occured, network
  157.      *     congestion, etc.), as well as percentage complete of the 
  158.      *     buffering process.
  159.      *
  160.      */
  161.     STDMETHOD (OnBuffering) (THIS_
  162. ULONG32     ulFlags,
  163. UINT16     unPercentComplete);
  164.     /************************************************************************
  165.      * Method:
  166.      *     IHXClientAdviseSink::OnContacting
  167.      * Purpose:
  168.      *     Called by client engine to inform the client is contacting
  169.      *     hosts(s).
  170.      *
  171.      */
  172.     STDMETHOD (OnContacting) (THIS_
  173. const char* pHostName);
  174. /*
  175.   IHXInteruptSafe methods. 
  176. */
  177. STDMETHOD_(BOOL,IsInterruptSafe) (THIS);
  178.     /*
  179.      * CHXAdviseSinkControl methods
  180.      */
  181.     HX_RESULT AddAdviseSink(IHXClientAdviseSink* pAdviseSink);
  182.     HX_RESULT RemoveAdviseSink(IHXClientAdviseSink* pAdviseSink);
  183.     void      Init(IHXClientEngine* pEngine);
  184. private:
  185.     CHXSimpleList m_pSinkList;
  186.     LONG32 m_lRefCount;
  187.     IHXInterruptState* m_pInterruptState;
  188.     IHXScheduler* m_pScheduler;
  189.     struct PlayerAdviseSink;
  190.     friend struct PlayerAdviseSink;
  191.     struct PlayerAdviseSink
  192.     {
  193.      PlayerAdviseSink(IHXClientAdviseSink* pAdviseSink,
  194.                         BOOL bInterruptSafe);
  195. ~PlayerAdviseSink();
  196.     
  197.      IHXClientAdviseSink* m_pAdviseSink;
  198.      BOOL m_bInterruptSafe;
  199. CHXSimpleList* m_pPendingAdviseList;
  200.     };
  201.     typedef enum 
  202.     {
  203.   ONPOSLENGTH = 0
  204. , ONPRESENTATIONOPENED
  205. , ONPRESENTATIONCLOSED
  206. , ONSTATISTICSCHANGED
  207. , ONPRESEEK
  208. , ONPOSTSEEK
  209. , ONSTOP
  210. , ONPAUSE
  211. , ONBEGIN
  212. , ONBUFFERING
  213. , ONCONTACTING
  214.     } AdviseType;
  215.     struct PendingAdvise;
  216.     friend struct PendingAdvise;
  217.     struct PendingAdvise
  218.     {
  219. PendingAdvise()
  220. {
  221.     m_pHostName = NULL;
  222. }
  223. ~PendingAdvise()
  224. {
  225.     if (m_pHostName)
  226.     {
  227. delete [] m_pHostName;
  228.     }
  229. }
  230. AdviseType  m_AdviseType;
  231. UINT32     m_ulArg1;
  232. UINT32     m_ulArg2;
  233. char*     m_pHostName;
  234.     };
  235.     void AddToPendingList(PlayerAdviseSink* pPlayerAdviseSink,
  236.   AdviseType type,
  237.   UINT32 ulArg1 = 0, 
  238.   UINT32 ulArg2 = 0, 
  239.   char* pHostName = NULL);
  240.     void ProcessPendingRequests(PlayerAdviseSink* pPlayerAdviseSink);
  241.     void ProcessAllRequests(void);
  242.     CHXGenericCallback*    m_pCallback;
  243.     static void AdviseSinkCallback(void* pParam);    
  244. };
  245. struct ErrorReport
  246. {
  247.     ErrorReport()
  248.     {
  249. m_unSeverity = 0;
  250. m_ulHXCode = 0;
  251. m_ulUserCode = 0;
  252. m_pUserString = NULL;
  253. m_pMoreInfoURL = NULL;
  254.     }
  255.     ~ErrorReport()
  256.     {
  257. m_unSeverity = 0;
  258. m_ulHXCode = 0;
  259. m_ulUserCode = 0;
  260. HX_VECTOR_DELETE(m_pUserString);
  261. HX_VECTOR_DELETE(m_pMoreInfoURL);
  262.     }
  263.     UINT8 m_unSeverity;
  264.     HX_RESULT   m_ulHXCode;
  265.     ULONG32     m_ulUserCode;
  266.     char* m_pUserString;
  267.     char* m_pMoreInfoURL;
  268. };
  269. class CHXErrorSinkControl : public IHXErrorSinkControl
  270. {
  271.     public:
  272.      CHXErrorSinkControl();
  273. ~CHXErrorSinkControl();
  274. /*
  275.  * IHXErrorSinkControl methods
  276.  */
  277.      STDMETHOD(AddErrorSink) (THIS_ 
  278.      IHXErrorSink* pErrorSink,
  279.                                  const UINT8     unLowSeverity,
  280.                                  const UINT8     unHighSeverity);
  281.      STDMETHOD(RemoveErrorSink) (THIS_ IHXErrorSink* pErrorSink);
  282. /*
  283.  * IUnknown methods
  284.  */
  285. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void** ppvObj);
  286. STDMETHOD_(ULONG32,AddRef) (THIS);
  287. STDMETHOD_(ULONG32,Release) (THIS);
  288.     
  289.      //get the severity range for pErrorSink
  290.      void GetSeverityRange(IHXErrorSink* pErrorSink, UINT8& unLowSeverity, 
  291.       UINT8& unHighSeverity);
  292. void Init(IHXClientEngine* pEngine);
  293. void Close();
  294.     
  295. HX_RESULT ErrorOccurred(const UINT8 unSeverity,  
  296. const ULONG32 ulHXCode,
  297. const ULONG32 ulUserCode,
  298. const char* pUserString,
  299. const char* pMoreInfoURL
  300. );
  301.      struct PlayerErrorSink
  302.      {
  303.          PlayerErrorSink(IHXErrorSink*  pErrorSink,
  304.                             const UINT8     unLowSeverity,
  305.                             const UINT8     unHighSeverity)
  306.             {
  307.      m_pErrorSink = pErrorSink;
  308.      m_unLowSeverity = unLowSeverity;
  309.      m_unHighSeverity = unHighSeverity;
  310.             };
  311.         
  312.          IHXErrorSink* m_pErrorSink;
  313.          UINT8 m_unLowSeverity;
  314.          UINT8 m_unHighSeverity;
  315.      };
  316.     
  317.     public:
  318.      CHXSimpleList m_pSinkList;
  319.     
  320.     private:
  321. HX_RESULT CallReport(
  322. const UINT8 unSeverity,  
  323. HX_RESULT ulHXCode,
  324. const ULONG32 ulUserCode,
  325. const char* pUserString,
  326. const char* pMoreInfoURL);
  327. void ReportPendingErrors(void);
  328.     
  329. friend class ErrorCallback;
  330.      LONG32     m_lRefCount;
  331. IHXInterruptState* m_pInterruptState;
  332. IHXScheduler*     m_pScheduler;
  333. CHXSimpleList*     m_pPendingErrorList;
  334.         CHXGenericCallback* m_pErrorCallback;
  335.         static void ErrorCallback(void* pParam);
  336. };
  337. #endif /* _SINKCTL_ */