#pragma warning disable IDE1006 // Naming Styles
using System;
using System.Runtime.InteropServices;
using System.Text;
using static Vanara.PInvoke.WinMm;
namespace Vanara.PInvoke
{
/// Items from the Vfw32.dll
public static partial class Vfw32
{
private const string Lib_Avicap32 = "avicap32.dll";
///
///
/// The capControlCallback function is the callback function used for precision control to begin and end streaming capture.
/// The name capControlCallback is a placeholder for the application-supplied function name.
///
///
/// To set the callback, send the WM_CAP_SET_CALLBACK_CAPCONTROL message to the capture window or call the
/// capSetCallbackOnCapControl macro.
///
///
/// Handle to the capture window associated with the callback function.
///
/// Current state of the capture operation. The CONTROLCALLBACK_PREROLL value is sent initially to enable prerolling of the video
/// sources and to return control to the capture application at the exact moment recording is to begin. The
/// CONTROLCALLBACK_CAPTURING value is sent once per captured frame to indicate that streaming capture is in progress and to enable
/// the application to end capture.
///
///
/// When nState is set to CONTROLCALLBACK_PREROLL, this callback function must return TRUE to start capture or FALSE
/// to abort it. When nState is set to CONTROLCALLBACK_CAPTURING, this callback function must return TRUE to continue capture
/// or FALSE to end it.
///
///
/// The first message sent to the callback procedure sets the nState parameter to CONTROLCALLBACK_PREROLL after allocating all
/// buffers and all other capture preparations are complete.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-capcontrolcallback CAPCONTROLCALLBACK Capcontrolcallback; LRESULT
// Capcontrolcallback( HWND hWnd, int nState ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPCONTROLCALLBACK")]
public delegate IntPtr capControlCallback(HWND hWnd, CONTROLCALLBACK nState);
///
///
/// The capErrorCallback function is the error callback function used with video capture. The name capErrorCallback is
/// a placeholder for the application-supplied function name.
///
///
/// To set the callback, send the WM_CAP_SET_CALLBACK_ERROR message to the capture window or call the capSetCallbackOnError macro.
///
///
/// Handle to the capture window associated with the callback function.
/// Error identification number.
/// Pointer to a textual description of the returned error.
/// None
///
///
/// A message identifier of zero indicates a new operation is starting and the callback function should clear the current error.
///
///
/// Note
///
/// The vfw.h header defines CAPERRORCALLBACK as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-caperrorcallbacka CAPERRORCALLBACKA Caperrorcallbacka; LRESULT
// Caperrorcallbacka( HWND hWnd, int nID, LPCSTR lpsz ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPERRORCALLBACKA")]
public delegate IntPtr capErrorCallback(HWND hWnd, int nID, [MarshalAs(UnmanagedType.LPTStr)] string lpsz);
///
///
/// The capStatusCallback function is the status callback function used with video capture. The name capStatusCallback
/// is a placeholder for the application-supplied function name.
///
///
/// To set the callback, send the WM_CAP_SET_CALLBACK_STATUS message to the capture window or call the capSetCallbackOnStatus macro.
///
///
/// Handle to the capture window associated with the callback function.
/// Message identification number.
/// Pointer to a textual description of the returned status.
/// None
///
///
/// During capture operations, the first message sent to the callback function is always IDS_CAP_BEGIN and the last is always
/// IDS_CAP_END. A message identifier of zero indicates a new operation is starting and the callback function should clear the
/// current status.
///
///
/// Note
///
/// The vfw.h header defines CAPSTATUSCALLBACK as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-capstatuscallbacka CAPSTATUSCALLBACKA Capstatuscallbacka; LRESULT
// Capstatuscallbacka( HWND hWnd, int nID, LPCSTR lpsz ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPSTATUSCALLBACKA")]
public delegate IntPtr capStatusCallback(HWND hWnd, int nID, [MarshalAs(UnmanagedType.LPTStr)] string lpsz);
///
///
/// The capVideoStreamCallback function is the callback function used with streaming capture to optionally process a frame of
/// captured video. The name capVideoStreamCallback is a placeholder for the application-supplied function name.
///
///
/// To set this callback for streaming capture, send the WM_CAP_SET_CALLBACK_VIDEOSTREAM message to the capture window or call the
/// capSetCallbackOnVideoStream macro.
///
///
/// To set this callback for preview frame capture, send the WM_CAP_SET_CALLBACK_FRAME message to the capture window or call the
/// capSetCallbackOnFrame macro.
///
///
/// Handle to the capture window associated with the callback function.
/// Pointer to a VIDEOHDR structure containing information about the captured frame.
/// None
///
/// The capture window calls a video stream callback function when a video buffer is marked done by the capture driver. When
/// capturing to disk, this will precede the disk write operation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-capvideocallback CAPVIDEOCALLBACK Capvideocallback; LRESULT
// Capvideocallback( HWND hWnd, LPVIDEOHDR lpVHdr ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPVIDEOCALLBACK")]
public delegate IntPtr capVideoStreamCallback(HWND hWnd, in VIDEOHDR lpVHdr);
///
///
/// The capWaveStreamCallback function is the callback function used with streaming capture to optionally process buffers of
/// audio data. The name capWaveStreamCallback is a placeholder for the application-supplied function name.
///
///
/// To set the callback, send the WM_CAP_SET_CALLBACK_WAVESTREAM message to the capture window or call the
/// capSetCallbackOnWaveStream macro.
///
///
/// Handle to the capture window associated with the callback function.
/// Pointer to a WAVEHDR structure containing information about the captured audio data.
/// None
///
/// The capture window calls a wave stream callback function when an audio buffer is marked done by the waveform-audio driver. When
/// capturing to disk, this will precede the disk write operation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-capwavecallback CAPWAVECALLBACK Capwavecallback; LRESULT
// Capwavecallback( HWND hWnd, LPWAVEHDR lpWHdr ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPWAVECALLBACK")]
public delegate IntPtr capWaveStreamCallback(HWND hWnd, in WAVEHDR lpWHdr);
///
///
/// The capYieldCallback function is the yield callback function used with video capture. The name capYieldCallback is
/// a placeholder for the application-supplied function name.
///
///
/// To set the callback, send the WM_CAP_SET_CALLBACK_YIELD message to the capture window or call the capSetCallbackOnYield macro.
///
///
/// Handle to the capture window associated with the callback function.
/// None
///
/// The capture window calls the yield callback function at least once for every captured video frame, but the exact rate depends on
/// the frame rate and the overhead of the capture driver and disk.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nc-vfw-capyieldcallback CAPYIELDCALLBACK Capyieldcallback; LRESULT
// Capyieldcallback( HWND hWnd ) {...}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPYIELDCALLBACK")]
public delegate IntPtr capYieldCallback(HWND hWnd);
/// Window messages for capture drivers.
[PInvokeData("vfw.h")]
public enum capMessage : uint
{
/// start of unicode messages
WM_CAP_START = User32.WM_USER,
///
WM_CAP_UNICODE_START = User32.WM_USER + 100,
///
WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1,
///
WM_CAP_SET_CALLBACK_ERRORW = WM_CAP_UNICODE_START + 2,
///
WM_CAP_SET_CALLBACK_STATUSW = WM_CAP_UNICODE_START + 3,
///
WM_CAP_SET_CALLBACK_ERRORA = WM_CAP_START + 2,
///
WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3,
///
WM_CAP_SET_CALLBACK_ERROR = WM_CAP_SET_CALLBACK_ERRORW,
///
WM_CAP_SET_CALLBACK_STATUS = WM_CAP_SET_CALLBACK_STATUSW,
///
WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4,
///
WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5,
///
WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6,
///
WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7,
///
WM_CAP_GET_USER_DATA = WM_CAP_START + 8,
///
WM_CAP_SET_USER_DATA = WM_CAP_START + 9,
///
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10,
///
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11,
///
WM_CAP_DRIVER_GET_NAMEA = WM_CAP_START + 12,
///
WM_CAP_DRIVER_GET_VERSIONA = WM_CAP_START + 13,
///
WM_CAP_DRIVER_GET_NAMEW = WM_CAP_UNICODE_START + 12,
///
WM_CAP_DRIVER_GET_VERSIONW = WM_CAP_UNICODE_START + 13,
///
WM_CAP_DRIVER_GET_NAME = WM_CAP_DRIVER_GET_NAMEW,
///
WM_CAP_DRIVER_GET_VERSION = WM_CAP_DRIVER_GET_VERSIONW,
///
WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14,
///
WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20,
///
WM_CAP_FILE_GET_CAPTURE_FILEA = WM_CAP_START + 21,
///
WM_CAP_FILE_SAVEASA = WM_CAP_START + 23,
///
WM_CAP_FILE_SAVEDIBA = WM_CAP_START + 25,
///
WM_CAP_FILE_SET_CAPTURE_FILEW = WM_CAP_UNICODE_START + 20,
///
WM_CAP_FILE_GET_CAPTURE_FILEW = WM_CAP_UNICODE_START + 21,
///
WM_CAP_FILE_SAVEASW = WM_CAP_UNICODE_START + 23,
///
WM_CAP_FILE_SAVEDIBW = WM_CAP_UNICODE_START + 25,
///
WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_FILE_SET_CAPTURE_FILEW,
///
WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_FILE_GET_CAPTURE_FILEW,
///
WM_CAP_FILE_SAVEAS = WM_CAP_FILE_SAVEASW,
///
WM_CAP_FILE_SAVEDIB = WM_CAP_FILE_SAVEDIBW,
///
WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22,
///
WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24,
///
WM_CAP_EDIT_COPY = WM_CAP_START + 30,
///
WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35,
///
WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36,
///
WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41,
///
WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42,
///
WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43,
///
WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44,
///
WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45,
///
WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46,
///
WM_CAP_SET_PREVIEW = WM_CAP_START + 50,
///
WM_CAP_SET_OVERLAY = WM_CAP_START + 51,
///
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52,
///
WM_CAP_SET_SCALE = WM_CAP_START + 53,
///
WM_CAP_GET_STATUS = WM_CAP_START + 54,
///
WM_CAP_SET_SCROLL = WM_CAP_START + 55,
///
WM_CAP_GRAB_FRAME = WM_CAP_START + 60,
///
WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61,
///
WM_CAP_SEQUENCE = WM_CAP_START + 62,
///
WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63,
///
WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64,
///
WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65,
///
WM_CAP_SET_MCI_DEVICEA = WM_CAP_START + 66,
///
WM_CAP_GET_MCI_DEVICEA = WM_CAP_START + 67,
///
WM_CAP_SET_MCI_DEVICEW = WM_CAP_UNICODE_START + 66,
///
WM_CAP_GET_MCI_DEVICEW = WM_CAP_UNICODE_START + 67,
///
WM_CAP_SET_MCI_DEVICE = WM_CAP_SET_MCI_DEVICEW,
///
WM_CAP_GET_MCI_DEVICE = WM_CAP_GET_MCI_DEVICEW,
///
WM_CAP_STOP = WM_CAP_START + 68,
///
WM_CAP_ABORT = WM_CAP_START + 69,
///
WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70,
///
WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71,
///
WM_CAP_SINGLE_FRAME = WM_CAP_START + 72,
///
WM_CAP_PAL_OPENA = WM_CAP_START + 80,
///
WM_CAP_PAL_SAVEA = WM_CAP_START + 81,
///
WM_CAP_PAL_OPENW = WM_CAP_UNICODE_START + 80,
///
WM_CAP_PAL_SAVEW = WM_CAP_UNICODE_START + 81,
///
WM_CAP_PAL_OPEN = WM_CAP_PAL_OPENW,
///
WM_CAP_PAL_SAVE = WM_CAP_PAL_SAVEW,
///
WM_CAP_PAL_PASTE = WM_CAP_START + 82,
///
WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83,
/// Following added post VFW 1.1
WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84,
///
WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85,
}
/// Current state of the capture operation.
[PInvokeData("vfw.h", MSDNShortId = "NC:vfw.CAPCONTROLCALLBACK")]
public enum CONTROLCALLBACK
{
/// Waiting to start capture
CONTROLCALLBACK_PREROLL = 1,
/// Now capturing
CONTROLCALLBACK_CAPTURING = 2,
}
/// Flags for VIDEOHDR.
[Flags]
public enum VHDR : uint
{
/// Done bit
VHDR_DONE = 0x00000001,
/// Set if this header has been prepared
VHDR_PREPARED = 0x00000002,
/// Reserved for driver
VHDR_INQUEUE = 0x00000004,
/// Key Frame
VHDR_KEYFRAME = 0x00000008,
}
///
/// The capCaptureAbort macro stops the capture operation. You can use this macro or explictly send the WM_CAP_ABORT message.
///
/// Handle to a capture window.
/// None
///
/// The capture operation must yield to use this macro.
///
/// In the case of step capture, the image data collected up to the point of the capCaptureAbort macro will be retained in
/// the capture file, but audio will not be captured.
///
/// Use the capCaptureStop macro to halt step capture at the current position, and then capture audio.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcaptureabort void capCaptureAbort( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureAbort")]
public static bool capCaptureAbort(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_ABORT);
///
/// The capCaptureGetSetup macro retrieves the current settings of the streaming capture parameters. You can use this macro
/// or explictly send the WM_CAP_GET_SEQUENCE_SETUP message.
///
/// Handle to a capture window.
/// Pointer to a CAPTUREPARMS structure.
/// None
/// For information about the parameters used to control streaming capture, see the CAPTUREPARMS structure.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturegetsetup void capCaptureGetSetup( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureGetSetup")]
public static bool capCaptureGetSetup(HWND hwnd, out CAPTUREPARMS s) => AVICapSM(hwnd, capMessage.WM_CAP_GET_SEQUENCE_SETUP, out s) != 0;
///
/// The capCaptureSequence macro initiates streaming video and audio capture to a file. You can use this macro or explicitly
/// send the WM_CAP_SEQUENCE message.
///
/// Handle to a capture window.
/// None
///
///
/// If you want to alter the parameters controlling streaming capture, use the capCaptureSetSetup macro prior to starting the capture.
///
///
/// By default, the capture window does not allow other applications to continue running during capture. To override this, either
/// set the fYield member of the CAPTUREPARMS structure to TRUE, or install a yield callback function.
///
///
/// During streaming capture, the capture window can optionally issue notifications to your application of specific types of
/// conditions. To install callback procedures for these notifications, use the following macros:
///
///
/// -
/// capSetCallbackOnError
///
/// -
/// capSetCallbackOnStatus
///
/// -
/// capSetCallbackOnVideoStream
///
/// -
/// capSetCallbackOnWaveStream
///
/// -
/// capSetCallbackOnYield
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesequence void capCaptureSequence( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSequence")]
public static bool capCaptureSequence(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_SEQUENCE);
///
/// The capCaptureSequenceNoFile macro initiates streaming video capture without writing data to a file. You can use this
/// macro or explicitly send the WM_CAP_SEQUENCE_NOFILE message.
///
/// Handle to a capture window.
/// None
///
///
/// This message is useful in conjunction with video stream or waveform-audio stream callback functions that let your application
/// use the video and audio data directly.
///
///
/// If you want to alter the parameters controlling streaming capture, use the capCaptureSetSetup macro prior to starting the capture.
///
///
/// By default, the capture window does not allow other applications to continue running during capture. To override this, either
/// set the fYield member of the CAPTUREPARMS structure to TRUE, or install a yield callback function.
///
///
/// During streaming capture, the capture window can optionally issue notifications to your application of specific types of
/// conditions. To install callback procedures for these notifications, use the following macros:
///
///
/// -
/// capSetCallbackOnError
///
/// -
/// capSetCallbackOnStatus
///
/// -
/// capSetCallbackOnVideoStream
///
/// -
/// capSetCallbackOnWaveStream
///
/// -
/// capSetCallbackOnYield
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesequencenofile void capCaptureSequenceNoFile( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSequenceNoFile")]
public static bool capCaptureSequenceNoFile(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_SEQUENCE_NOFILE);
///
/// The capCaptureSetSetup macro sets the configuration parameters used with streaming capture. You can use this macro or
/// explicitly send the WM_CAP_SET_SEQUENCE_SETUP message.
///
/// Handle to a capture window.
/// Pointer to a CAPTUREPARMS structure.
/// None
/// For information about the parameters used to control streaming capture, see the CAPTUREPARMS structure.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesetsetup void capCaptureSetSetup( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSetSetup")]
public static bool capCaptureSetSetup(HWND hwnd, in CAPTUREPARMS s) => AVICapSM(hwnd, capMessage.WM_CAP_SET_SEQUENCE_SETUP, -1, s) != 0;
///
/// The capCaptureSingleFrame macro appends a single frame to a capture file that was opened using the
/// capCaptureSingleFrameOpen macro. You can use this macro or explicitly send the WM_CAP_SINGLE_FRAME message.
///
/// Handle to a capture window.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesingleframe void capCaptureSingleFrame( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSingleFrame")]
public static bool capCaptureSingleFrame(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_SINGLE_FRAME);
///
/// The capCaptureSingleFrameClose macro closes the capture file opened by the capCaptureSingleFrameOpen macro. You can use
/// this macro or explicitly send the WM_CAP_SINGLE_FRAME_CLOSE message.
///
/// Handle to a capture window.
/// None
/// For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesingleframeclose void capCaptureSingleFrameClose( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSingleFrameClose")]
public static bool capCaptureSingleFrameClose(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_SINGLE_FRAME_CLOSE);
///
/// The capCaptureSingleFrameOpen macro opens the capture file for single-frame capturing. Any previous information in the
/// capture file is overwritten. You can use this macro or explicitly send the WM_CAP_SINGLE_FRAME_OPEN message.
///
/// Handle to a capture window.
/// None
/// For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturesingleframeopen void capCaptureSingleFrameOpen( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureSingleFrameOpen")]
public static bool capCaptureSingleFrameOpen(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_SINGLE_FRAME_OPEN);
///
///
/// The capCaptureStop macro stops the capture operation. You can use this macro or explicitly send the WM_CAP_STOP message.
///
///
/// In step frame capture, the image data that was collected before this message was sent is retained in the capture file. An
/// equivalent duration of audio data is also retained in the capture file if audio capture was enabled.
///
///
/// Handle to a capture window.
/// None
///
/// The capture operation must yield to use this message. Use the capCaptureAbort macro to abandon the current capture operation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcapturestop void capCaptureStop( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCaptureStop")]
public static bool capCaptureStop(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_STOP);
/// The capCreateCaptureWindow function creates a capture window.
/// Null-terminated string containing the name used for the capture window.
/// Window styles used for the capture window. Window styles are described with the CreateWindowEx function.
/// The x-coordinate of the upper left corner of the capture window.
/// The y-coordinate of the upper left corner of the capture window.
/// Width of the capture window.
/// Height of the capture window.
/// Handle to the parent window.
/// Window identifier.
/// Returns a handle of the capture window if successful or NULL otherwise.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capcreatecapturewindowa HWND VFWAPI capCreateCaptureWindowA( LPCSTR
// lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, int nID );
[DllImport(Lib_Avicap32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capCreateCaptureWindowA")]
public static extern HWND capCreateCaptureWindow([MarshalAs(UnmanagedType.LPTStr)] string lpszWindowName, User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, [In, Optional] HWND hwndParent, int nID);
///
/// The capDlgVideoCompression macro displays a dialog box in which the user can select a compressor to use during the
/// capture process. The list of available compressors can vary with the video format selected in the capture driver's Video Format
/// dialog box. You can use this macro or explicitly send the WM_CAP_DLG_VIDEOCOMPRESSION message.
///
/// Handle to a capture window.
/// None
///
///
/// Use this message with capture drivers that provide frames only in the BI_RGB format. This message is most useful in the step
/// capture operation to combine capture and compression in a single operation. Compressing frames with a software compressor as
/// part of a real-time capture operation is most likely too time-consuming to perform.
///
/// Compression does not affect the frames copied to the clipboard.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdlgvideocompression void capDlgVideoCompression( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDlgVideoCompression")]
public static bool capDlgVideoCompression(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_DLG_VIDEOCOMPRESSION);
///
/// The capDlgVideoDisplay macro displays a dialog box in which the user can set or adjust the video output. This dialog box
/// might contain controls that affect the hue, contrast, and brightness of the displayed image, as well as key color alignment. You
/// can use this macro or explicitly send the WM_CAP_DLG_VIDEODISPLAY message.
///
/// Handle to a capture window.
/// None
///
///
/// The controls in this dialog box do not affect digitized video data; they affect only the output or redisplay of the video signal.
///
///
/// The Video Display dialog box is unique for each capture driver. Some capture drivers might not support a Video Display dialog
/// box. Applications can determine if the capture driver supports this message by checking the fHasDlgVideoDisplay member of
/// the CAPDRIVERCAPS structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdlgvideodisplay void capDlgVideoDisplay( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDlgVideoDisplay")]
public static bool capDlgVideoDisplay(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_DLG_VIDEODISPLAY);
///
/// The capDlgVideoFormat macro displays a dialog box in which the user can select the video format. The Video Format dialog
/// box might be used to select image dimensions, bit depth, and hardware compression options. You can use this macro or explicitly
/// send the WM_CAP_DLG_VIDEOFORMAT message.
///
/// Handle to a capture window.
/// None
///
///
/// After this message returns, applications might need to update the CAPSTATUS structure because the user might have changed the
/// image dimensions.
///
///
/// The Video Format dialog box is unique for each capture driver. Some capture drivers might not support a Video Format dialog box.
/// Applications can determine if the capture driver supports this message by checking the fHasDlgVideoFormat member of CAPDRIVERCAPS.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdlgvideoformat void capDlgVideoFormat( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDlgVideoFormat")]
public static bool capDlgVideoFormat(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_DLG_VIDEOFORMAT);
///
/// The capDlgVideoSource macro displays a dialog box in which the user can control the video source. The Video Source dialog
/// box might contain controls that select input sources; alter the hue, contrast, brightness of the image; and modify the video
/// quality before digitizing the images into the frame buffer. You can use this macro or explicitly send the WM_CAP_DLG_VIDEOSOURCE message.
///
/// Handle to a capture window.
/// None
///
/// The Video Source dialog box is unique for each capture driver. Some capture drivers might not support a Video Source dialog box.
/// Applications can determine if the capture driver supports this message by checking the fHasDlgVideoSource member of the
/// CAPDRIVERCAPS structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdlgvideosource void capDlgVideoSource( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDlgVideoSource")]
public static bool capDlgVideoSource(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_DLG_VIDEOSOURCE);
///
/// The capDriverConnect macro connects a capture window to a capture driver. You can use this macro or explicitly send the
/// WM_CAP_DRIVER_CONNECT message.
///
/// Handle to a capture window.
/// Index of the capture driver. The index can range from 0 through 9.
/// None
/// Connecting a capture driver to a capture window automatically disconnects any previously connected capture driver.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdriverconnect void capDriverConnect( hwnd, i );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDriverConnect")]
public static bool capDriverConnect(HWND hwnd, int i) => AVICapSM(hwnd, capMessage.WM_CAP_DRIVER_CONNECT, (IntPtr)i);
///
/// The capDriverDisconnect macro disconnects a capture driver from a capture window. You can use this macro or explicitly
/// send the WM_CAP_DRIVER_DISCONNECT message.
///
/// Handle to a capture window.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdriverdisconnect void capDriverDisconnect( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDriverDisconnect")]
public static bool capDriverDisconnect(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_DRIVER_DISCONNECT);
///
/// The capDriverGetCaps macro returns the hardware capabilities of the capture driver currently connected to a capture
/// window. You can use this macro or explicitly send the WM_CAP_DRIVER_GET_CAPS message.
///
/// Handle to a capture window.
/// Pointer to the CAPDRIVERCAPS structure to contain the hardware capabilities.
/// None
///
/// The capabilities returned in CAPDRIVERCAPS are constant for a given capture driver. Applications need to retrieve this
/// information once when the capture driver is first connected to a capture window.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdrivergetcaps void capDriverGetCaps( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDriverGetCaps")]
public static bool capDriverGetCaps(HWND hwnd, out CAPDRIVERCAPS s) => AVICapSM(hwnd, capMessage.WM_CAP_DRIVER_GET_CAPS, out s) != 0;
///
/// The capDriverGetName macro returns the name of the capture driver connected to the capture window. You can use this macro
/// or explicitly call the WM_CAP_DRIVER_GET_NAME message.
///
/// Handle to a capture window.
/// Pointer to an application-defined buffer used to return the device name as a null-terminated string.
/// None
///
/// The name is a text string retrieved from the driver's resource area. Applications should allocate approximately 80 bytes for
/// this string. If the driver does not contain a name resource, the full path name of the driver listed in the registry or in the
/// SYSTEM.INI file is returned.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdrivergetname void capDriverGetName( hwnd, szName, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDriverGetName")]
public static bool capDriverGetName(HWND hwnd, StringBuilder szName) => AVICapSM(hwnd, capMessage.WM_CAP_DRIVER_GET_NAME, szName);
///
/// The capDriverGetVersion macro returns the version information of the capture driver connected to a capture window. You
/// can use this macro or explicitly send the WM_CAP_DRIVER_GET_VERSION message.
///
/// Handle to a capture window.
/// Pointer to an application-defined buffer used to return the version information as a null-terminated string.
/// None
///
/// The version information is a text string retrieved from the driver's resource area. Applications should allocate approximately
/// 40 bytes for this string. If version information is not available, a NULL string is returned.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capdrivergetversion void capDriverGetVersion( hwnd, szVer, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capDriverGetVersion")]
public static bool capDriverGetVersion(HWND hwnd, StringBuilder szVer) => AVICapSM(hwnd, capMessage.WM_CAP_DRIVER_GET_VERSION, szVer);
///
/// The capEditCopy macro copies the contents of the video frame buffer and associated palette to the clipboard. You can use
/// this macro or explicitly send the WM_CAP_EDIT_COPY message.
///
/// Handle to a capture window.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capeditcopy void capEditCopy( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capEditCopy")]
public static bool capEditCopy(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_EDIT_COPY);
///
/// The capFileAlloc macro creates (preallocates) a capture file of a specified size. You can use this macro or explicitly
/// send the WM_CAP_FILE_ALLOCATE message.
///
/// Handle to a capture window.
/// Size, in bytes, to create the capture file.
/// None
///
/// You can improve streaming capture performance significantly by preallocating a capture file large enough to store an entire
/// video clip and by defragmenting the capture file before capturing the clip.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilealloc void capFileAlloc( hwnd, dwSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileAlloc")]
public static bool capFileAlloc(HWND hwnd, int dwSize) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_ALLOCATE, (IntPtr)0, (IntPtr)dwSize);
///
/// The capFileGetCaptureFile macro returns the name of the current capture file. You can use this macro or explicitly call
/// the WM_CAP_FILE_GET_CAPTURE_FILE message.
///
/// Handle to a capture window.
///
/// Pointer to an application-defined buffer used to return the name of the capture file as a null-terminated string.
///
/// None
/// The default capture filename is C:\CAPTURE.AVI.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilegetcapturefile void capFileGetCaptureFile( hwnd, szName,
// wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileGetCaptureFile")]
public static bool capFileGetCaptureFile(HWND hwnd, StringBuilder szName) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_GET_CAPTURE_FILE, szName);
///
/// The capFileSaveAs macro copies the contents of the capture file to another file. You can use this macro or explicitly
/// call the WM_CAP_FILE_SAVEAS message.
///
/// Handle to a capture window.
///
/// Pointer to the null-terminated string that contains the name of the destination file used to copy the file.
///
/// None
///
/// This message does not change the name or contents of the current capture file.
/// If the copy operation is unsuccessful due to a disk full error, the destination file is automatically deleted.
///
/// Typically, a capture file is preallocated for the largest capture segment anticipated and only a portion of it might be used to
/// capture data. This message copies only the portion of the file containing the capture data.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilesaveas void capFileSaveAs( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileSaveAs")]
public static bool capFileSaveAs(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_SAVEAS, szName);
///
/// The capFileSaveDIB macro copies the current frame to a DIB file. You can use this macro or explicitly call the
/// WM_CAP_FILE_SAVEDIB message.
///
/// Handle to a capture window.
/// Pointer to the null-terminated string that contains the name of the destination DIB file.
/// None
///
/// If the capture driver supplies frames in a compressed format, this call attempts to decompress the frame before writing the file.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilesavedib void capFileSaveDIB( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileSaveDIB")]
public static bool capFileSaveDIB(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_SAVEDIB, szName);
///
/// The capFileSetCaptureFile macro names the file used for video capture. You can use this macro or explicitly call the
/// WM_CAP_FILE_SET_CAPTURE_FILE message.
///
/// Handle to a capture window.
/// Pointer to the null-terminated string that contains the name of the capture file to use.
/// None
///
/// This message stores the filename in an internal structure. It does not create, allocate, or open the specified file. The default
/// capture filename is C:\CAPTURE.AVI.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilesetcapturefile void capFileSetCaptureFile( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileSetCaptureFile")]
public static bool capFileSetCaptureFile(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_SET_CAPTURE_FILE, szName);
///
/// The capFileSetInfoChunk macro sets and clears information chunks. Information chunks can be inserted in an AVI file
/// during capture to embed text strings or custom data. You can use this macro or explicitly call the WM_CAP_FILE_SET_INFOCHUNK message.
///
/// Handle to a capture window.
/// Pointer to a CAPINFOCHUNK structure defining the information chunk to be created or deleted.
/// None
///
/// Multiple registered information chunks can be added to an AVI file. After an information chunk is set, it continues to be added
/// to subsequent capture files until either the entry is cleared or all information chunk entries are cleared. To clear a single
/// entry, specify the information chunk in the fccInfoID member and NULL in the lpData member of the
/// CAPINFOCHUNK structure. To clear all entries, specify NULL in fccInfoID.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capfilesetinfochunk void capFileSetInfoChunk( hwnd, lpInfoChunk );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capFileSetInfoChunk")]
public static bool capFileSetInfoChunk(HWND hwnd, out CAPINFOCHUNK lpInfoChunk) => AVICapSM(hwnd, capMessage.WM_CAP_FILE_SET_INFOCHUNK, out lpInfoChunk, 0) != 0;
///
/// The capGetAudioFormat macro obtains the audio format. You can use this macro or explicitly call the
/// WM_CAP_GET_AUDIOFORMAT message.
///
/// Handle to a capture window.
///
/// Pointer to a WAVEFORMATEX structure, or NULL. If the value is NULL, the size, in bytes, required to hold the
/// WAVEFORMATEX structure is returned.
///
/// Size, in bytes, of the structure referenced by s.
/// None
///
/// Because compressed audio formats vary in size requirements applications must first retrieve the size, then allocate memory, and
/// finally request the audio format data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetaudioformat void capGetAudioFormat( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetAudioFormat")]
public static int capGetAudioFormat(HWND hwnd, IntPtr s, int wSize) => User32.SendMessage(hwnd, capMessage.WM_CAP_GET_AUDIOFORMAT, (IntPtr)wSize, s).ToInt32();
///
/// The capGetAudioFormatSize macro obtains the size of the audio format. You can use this macro or explicitly call the
/// WM_CAP_GET_AUDIOFORMAT message.
///
/// Handle to a capture window.
/// None
///
/// Because compressed audio formats vary in size requirements applications must first retrieve the size, then allocate memory, and
/// finally request the audio format data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetaudioformatsize void capGetAudioFormatSize( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetAudioFormatSize")]
public static int capGetAudioFormatSize(HWND hwnd) => User32.SendMessage(hwnd, capMessage.WM_CAP_GET_AUDIOFORMAT).ToInt32();
/// The capGetDriverDescription function retrieves the version description of the capture driver.
///
/// Index of the capture driver. The index can range from 0 through 9.
///
/// Plug-and-Play capture drivers are enumerated first, followed by capture drivers listed in the registry, which are then followed
/// by capture drivers listed in SYSTEM.INI.
///
///
/// Pointer to a buffer containing a null-terminated string corresponding to the capture driver name.
/// Length, in bytes, of the buffer pointed to by lpszName.
///
/// Pointer to a buffer containing a null-terminated string corresponding to the description of the capture driver.
///
/// Length, in bytes, of the buffer pointed to by lpszVer.
/// Returns TRUE if successful or FALSE otherwise.
///
///
/// If the information description is longer than its buffer, the description is truncated. The returned string is always
/// null-terminated. If a buffer size is zero, its corresponding description is not copied.
///
///
/// Note
///
/// The vfw.h header defines capGetDriverDescription as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetdriverdescriptiona BOOL VFWAPI capGetDriverDescriptionA( UINT
// wDriverIndex, LPSTR lpszName, int cbName, LPSTR lpszVer, int cbVer );
[DllImport(Lib_Avicap32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetDriverDescriptionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool capGetDriverDescription(uint wDriverIndex, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszName, int cbName, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszVer, int cbVer);
///
/// The capGetMCIDeviceName macro retrieves the name of an MCI device previously set with the capSetMCIDeviceName macro. You
/// can use this macro or explicitly call the WM_CAP_GET_MCI_DEVICE message.
///
/// Handle to a capture window.
/// Pointer to a null-terminated string that contains the MCI device name.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetmcidevicename void capGetMCIDeviceName( hwnd, szName, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetMCIDeviceName")]
public static bool capGetMCIDeviceName(HWND hwnd, StringBuilder szName) => AVICapSM(hwnd, capMessage.WM_CAP_GET_MCI_DEVICE, szName);
///
/// The capGetStatus macro retrieves the status of the capture window. You can use this macro or explicitly call the
/// WM_CAP_GET_STATUS message.
///
/// Handle to a capture window.
/// Pointer to a CAPSTATUS structure.
/// None
///
/// The CAPSTATUS structure contains the current state of the capture window. Since this state is dynamic and changes in response to
/// various messages, the application should initialize this structure after sending the capDlgVideoFormat macro and whenever it
/// needs to enable menu items or determine the actual state of the window.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetstatus void capGetStatus( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetStatus")]
public static bool capGetStatus(HWND hwnd, out CAPSTATUS s) => AVICapSM(hwnd, capMessage.WM_CAP_GET_STATUS, out s) != 0;
///
/// The capGetUserData macro retrieves a LONG_PTR data value associated with a capture window. You can use this macro
/// or explicitly call the WM_CAP_GET_USER_DATA message.
///
/// Handle to a capture window.
/// Returns a value previously saved by using the WM_CAP_SET_USER_DATA message.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetuserdata void capGetUserData( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetUserData")]
public static IntPtr capGetUserData(HWND hwnd) => User32.SendMessage(hwnd, capMessage.WM_CAP_GET_USER_DATA);
///
/// The capGetVideoFormat macro retrieves a copy of the video format in use. You can use this macro or explicitly call the
/// WM_CAP_GET_VIDEOFORMAT message.
///
/// Handle to a capture window.
///
/// Pointer to a BITMAPINFO structure. You can also specify NULL to retrieve the number of bytes needed by BITMAPINFO.
///
/// None
///
/// Because compressed video formats vary in size requirements applications must first retrieve the size, then allocate memory, and
/// finally request the video format data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetvideoformat void capGetVideoFormat( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetVideoFormat")]
public static int capGetVideoFormat(HWND hwnd, [Out] Gdi32.SafeBITMAPINFO s) => User32.SendMessage(hwnd, capMessage.WM_CAP_GET_VIDEOFORMAT, (IntPtr)(int)s.Size, s.DangerousGetHandle()).ToInt32();
///
/// The capGetVideoFormatSize macro retrieves the size required for the video format. You can use this macro or explicitly
/// call the WM_CAP_GET_VIDEOFORMAT message.
///
/// Handle to a capture window.
/// None
///
/// Because compressed video formats vary in size requirements applications must first retrieve the size, then allocate memory, and
/// finally request the video format data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgetvideoformatsize void capGetVideoFormatSize( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGetVideoFormatSize")]
public static int capGetVideoFormatSize(HWND hwnd) => User32.SendMessage(hwnd, capMessage.WM_CAP_GET_VIDEOFORMAT).ToInt32();
///
/// The capGrabFrame macro retrieves and displays a single frame from the capture driver. After capture, overlay and preview
/// are disabled. You can use this macro or explicitly call the WM_CAP_GRAB_FRAME message.
///
/// Handle to a capture window.
/// None
/// For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgrabframe void capGrabFrame( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGrabFrame")]
public static bool capGrabFrame(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_GRAB_FRAME);
///
/// The capGrabFrameNoStop macro fills the frame buffer with a single uncompressed frame from the capture device and displays
/// it. Unlike with the capGrabFrame macro, the state of overlay or preview is not altered by this message. You can use this macro
/// or explicitly call the WM_CAP_GRAB_FRAME_NOSTOP message.
///
/// Handle to a capture window.
/// None
///
/// For information about installing callback functions, see the capSetCallbackOnError and capSetCallbackOnFrame macros.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capgrabframenostop void capGrabFrameNoStop( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capGrabFrameNoStop")]
public static bool capGrabFrameNoStop(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_GRAB_FRAME_NOSTOP);
///
/// The capOverlay macro enables or disables overlay mode. In overlay mode, video is displayed using hardware overlay. You
/// can use this macro or explicitly call the WM_CAP_SET_OVERLAY message.
///
/// Handle to a capture window.
/// Overlay flag. Specify TRUE for this parameter to enable overlay mode or FALSE to disable it.
/// None
///
/// Using an overlay does not require CPU resources.
///
/// The fHasOverlay member of the CAPDRIVERCAPS structure indicates whether the device is capable of overlay. The
/// fOverlayWindow member of the CAPSTATUS structure indicates whether overlay mode is currently enabled.
///
/// Enabling overlay mode automatically disables preview mode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capoverlay void capOverlay( hwnd, f );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capOverlay")]
public static bool capOverlay(HWND hwnd, bool f) => AVICapSM(hwnd, capMessage.WM_CAP_SET_OVERLAY, (IntPtr)(f ? 1 : 0));
///
/// The capPaletteAuto macro requests that the capture driver sample video frames and automatically create a new palette. You
/// can use this macro or explicitly call the WM_CAP_PAL_AUTOCREATE message.
///
/// Handle to a capture window.
/// Number of frames to sample.
/// Number of colors in the palette. The maximum value for this parameter is 256.
/// None
///
/// The sampled video sequence should include all the colors you want in the palette. To obtain the best palette, you might have to
/// sample the whole sequence rather than a portion of it.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappaletteauto void capPaletteAuto( hwnd, iFrames, iColors );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPaletteAuto")]
public static bool capPaletteAuto(HWND hwnd, int iFrames, int iColors) => AVICapSM(hwnd, capMessage.WM_CAP_PAL_AUTOCREATE, (IntPtr)iFrames, (IntPtr)iColors);
///
/// The capPaletteManual macro requests that the capture driver manually sample video frames and create a new palette. You
/// can use this macro or explicitly call the WM_CAP_PAL_MANUALCREATE message.
///
/// Handle to a capture window.
///
/// Palette histogram flag. Set this parameter to TRUE for each frame included in creating the optimal palette. After the
/// last frame has been collected, set this parameter to FALSE to calculate the optimal palette and send it to the capture driver.
///
///
/// Number of colors in the palette. The maximum value for this parameter is 256. This value is used only during collection of the
/// first frame in a sequence.
///
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappalettemanual void capPaletteManual( hwnd, fGrab, iColors );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPaletteManual")]
public static bool capPaletteManual(HWND hwnd, bool fGrab, int iColors) => AVICapSM(hwnd, capMessage.WM_CAP_PAL_MANUALCREATE, (IntPtr)(fGrab ? 1 : 0), (IntPtr)iColors);
///
/// The capPaletteOpen macro loads a new palette from a palette file and passes it to a capture driver. Palette files
/// typically use the filename extension .PAL. A capture driver uses a palette when required by the specified digitized image
/// format. You can use this macro or explicitly call the WM_CAP_PAL_OPEN message.
///
/// Handle to a capture window.
/// Pointer to a null-terminated string containing the palette filename.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappaletteopen void capPaletteOpen( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPaletteOpen")]
public static bool capPaletteOpen(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_PAL_OPEN, szName);
///
/// The capPalettePaste macro copies the palette from the clipboard and passes it to a capture driver. You can use this macro
/// or explicitly call the WM_CAP_PAL_PASTE message.
///
/// Handle to a capture window.
/// None
/// A capture driver uses a palette when required by the specified digitized video format.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappalettepaste void capPalettePaste( hwnd );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPalettePaste")]
public static bool capPalettePaste(HWND hwnd) => AVICapSM(hwnd, capMessage.WM_CAP_PAL_PASTE);
///
/// The capPaletteSave macro saves the current palette to a palette file. Palette files typically use the filename extension
/// .PAL. You can use this macro or explicitly send the WM_CAP_PAL_SAVE message.
///
/// Handle to a capture window.
/// Pointer to a null-terminated string containing the palette filename.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappalettesave void capPaletteSave( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPaletteSave")]
public static bool capPaletteSave(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_PAL_SAVE, szName);
///
/// The capPreview macro enables or disables preview mode. In preview mode, frames are transferred from the capture hardware
/// to system memory and then displayed in the capture window using GDI functions. You can use this macro or explicitly call the
/// WM_CAP_SET_PREVIEW message.
///
/// Handle to a capture window.
/// Preview flag. Specify TRUE for this parameter to enable preview mode or FALSE to disable it.
/// None
///
///
/// The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another
/// application has the focus. The fLiveWindow member of the CAPSTATUS structure indicates if preview mode is currently enabled.
///
/// Enabling preview mode automatically disables overlay mode.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappreview void capPreview( hwnd, f );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPreview")]
public static bool capPreview(HWND hwnd, bool f) => AVICapSM(hwnd, capMessage.WM_CAP_SET_PREVIEW, (IntPtr)(f ? 1 : 0));
///
/// The capPreviewRate macro sets the frame display rate in preview mode. You can use this macro or explicitly call the
/// WM_CAP_SET_PREVIEWRATE message.
///
/// Handle to a capture window.
/// Rate, in milliseconds, at which new frames are captured and displayed.
/// None
///
/// The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another
/// application has the focus. During streaming video capture, the previewing task is lower priority than writing frames to disk,
/// and preview frames are displayed only if no other buffers are available for writing.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappreviewrate void capPreviewRate( hwnd, wMS );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPreviewRate")]
public static bool capPreviewRate(HWND hwnd, int wMS) => AVICapSM(hwnd, capMessage.WM_CAP_SET_PREVIEWRATE, (IntPtr)wMS);
///
/// The capPreviewScale macro enables or disables scaling of the preview video images. If scaling is enabled, the captured
/// video frame is stretched to the dimensions of the capture window. You can use this macro or explicitly call the WM_CAP_SET_SCALE message.
///
/// Handle to a capture window.
///
/// Preview scaling flag. Specify TRUE for this parameter to stretch preview frames to the size of the capture window or
/// FALSE to display them at their natural size.
///
/// None
///
///
/// Scaling preview images controls the immediate presentation of captured frames within the capture window. It has no effect on the
/// size of the frames saved to file.
///
/// Scaling has no effect when using overlay to display video in the frame buffer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-cappreviewscale void capPreviewScale( hwnd, f );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capPreviewScale")]
public static bool capPreviewScale(HWND hwnd, bool f) => AVICapSM(hwnd, capMessage.WM_CAP_SET_SCALE, (IntPtr)(f ? 1 : 0));
///
/// The capSetAudioFormat macro sets the audio format to use when performing streaming or step capture. You can use this
/// macro or explicitly call the WM_CAP_SET_AUDIOFORMAT message.
///
/// Handle to a capture window.
/// Pointer to a WAVEFORMATEX or PCMWAVEFORMAT structure that defines the audio format.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetaudioformat void capSetAudioFormat( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetAudioFormat")]
public static bool capSetAudioFormat(HWND hwnd, in WAVEFORMATEX s) => AVICapSM(hwnd, capMessage.WM_CAP_SET_AUDIOFORMAT, -1, s) != 0;
///
/// The capSetAudioFormat macro sets the audio format to use when performing streaming or step capture. You can use this
/// macro or explicitly call the WM_CAP_SET_AUDIOFORMAT message.
///
/// Handle to a capture window.
/// Pointer to a WAVEFORMATEX or PCMWAVEFORMAT structure that defines the audio format.
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetaudioformat void capSetAudioFormat( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetAudioFormat")]
public static bool capSetAudioFormat(HWND hwnd, in PCMWAVEFORMAT s) => AVICapSM(hwnd, capMessage.WM_CAP_SET_AUDIOFORMAT, -1, s) != 0;
///
/// The capSetCallbackOnCapControl macro sets a callback function in the application giving it precise recording control. You
/// can use this macro or explicitly call the WM_CAP_SET_CALLBACK_CAPCONTROL message.
///
/// Handle to a capture window.
///
/// Pointer to the callback function, of type capControlCallback . Specify NULL for this parameter to disable a previously
/// installed callback function.
///
/// None
///
/// A single callback function is used to give the application precise control over the moments that streaming capture begins and
/// completes. The capture window first calls the procedure with nState set to CONTROLCALLBACK_PREROLL after all buffers have been
/// allocated and all other capture preparations have finished. This gives the application the ability to preroll video sources,
/// returning from the callback function at the exact moment recording is to begin. A return value of TRUE from the callback
/// function continues capture, and a return value of FALSE aborts capture. After capture begins, this callback function will
/// be called frequently with nState set to CONTROLCALLBACK_CAPTURING to allow the application to end capture by returning FALSE.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackoncapcontrol void capSetCallbackOnCapControl( hwnd,
// fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnCapControl")]
public static bool capSetCallbackOnCapControl(HWND hwnd, [Optional] capControlCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_CAPCONTROL, 0, fpProc);
///
/// The capSetCallbackOnError macro sets an error callback function in the client application. AVICap calls this procedure
/// when errors occur. You can use this macro or explicitly call the WM_CAP_SET_CALLBACK_ERROR message.
///
/// Handle to a capture window.
///
/// Pointer to the error callback function, of type capErrorCallback. Specify NULL for this parameter to disable a previously
/// installed error callback function.
///
/// None
///
///
/// Applications can optionally set an error callback function. If set, AVICap calls the error procedure in the following situations:
///
///
/// -
/// The disk is full.
///
/// -
/// A capture window cannot be connected with a capture driver.
///
/// -
/// A waveform-audio device cannot be opened.
///
/// -
/// The number of frames dropped during capture exceeds the specified percentage.
///
/// -
/// The frames cannot be captured due to vertical synchronization interrupt problems.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonerror void capSetCallbackOnError( hwnd, fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnError")]
public static bool capSetCallbackOnError(HWND hwnd, [Optional] capErrorCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_ERROR, 0, fpProc);
///
/// The capSetCallbackOnFrame macro sets a preview callback function in the application. AVICap calls this procedure when the
/// capture window captures preview frames. You can use this macro or explicitly call the WM_CAP_SET_CALLBACK_FRAME message.
///
/// Handle to a capture window.
///
/// Pointer to the preview callback function, of type capVideoStreamCallback. Specify NULL for this parameter to disable a
/// previously installed callback function.
///
/// None
///
/// The capture window calls the callback function before displaying preview frames. This allows an application to modify the frame
/// if desired. This callback function is not used during streaming video capture.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonframe void capSetCallbackOnFrame( hwnd, fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnFrame")]
public static bool capSetCallbackOnFrame(HWND hwnd, capVideoStreamCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_FRAME, 0, fpProc);
///
/// The capSetCallbackOnStatus macro sets a status callback function in the application. AVICap calls this procedure whenever
/// the capture window status changes. You can use this macro or explicitly call the WM_CAP_SET_CALLBACK_STATUS message.
///
/// Handle to a capture window.
///
/// Pointer to the status callback function, of type capStatusCallback. Specify NULL for this parameter to disable a
/// previously installed status callback function.
///
/// None
///
/// Applications can optionally set a status callback function. If set, AVICap calls this procedure in the following situations:
///
/// -
/// A capture session is completed.
///
/// -
/// A capture driver successfully connected to a capture window.
///
/// -
/// An optimal palette is created.
///
/// -
/// The number of captured frames is reported.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonstatus void capSetCallbackOnStatus( hwnd, fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnStatus")]
public static bool capSetCallbackOnStatus(HWND hwnd, [Optional] capStatusCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_STATUS, 0, fpProc);
///
/// The capSetCallbackOnVideoStream macro sets a callback function in the application. AVICap calls this procedure during
/// streaming capture when a video buffer is filled. You can use this macro or explicitly call the WM_CAP_SET_CALLBACK_VIDEOSTREAM message.
///
/// Handle to a capture window.
///
/// Pointer to the video-stream callback function, of type capVideoStreamCallback. Specify NULL for this parameter to disable
/// a previously installed video-stream callback function.
///
/// None
///
///
/// The capture window calls the callback function before writing the captured frame to disk. This allows applications to modify the
/// frame if desired.
///
///
/// If a video stream callback function is used for streaming capture, the procedure must be installed before starting the capture
/// session and it must remain enabled for the duration of the session. It can be disabled after streaming capture ends.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonvideostream void capSetCallbackOnVideoStream( hwnd,
// fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnVideoStream")]
public static bool capSetCallbackOnVideoStream(HWND hwnd, [Optional] capVideoStreamCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, fpProc);
///
/// The capSetCallbackOnWaveStream macro sets a callback function in the application. AVICap calls this procedure during
/// streaming capture when a new audio buffer becomes available. You can use this macro or explicitly call the
/// WM_CAP_SET_CALLBACK_WAVESTREAM message.
///
/// Handle to a capture window.
///
/// Pointer to the wave stream callback function, of type capWaveStreamCallback. Specify NULL for this parameter to disable a
/// previously installed wave stream callback function.
///
/// None
///
///
/// The capture window calls the procedure before writing the audio buffer to disk. This allows applications to modify the audio
/// buffer if desired.
///
///
/// If a wave stream callback function is used, it must be installed before starting the capture session and it must remain enabled
/// for the duration of the session. It can be disabled after streaming capture ends.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonwavestream void capSetCallbackOnWaveStream( hwnd,
// fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnWaveStream")]
public static bool capSetCallbackOnWaveStream(HWND hwnd, [Optional] capWaveStreamCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_WAVESTREAM, 0, fpProc);
///
/// The capSetCallbackOnYield macro sets a callback function in the application. AVICap calls this procedure when the capture
/// window yields during streaming capture. You can use this macro or explicitly call the WM_CAP_SET_CALLBACK_YIELD message.
///
/// Handle to a capture window.
///
/// Pointer to the yield callback function, of type capYieldCallback. Specify NULL for this parameter to disable a previously
/// installed yield callback function.
///
/// None
///
///
/// Applications can optionally set a yield callback function. The yield callback function is called at least once for each video
/// frame captured during streaming capture. If a yield callback function is installed, it will be called regardless of the state of
/// the fYield member of the CAPTUREPARMS structure.
///
///
/// If the yield callback function is used, it must be installed before starting the capture session and it must remain enabled for
/// the duration of the session. It can be disabled after streaming capture ends.
///
///
/// Applications typically perform some type of message processing in the callback function consisting of a PeekMessage,
/// TranslateMessage, DispatchMessage loop, as in the message loop of a WinMain function. The yield callback function must also
/// filter and remove messages that can cause reentrancy problems.
///
///
/// An application typically returns TRUE in the yield procedure to continue streaming capture. If a yield callback function
/// returns FALSE, the capture window stops the capture process.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetcallbackonyield void capSetCallbackOnYield( hwnd, fpProc );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetCallbackOnYield")]
public static bool capSetCallbackOnYield(HWND hwnd, [Optional] capYieldCallback fpProc) => AVICapSM(hwnd, capMessage.WM_CAP_SET_CALLBACK_YIELD, 0, fpProc);
///
/// The capSetMCIDeviceName macro specifies the name of the MCI video device to be used to capture data. You can use this
/// macro or explicitly call the WM_CAP_SET_MCI_DEVICE message.
///
/// Handle to a capture window.
/// Pointer to a null-terminated string containing the name of the device.
/// None
///
/// This message stores the MCI device name in an internal structure. It does not open or access the device. The default device name
/// is NULL.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetmcidevicename void capSetMCIDeviceName( hwnd, szName );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetMCIDeviceName")]
public static bool capSetMCIDeviceName(HWND hwnd, string szName) => AVICapSM(hwnd, capMessage.WM_CAP_SET_MCI_DEVICE, szName);
///
/// The capSetScrollPos macro defines the portion of the video frame to display in the capture window. This message sets the
/// upper left corner of the client area of the capture window to the coordinates of a specified pixel within the video frame. You
/// can use this macro or explicitly call the WM_CAP_SET_SCROLL message.
///
/// Handle to a capture window.
/// Address to contain the desired scroll position.
/// None
/// The scroll position affects the image in both preview and overlay modes.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetscrollpos void capSetScrollPos( hwnd, lpP );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetScrollPos")]
public static bool capSetScrollPos(HWND hwnd, System.Drawing.Point lpP) => AVICapSM(hwnd, capMessage.WM_CAP_SET_SCROLL, 0, lpP) != 0;
///
/// The capSetUserData macro associates a LONG_PTR data value with a capture window. You can use this macro or
/// explicitly call the WM_CAP_SET_USER_DATA message.
///
/// Handle to a capture window.
/// Data value to associate with a capture window.
/// None
/// Typically this message is used to point to a block of data associated with a capture window.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetuserdata void capSetUserData( hwnd, lUser );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetUserData")]
public static bool capSetUserData(HWND hwnd, IntPtr lUser) => AVICapSM(hwnd, capMessage.WM_CAP_SET_USER_DATA, default, lUser);
///
/// The capSetVideoFormat macro sets the format of captured video data. You can use this macro or explicitly call the
/// WM_CAP_SET_VIDEOFORMAT message.
///
/// Handle to a capture window.
/// Pointer to a BITMAPINFO structure.
/// None
///
/// Because video formats are device-specific, applications should check the return value from this function to determine if the
/// format is accepted by the driver.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-capsetvideoformat void capSetVideoFormat( hwnd, s, wSize );
[PInvokeData("vfw.h", MSDNShortId = "NF:vfw.capSetVideoFormat")]
public static bool capSetVideoFormat(HWND hwnd, [In] Gdi32.SafeBITMAPINFO s) => AVICapSM(hwnd, capMessage.WM_CAP_SET_VIDEOFORMAT, (IntPtr)(int)s.Size, s.DangerousGetHandle());
private static bool AVICapSM(HWND hwnd, capMessage msg, int v, Delegate d) => User32.SendMessage(hwnd, unchecked((uint)msg), (IntPtr)v, Marshal.GetFunctionPointerForDelegate(d)) != IntPtr.Zero;
private static bool AVICapSM(HWND hwnd, capMessage msg, [Optional] IntPtr wparam, [Optional] IntPtr lparam) => User32.SendMessage(hwnd, unchecked((uint)msg), wparam, lparam) != IntPtr.Zero;
private static bool AVICapSM(HWND hwnd, capMessage msg, StringBuilder lparam) => User32.SendMessage(hwnd, unchecked((uint)msg), (IntPtr)(lparam?.Capacity ?? 0), lparam) != IntPtr.Zero;
private static int AVICapSM(HWND hwnd, capMessage msg, int size, in TLP lparam) where TLP : struct
{
TLP res = lparam;
return User32.SendMessage(hwnd, msg, (IntPtr)(size == -1 ? Marshal.SizeOf(typeof(TLP)) : size), ref res).ToInt32();
}
private static int AVICapSM(HWND hwnd, capMessage msg, out TLP lparam, int size = -1) where TLP : struct
{
TLP res = default;
var ret = User32.SendMessage(hwnd, msg, (IntPtr)(size == -1 ? Marshal.SizeOf(typeof(TLP)) : size), ref res).ToInt32();
lparam = res;
return ret;
}
private static bool AVICapSM(HWND hwnd, capMessage msg, string lparam) => User32.SendMessage(hwnd, unchecked((uint)msg), default, lparam) != IntPtr.Zero;
///
/// The CAPDRIVERCAPS structure defines the capabilities of the capture driver.
///
/// An application should use the WM_CAP_DRIVER_GET_CAPS message or capDriverGetCaps macro to place a copy of the driver
/// capabilities in a CAPDRIVERCAPS structure whenever the application connects a capture window to a capture driver.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-capdrivercaps typedef struct tagCapDriverCaps { UINT wDeviceIndex;
// BOOL fHasOverlay; BOOL fHasDlgVideoSource; BOOL fHasDlgVideoFormat; BOOL fHasDlgVideoDisplay; BOOL fCaptureInitialized; BOOL
// fDriverSuppliesPalettes; HANDLE hVideoIn; HANDLE hVideoOut; HANDLE hVideoExtIn; HANDLE hVideoExtOut; } CAPDRIVERCAPS,
// *PCAPDRIVERCAPS, *LPCAPDRIVERCAPS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.tagCapDriverCaps")]
[StructLayout(LayoutKind.Sequential)]
public struct CAPDRIVERCAPS
{
/// Index of the capture driver. An index value can range from 0 to 9.
public uint wDeviceIndex;
/// Video-overlay flag. The value of this member is TRUE if the device supports video overlay.
[MarshalAs(UnmanagedType.Bool)]
public bool fHasOverlay;
///
/// Video source dialog flag. The value of this member is TRUE if the device supports a dialog box for selecting and
/// controlling the video source.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoSource;
///
/// Video format dialog flag. The value of this member is TRUE if the device supports a dialog box for selecting the
/// video format.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoFormat;
///
/// Video display dialog flag. The value of this member is TRUE if the device supports a dialog box for controlling the
/// redisplay of video from the capture frame buffer.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoDisplay;
///
/// Capture initialization flag. The value of this member is TRUE if a capture device has been successfully connected.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fCaptureInitialized;
/// Driver palette flag. The value of this member is TRUE if the driver can create palettes.
[MarshalAs(UnmanagedType.Bool)]
public bool fDriverSuppliesPalettes;
/// Not used in Win32 applications.
public HANDLE hVideoIn;
/// Not used in Win32 applications.
public HANDLE hVideoOut;
/// Not used in Win32 applications.
public HANDLE hVideoExtIn;
/// Not used in Win32 applications.
public HANDLE hVideoExtOut;
}
///
/// The CAPINFOCHUNK structure contains parameters that can be used to define an information chunk within an AVI capture
/// file. The WM_CAP_FILE_SET_INFOCHUNK message or capSetInfoChunk macro is used to send a CAPINFOCHUNK structure to a
/// capture window.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-capinfochunk typedef struct tagCapInfoChunk { FOURCC fccInfoID;
// LPVOID lpData; LONG cbData; } CAPINFOCHUNK, *PCAPINFOCHUNK, *LPCAPINFOCHUNK;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.tagCapInfoChunk")]
[StructLayout(LayoutKind.Sequential)]
public struct CAPINFOCHUNK
{
///
/// Four-character code that identifies the representation of the chunk data. If this value is NULL and lpData is
/// NULL, all accumulated information chunks are deleted.
///
public uint fccInfoID;
/// Pointer to the data. If this value is NULL, all fccInfoID information chunks are deleted.
public IntPtr lpData;
///
/// Size, in bytes, of the data pointed to by lpData. If lpData specifies a null-terminated string, use the string
/// length incremented by one to save the NULL with the string.
///
public int cbData;
}
/// The CAPSTATUS structure defines the current state of the capture window.
///
/// Because the state of a capture window changes in response to various messages, an application should update the information in
/// this structure whenever it needs to enable menu items, determine the actual state of the capture window, or call the video
/// format dialog box. If the application yields during streaming capture, this structure returns the progress of the capture in the
/// dwCurrentVideoFrame, dwCurrentVideoFramesDropped, dwCurre ntWaveSamples, and dwCurrentTimeElapsedMS
/// members. Use the WM_CAP_GET_STATUS message or capGetStatus macro to update the contents of this structure.
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-capstatus typedef struct tagCapStatus { UINT uiImageWidth; UINT
// uiImageHeight; BOOL fLiveWindow; BOOL fOverlayWindow; BOOL fScale; POINT ptScroll; BOOL fUsingDefaultPalette; BOOL
// fAudioHardware; BOOL fCapFileExists; DWORD dwCurrentVideoFrame; DWORD dwCurrentVideoFramesDropped; DWORD dwCurrentWaveSamples;
// DWORD dwCurrentTimeElapsedMS; HPALETTE hPalCurrent; BOOL fCapturingNow; DWORD dwReturn; UINT wNumVideoAllocated; UINT
// wNumAudioAllocated; } CAPSTATUS, *PCAPSTATUS, *LPCAPSTATUS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.tagCapStatus")]
[StructLayout(LayoutKind.Sequential)]
public struct CAPSTATUS
{
/// Image width, in pixels.
public uint uiImageWidth;
/// Image height, in pixels
public uint uiImageHeight;
///
/// Live window flag. The value of this member is TRUE if the window is displaying video using the preview method.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fLiveWindow;
///
/// Overlay window flag. The value of this member is TRUE if the window is displaying video using hardware overlay.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fOverlayWindow;
///
/// Input scaling flag. The value of this member is TRUE if the window is scaling the input video to the client area when
/// displaying video using preview. This parameter has no effect when displaying video using overlay.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fScale;
/// The x- and y-offset of the pixel displayed in the upper left corner of the client area of the window.
public System.Drawing.Point ptScroll;
/// Default palette flag. The value of this member is TRUE if the capture driver is using its default palette.
[MarshalAs(UnmanagedType.Bool)]
public bool fUsingDefaultPalette;
/// Audio hardware flag. The value of this member is TRUE if the system has waveform-audio hardware installed.
[MarshalAs(UnmanagedType.Bool)]
public bool fAudioHardware;
/// Capture file flag. The value of this member is TRUE if a valid capture file has been generated.
[MarshalAs(UnmanagedType.Bool)]
public bool fCapFileExists;
///
/// Number of frames processed during the current (or most recent) streaming capture. This count includes dropped frames.
///
public uint dwCurrentVideoFrame;
///
/// Number of frames dropped during the current (or most recent) streaming capture. Dropped frames occur when the capture rate
/// exceeds the rate at which frames can be saved to file. In this case, the capture driver has no buffers available for storing
/// data. Dropping frames does not affect synchronization because the previous frame is displayed in place of the dropped frame.
///
public uint dwCurrentVideoFramesDropped;
/// Number of waveform-audio samples processed during the current (or most recent) streaming capture.
public uint dwCurrentWaveSamples;
/// Time, in milliseconds, since the start of the current (or most recent) streaming capture.
public uint dwCurrentTimeElapsedMS;
/// Handle to current palette.
public HPALETTE hPalCurrent;
/// Capturing flag. The value of this member is TRUE when capturing is in progress.
[MarshalAs(UnmanagedType.Bool)]
public bool fCapturingNow;
/// Error return values. Use this member if your application does not support an error callback function.
public uint dwReturn;
///
/// Number of video buffers allocated. This value might be less than the number specified in the wNumVideoRequested
/// member of the CAPTUREPARMS structure.
///
public uint wNumVideoAllocated;
///
/// Number of audio buffers allocated. This value might be less than the number specified in the wNumAudioRequested
/// member of the CAPTUREPARMS structure.
///
public uint wNumAudioAllocated;
}
///
/// The CAPTUREPARMS structure contains parameters that control the streaming video capture process. This structure is used
/// to get and set parameters that affect the capture rate, the number of buffers to use while capturing, and how capture is terminated.
///
///
///
/// The WM_CAP_GET_SEQUENCE_SETUP message or capCaptureGetSetup macro is used to retrieve the current capture parameters. The
/// WM_CAP_SET_SEQUENCE_SETUP message or capCaptureSetSetup macro is used to set the capture parameters.
///
///
/// The WM_CAP_GET_SEQUENCE_SETUP message or capCaptureGetSetup macro is used to retrieve the current capture parameters. The
/// WM_CAP_SET_SEQUENCE_SETUP message or capCaptureSetSetup macro is used to set the capture parameters.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-captureparms typedef struct tagCaptureParms { DWORD
// dwRequestMicroSecPerFrame; BOOL fMakeUserHitOKToCapture; UINT wPercentDropForError; BOOL fYield; DWORD dwIndexSize; UINT
// wChunkGranularity; BOOL fUsingDOSMemory; UINT wNumVideoRequested; BOOL fCaptureAudio; UINT wNumAudioRequested; UINT vKeyAbort;
// BOOL fAbortLeftMouse; BOOL fAbortRightMouse; BOOL fLimitEnabled; UINT wTimeLimit; BOOL fMCIControl; BOOL fStepMCIDevice; DWORD
// dwMCIStartTime; DWORD dwMCIStopTime; BOOL fStepCaptureAt2x; UINT wStepCaptureAverageFrames; DWORD dwAudioBufferSize; BOOL
// fDisableWriteCache; UINT AVStreamMaster; } CAPTUREPARMS, *PCAPTUREPARMS, *LPCAPTUREPARMS;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.tagCaptureParms")]
[StructLayout(LayoutKind.Sequential)]
public struct CAPTUREPARMS
{
/// Requested frame rate, in microseconds. The default value is 66667, which corresponds to 15 frames per second.
public uint dwRequestMicroSecPerFrame;
///
/// User-initiated capture flag. If this member is TRUE, AVICap displays a dialog box prompting the user to initiate
/// capture. The default value is FALSE.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fMakeUserHitOKToCapture;
///
/// Maximum allowable percentage of dropped frames during capture. Values range from 0 to 100. The default value is 10.
///
public uint wPercentDropForError;
///
///
/// Yield flag. If this member is TRUE, the capture window spawns a separate background thread to perform step and
/// streaming capture. The default value is FALSE.
///
///
/// Applications that set this flag must handle potential reentry issues because the controls in the application are not
/// disabled while capture is in progress.
///
///
[MarshalAs(UnmanagedType.Bool)]
public bool fYield;
///
///
/// Maximum number of index entries in an AVI file. Values range from 1800 to 324,000. If set to 0, a default value of 34,952
/// (32K frames plus a proportional number of audio buffers) is used.
///
///
/// Each video frame or buffer of waveform-audio data uses one index entry. The value of this entry establishes a limit for the
/// number of frames or audio buffers that can be captured.
///
///
public uint dwIndexSize;
/// Logical block size, in bytes, of an AVI file. The value 0 indicates the current sector size is used as the granularity.
public uint wChunkGranularity;
/// Not used in Win32 applications.
[MarshalAs(UnmanagedType.Bool)]
public bool fUsingDOSMemory;
///
/// Maximum number of video buffers to allocate. The memory area to place the buffers is specified with fUsingDOSMemory.
/// The actual number of buffers allocated might be lower if memory is unavailable.
///
public uint wNumVideoRequested;
///
/// Capture audio flag. If this member is TRUE, audio is captured during streaming capture. This is the default value if
/// audio hardware is installed.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fCaptureAudio;
/// Maximum number of audio buffers to allocate. The maximum number of buffers is 10.
public uint wNumAudioRequested;
///
///
/// Virtual keycode used to terminate streaming capture. The default value is VK_ESCAPE. You must call the RegisterHotKey
/// function before specifying a keystroke that can abort a capture session.
///
///
/// You can combine keycodes that include CTRL and SHIFT keystrokes by using the logical OR operator with the keycodes for CTRL
/// (0x8000) and SHIFT (0x4000).
///
///
public uint vKeyAbort;
///
/// Abort flag for left mouse button. If this member is TRUE, streaming capture stops if the left mouse button is
/// pressed. The default value is TRUE.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fAbortLeftMouse;
///
/// Abort flag for right mouse button. If this member is TRUE, streaming capture stops if the right mouse button is
/// pressed. The default value is TRUE.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fAbortRightMouse;
///
/// Time limit enabled flag. If this member is TRUE, streaming capture stops after the number of seconds in
/// wTimeLimit has elapsed. The default value is FALSE.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fLimitEnabled;
/// Time limit for capture, in seconds. This parameter is used only if fLimitEnabled is TRUE.
public uint wTimeLimit;
///
/// MCI device capture flag. If this member is TRUE, AVICap controls an MCI-compatible video source during streaming
/// capture. MCI-compatible video sources include VCRs and laserdiscs.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fMCIControl;
///
/// MCI device step capture flag. If this member is TRUE, step capture using an MCI device as a video source is enabled.
/// If it is FALSE, real-time capture using an MCI device is enabled. (If fMCIControl is FALSE, this member
/// is ignored.)
///
[MarshalAs(UnmanagedType.Bool)]
public bool fStepMCIDevice;
///
/// Starting position, in milliseconds, of the MCI device for the capture sequence. (If fMCIControl is FALSE, this
/// member is ignored.)
///
public uint dwMCIStartTime;
///
/// Stopping position, in milliseconds, of the MCI device for the capture sequence. When this position in the content is
/// reached, capture ends and the MCI device stops. (If fMCIControl is FALSE, this member is ignored.)
///
public uint dwMCIStopTime;
///
///
/// Double-resolution step capture flag. If this member is TRUE, the capture hardware captures at twice the specified
/// resolution. (The resolution for the height and width is doubled.)
///
/// Enable this option if the hardware does not support hardware-based decimation and you are capturing in the RGB format.
///
[MarshalAs(UnmanagedType.Bool)]
public bool fStepCaptureAt2x;
///
/// Number of times a frame is sampled when creating a frame based on the average sample. A typical value for the number of
/// averages is 5.
///
public uint wStepCaptureAverageFrames;
///
/// Audio buffer size. If the default value of zero is used, the size of each buffer will be the maximum of 0.5 seconds of audio
/// or 10K bytes.
///
public uint dwAudioBufferSize;
/// Not used in Win32 applications.
[MarshalAs(UnmanagedType.Bool)]
public bool fDisableWriteCache;
///
/// Indicates whether the audio stream controls the clock when writing an AVI file. If this member is set to
/// AVSTREAMMASTER_AUDIO, the audio stream is considered the master stream and the video stream duration is forced to match the
/// audio duration. If this member is set to AVSTREAMMASTER_NONE, the durations of audio and video streams can differ.
///
public uint AVStreamMaster;
}
/// The VIDEOHDR structure is used by the capVideoStreamCallback function.
// https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-videohdr typedef struct videohdr_tag { LPBYTE lpData; DWORD
// dwBufferLength; DWORD dwBytesUsed; DWORD dwTimeCaptured; DWORD_PTR dwUser; DWORD dwFlags; DWORD_PTR dwReserved[4]; } VIDEOHDR,
// *PVIDEOHDR, *LPVIDEOHDR;
[PInvokeData("vfw.h", MSDNShortId = "NS:vfw.videohdr_tag")]
[StructLayout(LayoutKind.Sequential)]
public struct VIDEOHDR
{
/// Pointer to locked data buffer.
public IntPtr lpData;
/// Length of data buffer.
public uint dwBufferLength;
/// Bytes actually used.
public uint dwBytesUsed;
/// Milliseconds from start of stream.
public uint dwTimeCaptured;
/// User-defined data.
public IntPtr dwUser;
///
/// The flags are defined as follows.
///
///
/// Flag
/// Meaning
///
/// -
/// VHDR_DONE
/// Done bit
///
/// -
/// VHDR_PREPARED
/// Set if this header has been prepared
///
/// -
/// VHDR_INQUEUE
/// Reserved for driver
///
/// -
/// VHDR_KEYFRAME
/// Key Frame
///
///
///
public VHDR dwFlags;
/// Reserved for driver.
public IntPtr dwReserved1;
/// Reserved for driver.
public IntPtr dwReserved2;
/// Reserved for driver.
public IntPtr dwReserved3;
/// Reserved for driver.
public IntPtr dwReserved4;
}
}
}