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.

524 lines
15 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. avcstrm.h
  5. Abstract
  6. MS AVC Connection and Streaming
  7. --*/
  8. #ifndef __AVCSTRM_H__
  9. #define __AVCSTRM_H__
  10. #define MASK_AUX_50_60_BIT 0x00200000 // the NTSC/PAL bit of DV{A|V}AuxSrc
  11. // DVINFO
  12. typedef struct _DVINFO {
  13. //for 1st track
  14. DWORD dwDVAAuxSrc;
  15. DWORD dwDVAAuxCtl;
  16. // for 2nd track
  17. DWORD dwDVAAuxSrc1;
  18. DWORD dwDVAAuxCtl1;
  19. //for video information
  20. DWORD dwDVVAuxSrc;
  21. DWORD dwDVVAuxCtl;
  22. DWORD dwDVReserved[2];
  23. } DVINFO, *PDVINFO;
  24. // Static definitions for DVINFO initialization
  25. // MEDIATYPE_Interleaved equivalent
  26. #define STATIC_KSDATAFORMAT_TYPE_INTERLEAVED\
  27. 0x73766169L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
  28. DEFINE_GUIDSTRUCT("73766169-0000-0010-8000-00aa00389b71", KSDATAFORMAT_TYPE_INTERLEAVED);
  29. #define KSDATAFORMAT_TYPE_INTERLEAVED DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_INTERLEAVED)
  30. // MEDIASUBTYPE_dvsd equivalent
  31. #define STATIC_KSDATAFORMAT_SUBTYPE_DVSD\
  32. 0x64737664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
  33. DEFINE_GUIDSTRUCT("64737664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVSD);
  34. #define KSDATAFORMAT_SUBTYPE_DVSD DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVSD)
  35. // MEDIASUBTYPE_dvsl equivalent
  36. #define STATIC_KSDATAFORMAT_SUBTYPE_DVSL\
  37. 0x6C737664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
  38. DEFINE_GUIDSTRUCT("6C737664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVSL);
  39. #define KSDATAFORMAT_SUBTYPE_DVSL DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVSL)
  40. // MEDIASUBTYPE_dvhd equivalent
  41. #define STATIC_KSDATAFORMAT_SUBTYPE_DVHD\
  42. 0x64687664L, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
  43. DEFINE_GUIDSTRUCT("64687664-0000-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_DVHD);
  44. #define KSDATAFORMAT_SUBTYPE_DVHD DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_DVHD)
  45. // FORMAT_DvInfo equivalent
  46. #define STATIC_KSDATAFORMAT_SPECIFIER_DVINFO\
  47. 0x05589f84L, 0xc356, 0x11ce, 0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a
  48. DEFINE_GUIDSTRUCT("05589f84-c356-11ce-bf01-00aa0055595a", KSDATAFORMAT_SPECIFIER_DVINFO);
  49. #define KSDATAFORMAT_SPECIFIER_DVINFO DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_DVINFO)
  50. #define STATIC_KSDATAFORMAT_SPECIFIER_DV_AVC\
  51. 0xddcff71aL, 0xfc9f, 0x4bd9, 0xb9, 0xb, 0x19, 0x7b, 0xd, 0x44, 0xad, 0x94
  52. DEFINE_GUIDSTRUCT("ddcff71a-fc9f-4bd9-b90b-197b0d44ad94", KSDATAFORMAT_SPECIFIER_DV_AVC);
  53. #define KSDATAFORMAT_SPECIFIER_DV_AVC DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_DV_AVC)
  54. #define STATIC_KSDATAFORMAT_SPECIFIER_AVC\
  55. 0xf09dc377L, 0x6e51, 0x4ec5, 0xa0, 0xc4, 0xcd, 0x7f, 0x39, 0x62, 0x98, 0x80
  56. DEFINE_GUIDSTRUCT("f09dc377-6e51-4ec5-a0c4-cd7f39629880", KSDATAFORMAT_SPECIFIER_AVC);
  57. #define KSDATAFORMAT_SPECIFIER_AVC DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_AVC)
  58. // Media subtype for MPEG2TS with STRIDE
  59. #define STATIC_KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE\
  60. 0x138aa9a4L, 0x1ee2, 0x4c5b, 0x98, 0x8e, 0x19, 0xab, 0xfd, 0xbc, 0x8a, 0x11
  61. DEFINE_GUIDSTRUCT("138aa9a4-1ee2-4c5b-988e-19abfdbc8a11", KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE);
  62. #define KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_MPEG2_TRANSPORT_STRIDE)
  63. // Specifier for MPEG2TS with STRIDE
  64. #define STATIC_KSDATAFORMAT_SPECIFIER_61883_4\
  65. 0x97e218b1L, 0x1e5a, 0x498e, 0xa9, 0x54, 0xf9, 0x62, 0xcf, 0xd9, 0x8c, 0xde
  66. DEFINE_GUIDSTRUCT("97e218b1-1e5a-498e-a954-f962cfd98cde", KSDATAFORMAT_SPECIFIER_61883_4);
  67. #define KSDATAFORMAT_SPECIFIER_61883_4 DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_61883_4)
  68. // Associated with KSDATAFORMAT_SPECIFIER_DVINFO
  69. typedef struct tagKS_DATARANGE_DVVIDEO {
  70. KSDATARANGE DataRange;
  71. DVINFO DVVideoInfo;
  72. } KS_DATARANGE_DVVIDEO, *PKS_DATARANGE_DVVIDEO;
  73. // Associated with KSDATAFORMAT_SPECIFIER_DV_AVC
  74. typedef struct tagKS_DATARANGE_DV_AVC {
  75. KSDATARANGE DataRange;
  76. DVINFO DVVideoInfo;
  77. AVCPRECONNECTINFO ConnectInfo;
  78. } KS_DATARANGE_DV_AVC, *PKS_DATARANGE_DV_AVC;
  79. typedef struct tagKS_DATAFORMAT_DV_AVC {
  80. KSDATAFORMAT DataFormat;
  81. DVINFO DVVideoInfo;
  82. AVCCONNECTINFO ConnectInfo;
  83. } KS_DATAFORMAT_DV_AVC, *PKS_DATAFORMAT_DV_AVC;
  84. // Associated with KSDATAFORMAT_SPECIFIER_AVC
  85. typedef struct tagKS_DATARANGE_MPEG2TS_AVC {
  86. KSDATARANGE DataRange;
  87. AVCPRECONNECTINFO ConnectInfo;
  88. } KS_DATARANGE_MPEG2TS_AVC, *PKS_DATARANGE_MPEG2TS_AVC;
  89. typedef struct tagKS_DATAFORMAT_MPEG2TS_AVC {
  90. KSDATAFORMAT DataFormat;
  91. AVCCONNECTINFO ConnectInfo;
  92. } KS_DATAFORMAT_MPEG2TS_AVC, *PKS_DATAFORMAT_MPEG2TS_AVC;
  93. /**********************
  94. // 1394
  95. ***********************/
  96. #define SPEED_100_INDEX 0
  97. #define SPEED_200_INDEX 1
  98. #define SPEED_400_INDEX 2
  99. /**********************
  100. // 61883
  101. ***********************/
  102. #define BLOCK_PERIOD_2997 133466800 // nano-sec
  103. #define BLOCK_PERIOD_25 133333333 // nano-sec
  104. /************************
  105. // CIP header definition:
  106. *************************/
  107. // FMT: "Blue book" Part 1, page 25, Table 3; DVCR:000000
  108. #define CIP_HDR_FMT_MASK 0x3f
  109. #define CIP_HDR_FMT_DVCR 0x80 // 10:FMT(00:0000)
  110. #define CIP_HDR_FMT_MPEG 0xa0 // 10:FMT(10:0000)
  111. // FDF
  112. #define CIP_HDR_FDF0_50_60_MASK 0x80
  113. #define CIP_HDR_FDF0_50_60_PAL 0x80
  114. #define CIP_HDR_FDF0_50_60_NTSC 0x00
  115. #define CIP_HDR_FDF0_STYPE_MASK 0x7c
  116. #define CIP_HDR_FDF0_STYPE_SD_DVCR 0x00 // STYPE: 000:00
  117. #define CIP_HDR_FDF0_STYPE_SDL_DVCR 0x04 // STYPE: 000:01
  118. #define CIP_HDR_FDF0_STYPE_HD_DVCR 0x08 // STYPE: 000:10
  119. #define CIP_HDR_FDF0_STYPE_SD_DVCPRO 0x78 // STYPE: 111:10
  120. #define CIP_SPH_DV 0 // No source packet header
  121. #define CIP_SPH_MPEG 1 // Has a source packet header
  122. #define CIP_FN_DV 0 // Data blocks in a source pacaket of SD DVCR; BlueBook Part 2
  123. #define CIP_FN_MPEG 0x3 // Data blocks in a source pacaket of SD DVCR; BlueBook Part 2
  124. #define CIP_QPC_DV 0 // No padding
  125. #define CIP_QPC_MPEG 0 // No padding
  126. #define CIP_SPH_DV 0 // No header
  127. #define CIP_SPH_MPEG 1 // Has a header (time stamp)
  128. #define CIP_DBS_SDDV 120 // quadlets in a data block of the SD DVCR; BlueBook Part 2
  129. #define CIP_DBS_HDDV 240 // quadlets in a data block of the HD DVCR; BlueBook Part 3
  130. #define CIP_DBS_SDLDV 60 // quadlets in a data block of the SDL DVCR; BlueBook Part 5
  131. #define CIP_DBS_MPEG 6 // quadlets in a data block of the MPEG TS; BlueBook Part 4
  132. #define CIP_FMT_DV 0x0 // 00 0000
  133. #define CIP_FMT_MPEG 0x20 // 10 0000
  134. #define CIP_60_FIELDS 0 // 60 fields (NTSC)
  135. #define CIP_50_FIELDS 1 // 50 fields (PAL)
  136. #define CIP_TSF_ON 1 // TimeShift is ON
  137. #define CIP_TSF_OFF 0 // TimeShift is OFF
  138. #define CIP_STYPE_DV 0x0 // 00000
  139. #define CIP_STYPE_DVCPRO 0x1e // 11100
  140. //
  141. // Some derive values
  142. //
  143. #define SRC_PACKETS_PER_NTSC_FRAME 250 // Fixed and same for SDDV, HDDV and SDLDV
  144. #define SRC_PACKETS_PER_PAL_FRAME 300 // Fixed and same for SDDV, HDDV and SDLDV
  145. // Note: Frame size of MPEG2 will depends on number of source packets per frame, and
  146. // the is application dependent..
  147. #define FRAME_TIME_NTSC 333667 // "about" 29.97
  148. #define FRAME_TIME_PAL 400000 // exactly 25
  149. #define SRC_PACKET_SIZE_SDDV ((CIP_DBS_SDDV << 2) * (1 << CIP_FN_DV))
  150. #define SRC_PACKET_SIZE_HDDV ((CIP_DBS_HDDV << 2) * (1 << CIP_FN_DV))
  151. #define SRC_PACKET_SIZE_SDLDV ((CIP_DBS_SDLDV << 2) * (1 << CIP_FN_DV))
  152. #define SRC_PACKET_SIZE_MPEG2TS ((CIP_DBS_MPEG << 2) * (1 << CIP_FN_MPEG)) // Contain a sourcr packet header
  153. #define FRAME_SIZE_SDDV_NTSC (SRC_PACKET_SIZE_SDDV * SRC_PACKETS_PER_NTSC_FRAME)
  154. #define FRAME_SIZE_SDDV_PAL (SRC_PACKET_SIZE_SDDV * SRC_PACKETS_PER_PAL_FRAME)
  155. #define FRAME_SIZE_HDDV_NTSC (SRC_PACKET_SIZE_HDDV * SRC_PACKETS_PER_NTSC_FRAME)
  156. #define FRAME_SIZE_HDDV_PAL (SRC_PACKET_SIZE_HDDV * SRC_PACKETS_PER_PAL_FRAME)
  157. #define FRAME_SIZE_SDLDV_NTSC (SRC_PACKET_SIZE_SDLDV * SRC_PACKETS_PER_NTSC_FRAME)
  158. #define FRAME_SIZE_SDLDV_PAL (SRC_PACKET_SIZE_SDLDV * SRC_PACKETS_PER_PAL_FRAME)
  159. // Generic 1st quadlet of a CIP header
  160. typedef struct _CIP_HDR1 {
  161. ULONG DBC: 8; // Continuity counter of data blocks
  162. ULONG Rsv00: 2;
  163. ULONG SPH: 1; // Sourcre packet header; 1: source packet contain a source packet header
  164. ULONG QPC: 3; // Quadlet padding count (0..7 quadlets)
  165. ULONG FN: 2; // Fraction number
  166. ULONG DBS: 8; // Data block size in quadlets
  167. ULONG SID: 6; // Source node ID (ID of transmitter)
  168. ULONG Bit00: 2; // Always 0:0
  169. } CIP_HDR1, *PCIP_HDR1;
  170. // Generic 2nd quadlet of a CIP header with SYT field
  171. typedef struct _CIP_HDR2_SYT {
  172. ULONG SYT: 16; // lower 16bits of IEEE CYCLE_TIME
  173. ULONG RSV: 2; //
  174. ULONG STYPE: 5; // Signal type of video signal
  175. ULONG F5060_OR_TSF: 1; // 0:(60 field system; NTSC); 1:(50 field system; PAL); or 1/0 for TimeShiftFlag
  176. // e.g. 000000:DV, 100000 :MPEGTS;
  177. // if 111111 (no data), DBS, FN, QPC, SPH and DBC arfe ignored.
  178. ULONG FMT: 6; // Format ID
  179. ULONG Bit10: 2; // Always 1:0
  180. } CIP_HDR2_SYT, *PCIP_HDR2_SYT;
  181. // Generic 2nd quadlet of a CIP header with FDF field
  182. typedef struct _CIP_HDR2_FDF {
  183. ULONG FDF: 24;
  184. ULONG FMT: 6; // e.g. 000000:DV, 100000 :MPEGTS
  185. ULONG Bit10: 2; // Always 1:0
  186. } CIP_HDR2_FDF, *PCIP_HDR2_FDF;
  187. // 2nd quadlet of a CIP header of a MPEGTS data
  188. typedef struct _CIP_HDR2_MPEGTS {
  189. ULONG TSF: 1;
  190. ULONG RSV23bit: 23;
  191. ULONG FMT: 6; // e.g. 000000:DV, 100000 :MPEGTS
  192. ULONG Bit10: 2; // Always 1:0
  193. } CIP_HDR2_MPEGTS, *PCIP_HDR2_MPEGTS;
  194. //
  195. // AV/C command response data definition
  196. //
  197. #define AVC_DEVICE_TAPE_REC 0x20 // 00100:000
  198. #define AVC_DEVICE_CAMERA 0x38 // 00111:000
  199. #define AVC_DEVICE_TUNER 0x28 // 00101:000
  200. //
  201. // 61883 data format
  202. //
  203. typedef enum _AVCSTRM_FORMAT {
  204. AVCSTRM_FORMAT_SDDV_NTSC = 0, // 61883-2
  205. AVCSTRM_FORMAT_SDDV_PAL, // 61883-2
  206. AVCSTRM_FORMAT_MPEG2TS, // 61883-4
  207. AVCSTRM_FORMAT_HDDV_NTSC, // 61883-3
  208. AVCSTRM_FORMAT_HDDV_PAL, // 61883-3
  209. AVCSTRM_FORMAT_SDLDV_NTSC, // 61883-5
  210. AVCSTRM_FORMAT_SDLDV_PAL, // 61883-5
  211. // others..
  212. } AVCSTRM_FORMAT;
  213. //
  214. // This structure is create and initialize by the subunit.parameters
  215. // The streaming DLL will streaming based on these parameters.
  216. // Not all parameters apply to every format.
  217. //
  218. #define AVCSTRM_FORMAT_OPTION_STRIP_SPH 0x00000001
  219. typedef struct _AVCSTRM_FORMAT_INFO {
  220. ULONG SizeOfThisBlock; // sizeof of this structure
  221. /**************************
  222. * 61883-x format defintion
  223. **************************/
  224. AVCSTRM_FORMAT AVCStrmFormat; // Format, such as DV or MPEG2TS
  225. //
  226. // Two quadlet of a CIP header
  227. //
  228. CIP_HDR1 cipHdr1;
  229. CIP_HDR2_SYT cipHdr2;
  230. /*****************
  231. * Buffers related
  232. *****************/
  233. //
  234. // Number of source packet per frame
  235. //
  236. ULONG SrcPacketsPerFrame;
  237. //
  238. // Frame size
  239. //
  240. ULONG FrameSize;
  241. //
  242. // Number of receiving buffers
  243. //
  244. ULONG NumOfRcvBuffers;
  245. //
  246. // Number of transmitting buffers
  247. //
  248. ULONG NumOfXmtBuffers;
  249. //
  250. // Optional flags
  251. //
  252. DWORD OptionFlags;
  253. /********************
  254. * Frame rate related
  255. ********************/
  256. //
  257. // Approximate time per frame
  258. //
  259. ULONG AvgTimePerFrame;
  260. //
  261. // BlockPeriod - TX Only
  262. //
  263. ULONG BlockPeriod;
  264. //
  265. // Reserved for future use
  266. //
  267. ULONG Reserved[4];
  268. } AVCSTRM_FORMAT_INFO, * PAVCSTRM_FORMAT_INFO;
  269. //
  270. // IOCTL Definitions
  271. //
  272. #define IOCTL_AVCSTRM_CLASS CTL_CODE( \
  273. FILE_DEVICE_UNKNOWN, \
  274. 0x93, \
  275. METHOD_IN_DIRECT, \
  276. FILE_ANY_ACCESS \
  277. )
  278. //
  279. // Current AVCSTRM DDI Version
  280. //
  281. #define CURRENT_AVCSTRM_DDI_VERSION '15TN' // 1.' 8XD' 2.'15TN'
  282. //
  283. // INIT_AVCStrm_HEADER Macro
  284. //
  285. #define INIT_AVCSTRM_HEADER( AVCStrm, Request ) \
  286. (AVCStrm)->SizeOfThisBlock = sizeof(AVC_STREAM_REQUEST_BLOCK); \
  287. (AVCStrm)->Function = Request; \
  288. (AVCStrm)->Version = CURRENT_AVCSTRM_DDI_VERSION;
  289. typedef enum _AVCSTRM_FUNCTION {
  290. // Stream funcrtions
  291. AVCSTRM_READ = 0,
  292. AVCSTRM_WRITE,
  293. AVCSTRM_ABORT_STREAMING, // Cancel all; to cancel each individual IRP, use IoCancelIrp()
  294. AVCSTRM_OPEN = 0x100,
  295. AVCSTRM_CLOSE,
  296. AVCSTRM_GET_STATE,
  297. AVCSTRM_SET_STATE,
  298. // Not enabled
  299. AVCSTRM_GET_PROPERTY,
  300. AVCSTRM_SET_PROPERTY,
  301. } AVCSTRM_FUNCTION;
  302. //
  303. // Structure used to open a stream; a stream extension is returned when success.
  304. //
  305. typedef struct _AVCSTRM_OPEN_STRUCT {
  306. KSPIN_DATAFLOW DataFlow;
  307. PAVCSTRM_FORMAT_INFO AVCFormatInfo;
  308. // return stream exension (a context) if a stream is open successfully
  309. // This context is used for subsequent call after a stream is opened.
  310. PVOID AVCStreamContext;
  311. // Local i/oPCR to be connected to the remote o/iPCR
  312. HANDLE hPlugLocal;
  313. } AVCSTRM_OPEN_STRUCT, * PAVCSTRM_OPEN_STRUCT;
  314. //
  315. // Structure used to read or write a buffer
  316. //
  317. typedef struct _AVCSTRM_BUFFER_STRUCT {
  318. //
  319. // Clock provider
  320. //
  321. BOOL ClockProvider;
  322. HANDLE ClockHandle; // This is used only if !ClockProvider
  323. //
  324. // KS stream header
  325. //
  326. PKSSTREAM_HEADER StreamHeader;
  327. //
  328. // Frame buffer
  329. //
  330. PVOID FrameBuffer;
  331. //
  332. // Notify Context
  333. //
  334. PVOID Context;
  335. } AVCSTRM_BUFFER_STRUCT, * PAVCSTRM_BUFFER_STRUCT;
  336. typedef struct _AVC_STREAM_REQUEST_BLOCK {
  337. ULONG SizeOfThisBlock; // sizeof AVC_STREAM_REQUEST_BLOCK
  338. //
  339. // Version
  340. //
  341. ULONG Version;
  342. //
  343. // AVC Stream function
  344. //
  345. AVCSTRM_FUNCTION Function;
  346. //
  347. // Flags
  348. //
  349. ULONG Flags;
  350. //
  351. // Status of this final AVCStream request.
  352. //
  353. NTSTATUS Status;
  354. //
  355. // This pointer contain the context of a stream and this structure is opaque to client.
  356. //
  357. PVOID AVCStreamContext;
  358. //
  359. // Contexts that the requester needs when this request is completed asychronously
  360. //
  361. PVOID Context1;
  362. PVOID Context2;
  363. PVOID Context3;
  364. PVOID Context4;
  365. ULONG Reserved[4];
  366. //
  367. // the following union passes in the information needed for the various ASRB functions.
  368. //
  369. union _tagCommandData {
  370. // Get or set a stream state
  371. KSSTATE StreamState;
  372. // Struct used to open a stream
  373. AVCSTRM_OPEN_STRUCT OpenStruct;
  374. // Stream buffer structure
  375. AVCSTRM_BUFFER_STRUCT BufferStruct;
  376. } CommandData; // union for function data
  377. } AVC_STREAM_REQUEST_BLOCK, *PAVC_STREAM_REQUEST_BLOCK;
  378. #endif // ifndef __AVCSTRM_H__