Add FrmWebcam

This commit is contained in:
2017-11-30 18:31:46 +01:00
parent 409f0f7ad3
commit ab7574adc2
38 changed files with 4700 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
/// <summary>
/// The enumeration specifies a setting on a camera.
/// </summary>
public enum CameraControlProperty
{
/// <summary>
/// Pan control.
/// </summary>
Pan = 0,
/// <summary>
/// Tilt control.
/// </summary>
Tilt,
/// <summary>
/// Roll control.
/// </summary>
Roll,
/// <summary>
/// Zoom control.
/// </summary>
Zoom,
/// <summary>
/// Exposure control.
/// </summary>
Exposure,
/// <summary>
/// Iris control.
/// </summary>
Iris,
/// <summary>
/// Focus control.
/// </summary>
Focus
}
/// <summary>
/// The enumeration defines whether a camera setting is controlled manually or automatically.
/// </summary>
[Flags]
public enum CameraControlFlags
{
/// <summary>
/// No control flag.
/// </summary>
None = 0x0,
/// <summary>
/// Auto control Flag.
/// </summary>
Auto = 0x0001,
/// <summary>
/// Manual control Flag.
/// </summary>
Manual = 0x0002
}
}

View File

@@ -0,0 +1,73 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The IAMCameraControl interface controls camera settings such as zoom, pan, aperture adjustment,
/// or shutter speed. To obtain this interface, query the filter that controls the camera.
/// </summary>
[ComImport,
Guid( "C6E13370-30AC-11d0-A18C-00A0C9118956" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IAMCameraControl
{
/// <summary>
/// Gets the range and default value of a specified camera property.
/// </summary>
///
/// <param name="Property">Specifies the property to query.</param>
/// <param name="pMin">Receives the minimum value of the property.</param>
/// <param name="pMax">Receives the maximum value of the property.</param>
/// <param name="pSteppingDelta">Receives the step size for the property.</param>
/// <param name="pDefault">Receives the default value of the property. </param>
/// <param name="pCapsFlags">Receives a member of the CameraControlFlags enumeration, indicating whether the property is controlled automatically or manually.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetRange(
[In] CameraControlProperty Property,
[Out] out int pMin,
[Out] out int pMax,
[Out] out int pSteppingDelta,
[Out] out int pDefault,
[Out] out CameraControlFlags pCapsFlags
);
/// <summary>
/// Sets a specified property on the camera.
/// </summary>
///
/// <param name="Property">Specifies the property to set.</param>
/// <param name="lValue">Specifies the new value of the property.</param>
/// <param name="Flags">Specifies the desired control setting, as a member of the CameraControlFlags enumeration.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Set(
[In] CameraControlProperty Property,
[In] int lValue,
[In] CameraControlFlags Flags
);
/// <summary>
/// Gets the current setting of a camera property.
/// </summary>
///
/// <param name="Property">Specifies the property to retrieve.</param>
/// <param name="lValue">Receives the value of the property.</param>
/// <param name="Flags">Receives a member of the CameraControlFlags enumeration.
/// The returned value indicates whether the setting is controlled manually or automatically.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Get(
[In] CameraControlProperty Property,
[Out] out int lValue,
[Out] out CameraControlFlags Flags
);
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code.DirectShow
{
/// <summary>
/// The IAMCrossbar interface routes signals from an analog or digital source to a video capture filter.
/// </summary>
[ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid( "C6E13380-30AC-11D0-A18C-00A0C9118956" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IAMCrossbar
{
/// <summary>
/// Retrieves the number of input and output pins on the crossbar filter.
/// </summary>
///
/// <param name="outputPinCount">Variable that receives the number of output pins.</param>
/// <param name="inputPinCount">Variable that receives the number of input pins.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_PinCounts( [Out] out int outputPinCount, [Out] out int inputPinCount );
/// <summary>
/// Queries whether a specified input pin can be routed to a specified output pin.
/// </summary>
///
/// <param name="outputPinIndex">Specifies the index of the output pin.</param>
/// <param name="inputPinIndex">Specifies the index of input pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int CanRoute( [In] int outputPinIndex, [In] int inputPinIndex );
/// <summary>
/// Routes an input pin to an output pin.
/// </summary>
///
/// <param name="outputPinIndex">Specifies the index of the output pin.</param>
/// <param name="inputPinIndex">Specifies the index of the input pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Route( [In] int outputPinIndex, [In] int inputPinIndex );
/// <summary>
/// Retrieves the input pin that is currently routed to the specified output pin.
/// </summary>
///
/// <param name="outputPinIndex">Specifies the index of the output pin.</param>
/// <param name="inputPinIndex">Variable that receives the index of the input pin, or -1 if no input pin is routed to this output pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_IsRoutedTo( [In] int outputPinIndex, [Out] out int inputPinIndex );
/// <summary>
/// Retrieves information about a specified pin.
/// </summary>
///
/// <param name="isInputPin">Specifies the direction of the pin. Use one of the following values.</param>
/// <param name="pinIndex">Specifies the index of the pin.</param>
/// <param name="pinIndexRelated">Variable that receives the index of the related pin, or 1 if no pin is related to this pin.</param>
/// <param name="physicalType">Variable that receives a member of the PhysicalConnectorType enumeration, indicating the pin's physical type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_CrossbarPinInfo(
[In, MarshalAs( UnmanagedType.Bool )] bool isInputPin,
[In] int pinIndex,
[Out] out int pinIndexRelated,
[Out] out PhysicalConnectorType physicalType );
}
}

View File

@@ -0,0 +1,67 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This interface sets the output format on certain capture and compression filters,
/// for both audio and video.
/// </summary>
///
[ComImport,
Guid( "C6E13340-30AC-11d0-A18C-00A0C9118956" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IAMStreamConfig
{
/// <summary>
/// Set the output format on the pin.
/// </summary>
///
/// <param name="mediaType">Media type to set.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetFormat( [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Retrieves the audio or video stream's format.
/// </summary>
///
/// <param name="mediaType">Retrieved media type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetFormat( [Out, MarshalAs( UnmanagedType.LPStruct )] out AMMediaType mediaType );
/// <summary>
/// Retrieve the number of format capabilities that this pin supports.
/// </summary>
///
/// <param name="count">Variable that receives the number of format capabilities.</param>
/// <param name="size">Variable that receives the size of the configuration structure in bytes.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetNumberOfCapabilities( out int count, out int size );
/// <summary>
/// Retrieve a set of format capabilities.
/// </summary>
///
/// <param name="index">Specifies the format capability to retrieve, indexed from zero.</param>
/// <param name="mediaType">Retrieved media type.</param>
/// <param name="streamConfigCaps">Byte array, which receives information about capabilities.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetStreamCaps(
[In] int index,
[Out, MarshalAs( UnmanagedType.LPStruct )] out AMMediaType mediaType,
[In, MarshalAs( UnmanagedType.LPStruct )] VideoStreamConfigCaps streamConfigCaps
);
}
}

View File

@@ -0,0 +1,104 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface controls certain video capture operations such as enumerating available
/// frame rates and image orientation.
/// </summary>
///
[ComImport,
Guid( "6A2E0670-28E4-11D0-A18c-00A0C9118956" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IAMVideoControl
{
/// <summary>
/// Retrieves the capabilities of the underlying hardware.
/// </summary>
///
/// <param name="pin">Pin to query capabilities from.</param>
/// <param name="flags">Get capabilities of the specified pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetCaps( [In] IPin pin, [Out, MarshalAs( UnmanagedType.I4 )] out VideoControlFlags flags );
/// <summary>
/// Sets the video control mode of operation.
/// </summary>
///
/// <param name="pin">The pin to set the video control mode on.</param>
/// <param name="mode">Value specifying a combination of the flags to set the video control mode.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetMode( [In] IPin pin, [In, MarshalAs( UnmanagedType.I4 )] VideoControlFlags mode );
/// <summary>
/// Retrieves the video control mode of operation.
/// </summary>
///
/// <param name="pin">The pin to retrieve the video control mode from.</param>
/// <param name="mode">Gets combination of flags, which specify the video control mode.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetMode( [In] IPin pin, [Out, MarshalAs( UnmanagedType.I4 )] out VideoControlFlags mode );
/// <summary>
/// The method retrieves the actual frame rate, expressed as a frame duration in 100-nanosecond units.
/// USB (Universal Serial Bus) and IEEE 1394 cameras may provide lower frame rates than requested
/// because of bandwidth availability. This is only available during video streaming.
/// </summary>
///
/// <param name="pin">The pin to retrieve the frame rate from.</param>
/// <param name="actualFrameRate">Gets frame rate in frame duration in 100-nanosecond units.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetCurrentActualFrameRate( [In] IPin pin, [Out, MarshalAs( UnmanagedType.I8 )] out long actualFrameRate );
/// <summary>
/// Retrieves the maximum frame rate currently available based on bus bandwidth usage for connections
/// such as USB and IEEE 1394 camera devices where the maximum frame rate can be limited by bandwidth
/// availability.
/// </summary>
///
/// <param name="pin">The pin to retrieve the maximum frame rate from.</param>
/// <param name="index">Index of the format to query for maximum frame rate. This index corresponds
/// to the order in which formats are enumerated by <see cref="IAMStreamConfig.GetStreamCaps"/>.</param>
/// <param name="dimensions">Frame image size (width and height) in pixels.</param>
/// <param name="maxAvailableFrameRate">Gets maximum available frame rate. The frame rate is expressed as frame duration in 100-nanosecond units.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetMaxAvailableFrameRate( [In] IPin pin, [In] int index,
[In] System.Drawing.Size dimensions,
[Out] out long maxAvailableFrameRate );
/// <summary>
/// Retrieves a list of available frame rates.
/// </summary>
///
/// <param name="pin">The pin to retrieve the maximum frame rate from.</param>
/// <param name="index">Index of the format to query for maximum frame rate. This index corresponds
/// to the order in which formats are enumerated by <see cref="IAMStreamConfig.GetStreamCaps"/>.</param>
/// <param name="dimensions">Frame image size (width and height) in pixels.</param>
/// <param name="listSize">Number of elements in the list of frame rates.</param>
/// <param name="frameRate">Array of frame rates in 100-nanosecond units.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetFrameRateList( [In] IPin pin, [In] int index,
[In] System.Drawing.Size dimensions,
[Out] out int listSize,
[Out] out IntPtr frameRate );
}
}

View File

@@ -0,0 +1,154 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The IBaseFilter interface provides methods for controlling a filter.
/// All DirectShow filters expose this interface
/// </summary>
///
[ComImport,
Guid( "56A86895-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IBaseFilter
{
// --- IPersist Methods
/// <summary>
/// Returns the class identifier (CLSID) for the component object.
/// </summary>
///
/// <param name="ClassID">Points to the location of the CLSID on return.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetClassID( [Out] out Guid ClassID );
// --- IMediaFilter Methods
/// <summary>
/// Stops the filter.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Stop( );
/// <summary>
/// Pauses the filter.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Pause( );
/// <summary>
/// Runs the filter.
/// </summary>
///
/// <param name="start">Reference time corresponding to stream time 0.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Run( long start );
/// <summary>
/// Retrieves the state of the filter (running, stopped, or paused).
/// </summary>
///
/// <param name="milliSecsTimeout">Time-out interval, in milliseconds.</param>
/// <param name="filterState">Pointer to a variable that receives filter's state.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetState( int milliSecsTimeout, [Out] out int filterState );
/// <summary>
/// Sets the reference clock for the filter or the filter graph.
/// </summary>
///
/// <param name="clock">Pointer to the clock's <b>IReferenceClock</b> interface, or NULL. </param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetSyncSource( [In] IntPtr clock );
/// <summary>
/// Retrieves the current reference clock.
/// </summary>
///
/// <param name="clock">Address of a variable that receives a pointer to the clock's IReferenceClock interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetSyncSource( [Out] out IntPtr clock );
// --- IBaseFilter Methods
/// <summary>
/// Enumerates the pins on this filter.
/// </summary>
///
/// <param name="enumPins">Address of a variable that receives a pointer to the IEnumPins interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EnumPins( [Out] out IEnumPins enumPins );
/// <summary>
/// Retrieves the pin with the specified identifier.
/// </summary>
///
/// <param name="id">Pointer to a constant wide-character string that identifies the pin.</param>
/// <param name="pin">Address of a variable that receives a pointer to the pin's IPin interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindPin( [In, MarshalAs( UnmanagedType.LPWStr )] string id, [Out] out IPin pin );
/// <summary>
/// Retrieves information about the filter.
/// </summary>
///
/// <param name="filterInfo">Pointer to <b>FilterInfo</b> structure.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryFilterInfo( [Out] out FilterInfo filterInfo );
/// <summary>
/// Notifies the filter that it has joined or left the filter graph.
/// </summary>
///
/// <param name="graph">Pointer to the Filter Graph Manager's <b>IFilterGraph</b> interface, or NULL
/// if the filter is leaving the graph.</param>
/// <param name="name">String that specifies a name for the filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int JoinFilterGraph( [In] IFilterGraph graph, [In, MarshalAs( UnmanagedType.LPWStr )] string name );
/// <summary>
/// Retrieves a string containing vendor information.
/// </summary>
///
/// <param name="vendorInfo">Receives a string containing the vendor information.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryVendorInfo( [Out, MarshalAs( UnmanagedType.LPWStr )] out string vendorInfo );
}
}

View File

@@ -0,0 +1,185 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This interface builds capture graphs and other custom filter graphs.
/// </summary>
///
[ComImport,
Guid( "93E5A4E0-2D50-11d2-ABFA-00A0C9C6E38D" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface ICaptureGraphBuilder2
{
/// <summary>
/// Specify filter graph for the capture graph builder to use.
/// </summary>
///
/// <param name="graphBuilder">Filter graph's interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetFiltergraph( [In] IGraphBuilder graphBuilder );
/// <summary>
/// Retrieve the filter graph that the builder is using.
/// </summary>
///
/// <param name="graphBuilder">Filter graph's interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetFiltergraph( [Out] out IGraphBuilder graphBuilder );
/// <summary>
/// Create file writing section of the filter graph.
/// </summary>
///
/// <param name="type">GUID that represents either the media subtype of the output or the
/// class identifier (CLSID) of a multiplexer filter or file writer filter.</param>
/// <param name="fileName">Output file name.</param>
/// <param name="baseFilter">Receives the multiplexer's <see cref="IBaseFilter"/> interface.</param>
/// <param name="fileSinkFilter">Receives the file writer's IFileSinkFilter interface. Can be NULL.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetOutputFileName(
[In, MarshalAs( UnmanagedType.LPStruct )] Guid type,
[In, MarshalAs( UnmanagedType.LPWStr )] string fileName,
[Out] out IBaseFilter baseFilter,
[Out] out IntPtr fileSinkFilter
);
/// <summary>
/// Searche the graph for a specified interface, starting from a specified filter.
/// </summary>
///
/// <param name="category">GUID that specifies the search criteria.</param>
/// <param name="type">GUID that specifies the major media type of an output pin, or NULL.</param>
/// <param name="baseFilter"><see cref="IBaseFilter"/> interface of the filter. The method begins searching from this filter.</param>
/// <param name="interfaceID">Interface identifier (IID) of the interface to locate.</param>
/// <param name="retInterface">Receives found interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindInterface(
[In, MarshalAs( UnmanagedType.LPStruct )] Guid category,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid type,
[In] IBaseFilter baseFilter,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid interfaceID ,
[Out, MarshalAs( UnmanagedType.IUnknown )] out object retInterface
);
/// <summary>
/// Connect an output pin on a source filter to a rendering filter, optionally through a compression filter.
/// </summary>
///
/// <param name="category">Pin category.</param>
/// <param name="mediaType">Major-type GUID that specifies the media type of the output pin.</param>
/// <param name="source">Starting filter for the connection.</param>
/// <param name="compressor">Interface of an intermediate filter, such as a compression filter. Can be NULL.</param>
/// <param name="renderer">Sink filter, such as a renderer or mux filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RenderStream(
[In, MarshalAs( UnmanagedType.LPStruct )] Guid category,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid mediaType,
[In, MarshalAs( UnmanagedType.IUnknown )] object source,
[In] IBaseFilter compressor,
[In] IBaseFilter renderer
);
/// <summary>
/// Set the start and stop times for one or more streams of captured data.
/// </summary>
///
/// <param name="category">Pin category.</param>
/// <param name="mediaType">Major-type GUID that specifies the media type.</param>
/// <param name="filter"><see cref="IBaseFilter"/> interface that specifies which filter to control.</param>
/// <param name="start">Start time.</param>
/// <param name="stop">Stop time.</param>
/// <param name="startCookie">Value that is sent as the second parameter of the
/// EC_STREAM_CONTROL_STARTED event notification.</param>
/// <param name="stopCookie">Value that is sent as the second parameter of the
/// EC_STREAM_CONTROL_STOPPED event notification.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ControlStream(
[In, MarshalAs( UnmanagedType.LPStruct )] Guid category,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid mediaType,
[In, MarshalAs( UnmanagedType.Interface )] IBaseFilter filter,
[In] long start,
[In] long stop,
[In] short startCookie,
[In] short stopCookie
);
/// <summary>
/// Preallocate a capture file to a specified size.
/// </summary>
///
/// <param name="fileName">File name to create or resize.</param>
/// <param name="size">Size of the file to allocate, in bytes.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AllocCapFile(
[In, MarshalAs( UnmanagedType.LPWStr )] string fileName,
[In] long size
);
/// <summary>
/// Copy the valid media data from a capture file.
/// </summary>
///
/// <param name="oldFileName">Old file name.</param>
/// <param name="newFileName">New file name.</param>
/// <param name="allowEscAbort">Boolean value that specifies whether pressing the ESC key cancels the copy operation.</param>
/// <param name="callback">IAMCopyCaptureFileProgress interface to display progress information, or NULL.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int CopyCaptureFile(
[In, MarshalAs( UnmanagedType.LPWStr )] string oldFileName,
[In, MarshalAs( UnmanagedType.LPWStr )] string newFileName,
[In, MarshalAs( UnmanagedType.Bool )] bool allowEscAbort,
[In] IntPtr callback
);
/// <summary>
///
/// </summary>
///
/// <param name="source">Interface on a filter, or to an interface on a pin.</param>
/// <param name="pinDirection">Pin direction (input or output).</param>
/// <param name="category">Pin category.</param>
/// <param name="mediaType">Media type.</param>
/// <param name="unconnected">Boolean value that specifies whether the pin must be unconnected.</param>
/// <param name="index">Zero-based index of the pin to retrieve, from the set of matching pins.</param>
/// <param name="pin">Interface of the matching pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindPin(
[In, MarshalAs( UnmanagedType.IUnknown )] object source,
[In] PinDirection pinDirection,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid category,
[In, MarshalAs( UnmanagedType.LPStruct )] Guid mediaType,
[In, MarshalAs( UnmanagedType.Bool )] bool unconnected,
[In] int index,
[Out, MarshalAs( UnmanagedType.Interface )] out IPin pin
);
}
}

View File

@@ -0,0 +1,30 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
/// <summary>
/// The <b>ICreateDevEnum</b> interface creates an enumerator for devices within a particular category,
/// such as video capture devices, audio capture devices, video compressors, and so forth.
/// </summary>
///
[ComImport,
Guid( "29840822-5B84-11D0-BD3B-00A0C911CE86" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface ICreateDevEnum
{
/// <summary>
/// Creates a class enumerator for a specified device category.
/// </summary>
///
/// <param name="type">Specifies the class identifier of the device category.</param>
/// <param name="enumMoniker">Address of a variable that receives an <b>IEnumMoniker</b> interface pointer</param>
/// <param name="flags">Bitwise combination of zero or more flags. If zero, the method enumerates every filter in the category.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int CreateClassEnumerator( [In] ref Guid type, [Out] out IEnumMoniker enumMoniker, [In] int flags );
}
}

View File

@@ -0,0 +1,64 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This interface is used by applications or other filters to determine
/// what filters exist in the filter graph.
/// </summary>
///
[ComImport,
Guid( "56A86893-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IEnumFilters
{
/// <summary>
/// Retrieves the specified number of filters in the enumeration sequence.
/// </summary>
///
/// <param name="cFilters">Number of filters to retrieve.</param>
/// <param name="filters">Array in which to place <see cref="IBaseFilter"/> interfaces.</param>
/// <param name="filtersFetched">Actual number of filters placed in the array.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Next( [In] int cFilters,
[Out, MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 0 )] IBaseFilter[] filters,
[Out] out int filtersFetched );
/// <summary>
/// Skips a specified number of filters in the enumeration sequence.
/// </summary>
///
/// <param name="cFilters">Number of filters to skip.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Skip( [In] int cFilters );
/// <summary>
/// Resets the enumeration sequence to the beginning.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Reset( );
/// <summary>
/// Makes a copy of the enumerator with the same enumeration state.
/// </summary>
///
/// <param name="enumFilters">Duplicate of the enumerator.</param>
///
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
///
[PreserveSig]
int Clone( [Out] out IEnumFilters enumFilters );
}
}

View File

@@ -0,0 +1,61 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Enumerates pins on a filter.
/// </summary>
///
[ComImport,
Guid( "56A86892-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IEnumPins
{
/// <summary>
/// Retrieves a specified number of pins.
/// </summary>
///
/// <param name="cPins">Number of pins to retrieve.</param>
/// <param name="pins">Array of size <b>cPins</b> that is filled with <b>IPin</b> pointers.</param>
/// <param name="pinsFetched">Receives the number of pins retrieved.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Next( [In] int cPins,
[Out, MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 0 )] IPin[] pins,
[Out] out int pinsFetched );
/// <summary>
/// Skips a specified number of pins in the enumeration sequence.
/// </summary>
///
/// <param name="cPins">Number of pins to skip.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Skip( [In] int cPins );
/// <summary>
/// Resets the enumeration sequence to the beginning.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Reset( );
/// <summary>
/// Makes a copy of the enumerator with the same enumeration state.
/// </summary>
///
/// <param name="enumPins">Duplicate of the enumerator.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Clone( [Out] out IEnumPins enumPins );
}
}

View File

@@ -0,0 +1,41 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface is exposed by source filters to set the file name and media type of the media file that they are to render.
/// </summary>
///
[ComImport,
Guid( "56A868A6-0Ad4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IFileSourceFilter
{
/// <summary>
/// Loads the source filter with the file.
/// </summary>
///
/// <param name="fileName">The name of the file to open.</param>
/// <param name="mediaType">Media type of the file. This can be null.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Load( [In, MarshalAs( UnmanagedType.LPWStr )] string fileName,
[In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Retrieves the current file.
/// </summary>
///
/// <param name="fileName">Name of media file.</param>
/// <param name="mediaType">Receives media type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetCurFile([Out, MarshalAs( UnmanagedType.LPWStr )] out string fileName,
[Out, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
}
}

View File

@@ -0,0 +1,106 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface provides methods for building a filter graph. An application can use it to add filters to
/// the graph, connect or disconnect filters, remove filters, and perform other basic operations.
/// </summary>
///
[ComImport,
Guid( "56A8689F-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IFilterGraph
{
/// <summary>
/// Adds a filter to the graph and gives it a name.
/// </summary>
///
/// <param name="filter">Filter to add to the graph.</param>
/// <param name="name">Name of the filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddFilter( [In] IBaseFilter filter, [In, MarshalAs( UnmanagedType.LPWStr )] string name );
/// <summary>
/// Removes a filter from the graph.
/// </summary>
///
/// <param name="filter">Filter to be removed from the graph.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RemoveFilter( [In] IBaseFilter filter );
/// <summary>
/// Provides an enumerator for all filters in the graph.
/// </summary>
///
/// <param name="enumerator">Filter enumerator.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EnumFilters( [Out] out IntPtr enumerator );
/// <summary>
/// Finds a filter that was added with a specified name.
/// </summary>
///
/// <param name="name">Name of filter to search for.</param>
/// <param name="filter">Interface of found filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindFilterByName( [In, MarshalAs( UnmanagedType.LPWStr )] string name, [Out] out IBaseFilter filter );
/// <summary>
/// Connects two pins directly (without intervening filters).
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
/// <param name="pinIn">Input pin.</param>
/// <param name="mediaType">Media type to use for the connection.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ConnectDirect( [In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect and reconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Reconnect( [In] IPin pin );
/// <summary>
/// Disconnects a specified pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Disconnect( [In] IPin pin );
/// <summary>
/// Sets the reference clock to the default clock.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetDefaultSyncSource( );
}
}

View File

@@ -0,0 +1,250 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
/// <summary>
/// This interface extends the <see cref="IFilterGraph"/> and <see cref="IGraphBuilder"/>
/// interfaces, which contain methods for building filter graphs.
/// </summary>
///
[ComImport,
Guid("36B73882-C2C8-11CF-8B46-00805F6CEF60"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFilterGraph2
{
// --- IFilterGraph Methods
/// <summary>
/// Adds a filter to the graph and gives it a name.
/// </summary>
///
/// <param name="filter">Filter to add to the graph.</param>
/// <param name="name">Name of the filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddFilter( [In] IBaseFilter filter, [In, MarshalAs( UnmanagedType.LPWStr )] string name );
/// <summary>
/// Removes a filter from the graph.
/// </summary>
///
/// <param name="filter">Filter to be removed from the graph.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RemoveFilter( [In] IBaseFilter filter );
/// <summary>
/// Provides an enumerator for all filters in the graph.
/// </summary>
///
/// <param name="enumerator">Filter enumerator.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EnumFilters( [Out] out IEnumFilters enumerator );
/// <summary>
/// Finds a filter that was added with a specified name.
/// </summary>
///
/// <param name="name">Name of filter to search for.</param>
/// <param name="filter">Interface of found filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindFilterByName( [In, MarshalAs( UnmanagedType.LPWStr )] string name, [Out] out IBaseFilter filter );
/// <summary>
/// Connects two pins directly (without intervening filters).
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
/// <param name="pinIn">Input pin.</param>
/// <param name="mediaType">Media type to use for the connection.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ConnectDirect( [In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect and reconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Reconnect( [In] IPin pin );
/// <summary>
/// Disconnects a specified pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Disconnect( [In] IPin pin );
/// <summary>
/// Sets the reference clock to the default clock.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetDefaultSyncSource( );
// --- IGraphBuilder methods
/// <summary>
/// Connects two pins. If they will not connect directly, this method connects them with intervening transforms.
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
/// <param name="pinIn">Input pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Connect( [In] IPin pinOut, [In] IPin pinIn );
/// <summary>
/// Adds a chain of filters to a specified output pin to render it.
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Render( [In] IPin pinOut );
/// <summary>
/// Builds a filter graph that renders the specified file.
/// </summary>
///
/// <param name="file">Specifies a string that contains file name or device moniker.</param>
/// <param name="playList">Reserved.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RenderFile(
[In, MarshalAs( UnmanagedType.LPWStr )] string file,
[In, MarshalAs( UnmanagedType.LPWStr )] string playList );
/// <summary>
/// Adds a source filter to the filter graph for a specific file.
/// </summary>
///
/// <param name="fileName">Specifies the name of the file to load.</param>
/// <param name="filterName">Specifies a name for the source filter.</param>
/// <param name="filter">Variable that receives the interface of the source filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddSourceFilter(
[In, MarshalAs( UnmanagedType.LPWStr )] string fileName,
[In, MarshalAs( UnmanagedType.LPWStr )] string filterName,
[Out] out IBaseFilter filter );
/// <summary>
/// Sets the file for logging actions taken when attempting to perform an operation.
/// </summary>
///
/// <param name="hFile">Handle to the log file.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetLogFile( IntPtr hFile );
/// <summary>
/// Requests that the graph builder return as soon as possible from its current task.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Abort( );
/// <summary>
/// Queries whether the current operation should continue.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ShouldOperationContinue( );
// --- IFilterGraph2 methods
/// <summary>
///
/// </summary>
///
/// <param name="moniker">Moniker interface.</param>
/// <param name="bindContext">Bind context interface.</param>
/// <param name="filterName">Name for the filter.</param>
/// <param name="filter"> Receives source filter's IBaseFilter interface.
/// The caller must release the interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddSourceFilterForMoniker(
[In] IMoniker moniker,
[In] IBindCtx bindContext,
[In, MarshalAs( UnmanagedType.LPWStr )] string filterName,
[Out] out IBaseFilter filter
);
/// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin,
/// using a specified media type.
/// </summary>
///
/// <param name="pin">Pin to disconnect and reconnect.</param>
/// <param name="mediaType">Media type to reconnect with.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ReconnectEx(
[In] IPin pin,
[In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType
);
/// <summary>
/// Render an output pin, with an option to use existing renderers only.
/// </summary>
///
/// <param name="outputPin">Interface of the output pin.</param>
/// <param name="flags">Flag that specifies how to render the pin.</param>
/// <param name="context">Reserved.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RenderEx(
[In] IPin outputPin,
[In] int flags,
[In] IntPtr context
);
}
}

View File

@@ -0,0 +1,191 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This interface provides methods that enable an application to build a filter graph.
/// </summary>
///
[ComImport,
Guid( "56A868A9-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IGraphBuilder
{
// --- IFilterGraph Methods
/// <summary>
/// Adds a filter to the graph and gives it a name.
/// </summary>
///
/// <param name="filter">Filter to add to the graph.</param>
/// <param name="name">Name of the filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddFilter( [In] IBaseFilter filter, [In, MarshalAs( UnmanagedType.LPWStr )] string name );
/// <summary>
/// Removes a filter from the graph.
/// </summary>
///
/// <param name="filter">Filter to be removed from the graph.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RemoveFilter( [In] IBaseFilter filter );
/// <summary>
/// Provides an enumerator for all filters in the graph.
/// </summary>
///
/// <param name="enumerator">Filter enumerator.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EnumFilters( [Out] out IEnumFilters enumerator );
/// <summary>
/// Finds a filter that was added with a specified name.
/// </summary>
///
/// <param name="name">Name of filter to search for.</param>
/// <param name="filter">Interface of found filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FindFilterByName( [In, MarshalAs( UnmanagedType.LPWStr )] string name, [Out] out IBaseFilter filter );
/// <summary>
/// Connects two pins directly (without intervening filters).
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
/// <param name="pinIn">Input pin.</param>
/// <param name="mediaType">Media type to use for the connection.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ConnectDirect( [In] IPin pinOut, [In] IPin pinIn, [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Breaks the existing pin connection and reconnects it to the same pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect and reconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Reconnect( [In] IPin pin );
/// <summary>
/// Disconnects a specified pin.
/// </summary>
///
/// <param name="pin">Pin to disconnect.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Disconnect( [In] IPin pin );
/// <summary>
/// Sets the reference clock to the default clock.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetDefaultSyncSource( );
// --- IGraphBuilder methods
/// <summary>
/// Connects two pins. If they will not connect directly, this method connects them with intervening transforms.
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
/// <param name="pinIn">Input pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Connect( [In] IPin pinOut, [In] IPin pinIn );
/// <summary>
/// Adds a chain of filters to a specified output pin to render it.
/// </summary>
///
/// <param name="pinOut">Output pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Render( [In] IPin pinOut );
/// <summary>
/// Builds a filter graph that renders the specified file.
/// </summary>
///
/// <param name="file">Specifies a string that contains file name or device moniker.</param>
/// <param name="playList">Reserved.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RenderFile(
[In, MarshalAs( UnmanagedType.LPWStr )] string file,
[In, MarshalAs( UnmanagedType.LPWStr )] string playList);
/// <summary>
/// Adds a source filter to the filter graph for a specific file.
/// </summary>
///
/// <param name="fileName">Specifies the name of the file to load.</param>
/// <param name="filterName">Specifies a name for the source filter.</param>
/// <param name="filter">Variable that receives the interface of the source filter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddSourceFilter(
[In, MarshalAs( UnmanagedType.LPWStr )] string fileName,
[In, MarshalAs( UnmanagedType.LPWStr )] string filterName,
[Out] out IBaseFilter filter );
/// <summary>
/// Sets the file for logging actions taken when attempting to perform an operation.
/// </summary>
///
/// <param name="hFile">Handle to the log file.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetLogFile( IntPtr hFile );
/// <summary>
/// Requests that the graph builder return as soon as possible from its current task.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Abort( );
/// <summary>
/// Queries whether the current operation should continue.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ShouldOperationContinue( );
}
}

View File

@@ -0,0 +1,111 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface provides methods for controlling the flow of data through the filter graph.
/// It includes methods for running, pausing, and stopping the graph.
/// </summary>
///
[ComImport,
Guid( "56A868B1-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IMediaControl
{
/// <summary>
/// Runs all the filters in the filter graph.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Run( );
/// <summary>
/// Pauses all filters in the filter graph.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Pause( );
/// <summary>
/// Stops all the filters in the filter graph.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Stop( );
/// <summary>
/// Retrieves the state of the filter graph.
/// </summary>
///
/// <param name="timeout">Duration of the time-out, in milliseconds, or INFINITE to specify an infinite time-out.</param>
/// <param name="filterState">Ìariable that receives a member of the <b>FILTER_STATE</b> enumeration.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetState( int timeout, out int filterState );
/// <summary>
/// Builds a filter graph that renders the specified file.
/// </summary>
///
/// <param name="fileName">Name of the file to render</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RenderFile( string fileName );
/// <summary>
/// Adds a source filter to the filter graph, for a specified file.
/// </summary>
///
/// <param name="fileName">Name of the file containing the source video.</param>
/// <param name="filterInfo">Receives interface of filter information object.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AddSourceFilter( [In] string fileName, [Out, MarshalAs( UnmanagedType.IDispatch )] out object filterInfo );
/// <summary>
/// Retrieves a collection of the filters in the filter graph.
/// </summary>
///
/// <param name="collection">Receives the <b>IAMCollection</b> interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_FilterCollection(
[Out, MarshalAs( UnmanagedType.IDispatch )] out object collection );
/// <summary>
/// Retrieves a collection of all the filters listed in the registry.
/// </summary>
///
/// <param name="collection">Receives the <b>IDispatch</b> interface of <b>IAMCollection</b> object.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_RegFilterCollection(
[Out, MarshalAs( UnmanagedType.IDispatch )] out object collection );
/// <summary>
/// Pauses the filter graph, allowing filters to queue data, and then stops the filter graph.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int StopWhenReady( );
}
}

View File

@@ -0,0 +1,119 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface inherits contains methods for retrieving event notifications and for overriding the
/// filter graph's default handling of events.
/// </summary>
[ComVisible( true ), ComImport,
Guid( "56a868c0-0ad4-11ce-b03a-0020af0ba770" ),
InterfaceType( ComInterfaceType.InterfaceIsDual )]
internal interface IMediaEventEx
{
/// <summary>
/// Retrieves a handle to a manual-reset event that remains signaled while the queue contains event notifications.
/// </summary>
/// <param name="hEvent">Pointer to a variable that receives the event handle.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetEventHandle( out IntPtr hEvent );
/// <summary>
/// Retrieves the next event notification from the event queue.
/// </summary>
///
/// <param name="lEventCode">Variable that receives the event code.</param>
/// <param name="lParam1">Pointer to a variable that receives the first event parameter.</param>
/// <param name="lParam2">Pointer to a variable that receives the second event parameter.</param>
/// <param name="msTimeout">Time-out interval, in milliseconds.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetEvent( [Out, MarshalAs( UnmanagedType.I4 )] out DsEvCode lEventCode, [Out] out IntPtr lParam1, [Out] out IntPtr lParam2, int msTimeout );
/// <summary>
/// Waits for the filter graph to render all available data.
/// </summary>
///
/// <param name="msTimeout">Time-out interval, in milliseconds. Pass zero to return immediately.</param>
/// <param name="pEvCode">Pointer to a variable that receives an event code.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int WaitForCompletion( int msTimeout, [Out] out int pEvCode );
/// <summary>
/// Cancels the Filter Graph Manager's default handling for a specified event.
/// </summary>
///
/// <param name="lEvCode">Event code for which to cancel default handling.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int CancelDefaultHandling( int lEvCode );
/// <summary>
/// Restores the Filter Graph Manager's default handling for a specified event.
/// </summary>
/// <param name="lEvCode">Event code for which to restore default handling.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int RestoreDefaultHandling( int lEvCode );
/// <summary>
/// Frees resources associated with the parameters of an event.
/// </summary>
/// <param name="lEvCode">Event code.</param>
/// <param name="lParam1">First event parameter.</param>
/// <param name="lParam2">Second event parameter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int FreeEventParams( [In, MarshalAs( UnmanagedType.I4 )] DsEvCode lEvCode, IntPtr lParam1, IntPtr lParam2 );
/// <summary>
/// Registers a window to process event notifications.
/// </summary>
///
/// <param name="hwnd">Handle to the window, or <see cref="IntPtr.Zero"/> to stop receiving event messages.</param>
/// <param name="lMsg">Window message to be passed as the notification.</param>
/// <param name="lInstanceData">Value to be passed as the <i>lParam</i> parameter for the <i>lMsg</i> message.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetNotifyWindow( IntPtr hwnd, int lMsg, IntPtr lInstanceData );
/// <summary>
/// Enables or disables event notifications.
/// </summary>
///
/// <param name="lNoNotifyFlags">Value indicating whether to enable or disable event notifications.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetNotifyFlags( int lNoNotifyFlags );
/// <summary>
/// Determines whether event notifications are enabled.
/// </summary>
///
/// <param name="lplNoNotifyFlags">Variable that receives current notification status.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetNotifyFlags( out int lplNoNotifyFlags );
}
}

View File

@@ -0,0 +1,91 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface provides methods for controlling the flow of data through the filter graph.
/// It includes methods for running, pausing, and stopping the graph.
/// </summary>
///
[ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid( "56a86899-0ad4-11ce-b03a-0020af0ba770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IMediaFilter : IPersist
{
#region IPersist Methods
[PreserveSig]
new int GetClassID(
[Out] out Guid pClassID );
#endregion
/// <summary>
/// This method informs the filter to transition to the new state.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Stop( );
/// <summary>
/// This method informs the filter to transition to the new state.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Pause( );
/// <summary>
/// This method informs the filter to transition to the new (running) state. Passes a time value to synchronize independent streams.
/// </summary>
///
/// <param name="tStart">Time value of the reference clock. The amount to be added to the IMediaSample time stamp to determine the time at which that sample should be rendered according to the reference clock. That is, it is the reference time at which a sample with a stream time of zero should be rendered.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Run( [In] long tStart );
/// <summary>
/// This method determines the filter's state.
/// </summary>
///
/// <param name="dwMilliSecsTimeout">Duration of the time-out, in milliseconds. To block indefinitely, pass INFINITE. </param>
/// <param name="filtState">Returned state of the filter. States include stopped, paused, running, or intermediate (in the process of changing). </param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetState(
[In] int dwMilliSecsTimeout,
[Out] out FilterState filtState );
/// <summary>
/// This method identifies the reference clock to which the filter should synchronize activity.
/// </summary>
///
/// <param name="pClock">Pointer to the IReferenceClock interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetSyncSource( [In] IReferenceClock pClock );
/// <summary>
/// This method retrieves the current reference clock in use by this filter.
/// </summary>
///
/// <param name="pClock">Pointer to a reference clock; it will be set to the IReferenceClock interface. </param>
///
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetSyncSource( [Out] out IReferenceClock pClock );
}
}

View File

@@ -0,0 +1,23 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Provides the CLSID of an object that can be stored persistently in the system. Allows the object to specify which object
/// handler to use in the client process, as it is used in the default implementation of marshaling.
/// </summary>
[ComImport,
Guid("0000010c-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IPersist
{
/// <summary>
/// Retrieves the class identifier (CLSID) of the object.
/// </summary>
/// <param name="pClassID"></param>
/// <returns></returns>
[PreserveSig]
int GetClassID([Out] out Guid pClassID);
}
}

View File

@@ -0,0 +1,184 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This interface is exposed by all input and output pins of DirectShow filters.
/// </summary>
///
[ComImport,
Guid( "56A86891-0AD4-11CE-B03A-0020AF0BA770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IPin
{
/// <summary>
/// Connects the pin to another pin.
/// </summary>
///
/// <param name="receivePin">Other pin to connect to.</param>
/// <param name="mediaType">Type to use for the connections (optional).</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Connect( [In] IPin receivePin, [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Makes a connection to this pin and is called by a connecting pin.
/// </summary>
///
/// <param name="receivePin">Connecting pin.</param>
/// <param name="mediaType">Media type of the samples to be streamed.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ReceiveConnection( [In] IPin receivePin, [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Breaks the current pin connection.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Disconnect( );
/// <summary>
/// Returns a pointer to the connecting pin.
/// </summary>
///
/// <param name="pin">Receives <b>IPin</b> interface of connected pin (if any).</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ConnectedTo( [Out] out IPin pin );
/// <summary>
/// Returns the media type of this pin's connection.
/// </summary>
///
/// <param name="mediaType">Pointer to an <see cref="AMMediaType"/> structure. If the pin is connected,
/// the media type is returned. Otherwise, the structure is initialized to a default state in which
/// all elements are 0, with the exception of <b>lSampleSize</b>, which is set to 1, and
/// <b>FixedSizeSamples</b>, which is set to <b>true</b>.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int ConnectionMediaType( [Out, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Retrieves information about this pin (for example, the name, owning filter, and direction).
/// </summary>
///
/// <param name="pinInfo"><see cref="PinInfo"/> structure that receives the pin information.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryPinInfo( [Out] out PinInfo pinInfo );
/// <summary>
/// Retrieves the direction for this pin.
/// </summary>
///
/// <param name="pinDirection">Receives direction of the pin.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryDirection( out PinDirection pinDirection );
/// <summary>
/// Retrieves an identifier for the pin.
/// </summary>
///
/// <param name="id">Pin identifier.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryId( [Out, MarshalAs( UnmanagedType.LPWStr )] out string id );
/// <summary>
/// Queries whether a given media type is acceptable by the pin.
/// </summary>
///
/// <param name="mediaType"><see cref="AMMediaType"/> structure that specifies the media type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryAccept( [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Provides an enumerator for this pin's preferred media types.
/// </summary>
///
/// <param name="enumerator">Address of a variable that receives a pointer to the <b>IEnumMediaTypes</b> interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EnumMediaTypes( IntPtr enumerator );
/// <summary>
/// Provides an array of the pins to which this pin internally connects.
/// </summary>
///
/// <param name="apPin">Address of an array of <b>IPin</b> pointers.</param>
/// <param name="nPin">On input, specifies the size of the array. When the method returns,
/// the value is set to the number of pointers returned in the array.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int QueryInternalConnections( IntPtr apPin, [In, Out] ref int nPin );
/// <summary>
/// Notifies the pin that no additional data is expected.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EndOfStream( );
/// <summary>
/// Begins a flush operation.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int BeginFlush( );
/// <summary>
/// Ends a flush operation.
/// </summary>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int EndFlush( );
/// <summary>
/// Specifies that samples following this call are grouped as a segment with a given start time, stop time, and rate.
/// </summary>
///
/// <param name="start">Start time of the segment, relative to the original source, in 100-nanosecond units.</param>
/// <param name="stop">End time of the segment, relative to the original source, in 100-nanosecond units.</param>
/// <param name="rate">Rate at which this segment should be processed, as a percentage of the original rate.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int NewSegment(
long start,
long stop,
double rate );
}
}

View File

@@ -0,0 +1,46 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The <b>IPropertyBag</b> interface provides an object with a property bag in
/// which the object can persistently save its properties.
/// </summary>
///
[ComImport,
Guid( "55272A00-42CB-11CE-8135-00AA004BB851" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IPropertyBag
{
/// <summary>
/// Read a property from property bag.
/// </summary>
///
/// <param name="propertyName">Property name to read.</param>
/// <param name="pVar">Property value.</param>
/// <param name="pErrorLog">Caller's error log.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Read(
[In, MarshalAs( UnmanagedType.LPWStr )] string propertyName,
[In, Out, MarshalAs( UnmanagedType.Struct )] ref object pVar,
[In] IntPtr pErrorLog );
/// <summary>
/// Write property to property bag.
/// </summary>
///
/// <param name="propertyName">Property name to read.</param>
/// <param name="pVar">Property value.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Write(
[In, MarshalAs( UnmanagedType.LPWStr )] string propertyName,
[In, MarshalAs( UnmanagedType.Struct )] ref object pVar );
}
}

View File

@@ -0,0 +1,76 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The IReferenceClock interface provides the reference time for the filter graph.
///
/// Filters that can act as a reference clock can expose this interface. It is also exposed by the System Reference Clock.
/// The filter graph manager uses this interface to synchronize the filter graph. Applications can use this interface to
/// retrieve the current reference time, or to request notification of an elapsed time.
/// </summary>
[ComImport, System.Security.SuppressUnmanagedCodeSecurity,
Guid( "56a86897-0ad4-11ce-b03a-0020af0ba770" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface IReferenceClock
{
/// <summary>
/// The GetTime method retrieves the current reference time.
/// </summary>
///
/// <param name="pTime">Pointer to a variable that receives the current time, in 100-nanosecond units.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetTime( [Out] out long pTime );
/// <summary>
/// The AdviseTime method creates a one-shot advise request.
/// </summary>
///
/// <param name="baseTime">Base reference time, in 100-nanosecond units. See Remarks.</param>
/// <param name="streamTime">Stream offset time, in 100-nanosecond units. See Remarks.</param>
/// <param name="hEvent">Handle to an event, created by the caller.</param>
/// <param name="pdwAdviseCookie">Pointer to a variable that receives an identifier for the advise request.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AdviseTime(
[In] long baseTime,
[In] long streamTime,
[In] IntPtr hEvent,
[Out] out int pdwAdviseCookie );
/// <summary>
/// The AdvisePeriodic method creates a periodic advise request.
/// </summary>
///
/// <param name="startTime">Time of the first notification, in 100-nanosecond units. Must be greater than zero and less than MAX_TIME.</param>
/// <param name="periodTime">Time between notifications, in 100-nanosecond units. Must be greater than zero.</param>
/// <param name="hSemaphore">Handle to a semaphore, created by the caller.</param>
/// <param name="pdwAdviseCookie">Pointer to a variable that receives an identifier for the advise request.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int AdvisePeriodic(
[In] long startTime,
[In] long periodTime,
[In] IntPtr hSemaphore,
[Out] out int pdwAdviseCookie );
/// <summary>
/// The Unadvise method removes a pending advise request.
/// </summary>
///
/// <param name="dwAdviseCookie">Identifier of the request to remove. Use the value returned by IReferenceClock::AdviseTime or IReferenceClock::AdvisePeriodic in the pdwAdviseToken parameter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int Unadvise( [In] int dwAdviseCookie );
}
}

View File

@@ -0,0 +1,96 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface is exposed by the Sample Grabber Filter. It enables an application to retrieve
/// individual media samples as they move through the filter graph.
/// </summary>
///
[ComImport,
Guid("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ISampleGrabber
{
/// <summary>
/// Specifies whether the filter should stop the graph after receiving one sample.
/// </summary>
///
/// <param name="oneShot">Boolean value specifying whether the filter should stop the graph after receiving one sample.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetOneShot( [In, MarshalAs( UnmanagedType.Bool )] bool oneShot );
/// <summary>
/// Specifies the media type for the connection on the Sample Grabber's input pin.
/// </summary>
///
/// <param name="mediaType">Specifies the required media type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetMediaType( [In, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Retrieves the media type for the connection on the Sample Grabber's input pin.
/// </summary>
///
/// <param name="mediaType"><see cref="AMMediaType"/> structure, which receives media type.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetConnectedMediaType( [Out, MarshalAs( UnmanagedType.LPStruct )] AMMediaType mediaType );
/// <summary>
/// Specifies whether to copy sample data into a buffer as it goes through the filter.
/// </summary>
///
/// <param name="bufferThem">Boolean value specifying whether to buffer sample data.
/// If <b>true</b>, the filter copies sample data into an internal buffer.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetBufferSamples( [In, MarshalAs( UnmanagedType.Bool )] bool bufferThem );
/// <summary>
/// Retrieves a copy of the sample that the filter received most recently.
/// </summary>
///
/// <param name="bufferSize">Pointer to the size of the buffer. If pBuffer is NULL, this parameter receives the required size.</param>
/// <param name="buffer">Pointer to a buffer to receive a copy of the sample, or NULL.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetCurrentBuffer( ref int bufferSize, IntPtr buffer );
/// <summary>
/// Not currently implemented.
/// </summary>
///
/// <param name="sample"></param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetCurrentSample( IntPtr sample );
/// <summary>
/// Specifies a callback method to call on incoming samples.
/// </summary>
///
/// <param name="callback"><see cref="ISampleGrabberCB"/> interface containing the callback method, or NULL to cancel the callback.</param>
/// <param name="whichMethodToCallback">Index specifying the callback method.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetCallback( ISampleGrabberCB callback, int whichMethodToCallback );
}
}

View File

@@ -0,0 +1,40 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface provides callback methods for the <see cref="ISampleGrabber.SetCallback"/> method.
/// </summary>
///
[ComImport,
Guid("0579154A-2B53-4994-B0D0-E773148EFF85"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ISampleGrabberCB
{
/// <summary>
/// Callback method that receives a pointer to the media sample.
/// </summary>
///
/// <param name="sampleTime">Starting time of the sample, in seconds.</param>
/// <param name="sample">Pointer to the sample's <b>IMediaSample</b> interface.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SampleCB( double sampleTime, IntPtr sample );
/// <summary>
/// Callback method that receives a pointer to the sample bufferþ
/// </summary>
///
/// <param name="sampleTime">Starting time of the sample, in seconds.</param>
/// <param name="buffer">Pointer to a buffer that contains the sample data.</param>
/// <param name="bufferLen">Length of the buffer pointed to by <b>buffer</b>, in bytes</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int BufferCB( double sampleTime, IntPtr buffer, int bufferLen );
}
}

View File

@@ -0,0 +1,29 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface indicates that an object supports property pages.
/// </summary>
///
[ComImport,
Guid( "B196B28B-BAB4-101A-B69C-00AA00341D07" ),
InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
internal interface ISpecifyPropertyPages
{
/// <summary>
/// Fills a counted array of GUID values where each GUID specifies the
/// CLSID of each property page that can be displayed in the property
/// sheet for this object.
/// </summary>
///
/// <param name="pPages">Pointer to a CAUUID structure that must be initialized
/// and filled before returning.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetPages( out CAUUID pPages );
}
}

View File

@@ -0,0 +1,459 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// The interface sets properties on the video window.
/// </summary>
///
[ComImport,
Guid("56A868B4-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IVideoWindow
{
/// <summary>
/// Sets the video window caption.
/// </summary>
///
/// <param name="caption">Caption.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Caption( string caption );
/// <summary>
/// Retrieves the video window caption.
/// </summary>
///
/// <param name="caption">Caption.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Caption( [Out] out string caption );
/// <summary>
/// Sets the window style on the video window.
/// </summary>
///
/// <param name="windowStyle">Window style flags.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_WindowStyle( int windowStyle );
/// <summary>
/// Retrieves the window style on the video window.
/// </summary>
///
/// <param name="windowStyle">Window style flags.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_WindowStyle( out int windowStyle );
/// <summary>
/// Sets the extended window style on the video window.
/// </summary>
///
/// <param name="windowStyleEx">Window extended style flags.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_WindowStyleEx( int windowStyleEx );
/// <summary>
/// Retrieves the extended window style on the video window.
/// </summary>
///
/// <param name="windowStyleEx">Window extended style flags.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_WindowStyleEx( out int windowStyleEx );
/// <summary>
/// Specifies whether the video renderer automatically shows the video window when it receives video data.
/// </summary>
///
/// <param name="autoShow">Specifies whether the video renderer automatically shows the video window.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_AutoShow( [In, MarshalAs( UnmanagedType.Bool )] bool autoShow );
/// <summary>
/// Queries whether the video renderer automatically shows the video window when it receives video data.
/// </summary>
///
/// <param name="autoShow">REceives window auto show flag.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_AutoShow( [Out, MarshalAs( UnmanagedType.Bool )] out bool autoShow );
/// <summary>
/// Shows, hides, minimizes, or maximizes the video window.
/// </summary>
///
/// <param name="windowState">Window state.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_WindowState( int windowState );
/// <summary>
/// Queries whether the video window is visible, hidden, minimized, or maximized.
/// </summary>
///
/// <param name="windowState">Window state.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_WindowState( out int windowState );
/// <summary>
/// Specifies whether the video window realizes its palette in the background.
/// </summary>
///
/// <param name="backgroundPalette">Value that specifies whether the video renderer realizes it palette in the background.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_BackgroundPalette( [In, MarshalAs( UnmanagedType.Bool )] bool backgroundPalette );
/// <summary>
/// Queries whether the video window realizes its palette in the background.
/// </summary>
///
/// <param name="backgroundPalette">Receives state of background palette flag.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_BackgroundPalette( [Out, MarshalAs( UnmanagedType.Bool )] out bool backgroundPalette );
/// <summary>
/// Shows or hides the video window.
/// </summary>
///
/// <param name="visible">Value that specifies whether to show or hide the window.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Visible( [In, MarshalAs( UnmanagedType.Bool )] bool visible );
/// <summary>
/// Queries whether the video window is visible.
/// </summary>
///
/// <param name="visible">Visibility flag.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Visible( [Out, MarshalAs( UnmanagedType.Bool )] out bool visible );
/// <summary>
/// Sets the video window's x-coordinate.
/// </summary>
///
/// <param name="left">Specifies the x-coordinate, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Left( int left );
/// <summary>
/// Retrieves the video window's x-coordinate.
/// </summary>
///
/// <param name="left">x-coordinate, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Left( out int left );
/// <summary>
/// Sets the width of the video window.
/// </summary>
///
/// <param name="width">Specifies the width, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Width( int width );
/// <summary>
/// Retrieves the width of the video window.
/// </summary>
///
/// <param name="width">Width, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Width( out int width );
/// <summary>
/// Sets the video window's y-coordinate.
/// </summary>
///
/// <param name="top">Specifies the y-coordinate, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Top( int top );
/// <summary>
/// Retrieves the video window's y-coordinate.
/// </summary>
///
/// <param name="top">y-coordinate, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Top( out int top );
/// <summary>
/// Sets the height of the video window.
/// </summary>
///
/// <param name="height">Specifies the height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Height( int height );
/// <summary>
/// Retrieves the height of the video window.
/// </summary>
///
/// <param name="height">Height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Height( out int height );
/// <summary>
/// Specifies a parent window for the video windowþ
/// </summary>
///
/// <param name="owner">Specifies a handle to the parent window.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_Owner( IntPtr owner );
/// <summary>
/// Retrieves the video window's parent window, if anyþ
/// </summary>
///
/// <param name="owner">Parent window's handle.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_Owner( out IntPtr owner );
/// <summary>
/// Specifies a window to receive mouse and keyboard messages from the video window.
/// </summary>
///
/// <param name="drain">Specifies a handle to the window.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_MessageDrain( IntPtr drain );
/// <summary>
/// Retrieves the window that receives mouse and keyboard messages from the video window, if any.
/// </summary>
///
/// <param name="drain">Window's handle.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_MessageDrain( out IntPtr drain );
/// <summary>
/// Retrieves the color that appears around the edges of the destination rectangle.
/// </summary>
///
/// <param name="color">Border's color.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_BorderColor( out int color );
/// <summary>
/// Sets the color that appears around the edges of the destination rectangle.
/// </summary>
///
/// <param name="color">Specifies the border color.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_BorderColor( int color );
/// <summary>
/// Queries whether the video renderer is in full-screen mode.
/// </summary>
///
/// <param name="fullScreenMode">Full-screen mode.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int get_FullScreenMode(
[Out, MarshalAs( UnmanagedType.Bool )] out bool fullScreenMode );
/// <summary>
/// Enables or disables full-screen mode.
/// </summary>
///
/// <param name="fullScreenMode">Boolean value that specifies whether to enable or disable full-screen mode.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int put_FullScreenMode( [In, MarshalAs( UnmanagedType.Bool )] bool fullScreenMode );
/// <summary>
/// Places the video window at the top of the Z order.
/// </summary>
///
/// <param name="focus">Value that specifies whether to give the window focus.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetWindowForeground( int focus );
/// <summary>
/// Forwards a message to the video window.
/// </summary>
///
/// <param name="hwnd">Handle to the window.</param>
/// <param name="msg">Specifies the message.</param>
/// <param name="wParam">Message parameter.</param>
/// <param name="lParam">Message parameter.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int NotifyOwnerMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam );
/// <summary>
/// Sets the position of the video windowþ
/// </summary>
///
/// <param name="left">Specifies the x-coordinate, in pixels.</param>
/// <param name="top">Specifies the y-coordinate, in pixels.</param>
/// <param name="width">Specifies the width, in pixels.</param>
/// <param name="height">Specifies the height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int SetWindowPosition( int left, int top, int width, int height );
/// <summary>
/// Retrieves the position of the video window.
/// </summary>
///
/// <param name="left">x-coordinate, in pixels.</param>
/// <param name="top">y-coordinate, in pixels.</param>
/// <param name="width">Width, in pixels.</param>
/// <param name="height">Height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetWindowPosition( out int left, out int top, out int width, out int height );
/// <summary>
/// Retrieves the minimum ideal size for the video image.
/// </summary>
///
/// <param name="width">Receives the minimum ideal width, in pixels.</param>
/// <param name="height">Receives the minimum ideal height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetMinIdealImageSize( out int width, out int height );
/// <summary>
/// Retrieves the maximum ideal size for the video image.
/// </summary>
///
/// <param name="width">Receives the maximum ideal width, in pixels.</param>
/// <param name="height">Receives the maximum ideal height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetMaxIdealImageSize( out int width, out int height );
/// <summary>
/// Retrieves the restored window position.
/// </summary>
///
/// <param name="left">x-coordinate, in pixels.</param>
/// <param name="top">y-coordinate, in pixels.</param>
/// <param name="width">Width, in pixels.</param>
/// <param name="height">Height, in pixels.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int GetRestorePosition( out int left, out int top, out int width, out int height );
/// <summary>
/// Hides the cursor.
/// </summary>
///
/// <param name="hideCursor">Specifies whether to hide or display the cursor.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int HideCursor( [In, MarshalAs( UnmanagedType.Bool )] bool hideCursor );
/// <summary>
/// Queries whether the cursor is hidden.
/// </summary>
///
/// <param name="hideCursor">Specifies if cursor is hidden or not.</param>
///
/// <returns>Return's <b>HRESULT</b> error code.</returns>
///
[PreserveSig]
int IsCursorHidden( [Out, MarshalAs( UnmanagedType.Bool )] out bool hideCursor );
}
}

View File

@@ -0,0 +1,115 @@
namespace VAR.Toolbox.Code.DirectShow
{
/// <summary>
/// Specifies the physical type of pin (audio or video).
/// </summary>
public enum PhysicalConnectorType
{
/// <summary>
/// Default value of connection type. Physically it does not exist, but just either to specify that
/// connection type should not be changed (input) or was not determined (output).
/// </summary>
Default = 0,
/// <summary>
/// Specifies a tuner pin for video.
/// </summary>
VideoTuner = 1,
/// <summary>
/// Specifies a composite pin for video.
/// </summary>
VideoComposite,
/// <summary>
/// Specifies an S-Video (Y/C video) pin.
/// </summary>
VideoSVideo,
/// <summary>
/// Specifies an RGB pin for video.
/// </summary>
VideoRGB,
/// <summary>
/// Specifies a YRYBY (Y, RY, BY) pin for video.
/// </summary>
VideoYRYBY,
/// <summary>
/// Specifies a serial digital pin for video.
/// </summary>
VideoSerialDigital,
/// <summary>
/// Specifies a parallel digital pin for video.
/// </summary>
VideoParallelDigital,
/// <summary>
/// Specifies a SCSI (Small Computer System Interface) pin for video.
/// </summary>
VideoSCSI,
/// <summary>
/// Specifies an AUX (auxiliary) pin for video.
/// </summary>
VideoAUX,
/// <summary>
/// Specifies an IEEE 1394 pin for video.
/// </summary>
Video1394,
/// <summary>
/// Specifies a USB (Universal Serial Bus) pin for video.
/// </summary>
VideoUSB,
/// <summary>
/// Specifies a video decoder pin.
/// </summary>
VideoDecoder,
/// <summary>
/// Specifies a video encoder pin.
/// </summary>
VideoEncoder,
/// <summary>
/// Specifies a SCART (Peritel) pin for video.
/// </summary>
VideoSCART,
/// <summary>
/// Not used.
/// </summary>
VideoBlack,
/// <summary>
/// Specifies a tuner pin for audio.
/// </summary>
AudioTuner = 4096,
/// <summary>
/// Specifies a line pin for audio.
/// </summary>
AudioLine,
/// <summary>
/// Specifies a microphone pin.
/// </summary>
AudioMic,
/// <summary>
/// Specifies an AES/EBU (Audio Engineering Society/European Broadcast Union) digital pin for audio.
/// </summary>
AudioAESDigital,
/// <summary>
/// Specifies an S/PDIF (Sony/Philips Digital Interface Format) digital pin for audio.
/// </summary>
AudioSPDIFDigital,
/// <summary>
/// Specifies a SCSI pin for audio.
/// </summary>
AudioSCSI,
/// <summary>
/// Specifies an AUX pin for audio.
/// </summary>
AudioAUX,
/// <summary>
/// Specifies an IEEE 1394 pin for audio.
/// </summary>
Audio1394,
/// <summary>
/// Specifies a USB pin for audio.
/// </summary>
AudioUSB,
/// <summary>
/// Specifies an audio decoder pin.
/// </summary>
AudioDecoder
}
}

View File

@@ -0,0 +1,510 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
using System.Drawing;
// PIN_DIRECTION
/// <summary>
/// This enumeration indicates a pin's direction.
/// </summary>
///
[ComVisible( false )]
internal enum PinDirection
{
/// <summary>
/// Input pin.
/// </summary>
Input,
/// <summary>
/// Output pin.
/// </summary>
Output
}
// AM_MEDIA_TYPE
/// <summary>
/// The structure describes the format of a media sample.
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential )]
internal class AMMediaType : IDisposable
{
/// <summary>
/// Globally unique identifier (GUID) that specifies the major type of the media sample.
/// </summary>
public Guid MajorType;
/// <summary>
/// GUID that specifies the subtype of the media sample.
/// </summary>
public Guid SubType;
/// <summary>
/// If <b>true</b>, samples are of a fixed size.
/// </summary>
[MarshalAs( UnmanagedType.Bool )]
public bool FixedSizeSamples = true;
/// <summary>
/// If <b>true</b>, samples are compressed using temporal (interframe) compression.
/// </summary>
[MarshalAs( UnmanagedType.Bool )]
public bool TemporalCompression;
/// <summary>
/// Size of the sample in bytes. For compressed data, the value can be zero.
/// </summary>
public int SampleSize = 1;
/// <summary>
/// GUID that specifies the structure used for the format block.
/// </summary>
public Guid FormatType;
/// <summary>
/// Not used.
/// </summary>
public IntPtr unkPtr;
/// <summary>
/// Size of the format block, in bytes.
/// </summary>
public int FormatSize;
/// <summary>
/// Pointer to the format block.
/// </summary>
public IntPtr FormatPtr;
/// <summary>
/// Destroys the instance of the <see cref="AMMediaType"/> class.
/// </summary>
///
~AMMediaType( )
{
Dispose( false );
}
/// <summary>
/// Dispose the object.
/// </summary>
///
public void Dispose( )
{
Dispose( true );
// remove me from the Finalization queue
GC.SuppressFinalize( this );
}
/// <summary>
/// Dispose the object
/// </summary>
///
/// <param name="disposing">Indicates if disposing was initiated manually.</param>
///
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
/// <summary>
/// The structure contains information about a pin.
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode )]
internal struct PinInfo
{
/// <summary>
/// Owning filter.
/// </summary>
public IBaseFilter Filter;
/// <summary>
/// Direction of the pin.
/// </summary>
public PinDirection Direction;
/// <summary>
/// Name of the pin.
/// </summary>
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )]
public string Name;
}
// FILTER_INFO
[ComVisible( false ),
StructLayout( LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode )]
internal struct FilterInfo
{
/// <summary>
/// Filter's name.
/// </summary>
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )]
public string Name;
/// <summary>
/// Owning graph.
/// </summary>
public IFilterGraph FilterGraph;
}
// VIDEOINFOHEADER
/// <summary>
/// The structure describes the bitmap and color information for a video image.
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential )]
internal struct VideoInfoHeader
{
/// <summary>
/// <see cref="RECT"/> structure that specifies the source video window.
/// </summary>
public RECT SrcRect;
/// <summary>
/// <see cref="RECT"/> structure that specifies the destination video window.
/// </summary>
public RECT TargetRect;
/// <summary>
/// Approximate data rate of the video stream, in bits per second.
/// </summary>
public int BitRate;
/// <summary>
/// Data error rate, in bit errors per second.
/// </summary>
public int BitErrorRate;
/// <summary>
/// The desired average display time of the video frames, in 100-nanosecond units.
/// </summary>
public long AverageTimePerFrame;
/// <summary>
/// <see cref="BitmapInfoHeader"/> structure that contains color and dimension information for the video image bitmap.
/// </summary>
public BitmapInfoHeader BmiHeader;
}
// VIDEOINFOHEADER2
/// <summary>
/// The structure describes the bitmap and color information for a video image (v2).
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential )]
internal struct VideoInfoHeader2
{
/// <summary>
/// <see cref="RECT"/> structure that specifies the source video window.
/// </summary>
public RECT SrcRect;
/// <summary>
/// <see cref="RECT"/> structure that specifies the destination video window.
/// </summary>
public RECT TargetRect;
/// <summary>
/// Approximate data rate of the video stream, in bits per second.
/// </summary>
public int BitRate;
/// <summary>
/// Data error rate, in bit errors per second.
/// </summary>
public int BitErrorRate;
/// <summary>
/// The desired average display time of the video frames, in 100-nanosecond units.
/// </summary>
public long AverageTimePerFrame;
/// <summary>
/// Flags that specify how the video is interlaced.
/// </summary>
public int InterlaceFlags;
/// <summary>
/// Flag set to indicate that the duplication of the stream should be restricted.
/// </summary>
public int CopyProtectFlags;
/// <summary>
/// The X dimension of picture aspect ratio.
/// </summary>
public int PictAspectRatioX;
/// <summary>
/// The Y dimension of picture aspect ratio.
/// </summary>
public int PictAspectRatioY;
/// <summary>
/// Reserved for future use.
/// </summary>
public int Reserved1;
/// <summary>
/// Reserved for future use.
/// </summary>
public int Reserved2;
/// <summary>
/// <see cref="BitmapInfoHeader"/> structure that contains color and dimension information for the video image bitmap.
/// </summary>
public BitmapInfoHeader BmiHeader;
}
/// <summary>
/// The structure contains information about the dimensions and color format of a device-independent bitmap (DIB).
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential, Pack = 2 )]
internal struct BitmapInfoHeader
{
/// <summary>
/// Specifies the number of bytes required by the structure.
/// </summary>
public int Size;
/// <summary>
/// Specifies the width of the bitmap.
/// </summary>
public int Width;
/// <summary>
/// Specifies the height of the bitmap, in pixels.
/// </summary>
public int Height;
/// <summary>
/// Specifies the number of planes for the target device. This value must be set to 1.
/// </summary>
public short Planes;
/// <summary>
/// Specifies the number of bits per pixel.
/// </summary>
public short BitCount;
/// <summary>
/// If the bitmap is compressed, this member is a <b>FOURCC</b> the specifies the compression.
/// </summary>
public int Compression;
/// <summary>
/// Specifies the size, in bytes, of the image.
/// </summary>
public int ImageSize;
/// <summary>
/// Specifies the horizontal resolution, in pixels per meter, of the target device for the bitmap.
/// </summary>
public int XPelsPerMeter;
/// <summary>
/// Specifies the vertical resolution, in pixels per meter, of the target device for the bitmap.
/// </summary>
public int YPelsPerMeter;
/// <summary>
/// Specifies the number of color indices in the color table that are actually used by the bitmap.
/// </summary>
public int ColorsUsed;
/// <summary>
/// Specifies the number of color indices that are considered important for displaying the bitmap.
/// </summary>
public int ColorsImportant;
}
// RECT
/// <summary>
/// The structure defines the coordinates of the upper-left and lower-right corners of a rectangle.
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential )]
internal struct RECT
{
/// <summary>
/// Specifies the x-coordinate of the upper-left corner of the rectangle.
/// </summary>
public int Left;
/// <summary>
/// Specifies the y-coordinate of the upper-left corner of the rectangle.
/// </summary>
public int Top;
/// <summary>
/// Specifies the x-coordinate of the lower-right corner of the rectangle.
/// </summary>
public int Right;
/// <summary>
/// Specifies the y-coordinate of the lower-right corner of the rectangle.
/// </summary>
public int Bottom;
}
// CAUUID
/// <summary>
/// The CAUUID structure is a Counted Array of UUID or GUID types.
/// </summary>
///
[ComVisible( false ),
StructLayout( LayoutKind.Sequential )]
internal struct CAUUID
{
/// <summary>
/// Size of the array pointed to by <b>pElems</b>.
/// </summary>
public int cElems;
/// <summary>
/// Pointer to an array of UUID values, each of which specifies UUID.
/// </summary>
public IntPtr pElems;
/// <summary>
/// Performs manual marshaling of <b>pElems</b> to retrieve an array of Guid objects.
/// </summary>
///
/// <returns>A managed representation of <b>pElems</b>.</returns>
///
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;
}
}
/// <summary>
/// Enumeration of DirectShow event codes.
/// </summary>
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;
}
/// <summary>
/// Specifies a filter's state or the state of the filter graph.
/// </summary>
internal enum FilterState
{
/// <summary>
/// Stopped. The filter is not processing data.
/// </summary>
State_Stopped,
/// <summary>
/// Paused. The filter is processing data, but not rendering it.
/// </summary>
State_Paused,
/// <summary>
/// Running. The filter is processing and rendering data.
/// </summary>
State_Running
}
}

View File

@@ -0,0 +1,88 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// Some miscellaneous functions.
/// </summary>
///
internal static class Tools
{
/// <summary>
/// Get filter's pin.
/// </summary>
///
/// <param name="filter">Filter to get pin of.</param>
/// <param name="dir">Pin's direction.</param>
/// <param name="num">Pin's number.</param>
///
/// <returns>Returns filter's pin.</returns>
///
public static IPin GetPin( IBaseFilter filter, PinDirection dir, int num )
{
IPin[] pin = new IPin[1];
IEnumPins pinsEnum = null;
// enum filter pins
if ( filter.EnumPins( out pinsEnum ) == 0 )
{
PinDirection pinDir;
int n;
try
{
// get next pin
while ( pinsEnum.Next( 1, pin, out n ) == 0 )
{
// query pin`s direction
pin[0].QueryDirection( out pinDir );
if ( pinDir == dir )
{
if ( num == 0 )
return pin[0];
num--;
}
Marshal.ReleaseComObject( pin[0] );
pin[0] = null;
}
}
finally
{
Marshal.ReleaseComObject( pinsEnum );
}
}
return null;
}
/// <summary>
/// Get filter's input pin.
/// </summary>
///
/// <param name="filter">Filter to get pin of.</param>
/// <param name="num">Pin's number.</param>
///
/// <returns>Returns filter's pin.</returns>
///
public static IPin GetInPin( IBaseFilter filter, int num )
{
return GetPin( filter, PinDirection.Input, num );
}
/// <summary>
/// Get filter's output pin.
/// </summary>
///
/// <param name="filter">Filter to get pin of.</param>
/// <param name="num">Pin's number.</param>
///
/// <returns>Returns filter's pin.</returns>
///
public static IPin GetOutPin( IBaseFilter filter, int num )
{
return GetPin( filter, PinDirection.Output, num );
}
}
}

View File

@@ -0,0 +1,327 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
/// <summary>
/// DirectShow class IDs.
/// </summary>
[ComVisible( false )]
static internal class Clsid
{
/// <summary>
/// System device enumerator.
/// </summary>
///
/// <remarks>Equals to CLSID_SystemDeviceEnum.</remarks>
///
public static readonly Guid SystemDeviceEnum =
new Guid( 0x62BE5D10, 0x60EB, 0x11D0, 0xBD, 0x3B, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86 );
/// <summary>
/// Filter graph.
/// </summary>
///
/// <remarks>Equals to CLSID_FilterGraph.</remarks>
///
public static readonly Guid FilterGraph =
new Guid( 0xE436EBB3, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// Sample grabber.
/// </summary>
///
/// <remarks>Equals to CLSID_SampleGrabber.</remarks>
///
public static readonly Guid SampleGrabber =
new Guid( 0xC1F400A0, 0x3F08, 0x11D3, 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 );
/// <summary>
/// Capture graph builder.
/// </summary>
///
/// <remarks>Equals to CLSID_CaptureGraphBuilder2.</remarks>
///
public static readonly Guid CaptureGraphBuilder2 =
new Guid( 0xBF87B6E1, 0x8C27, 0x11D0, 0xB3, 0xF0, 0x00, 0xAA, 0x00, 0x37, 0x61, 0xC5 );
/// <summary>
/// Async reader.
/// </summary>
///
/// <remarks>Equals to CLSID_AsyncReader.</remarks>
///
public static readonly Guid AsyncReader =
new Guid( 0xE436EBB5, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
public static readonly Guid NullRenderer =
new Guid(0xC1F400A4, 0x3F08, 0x11d3, 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37);
}
/// <summary>
/// DirectShow format types.
/// </summary>
///
[ComVisible( false )]
static internal class FormatType
{
/// <summary>
/// VideoInfo.
/// </summary>
///
/// <remarks>Equals to FORMAT_VideoInfo.</remarks>
///
public static readonly Guid VideoInfo =
new Guid( 0x05589F80, 0xC356, 0x11CE, 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A );
/// <summary>
/// VideoInfo2.
/// </summary>
///
/// <remarks>Equals to FORMAT_VideoInfo2.</remarks>
///
public static readonly Guid VideoInfo2 =
new Guid( 0xf72A76A0, 0xEB0A, 0x11D0, 0xAC, 0xE4, 0x00, 0x00, 0xC0, 0xCC, 0x16, 0xBA );
}
/// <summary>
/// DirectShow media types.
/// </summary>
///
[ComVisible( false )]
static internal class MediaType
{
/// <summary>
/// Video.
/// </summary>
///
/// <remarks>Equals to MEDIATYPE_Video.</remarks>
///
public static readonly Guid Video =
new Guid( 0x73646976, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// Interleaved. Used by Digital Video (DV).
/// </summary>
///
/// <remarks>Equals to MEDIATYPE_Interleaved.</remarks>
///
public static readonly Guid Interleaved =
new Guid( 0x73766169, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// Audio.
/// </summary>
///
/// <remarks>Equals to MEDIATYPE_Audio.</remarks>
///
public static readonly Guid Audio =
new Guid( 0x73647561, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// Text.
/// </summary>
///
/// <remarks>Equals to MEDIATYPE_Text.</remarks>
///
public static readonly Guid Text =
new Guid( 0x73747874, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// Byte stream with no time stamps.
/// </summary>
///
/// <remarks>Equals to MEDIATYPE_Stream.</remarks>
///
public static readonly Guid Stream =
new Guid( 0xE436EB83, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
}
/// <summary>
/// DirectShow media subtypes.
/// </summary>
///
[ComVisible( false )]
static internal class MediaSubType
{
/// <summary>
/// YUY2 (packed 4:2:2).
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_YUYV.</remarks>
///
public static readonly Guid YUYV =
new Guid( 0x56595559, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// IYUV.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_IYUV.</remarks>
///
public static readonly Guid IYUV =
new Guid( 0x56555949, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// A DV encoding format. (FOURCC 'DVSD')
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_DVSD.</remarks>
///
public static readonly Guid DVSD =
new Guid( 0x44535644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 );
/// <summary>
/// RGB, 1 bit per pixel (bpp), palettized.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB1.</remarks>
///
public static readonly Guid RGB1 =
new Guid( 0xE436EB78, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB, 4 bpp, palettized.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB4.</remarks>
///
public static readonly Guid RGB4 =
new Guid( 0xE436EB79, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB, 8 bpp.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB8.</remarks>
///
public static readonly Guid RGB8 =
new Guid( 0xE436EB7A, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB 565, 16 bpp.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB565.</remarks>
///
public static readonly Guid RGB565 =
new Guid( 0xE436EB7B, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB 555, 16 bpp.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB555.</remarks>
///
public static readonly Guid RGB555 =
new Guid( 0xE436EB7C, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB, 24 bpp.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB24.</remarks>
///
public static readonly Guid RGB24 =
new Guid( 0xE436Eb7D, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// RGB, 32 bpp, no alpha channel.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_RGB32.</remarks>
///
public static readonly Guid RGB32 =
new Guid( 0xE436EB7E, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// Data from AVI file.
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_Avi.</remarks>
///
public static readonly Guid Avi =
new Guid( 0xE436EB88, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70 );
/// <summary>
/// Advanced Streaming Format (ASF).
/// </summary>
///
/// <remarks>Equals to MEDIASUBTYPE_Asf.</remarks>
///
public static readonly Guid Asf =
new Guid( 0x3DB80F90, 0x9412, 0x11D1, 0xAD, 0xED, 0x00, 0x00, 0xF8, 0x75, 0x4B, 0x99 );
}
/// <summary>
/// DirectShow pin categories.
/// </summary>
///
[ComVisible( false )]
static internal class PinCategory
{
/// <summary>
/// Capture pin.
/// </summary>
///
/// <remarks>Equals to PIN_CATEGORY_CAPTURE.</remarks>
///
public static readonly Guid Capture =
new Guid( 0xFB6C4281, 0x0353, 0x11D1, 0x90, 0x5F, 0x00, 0x00, 0xC0, 0xCC, 0x16, 0xBA );
/// <summary>
/// Preview pin.
/// </summary>
///
/// <remarks>Equals to PIN_CATEGORY_PREVIEW.</remarks>
///
public static readonly Guid Preview =
new Guid(0xfb6c4282, 0x0353, 0x11d1, 0x90, 0x5f, 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba);
}
/// <summary>
/// DirectShow filter categories.
/// </summary>
[ComVisible(false)]
public static class FilterCategory
{
/// <summary>
/// Audio input device category.
/// </summary>
///
/// <remarks>Equals to CLSID_AudioInputDeviceCategory.</remarks>
///
public static readonly Guid AudioInputDevice =
new Guid(0x33D9A762, 0x90C8, 0x11D0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
/// <summary>
/// Video input device category.
/// </summary>
///
/// <remarks>Equals to CLSID_VideoInputDeviceCategory.</remarks>
///
public static readonly Guid VideoInputDevice =
new Guid(0x860BB310, 0x5D01, 0x11D0, 0xBD, 0x3B, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
/// <summary>
/// Video compressor category.
/// </summary>
///
/// <remarks>Equals to CLSID_VideoCompressorCategory.</remarks>
///
public static readonly Guid VideoCompressorCategory =
new Guid(0x33D9A760, 0x90C8, 0x11D0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
/// <summary>
/// Audio compressor category
/// </summary>
///
/// <remarks>Equals to CLSID_AudioCompressorCategory.</remarks>
///
public static readonly Guid AudioCompressorCategory =
new Guid(0x33D9A761, 0x90C8, 0x11D0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
}
}

View File

@@ -0,0 +1,94 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
/// <summary>
/// Some Win32 API used internally.
/// </summary>
///
internal static class Win32
{
/// <summary>
/// Supplies a pointer to an implementation of <b>IBindCtx</b> (a bind context object).
/// This object stores information about a particular moniker-binding operation.
/// </summary>
///
/// <param name="reserved">Reserved for future use; must be zero.</param>
/// <param name="ppbc">Address of <b>IBindCtx*</b> pointer variable that receives the
/// interface pointer to the new bind context object.</param>
///
/// <returns>Returns <b>S_OK</b> on success.</returns>
///
[DllImport( "ole32.dll" )]
public static extern
int CreateBindCtx( int reserved, out IBindCtx ppbc );
/// <summary>
/// Converts a string into a moniker that identifies the object named by the string.
/// </summary>
///
/// <param name="pbc">Pointer to the IBindCtx interface on the bind context object to be used in this binding operation.</param>
/// <param name="szUserName">Pointer to a zero-terminated wide character string containing the display name to be parsed. </param>
/// <param name="pchEaten">Pointer to the number of characters of szUserName that were consumed.</param>
/// <param name="ppmk">Address of <b>IMoniker*</b> pointer variable that receives the interface pointer
/// to the moniker that was built from <b>szUserName</b>.</param>
///
/// <returns>Returns <b>S_OK</b> on success.</returns>
///
[DllImport( "ole32.dll", CharSet = CharSet.Unicode )]
public static extern
int MkParseDisplayName( IBindCtx pbc, string szUserName,
ref int pchEaten, out IMoniker ppmk );
/// <summary>
/// Copy a block of memory.
/// </summary>
///
/// <param name="dst">Destination pointer.</param>
/// <param name="src">Source pointer.</param>
/// <param name="count">Memory block's length to copy.</param>
///
/// <returns>Return's the value of <b>dst</b> - pointer to destination.</returns>
///
[DllImport("ntdll.dll", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern int memcpy(
byte* dst,
byte* src,
int count);
/// <summary>
/// Invokes a new property frame, that is, a property sheet dialog box.
/// </summary>
///
/// <param name="hwndOwner">Parent window of property sheet dialog box.</param>
/// <param name="x">Horizontal position for dialog box.</param>
/// <param name="y">Vertical position for dialog box.</param>
/// <param name="caption">Dialog box caption.</param>
/// <param name="cObjects">Number of object pointers in <b>ppUnk</b>.</param>
/// <param name="ppUnk">Pointer to the objects for property sheet.</param>
/// <param name="cPages">Number of property pages in <b>lpPageClsID</b>.</param>
/// <param name="lpPageClsID">Array of CLSIDs for each property page.</param>
/// <param name="lcid">Locale identifier for property sheet locale.</param>
/// <param name="dwReserved">Reserved.</param>
/// <param name="lpvReserved">Reserved.</param>
///
/// <returns>Returns <b>S_OK</b> on success.</returns>
///
[DllImport( "oleaut32.dll" )]
public static extern int OleCreatePropertyFrame(
IntPtr hwndOwner,
int x,
int y,
[MarshalAs( UnmanagedType.LPWStr )] string caption,
int cObjects,
[MarshalAs( UnmanagedType.Interface, ArraySubType = UnmanagedType.IUnknown )]
ref object ppUnk,
int cPages,
IntPtr lpPageClsID,
int lcid,
int dwReserved,
IntPtr lpvReserved );
}
}

322
VAR.Toolbox/Code/Webcam.cs Normal file
View File

@@ -0,0 +1,322 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using VAR.Toolbox.Code.DirectShow;
namespace VAR.Toolbox.Code
{
public class Webcam
{
#region Declarations
private IFilterGraph2 graph;
private ICaptureGraphBuilder2 capture;
private IMediaControl control;
private IBaseFilter sourceFilter;
private IBaseFilter samplegrabberfilter;
private IBaseFilter nullrenderer;
private Grabber grabber;
private int width = 0;
private int height = 0;
private int bpp = 0;
private bool active = false;
private static Dictionary<string, string> _deviceDescriptions;
#endregion Declarations
#region Properties
public int Width { get { return width; } }
public int Height { get { return height; } }
public int BPP { get { return bpp; } }
public bool Active { get { return active; } }
#endregion Properties
#region Lifecycle
public Webcam(string monikerString)
{
int result;
graph = CreateInstanceFromClsid<IFilterGraph2>(Clsid.FilterGraph);
capture = CreateInstanceFromClsid<ICaptureGraphBuilder2>(Clsid.CaptureGraphBuilder2);
control = (IMediaControl)graph;
capture.SetFiltergraph((IGraphBuilder)graph);
IBindCtx bindCtx = null;
IMoniker moniker = null;
int n = 0;
if (Win32.CreateBindCtx(0, out bindCtx) != 0)
{
throw new Exception("Failed to create binding context");
}
if (Win32.MkParseDisplayName(bindCtx, monikerString, ref n, out moniker) != 0)
{
throw new Exception("Failed to create binding moniker");
}
graph.AddSourceFilterForMoniker(moniker, bindCtx, monikerString, out sourceFilter);
samplegrabberfilter = CreateInstanceFromClsid<IBaseFilter>(Clsid.SampleGrabber);
graph.AddFilter(samplegrabberfilter, string.Format("SampleGrabber {0}", monikerString));
ISampleGrabber sampleGrabber = (ISampleGrabber)samplegrabberfilter;
// Set media type
AMMediaType mediaType = new AMMediaType();
mediaType.MajorType = MediaType.Video;
mediaType.SubType = MediaSubType.RGB24;
sampleGrabber.SetMediaType(mediaType);
grabber = new Grabber(this);
result = sampleGrabber.SetCallback(grabber, 1);
if (result < 0) throw new Exception("Failure creating Webcam device");
//set the null renderer
nullrenderer = CreateInstanceFromClsid<IBaseFilter>(Clsid.NullRenderer);
graph.AddFilter(nullrenderer, string.Format("NullRenderer {0}", monikerString));
result = capture.RenderStream(PinCategory.Preview, MediaType.Video, sourceFilter, samplegrabberfilter, nullrenderer);
if (result < 0) throw new Exception("Failure creating Webcam device");
AMMediaType queryMediaType = new AMMediaType();
result = sampleGrabber.GetConnectedMediaType(queryMediaType);
if (result == 0)
{
if (queryMediaType.FormatType == FormatType.VideoInfo)
{
VideoInfoHeader videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(queryMediaType.FormatPtr, typeof(VideoInfoHeader));
width = videoInfo.BmiHeader.Width;
height = videoInfo.BmiHeader.Height;
bpp = videoInfo.BmiHeader.BitCount;
}
}
control.Run();
Stop();
}
#endregion Lifecycle
#region Public methods
public void Start()
{
int result;
result = nullrenderer.Run(0);
if (result < 0) throw new Exception("Webcam Start failure");
result = samplegrabberfilter.Run(0);
if (result < 0) throw new Exception("Webcam Start failure");
result = sourceFilter.Run(0);
if (result < 0) throw new Exception("Webcam Start failure");
active = true;
}
public void Stop()
{
int result;
result = sourceFilter.Stop();
if (result < 0) throw new Exception("Webcam Stop failure");
result = samplegrabberfilter.Stop();
if (result < 0) throw new Exception("Webcam Stop failure");
result = nullrenderer.Stop();
if (result < 0) throw new Exception("Webcam Stop failure");
active = false;
}
public static Dictionary<string, string> ListDevices()
{
if (_deviceDescriptions != null) { return _deviceDescriptions; }
int result;
Dictionary<string, string> devices = new Dictionary<string, string>();
ICreateDevEnum devEnum = CreateInstanceFromClsid<ICreateDevEnum>(Clsid.SystemDeviceEnum);
IEnumMoniker enumMon = null;
Guid category = FilterCategory.VideoInputDevice;
result = devEnum.CreateClassEnumerator(ref category, out enumMon, 0);
if (result != 0)
throw new ApplicationException("No devices of the category");
IMoniker[] devMoniker = new IMoniker[1];
IntPtr n = IntPtr.Zero;
while (true)
{
// Get next filter
result = enumMon.Next(1, devMoniker, n);
if ((result != 0) || (devMoniker[0] == null))
break;
// Add device description
string deviceName = new String(GetMonikerName(devMoniker[0]).ToCharArray());
string deviceString = new String(GetMonikerString(devMoniker[0]).ToCharArray());
devices.Add(deviceName, deviceString);
// Release COM object
Marshal.ReleaseComObject(devMoniker[0]);
devMoniker[0] = null;
}
_deviceDescriptions = devices;
Marshal.ReleaseComObject(devEnum);
Marshal.ReleaseComObject(enumMon);
return devices;
}
#endregion Public methods
#region Private methods
private static T CreateInstanceFromClsid<T>(Guid clsid)
{
Type srvType = Type.GetTypeFromCLSID(clsid);
if (srvType == null)
throw new ApplicationException("Failed creating device enumerator");
object comObj = Activator.CreateInstance(srvType);
return (T)comObj;
}
//
// Get moniker string of the moniker
//
private static string GetMonikerString(IMoniker moniker)
{
string str;
moniker.GetDisplayName(null, null, out str);
return str;
}
//
// Get moniker name represented
//
private static string GetMonikerName(IMoniker moniker)
{
Object bagObj = null;
IPropertyBag bag = null;
try
{
Guid bagId = typeof(IPropertyBag).GUID;
// get property bag of the moniker
moniker.BindToStorage(null, null, ref bagId, out bagObj);
bag = (IPropertyBag)bagObj;
// read FriendlyName
object val = "";
int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
if (hr != 0)
Marshal.ThrowExceptionForHR(hr);
// get it as string
string ret = (string)val;
if ((ret == null) || (ret.Length < 1))
throw new ApplicationException();
return ret;
}
catch (Exception)
{
return string.Empty;
}
finally
{
// release all COM objects
bag = null;
if (bagObj != null)
{
Marshal.ReleaseComObject(bagObj);
bagObj = null;
}
}
}
#endregion Private methods
#region NewFrameEvent
public delegate void NewFrameEventHandler(object sender, Bitmap frame);
public event NewFrameEventHandler NewFrame;
private void OnNewFrame(Bitmap frame)
{
if (NewFrame != null)
NewFrame(this, frame);
}
#endregion NewFrameEvent
#region Grabber
private class Grabber : ISampleGrabberCB
{
private Webcam _parent;
public Grabber(Webcam parent)
{
_parent = parent;
}
public int SampleCB(double sampleTime, IntPtr sample)
{
return 0;
}
public int BufferCB(double sampleTime, IntPtr buffer, int bufferLen)
{
if (_parent.NewFrame != null)
{
// create new image
Bitmap _image = new Bitmap(_parent.width, _parent.height, PixelFormat.Format24bppRgb);
Rectangle _imageRect = new Rectangle(0, 0, _parent.width, _parent.height);
// lock bitmap data
BitmapData imageData = _image.LockBits(
_imageRect,
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
// copy image data
int srcStride = imageData.Stride;
int dstStride = imageData.Stride;
unsafe
{
byte* dst = (byte*)imageData.Scan0.ToPointer() + dstStride * (_parent.height - 1);
byte* src = (byte*)buffer.ToPointer();
for (int y = 0; y < _parent.height; y++)
{
Win32.memcpy(dst, src, srcStride);
dst -= dstStride;
src += srcStride;
}
}
// unlock bitmap data
_image.UnlockBits(imageData);
// notify parent
_parent.OnNewFrame(_image);
}
return 0;
}
}
#endregion Grabber
}
}

View File

@@ -0,0 +1,125 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace VAR.Toolbox.Controls
{
public class CtrImageViewer : PictureBox
{
#region Declarations
Image _imageShow = null;
// Image projection
private double offsetX = 0;
private double offsetY = 0;
private double scaleX = 1.0f;
private double scaleY = 1.0f;
#endregion
#region Properties
public Image ImageShow
{
get { return _imageShow; }
set
{
lock (this)
{
_imageShow = value;
this.Invalidate();
}
}
}
#endregion
#region Control life cycle
public CtrImageViewer()
{
BackColor = Color.Black;
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
Redraw(pe.Graphics);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
//Redraw(null);
this.Invalidate();
}
#endregion
#region Private methods
private void Redraw(Graphics graph)
{
if (_imageShow == null)
{
return;
}
lock (_imageShow)
{
if (graph == null)
{
graph = this.CreateGraphics();
}
// Calcular dimensiones a dibujar y centrar
int imgDrawWidth;
int imgDrawHeight;
float imgDrawX = 0;
float imgDrawY = 0;
float relation = (float)_imageShow.Width / (float)_imageShow.Height;
if (relation > 0)
{
// Imagen mas ancha que alta
imgDrawHeight = (int)(this.Width / relation);
if (imgDrawHeight > this.Height)
{
imgDrawHeight = this.Height;
imgDrawWidth = (int)(this.Height * relation);
imgDrawX = ((this.Width - imgDrawWidth) / 2.0f);
}
else
{
imgDrawWidth = this.Width;
imgDrawY = ((this.Height - imgDrawHeight) / 2.0f);
}
}
else
{
// Imagen mas alta que ancha
imgDrawWidth = (int)(this.Width * relation);
if (imgDrawWidth > this.Width)
{
imgDrawWidth = this.Width;
imgDrawHeight = (int)(this.Height / relation);
imgDrawY = ((this.Height - imgDrawHeight) / 2.0f);
}
else
{
imgDrawHeight = this.Height;
imgDrawX = ((this.Width - imgDrawWidth) / 2.0f);
}
}
graph.DrawImage(_imageShow, imgDrawX, imgDrawY, imgDrawWidth, imgDrawHeight);
offsetX = imgDrawX;
offsetY = imgDrawY;
scaleX = (double)imgDrawWidth / (double)_imageShow.Width;
scaleY = (double)imgDrawHeight / (double)_imageShow.Height;
}
}
#endregion
}
}

View File

@@ -30,6 +30,7 @@
{ {
this.btnBase64 = new System.Windows.Forms.Button(); this.btnBase64 = new System.Windows.Forms.Button();
this.btnProxyCmd = new System.Windows.Forms.Button(); this.btnProxyCmd = new System.Windows.Forms.Button();
this.btnWebcam = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnBase64 // btnBase64
@@ -52,11 +53,22 @@
this.btnProxyCmd.UseVisualStyleBackColor = true; this.btnProxyCmd.UseVisualStyleBackColor = true;
this.btnProxyCmd.Click += new System.EventHandler(this.btnProxyCmd_Click); this.btnProxyCmd.Click += new System.EventHandler(this.btnProxyCmd_Click);
// //
// btnWebcam
//
this.btnWebcam.Location = new System.Drawing.Point(12, 94);
this.btnWebcam.Name = "btnWebcam";
this.btnWebcam.Size = new System.Drawing.Size(209, 36);
this.btnWebcam.TabIndex = 2;
this.btnWebcam.Text = "Webcam";
this.btnWebcam.UseVisualStyleBackColor = true;
this.btnWebcam.Click += new System.EventHandler(this.btnWebcam_Click);
//
// FrmToolbox // FrmToolbox
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(233, 391); this.ClientSize = new System.Drawing.Size(233, 391);
this.Controls.Add(this.btnWebcam);
this.Controls.Add(this.btnProxyCmd); this.Controls.Add(this.btnProxyCmd);
this.Controls.Add(this.btnBase64); this.Controls.Add(this.btnBase64);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
@@ -71,6 +83,7 @@
private System.Windows.Forms.Button btnBase64; private System.Windows.Forms.Button btnBase64;
private System.Windows.Forms.Button btnProxyCmd; private System.Windows.Forms.Button btnProxyCmd;
private System.Windows.Forms.Button btnWebcam;
} }
} }

View File

@@ -21,5 +21,11 @@ namespace VAR.Toolbox.UI
var frmProxyCmd = new FrmProxyCmd(); var frmProxyCmd = new FrmProxyCmd();
frmProxyCmd.Show(); frmProxyCmd.Show();
} }
private void btnWebcam_Click(object sender, EventArgs e)
{
var frmWebcam = new FrmWebcam();
frmWebcam.Show();
}
} }
} }

99
VAR.Toolbox/UI/FrmWebcam.Designer.cs generated Normal file
View File

@@ -0,0 +1,99 @@
namespace VAR.Toolbox
{
partial class FrmWebcam
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartStop = new System.Windows.Forms.Button();
this.cboWebcams = new System.Windows.Forms.ComboBox();
this.picWebcam = new VAR.Toolbox.Controls.CtrImageViewer();
((System.ComponentModel.ISupportInitialize)(this.picWebcam)).BeginInit();
this.SuspendLayout();
//
// btnStartStop
//
this.btnStartStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnStartStop.Location = new System.Drawing.Point(18, 500);
this.btnStartStop.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnStartStop.Name = "btnStartStop";
this.btnStartStop.Size = new System.Drawing.Size(112, 35);
this.btnStartStop.TabIndex = 4;
this.btnStartStop.Text = "Start";
this.btnStartStop.UseVisualStyleBackColor = true;
this.btnStartStop.Click += new System.EventHandler(this.btnStartStop_Click);
//
// cboWebcams
//
this.cboWebcams.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cboWebcams.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboWebcams.FormattingEnabled = true;
this.cboWebcams.Location = new System.Drawing.Point(140, 500);
this.cboWebcams.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.cboWebcams.Name = "cboWebcams";
this.cboWebcams.Size = new System.Drawing.Size(397, 28);
this.cboWebcams.TabIndex = 5;
//
// picWebcam
//
this.picWebcam.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.picWebcam.BackColor = System.Drawing.Color.Black;
this.picWebcam.ImageShow = null;
this.picWebcam.Location = new System.Drawing.Point(18, 18);
this.picWebcam.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.picWebcam.Name = "picWebcam";
this.picWebcam.Size = new System.Drawing.Size(520, 472);
this.picWebcam.TabIndex = 0;
this.picWebcam.TabStop = false;
//
// FrmWebcam
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(558, 554);
this.Controls.Add(this.cboWebcams);
this.Controls.Add(this.btnStartStop);
this.Controls.Add(this.picWebcam);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FrmWebcam";
this.Text = "Webcam";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmWebcam_FormClosed);
this.Load += new System.EventHandler(this.FrmWebcam_Load);
((System.ComponentModel.ISupportInitialize)(this.picWebcam)).EndInit();
this.ResumeLayout(false);
}
#endregion
private VAR.Toolbox.Controls.CtrImageViewer picWebcam;
private System.Windows.Forms.Button btnStartStop;
private System.Windows.Forms.ComboBox cboWebcams;
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using VAR.Toolbox.Code;
namespace VAR.Toolbox
{
public partial class FrmWebcam : Form
{
private Webcam webcam = null;
public FrmWebcam()
{
InitializeComponent();
}
private void FrmWebcam_Load(object sender, EventArgs e)
{
cboWebcams_LoadData();
}
void webcam_NewFrame(object sender, Bitmap frame)
{
picWebcam.ImageShow = frame;
}
private void FrmWebcam_FormClosed(object sender, FormClosedEventArgs e)
{
if(webcam!=null){
webcam.Stop();
}
}
private void btnStartStop_Click(object sender, EventArgs e)
{
if (webcam == null)
{
InitWebcam();
}
if (webcam != null)
{
if (webcam.Active)
{
webcam.Stop();
btnStartStop.Text = "Start";
picWebcam.ImageShow = null;
webcam = null;
}
else
{
webcam.Start();
btnStartStop.Text = "Stop";
}
}
}
private void InitWebcam()
{
if (cboWebcams.SelectedIndex < 0) { return; }
WebcamObject webcamObject = (WebcamObject)cboWebcams.SelectedItem;
webcam = new Webcam(webcamObject.Moniker);
webcam.NewFrame += webcam_NewFrame;
}
private class WebcamObject
{
public string Name;
public string Moniker;
public override string ToString()
{
return Name;
}
};
private void cboWebcams_LoadData()
{
try
{
Dictionary<string, string> devices = Webcam.ListDevices();
foreach (KeyValuePair<string, string> pair in devices)
{
cboWebcams.Items.Add(new WebcamObject { Name = pair.Key, Moniker = pair.Value });
}
if (cboWebcams.Items.Count > 0)
{
cboWebcams.SelectedIndex = 0;
}
}
catch (Exception)
{
cboWebcams.Items.Clear();
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -46,6 +47,40 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Code\DirectShow\CameraControlProperty.cs" />
<Compile Include="Code\DirectShow\IAMCameraControl.cs" />
<Compile Include="Code\DirectShow\IAMCrossbar.cs" />
<Compile Include="Code\DirectShow\IAMStreamConfig.cs" />
<Compile Include="Code\DirectShow\IAMVideoControl.cs" />
<Compile Include="Code\DirectShow\IBaseFilter.cs" />
<Compile Include="Code\DirectShow\ICaptureGraphBuilder2.cs" />
<Compile Include="Code\DirectShow\ICreateDevEnum.cs" />
<Compile Include="Code\DirectShow\IEnumFilters.cs" />
<Compile Include="Code\DirectShow\IEnumPins.cs" />
<Compile Include="Code\DirectShow\IFileSourceFilter.cs" />
<Compile Include="Code\DirectShow\IFilterGraph.cs" />
<Compile Include="Code\DirectShow\IFilterGraph2.cs" />
<Compile Include="Code\DirectShow\IGraphBuilder.cs" />
<Compile Include="Code\DirectShow\IMediaControl.cs" />
<Compile Include="Code\DirectShow\IMediaEventEx.cs" />
<Compile Include="Code\DirectShow\IMediaFilter.cs" />
<Compile Include="Code\DirectShow\IPersist.cs" />
<Compile Include="Code\DirectShow\IPin.cs" />
<Compile Include="Code\DirectShow\IPropertyBag.cs" />
<Compile Include="Code\DirectShow\IReferenceClock.cs" />
<Compile Include="Code\DirectShow\ISampleGrabber.cs" />
<Compile Include="Code\DirectShow\ISampleGrabberCB.cs" />
<Compile Include="Code\DirectShow\ISpecifyPropertyPages.cs" />
<Compile Include="Code\DirectShow\IVideoWindow.cs" />
<Compile Include="Code\DirectShow\PhysicalConnectorType.cs" />
<Compile Include="Code\DirectShow\Structures.cs" />
<Compile Include="Code\DirectShow\Tools.cs" />
<Compile Include="Code\DirectShow\Uuids.cs" />
<Compile Include="Code\DirectShow\Win32.cs" />
<Compile Include="Code\Webcam.cs" />
<Compile Include="Controls\CtrImageViewer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\FrmBase64.cs"> <Compile Include="UI\FrmBase64.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -71,6 +106,12 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\FrmWebcam.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\FrmWebcam.Designer.cs">
<DependentUpon>FrmWebcam.cs</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="UI\FrmBase64.resx"> <EmbeddedResource Include="UI\FrmBase64.resx">
@@ -82,6 +123,9 @@
<EmbeddedResource Include="UI\FrmToolbox.resx"> <EmbeddedResource Include="UI\FrmToolbox.resx">
<DependentUpon>FrmToolbox.cs</DependentUpon> <DependentUpon>FrmToolbox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UI\FrmWebcam.resx">
<DependentUpon>FrmWebcam.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />