Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. qcobj.h
  5. Abstract:
  6. Declaration of classes
  7. CCallQualityControlRelay and CStreamQualityControlRelay
  8. Author:
  9. Qianbo Huai (qhuai) 03/10/2000
  10. --*/
  11. #ifndef __QCOBJ_H_
  12. #define __QCOBJ_H_
  13. class CIPConfMSPCall;
  14. // default values
  15. #define QCDEFAULT_QUALITY_UNSET -1
  16. #define QCDEFAULT_MAX_CPU_LOAD 85
  17. #define QCDEFAULT_MAX_CALL_BITRATE QCDEFAULT_QUALITY_UNSET
  18. #define QCDEFAULT_MAX_STREAM_BITRATE QCDEFAULT_QUALITY_UNSET
  19. #define QCDEFAULT_MAX_VIDEO_BITRATE 95000L // 95k bps
  20. #define QCDEFAULT_UP_THRESHOLD 0.05 // above target value
  21. #define QCDEFAULT_LOW_THRESHOLD 0.20 // below target value
  22. #define QCDEFAULT_QUALITY_CONTROL_INTERVAL 7000
  23. // limited values
  24. #define QCLIMIT_MIN_QUALITY_CONTROL_INTERVAL 2000
  25. #define QCLIMIT_MAX_QUALITY_CONTROL_INTERVAL 60000
  26. #define QCLIMIT_MAX_CPU_LOAD 100
  27. #define QCLIMIT_MIN_CPU_LOAD 5
  28. #define QCLIMIT_MIN_BITRATE 1000L // 1k bps
  29. #define QCLIMIT_MIN_CONFBITRATE 4000L // 4k bps
  30. #define QCLIMIT_MIN_FRAME_INTERVAL 333333L
  31. #define QCLIMIT_MAX_FRAME_INTERVAL 10000000L
  32. #define QCLIMIT_MAX_QOSNOTALLOWEDTOSEND 8000L
  33. /*//////////////////////////////////////////////////////////////////////////////
  34. ////*/
  35. typedef CMSPArray <IInnerStreamQualityControl *> InnerStreamQCArray;
  36. class CCallQualityControlRelay
  37. {
  38. public:
  39. CCallQualityControlRelay ();
  40. ~CCallQualityControlRelay ();
  41. HRESULT Initialize (CIPConfMSPCall *pCall);
  42. HRESULT Shutdown (VOID);
  43. HRESULT SetConfBitrate (LONG lConfBitrate);
  44. LONG GetConfBitrate ();
  45. // main callback
  46. VOID CallbackProc (BOOLEAN bTimerFired);
  47. // methods called by inner call quality control
  48. HRESULT RegisterInnerStreamQC (
  49. IN IInnerStreamQualityControl *pIInnerStreamQC
  50. );
  51. HRESULT DeRegisterInnerStreamQC (
  52. IN IInnerStreamQualityControl *pIInnerStreamQC
  53. );
  54. HRESULT ProcessQCEvent (
  55. IN QCEvent event,
  56. IN DWORD dwParam
  57. );
  58. // methods called by ITCallQualityControl
  59. HRESULT Get (
  60. IN CallQualityProperty property,
  61. OUT LONG *plValue,
  62. OUT TAPIControlFlags *plFlags
  63. );
  64. HRESULT Set(
  65. IN CallQualityProperty property,
  66. IN LONG lValue,
  67. IN TAPIControlFlags lFlags
  68. );
  69. HRESULT GetRange (
  70. IN CallQualityProperty Property,
  71. OUT long *plMin,
  72. OUT long *plMax,
  73. OUT long *plSteppingDelta,
  74. OUT long *plDefault,
  75. OUT TAPIControlFlags *plFlags
  76. );
  77. private:
  78. BOOL GetCPUUsage (PDWORD pdwOverallCPUUsage);
  79. HRESULT GetCallBitrate (LONG MediaType, TERMINAL_DIRECTION Direction, LONG *plValue);
  80. LONG GetVideoOutBitrate ();
  81. VOID ReDistributeResources (VOID);
  82. VOID ReDistributeCPU (VOID);
  83. VOID ReDistributeBandwidth (VOID);
  84. private:
  85. CIPConfMSPCall *m_pCall;
  86. // inner stream quality control
  87. CMSPCritSection m_lock_aInnerStreamQC;
  88. InnerStreamQCArray m_aInnerStreamQC;
  89. BOOL m_fInitiated;
  90. HANDLE m_hWait;
  91. // used by callback to wait
  92. HANDLE m_hQCEvent;
  93. DWORD m_dwControlInterval;
  94. // notify callback to stop
  95. BOOL m_fStop;
  96. BOOL m_fStopAck;
  97. // lock when access quality data
  98. CMSPCritSection m_lock_QualityData;
  99. // note: should design a structure if we have complicated algorithms
  100. // conference-wide bandwidth
  101. LONG m_lConfBitrate;
  102. // prefered maximum cpu load
  103. LONG m_lPrefMaxCPULoad;
  104. LONG m_lCPUUpThreshold;
  105. LONG m_lCPULowThreshold;
  106. // prefered maximum output bitrate on call
  107. LONG m_lPrefMaxOutputBitrate;
  108. LONG m_lOutBitUpThreshold;
  109. LONG m_lOutBitLowThreshold;
  110. #ifdef DEBUG_QUALITY_CONTROL
  111. private:
  112. VOID QCDbgInitiate (VOID);
  113. VOID QCDbgRead (VOID);
  114. VOID QCDbgShutdown (VOID);
  115. HKEY m_hQCDbg;
  116. BOOL m_fQCDbgTraceCPULoad;
  117. BOOL m_fQCDbgTraceBitrate;
  118. #endif // DEBUG_QUALITY_CONTROL
  119. };
  120. /*//////////////////////////////////////////////////////////////////////////////
  121. ////*/
  122. class CStreamQualityControlRelay
  123. {
  124. public:
  125. CStreamQualityControlRelay ();
  126. ~CStreamQualityControlRelay ();
  127. HRESULT ProcessQCEvent (
  128. IN QCEvent event,
  129. IN DWORD dwParam
  130. )
  131. {
  132. return S_OK;
  133. }
  134. // methods called by inner stream control
  135. HRESULT LinkInnerCallQC (
  136. IN IInnerCallQualityControl *pIInnerCallQC
  137. );
  138. HRESULT UnlinkInnerCallQC (
  139. IN IInnerStreamQualityControl *pIInnerStreamQC
  140. );
  141. HRESULT Get(
  142. IN InnerStreamQualityProperty property,
  143. OUT LONG *plValue,
  144. OUT TAPIControlFlags *plFlags
  145. );
  146. HRESULT Set(
  147. IN InnerStreamQualityProperty property,
  148. IN LONG lValue,
  149. IN TAPIControlFlags lFlags
  150. );
  151. // qos, actually, all variables should be public
  152. BOOL m_fQOSAllowedToSend;
  153. private:
  154. // call quality controller
  155. IInnerCallQualityControl *m_pIInnerCallQC;
  156. // note: quality related data better be stored in a structure
  157. // if we have a complicated algorithm
  158. TAPIControlFlags m_PrefFlagBitrate;
  159. LONG m_lPrefMaxBitrate;
  160. LONG m_lAdjMaxBitrate;
  161. TAPIControlFlags m_PrefFlagFrameInterval;
  162. LONG m_lPrefMinFrameInterval;
  163. LONG m_lAdjMinFrameInterval;
  164. // not used
  165. DWORD m_dwState;
  166. };
  167. #endif // __QCOBJ_H_