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.

537 lines
22 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) 1992 - 1999 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //==========================================================================;
  11. #ifndef __CODSTRM_H__
  12. #define __CODSTRM_H__
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif // __cplusplus
  16. #include "defaults.h"
  17. // ------------------------------------------------------------------------
  18. // Property set for all video capture streams
  19. // ------------------------------------------------------------------------
  20. DEFINE_KSPROPERTY_TABLE(VideoStreamConnectionProperties)
  21. {
  22. DEFINE_KSPROPERTY_ITEM
  23. (
  24. KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
  25. TRUE, // GetSupported or Handler
  26. sizeof(KSPROPERTY), // MinProperty
  27. sizeof(KSALLOCATOR_FRAMING), // MinData
  28. FALSE, // SetSupported or Handler
  29. NULL, // Values
  30. 0, // RelationsCount
  31. NULL, // Relations
  32. NULL, // SupportHandler
  33. sizeof(ULONG) // SerializedSize
  34. )
  35. };
  36. DEFINE_KSPROPERTY_TABLE(StreamAllocatorProperties)
  37. {
  38. DEFINE_KSPROPERTY_ITEM_STREAM_ALLOCATOR
  39. (
  40. FALSE,
  41. TRUE
  42. )
  43. };
  44. // ------------------------------------------------------------------------
  45. // Per pin property set for VBI codec filtering
  46. // ------------------------------------------------------------------------
  47. DEFINE_KSPROPERTY_TABLE(VBICodecProperties)
  48. {
  49. DEFINE_KSPROPERTY_ITEM
  50. (
  51. KSPROPERTY_VBICODECFILTERING_SCANLINES_REQUESTED_BIT_ARRAY,
  52. TRUE, // GetSupported or Handler
  53. sizeof(KSPROPERTY), // MinProperty
  54. sizeof(VBICODECFILTERING_SCANLINES), // MinData
  55. TRUE, // SetSupported or Handler
  56. NULL, // Values
  57. 0, // RelationsCount
  58. NULL, // Relations
  59. NULL, // SupportHandler
  60. 0, // SerializedSize
  61. ),
  62. DEFINE_KSPROPERTY_ITEM
  63. (
  64. KSPROPERTY_VBICODECFILTERING_SCANLINES_DISCOVERED_BIT_ARRAY,
  65. TRUE, // GetSupported or Handler
  66. sizeof(KSPROPERTY), // MinProperty
  67. sizeof(VBICODECFILTERING_SCANLINES), // MinData
  68. FALSE, // SetSupported or Handler
  69. NULL, // Values
  70. 0, // RelationsCount
  71. NULL, // Relations
  72. NULL, // SupportHandler
  73. 0, // SerializedSize
  74. ),
  75. DEFINE_KSPROPERTY_ITEM
  76. (
  77. KSPROPERTY_VBICODECFILTERING_SUBSTREAMS_REQUESTED_BIT_ARRAY,
  78. TRUE, // GetSupported or Handler
  79. sizeof(KSPROPERTY), // MinProperty
  80. sizeof(VBICODECFILTERING_CC_SUBSTREAMS),// MinData
  81. TRUE, // SetSupported or Handler
  82. NULL, // Values
  83. 0, // RelationsCount
  84. NULL, // Relations
  85. NULL, // SupportHandler
  86. 0, // SerializedSize
  87. ),
  88. DEFINE_KSPROPERTY_ITEM
  89. (
  90. KSPROPERTY_VBICODECFILTERING_SUBSTREAMS_DISCOVERED_BIT_ARRAY,
  91. TRUE, // GetSupported or Handler
  92. sizeof(KSPROPERTY), // MinProperty
  93. sizeof(VBICODECFILTERING_CC_SUBSTREAMS),// MinData
  94. FALSE, // SetSupported or Handler
  95. NULL, // Values
  96. 0, // RelationsCount
  97. NULL, // Relations
  98. NULL, // SupportHandler
  99. 0, // SerializedSize
  100. ),
  101. DEFINE_KSPROPERTY_ITEM
  102. (
  103. KSPROPERTY_VBICODECFILTERING_STATISTICS,
  104. TRUE, // GetSupported or Handler
  105. sizeof(KSPROPERTY), // MinProperty
  106. sizeof(VBICODECFILTERING_STATISTICS_CC_PIN),// MinData
  107. TRUE, // SetSupported or Handler
  108. NULL, // Values
  109. 0, // RelationsCount
  110. NULL, // Relations
  111. NULL, // SupportHandler
  112. 0, // SerializedSize
  113. ),
  114. };
  115. // ------------------------------------------------------------------------
  116. // Array of all of the property sets supported by video streams
  117. // ------------------------------------------------------------------------
  118. DEFINE_KSPROPERTY_SET_TABLE(VideoStreamProperties)
  119. {
  120. DEFINE_KSPROPERTY_SET
  121. (
  122. &KSPROPSETID_Connection, // Set
  123. SIZEOF_ARRAY(VideoStreamConnectionProperties), // PropertiesCount
  124. VideoStreamConnectionProperties, // PropertyItems
  125. 0, // FastIoCount
  126. NULL // FastIoTable
  127. ),
  128. DEFINE_KSPROPERTY_SET
  129. (
  130. &KSPROPSETID_Stream, // Set
  131. SIZEOF_ARRAY(StreamAllocatorProperties), // PropertiesCount
  132. StreamAllocatorProperties, // PropertyItems
  133. 0, // FastIoCount
  134. NULL // FastIoTable
  135. ),
  136. DEFINE_KSPROPERTY_SET
  137. (
  138. &KSPROPSETID_VBICodecFiltering, // Set
  139. SIZEOF_ARRAY(VBICodecProperties), // PropertiesCount
  140. VBICodecProperties, // PropertyItems
  141. 0, // FastIoCount
  142. NULL // FastIoTable
  143. )
  144. };
  145. #define NUMBER_VIDEO_STREAM_PROPERTIES (SIZEOF_ARRAY(VideoStreamProperties))
  146. //---------------------------------------------------------------------------
  147. // All of the video and vbi data formats we might use
  148. //---------------------------------------------------------------------------
  149. KSDATARANGE StreamFormatCC =
  150. {
  151. // Definition of the CC stream
  152. {
  153. sizeof (KSDATARANGE), // FormatSize
  154. 0, // Flags
  155. CCSamples, // SampleSize
  156. 0, // Reserved
  157. { STATIC_KSDATAFORMAT_TYPE_AUXLine21Data },
  158. { STATIC_KSDATAFORMAT_SUBTYPE_Line21_BytePair },
  159. { STATIC_KSDATAFORMAT_SPECIFIER_NONE }
  160. }
  161. };
  162. #ifdef CCINPUTPIN
  163. # define GUIDKLUDGESTORAGE
  164. # include "guidkludge.h"
  165. KSDATARANGE StreamFormatCCin =
  166. {
  167. // Definition of the CC input stream
  168. {
  169. sizeof (KSDATARANGE), // FormatSize
  170. 0, // Flags
  171. sizeof (CC_HW_FIELD), // SampleSize
  172. 0, // Reserved
  173. { STATIC_KSDATAFORMAT_TYPE_VBI },
  174. { STATIC_KSDATAFORMAT_SUBTYPE_CC },
  175. { STATIC_KSDATAFORMAT_SPECIFIER_NONE }
  176. }
  177. };
  178. #endif // CCINPUTPIN
  179. // Warning, the following VBI geometry is governed by the capture driver NOT
  180. // the codecs. Therefore, any specification of a VBI capture format will be
  181. // ignored by most capture drivers. Look at the KS_VBI_FRAME_INFO data on each
  182. // sample to determine the actual data characteristics of the samples.
  183. #define NORMAL_VBI_START_LINE 10
  184. #define NORMAL_VBI_STOP_LINE 21
  185. #define MIN_VBI_X_SAMPLES (720*2)
  186. #define AVG_VBI_X_SAMPLES (VBISamples)
  187. #define MAX_VBI_X_SAMPLES (1135*2)
  188. #define MIN_VBI_Y_SAMPLES (1)
  189. #define AVG_VBI_Y_SAMPLES (12)
  190. #define MAX_VBI_Y_SAMPLES (21)
  191. #define MIN_VBI_T_SAMPLES (50)
  192. #define AVG_VBI_T_SAMPLES (59.94)
  193. #define MAX_VBI_T_SAMPLES (60)
  194. #define NTSC_FSC_FREQUENCY 3580000
  195. #define PAL_FSC_FREQUENCY 4430000
  196. #define MIN_SAMPLING_RATE (min(8*NTSC_FSC_FREQUENCY,8*PAL_FSC_FREQUENCY))
  197. #define AVG_SAMPLING_RATE (8*NTSC_FSC_FREQUENCY)
  198. #define MAX_SAMPLING_RATE (max(8*NTSC_FSC_FREQUENCY,8*PAL_FSC_FREQUENCY))
  199. // This format is the "arbitrary one" that was used in early sample capture drivers!
  200. //---------------------------------------------------------------------------
  201. // All of the video and vbi data formats we might use
  202. //---------------------------------------------------------------------------
  203. KS_DATARANGE_VIDEO_VBI StreamFormatVBI =
  204. {
  205. // KSDATARANGE
  206. {
  207. {
  208. sizeof( KS_DATARANGE_VIDEO_VBI ),
  209. 0,
  210. VBISamples * VBILines, // SampleSize
  211. 0, // Reserved
  212. { STATIC_KSDATAFORMAT_TYPE_VBI },
  213. { STATIC_KSDATAFORMAT_SUBTYPE_RAW8 },
  214. { STATIC_KSDATAFORMAT_SPECIFIER_VBI }
  215. }
  216. },
  217. TRUE, // BOOL, bFixedSizeSamples (all samples same size?)
  218. TRUE, // BOOL, bTemporalCompression (all I frames?)
  219. KS_VIDEOSTREAM_VBI, // StreamDescriptionFlags (KS_VIDEO_DESC_*)
  220. 0, // MemoryAllocationFlags (KS_VIDEO_ALLOC_*)
  221. // _KS_VIDEO_STREAM_CONFIG_CAPS
  222. {
  223. { STATIC_KSDATAFORMAT_SPECIFIER_VBI },
  224. KS_AnalogVideo_NTSC_M, // AnalogVideoStandard
  225. {
  226. VBISamples, VBILines // SIZE InputSize
  227. },
  228. {
  229. VBISamples, VBILines // SIZE MinCroppingSize; smallest rcSrc cropping rect allowed
  230. },
  231. {
  232. VBISamples, VBILines // SIZE MaxCroppingSize; largest rcSrc cropping rect allowed
  233. },
  234. 1, // int CropGranularityX; // granularity of cropping size
  235. 1, // int CropGranularityY;
  236. 1, // int CropAlignX; // alignment of cropping rect
  237. 1, // int CropAlignY;
  238. {
  239. VBISamples, VBILines // SIZE MinOutputSize; // smallest bitmap stream can produce
  240. },
  241. {
  242. VBISamples, VBILines // SIZE MaxOutputSize; // largest bitmap stream can produce
  243. },
  244. 1, // int OutputGranularityX; // granularity of output bitmap size
  245. 2, // int OutputGranularityY;
  246. 0, // StretchTapsX (0 no stretch, 1 pix dup, 2 interp...)
  247. 0, // StretchTapsY
  248. 0, // ShrinkTapsX
  249. 0, // ShrinkTapsY
  250. 166834, // LONGLONG MinFrameInterval; // 100 nS units
  251. 166834, // LONGLONG MaxFrameInterval;
  252. // cool. Bits or Bytes? See other streams as well
  253. VBISamples * 30 * VBILines * 2, // LONG MinBitsPerSecond;
  254. VBISamples * 30 * VBILines * 2 // LONG MaxBitsPerSecond;
  255. },
  256. // KS_VBIINFOHEADER (default format)
  257. {
  258. VBIStart, // StartLine -- inclusive
  259. VBIEnd, // EndLine -- inclusive
  260. SamplingFrequency, // SamplingFrequency
  261. 454, // MinLineStartTime; // (uS past HR LE) * 100
  262. 454, // MaxLineStartTime; // (uS past HR LE) * 100
  263. 454, // ActualLineStartTime // (uS past HR LE) * 100
  264. 5902, // ActualLineEndTime; // (uS past HR LE) * 100
  265. KS_AnalogVideo_NTSC_M, // VideoStandard;
  266. VBISamples, // SamplesPerLine;
  267. VBISamples, // StrideInBytes;
  268. VBISamples * VBILines // BufferSize;
  269. }
  270. };
  271. //---------------------------------------------------------------------------
  272. // STREAM_Capture Formats
  273. //---------------------------------------------------------------------------
  274. static PKSDATAFORMAT VBIFormats[] =
  275. {
  276. (PKSDATAFORMAT) &StreamFormatVBI,
  277. // Add more formats here for to mirror output formats for "passthrough" mode
  278. // The idea is that upstream capture drivers may have done some decoding
  279. // already or downstream drivers may wish to have the raw data without any
  280. // decoding at all.
  281. // In that case all we need to do is copy the data (if there is a pending
  282. // SRB) OR forward the SRB to the downstream client.
  283. };
  284. #define NUM_VBI_FORMATS (SIZEOF_ARRAY(VBIFormats))
  285. #ifdef CCINPUTPIN
  286. static PKSDATAFORMAT CCInputFormats[] =
  287. {
  288. (PKSDATAFORMAT) &StreamFormatCCin
  289. };
  290. # define NUM_CC_INPUT_FORMATS (SIZEOF_ARRAY(CCInputFormats))
  291. #endif // CCINPUTPIN
  292. static PKSDATAFORMAT DecodeFormats[] =
  293. {
  294. (PKSDATAFORMAT) &StreamFormatCC,
  295. //(PKSDATAFORMAT) &StreamFormatVBI // Can't do VBI here since Stream1
  296. // does NOT use extended headers
  297. // Add more formats here for whatever CODEC output formats are supported.
  298. };
  299. #define NUM_DECODE_FORMATS (SIZEOF_ARRAY (DecodeFormats))
  300. //---------------------------------------------------------------------------
  301. //---------------------------------------------------------------------------
  302. // Create an array that holds the list of all of the streams supported
  303. //---------------------------------------------------------------------------
  304. static ALL_STREAM_INFO Streams [] =
  305. {
  306. // -----------------------------------------------------------------
  307. // STREAM_VBI
  308. // -----------------------------------------------------------------
  309. {
  310. // HW_STREAM_INFORMATION -------------------------------------------
  311. {
  312. 1, // NumberOfPossibleInstances
  313. KSPIN_DATAFLOW_IN, // DataFlow
  314. TRUE, // DataAccessible
  315. NUM_VBI_FORMATS, // NumberOfFormatArrayEntries
  316. VBIFormats, // StreamFormatsArray
  317. 0, // ClassReserved[0]
  318. 0, // ClassReserved[1]
  319. 0, // ClassReserved[2]
  320. 0, // ClassReserved[3]
  321. NUMBER_VIDEO_STREAM_PROPERTIES, // NumStreamPropArrayEntries
  322. (PKSPROPERTY_SET)VideoStreamProperties, // StreamPropertiesArray
  323. 0, // NumStreamEventArrayEntries
  324. 0, // StreamEventsArray
  325. (GUID *)&PINNAME_VIDEO_VBI, // Category
  326. (GUID *)&PINNAME_VIDEO_VBI, // Name
  327. 0, // MediumsCount
  328. NULL, // Mediums
  329. FALSE,
  330. },
  331. // HW_STREAM_OBJECT ------------------------------------------------
  332. {
  333. sizeof (HW_STREAM_OBJECT), // SizeOfThisPacket
  334. STREAM_VBI, // StreamNumber
  335. (PVOID)NULL, // HwStreamExtension
  336. VBIReceiveDataPacket, // HwReceiveDataPacket
  337. VBIReceiveCtrlPacket, // HwReceiveControlPacket
  338. { // HW_CLOCK_OBJECT
  339. NULL, // .HWClockFunction
  340. 0, // .ClockSupportFlags
  341. },
  342. FALSE, // Dma
  343. TRUE, // Pio
  344. (PVOID)NULL, // HwDeviceExtension
  345. sizeof (KS_VBI_FRAME_INFO), // StreamHeaderMediaSpecific
  346. 0, // StreamHeaderWorkspace
  347. TRUE, // Allocator
  348. NULL, // HwEventRoutine
  349. },
  350. },
  351. // -----------------------------------------------------------------
  352. // STREAM_Decode (Closed Caption Output )
  353. // -----------------------------------------------------------------
  354. {
  355. // HW_STREAM_INFORMATION -------------------------------------------
  356. {
  357. MAX_PIN_INSTANCES, // NumberOfPossibleInstances
  358. KSPIN_DATAFLOW_OUT, // DataFlow
  359. TRUE, // DataAccessible
  360. NUM_DECODE_FORMATS, // NumberOfFormatArrayEntries
  361. DecodeFormats, // StreamFormatsArray
  362. 0, // ClassReserved[0]
  363. 0, // ClassReserved[1]
  364. 0, // ClassReserved[2]
  365. 0, // ClassReserved[3]
  366. NUMBER_VIDEO_STREAM_PROPERTIES, // NumStreamPropArrayEntries
  367. (PKSPROPERTY_SET)VideoStreamProperties, // StreamPropertiesArray
  368. 0, // NumStreamEventArrayEntries;
  369. 0, // StreamEventsArray;
  370. (GUID *)&PINNAME_VIDEO_CC, // Category
  371. (GUID *)&PINNAME_VIDEO_CC, // Name
  372. 0, // MediumsCount
  373. NULL, // Mediums
  374. FALSE,
  375. },
  376. // HW_STREAM_OBJECT ------------------------------------------------
  377. {
  378. sizeof (HW_STREAM_OBJECT), // SizeOfThisPacket
  379. STREAM_CC, // StreamNumber
  380. (PVOID)NULL, // HwStreamExtension
  381. VBIReceiveDataPacket, // HwReceiveDataPacket
  382. VBIReceiveCtrlPacket, // HwReceiveControlPacket
  383. { // HW_CLOCK_OBJECT
  384. NULL, // .HWClockFunction
  385. 0, // .ClockSupportFlags
  386. },
  387. FALSE, // Dma
  388. TRUE, // Pio
  389. (PVOID)NULL, // HwDeviceExtension
  390. 0, // StreamHeaderMediaSpecific
  391. 0, // StreamHeaderWorkspace
  392. TRUE, // Allocator
  393. NULL, // HwEventRoutine
  394. },
  395. },
  396. #ifdef CCINPUTPIN
  397. // -----------------------------------------------------------------
  398. // STREAM_CCInput (Closed Caption Input )
  399. // -----------------------------------------------------------------
  400. {
  401. // HW_STREAM_INFORMATION -------------------------------------------
  402. {
  403. 1, // NumberOfPossibleInstances
  404. KSPIN_DATAFLOW_IN, // DataFlow
  405. TRUE, // DataAccessible
  406. NUM_CC_INPUT_FORMATS, // NumberOfFormatArrayEntries
  407. CCInputFormats, // StreamFormatsArray
  408. 0, // ClassReserved[0]
  409. 0, // ClassReserved[1]
  410. 0, // ClassReserved[2]
  411. 0, // ClassReserved[3]
  412. NUMBER_VIDEO_STREAM_PROPERTIES, // NumStreamPropArrayEntries
  413. (PKSPROPERTY_SET)VideoStreamProperties, // StreamPropertiesArray
  414. 0, // NumStreamEventArrayEntries;
  415. 0, // StreamEventsArray;
  416. (GUID *)&PINNAME_VIDEO_CC_CAPTURE, // Category
  417. (GUID *)&PINNAME_VIDEO_CC_CAPTURE, // Name
  418. 0, // MediumsCount
  419. NULL, // Mediums
  420. FALSE,
  421. },
  422. // HW_STREAM_OBJECT ------------------------------------------------
  423. {
  424. sizeof (HW_STREAM_OBJECT), // SizeOfThisPacket
  425. STREAM_CCINPUT, // StreamNumber
  426. (PVOID)NULL, // HwStreamExtension
  427. VBIReceiveDataPacket, // HwReceiveDataPacket
  428. VBIReceiveCtrlPacket, // HwReceiveControlPacket
  429. { // HW_CLOCK_OBJECT
  430. NULL, // .HWClockFunction
  431. 0, // .ClockSupportFlags
  432. },
  433. FALSE, // Dma
  434. TRUE, // Pio
  435. (PVOID)NULL, // HwDeviceExtension
  436. 0, // StreamHeaderMediaSpecific
  437. 0, // StreamHeaderWorkspace
  438. TRUE, // Allocator
  439. NULL, // HwEventRoutine
  440. }
  441. },
  442. #endif // CCINPUTPIN
  443. };
  444. #define DRIVER_STREAM_COUNT (SIZEOF_ARRAY (Streams))
  445. //---------------------------------------------------------------------------
  446. // Topology
  447. //---------------------------------------------------------------------------
  448. // Categories define what the device does.
  449. static GUID Categories[] = {
  450. // {07DAD660-22F1-11d1-A9F4-00C04FBBDE8F}
  451. STATIC_KSCATEGORY_VBICODEC
  452. };
  453. #define NUMBER_OF_CATEGORIES SIZEOF_ARRAY (Categories)
  454. static KSTOPOLOGY Topology = {
  455. NUMBER_OF_CATEGORIES,
  456. (GUID*) &Categories,
  457. 0,
  458. NULL,
  459. 0,
  460. NULL
  461. };
  462. //---------------------------------------------------------------------------
  463. // The Main stream header
  464. //---------------------------------------------------------------------------
  465. static HW_STREAM_HEADER StreamHeader =
  466. {
  467. DRIVER_STREAM_COUNT, // NumberOfStreams
  468. sizeof (HW_STREAM_INFORMATION), // Future proofing
  469. 0, // NumDevPropArrayEntries set at init time
  470. NULL, // DevicePropertiesArray set at init time
  471. 0, // NumDevEventArrayEntries;
  472. NULL, // DeviceEventsArray;
  473. &Topology // Pointer to Device Topology
  474. };
  475. #ifdef __cplusplus
  476. }
  477. #endif // __cplusplus
  478. #endif // __CODSTRM_H__