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

Video Capture

Development Platform:

Visual C++

  1. // ------------------------------------------------------------------
  2. // DirectX.Capture
  3. //
  4. // History:
  5. // 2003-Jan-24 BL - created
  6. //
  7. // Copyright (c) 2003 Brian Low
  8. // ------------------------------------------------------------------
  9. using System;
  10. using System.Runtime.InteropServices; 
  11. using System.Windows.Forms;
  12. using DShowNET;
  13. namespace DirectX.Capture
  14. {
  15. /// <summary>
  16. ///  The property page to configure a Video for Windows compliant
  17. ///  compression codec. Most compressors support this property page
  18. ///  rather than a DirectShow property page. Also, most compressors
  19. ///  do not support the IAMVideoCompression interface so this
  20. ///  property page is the only method to configure a compressor. 
  21. /// </summary>
  22. public class VfwCompressorPropertyPage : PropertyPage
  23. {
  24. // ---------------- Properties --------------------
  25. /// <summary> Video for Windows compression dialog interface </summary>
  26. protected IAMVfwCompressDialogs vfwCompressDialogs = null;
  27. /// <summary> 
  28. ///  Get or set the state of the property page. This is used to save
  29. ///  and restore the user's choices without redisplaying the property page.
  30. ///  This property will be null if unable to retrieve the property page's
  31. ///  state.
  32. /// </summary>
  33. /// <remarks>
  34. ///  After showing this property page, read and store the value of 
  35. ///  this property. At a later time, the user's choices can be 
  36. ///  reloaded by setting this property with the value stored earlier. 
  37. ///  Note that some property pages, after setting this property, 
  38. ///  will not reflect the new state. However, the filter will use the
  39. ///  new settings.
  40. /// </remarks>
  41. public override byte[] State
  42. {
  43. get 
  44. byte[] data = null;
  45. int size = 0;
  46. int hr = vfwCompressDialogs.GetState( null, ref size );
  47. if ( ( hr == 0 ) && ( size > 0 ) )
  48. {
  49. data = new byte[size];
  50. hr = vfwCompressDialogs.GetState( data, ref size );
  51. if ( hr != 0 ) data = null;
  52. }
  53. return( data );
  54. }
  55. set 
  56. {  
  57. int hr = vfwCompressDialogs.SetState( value, value.Length );
  58. if ( hr != 0 ) Marshal.ThrowExceptionForHR( hr );
  59. }
  60. }
  61. // ---------------- Constructors --------------------
  62. /// <summary> Constructor </summary>
  63. public VfwCompressorPropertyPage(string name, IAMVfwCompressDialogs compressDialogs)
  64. {
  65. Name = name;
  66. SupportsPersisting = true;
  67. this.vfwCompressDialogs = compressDialogs;
  68. }
  69. // ---------------- Public Methods --------------------
  70. /// <summary> 
  71. ///  Show the property page. Some property pages cannot be displayed 
  72. ///  while previewing and/or capturing. 
  73. /// </summary>
  74. public override void Show(Control owner)
  75. {
  76. vfwCompressDialogs.ShowDialog( VfwCompressDialogs.Config, owner.Handle );
  77. }
  78. }
  79. }