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.

162 lines
5.8 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL WDMSTREAMER
  3. *
  4. * @module WDMStrmr.h | Include file for <c CWDMStreamer> class used to get a
  5. * stream of video data flowing from WDM devices.
  6. *
  7. * @comm This code is based on the VfW to WDM mapper code written by
  8. * FelixA and E-zu Wu. The original code can be found on
  9. * \\redrum\slmro\proj\wdm10\\src\image\vfw\win9x\raytube.
  10. *
  11. * Documentation by George Shaw on kernel streaming can be found in
  12. * \\popcorn\razzle1\src\spec\ks\ks.doc.
  13. *
  14. * WDM streaming capture is discussed by Jay Borseth in
  15. * \\blues\public\jaybo\WDMVCap.doc.
  16. ***************************************************************************/
  17. #ifndef _WDMSTRMR_H // { _WDMSTRMR_H
  18. #define _WDMSTRMR_H
  19. /*****************************************************************************
  20. * @doc INTERNAL VIDEOSTRUCTENUM
  21. *
  22. * @struct BUFSTRUCT | The <t BUFSTRUCT> structure holds the status of each
  23. * video streaming buffer.
  24. *
  25. * @field LPVIDEOHDR | lpVHdr | Specifies a pointer to the video header of a
  26. * video streaming buffer.
  27. *
  28. * @field BOOL | fReady | Set to TRUE if the video buffer is available for
  29. * video streaming, FALSE if is locked by the application or queued for
  30. * an asynchronous read.
  31. ***************************************************************************/
  32. // Holds status of each video streaming buffer
  33. typedef struct _BUFSTRUCT {
  34. LPVIDEOHDR lpVHdr; // Pointer to the video header of the buffer
  35. BOOL fReady; // Set to TRUE if the buffer is available for streaming, FALSE otherwise
  36. } BUFSTRUCT, * PBUFSTRUCT;
  37. /*****************************************************************************
  38. * @doc INTERNAL VIDEOSTRUCTENUM
  39. *
  40. * @struct WDMVIDEOBUFF | The <t WDMVIDEOBUFF> structure is used to queue
  41. * asynchronous read on a video streaming pin.
  42. *
  43. * @field OVERLAPPED | Overlap | Structure used for overlapping IOs.
  44. *
  45. * @field BOOL | fBlocking | Set to TRUE if read is going to block.
  46. *
  47. * @field KS_HEADER_AND_INFO | SHGetImage | Video streaming structure used
  48. * on the video pin to get video data.
  49. *
  50. * @field LPVIDEOHDR | pVideoHdr | Pointer to the video header for this WDM
  51. * video buffer.
  52. ***************************************************************************/
  53. // Read buffer structure
  54. typedef struct tagWDMVIDEOBUFF {
  55. OVERLAPPED Overlap; // Structure used for overlapping IOs
  56. BOOL fBlocking; // Set to TRUE if the read operation will execute asynchronously
  57. KS_HEADER_AND_INFO SHGetImage; // Video streaming structure used on the video pin
  58. LPVIDEOHDR pVideoHdr; // Pointer to the video header for this WDM buffer
  59. } WDMVIDEOBUFF, *PWDMVIDEOBUFF;
  60. /****************************************************************************
  61. * @doc INTERNAL CWDMSTREAMERCLASS
  62. *
  63. * @class CWDMStreamer | This class provides support for streaming video
  64. * data from WDM device streaming pin.
  65. *
  66. * @mdata CWDMPin * | CWDMStreamer | m_pWDMVideoPin | Handle to the video
  67. * streaming pin.
  68. *
  69. * @mdata ULONG | CWDMStreamer | m_cntNumVidBuf | Number of video buffers
  70. * used for streaming.
  71. *
  72. * @mdata PBUFSTRUCT | CWDMStreamer | m_pBufTable | Pointer to a list of
  73. * <t BUFSTRUCT> video buffers used for streaming and their status.
  74. *
  75. * @mdata VIDEO_STREAM_INIT_PARMS | CWDMStreamer | m_CaptureStreamParms |
  76. * Streaming initialization parameters.
  77. *
  78. * @mdata LPVIDEOHDR | CWDMStreamer | m_lpVHdrFirst | Head pointer to the
  79. * list of video buffers.
  80. *
  81. * @mdata LPVIDEOHDR | CWDMStreamer | m_lpVHdrLast | Tail pointer to the
  82. * list of video buffers.
  83. *
  84. * @mdata BOOL | CWDMStreamer | m_fVideoOpen | Set to TRUE if the stream is
  85. * open, FALSE otherwise.
  86. *
  87. * @mdata BOOL | CWDMStreamer | m_fStreamingStarted | Set to TRUE if we
  88. * are currently streaming video data, FALSE otherwise.
  89. *
  90. * @mdata DWORD | CWDMStreamer | m_dwTimeStart | Timestamp of the first
  91. * video buffer ever returned to the application.
  92. *
  93. * @mdata DWORD | CWDMStreamer | m_dwNextToComplete | Index of the next
  94. * overlapped read to complete.
  95. *
  96. * @mdata WDMVIDEOBUFF | CWDMStreamer | m_pWDMVideoBuff | Pointer to a
  97. * list of <t WDMVIDEOBUFF> used to read data from the video pin.
  98. *
  99. * @mdata DWORD | CWDMStreamer | m_dwFrameCount | Number of frames returned
  100. * so far to the application - DEBUG only.
  101. *
  102. * @mdata HANDLE | CWDMStreamer | m_hThread | Handle to our streaming
  103. * thread.
  104. *
  105. * @mdata BOOL | CWDMStreamer | m_bKillThread | Set to TRUE to kill our
  106. * streaming thread.
  107. ***************************************************************************/
  108. class CWDMStreamer
  109. {
  110. public:
  111. CWDMStreamer(CWDMPin * pCWDMPin);
  112. ~CWDMStreamer() {};
  113. // Stream control functions
  114. BOOL Open(LPVIDEO_STREAM_INIT_PARMS lpStreamInitParms);
  115. BOOL Close();
  116. BOOL Start();
  117. BOOL Stop();
  118. BOOL Reset();
  119. BOOL AddBuffer(LPVIDEOHDR lpVHdr);
  120. private:
  121. CWDMPin *m_pWDMVideoPin;
  122. ULONG m_cntNumVidBuf;
  123. ULONG m_idxNextVHdr; // index of expected next Hdr ID
  124. PBUFSTRUCT m_pBufTable;
  125. VIDEO_STREAM_INIT_PARMS m_CaptureStreamParms;
  126. LPVIDEOHDR m_lpVHdrFirst;
  127. LPVIDEOHDR m_lpVHdrLast;
  128. BOOL m_fVideoOpen;
  129. BOOL m_fStreamingStarted;
  130. DWORD m_dwTimeStart;
  131. int m_dwNextToComplete;
  132. WDMVIDEOBUFF *m_pWDMVideoBuff;
  133. #ifdef _DEBUG
  134. DWORD m_dwFrameCount;
  135. #endif
  136. HANDLE m_hThread;
  137. BOOL m_bKillThread;
  138. // Video buffer management functions
  139. void BufferDone(LPVIDEOHDR lpVHdr);
  140. LPVIDEOHDR DeQueueHeader();
  141. void QueueHeader(LPVIDEOHDR lpVHdr);
  142. BOOL QueueRead(DWORD dwIndex);
  143. // User callback function
  144. void videoCallback(WORD msg, DWORD_PTR dw1);
  145. // Thread functions
  146. void Stream(void);
  147. static LPTHREAD_START_ROUTINE ThreadStub(CWDMStreamer *object);
  148. };
  149. #endif // } _WDMSTRMR_H
  150.