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.

386 lines
12 KiB

  1. //==========================================================================;
  2. //
  3. // Video Decoder Device abstract base class implementation
  4. //
  5. // $Date: 28 Aug 1998 14:43:00 $
  6. // $Revision: 1.2 $
  7. // $Author: Tashjian $
  8. //
  9. // $Copyright: (c) 1997 - 1998 ATI Technologies Inc. All Rights Reserved. $
  10. //
  11. //==========================================================================;
  12. extern "C"
  13. {
  14. #include "strmini.h"
  15. #include "ksmedia.h"
  16. }
  17. #include "wdmdrv.h"
  18. #include "decdev.h"
  19. #include "capdebug.h"
  20. #include "wdmvdec.h"
  21. /*^^*
  22. * CVideoDecoderDevice()
  23. * Purpose : CVideoDecoderDevice class constructor
  24. *
  25. * Inputs : PDEVICE_OBJECT pDeviceObject : pointer to the Driver object to access the Registry
  26. *
  27. * Outputs : none
  28. * Author : IKLEBANOV
  29. *^^*/
  30. CVideoDecoderDevice::CVideoDecoderDevice()
  31. : m_pDecoder(NULL),
  32. m_bOutputEnabledSet(FALSE)
  33. {
  34. }
  35. CVideoDecoderDevice::~CVideoDecoderDevice()
  36. {
  37. }
  38. // -------------------------------------------------------------------
  39. // XBar Property Set functions
  40. // -------------------------------------------------------------------
  41. //
  42. // The only property to set on the XBar selects the input to use
  43. //
  44. /* Method: CVideoDecoderDevice::SetCrossbarProperty
  45. * Purpose:
  46. */
  47. VOID CVideoDecoderDevice::SetCrossbarProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
  48. {
  49. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  50. ULONG Id = pSPD->Property->Id; // index of the property
  51. pSrb->Status = STATUS_SUCCESS;
  52. switch (Id) {
  53. case KSPROPERTY_CROSSBAR_ROUTE:
  54. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
  55. {
  56. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  57. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  58. ULONG InPin, OutPin;
  59. InPin = pRoute->IndexInputPin;
  60. OutPin = pRoute->IndexOutputPin;
  61. if (GoodPins(InPin, OutPin) && TestRoute(InPin, OutPin)) {
  62. SetVideoInput((Connector)InPin);
  63. // this just sets the association
  64. Route(OutPin, InPin);
  65. }
  66. else {
  67. pSrb->Status = STATUS_INVALID_PARAMETER;
  68. }
  69. }
  70. break;
  71. default:
  72. TRAP();
  73. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  74. break;
  75. }
  76. }
  77. /* Method: CVideoDecoderDevice::GetCrossbarProperty
  78. * Purpose:
  79. */
  80. VOID CVideoDecoderDevice::GetCrossbarProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
  81. {
  82. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  83. ULONG Id = pSPD->Property->Id; // index of the property
  84. pSrb->Status = STATUS_SUCCESS;
  85. // Property set specific structure
  86. switch (Id)
  87. {
  88. case KSPROPERTY_CROSSBAR_CAPS: // R
  89. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CROSSBAR_CAPS_S));
  90. {
  91. PKSPROPERTY_CROSSBAR_CAPS_S pCaps =
  92. (PKSPROPERTY_CROSSBAR_CAPS_S)pSPD->PropertyInfo;
  93. // Copy the input property info to the output property info
  94. RtlCopyMemory(pCaps, pSPD->Property, sizeof KSPROPERTY_CROSSBAR_CAPS_S);
  95. pCaps->NumberOfInputs = GetNoInputs();
  96. pCaps->NumberOfOutputs = GetNoOutputs();
  97. pSrb->ActualBytesTransferred = sizeof KSPROPERTY_CROSSBAR_CAPS_S;
  98. }
  99. break;
  100. case KSPROPERTY_CROSSBAR_CAN_ROUTE:
  101. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
  102. {
  103. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  104. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  105. // Copy the input property info to the output property info
  106. RtlCopyMemory(pRoute, pSPD->Property, sizeof KSPROPERTY_CROSSBAR_ROUTE_S);
  107. ULONG InPin, OutPin;
  108. InPin = pRoute->IndexInputPin;
  109. OutPin = pRoute->IndexOutputPin;
  110. if (GoodPins(InPin, OutPin)) {
  111. pRoute->CanRoute = TestRoute(InPin, OutPin);
  112. } else {
  113. pRoute->CanRoute = FALSE;
  114. }
  115. pSrb->ActualBytesTransferred = sizeof KSPROPERTY_CROSSBAR_ROUTE_S;
  116. }
  117. break;
  118. case KSPROPERTY_CROSSBAR_ROUTE:
  119. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
  120. {
  121. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  122. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  123. // Copy the input property info to the output property info
  124. RtlCopyMemory(pRoute, pSPD->Property, sizeof KSPROPERTY_CROSSBAR_ROUTE_S);
  125. ULONG OutPin = pRoute->IndexOutputPin;
  126. if (OutPin < GetNoOutputs())
  127. pRoute->IndexInputPin = GetRoute(OutPin);
  128. else
  129. pRoute->IndexInputPin = (ULONG)-1;
  130. pSrb->ActualBytesTransferred = sizeof KSPROPERTY_CROSSBAR_ROUTE_S;
  131. }
  132. break;
  133. case KSPROPERTY_CROSSBAR_PININFO: // R
  134. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CROSSBAR_PININFO_S));
  135. {
  136. PKSPROPERTY_CROSSBAR_PININFO_S pPinInfo =
  137. (PKSPROPERTY_CROSSBAR_PININFO_S)pSPD->PropertyInfo;
  138. // Copy the input property info to the output property info
  139. RtlCopyMemory(pPinInfo, pSPD->Property, sizeof KSPROPERTY_CROSSBAR_PININFO_S);
  140. if (pPinInfo->Direction == KSPIN_DATAFLOW_IN) {
  141. if (pPinInfo->Index >= GetNoInputs()) {
  142. pSrb->Status = STATUS_INVALID_PARAMETER;
  143. break;
  144. }
  145. }
  146. else
  147. if (pPinInfo->Direction == KSPIN_DATAFLOW_OUT) {
  148. if (pPinInfo->Index >= GetNoOutputs()) {
  149. pSrb->Status = STATUS_INVALID_PARAMETER;
  150. break;
  151. }
  152. }
  153. else {
  154. pSrb->Status = STATUS_INVALID_PARAMETER;
  155. break;
  156. }
  157. pPinInfo->PinType = GetPinInfo(pPinInfo->Direction,
  158. pPinInfo->Index,
  159. pPinInfo->RelatedPinIndex);
  160. pPinInfo->Medium = * GetPinMedium(pPinInfo->Direction,
  161. pPinInfo->Index);
  162. pSrb->ActualBytesTransferred = sizeof KSPROPERTY_CROSSBAR_PININFO_S;
  163. }
  164. break;
  165. default:
  166. TRAP();
  167. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  168. break;
  169. }
  170. }
  171. // -------------------------------------------------------------------
  172. // Decoder functions
  173. // -------------------------------------------------------------------
  174. /*
  175. ** CVideoDecoderDevice::SetDecoderProperty ()
  176. **
  177. ** Handles Set operations on the Decoder property set.
  178. **
  179. ** Arguments:
  180. **
  181. ** pSRB -
  182. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  183. **
  184. ** Returns:
  185. **
  186. ** Side Effects: none
  187. */
  188. VOID CVideoDecoderDevice::SetDecoderProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
  189. {
  190. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  191. ULONG Id = pSPD->Property->Id; // index of the property
  192. switch (Id)
  193. {
  194. case KSPROPERTY_VIDEODECODER_STANDARD:
  195. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_S));
  196. {
  197. PKSPROPERTY_VIDEODECODER_S pS = (PKSPROPERTY_VIDEODECODER_S) pSPD->PropertyInfo;
  198. DBGTRACE(("KSPROPERTY_VIDEODECODER_STANDARD.\n"));
  199. if (!SetVideoDecoderStandard(pS->Value))
  200. {
  201. DBGERROR(("Unsupported video standard.\n"));
  202. pSrb->Status = STATUS_UNSUCCESSFUL;
  203. }
  204. }
  205. break;
  206. case KSPROPERTY_VIDEODECODER_OUTPUT_ENABLE:
  207. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_S));
  208. {
  209. PKSPROPERTY_VIDEODECODER_S pS = (PKSPROPERTY_VIDEODECODER_S) pSPD->PropertyInfo;
  210. DBGTRACE(("KSPROPERTY_VIDEODECODER_OUTPUT_ENABLE.\n"));
  211. // Should we leave this property as it was and add a new
  212. // property that supports the new behavior?
  213. // We probably should allow this if the filter is stopped because
  214. // the transition to Acquire/Pause/Run will fail if the
  215. // PreEvent has not been cleared by then. We'll have to add
  216. // some logic to this class to track the filter's state.
  217. if (pS->Value && m_pDecoder && m_pDecoder->PreEventOccurred())
  218. {
  219. DBGERROR(("Output enabled when preevent has occurred.\n"));
  220. pSrb->Status = STATUS_UNSUCCESSFUL;
  221. }
  222. else
  223. {
  224. SetOutputEnabled(pS->Value);
  225. SetOutputEnabledOverridden(TRUE);
  226. }
  227. }
  228. break;
  229. default:
  230. TRAP();
  231. break;
  232. }
  233. }
  234. /*
  235. ** CVideoDecoderDevice::GetDecoderProperty ()
  236. **
  237. ** Handles Get operations on the Decoder property set.
  238. **
  239. ** Arguments:
  240. **
  241. ** pSRB -
  242. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  243. **
  244. ** Returns:
  245. **
  246. ** Side Effects: none
  247. */
  248. VOID CVideoDecoderDevice::GetDecoderProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
  249. {
  250. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  251. ULONG Id = pSPD->Property->Id; // index of the property
  252. switch (Id)
  253. {
  254. case KSPROPERTY_VIDEODECODER_CAPS:
  255. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_CAPS_S));
  256. {
  257. DBGTRACE(("KSPROPERTY_VIDEODECODER_CAPS\n"));
  258. PKSPROPERTY_VIDEODECODER_CAPS_S pCaps =
  259. (PKSPROPERTY_VIDEODECODER_CAPS_S)pSPD->PropertyInfo;
  260. // Copy the input property info to the output property info
  261. RtlCopyMemory(pCaps, pSPD->Property, sizeof KSPROPERTY);
  262. GetVideoDecoderCaps(pCaps);
  263. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_CAPS_S);
  264. }
  265. break;
  266. case KSPROPERTY_VIDEODECODER_STANDARD:
  267. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_S));
  268. {
  269. DBGTRACE(("KSPROPERTY_VIDEODECODER_STANDARD\n"));
  270. PKSPROPERTY_VIDEODECODER_S pS =
  271. (PKSPROPERTY_VIDEODECODER_S)pSPD->PropertyInfo;
  272. // Copy the input property info to the output property info
  273. RtlCopyMemory(pS, pSPD->Property, sizeof KSPROPERTY);
  274. pS->Value = GetVideoDecoderStandard();
  275. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_S);
  276. }
  277. break;
  278. case KSPROPERTY_VIDEODECODER_STATUS:
  279. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_STATUS_S));
  280. {
  281. DBGTRACE(("KSPROPERTY_VIDEODECODER_STATUS\n"));
  282. PKSPROPERTY_VIDEODECODER_STATUS_S pS =
  283. (PKSPROPERTY_VIDEODECODER_STATUS_S)pSPD->PropertyInfo;
  284. // Copy the input property info to the output property info
  285. RtlCopyMemory(pS, pSPD->Property, sizeof KSPROPERTY);
  286. GetVideoDecoderStatus(pS);
  287. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_STATUS_S);
  288. }
  289. break;
  290. case KSPROPERTY_VIDEODECODER_OUTPUT_ENABLE:
  291. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEODECODER_S));
  292. {
  293. DBGTRACE(("KSPROPERTY_VIDEODECODER_OUTPUT_ENABLE\n"));
  294. PKSPROPERTY_VIDEODECODER_S pS = (PKSPROPERTY_VIDEODECODER_S) pSPD->PropertyInfo; // pointer to the data
  295. // Copy the input property info to the output property info
  296. RtlCopyMemory(pS, pSPD->Property, sizeof KSPROPERTY);
  297. pS->Value = IsOutputEnabled();
  298. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_S);
  299. }
  300. break;
  301. default:
  302. TRAP();
  303. break;
  304. }
  305. }