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.

237 lines
6.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. qcstream.cpp
  5. Abstract:
  6. Implementation of CStreamQualityControlRelay
  7. Data stored in this class can be, and better, kept in stream object itself,
  8. because other members in stream need to be accessed to either set or get
  9. properties related to stream quality control. Most of these access methods
  10. are specific to each particular kind of stream class.
  11. This class is used as a data store.
  12. Author:
  13. Qianbo Huai (qhuai) 03/10/2000
  14. --*/
  15. #include "stdafx.h"
  16. /*//////////////////////////////////////////////////////////////////////////////
  17. ////*/
  18. CStreamQualityControlRelay::CStreamQualityControlRelay ()
  19. :m_pIInnerCallQC (NULL)
  20. ,m_PrefFlagBitrate (TAPIControl_Flags_Auto)
  21. ,m_lPrefMaxBitrate (QCDEFAULT_QUALITY_UNSET)
  22. ,m_lAdjMaxBitrate (QCDEFAULT_QUALITY_UNSET)
  23. ,m_PrefFlagFrameInterval (TAPIControl_Flags_Auto)
  24. ,m_lPrefMinFrameInterval (QCDEFAULT_QUALITY_UNSET)
  25. ,m_lAdjMinFrameInterval (QCDEFAULT_QUALITY_UNSET)
  26. ,m_fQOSAllowedToSend (TRUE)
  27. ,m_dwState (NULL)
  28. {
  29. }
  30. /*//////////////////////////////////////////////////////////////////////////////
  31. Description:
  32. destructor. deregister relay
  33. ////*/
  34. CStreamQualityControlRelay::~CStreamQualityControlRelay ()
  35. {
  36. ENTER_FUNCTION ("CStreamQualityControlRelay::~CStreamQualityControlRelay");
  37. if (m_pIInnerCallQC)
  38. {
  39. LOG ((MSP_ERROR, "!!! %s destructed before unnlink. call keeps stream qc"));
  40. // access to m_pIInnerCallQC is locked in this method
  41. UnlinkInnerCallQC (NULL);
  42. }
  43. }
  44. /*//////////////////////////////////////////////////////////////////////////////
  45. Description:
  46. store call controller
  47. ////*/
  48. HRESULT
  49. CStreamQualityControlRelay::LinkInnerCallQC (
  50. IN IInnerCallQualityControl *pIInnerCallQC
  51. )
  52. {
  53. ENTER_FUNCTION ("CStreamQualityControlRelay::LinkInnerCallQC");
  54. // check pointer
  55. if (IsBadReadPtr (pIInnerCallQC, sizeof (IInnerCallQualityControl)))
  56. {
  57. LOG ((MSP_ERROR, "%s got bad read pointer", __fxName));
  58. return E_POINTER;
  59. }
  60. // check if call controller already set
  61. if (NULL != m_pIInnerCallQC)
  62. {
  63. LOG ((MSP_WARN, "%s already set call controller", __fxName));
  64. return E_UNEXPECTED;
  65. }
  66. m_pIInnerCallQC = pIInnerCallQC;
  67. m_pIInnerCallQC->InnerCallAddRef ();
  68. return S_OK;
  69. }
  70. /*//////////////////////////////////////////////////////////////////////////////
  71. ////*/
  72. HRESULT
  73. CStreamQualityControlRelay::UnlinkInnerCallQC (
  74. IN IInnerStreamQualityControl *pIInnerStreamQC
  75. )
  76. {
  77. ENTER_FUNCTION ("CStreamQualityControlRelay::UnlinkInnerCallQC");
  78. if (!m_pIInnerCallQC)
  79. {
  80. LOG ((MSP_WARN, "%s tried unlink while inner call qc is null", __fxName));
  81. return S_OK;
  82. }
  83. if (NULL != pIInnerStreamQC)
  84. {
  85. HRESULT hr;
  86. // release is initiated by stream, need to remove the link on call
  87. if (FAILED (hr = m_pIInnerCallQC->DeRegisterInnerStreamQC (pIInnerStreamQC)))
  88. LOG ((MSP_ERROR, "%s failed to deregister from call qc, %x", __fxName, hr));
  89. }
  90. m_pIInnerCallQC->InnerCallRelease ();
  91. m_pIInnerCallQC = NULL;
  92. return S_OK;
  93. }
  94. /*//////////////////////////////////////////////////////////////////////////////
  95. ////*/
  96. HRESULT
  97. CStreamQualityControlRelay::Get(
  98. IN InnerStreamQualityProperty property,
  99. OUT LONG *plValue,
  100. OUT TAPIControlFlags *plFlags
  101. )
  102. {
  103. ENTER_FUNCTION ("CStreamQualityControlRelay::Get");
  104. HRESULT hr;
  105. hr = S_OK;
  106. switch (property)
  107. {
  108. case InnerStreamQuality_PrefMaxBitrate:
  109. *plValue = m_lPrefMaxBitrate;
  110. *plFlags = m_PrefFlagBitrate;
  111. break;
  112. case InnerStreamQuality_AdjMaxBitrate:
  113. *plValue = m_lAdjMaxBitrate;
  114. *plFlags = m_PrefFlagBitrate;
  115. break;
  116. case InnerStreamQuality_PrefMinFrameInterval:
  117. *plValue = m_lPrefMinFrameInterval;
  118. *plFlags = m_PrefFlagFrameInterval;
  119. break;
  120. case InnerStreamQuality_AdjMinFrameInterval:
  121. *plValue = m_lAdjMinFrameInterval;
  122. *plFlags = m_PrefFlagFrameInterval;
  123. break;
  124. default:
  125. hr = E_NOTIMPL;
  126. }
  127. return hr;
  128. }
  129. /*//////////////////////////////////////////////////////////////////////////////
  130. ////*/
  131. HRESULT
  132. CStreamQualityControlRelay::Set(
  133. IN InnerStreamQualityProperty property,
  134. IN LONG lValue,
  135. IN TAPIControlFlags lFlags
  136. )
  137. {
  138. ENTER_FUNCTION ("CStreamQualityControlRelay::Set");
  139. HRESULT hr;
  140. hr = S_OK;
  141. switch (property)
  142. {
  143. case InnerStreamQuality_PrefMaxBitrate:
  144. if (lValue < QCLIMIT_MIN_BITRATE)
  145. {
  146. LOG ((MSP_ERROR, "%s: pref max bitrate %d is too small", __fxName, lValue));
  147. hr = E_INVALIDARG;
  148. }
  149. else
  150. {
  151. m_lPrefMaxBitrate = lValue;
  152. m_PrefFlagBitrate = lFlags;
  153. }
  154. break;
  155. case InnerStreamQuality_AdjMaxBitrate:
  156. if (lValue < QCLIMIT_MIN_BITRATE)
  157. {
  158. LOG ((MSP_ERROR, "%s: adjusted max bitrate %d is too small", __fxName, lValue));
  159. hr = E_INVALIDARG;
  160. }
  161. else
  162. m_lAdjMaxBitrate = lValue;
  163. break;
  164. case InnerStreamQuality_PrefMinFrameInterval:
  165. if (lValue < QCLIMIT_MIN_FRAME_INTERVAL || lValue > QCLIMIT_MAX_FRAME_INTERVAL)
  166. {
  167. LOG ((MSP_ERROR, "%s: pref max frame interval %d is out of range", __fxName, lValue));
  168. hr = E_INVALIDARG;
  169. }
  170. else
  171. {
  172. m_lPrefMinFrameInterval = lValue;
  173. m_PrefFlagFrameInterval = lFlags;
  174. }
  175. break;
  176. case InnerStreamQuality_AdjMinFrameInterval:
  177. if (lValue < QCLIMIT_MIN_FRAME_INTERVAL || lValue > QCLIMIT_MAX_FRAME_INTERVAL)
  178. {
  179. LOG ((MSP_ERROR, "%s: adjusted max frame interval %d is out of range", __fxName, lValue));
  180. hr = E_INVALIDARG;
  181. }
  182. else
  183. m_lAdjMinFrameInterval = lValue;
  184. break;
  185. default:
  186. hr = E_NOTIMPL;
  187. }
  188. return hr;
  189. }