DsExtend.cs
Upload User: wuming6209
Upload Date: 2013-06-06
Package Size: 161k
Code Size: 19k
Category:

Video Capture

Development Platform:

Visual C++

  1. /******************************************************
  2.                   DirectShow .NET
  3.       netmaster@swissonline.ch
  4. *******************************************************/
  5. // DsExtend
  6. // Extended streaming interfaces, ported from axextend.idl
  7. using System;
  8. using System.Drawing;
  9. using System.Runtime.InteropServices;
  10. namespace DShowNET
  11. {
  12. [ComVisible(true), ComImport,
  13. Guid("93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D"),
  14. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  15. public interface ICaptureGraphBuilder2
  16. {
  17. [PreserveSig]
  18. int SetFiltergraph( [In] IGraphBuilder pfg );
  19. [PreserveSig]
  20. int GetFiltergraph( [Out] out IGraphBuilder ppfg );
  21. [PreserveSig]
  22. int SetOutputFileName(
  23. [In] ref Guid pType,
  24. [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrFile,
  25. [Out] out IBaseFilter ppbf,
  26. [Out] out IFileSinkFilter ppSink );
  27. [PreserveSig]
  28. int FindInterface(
  29. [In] ref Guid pCategory,
  30. [In] ref Guid pType,
  31. [In] IBaseFilter pbf,
  32. [In] ref Guid riid,
  33. [Out, MarshalAs(UnmanagedType.IUnknown) ] out object ppint );
  34. [PreserveSig]
  35. int RenderStream(
  36. [In] ref Guid pCategory,
  37. [In] ref Guid pType,
  38. [In, MarshalAs(UnmanagedType.IUnknown)] object pSource,
  39. [In] IBaseFilter pfCompressor,
  40. [In] IBaseFilter pfRenderer );
  41. [PreserveSig]
  42. int ControlStream(
  43. [In] ref Guid pCategory,
  44. [In] ref Guid pType,
  45. [In] IBaseFilter pFilter,
  46. [In] long pstart,
  47. [In] long pstop,
  48. [In] short wStartCookie,
  49. [In] short wStopCookie );
  50. [PreserveSig]
  51. int AllocCapFile(
  52. [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrFile,
  53. [In] long dwlSize );
  54. [PreserveSig]
  55. int CopyCaptureFile(
  56. [In, MarshalAs(UnmanagedType.LPWStr)] string lpwstrOld,
  57. [In, MarshalAs(UnmanagedType.LPWStr)] string lpwstrNew,
  58. [In] int fAllowEscAbort,
  59. [In] IAMCopyCaptureFileProgress pFilter );
  60. [PreserveSig]
  61. int FindPin(
  62. [In] object pSource,
  63. [In] int pindir,
  64. [In] ref Guid pCategory,
  65. [In] ref Guid pType,
  66. [In, MarshalAs(UnmanagedType.Bool) ] bool fUnconnected,
  67. [In] int num,
  68. [Out] out IPin ppPin );
  69. }
  70. [ComVisible(true), ComImport,
  71. Guid("56a868a9-0ad4-11ce-b03a-0020af0ba770"),
  72. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  73. public interface IGraphBuilder
  74. {
  75. #region "IFilterGraph Methods"
  76. [PreserveSig]
  77. int AddFilter(
  78. [In] IBaseFilter pFilter,
  79. [In, MarshalAs(UnmanagedType.LPWStr)] string pName );
  80. [PreserveSig]
  81. int RemoveFilter( [In] IBaseFilter pFilter );
  82. [PreserveSig]
  83. int EnumFilters( [Out] out IEnumFilters ppEnum );
  84. [PreserveSig]
  85. int FindFilterByName(
  86. [In, MarshalAs(UnmanagedType.LPWStr)] string pName,
  87. [Out] out IBaseFilter ppFilter );
  88. [PreserveSig]
  89. int ConnectDirect( [In] IPin ppinOut, [In] IPin ppinIn,
  90. [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt );
  91. [PreserveSig]
  92. int Reconnect( [In] IPin ppin );
  93. [PreserveSig]
  94. int Disconnect( [In] IPin ppin );
  95. [PreserveSig]
  96. int SetDefaultSyncSource();
  97. #endregion
  98. [PreserveSig]
  99. int Connect( [In] IPin ppinOut, [In] IPin ppinIn );
  100. [PreserveSig]
  101. int Render( [In] IPin ppinOut );
  102. [PreserveSig]
  103. int RenderFile(
  104. [In, MarshalAs(UnmanagedType.LPWStr)] string lpcwstrFile,
  105. [In, MarshalAs(UnmanagedType.LPWStr)] string lpcwstrPlayList );
  106. [PreserveSig]
  107. int AddSourceFilter(
  108. [In, MarshalAs(UnmanagedType.LPWStr)] string lpcwstrFileName,
  109. [In, MarshalAs(UnmanagedType.LPWStr)] string lpcwstrFilterName,
  110. [Out] out IBaseFilter ppFilter );
  111. [PreserveSig]
  112. int SetLogFile( IntPtr hFile );
  113. [PreserveSig]
  114. int Abort();
  115. [PreserveSig]
  116. int ShouldOperationContinue();
  117. }
  118. // ---------------------------------------------------------------------------------------
  119. [ComVisible(true), ComImport,
  120. Guid("a2104830-7c70-11cf-8bce-00aa00a3f1a6"),
  121. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  122. public interface IFileSinkFilter
  123. {
  124. [PreserveSig]
  125. int SetFileName(
  126. [In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
  127. [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt );
  128. [PreserveSig]
  129. int GetCurFile(
  130. [Out, MarshalAs(UnmanagedType.LPWStr) ] out string pszFileName,
  131. [Out, MarshalAs(UnmanagedType.LPStruct) ] AMMediaType pmt );
  132. }
  133. [ComVisible(true), ComImport,
  134. Guid("00855B90-CE1B-11d0-BD4F-00A0C911CE86"),
  135. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  136. public interface IFileSinkFilter2
  137. {
  138. [PreserveSig]
  139. int SetFileName(
  140. [In, MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
  141. [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt );
  142. [PreserveSig]
  143. int GetCurFile(
  144. [Out, MarshalAs(UnmanagedType.LPWStr) ] out string pszFileName,
  145. [Out, MarshalAs(UnmanagedType.LPStruct) ] AMMediaType pmt );
  146. [PreserveSig]
  147. int SetMode( [In] int dwFlags );
  148. [PreserveSig]
  149. int GetMode( [Out] out int dwFlags );
  150. }
  151. // ---------------------------------------------------------------------------------------
  152. [ComVisible(true), ComImport,
  153. Guid("670d1d20-a068-11d0-b3f0-00aa003761c5"),
  154. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  155. public interface IAMCopyCaptureFileProgress
  156. {
  157. [PreserveSig]
  158. int Progress( int iProgress );
  159. }
  160. // ---------------------------------------------------------------------------------------
  161. [ComVisible(true), ComImport,
  162. Guid("e46a9787-2b71-444d-a4b5-1fab7b708d6a"),
  163. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  164. public interface IVideoFrameStep
  165. {
  166. [PreserveSig]
  167. int Step( int dwFrames,
  168. [In, MarshalAs(UnmanagedType.IUnknown)] object pStepObject );
  169. [PreserveSig]
  170. int CanStep( int bMultiple,
  171. [In, MarshalAs(UnmanagedType.IUnknown)] object pStepObject );
  172. [PreserveSig]
  173. int CancelStep();
  174. }
  175. // ---------------------------------------------------------------------------------------
  176. [ComVisible(true), ComImport,
  177. Guid("C6E13340-30AC-11d0-A18C-00A0C9118956"),
  178. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  179. public interface IAMStreamConfig
  180. {
  181. [PreserveSig]
  182. int SetFormat(
  183. [In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt );
  184. [PreserveSig]
  185. int GetFormat(
  186. [Out] out IntPtr pmt );
  187. [PreserveSig]
  188. int GetNumberOfCapabilities( out int piCount, out int piSize );
  189. [PreserveSig]
  190. int GetStreamCaps( int iIndex,
  191. //[Out, MarshalAs(UnmanagedType.LPStruct)] out AMMediaType ppmt,
  192. [Out] out IntPtr pmt,
  193. [In] IntPtr pSCC );
  194.     }
  195. // =============================================================================
  196. // TUNER
  197. // =============================================================================
  198. [ComVisible(false)]
  199. public enum AMTunerSubChannel
  200. {
  201. NoTune = -2, // AMTUNER_SUBCHAN_NO_TUNE : don't tune
  202. Default = -1 // AMTUNER_SUBCHAN_DEFAULT : use default sub chan
  203. }
  204. [ComVisible(false)]
  205. public enum AMTunerSignalStrength
  206. {
  207. NA = -1, // AMTUNER_HASNOSIGNALSTRENGTH : cannot indicate signal strength
  208. NoSignal = 0, // AMTUNER_NOSIGNAL : no signal available
  209. SignalPresent = 1 // AMTUNER_SIGNALPRESENT : signal present
  210. }
  211. [Flags, ComVisible(false)]
  212. public enum AMTunerModeType
  213. {
  214. Default = 0x0000, // AMTUNER_MODE_DEFAULT : default tuner mode
  215. TV = 0x0001, // AMTUNER_MODE_TV : tv
  216. FMRadio = 0x0002, // AMTUNER_MODE_FM_RADIO : fm radio
  217. AMRadio = 0x0004, // AMTUNER_MODE_AM_RADIO : am radio
  218. Dss = 0x0008 // AMTUNER_MODE_DSS : dss
  219. }
  220. [ComVisible(false)]
  221. public enum AMTunerEventType
  222. {
  223. Changed = 0x0001, // AMTUNER_EVENT_CHANGED : status changed
  224. }
  225. // ---------------------------------------------------------------------------------------
  226. [ComVisible(true), ComImport,
  227. Guid("211A8761-03AC-11d1-8D13-00AA00BD8339"),
  228. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  229. public interface IAMTuner
  230. {
  231. [PreserveSig]
  232. int put_Channel( int lChannel, AMTunerSubChannel lVideoSubChannel, AMTunerSubChannel lAudioSubChannel );
  233. [PreserveSig]
  234. int get_Channel( out int plChannel, out int plVideoSubChannel, out int plAudioSubChannel );
  235.     
  236. [PreserveSig]
  237. int ChannelMinMax( out int lChannelMin, out int lChannelMax );
  238.         
  239. [PreserveSig]
  240. int put_CountryCode( int lCountryCode );
  241. [PreserveSig]
  242. int get_CountryCode( out int plCountryCode );
  243. [PreserveSig]
  244. int put_TuningSpace( int lTuningSpace );
  245. [PreserveSig]
  246. int get_TuningSpace( out int plTuningSpace );
  247. [PreserveSig]
  248. int Logon( IntPtr hCurrentUser );
  249.     
  250. [PreserveSig]
  251. int Logout();
  252. [PreserveSig]
  253. int SignalPresent( out AMTunerSignalStrength plSignalStrength );
  254.     
  255. [PreserveSig]
  256. int put_Mode( AMTunerModeType lMode );
  257. [PreserveSig]
  258. int get_Mode( out AMTunerModeType plMode );
  259.     
  260. [PreserveSig]
  261. int GetAvailableModes( out AMTunerModeType plModes );
  262.     
  263. [PreserveSig]
  264. int RegisterNotificationCallBack( IAMTunerNotification pNotify, AMTunerEventType lEvents );
  265. [PreserveSig]
  266. int UnRegisterNotificationCallBack( IAMTunerNotification pNotify );
  267. }
  268. // ---------------------------------------------------------------------------------------
  269. [ComVisible(true), ComImport,
  270. Guid("211A8760-03AC-11d1-8D13-00AA00BD8339"),
  271. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  272. public interface IAMTunerNotification
  273. {
  274. [PreserveSig]
  275. int OnEvent( AMTunerEventType Event );
  276. }
  277. // ---------------------------------------------------------------------------------------
  278. [Flags, ComVisible(false)]
  279. public enum AnalogVideoStandard
  280. {
  281. None = 0x00000000,  // This is a digital sensor
  282. NTSC_M = 0x00000001,  //        75 IRE Setup
  283. NTSC_M_J = 0x00000002,  // Japan,  0 IRE Setup
  284. NTSC_433 = 0x00000004,
  285. PAL_B = 0x00000010,
  286. PAL_D = 0x00000020,
  287. PAL_G = 0x00000040,
  288. PAL_H = 0x00000080,
  289. PAL_I = 0x00000100,
  290. PAL_M = 0x00000200,
  291. PAL_N = 0x00000400,
  292. PAL_60 = 0x00000800,
  293. SECAM_B = 0x00001000,
  294. SECAM_D = 0x00002000,
  295. SECAM_G = 0x00004000,
  296. SECAM_H = 0x00008000,
  297. SECAM_K = 0x00010000,
  298. SECAM_K1 = 0x00020000,
  299. SECAM_L = 0x00040000,
  300. SECAM_L1 = 0x00080000,
  301. PAL_N_COMBO = 0x00100000 // Argentina
  302. }
  303. [ComVisible(false)]
  304. public enum TunerInputType
  305. {
  306. Cable,
  307. Antenna
  308. }
  309. // ---------------------------------------------------------------------------------------
  310. [ComVisible(true), ComImport,
  311. Guid("211A8766-03AC-11d1-8D13-00AA00BD8339"),
  312. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  313. public interface IAMTVTuner
  314. {
  315. #region "IAMTuner Methods"
  316. [PreserveSig]
  317. int put_Channel( int lChannel, AMTunerSubChannel lVideoSubChannel, AMTunerSubChannel lAudioSubChannel );
  318. [PreserveSig]
  319. int get_Channel( out int plChannel, out int plVideoSubChannel, out int plAudioSubChannel );
  320.     
  321. [PreserveSig]
  322. int ChannelMinMax( out int lChannelMin, out int lChannelMax );
  323.         
  324. [PreserveSig]
  325. int put_CountryCode( int lCountryCode );
  326. [PreserveSig]
  327. int get_CountryCode( out int plCountryCode );
  328. [PreserveSig]
  329. int put_TuningSpace( int lTuningSpace );
  330. [PreserveSig]
  331. int get_TuningSpace( out int plTuningSpace );
  332. [PreserveSig]
  333. int Logon( IntPtr hCurrentUser );
  334.     
  335. [PreserveSig]
  336. int Logout();
  337. [PreserveSig]
  338. int SignalPresent( out AMTunerSignalStrength plSignalStrength );
  339.     
  340. [PreserveSig]
  341. int put_Mode( AMTunerModeType lMode );
  342. [PreserveSig]
  343. int get_Mode( out AMTunerModeType plMode );
  344.     
  345. [PreserveSig]
  346. int GetAvailableModes( out AMTunerModeType plModes );
  347.     
  348. [PreserveSig]
  349. int RegisterNotificationCallBack( IAMTunerNotification pNotify, AMTunerEventType lEvents );
  350. [PreserveSig]
  351. int UnRegisterNotificationCallBack( IAMTunerNotification pNotify );
  352. #endregion
  353. [PreserveSig]
  354. int get_AvailableTVFormats( out AnalogVideoStandard lAnalogVideoStandard );
  355. [PreserveSig]
  356. int get_TVFormat( out AnalogVideoStandard lAnalogVideoStandard );
  357.     
  358. [PreserveSig]
  359. int AutoTune( int lChannel, out int plFoundSignal );
  360.     
  361. [PreserveSig]
  362. int StoreAutoTune();
  363.     
  364. [PreserveSig]
  365. int get_NumInputConnections( out int plNumInputConnections );
  366.     
  367. [PreserveSig]
  368. int put_InputType( int lIndex, TunerInputType inputType );
  369.     
  370. [PreserveSig]
  371. int get_InputType( int lIndex, out TunerInputType inputType );
  372. [PreserveSig]
  373. int put_ConnectInput( int lIndex );
  374.     
  375. [PreserveSig]
  376. int get_ConnectInput( out int lIndex );
  377. [PreserveSig]
  378. int get_VideoFrequency( out int lFreq );
  379. [PreserveSig]
  380. int get_AudioFrequency( out int lFreq );
  381. }
  382. // ---------------------------------------------------------------------------------------
  383. [ComVisible(true), ComImport,
  384. Guid("C6E13380-30AC-11d0-A18C-00A0C9118956"),
  385. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  386. public interface IAMCrossbar
  387. {
  388. [PreserveSig]
  389. int get_PinCounts(
  390. [Out] out int OutputPinCount, 
  391. [Out] out int InputPinCount );
  392. [PreserveSig]
  393. int CanRoute( 
  394. [In]  int OutputPinIndex, 
  395. [In]  int InputPinIndex );
  396. [PreserveSig]
  397. int Route( 
  398. [In]  int OutputPinIndex, 
  399. [In]  int InputPinIndex );
  400. [PreserveSig]
  401. int get_IsRoutedTo( 
  402. [In] int OutputPinIndex, 
  403. [Out] out int InputPinIndex );
  404. [PreserveSig]
  405. int get_CrossbarPinInfo( 
  406. [In, MarshalAs(UnmanagedType.Bool)] bool IsInputPin, 
  407. [In]  int PinIndex,
  408. [Out] out int PinIndexRelated,
  409. [Out] out PhysicalConnectorType PhysicalType
  410. );
  411. }
  412. // ---------------------------------------------------------------------------------------
  413. [ComVisible(true), ComImport,
  414. Guid("54C39221-8380-11d0-B3F0-00AA003761C5"),
  415. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  416. public interface IAMAudioInputMixer
  417. {
  418. // This interface is only supported by the input pins, not the filter
  419. // If disabled, this channel will not be mixed in as part of the
  420. // recorded signal.
  421. int put_Enable (
  422. [In] bool fEnable); // TRUE=enable FALSE=disable
  423. //Is this channel enabled?
  424. int get_Enable (
  425. [Out] out bool pfEnable);
  426. // When set to mono mode, making a stereo recording of this channel
  427. // will have both channels contain the same data... a mixture of the
  428. // left and right signals
  429. int put_Mono (
  430. [In] bool fMono); // TRUE=mono FALSE=multi channel
  431. //all channels combined into a mono signal?
  432. int get_Mono (
  433. [Out] out bool pfMono);
  434. // !!! WILL CARDS BE ABLE TO BOOST THE GAIN?
  435. //Set the record level for this channel
  436. int put_MixLevel (
  437. [In] double Level); // 0 = off, 1 = full (unity?) volume
  438. // AMF_AUTOMATICGAIN, if supported,
  439. // means automatic
  440. //Get the record level for this channel
  441. int get_MixLevel (
  442. [Out] out double pLevel);
  443. // For instance, when panned full left, and you make a stereo recording
  444. // of this channel, you will record a silent right channel.
  445. int put_Pan (
  446. [In] double Pan); // -1 = full left, 0 = centre, 1 = right
  447. //Get the pan for this channel
  448. int get_Pan (
  449. [Out] out double pPan);
  450. // Boosts the bass of low volume signals before they are recorded
  451. // to compensate for the fact that your ear has trouble hearing quiet
  452. // bass sounds
  453. int put_Loudness (
  454. [In] bool fLoudness);// TRUE=on FALSE=off
  455. int get_Loudness (
  456. [Out] out bool pfLoudness);
  457. // boosts or cuts the treble of the signal before it's recorded by
  458. // a certain amount of dB
  459. int put_Treble (
  460. [In] double Treble); // gain in dB (-ve = attenuate)
  461. //Get the treble EQ for this channel
  462. int get_Treble (
  463. [Out] out double pTreble);
  464. // This is the maximum value allowed in put_Treble.  ie 6.0 means
  465. // any value between -6.0 and 6.0 is allowed
  466. int get_TrebleRange (
  467. [Out] out double pRange); // largest value allowed
  468. // boosts or cuts the bass of the signal before it's recorded by
  469. // a certain amount of dB
  470. int put_Bass (
  471. [In] double Bass); // gain in dB (-ve = attenuate)
  472. // Get the bass EQ for this channel
  473. int get_Bass (
  474. [Out] out double pBass);
  475. // This is the maximum value allowed in put_Bass.  ie 6.0 means
  476. // any value between -6.0 and 6.0 is allowed
  477. int get_BassRange (
  478. [Out] out double pRange); // largest value allowed
  479. }
  480. // ---------------------------------------------------------------------------------------
  481. public enum VfwCompressDialogs
  482. {
  483. Config = 0x01,
  484. About =  0x02,
  485. QueryConfig = 0x04,
  486. QueryAbout =  0x08
  487. }
  488. // ---------------------------------------------------------------------------------------
  489. [ComVisible(true), ComImport,
  490. Guid("D8D715A3-6E5E-11D0-B3F0-00AA003761C5"),
  491. InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
  492. public interface IAMVfwCompressDialogs
  493. {
  494. [PreserveSig]
  495. // Bring up a dialog for this codec
  496. int ShowDialog(
  497. [In]  VfwCompressDialogs iDialog,
  498. [In]  IntPtr hwnd );
  499. // Calls ICGetState and gives you the result
  500. int GetState(
  501. [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] byte[] pState,
  502. ref int pcbState );
  503. // Calls ICSetState
  504. int SetState(
  505. [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] byte[] pState,
  506. [In] int cbState );
  507. // Send a codec specific message
  508. int SendDriverMessage(
  509. int uMsg,
  510. long dw1,
  511. long dw2 );
  512. }
  513. // ---------------------------------------------------------------------------------------
  514. [StructLayout(LayoutKind.Sequential), ComVisible(false)]
  515. public class VideoStreamConfigCaps // VIDEO_STREAM_CONFIG_CAPS
  516. {
  517. public Guid Guid;
  518. public AnalogVideoStandard     VideoStandard;
  519. public Size InputSize;
  520. public Size MinCroppingSize;
  521. public Size MaxCroppingSize;
  522. public int CropGranularityX;
  523. public int CropGranularityY;
  524. public int CropAlignX;
  525. public int CropAlignY;
  526. public Size MinOutputSize;
  527. public Size MaxOutputSize;
  528. public int OutputGranularityX;
  529. public int OutputGranularityY;
  530. public int StretchTapsX;
  531. public int StretchTapsY;
  532. public int ShrinkTapsX;
  533. public int ShrinkTapsY;
  534. public long MinFrameInterval;
  535. public long MaxFrameInterval;
  536. public int MinBitsPerSecond;
  537. public int MaxBitsPerSecond;
  538. }
  539. // ---------------------------------------------------------------------------------------
  540. [StructLayout(LayoutKind.Sequential), ComVisible(false)]
  541. public class AudioStreamConfigCaps  // AUDIO_STREAM_CONFIG_CAPS
  542. {
  543. public Guid Guid;
  544. public int MinimumChannels;
  545. public int MaximumChannels;
  546. public int ChannelsGranularity;
  547. public int MinimumBitsPerSample;
  548. public int MaximumBitsPerSample;
  549. public int BitsPerSampleGranularity;
  550. public int MinimumSampleFrequency;
  551. public int MaximumSampleFrequency;
  552. public int SampleFrequencyGranularity;
  553. }
  554. } // namespace DShowNET