Source code of Windows XP (NT5)
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.

146 lines
4.3 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1997 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //
  11. // History:
  12. // 22-Aug-97 TKB Created Initial Interface Version
  13. //
  14. //==========================================================================;
  15. #ifndef __IKS_H
  16. #define __IKS_H
  17. #include <ks.h>
  18. #include <ksmedia.h>
  19. #include <windows.h>
  20. #include <winioctl.h>
  21. #include <tchar.h>
  22. #if !defined(FILE_DEVICE_KS)
  23. // This comes from <wdm.h> but is not easily included(Been there, done that)
  24. #define FILE_DEVICE_KS 0x000002F
  25. #endif
  26. //////////////////////////////////////////////////////////////
  27. // Force the correct library to be included.
  28. //////////////////////////////////////////////////////////////
  29. #ifdef _DEBUG
  30. #pragma comment(lib, "icodecd.lib")
  31. #else
  32. #pragma comment(lib, "icodec.lib")
  33. #endif
  34. //////////////////////////////////////////////////////////////
  35. // Global Types
  36. //////////////////////////////////////////////////////////////
  37. typedef GUID * LPGUID;
  38. typedef const GUID *LPCGUID;
  39. //////////////////////////////////////////////////////////////
  40. // IKSDriver:: Kernel Mode Streaming Driver Interface
  41. //////////////////////////////////////////////////////////////
  42. class IKSDriver
  43. {
  44. // Usable public interfaces
  45. public:
  46. IKSDriver(LPCGUID lpCategory, LPCSTR lpszFriendlyName);
  47. ~IKSDriver();
  48. BOOL Ioctl(ULONG dwControlCode, LPBYTE pInput, ULONG nInput,
  49. LPBYTE pOutput, ULONG nOutput,
  50. DWORD *nReturned, LPOVERLAPPED lpOS=NULL );
  51. BOOL IsValid() { return m_lpszDriver && m_hKSDriver; }
  52. HANDLE m_hKSDriver;
  53. // Helper functions and internal data
  54. protected:
  55. LPWSTR GetSymbolicName(LPCGUID lpCategory, LPCSTR lpszFriendlyName);
  56. BOOL OpenDriver(DWORD dwAccess, DWORD dwFlags);
  57. BOOL CloseDriver();
  58. LPWSTR m_lpszDriver;
  59. };
  60. //////////////////////////////////////////////////////////////
  61. // IKSPin:: Kernel Mode Streaming Pin Interface
  62. //////////////////////////////////////////////////////////////
  63. class IKSPin
  64. {
  65. // Usable public interfaces
  66. public:
  67. IKSPin(IKSDriver &driver, int nPin, PKSDATARANGE pKSDataRange );
  68. ~IKSPin();
  69. BOOL Ioctl(ULONG dwControlCode, void *pInput, ULONG nInput,
  70. void *pOutput, ULONG nOutput,
  71. ULONG *nReturned, LPOVERLAPPED lpOS=NULL );
  72. BOOL Run(); // Automatically called by the constructors
  73. BOOL Stop(); // Automatically called by the destructors
  74. BOOL IsRunning() { return m_bRunning; }
  75. int ReadData( LPBYTE lpBuffer, int nBytes, DWORD *lpcbReturned, LPOVERLAPPED lpOS );
  76. int GetOverlappedResult( LPOVERLAPPED lpOS, LPDWORD lpdwTransferred = NULL, BOOL bWait=TRUE );
  77. BOOL IsValid() { return m_IKSDriver && m_nPin>=0 && m_hKSPin /*&& m_bRunning*/; }
  78. HANDLE m_hKSPin;
  79. // Helper functions and internal data
  80. protected:
  81. BOOL OpenPin(PKSDATARANGE pKSDataRange);
  82. BOOL ClosePin();
  83. BOOL GetRunState( PKSSTATE pKSState );
  84. BOOL SetRunState( KSSTATE KSState );
  85. IKSDriver *m_IKSDriver;
  86. LONG m_nPin;
  87. BOOL m_bRunning;
  88. };
  89. //////////////////////////////////////////////////////////////
  90. // IKSProperty:: Kernel Mode Streaming Property Interface
  91. //////////////////////////////////////////////////////////////
  92. class IKSProperty
  93. {
  94. // Usable public interfaces
  95. public:
  96. IKSProperty(IKSDriver &pin, LPCGUID Set, ULONG Id, ULONG Size);
  97. IKSProperty(IKSPin &pin, LPCGUID Set, ULONG Id, ULONG Size);
  98. ~IKSProperty();
  99. BOOL SetValue(void *nValue);
  100. BOOL GetValue(void *nValue);
  101. BOOL IsValid() { return (m_IKSPin || m_IKSDriver) && m_Id && m_hKSProperty; }
  102. HANDLE m_hKSProperty;
  103. // Helper functions and internal data
  104. protected:
  105. BOOL OpenProperty();
  106. BOOL CloseProperty();
  107. IKSDriver *m_IKSDriver;
  108. IKSPin *m_IKSPin;
  109. GUID m_Set;
  110. ULONG m_Id;
  111. ULONG m_Size;
  112. };
  113. #endif