// AForge Direct Show Library // AForge.NET framework // http://www.aforgenet.com/framework/ // // Copyright © AForge.NET, 2009-2013 // contacts@aforgenet.com // namespace AForge.Video.DirectShow.Internals { using System; using System.Runtime.InteropServices; using System.Drawing; // PIN_DIRECTION /// /// This enumeration indicates a pin's direction. /// /// [ComVisible( false )] internal enum PinDirection { /// /// Input pin. /// Input, /// /// Output pin. /// Output } // AM_MEDIA_TYPE /// /// The structure describes the format of a media sample. /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential )] internal class AMMediaType : IDisposable { /// /// Globally unique identifier (GUID) that specifies the major type of the media sample. /// public Guid MajorType; /// /// GUID that specifies the subtype of the media sample. /// public Guid SubType; /// /// If true, samples are of a fixed size. /// [MarshalAs( UnmanagedType.Bool )] public bool FixedSizeSamples = true; /// /// If true, samples are compressed using temporal (interframe) compression. /// [MarshalAs( UnmanagedType.Bool )] public bool TemporalCompression; /// /// Size of the sample in bytes. For compressed data, the value can be zero. /// public int SampleSize = 1; /// /// GUID that specifies the structure used for the format block. /// public Guid FormatType; /// /// Not used. /// public IntPtr unkPtr; /// /// Size of the format block, in bytes. /// public int FormatSize; /// /// Pointer to the format block. /// public IntPtr FormatPtr; /// /// Destroys the instance of the class. /// /// ~AMMediaType( ) { Dispose( false ); } /// /// Dispose the object. /// /// public void Dispose( ) { Dispose( true ); // remove me from the Finalization queue GC.SuppressFinalize( this ); } /// /// Dispose the object /// /// /// Indicates if disposing was initiated manually. /// protected virtual void Dispose( bool disposing ) { if ( ( FormatSize != 0 ) && ( FormatPtr != IntPtr.Zero ) ) { Marshal.FreeCoTaskMem( FormatPtr ); FormatSize = 0; } if ( unkPtr != IntPtr.Zero ) { Marshal.Release( unkPtr ); unkPtr = IntPtr.Zero; } } } // PIN_INFO /// /// The structure contains information about a pin. /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode )] internal struct PinInfo { /// /// Owning filter. /// public IBaseFilter Filter; /// /// Direction of the pin. /// public PinDirection Direction; /// /// Name of the pin. /// [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )] public string Name; } // FILTER_INFO [ComVisible( false ), StructLayout( LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode )] internal struct FilterInfo { /// /// Filter's name. /// [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )] public string Name; /// /// Owning graph. /// public IFilterGraph FilterGraph; } // VIDEOINFOHEADER /// /// The structure describes the bitmap and color information for a video image. /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential )] internal struct VideoInfoHeader { /// /// structure that specifies the source video window. /// public RECT SrcRect; /// /// structure that specifies the destination video window. /// public RECT TargetRect; /// /// Approximate data rate of the video stream, in bits per second. /// public int BitRate; /// /// Data error rate, in bit errors per second. /// public int BitErrorRate; /// /// The desired average display time of the video frames, in 100-nanosecond units. /// public long AverageTimePerFrame; /// /// structure that contains color and dimension information for the video image bitmap. /// public BitmapInfoHeader BmiHeader; } // VIDEOINFOHEADER2 /// /// The structure describes the bitmap and color information for a video image (v2). /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential )] internal struct VideoInfoHeader2 { /// /// structure that specifies the source video window. /// public RECT SrcRect; /// /// structure that specifies the destination video window. /// public RECT TargetRect; /// /// Approximate data rate of the video stream, in bits per second. /// public int BitRate; /// /// Data error rate, in bit errors per second. /// public int BitErrorRate; /// /// The desired average display time of the video frames, in 100-nanosecond units. /// public long AverageTimePerFrame; /// /// Flags that specify how the video is interlaced. /// public int InterlaceFlags; /// /// Flag set to indicate that the duplication of the stream should be restricted. /// public int CopyProtectFlags; /// /// The X dimension of picture aspect ratio. /// public int PictAspectRatioX; /// /// The Y dimension of picture aspect ratio. /// public int PictAspectRatioY; /// /// Reserved for future use. /// public int Reserved1; /// /// Reserved for future use. /// public int Reserved2; /// /// structure that contains color and dimension information for the video image bitmap. /// public BitmapInfoHeader BmiHeader; } /// /// The structure contains information about the dimensions and color format of a device-independent bitmap (DIB). /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential, Pack = 2 )] internal struct BitmapInfoHeader { /// /// Specifies the number of bytes required by the structure. /// public int Size; /// /// Specifies the width of the bitmap. /// public int Width; /// /// Specifies the height of the bitmap, in pixels. /// public int Height; /// /// Specifies the number of planes for the target device. This value must be set to 1. /// public short Planes; /// /// Specifies the number of bits per pixel. /// public short BitCount; /// /// If the bitmap is compressed, this member is a FOURCC the specifies the compression. /// public int Compression; /// /// Specifies the size, in bytes, of the image. /// public int ImageSize; /// /// Specifies the horizontal resolution, in pixels per meter, of the target device for the bitmap. /// public int XPelsPerMeter; /// /// Specifies the vertical resolution, in pixels per meter, of the target device for the bitmap. /// public int YPelsPerMeter; /// /// Specifies the number of color indices in the color table that are actually used by the bitmap. /// public int ColorsUsed; /// /// Specifies the number of color indices that are considered important for displaying the bitmap. /// public int ColorsImportant; } // RECT /// /// The structure defines the coordinates of the upper-left and lower-right corners of a rectangle. /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential )] internal struct RECT { /// /// Specifies the x-coordinate of the upper-left corner of the rectangle. /// public int Left; /// /// Specifies the y-coordinate of the upper-left corner of the rectangle. /// public int Top; /// /// Specifies the x-coordinate of the lower-right corner of the rectangle. /// public int Right; /// /// Specifies the y-coordinate of the lower-right corner of the rectangle. /// public int Bottom; } // CAUUID /// /// The CAUUID structure is a Counted Array of UUID or GUID types. /// /// [ComVisible( false ), StructLayout( LayoutKind.Sequential )] internal struct CAUUID { /// /// Size of the array pointed to by pElems. /// public int cElems; /// /// Pointer to an array of UUID values, each of which specifies UUID. /// public IntPtr pElems; /// /// Performs manual marshaling of pElems to retrieve an array of Guid objects. /// /// /// A managed representation of pElems. /// public Guid[] ToGuidArray( ) { Guid[] retval = new Guid[cElems]; for ( int i = 0; i < cElems; i++ ) { IntPtr ptr = new IntPtr( pElems.ToInt64( ) + i * Marshal.SizeOf( typeof( Guid ) ) ); retval[i] = (Guid) Marshal.PtrToStructure( ptr, typeof( Guid ) ); } return retval; } } /// /// Enumeration of DirectShow event codes. /// internal enum DsEvCode { None, Complete = 0x01, // EC_COMPLETE DeviceLost = 0x1F, // EC_DEVICE_LOST //(...) not yet interested in other events } [Flags, ComVisible( false )] internal enum AnalogVideoStandard { None = 0x00000000, // This is a digital sensor NTSC_M = 0x00000001, // 75 IRE Setup NTSC_M_J = 0x00000002, // Japan, 0 IRE Setup NTSC_433 = 0x00000004, PAL_B = 0x00000010, PAL_D = 0x00000020, PAL_G = 0x00000040, PAL_H = 0x00000080, PAL_I = 0x00000100, PAL_M = 0x00000200, PAL_N = 0x00000400, PAL_60 = 0x00000800, SECAM_B = 0x00001000, SECAM_D = 0x00002000, SECAM_G = 0x00004000, SECAM_H = 0x00008000, SECAM_K = 0x00010000, SECAM_K1 = 0x00020000, SECAM_L = 0x00040000, SECAM_L1 = 0x00080000, PAL_N_COMBO = 0x00100000 // Argentina } [Flags, ComVisible( false )] internal enum VideoControlFlags { FlipHorizontal = 0x0001, FlipVertical = 0x0002, ExternalTriggerEnable = 0x0004, Trigger = 0x0008 } [StructLayout( LayoutKind.Sequential ), ComVisible( false )] internal class VideoStreamConfigCaps // VIDEO_STREAM_CONFIG_CAPS { public Guid Guid; public AnalogVideoStandard VideoStandard; public Size InputSize; public Size MinCroppingSize; public Size MaxCroppingSize; public int CropGranularityX; public int CropGranularityY; public int CropAlignX; public int CropAlignY; public Size MinOutputSize; public Size MaxOutputSize; public int OutputGranularityX; public int OutputGranularityY; public int StretchTapsX; public int StretchTapsY; public int ShrinkTapsX; public int ShrinkTapsY; public long MinFrameInterval; public long MaxFrameInterval; public int MinBitsPerSecond; public int MaxBitsPerSecond; } /// /// Specifies a filter's state or the state of the filter graph. /// internal enum FilterState { /// /// Stopped. The filter is not processing data. /// State_Stopped, /// /// Paused. The filter is processing data, but not rendering it. /// State_Paused, /// /// Running. The filter is processing and rendering data. /// State_Running } }