diff --git a/PInvoke/Multimedia/JoystickApi.cs b/PInvoke/Multimedia/JoystickApi.cs
new file mode 100644
index 00000000..8120a64d
--- /dev/null
+++ b/PInvoke/Multimedia/JoystickApi.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Vanara.PInvoke
+{
+ public static partial class WinMm
+ {
+ /*
+ JOYCAPS
+ JOYCAPSA
+ JOYCAPSW
+ JOYINFO
+ JOYINFOEX
+ joyConfigChanged
+ joyGetDevCaps
+ joyGetDevCapsA
+ joyGetDevCapsW
+ joyGetNumDevs
+ joyGetPos
+ joyGetPosEx
+ joyGetThreshold
+ joyReleaseCapture
+ joySetCapture
+ joySetThreshold
+
+ */
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/MSAcm.cs b/PInvoke/Multimedia/MSAcm.cs
new file mode 100644
index 00000000..ce26f759
--- /dev/null
+++ b/PInvoke/Multimedia/MSAcm.cs
@@ -0,0 +1,4860 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.WinMm;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the MsAcm32.dll
+ public static partial class MsAcm32
+ {
+ /// The FOURCC used in the fccComp field of the ACMDRIVERDETAILS structure. This is currently an unused field.
+ public static readonly uint ACMDRIVERDETAILS_FCCCOMP = 0;
+
+ ///
+ /// The FOURCC used in the fccType field of the ACMDRIVERDETAILS structure to specify that this is an ACM codec designed for audio.
+ ///
+ public static readonly uint ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC = MAKEFOURCC('a', 'u', 'd', 'c');
+
+ private const int ACMFILTERDETAILS_FILTER_CHARS = 128;
+ private const int ACMFILTERTAGDETAILS_FILTERTAG_CHARS = 48;
+ private const int ACMFORMATDETAILS_FORMAT_CHARS = 128;
+ private const int ACMFORMATTAGDETAILS_FORMATTAG_CHARS = 48;
+ private const string Lib_Msacm32 = "msacm32.dll";
+
+ ///
+ /// The acmDriverEnumCallback function specifies a callback function used with the acmDriverEnum function. The
+ /// acmDriverEnumCallback name is a placeholder for an application-defined function name.
+ ///
+ /// Handle to an ACM driver identifier.
+ /// Application-defined value specified in acmDriverEnum.
+ ///
+ ///
+ /// Driver-support flags specific to the driver specified by ACMDRIVERDETAILS structure. This parameter can be a combination of the
+ /// following values.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags. For example, if a driver supports compression from WAVE_FORMAT_PCM
+ /// to WAVE_FORMAT_ADPCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag. For example, if a driver supports resampling of
+ /// WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_DISABLED
+ ///
+ /// Driver has been disabled. An application must specify the ACM_DRIVERENUMF_DISABLED flag with acmDriverEnum to include disabled
+ /// drivers in the enumeration.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ ///
+ ///
+ /// The callback function must return TRUE to continue enumeration or FALSE to stop enumeration.
+ ///
+ ///
+ /// The acmDriverEnum function will return MMSYSERR_NOERROR (zero) if no ACM drivers are installed. Moreover, the callback function
+ /// will not be called.
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nc-msacm-acmdriverenumcb ACMDRIVERENUMCB Acmdriverenumcb; BOOL
+ // Acmdriverenumcb( HACMDRIVERID hadid, DWORD_PTR dwInstance, DWORD fdwSupport ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMDRIVERENUMCB")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool ACMDRIVERENUMCB(HACMDRIVERID hadid, IntPtr dwInstance, ACMDRIVERDETAILS_SUPPORTF fdwSupport);
+
+ ///
+ /// The acmDriverProc function specifies a callback function used with the ACM driver. The acmDriverProc name is a
+ /// placeholder for an application-defined function name. The actual name must be exported by including it in the module-definition
+ /// file of the executable or DLL file.
+ ///
+ /// Identifier of the installable ACM driver.
+ ///
+ /// Handle to the installable ACM driver. This parameter is a unique handle the ACM assigns to the driver.
+ ///
+ /// ACM driver message.
+ /// Message parameter.
+ /// Message parameter.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// Applications should not call any system-defined functions from inside a callback function, except for PostMessage,
+ /// timeGetSystemTime, timeGetTime, timeSetEvent, timeKillEvent, midiOutShortMsg, midiOutLongMsg, and OutputDebugStr.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nc-msacm-acmdriverproc ACMDRIVERPROC Acmdriverproc; LRESULT
+ // Acmdriverproc( DWORD_PTR unnamedParam1, HACMDRIVERID unnamedParam2, UINT unnamedParam3, LPARAM unnamedParam4, LPARAM
+ // unnamedParam5 ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMDRIVERPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate IntPtr ACMDRIVERPROC(IntPtr unnamedParam1, HACMDRIVERID unnamedParam2, uint unnamedParam3, IntPtr unnamedParam4, IntPtr unnamedParam5);
+
+ ///
+ /// The acmFilterChooseHookProc function specifies a user-defined function that hooks the acmFilterChoose dialog box.
+ ///
+ /// Window handle for the dialog box.
+ /// Window message.
+ /// Message parameter.
+ /// Message parameter.
+ /// None
+ ///
+ /// To customize the dialog box selections, a hook function can optionally process the MM_ACM_FILTERCHOOSE message.
+ /// You should use this function the same way as you use the Common Dialog hook functions for customizing common dialog boxes.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nc-msacm-acmfilterchoosehookproc ACMFILTERCHOOSEHOOKPROC
+ // Acmfilterchoosehookproc; UINT Acmfilterchoosehookproc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFILTERCHOOSEHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate uint ACMFILTERCHOOSEHOOKPROC(HWND hwnd, uint uMsg, IntPtr wParam, IntPtr lParam);
+
+ ///
+ /// The acmFilterEnumCallback function specifies a callback function used with the acmFilterEnum function. The
+ /// acmFilterEnumCallback name is a placeholder for an application-defined function name.
+ ///
+ /// Handle to the ACM driver identifier.
+ /// Pointer to an ACMFILTERDETAILS structure that contains the enumerated filter details for a filter tag.
+ /// Application-defined value specified in acmFilterEnum.
+ ///
+ ///
+ /// Driver-support flags specific to the driver identified by ACMDRIVERDETAILS structure, but they are specific to the filter that
+ /// is being enumerated. This parameter can be a combination of the following values and identifies which operations the driver
+ /// supports for the filter tag.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified filter tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags while using the specified filter. For example, if a driver supports
+ /// compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified filter, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified filter. For example,
+ /// if a driver supports resampling of WAVE_FORMAT_PCM with the specified filter, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both with the specified filter through a waveform-audio device. An application should
+ /// use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indices to get
+ /// the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ /// The callback function must return TRUE to continue enumeration or FALSE to stop enumeration.
+ ///
+ ///
+ /// The acmFilterEnum function will return MMSYSERR_NOERROR (zero) if no filters are to be enumerated. Moreover, the callback
+ /// function will not be called.
+ ///
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFILTERENUMCB 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/msacm/nc-msacm-acmfilterenumcbw ACMFILTERENUMCBW Acmfilterenumcbw; BOOL
+ // Acmfilterenumcbw( HACMDRIVERID hadid, LPACMFILTERDETAILSW pafd, DWORD_PTR dwInstance, DWORD fdwSupport ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFILTERENUMCBW")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool ACMFILTERENUMCB(HACMDRIVERID hadid, in ACMFILTERDETAILS pafd, IntPtr dwInstance, ACMDRIVERDETAILS_SUPPORTF fdwSupport);
+
+ ///
+ /// The acmFilterTagEnumCallback function specifies a callback function used with the acmFilterTagEnum function. The
+ /// acmFilterTagEnumCallback function name is a placeholder for an application-defined function name.
+ ///
+ /// Handle to the ACM driver identifier.
+ /// Pointer to an ACMFILTERTAGDETAILS structure that contains the enumerated filter tag details.
+ /// Application-defined value specified in acmFilterTagEnum.
+ ///
+ ///
+ /// Driver-support flags specific to the driver identifier ACMDRIVERDETAILS structure. This parameter can be a combination of the
+ /// following values and identifies which operations the driver supports with the filter tag.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified filter tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags while using the specified filter tag. For example, if a driver
+ /// supports compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified filter tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified filter tag. For
+ /// example, if a driver supports resampling of WAVE_FORMAT_PCM with the specified filter tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both with the specified filter tag through a waveform-audio device. An application
+ /// should use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indices to
+ /// get the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ /// The callback function must return TRUE to continue enumeration or FALSE to stop enumeration.
+ ///
+ ///
+ /// The acmFilterTagEnum function returns MMSYSERR_NOERROR (zero) if no filter tags are to be enumerated. Moreover, the
+ /// callback function will not be called.
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFILTERTAGENUMCB 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/msacm/nc-msacm-acmfiltertagenumcbw ACMFILTERTAGENUMCBW Acmfiltertagenumcbw;
+ // BOOL Acmfiltertagenumcbw( HACMDRIVERID hadid, LPACMFILTERTAGDETAILSW paftd, DWORD_PTR dwInstance, DWORD fdwSupport ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFILTERTAGENUMCBW")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool ACMFILTERTAGENUMCB(HACMDRIVERID hadid, in ACMFILTERTAGDETAILS paftd, IntPtr dwInstance, ACMDRIVERDETAILS_SUPPORTF fdwSupport);
+
+ ///
+ /// The acmFormatChooseHookProc function specifies a user-defined function that hooks the acmFormatChoose dialog box. The
+ /// acmFormatChooseHookProc name is a placeholder for an application-defined name.
+ ///
+ /// Window handle for the dialog box.
+ /// Window message.
+ /// Message parameter.
+ /// Message parameter.
+ /// None
+ ///
+ ///
+ /// If the hook function processes one of the WM_CTLCOLOR messages, this function must return a handle of the brush that should be
+ /// used to paint the control background.
+ ///
+ /// A hook function can optionally process the MM_ACM_FORMATCHOOSE message.
+ /// You should use this function the same way as you use the Common Dialog hook functions for customizing common dialog boxes.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nc-msacm-acmformatchoosehookproc ACMFORMATCHOOSEHOOKPROC
+ // Acmformatchoosehookproc; UINT Acmformatchoosehookproc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFORMATCHOOSEHOOKPROC")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate uint ACMFORMATCHOOSEHOOKPROC(HWND hwnd, uint uMsg, IntPtr wParam, IntPtr lParam);
+
+ ///
+ /// The acmFormatEnumCallback function specifies a callback function used with the acmFormatEnum function. The
+ /// acmFormatEnumCallback name is a placeholder for the application-defined function name.
+ ///
+ /// Handle to the ACM driver identifier.
+ /// Pointer to an ACMFORMATDETAILS structure that contains the enumerated format details for a format tag.
+ /// Application-defined value specified in the acmFormatEnum function.
+ ///
+ ///
+ /// Driver support flags specific to the driver identified by ACMDRIVERDETAILS structure, but they are specific to the format that
+ /// is being enumerated. This parameter can be a combination of the following values and indicates which operations the driver
+ /// supports for the format tag.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified filter tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags for the specified format. For example, if a driver supports
+ /// compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified format, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified format. For example,
+ /// if a driver supports resampling of WAVE_FORMAT_PCM to the specified format, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes) with the specified format. For
+ /// example, if a driver supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both of the specified format tags through a waveform-audio device. An application
+ /// should use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indexes to
+ /// get the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ /// The callback function must return TRUE to continue enumeration or FALSE to stop enumeration.
+ ///
+ ///
+ /// The acmFormatEnum function will return MMSYSERR_NOERROR (zero) if no formats are to be enumerated. Moreover, the callback
+ /// function will not be called.
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFORMATENUMCB 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/msacm/nc-msacm-acmformatenumcbw ACMFORMATENUMCBW Acmformatenumcbw; BOOL
+ // Acmformatenumcbw( HACMDRIVERID hadid, LPACMFORMATDETAILSW pafd, DWORD_PTR dwInstance, DWORD fdwSupport ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFORMATENUMCBW")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool ACMFORMATENUMCB(HACMDRIVERID hadid, in ACMFORMATDETAILS pafd, IntPtr dwInstance, ACMDRIVERDETAILS_SUPPORTF fdwSupport);
+
+ ///
+ /// The acmFormatTagEnumCallback function specifies a callback function used with the acmFormatTagEnum function. The
+ /// acmFormatTagEnumCallback name is a placeholder for an application-defined function name.
+ ///
+ /// Handle to the ACM driver identifier.
+ /// Pointer to an ACMFORMATTAGDETAILS structure that contains the enumerated format tag details.
+ /// Application-defined value specified in the acmFormatTagEnum function.
+ ///
+ ///
+ /// Driver-support flags specific to the format tag. These flags are identical to the ACMDRIVERDETAILS structure. This parameter can
+ /// be a combination of the following values and indicates which operations the driver supports with the format tag.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified filter tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags where one of the tags is the specified format tag. For example, if
+ /// a driver supports compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the specified format tag. For example, if a driver supports
+ /// resampling of WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on the specified format tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both of the specified format tag through a waveform-audio device. An application
+ /// should use acmMetrics with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indexes to get the
+ /// waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ /// The callback function must return TRUE to continue enumeration or FALSE to stop enumeration.
+ ///
+ ///
+ /// The acmFormatTagEnum function will return MMSYSERR_NOERROR (zero) if no format tags are to be enumerated. Moreover, the callback
+ /// function will not be called.
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFORMATTAGENUMCB 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/msacm/nc-msacm-acmformattagenumcbw ACMFORMATTAGENUMCBW Acmformattagenumcbw;
+ // BOOL Acmformattagenumcbw( HACMDRIVERID hadid, LPACMFORMATTAGDETAILSW paftd, DWORD_PTR dwInstance, DWORD fdwSupport ) {...}
+ [PInvokeData("msacm.h", MSDNShortId = "NC:msacm.ACMFORMATTAGENUMCBW")]
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool ACMFORMATTAGENUMCB(HACMDRIVERID hadid, in ACMFORMATTAGDETAILS paftd, IntPtr dwInstance, uint fdwSupport);
+
+ /// Flags for adding ACM drivers.
+ [Flags]
+ public enum ACM_DRIVERADDF : uint
+ {
+ ///
+ /// The lParam parameter is a registry value name in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32.
+ /// The value identifies a DLL that implements an ACM codec. Applications can use this flag if new registry entries are created
+ /// after the application has already started using the ACM.
+ ///
+ ACM_DRIVERADDF_NAME = 0x00000001,
+
+ ///
+ /// The lParam parameter is a driver function address conforming to the acmDriverProc prototype. The function may reside in
+ /// either an executable or DLL file.
+ ///
+ ACM_DRIVERADDF_FUNCTION = 0x00000003,
+
+ ///
+ /// The lParam parameter is a handle of a notification window that receives messages when changes to global driver priorities
+ /// and states are made. The window message to receive is defined by the application and must be passed in dwPriority. The
+ /// wParam and lParam parameters passed with the window message are reserved for future use and should be ignored.
+ /// ACM_DRIVERADDF_GLOBAL cannot be specified in conjunction with this flag. For more information about driver priorities, see
+ /// the description for the acmDriverPriority function.
+ ///
+ ACM_DRIVERADDF_NOTIFYHWND = 0x00000004,
+
+ ///
+ /// The ACM automatically gives a local driver higher priority than a global driver when searching for a driver to satisfy a
+ /// function call. For more information, see Adding Drivers Within an Application.
+ ///
+ ACM_DRIVERADDF_LOCAL = 0x00000000,
+
+ ///
+ /// Provided for compatibility with 16-bit applications. For the Win32 API, ACM drivers added by the acmDriverAdd function can
+ /// be used only by the application that added the driver. This is true whether or not ACM_DRIVERADDF_GLOBAL is specified. For
+ /// more information, see Adding Drivers Within an Application.
+ ///
+ ACM_DRIVERADDF_GLOBAL = 0x00000008,
+ }
+
+ /// Flags for enumerating ACM drivers.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverEnum")]
+ [Flags]
+ public enum ACM_DRIVERENUMF : uint
+ {
+ /// Only global drivers should be included in the enumeration.
+ ACM_DRIVERENUMF_NOLOCAL = 0x40000000,
+
+ ///
+ /// Disabled ACM drivers should be included in the enumeration. Drivers can be disabled by the user through the Control Panel or
+ /// by an application using the acmDriverPriority function. If a driver is disabled, the fdwSupport parameter to the callback
+ /// function will have the ACMDRIVERDETAILS_SUPPORTF_DISABLED flag set.
+ ///
+ ACM_DRIVERENUMF_DISABLED = 0x80000000,
+ }
+
+ /// Flags for setting priorities of ACM drivers.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverPriority")]
+ [Flags]
+ public enum ACM_DRIVERPRIORITYF : uint
+ {
+ /// ACM driver should be enabled if it is currently disabled. Enabling an enabled driver does nothing.
+ ACM_DRIVERPRIORITYF_ENABLE = 0x00000001,
+
+ /// ACM driver should be disabled if it is currently enabled. Disabling a disabled driver does nothing.
+ ACM_DRIVERPRIORITYF_DISABLE = 0x00000002,
+
+ ///
+ /// Change notification broadcasts should be deferred. An application must reenable notification broadcasts as soon as possible
+ /// with the ACM_DRIVERPRIORITYF_END flag. Note that hadid must be NULL, dwPriority must be zero, and only the
+ /// ACM_DRIVERPRIORITYF_BEGIN flag can be set.
+ ///
+ ACM_DRIVERPRIORITYF_BEGIN = 0x00010000,
+
+ ///
+ /// Calling task wants to reenable change notification broadcasts. An application must call acmDriverPriority with
+ /// ACM_DRIVERPRIORITYF_END for each successful call with the ACM_DRIVERPRIORITYF_BEGIN flag. Note that hadid must be NULL,
+ /// dwPriority must be zero, and only the ACM_DRIVERPRIORITYF_END flag can be set.
+ ///
+ ACM_DRIVERPRIORITYF_END = 0x00020000,
+ }
+
+ /// Flags for getting the details.
+ [Flags]
+ public enum ACM_FILTERDETAILSF : uint
+ {
+ ///
+ /// A filter index for the filter tag was given in the dwFilterIndex member of the ACMFILTERDETAILS structure. The filter
+ /// details will be returned in the structure defined by pafd. The index ranges from zero to one less than the cStandardFilters
+ /// member returned in the ACMFILTERTAGDETAILS structure for a filter tag. An application must specify a driver handle for had
+ /// when retrieving filter details with this flag. For information about what members should be initialized before calling this
+ /// function, see the ACMFILTERDETAILS structure.
+ ///
+ ACM_FILTERDETAILSF_INDEX = 0x00000000,
+
+ ///
+ /// A WAVEFILTER structure pointed to by the pwfltr member of the ACMFILTERDETAILS structure was given and the remaining details
+ /// should be returned. The dwFilterTag member of the ACMFILTERDETAILS structure must be initialized to the same filter tag
+ /// pwfltr specifies. This query type can be used to get a string description of an arbitrary filter structure. If an
+ /// application specifies an ACM driver handle for had, details on the filter will be returned for that driver. If an
+ /// application specifies NULL for had, the ACM finds the first acceptable driver to return the details.
+ ///
+ ACM_FILTERDETAILSF_FILTER = 0x00000001,
+ }
+
+ /// Optional flags for restricting the type of filters listed in the dialog box.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFILTERCHOOSE")]
+ [Flags]
+ public enum ACM_FILTERENUMF : uint
+ {
+ ///
+ /// The dwFilterTag member of the WAVEFILTER structure pointed to by the pwfltrEnum member is valid. The enumerator will only
+ /// enumerate a filter that conforms to this attribute.
+ ///
+ ACM_FILTERENUMF_DWFILTERTAG = 0x00010000
+ }
+
+ /// Flags for getting the details.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterTagDetailsW")]
+ [Flags]
+ public enum ACM_FILTERTAGDETAILSF : uint
+ {
+ ///
+ ACM_FILTERTAGDETAILSF_INDEX = 0x00000000,
+
+ ///
+ ACM_FILTERTAGDETAILSF_FILTERTAG = 0x00000001,
+
+ ///
+ ACM_FILTERTAGDETAILSF_LARGESTSIZE = 0x00000002,
+ }
+
+ /// Flags for getting the waveform-audio format tag details.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatDetailsW")]
+ [Flags]
+ public enum ACM_FORMATDETAILSF : uint
+ {
+ ///
+ /// A format index for the format tag was given in the dwFormatIndex member of the ACMFORMATDETAILS structure. The format
+ /// details will be returned in the structure defined by pafd. The index ranges from zero to one less than the cStandardFormats
+ /// member returned in the ACMFORMATTAGDETAILS structure for a format tag. An application must specify a driver handle for had
+ /// when retrieving format details with this flag. For information about which members should be initialized before calling this
+ /// function, see the ACMFORMATDETAILS structure.
+ ///
+ ACM_FORMATDETAILSF_INDEX = 0x00000000,
+
+ ///
+ /// ACMFORMATDETAILS structure was given and the remaining details should be returned. The dwFormatTag member of the
+ /// ACMFORMATDETAILS structure must be initialized to the same format tag as pwfx specifies. This query type can be used to get
+ /// a string description of an arbitrary format structure. If an application specifies an ACM driver handle for had , details on
+ /// the format will be returned for that driver. If an application specifies NULL for had , the ACM finds the first acceptable
+ /// driver to return the details.
+ ///
+ ACM_FORMATDETAILSF_FORMAT = 0x00000001,
+ }
+
+ /// Optional flags for restricting the type of formats listed in the dialog box.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFORMATCHOOSE")]
+ [Flags]
+ public enum ACM_FORMATENUMF : uint
+ {
+ ///
+ /// The wFormatTag member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ACM_FORMATENUMF_WFORMATTAG = 0x00010000,
+
+ ///
+ /// The nChannels member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate
+ /// only a format that conforms to this attribute.
+ ///
+ ACM_FORMATENUMF_NCHANNELS = 0x00020000,
+
+ ///
+ /// The nSamplesPerSec member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ACM_FORMATENUMF_NSAMPLESPERSEC = 0x00040000,
+
+ ///
+ /// The wBitsPerSample member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ACM_FORMATENUMF_WBITSPERSAMPLE = 0x00080000,
+
+ ///
+ /// The WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate only destination
+ /// formats that can be converted from the given pwfxEnum format.
+ ///
+ ACM_FORMATENUMF_CONVERT = 0x00100000,
+
+ ///
+ /// The WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate all suggested
+ /// destination formats for the given pwfxEnum format.
+ ///
+ ACM_FORMATENUMF_SUGGEST = 0x00200000,
+
+ ///
+ /// The enumerator should enumerate only formats that are supported in hardware by one or more of the installed waveform-audio
+ /// devices. This flag provides a way for an application to choose only formats native to an installed waveform-audio device.
+ ///
+ ACM_FORMATENUMF_HARDWARE = 0x00400000,
+
+ /// The enumerator should enumerate only formats that are supported for input (recording).
+ ACM_FORMATENUMF_INPUT = 0x00800000,
+
+ /// The enumerator should enumerate only formats that are supported for output (playback).
+ ACM_FORMATENUMF_OUTPUT = 0x01000000,
+ }
+
+ /// Flags for matching the desired destination format.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatSuggest")]
+ [Flags]
+ public enum ACM_FORMATSUGGESTF : uint
+ {
+ ///
+ /// The wFormatTag member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching wFormatTag or fail.
+ ///
+ ACM_FORMATSUGGESTF_WFORMATTAG = 0x00010000,
+
+ ///
+ /// The nChannels member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching nChannels or fail.
+ ///
+ ACM_FORMATSUGGESTF_NCHANNELS = 0x00020000,
+
+ ///
+ /// The nSamplesPerSec member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers
+ /// that can suggest a destination format matching nSamplesPerSec or fail.
+ ///
+ ACM_FORMATSUGGESTF_NSAMPLESPERSEC = 0x00040000,
+
+ ///
+ /// The wBitsPerSample member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers
+ /// that can suggest a destination format matching wBitsPerSample or fail.
+ ///
+ ACM_FORMATSUGGESTF_WBITSPERSAMPLE = 0x00080000,
+ }
+
+ /// Flags for getting the details.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatTagDetailsW")]
+ [Flags]
+ public enum ACM_FORMATTAGDETAILSF : uint
+ {
+ ///
+ /// ACMDRIVERDETAILS structure for an ACM driver. An application must specify a driver handle forhadwhen retrieving format tag
+ /// details with this flag.
+ ///
+ ACM_FORMATTAGDETAILSF_INDEX = 0x00000000,
+
+ ///
+ /// ACMFORMATTAGDETAILS structure. The format tag details will be returned in the structure pointed to bypaftd. If an
+ /// application specifies an ACM driver handle forhad, details on the format tag will be returned for that driver. If an
+ /// application specifiesNULLforhad, the ACM finds the first acceptable driver to return the details.
+ ///
+ ACM_FORMATTAGDETAILSF_FORMATTAG = 0x00000001,
+
+ ///
+ /// ACMFORMATTAGDETAILS structure must either be WAVE_FORMAT_UNKNOWN or the format tag to find the largest size for. If an
+ /// application specifies an ACM driver handle forhad, details on the largest format tag will be returned for that driver. If an
+ /// application specifiesNULLforhad, the ACM finds an acceptable driver with the largest format tag requested to return the details.
+ ///
+ ACM_FORMATTAGDETAILSF_LARGESTSIZE = 0x00000002,
+ }
+
+ /// Metric index to be returned in pMetric.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmMetrics")]
+ public enum ACM_METRIC
+ {
+ ///
+ /// Returned value is the total number of enabled global ACM drivers (of all support types) in the system. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_DRIVERS = 1,
+
+ ///
+ /// Returned value is the number of global ACM compressor or decompressor drivers in the system. The hao parameter must be NULL
+ /// for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_CODECS,
+
+ ///
+ /// Returned value is the number of global ACM converter drivers in the system. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_CONVERTERS,
+
+ ///
+ /// Returned value is the number of global ACM filter drivers in the system. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_FILTERS,
+
+ ///
+ /// Returned value is the total number of global disabled ACM drivers (of all support types) in the system. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value. The sum
+ /// of the ACM_METRIC_COUNT_DRIVERS and ACM_METRIC_COUNT_DISABLED metric indices is the total number of globally installed ACM drivers.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_DISABLED,
+
+ ///
+ /// Returned value is the number of global ACM hardware drivers in the system. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_HARDWARE,
+
+ ///
+ /// Returned value is the total number of enabled local ACM drivers (of all support types) for the calling task. The hao
+ /// parameter must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_LOCAL_DRIVERS = 20,
+
+ ///
+ /// Returned value is the number of local ACM compressor drivers, ACM decompressor drivers, or both for the calling task. The
+ /// hao parameter must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_LOCAL_CODECS,
+
+ ///
+ /// Returned value is the number of local ACM converter drivers for the calling task. The hao parameter must be NULL for this
+ /// metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_LOCAL_CONVERTERS,
+
+ ///
+ /// Returned value is the number of local ACM filter drivers for the calling task. The hao parameter must be NULL for this
+ /// metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_LOCAL_FILTERS,
+
+ ///
+ /// Returned value is the total number of local disabled ACM drivers, of all support types, for the calling task. The hao
+ /// parameter must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ /// The sum of the ACM_METRIC_COUNT_LOCAL_DRIVERS and ACM_METRIC_COUNT_LOCAL_DISABLED metric indices is the total number of
+ /// locally installed ACM drivers.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_COUNT_LOCAL_DISABLED,
+
+ ///
+ /// Returned value is the waveform-audio input device identifier associated with the specified driver. The hao parameter must be
+ /// a valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If no
+ /// waveform-audio input device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must
+ /// point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_HARDWARE_WAVE_INPUT = 30,
+
+ ///
+ /// Returned value is the waveform-audio output device identifier associated with the specified driver. The hao parameter must
+ /// be a valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If
+ /// no waveform-audio output device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must
+ /// point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_HARDWARE_WAVE_OUTPUT,
+
+ ///
+ /// Returned value is the size of the largest WAVEFORMATEX structure. If hao is NULL, the return value is the largest
+ /// WAVEFORMATEX structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an
+ /// ACM driver identifier of the HACMDRIVERID data type, the largest WAVEFORMATEX structure for that driver is returned. The
+ /// pMetric parameter must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream
+ /// handle of the HACMSTREAM data type.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_MAX_SIZE_FORMAT = 50,
+
+ ///
+ /// Returned value is the size of the largest WAVEFILTER structure. If hao is NULL, the return value is the largest WAVEFILTER
+ /// structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an ACM driver
+ /// identifier of the HACMDRIVERID data type, the largest WAVEFILTER structure for that driver is returned. The pMetric
+ /// parameter must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream handle of
+ /// the HACMSTREAM data type.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_MAX_SIZE_FILTER,
+
+ ///
+ /// Returned value is the fdwSupport flags for the specified driver. The hao parameter must be a valid ACM driver identifier of
+ /// the HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_DRIVER_SUPPORT = 100,
+
+ ///
+ /// Returned value is the current priority for the specified driver. The hao parameter must be a valid ACM driver identifier of
+ /// the HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ [CorrespondingType(typeof(uint))]
+ ACM_METRIC_DRIVER_PRIORITY,
+ }
+
+ /// Flags for doing the conversion.
+ [Flags]
+ public enum ACM_STREAMCONVERTF : uint
+ {
+ ///
+ /// Only integral numbers of blocks will be converted. Converted data will end on block-aligned boundaries. An application
+ /// should use this flag for all conversions on a stream until there is not enough source data to convert to a block-aligned
+ /// destination. In this case, the last conversion should be specified without this flag.
+ ///
+ ACM_STREAMCONVERTF_BLOCKALIGN = 0x00000004,
+
+ ///
+ /// ACM conversion stream should reinitialize its instance data. For example, if a conversion stream holds instance data, such
+ /// as delta or predictor information, this flag will restore the stream to starting defaults. This flag can be specified with
+ /// the ACM_STREAMCONVERTF_END flag.
+ ///
+ ACM_STREAMCONVERTF_START = 0x00000010,
+
+ ///
+ /// ACM conversion stream should begin returning pending instance data. For example, if a conversion stream holds instance data,
+ /// such as the end of an echo filter operation, this flag will cause the stream to start returning this remaining data with
+ /// optional source data. This flag can be specified with the ACM_STREAMCONVERTF_START flag.
+ ///
+ ACM_STREAMCONVERTF_END = 0x00000020,
+ }
+
+ ///
+ [Flags]
+ public enum ACM_STREAMOPENF : uint
+ {
+ ///
+ /// ACM will be queried to determine whether it supports the given conversion. A conversion stream will not be opened, and no
+ /// handle will be returned in the phas parameter.
+ ///
+ ACM_STREAMOPENF_QUERY = 0x00000001,
+
+ /// ACMSTREAMHEADER structure for the ACMSTREAMHEADER_STATUSF_DONE flag.
+ ACM_STREAMOPENF_ASYNC = 0x00000002,
+
+ ///
+ /// ACM will not consider time constraints when converting the data. By default, the driver will attempt to convert the data in
+ /// real time. For some formats, specifying this flag might improve the audio quality or other characteristics.
+ ///
+ ACM_STREAMOPENF_NONREALTIME = 0x00000004,
+
+ /// The dwCallback parameter is a window handle.
+ CALLBACK_WINDOW = 0x00010000,
+
+ /// The dwCallback parameter is a callback procedure address.
+ CALLBACK_FUNCTION = 0x00030000,
+
+ /// The dwCallback parameter is an event handle.
+ CALLBACK_EVENT = 0x00050000,
+ }
+
+ /// Flags for the stream size query.
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamSize")]
+ [Flags]
+ public enum ACM_STREAMSIZEF : uint
+ {
+ ///
+ /// The cbInput parameter contains the size of the source buffer. The pdwOutputBytes parameter will receive the recommended
+ /// destination buffer size, in bytes.
+ ///
+ ACM_STREAMSIZEF_SOURCE = 0x00000000,
+
+ ///
+ /// The cbInput parameter contains the size of the destination buffer. The pdwOutputBytes parameter will receive the recommended
+ /// source buffer size, in bytes.
+ ///
+ ACM_STREAMSIZEF_DESTINATION = 0x00000001,
+ }
+
+ /// Support flags for the driver.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMDRIVERDETAILS")]
+ [Flags]
+ public enum ACMDRIVERDETAILS_SUPPORTF : uint
+ {
+ ///
+ /// Driver supports conversion between two different format tags. For example, if a driver supports compression from
+ /// WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM, this flag is set.
+ ///
+ ACMDRIVERDETAILS_SUPPORTF_CODEC = 0x00000001,
+
+ ///
+ /// Driver supports conversion between two different formats of the same format tag. For example, if a driver supports
+ /// resampling of WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ACMDRIVERDETAILS_SUPPORTF_CONVERTER = 0x00000002,
+
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ACMDRIVERDETAILS_SUPPORTF_FILTER = 0x00000004,
+
+ ///
+ /// Driver supports hardware input, output, or both through a waveform-audio device. An application should use the acmMetrics
+ /// function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indexes to get the
+ /// waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ACMDRIVERDETAILS_SUPPORTF_HARDWARE = 0x00000008,
+
+ /// Driver supports asynchronous conversions.
+ ACMDRIVERDETAILS_SUPPORTF_ASYNC = 0x00000010,
+
+ /// The driver has been installed locally with respect to the current task.
+ ACMDRIVERDETAILS_SUPPORTF_LOCAL = 0x40000000,
+
+ ///
+ /// Driver has been disabled. This flag is set by the ACM for a driver when it has been disabled for any of a number of reasons.
+ /// Disabled drivers cannot be opened and can be used only under very limited circumstances.
+ ///
+ ACMDRIVERDETAILS_SUPPORTF_DISABLED = 0x80000000,
+ }
+
+ /// Optional style flags for the acmFilterChoose function.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFILTERCHOOSE")]
+ [Flags]
+ public enum ACMFILTERCHOOSE_STYLEF : uint
+ {
+ ///
+ /// A help button will appear in the dialog box. To use a custom Help file, an application must register the ACMHELPMSGSTRING
+ /// value with the RegisterWindowMessage function. When the user presses the help button, the registered message is posted to
+ /// the owner.
+ ///
+ ACMFILTERCHOOSE_STYLEF_SHOWHELP = 0x00000004,
+
+ ///
+ /// Enables the hook function specified in the pfnHook member. An application can use hook functions for a variety of
+ /// customizations, including answering the MM_ACM_FILTERCHOOSE message.
+ ///
+ ACMFILTERCHOOSE_STYLEF_ENABLEHOOK = 0x00000008,
+
+ /// Causes the ACM to create the dialog box template identified by the hInstance and pszTemplateName members.
+ ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE = 0x00000010,
+
+ ///
+ /// The hInstance member identifies a data block that contains a preloaded dialog box template. If this flag is specified, the
+ /// ACM ignores the pszTemplateName member.
+ ///
+ ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE = 0x00000020,
+
+ ///
+ /// The buffer pointed to by pwfltr contains a valid WAVEFILTER structure that the dialog box will use as the initial selection.
+ ///
+ ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT = 0x00000040,
+
+ ///
+ /// Context-sensitive help will be available in the dialog box. To use this feature, an application must register the
+ /// ACMHELPMSGCONTEXTMENU and ACMHELPMSGCONTEXTHELP constants, using the RegisterWindowMessage function. When the user invokes
+ /// help, the registered message will be posted to the owning window. The message will contain the wParam and lParam parameters
+ /// from the original WM_CONTEXTMENU or WM_CONTEXTHELP message.
+ ///
+ ACMFILTERCHOOSE_STYLEF_CONTEXTHELP = 0x00000080,
+ }
+
+ /// Optional style flags for the acmFormatChoose function.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFORMATCHOOSE")]
+ [Flags]
+ public enum ACMFORMATCHOOSE_STYLEF : uint
+ {
+ ///
+ /// A help button will appear in the dialog box. To use a custom Help file, an application must register the ACMHELPMSGSTRING
+ /// constant with the RegisterWindowMessage function. When the user presses the help button, the registered message will be
+ /// posted to the owner.
+ ///
+ ACMFORMATCHOOSE_STYLEF_SHOWHELP = 0x00000004,
+
+ ///
+ /// Enables the hook function pointed to by the pfnHook member. An application can use hook functions for a variety of
+ /// customizations, including answering the MM_ACM_FORMATCHOOSE message.
+ ///
+ ACMFORMATCHOOSE_STYLEF_ENABLEHOOK = 0x00000008,
+
+ /// Causes the ACM to create the dialog box template identified by hInstance and pszTemplateName.
+ ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE = 0x00000010,
+
+ ///
+ /// The hInstance member identifies a data block that contains a preloaded dialog box template. If this flag is specified, the
+ /// ACM ignores the pszTemplateName member.
+ ///
+ ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE = 0x00000020,
+
+ ///
+ /// The buffer pointed to by pwfx contains a valid WAVEFORMATEX structure that the dialog box will use as the initial selection.
+ ///
+ ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT = 0x00000040,
+
+ ///
+ /// Context-sensitive help will be available in the dialog box. To use this feature, an application must register the
+ /// ACMHELPMSGCONTEXTMENU and ACMHELPMSGCONTEXTHELP constants, using the RegisterWindowMessage function. When the user invokes
+ /// help, the registered message will be posted to the owning window. The message will contain the wParam and lParam parameters
+ /// from the original WM_CONTEXTMENU or WM_CONTEXTHELP message.
+ ///
+ ACMFORMATCHOOSE_STYLEF_CONTEXTHELP = 0x00000080,
+ }
+
+ /// Flags giving information about the conversion buffers.
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMSTREAMHEADER")]
+ [Flags]
+ public enum ACMSTREAMHEADER_STATUSF : uint
+ {
+ ///
+ /// Set by the ACM or driver to indicate that it is finished with the conversion and is returning the buffers to the application.
+ ///
+ ACMSTREAMHEADER_STATUSF_DONE = 0x00010000,
+
+ /// Set by the ACM to indicate that the buffers have been prepared by using the acmStreamPrepareHeader function.
+ ACMSTREAMHEADER_STATUSF_PREPARED = 0x00020000,
+
+ /// Set by the ACM or driver to indicate that the buffers are queued for conversion.
+ ACMSTREAMHEADER_STATUSF_INQUEUE = 0x00100000,
+ }
+
+ ///
+ /// The acmDriverAdd function adds a driver to the list of available ACM drivers. The driver type and location are dependent
+ /// on the flags used to add ACM drivers. After a driver is successfully added, the driver entry function will receive ACM driver messages.
+ ///
+ ///
+ /// Pointer to the buffer that receives a handle identifying the installed driver. This handle is used to identify the driver in
+ /// calls to other ACM functions.
+ ///
+ ///
+ /// Handle to the instance of the module whose executable or dynamic-link library (DLL) contains the driver entry function.
+ ///
+ /// Driver function address or a notification window handle, depending on the fdwAdd flags.
+ ///
+ /// Window message to send for notification broadcasts. This parameter is used only with the ACM_DRIVERADDF_NOTIFYHWND flag. All
+ /// other flags require this member to be set to zero.
+ ///
+ ///
+ /// Flags for adding ACM drivers. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_DRIVERADDF_FUNCTION
+ ///
+ /// The lParam parameter is a driver function address conforming to the acmDriverProc prototype. The function may reside in either
+ /// an executable or DLL file.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERADDF_GLOBAL
+ ///
+ /// Provided for compatibility with 16-bit applications. For the Win32 API, ACM drivers added by the acmDriverAdd function can be
+ /// used only by the application that added the driver. This is true whether or not ACM_DRIVERADDF_GLOBAL is specified. For more
+ /// information, see Adding Drivers Within an Application.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERADDF_LOCAL
+ ///
+ /// The ACM automatically gives a local driver higher priority than a global driver when searching for a driver to satisfy a
+ /// function call. For more information, see Adding Drivers Within an Application.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERADDF_NAME
+ ///
+ /// The lParam parameter is a registry value name in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32. The
+ /// value identifies a DLL that implements an ACM codec. Applications can use this flag if new registry entries are created after
+ /// the application has already started using the ACM.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERADDF_NOTIFYHWND
+ ///
+ /// The lParam parameter is a handle of a notification window that receives messages when changes to global driver priorities and
+ /// states are made. The window message to receive is defined by the application and must be passed in dwPriority. The wParam and
+ /// lParam parameters passed with the window message are reserved for future use and should be ignored. ACM_DRIVERADDF_GLOBAL cannot
+ /// be specified in conjunction with this flag. For more information about driver priorities, see the description for the
+ /// acmDriverPriority function.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// The system is unable to allocate resources.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines acmDriverAdd 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/msacm/nf-msacm-acmdriveraddw MMRESULT ACMAPI acmDriverAddW( LPHACMDRIVERID
+ // phadid, HINSTANCE hinstModule, LPARAM lParam, DWORD dwPriority, DWORD fdwAdd );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverAddW")]
+ public static extern MMRESULT acmDriverAdd(out HACMDRIVERID phadid, HINSTANCE hinstModule, IntPtr lParam, uint dwPriority, ACM_DRIVERADDF fdwAdd);
+
+ ///
+ /// The acmDriverClose function closes a previously opened ACM driver instance. If the function is successful, the handle is invalidated.
+ ///
+ /// Handle to the open driver instance to be closed.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_BUSY
+ /// The driver is in use and cannot be closed.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriverclose MMRESULT ACMAPI acmDriverClose( HACMDRIVER had,
+ // DWORD fdwClose );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverClose")]
+ public static extern MMRESULT acmDriverClose(HACMDRIVER had, uint fdwClose = 0);
+
+ /// The acmDriverDetails function queries a specified ACM driver to determine its capabilities.
+ /// Handle to the driver identifier of an installed ACM driver. Disabled drivers can be queried for details.
+ ///
+ /// Pointer to an ACMDRIVERDETAILS structure that will receive the driver details. The cbStruct member must be initialized to
+ /// the size, in bytes, of the structure.
+ ///
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMDRIVERDETAILS 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/msacm/nf-msacm-acmdriverdetailsw MMRESULT ACMAPI acmDriverDetailsW(
+ // HACMDRIVERID hadid, LPACMDRIVERDETAILSW padd, DWORD fdwDetails );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverDetailsW")]
+ public static extern MMRESULT acmDriverDetails(HACMDRIVERID hadid, ACMDRIVERDETAILS padd, uint fdwDetails = 0);
+
+ ///
+ /// The acmDriverEnum function enumerates the available ACM drivers, continuing until there are no more drivers or the
+ /// callback function returns FALSE.
+ ///
+ /// Procedure instance address of the application-defined callback function.
+ ///
+ /// A 64-bit (DWORD_PTR) or 32-bit (DWORD) application-defined value that is passed to the callback function along with ACM driver information.
+ ///
+ ///
+ /// Flags for enumerating ACM drivers. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_DRIVERENUMF_DISABLED
+ ///
+ /// Disabled ACM drivers should be included in the enumeration. Drivers can be disabled by the user through the Control Panel or by
+ /// an application using the acmDriverPriority function. If a driver is disabled, the fdwSupport parameter to the callback function
+ /// will have the ACMDRIVERDETAILS_SUPPORTF_DISABLED flag set.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERENUMF_NOLOCAL
+ /// Only global drivers should be included in the enumeration.
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// The acmDriverEnum function will return MMSYSERR_NOERROR (zero) if no ACM drivers are installed. Moreover, the callback
+ /// function will not be called.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriverenum MMRESULT ACMAPI acmDriverEnum( ACMDRIVERENUMCB
+ // fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverEnum")]
+ public static extern MMRESULT acmDriverEnum(ACMDRIVERENUMCB fnCallback, IntPtr dwInstance, ACM_DRIVERENUMF fdwEnum);
+
+ ///
+ /// The acmDriverID function returns the handle of an ACM driver identifier associated with an open ACM driver instance or
+ /// stream handle.
+ ///
+ ///
+ /// Handle to the open driver instance or stream handle. This is the handle of an ACM object, such as HACMDRIVER or HACMSTREAM.
+ ///
+ /// Pointer to a buffer that receives a handle identifying the installed driver that is associated with hao.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriverid MMRESULT ACMAPI acmDriverID( HACMOBJ hao,
+ // LPHACMDRIVERID phadid, DWORD fdwDriverID );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverID")]
+ public static extern MMRESULT acmDriverID(HACMOBJ hao, out HACMDRIVERID phadid, uint fdwDriverID = 0);
+
+ /// The acmDriverMessage function sends a user-defined message to a given ACM driver instance.
+ /// Handle to the ACM driver instance to which the message will be sent.
+ ///
+ /// Message that the ACM driver must process. This message must be in the ACMDM_USER message range (above or equal to ACMDM_USER and
+ /// less than ACMDM_RESERVED_LOW). The exceptions to this restriction are the ACMDM_DRIVER_ABOUT, DRV_QUERYCONFIGURE, and
+ /// DRV_CONFIGURE messages.
+ ///
+ /// Message parameter.
+ /// Message parameter.
+ ///
+ ///
+ /// The return value is specific to the user-defined ACM driver message specified by the uMsg parameter. However, possible error
+ /// values include the following.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// The uMsg parameter is not in the ACMDM_USER range.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// The ACM driver did not process the message.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// To display a custom About dialog box from an ACM driver, an application must send the ACMDM_DRIVER_ABOUT message to the driver.
+ /// The lParam1 parameter should be the handle of the owner window for the custom About dialog box, and lParam2 must be set to zero.
+ /// If the driver does not support a custom About dialog box, MMSYSERR_NOTSUPPORTED will be returned and it is the application's
+ /// responsibility to display its own dialog box. For example, the Control Panel Sound Mapper option will display a default About
+ /// dialog box based on the ACMDRIVERDETAILS structure when an ACM driver returns MMSYSERR_NOTSUPPORTED. An application can
+ /// query a driver for custom About dialog box support without the dialog box being displayed by setting lParam1 to –1L. If the
+ /// driver supports a custom About dialog box, MMSYSERR_NOERROR will be returned. Otherwise, the return value is MMSYSERR_NOTSUPPORTED.
+ ///
+ ///
+ /// User-defined messages must be sent only to an ACM driver that specifically supports the messages. The caller should verify that
+ /// the ACM driver is the correct driver by retrieving the driver details and checking the wMid, wPid, and
+ /// vdwDriver members of the ACMDRIVERDETAILS structure.
+ ///
+ /// Never send user-defined messages to an unknown ACM driver.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdrivermessage LRESULT ACMAPI acmDriverMessage( HACMDRIVER
+ // had, UINT uMsg, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverMessage")]
+ public static extern IntPtr acmDriverMessage(HACMDRIVER had, uint uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// The acmDriverOpen function opens the specified ACM driver and returns a driver instance handle that can be used to
+ /// communicate with the driver.
+ ///
+ ///
+ /// Pointer to a buffer that receives the new driver instance handle that can be used to communicate with the driver.
+ ///
+ /// Handle to the driver identifier of an installed and enabled ACM driver.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// The system is unable to allocate resources.
+ ///
+ /// -
+ /// MMSYSERR_NOTENABLED
+ /// The driver is not enabled.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriveropen MMRESULT ACMAPI acmDriverOpen( LPHACMDRIVER phad,
+ // HACMDRIVERID hadid, DWORD fdwOpen );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverOpen")]
+ public static extern MMRESULT acmDriverOpen(out SafeHACMDRIVER phad, HACMDRIVERID hadid, uint fdwOpen = 0);
+
+ /// The acmDriverPriority function modifies the priority and state of an ACM driver.
+ ///
+ /// Handle to the driver identifier of an installed ACM driver. If the ACM_DRIVERPRIORITYF_BEGIN and ACM_DRIVERPRIORITYF_END flags
+ /// are specified, this parameter must be NULL.
+ ///
+ ///
+ /// New priority for a global ACM driver identifier. A zero value specifies that the priority of the driver identifier should remain
+ /// unchanged. A value of 1 specifies that the driver should be placed as the highest search priority driver. A value of –1
+ /// specifies that the driver should be placed as the lowest search priority driver. Priorities are used only for global drivers.
+ ///
+ ///
+ /// Flags for setting priorities of ACM drivers. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_DRIVERPRIORITYF_BEGIN
+ ///
+ /// Change notification broadcasts should be deferred. An application must reenable notification broadcasts as soon as possible with
+ /// the ACM_DRIVERPRIORITYF_END flag. Note that hadid must be NULL, dwPriority must be zero, and only the ACM_DRIVERPRIORITYF_BEGIN
+ /// flag can be set.
+ ///
+ ///
+ /// -
+ /// ACM_DRIVERPRIORITYF_DISABLE
+ /// ACM driver should be disabled if it is currently enabled. Disabling a disabled driver does nothing.
+ ///
+ /// -
+ /// ACM_DRIVERPRIORITYF_ENABLE
+ /// ACM driver should be enabled if it is currently disabled. Enabling an enabled driver does nothing.
+ ///
+ /// -
+ /// ACM_DRIVERPRIORITYF_END
+ ///
+ /// Calling task wants to reenable change notification broadcasts. An application must call acmDriverPriority with
+ /// ACM_DRIVERPRIORITYF_END for each successful call with the ACM_DRIVERPRIORITYF_BEGIN flag. Note that hadid must be NULL,
+ /// dwPriority must be zero, and only the ACM_DRIVERPRIORITYF_END flag can be set.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_ALLOCATED
+ /// The deferred broadcast lock is owned by a different task.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ ///
+ /// The requested operation is not supported for the specified driver. For example, local and notify driver identifiers do not
+ /// support priorities (but can be enabled and disabled). If an application specifies a nonzero value for dwPriority for local and
+ /// notify driver identifiers, this error will be returned.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// All driver identifiers can be enabled and disabled, including global, local and notification driver identifiers.
+ ///
+ /// If more than one global driver identifier needs to be enabled, disabled or shifted in priority, an application should defer
+ /// change notification broadcasts by using the ACM_DRIVERPRIORITYF_BEGIN flag. A single change notification will be broadcast when
+ /// the ACM_DRIVERPRIORITYF_END flag is specified.
+ ///
+ ///
+ /// An application can use the function with the acmMetrics ACM_METRIC_DRIVER_PRIORITY metric index to retrieve the current
+ /// priority of a global driver. Drivers are always enumerated from highest to lowest priority by the acmDriverEnum function.
+ ///
+ ///
+ /// All enabled driver identifiers will receive change notifications. An application can register a notification message by using
+ /// the acmDriverAdd function in conjunction with the ACM_DRIVERADDF_NOTIFYHWND flag. Changes to nonglobal driver identifiers
+ /// will not be broadcast.
+ ///
+ ///
+ /// Priorities are simply used for the search order when an application does not specify a driver. Boosting the priority of a driver
+ /// will have no effect on the performance of a driver.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriverpriority MMRESULT ACMAPI acmDriverPriority(
+ // HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverPriority")]
+ public static extern MMRESULT acmDriverPriority([In, Optional] HACMDRIVERID hadid, uint dwPriority, ACM_DRIVERPRIORITYF fdwPriority);
+
+ ///
+ /// The acmDriverRemove function removes an ACM driver from the list of available ACM drivers. The driver will be removed for
+ /// the calling application only. If the driver is globally installed, other applications will still be able to use it.
+ ///
+ /// Handle to the driver identifier to be removed.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_BUSY
+ /// The driver is in use and cannot be removed.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmdriverremove MMRESULT ACMAPI acmDriverRemove( HACMDRIVERID
+ // hadid, DWORD fdwRemove );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmDriverRemove")]
+ public static extern MMRESULT acmDriverRemove(HACMDRIVERID hadid, uint fdwRemove = 0);
+
+ ///
+ /// The acmFilterChoose function creates an ACM-defined dialog box that enables the user to select a waveform-audio filter.
+ ///
+ ///
+ ///
+ /// Pointer to an ACMFILTERCHOOSE structure that contains information used to initialize the dialog box. When acmFilterChoose
+ /// returns, this structure contains information about the user's filter selection.
+ ///
+ ///
+ /// The pwfltr member of this structure must contain a valid pointer to a memory location that will contain the returned
+ /// filter header structure. The cbwfltr member must be filled in with the size, in bytes, of this memory buffer.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_CANCELED
+ /// The user chose the Cancel button or the Close command on the System menu to close the dialog box.
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ ///
+ /// The buffer identified by the [ACMFILTERCHOOSE](./nf-msacm-acmfilterchoose.md) structure is too small to contain the selected filter.
+ ///
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// A suitable driver is not available to provide valid filter selections.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFILTERCHOOSE 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/msacm/nf-msacm-acmfilterchoosew MMRESULT ACMAPI acmFilterChooseW(
+ // LPACMFILTERCHOOSEW pafltrc );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterChooseW")]
+ public static extern MMRESULT acmFilterChoose(ref ACMFILTERCHOOSE pafltrc);
+
+ ///
+ /// The acmFilterDetails function queries the ACM for details about a filter with a specific waveform-audio filter tag.
+ ///
+ ///
+ /// Handle to the ACM driver to query for waveform-audio filter details for a filter tag. If this parameter is NULL, the ACM
+ /// uses the details from the first suitable ACM driver.
+ ///
+ /// Pointer to the ACMFILTERDETAILS structure that is to receive the filter details for the given filter tag.
+ ///
+ /// Flags for getting the details. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FILTERDETAILSF_FILTER
+ ///
+ /// [ACMFILTERDETAILS](./nf-msacm-acmfilterdetails.md) structure was given and the remaining details should be returned. The
+ /// dwFilterTag member of the ACMFILTERDETAILS structure must be initialized to the same filter tag pwfltr specifies. This query
+ /// type can be used to get a string description of an arbitrary filter structure. If an application specifies an ACM driver handle
+ /// for had , details on the filter will be returned for that driver. If an application specifies NULL for had , the ACM finds the
+ /// first acceptable driver to return the details.
+ ///
+ ///
+ /// -
+ /// ACM_FILTERDETAILSF_INDEX
+ ///
+ /// A filter index for the filter tag was given in the dwFilterIndex member of the ACMFILTERDETAILS structure. The filter details
+ /// will be returned in the structure defined by pafd. The index ranges from zero to one less than the cStandardFilters member
+ /// returned in the ACMFILTERTAGDETAILS structure for a filter tag. An application must specify a driver handle for had when
+ /// retrieving filter details with this flag. For information about what members should be initialized before calling this function,
+ /// see the ACMFILTERDETAILS structure.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details requested are not available.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFILTERDETAILS 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/msacm/nf-msacm-acmfilterdetailsw MMRESULT ACMAPI acmFilterDetailsW( HACMDRIVER
+ // had, LPACMFILTERDETAILSW pafd, DWORD fdwDetails );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterDetailsW")]
+ public static extern MMRESULT acmFilterDetails([In, Optional] HACMDRIVER had, ref ACMFILTERDETAILS pafd, ACM_FILTERDETAILSF fdwDetails);
+
+ ///
+ /// The acmFilterEnum function enumerates waveform-audio filters available for a given filter tag from an ACM driver. This
+ /// function continues enumerating until there are no more suitable filters for the filter tag or the callback function returns FALSE.
+ ///
+ ///
+ /// Handle to the ACM driver to query for waveform-audio filter details. If this parameter is NULL, the ACM uses the details
+ /// from the first suitable ACM driver.
+ ///
+ ///
+ /// Pointer to the ACMFILTERDETAILS structure that contains the filter details when it is passed to the function specified by
+ /// fnCallback. When your application calls acmFilterEnum, the cbStruct, pwfltr, and cbwfltr members of
+ /// this structure must be initialized. The dwFilterTag member must also be initialized to either WAVE_FILTER_UNKNOWN or a
+ /// valid filter tag.
+ ///
+ /// Procedure-instance address of the application-defined callback function.
+ ///
+ /// A 32-bit (DWORD), 64-bit (DWORD_PTR) application-defined value that is passed to the callback function along with ACM filter details.
+ ///
+ ///
+ /// Flags for enumerating the filters for a given filter tag. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FILTERENUMF_DWFILTERTAG
+ ///
+ /// [ACMFILTERDETAILS](./nf-msacm-acmfilterdetails.md) structure is valid. The enumerator will enumerate only a filter that conforms
+ /// to this attribute. The dwFilterTag member of the ACMFILTERDETAILS structure must be equal to the dwFilterTag member of the
+ /// WAVEFILTER structure.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details for the filter cannot be returned.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The acmFilterEnum function will return MMSYSERR_NOERROR (zero) if no suitable ACM drivers are installed. Moreover, the
+ /// callback function will not be called.
+ ///
+ ///
+ /// The following functions should not be called from within the callback function: acmDriverAdd, acmDriverRemove, and acmDriverPriority.
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines acmFilterEnum 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/msacm/nf-msacm-acmfilterenumw MMRESULT ACMAPI acmFilterEnumW( HACMDRIVER had,
+ // LPACMFILTERDETAILSW pafd, ACMFILTERENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterEnumW")]
+ public static extern MMRESULT acmFilterEnum([In, Optional] HACMDRIVER had, ref ACMFILTERDETAILS pafd, [In] ACMFILTERENUMCB fnCallback, IntPtr dwInstance, ACM_FILTERENUMF fdwEnum);
+
+ /// The acmFilterTagDetails function queries the ACM for details about a specific waveform-audio filter tag.
+ ///
+ /// Handle to the ACM driver to query for waveform-audio filter tag details. If this parameter is NULL, the ACM uses the
+ /// details from the first suitable ACM driver. An application must specify a valid HACMDRIVER or HACMDRIVERID
+ /// identifier when using the ACM_FILTERTAGDETAILSF_INDEX query type. Driver identifiers for disabled drivers are not allowed.
+ ///
+ /// Pointer to the ACMFILTERTAGDETAILS structure that is to receive the filter tag details.
+ ///
+ /// Flags for getting the details. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FILTERTAGDETAILSF_FILTERTAG
+ ///
+ /// [ACMFILTERTAGDETAILS](./nf-msacm-acmfiltertagdetails.md) structure. The filter tag details will be returned in the structure
+ /// pointed to by paftd . If an application specifies an ACM driver handle for had , details on the filter tag will be returned for
+ /// that driver. If an application specifies NULL for had , the ACM finds the first acceptable driver to return the details.
+ ///
+ ///
+ /// -
+ /// ACM_FILTERTAGDETAILSF_INDEX
+ ///
+ /// [ACMDRIVERDETAILS](./nf-msacm-acmdriverdetails.md) structure for an ACM driver. An application must specify a driver handle for
+ /// had when retrieving filter tag details with this flag.
+ ///
+ ///
+ /// -
+ /// ACM_FILTERTAGDETAILSF_LARGESTSIZE
+ ///
+ /// Details on the filter tag with the largest filter size, in bytes, are to be returned. The dwFilterTag member must either be
+ /// WAVE_FILTER_UNKNOWN or the filter tag to find the largest size for. If an application specifies an ACM driver handle for had,
+ /// details on the largest filter tag will be returned for that driver. If an application specifies NULL for had, the ACM finds an
+ /// acceptable driver with the largest filter tag requested to return the details.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details requested are not available.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFILTERTAGDETAILS 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/msacm/nf-msacm-acmfiltertagdetailsw MMRESULT ACMAPI acmFilterTagDetailsW(
+ // HACMDRIVER had, LPACMFILTERTAGDETAILSW paftd, DWORD fdwDetails );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterTagDetailsW")]
+ public static extern MMRESULT acmFilterTagDetails([In, Optional] HACMDRIVER had, ref ACMFILTERTAGDETAILS paftd, ACM_FILTERTAGDETAILSF fdwDetails);
+
+ ///
+ /// The acmFilterTagEnum function enumerates waveform-audio filter tags available from an ACM driver. This function continues
+ /// enumerating until there are no more suitable filter tags or the callback function returns FALSE.
+ ///
+ ///
+ /// Handle to the ACM driver to query for waveform-audio filter tag details. If this parameter is NULL, the ACM uses the
+ /// details from the first suitable ACM driver.
+ ///
+ ///
+ /// Pointer to the ACMFILTERTAGDETAILS structure that contains the filter tag details when it is passed to the fnCallback
+ /// function. When your application calls acmFilterTagEnum, the cbStruct member of this structure must be initialized.
+ ///
+ /// Procedure instance address of the application-defined callback function.
+ ///
+ /// A 64-bit (DWORD_PTR) or 32-bit (DWORD) application-defined value that is passed to the callback function along with ACM filter
+ /// tag details.
+ ///
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function will return MMSYSERR_NOERROR (zero) if no suitable ACM drivers are installed. Moreover, the callback function will
+ /// not be called.
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines acmFilterTagEnum 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/msacm/nf-msacm-acmfiltertagenumw MMRESULT ACMAPI acmFilterTagEnumW( HACMDRIVER
+ // had, LPACMFILTERTAGDETAILSW paftd, ACMFILTERTAGENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFilterTagEnumW")]
+ public static extern MMRESULT acmFilterTagEnum([In, Optional] HACMDRIVER had, ref ACMFILTERTAGDETAILS paftd, ACMFILTERTAGENUMCB fnCallback, IntPtr dwInstance, uint fdwEnum);
+
+ ///
+ /// The acmFormatChoose function creates an ACM-defined dialog box that enables the user to select a waveform-audio format.
+ ///
+ ///
+ ///
+ /// Pointer to an ACMFORMATCHOOSE structure that contains information used to initialize the dialog box. When this function returns,
+ /// this structure contains information about the user's format selection.
+ ///
+ ///
+ /// The pwfx member of this structure must contain a valid pointer to a memory location that will contain the returned format
+ /// header structure. Moreover, the cbwfx member must be filled in with the size, in bytes, of this memory buffer.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible return values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_CANCELED
+ /// The user chose the Cancel button or the Close command on the System menu to close the dialog box.
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The buffer identified by the pwfx member of the ACMFORMATCHOOSE structure is too small to contain the selected format.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// A suitable driver is not available to provide valid format selections.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFORMATCHOOSE 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/msacm/nf-msacm-acmformatchoosew MMRESULT ACMAPI acmFormatChooseW(
+ // LPACMFORMATCHOOSEW pafmtc );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatChooseW")]
+ public static extern MMRESULT acmFormatChoose(ref ACMFORMATCHOOSE pafmtc);
+
+ /// The acmFormatDetails function queries the ACM for format details for a specific waveform-audio format tag.
+ ///
+ /// Handle to the ACM driver to query for waveform-audio format details for a format tag. If this parameter is NULL, the ACM
+ /// uses the details from the first suitable ACM driver.
+ ///
+ /// Pointer to an ACMFORMATDETAILS structure to contain the format details for the given format tag.
+ ///
+ /// Flags for getting the waveform-audio format tag details. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FORMATDETAILSF_FORMAT
+ ///
+ /// ACMFORMATDETAILS structure was given and the remaining details should be returned. The dwFormatTag member of the
+ /// ACMFORMATDETAILS structure must be initialized to the same format tag as pwfx specifies. This query type can be used to get a
+ /// string description of an arbitrary format structure. If an application specifies an ACM driver handle for had , details on the
+ /// format will be returned for that driver. If an application specifies NULL for had , the ACM finds the first acceptable driver to
+ /// return the details.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATDETAILSF_INDEX
+ ///
+ /// A format index for the format tag was given in the dwFormatIndex member of the ACMFORMATDETAILS structure. The format details
+ /// will be returned in the structure defined by pafd. The index ranges from zero to one less than the cStandardFormats member
+ /// returned in the ACMFORMATTAGDETAILS structure for a format tag. An application must specify a driver handle for had when
+ /// retrieving format details with this flag. For information about which members should be initialized before calling this
+ /// function, see the ACMFORMATDETAILS structure.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details requested are not available.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFORMATDETAILS 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/msacm/nf-msacm-acmformatdetailsw MMRESULT ACMAPI acmFormatDetailsW( HACMDRIVER
+ // had, LPACMFORMATDETAILSW pafd, DWORD fdwDetails );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatDetailsW")]
+ public static extern MMRESULT acmFormatDetails([In, Optional] HACMDRIVER had, ref ACMFORMATDETAILS pafd, ACM_FORMATDETAILSF fdwDetails);
+
+ ///
+ /// The acmFormatEnum function enumerates waveform-audio formats available for a given format tag from an ACM driver. This
+ /// function continues enumerating until there are no more suitable formats for the format tag or the callback function returns FALSE.
+ ///
+ ///
+ /// Handle to the ACM driver to query for waveform-audio format details. If this parameter is NULL, the ACM uses the details
+ /// from the first suitable ACM driver.
+ ///
+ ///
+ ///
+ /// Pointer to an ACMFORMATDETAILS structure to contain the format details passed to the fnCallback function. This structure
+ /// must have the cbStruct, pwfx, and cbwfx members of the ACMFORMATDETAILS structure initialized. The
+ /// dwFormatTag member must also be initialized to either WAVE_FORMAT_UNKNOWN or a valid format tag.
+ ///
+ /// The fdwSupport member of the structure must be initialized to zero.
+ /// To find the required size of the pwfx buffer, call acmMetrics with the ACM_METRIC_MAX_SIZE_FORMAT flag.
+ ///
+ ///
+ /// Address of an application-defined callback function. See acmFormatEnumCallback. This parameter cannot be NULL.
+ ///
+ ///
+ /// A 64-bit (DWORD_PTR) or 32-bit (DWORD) application-defined value that is passed to the callback function along with ACM format details.
+ ///
+ ///
+ /// Flags for enumerating the formats for a given format tag. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FORMATENUMF_CONVERT
+ ///
+ /// ACMFORMATDETAILS structure is valid. The enumerator will only enumerate destination formats that can be converted from the given
+ /// pwfx format.If this flag is used, the wFormatTag member of the WAVEFORMATEX structure cannot be WAVE_FORMAT_UNKNOWN.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_HARDWARE
+ ///
+ /// The enumerator should only enumerate formats that are supported as native input or output formats on one or more of the
+ /// installed waveform-audio devices. This flag provides a way for an application to choose only formats native to an installed
+ /// waveform-audio device. This flag must be used with one or both of the ACM_FORMATENUMF_INPUT and ACM_FORMATENUMF_OUTPUT flags.
+ /// Specifying both ACM_FORMATENUMF_INPUT and ACM_FORMATENUMF_OUTPUT will enumerate only formats that can be opened for input or
+ /// output. This is true regardless of whether this flag is specified.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_INPUT
+ /// Enumerator should enumerate only formats that are supported for input (recording).
+ ///
+ /// -
+ /// ACM_FORMATENUMF_NCHANNELS
+ /// ACMFORMATDETAILS structure is valid. The enumerator will enumerate only a format that conforms to this attribute.
+ ///
+ /// -
+ /// ACM_FORMATENUMF_NSAMPLESPERSEC
+ ///
+ /// The nSamplesPerSec member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is
+ /// valid. The enumerator will enumerate only a format that conforms to this attribute.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_OUTPUT
+ /// Enumerator should enumerate only formats that are supported for output (playback).
+ ///
+ /// -
+ /// ACM_FORMATENUMF_SUGGEST
+ ///
+ /// ACMFORMATDETAILS structure is valid. The enumerator will enumerate all suggested destination formats for the given pwfx format.
+ /// This mechanism can be used instead of the acmFormatSuggest function to allow an application to choose the best suggested format
+ /// for conversion. The dwFormatIndex member will always be set to zero on return.If this flag is used, the wFormatTag member of the
+ /// WAVEFORMATEX structure cannot be WAVE_FORMAT_UNKNOWN.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_WBITSPERSAMPLE
+ ///
+ /// The wBitsPerSample member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is
+ /// valid. The enumerator will enumerate only a format that conforms to this attribute.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_WFORMATTAG
+ ///
+ /// The wFormatTag member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid.
+ /// The enumerator will enumerate only a format that conforms to this attribute. The dwFormatTag member of the ACMFORMATDETAILS
+ /// structure must be equal to the wFormatTag member.The value of wFormatTag cannot be WAVE_FORMAT_UNKNOWN in this case.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details for the format cannot be returned.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function will return MMSYSERR_NOERROR (zero) if no suitable ACM drivers are installed. Moreover, the callback function will
+ /// not be called.
+ ///
+ /// Examples
+ /// The following example shows how to enumerate formats that have the WAVE_FORMAT_MPEGLAYER3 format tag.
+ ///
+ /// MMRESULT EnumerateMP3Codecs() { DWORD cbMaxSize = 0; MMRESULT result = MMSYSERR_NOERROR; ACMFORMATDETAILS acmFormatDetails; // Buffer to hold the format information. BYTE *pFormat = NULL; // Caller allocated. // Find the largest format buffer needed. result = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &cbMaxSize); if (result != MMSYSERR_NOERROR) { return result; } // Allocate the format buffer. pFormat = new BYTE[cbMaxSize]; if (pFormat == NULL) { return MMSYSERR_NOMEM; } ZeroMemory(pFormat, cbMaxSize); // Ask for WAVE_FORMAT_MPEGLAYER3 formats. WAVEFORMATEX* pWaveFormat = (WAVEFORMATEX*)pFormat; pWaveFormat->wFormatTag = WAVE_FORMAT_MPEGLAYER3; // Set up the acmFormatDetails structure. ZeroMemory(&acmFormatDetails, sizeof(acmFormatDetails)); acmFormatDetails.cbStruct = sizeof(ACMFORMATDETAILS); acmFormatDetails.pwfx = pWaveFormat; acmFormatDetails.cbwfx = cbMaxSize; // For the ACM_FORMATENUMF_WFORMATTAG request, the format // tag in acmFormatDetails must match the format tag in // the pFormat buffer. acmFormatDetails.dwFormatTag = WAVE_FORMAT_MPEGLAYER3; result = acmFormatEnum(NULL, &acmFormatDetails, acmFormatEnumCallback, 0, ACM_FORMATENUMF_WFORMATTAG); delete [] pFormat; return result; }
+ ///
+ ///
+ /// The next example shows the callback function for the previous example. The callback function is called once for each matching
+ /// format or until the callback returns FALSE.
+ ///
+ ///
+ /// BOOL CALLBACK acmFormatEnumCallback( HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport ) { BOOL bContinue = TRUE; MPEGLAYER3WAVEFORMAT *pMP3WaveFormat = NULL; if (pafd->pwfx->wFormatTag == WAVE_FORMAT_MPEGLAYER3) { pMP3WaveFormat = (MPEGLAYER3WAVEFORMAT*)pafd->pwfx; // TODO: Examine the format. // To halt the enumeration, set bContinue to FALSE. } return bContinue; }
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines acmFormatEnum 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/msacm/nf-msacm-acmformatenumw MMRESULT ACMAPI acmFormatEnumW( HACMDRIVER had,
+ // LPACMFORMATDETAILSW pafd, ACMFORMATENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatEnumW")]
+ public static extern MMRESULT acmFormatEnum([In, Optional] HACMDRIVER had, ref ACMFORMATDETAILS pafd, ACMFORMATENUMCB fnCallback, IntPtr dwInstance, ACM_FORMATENUMF fdwEnum);
+
+ ///
+ /// The acmFormatSuggest function queries the ACM or a specified ACM driver to suggest a destination format for the supplied
+ /// source format. For example, an application can use this function to determine one or more valid PCM formats to which a
+ /// compressed format can be decompressed.
+ ///
+ ///
+ /// Handle to an open instance of a driver to query for a suggested destination format. If this parameter is NULL, the ACM
+ /// attempts to find the best driver to suggest a destination format.
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the source format for which a destination format will be suggested by the
+ /// ACM or specified driver.
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that will receive the suggested destination format for the pwfxSrc format. Depending on the
+ /// fdwSuggest parameter, some members of the structure pointed to by pwfxDst may require initialization.
+ ///
+ ///
+ /// Size, in bytes, available for the destination format. The acmMetrics and acmFormatTagDetails functions can be used to determine
+ /// the maximum size required for any format available for the specified driver (or for all installed ACM drivers).
+ ///
+ ///
+ /// Flags for matching the desired destination format. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_NCHANNELS
+ ///
+ /// The nChannels member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that can
+ /// suggest a destination format matching nChannels or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_NSAMPLESPERSEC
+ ///
+ /// The nSamplesPerSec member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching nSamplesPerSec or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_WBITSPERSAMPLE
+ ///
+ /// The wBitsPerSample member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching wBitsPerSample or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_WFORMATTAG
+ ///
+ /// The wFormatTag member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that can
+ /// suggest a destination format matching wFormatTag or fail.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmformatsuggest MMRESULT ACMAPI acmFormatSuggest( HACMDRIVER
+ // had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatSuggest")]
+ public static extern MMRESULT acmFormatSuggest([In, Optional] HACMDRIVER had, in WAVEFORMATEX pwfxSrc, out WAVEFORMATEX pwfxDst, uint cbwfxDst, ACM_FORMATSUGGESTF fdwSuggest);
+
+ ///
+ /// The acmFormatSuggest function queries the ACM or a specified ACM driver to suggest a destination format for the supplied
+ /// source format. For example, an application can use this function to determine one or more valid PCM formats to which a
+ /// compressed format can be decompressed.
+ ///
+ ///
+ /// Handle to an open instance of a driver to query for a suggested destination format. If this parameter is NULL, the ACM
+ /// attempts to find the best driver to suggest a destination format.
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the source format for which a destination format will be suggested by the
+ /// ACM or specified driver.
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that will receive the suggested destination format for the pwfxSrc format. Depending on the
+ /// fdwSuggest parameter, some members of the structure pointed to by pwfxDst may require initialization.
+ ///
+ ///
+ /// Size, in bytes, available for the destination format. The acmMetrics and acmFormatTagDetails functions can be used to determine
+ /// the maximum size required for any format available for the specified driver (or for all installed ACM drivers).
+ ///
+ ///
+ /// Flags for matching the desired destination format. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_NCHANNELS
+ ///
+ /// The nChannels member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that can
+ /// suggest a destination format matching nChannels or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_NSAMPLESPERSEC
+ ///
+ /// The nSamplesPerSec member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching nSamplesPerSec or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_WBITSPERSAMPLE
+ ///
+ /// The wBitsPerSample member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that
+ /// can suggest a destination format matching wBitsPerSample or fail.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATSUGGESTF_WFORMATTAG
+ ///
+ /// The wFormatTag member of the structure pointed to by pwfxDst is valid. The ACM will query acceptable installed drivers that can
+ /// suggest a destination format matching wFormatTag or fail.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmformatsuggest MMRESULT ACMAPI acmFormatSuggest( HACMDRIVER
+ // had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatSuggest")]
+ public static extern MMRESULT acmFormatSuggest([In, Optional] HACMDRIVER had, in WAVEFORMATEX pwfxSrc, [Out] IntPtr pwfxDst, uint cbwfxDst, ACM_FORMATSUGGESTF fdwSuggest);
+
+ /// The acmFormatTagDetails function queries the ACM for details on a specific waveform-audio format tag.
+ ///
+ /// Handle to the ACM driver to query for waveform-audio format tag details. If this parameter is NULL, the ACM uses the
+ /// details from the first suitable ACM driver. An application must specify a valid handle or driver identifier when using the
+ /// ACM_FORMATTAGDETAILSF_INDEX query type. Driver identifiers for disabled drivers are not allowed.
+ ///
+ /// Pointer to the ACMFORMATTAGDETAILS structure that is to receive the format tag details.
+ ///
+ /// Flags for getting the details. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_FORMATTAGDETAILSF_FORMATTAG
+ ///
+ /// ACMFORMATTAGDETAILS structure. The format tag details will be returned in the structure pointed to bypaftd. If an application
+ /// specifies an ACM driver handle forhad, details on the format tag will be returned for that driver. If an application
+ /// specifiesNULLforhad, the ACM finds the first acceptable driver to return the details.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATTAGDETAILSF_INDEX
+ ///
+ /// ACMDRIVERDETAILS structure for an ACM driver. An application must specify a driver handle forhadwhen retrieving format tag
+ /// details with this flag.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATTAGDETAILSF_LARGESTSIZE
+ ///
+ /// ACMFORMATTAGDETAILS structure must either be WAVE_FORMAT_UNKNOWN or the format tag to find the largest size for. If an
+ /// application specifies an ACM driver handle forhad, details on the largest format tag will be returned for that driver. If an
+ /// application specifiesNULLforhad, the ACM finds an acceptable driver with the largest format tag requested to return the details.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The details requested are not available.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines ACMFORMATTAGDETAILS 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/msacm/nf-msacm-acmformattagdetailsw MMRESULT ACMAPI acmFormatTagDetailsW(
+ // HACMDRIVER had, LPACMFORMATTAGDETAILSW paftd, DWORD fdwDetails );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatTagDetailsW")]
+ public static extern MMRESULT acmFormatTagDetails([In, Optional] HACMDRIVER had, ref ACMFORMATTAGDETAILS paftd, ACM_FORMATTAGDETAILSF fdwDetails);
+
+ ///
+ /// The acmFormatTagEnum function enumerates waveform-audio format tags available from an ACM driver. This function continues
+ /// enumerating until there are no more suitable format tags or the callback function returns FALSE.
+ ///
+ ///
+ /// Handle to the ACM driver to query for waveform-audio format tag details. If this parameter is NULL, the ACM uses the
+ /// details from the first suitable ACM driver.
+ ///
+ ///
+ /// Pointer to the ACMFORMATTAGDETAILS structure that is to receive the format tag details passed to the function specified in
+ /// fnCallback. This structure must have the cbStruct member of the ACMFORMATTAGDETAILS structure initialized.
+ ///
+ /// Procedure instance address of the application-defined callback function.
+ ///
+ /// A 64-bit (DWORD_PTR) or 32-bit (DWORD) application-defined value that is passed to the callback function along with ACM format
+ /// tag details.
+ ///
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function will return MMSYSERR_NOERROR (zero) if no suitable ACM drivers are installed. Moreover, the callback function will
+ /// not be called.
+ ///
+ ///
+ /// Note
+ ///
+ /// The msacm.h header defines acmFormatTagEnum 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/msacm/nf-msacm-acmformattagenumw MMRESULT ACMAPI acmFormatTagEnumW( HACMDRIVER
+ // had, LPACMFORMATTAGDETAILSW paftd, ACMFORMATTAGENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum );
+ [DllImport(Lib_Msacm32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmFormatTagEnumW")]
+ public static extern MMRESULT acmFormatTagEnum([In, Optional] HACMDRIVER had, ref ACMFORMATTAGDETAILS paftd, ACMFORMATTAGENUMCB fnCallback, IntPtr dwInstance, uint fdwEnum = 0);
+
+ /// The acmGetVersion function returns the version number of the ACM.
+ ///
+ /// The version number is returned as a hexadecimal number of the form 0xAABBCCCC, where AA is the major version number, BB is the
+ /// minor version number, and CCCC is the build number.
+ ///
+ ///
+ ///
+ /// Win32 applications must verify that the ACM version is at least 0x03320000 (version 3.50) or greater before attempting to use
+ /// any other ACM functions. The build number (CCCC) is always zero for the retail (non-debug) version of the ACM.
+ ///
+ ///
+ /// To display the ACM version for a user, an application should use the following format (note that the values should be printed as
+ /// unsigned decimals):
+ ///
+ ///
+ /// { DWORD dw; TCHAR ach[10]; dw = acmGetVersion(); _stprintf_s(ach, TEXT("%u.%.02u"), HIWORD(dw) >> 8, HIWORD(dw) & 0x00FF); }
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmgetversion DWORD ACMAPI acmGetVersion();
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmGetVersion")]
+ public static extern uint acmGetVersion();
+
+ /// The acmMetrics function returns various metrics for the ACM or related ACM objects.
+ ///
+ /// Handle to the ACM object to query for the metric specified in uMetric. For some queries, this parameter can be NULL.
+ ///
+ ///
+ /// Metric index to be returned in pMetric.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_CODECS
+ ///
+ /// Returned value is the number of global ACM compressor or decompressor drivers in the system. The hao parameter must be NULL for
+ /// this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_CONVERTERS
+ ///
+ /// Returned value is the number of global ACM converter drivers in the system. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_DISABLED
+ ///
+ /// Returned value is the total number of global disabled ACM drivers (of all support types) in the system. The hao parameter must
+ /// be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value. The sum of the
+ /// ACM_METRIC_COUNT_DRIVERS and ACM_METRIC_COUNT_DISABLED metric indices is the total number of globally installed ACM drivers.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_DRIVERS
+ ///
+ /// Returned value is the total number of enabled global ACM drivers (of all support types) in the system. The hao parameter must be
+ /// NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_FILTERS
+ ///
+ /// Returned value is the number of global ACM filter drivers in the system. The hao parameter must be NULL for this metric index.
+ /// The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_HARDWARE
+ ///
+ /// Returned value is the number of global ACM hardware drivers in the system. The hao parameter must be NULL for this metric index.
+ /// The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_CODECS
+ ///
+ /// Returned value is the number of local ACM compressor drivers, ACM decompressor drivers, or both for the calling task. The hao
+ /// parameter must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_CONVERTERS
+ ///
+ /// Returned value is the number of local ACM converter drivers for the calling task. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_DISABLED
+ ///
+ /// Returned value is the total number of local disabled ACM drivers, of all support types, for the calling task. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value. The sum of
+ /// the ACM_METRIC_COUNT_LOCAL_DRIVERS and ACM_METRIC_COUNT_LOCAL_DISABLED metric indices is the total number of locally installed
+ /// ACM drivers.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_DRIVERS
+ ///
+ /// Returned value is the total number of enabled local ACM drivers (of all support types) for the calling task. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_FILTERS
+ ///
+ /// Returned value is the number of local ACM filter drivers for the calling task. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_DRIVER_PRIORITY
+ ///
+ /// Returned value is the current priority for the specified driver. The hao parameter must be a valid ACM driver identifier of the
+ /// HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_DRIVER_SUPPORT
+ ///
+ /// Returned value is the fdwSupport flags for the specified driver. The hao parameter must be a valid ACM driver identifier of the
+ /// HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_HARDWARE_WAVE_INPUT
+ ///
+ /// Returned value is the waveform-audio input device identifier associated with the specified driver. The hao parameter must be a
+ /// valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If no
+ /// waveform-audio input device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must point
+ /// to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_HARDWARE_WAVE_OUTPUT
+ ///
+ /// Returned value is the waveform-audio output device identifier associated with the specified driver. The hao parameter must be a
+ /// valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If no
+ /// waveform-audio output device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must point
+ /// to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_MAX_SIZE_FILTER
+ ///
+ /// Returned value is the size of the largest WAVEFILTER structure. If hao is NULL, the return value is the largest WAVEFILTER
+ /// structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an ACM driver
+ /// identifier of the HACMDRIVERID data type, the largest WAVEFILTER structure for that driver is returned. The pMetric parameter
+ /// must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream handle of the HACMSTREAM
+ /// data type.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_MAX_SIZE_FORMAT
+ ///
+ /// Returned value is the size of the largest WAVEFORMATEX structure. If hao is NULL, the return value is the largest WAVEFORMATEX
+ /// structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an ACM driver
+ /// identifier of the HACMDRIVERID data type, the largest WAVEFORMATEX structure for that driver is returned. The pMetric parameter
+ /// must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream handle of the HACMSTREAM
+ /// data type.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to the buffer to receive the metric details. The exact definition depends on the uMetric index.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The index specified in uMetric cannot be returned for the specified hao.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// The index specified in uMetric is not supported.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmmetrics MMRESULT ACMAPI acmMetrics( HACMOBJ hao, UINT
+ // uMetric, LPVOID pMetric );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmMetrics")]
+ public static extern MMRESULT acmMetrics([In, Optional] HACMOBJ hao, ACM_METRIC uMetric, [Out] IntPtr pMetric);
+
+ /// The acmMetrics function returns various metrics for the ACM or related ACM objects.
+ ///
+ /// Handle to the ACM object to query for the metric specified in uMetric. For some queries, this parameter can be NULL.
+ ///
+ ///
+ /// Metric index to be returned in pMetric.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_CODECS
+ ///
+ /// Returned value is the number of global ACM compressor or decompressor drivers in the system. The hao parameter must be NULL for
+ /// this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_CONVERTERS
+ ///
+ /// Returned value is the number of global ACM converter drivers in the system. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_DISABLED
+ ///
+ /// Returned value is the total number of global disabled ACM drivers (of all support types) in the system. The hao parameter must
+ /// be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value. The sum of the
+ /// ACM_METRIC_COUNT_DRIVERS and ACM_METRIC_COUNT_DISABLED metric indices is the total number of globally installed ACM drivers.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_DRIVERS
+ ///
+ /// Returned value is the total number of enabled global ACM drivers (of all support types) in the system. The hao parameter must be
+ /// NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_FILTERS
+ ///
+ /// Returned value is the number of global ACM filter drivers in the system. The hao parameter must be NULL for this metric index.
+ /// The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_HARDWARE
+ ///
+ /// Returned value is the number of global ACM hardware drivers in the system. The hao parameter must be NULL for this metric index.
+ /// The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_CODECS
+ ///
+ /// Returned value is the number of local ACM compressor drivers, ACM decompressor drivers, or both for the calling task. The hao
+ /// parameter must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_CONVERTERS
+ ///
+ /// Returned value is the number of local ACM converter drivers for the calling task. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_DISABLED
+ ///
+ /// Returned value is the total number of local disabled ACM drivers, of all support types, for the calling task. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value. The sum of
+ /// the ACM_METRIC_COUNT_LOCAL_DRIVERS and ACM_METRIC_COUNT_LOCAL_DISABLED metric indices is the total number of locally installed
+ /// ACM drivers.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_DRIVERS
+ ///
+ /// Returned value is the total number of enabled local ACM drivers (of all support types) for the calling task. The hao parameter
+ /// must be NULL for this metric index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_COUNT_LOCAL_FILTERS
+ ///
+ /// Returned value is the number of local ACM filter drivers for the calling task. The hao parameter must be NULL for this metric
+ /// index. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_DRIVER_PRIORITY
+ ///
+ /// Returned value is the current priority for the specified driver. The hao parameter must be a valid ACM driver identifier of the
+ /// HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_DRIVER_SUPPORT
+ ///
+ /// Returned value is the fdwSupport flags for the specified driver. The hao parameter must be a valid ACM driver identifier of the
+ /// HACMDRIVERID data type. The pMetric parameter must point to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_HARDWARE_WAVE_INPUT
+ ///
+ /// Returned value is the waveform-audio input device identifier associated with the specified driver. The hao parameter must be a
+ /// valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If no
+ /// waveform-audio input device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must point
+ /// to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_HARDWARE_WAVE_OUTPUT
+ ///
+ /// Returned value is the waveform-audio output device identifier associated with the specified driver. The hao parameter must be a
+ /// valid ACM driver identifier of the HACMDRIVERID data type that supports the ACMDRIVERDETAILS_SUPPORTF_HARDWARE flag. If no
+ /// waveform-audio output device is associated with the driver, MMSYSERR_NOTSUPPORTED is returned. The pMetric parameter must point
+ /// to a buffer of a size equal to a DWORD value.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_MAX_SIZE_FILTER
+ ///
+ /// Returned value is the size of the largest WAVEFILTER structure. If hao is NULL, the return value is the largest WAVEFILTER
+ /// structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an ACM driver
+ /// identifier of the HACMDRIVERID data type, the largest WAVEFILTER structure for that driver is returned. The pMetric parameter
+ /// must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream handle of the HACMSTREAM
+ /// data type.
+ ///
+ ///
+ /// -
+ /// ACM_METRIC_MAX_SIZE_FORMAT
+ ///
+ /// Returned value is the size of the largest WAVEFORMATEX structure. If hao is NULL, the return value is the largest WAVEFORMATEX
+ /// structure in the system. If hao identifies an open instance of an ACM driver of the HACMDRIVER data type or an ACM driver
+ /// identifier of the HACMDRIVERID data type, the largest WAVEFORMATEX structure for that driver is returned. The pMetric parameter
+ /// must point to a buffer of a size equal to a DWORD value. This metric is not allowed for an ACM stream handle of the HACMSTREAM
+ /// data type.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to the buffer to receive the metric details. The exact definition depends on the uMetric index.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The index specified in uMetric cannot be returned for the specified hao.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// The index specified in uMetric is not supported.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmmetrics MMRESULT ACMAPI acmMetrics( HACMOBJ hao, UINT
+ // uMetric, LPVOID pMetric );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmMetrics")]
+ public static extern MMRESULT acmMetrics([In, Optional] HACMOBJ hao, ACM_METRIC uMetric, out uint pMetric);
+
+ ///
+ /// The acmStreamClose function closes an ACM conversion stream. If the function is successful, the handle is invalidated.
+ ///
+ /// Handle to the open conversion stream to be closed.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_BUSY
+ /// The conversion stream cannot be closed because an asynchronous conversion is still in progress.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamclose MMRESULT ACMAPI acmStreamClose( HACMSTREAM has,
+ // DWORD fdwClose );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamClose")]
+ public static extern MMRESULT acmStreamClose(HACMSTREAM has, uint fdwClose = 0);
+
+ ///
+ /// The acmStreamConvert function requests the ACM to perform a conversion on the specified conversion stream. A conversion
+ /// may be synchronous or asynchronous, depending on how the stream was opened.
+ ///
+ /// Handle to the open conversion stream.
+ ///
+ /// Pointer to a stream header that describes source and destination buffers for a conversion. This header must have been prepared
+ /// previously by using the acmStreamPrepareHeader function.
+ ///
+ ///
+ /// Flags for doing the conversion. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_STREAMCONVERTF_BLOCKALIGN
+ ///
+ /// Only integral numbers of blocks will be converted. Converted data will end on block-aligned boundaries. An application should
+ /// use this flag for all conversions on a stream until there is not enough source data to convert to a block-aligned destination.
+ /// In this case, the last conversion should be specified without this flag.
+ ///
+ ///
+ /// -
+ /// ACM_STREAMCONVERTF_END
+ ///
+ /// ACM conversion stream should begin returning pending instance data. For example, if a conversion stream holds instance data,
+ /// such as the end of an echo filter operation, this flag will cause the stream to start returning this remaining data with
+ /// optional source data. This flag can be specified with the ACM_STREAMCONVERTF_START flag.
+ ///
+ ///
+ /// -
+ /// ACM_STREAMCONVERTF_START
+ ///
+ /// ACM conversion stream should reinitialize its instance data. For example, if a conversion stream holds instance data, such as
+ /// delta or predictor information, this flag will restore the stream to starting defaults. This flag can be specified with the
+ /// ACM_STREAMCONVERTF_END flag.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_BUSY
+ /// The stream header specified in pash is currently in use and cannot be reused.
+ ///
+ /// -
+ /// ACMERR_UNPREPARED
+ /// The stream header specified in pash is currently not prepared by the acmStreamPrepareHeader function.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// You must use the acmStreamPrepareHeader function to prepare the source and destination buffers before they are passed to acmStreamConvert.
+ ///
+ ///
+ /// If an asynchronous conversion request is successfully queued by the ACM or driver and the conversion is later determined to be
+ /// impossible, the ACMSTREAMHEADER structure is posted back to the application's callback function with the cbDstLengthUsed
+ /// member set to zero.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamconvert MMRESULT ACMAPI acmStreamConvert( HACMSTREAM
+ // has, LPACMSTREAMHEADER pash, DWORD fdwConvert );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamConvert")]
+ public static extern MMRESULT acmStreamConvert(HACMSTREAM has, ref ACMSTREAMHEADER pash, ACM_STREAMCONVERTF fdwConvert);
+
+ /// The acmStreamMessage function sends a driver-specific message to an ACM driver.
+ /// Handle to an open conversion stream.
+ /// Message to send.
+ /// Message parameter.
+ /// Message parameter.
+ /// Returns the value returned by the ACM device driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreammessage MMRESULT ACMAPI acmStreamMessage( HACMSTREAM
+ // has, UINT uMsg, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamMessage")]
+ public static extern MMRESULT acmStreamMessage(HACMSTREAM has, uint uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// The acmStreamOpen function opens an ACM conversion stream. Conversion streams are used to convert data from one specified
+ /// audio format to another.
+ ///
+ ///
+ /// Pointer to a handle that will receive the new stream handle that can be used to perform conversions. This handle is used to
+ /// identify the stream in calls to other ACM stream conversion functions. If the ACM_STREAMOPENF_QUERY flag is specified, this
+ /// parameter should be NULL.
+ ///
+ ///
+ /// Handle to an ACM driver. If this handle is specified, it identifies a specific driver to be used for a conversion stream. If
+ /// this parameter is NULL, all suitable installed ACM drivers are queried until a match is found.
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the desired source format for the conversion.
+ /// Pointer to a WAVEFORMATEX structure that identifies the desired destination format for the conversion.
+ ///
+ /// Pointer to a WAVEFILTER structure that identifies the desired filtering operation to perform on the conversion stream. If no
+ /// filtering operation is desired, this parameter can be NULL. If a filter is specified, the source (pwfxSrc) and
+ /// destination (pwfxDst) formats must be the same.
+ ///
+ ///
+ /// Pointer to a callback function, a handle of a window, or a handle of an event. A callback function will be called only if the
+ /// conversion stream is opened with the ACM_STREAMOPENF_ASYNC flag. A callback function is notified when the conversion stream is
+ /// opened or closed and after each buffer is converted. If the conversion stream is opened without the ACM_STREAMOPENF_ASYNC flag,
+ /// this parameter should be set to zero.
+ ///
+ ///
+ /// User-instance data passed to the callback function specified by the dwCallback parameter. This parameter is not used with window
+ /// and event callbacks. If the conversion stream is opened without the ACM_STREAMOPENF_ASYNC flag, this parameter should be set to zero.
+ ///
+ ///
+ /// Flags for opening the conversion stream. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_STREAMOPENF_ASYNC
+ /// ACMSTREAMHEADER structure for the ACMSTREAMHEADER_STATUSF_DONE flag.
+ ///
+ /// -
+ /// ACM_STREAMOPENF_NONREALTIME
+ ///
+ /// ACM will not consider time constraints when converting the data. By default, the driver will attempt to convert the data in real
+ /// time. For some formats, specifying this flag might improve the audio quality or other characteristics.
+ ///
+ ///
+ /// -
+ /// ACM_STREAMOPENF_QUERY
+ ///
+ /// ACM will be queried to determine whether it supports the given conversion. A conversion stream will not be opened, and no handle
+ /// will be returned in the phas parameter.
+ ///
+ ///
+ /// -
+ /// CALLBACK_EVENT
+ /// The dwCallback parameter is a handle of an event.
+ ///
+ /// -
+ /// CALLBACK_FUNCTION
+ ///
+ /// The dwCallback parameter is a callback procedure address. The function prototype must conform to the acmStreamConvertCallback prototype.
+ ///
+ ///
+ /// -
+ /// CALLBACK_WINDOW
+ /// The dwCallback parameter is a window handle.
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The requested operation cannot be performed.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// The system is unable to allocate resources.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If an ACM driver cannot perform real-time conversions and the ACM_STREAMOPENF_NONREALTIME flag is not specified for the fdwOpen
+ /// parameter, the open operation will fail returning an ACMERR_NOTPOSSIBLE error code. An application can use the
+ /// ACM_STREAMOPENF_QUERY flag to determine if real-time conversions are supported for input.
+ ///
+ ///
+ /// If an application uses a window to receive callback information, the MM_ACM_OPEN, MM_ACM_CLOSE, and MM_ACM_DONE messages are
+ /// sent to the window procedure function to indicate the progress of the conversion stream. In this case, the ACMSTREAMHEADER
+ /// structure for MM_ACM_DONE, but it is not used for MM_ACM_OPEN and MM_ACM_CLOSE.
+ ///
+ ///
+ /// If an application uses a function to receive callback information, the MM_ACM_OPEN, MM_ACM_CLOSE, and MM_ACM_DONE messages are
+ /// sent to the function to indicate the progress of waveform-audio output. The callback function must reside in a dynamic-link
+ /// library (DLL).
+ ///
+ ///
+ /// If an application uses an event for callback notification, the event is signaled to indicate the progress of the conversion
+ /// stream. The event will be signaled when a stream is opened, after each buffer is converted, and when the stream is closed.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamopen MMRESULT ACMAPI acmStreamOpen( LPHACMSTREAM phas,
+ // HACMDRIVER had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, LPWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance,
+ // DWORD fdwOpen );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamOpen")]
+ public static extern MMRESULT acmStreamOpen(out SafeHACMSTREAM phas, [In, Optional] HACMDRIVER had, in WAVEFORMATEX pwfxSrc, in WAVEFORMATEX pwfxDst, in WAVEFILTER pwfltr, IntPtr dwCallback, IntPtr dwInstance, ACM_STREAMOPENF fdwOpen);
+
+ ///
+ /// The acmStreamOpen function opens an ACM conversion stream. Conversion streams are used to convert data from one specified
+ /// audio format to another.
+ ///
+ ///
+ /// Pointer to a handle that will receive the new stream handle that can be used to perform conversions. This handle is used to
+ /// identify the stream in calls to other ACM stream conversion functions. If the ACM_STREAMOPENF_QUERY flag is specified, this
+ /// parameter should be NULL.
+ ///
+ ///
+ /// Handle to an ACM driver. If this handle is specified, it identifies a specific driver to be used for a conversion stream. If
+ /// this parameter is NULL, all suitable installed ACM drivers are queried until a match is found.
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the desired source format for the conversion.
+ /// Pointer to a WAVEFORMATEX structure that identifies the desired destination format for the conversion.
+ ///
+ /// Pointer to a WAVEFILTER structure that identifies the desired filtering operation to perform on the conversion stream. If no
+ /// filtering operation is desired, this parameter can be NULL. If a filter is specified, the source (pwfxSrc) and
+ /// destination (pwfxDst) formats must be the same.
+ ///
+ ///
+ /// Pointer to a callback function, a handle of a window, or a handle of an event. A callback function will be called only if the
+ /// conversion stream is opened with the ACM_STREAMOPENF_ASYNC flag. A callback function is notified when the conversion stream is
+ /// opened or closed and after each buffer is converted. If the conversion stream is opened without the ACM_STREAMOPENF_ASYNC flag,
+ /// this parameter should be set to zero.
+ ///
+ ///
+ /// User-instance data passed to the callback function specified by the dwCallback parameter. This parameter is not used with window
+ /// and event callbacks. If the conversion stream is opened without the ACM_STREAMOPENF_ASYNC flag, this parameter should be set to zero.
+ ///
+ ///
+ /// Flags for opening the conversion stream. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_STREAMOPENF_ASYNC
+ /// ACMSTREAMHEADER structure for the ACMSTREAMHEADER_STATUSF_DONE flag.
+ ///
+ /// -
+ /// ACM_STREAMOPENF_NONREALTIME
+ ///
+ /// ACM will not consider time constraints when converting the data. By default, the driver will attempt to convert the data in real
+ /// time. For some formats, specifying this flag might improve the audio quality or other characteristics.
+ ///
+ ///
+ /// -
+ /// ACM_STREAMOPENF_QUERY
+ ///
+ /// ACM will be queried to determine whether it supports the given conversion. A conversion stream will not be opened, and no handle
+ /// will be returned in the phas parameter.
+ ///
+ ///
+ /// -
+ /// CALLBACK_EVENT
+ /// The dwCallback parameter is a handle of an event.
+ ///
+ /// -
+ /// CALLBACK_FUNCTION
+ ///
+ /// The dwCallback parameter is a callback procedure address. The function prototype must conform to the acmStreamConvertCallback prototype.
+ ///
+ ///
+ /// -
+ /// CALLBACK_WINDOW
+ /// The dwCallback parameter is a window handle.
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The requested operation cannot be performed.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// The system is unable to allocate resources.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If an ACM driver cannot perform real-time conversions and the ACM_STREAMOPENF_NONREALTIME flag is not specified for the fdwOpen
+ /// parameter, the open operation will fail returning an ACMERR_NOTPOSSIBLE error code. An application can use the
+ /// ACM_STREAMOPENF_QUERY flag to determine if real-time conversions are supported for input.
+ ///
+ ///
+ /// If an application uses a window to receive callback information, the MM_ACM_OPEN, MM_ACM_CLOSE, and MM_ACM_DONE messages are
+ /// sent to the window procedure function to indicate the progress of the conversion stream. In this case, the ACMSTREAMHEADER
+ /// structure for MM_ACM_DONE, but it is not used for MM_ACM_OPEN and MM_ACM_CLOSE.
+ ///
+ ///
+ /// If an application uses a function to receive callback information, the MM_ACM_OPEN, MM_ACM_CLOSE, and MM_ACM_DONE messages are
+ /// sent to the function to indicate the progress of waveform-audio output. The callback function must reside in a dynamic-link
+ /// library (DLL).
+ ///
+ ///
+ /// If an application uses an event for callback notification, the event is signaled to indicate the progress of the conversion
+ /// stream. The event will be signaled when a stream is opened, after each buffer is converted, and when the stream is closed.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamopen MMRESULT ACMAPI acmStreamOpen( LPHACMSTREAM phas,
+ // HACMDRIVER had, LPWAVEFORMATEX pwfxSrc, LPWAVEFORMATEX pwfxDst, LPWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance,
+ // DWORD fdwOpen );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamOpen")]
+ public static extern MMRESULT acmStreamOpen(out SafeHACMSTREAM phas, [In, Optional] HACMDRIVER had, in WAVEFORMATEX pwfxSrc, in WAVEFORMATEX pwfxDst, [In, Optional] IntPtr pwfltr, IntPtr dwCallback, IntPtr dwInstance, ACM_STREAMOPENF fdwOpen);
+
+ ///
+ /// The ACMSTREAMHEADER structure for an ACM stream conversion. This function must be called for every stream header before it can
+ /// be used in a conversion stream. An application needs to prepare a stream header only once for the life of a given stream. The
+ /// stream header can be reused as long as the sizes of the source and destination buffers do not exceed the sizes used when the
+ /// stream header was originally prepared.
+ ///
+ /// Handle to the conversion steam.
+ /// Pointer to an ACMSTREAMHEADER structure that identifies the source and destination buffers to be prepared.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// The system is unable to allocate resources.
+ ///
+ ///
+ ///
+ ///
+ /// Preparing a stream header that has already been prepared has no effect, and the function returns zero. Nevertheless, you should
+ /// ensure your application does not prepare a stream header multiple times.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamprepareheader MMRESULT ACMAPI acmStreamPrepareHeader(
+ // HACMSTREAM has, LPACMSTREAMHEADER pash, DWORD fdwPrepare );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamPrepareHeader")]
+ public static extern MMRESULT acmStreamPrepareHeader(HACMSTREAM has, ref ACMSTREAMHEADER pash, uint fdwPrepare = 0);
+
+ ///
+ /// The acmStreamReset function stops conversions for a given ACM stream. All pending buffers are marked as done and returned
+ /// to the application.
+ ///
+ /// Handle to the conversion stream.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// Resetting an ACM conversion stream is necessary only for asynchronous conversion streams. Resetting a synchronous conversion
+ /// stream will succeed, but no action will be taken.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamreset MMRESULT ACMAPI acmStreamReset( HACMSTREAM has,
+ // DWORD fdwReset );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamReset")]
+ public static extern MMRESULT acmStreamReset(HACMSTREAM has, uint fdwReset = 0);
+
+ /// The acmStreamSize function returns a recommended size for a source or destination buffer on an ACM stream.
+ /// Handle to the conversion stream.
+ ///
+ /// Size, in bytes, of the source or destination buffer. The fdwSize flags specify what the input parameter defines. This parameter
+ /// must be nonzero.
+ ///
+ ///
+ /// Pointer to a variable that contains the size, in bytes, of the source or destination buffer. The fdwSize flags specify what the
+ /// output parameter defines. If the acmStreamSize function succeeds, this location will always be filled with a nonzero value.
+ ///
+ ///
+ /// Flags for the stream size query. The following values are defined:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ACM_STREAMSIZEF_DESTINATION
+ ///
+ /// The cbInput parameter contains the size of the destination buffer. The pdwOutputBytes parameter will receive the recommended
+ /// source buffer size, in bytes.
+ ///
+ ///
+ /// -
+ /// ACM_STREAMSIZEF_SOURCE
+ ///
+ /// The cbInput parameter contains the size of the source buffer. The pdwOutputBytes parameter will receive the recommended
+ /// destination buffer size, in bytes.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_NOTPOSSIBLE
+ /// The requested operation cannot be performed.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// An application can use this function to determine suggested buffer sizes for either source or destination buffers. The buffer
+ /// sizes returned might be only an estimation of the actual sizes required for conversion. Because actual conversion sizes cannot
+ /// always be determined without performing the conversion, the sizes returned will usually be overestimated.
+ ///
+ ///
+ /// In the event of an error, the location pointed to by pdwOutputBytes will receive zero. This assumes that the pointer specified
+ /// by pdwOutputBytes is valid.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamsize MMRESULT ACMAPI acmStreamSize( HACMSTREAM has,
+ // DWORD cbInput, LPDWORD pdwOutputBytes, DWORD fdwSize );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamSize")]
+ public static extern MMRESULT acmStreamSize(HACMSTREAM has, uint cbInput, out uint pdwOutputBytes, ACM_STREAMSIZEF fdwSize);
+
+ ///
+ /// The acmStreamUnprepareHeader function cleans up the preparation performed by the acmStreamPrepareHeader function for an
+ /// ACM stream. This function must be called after the ACM is finished with the given buffers. An application must call this
+ /// function before freeing the source and destination buffers.
+ ///
+ /// Handle to the conversion steam.
+ /// Pointer to an ACMSTREAMHEADER structure that identifies the source and destination buffers to be unprepared.
+ /// Reserved; must be zero.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ACMERR_BUSY
+ /// The stream header specified in pash is currently in use and cannot be unprepared.
+ ///
+ /// -
+ /// ACMERR_UNPREPARED
+ /// The stream header specified in pash is currently not prepared by the acmStreamPrepareHeader function.
+ ///
+ /// -
+ /// MMSYSERR_INVALFLAG
+ /// At least one flag is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The specified handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_INVALPARAM
+ /// At least one parameter is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Unpreparing a stream header that has already been unprepared is an error. An application must specify the source and destination
+ /// buffer lengths ( cbSrcLength and cbDstLength, respectively) that were used during a call to the corresponding
+ /// acmStreamPrepareHeader. Failing to reset these member values will cause acmStreamUnprepareHeader to fail with an
+ /// MMSYSERR_INVALPARAM error.
+ ///
+ ///
+ /// The ACM can recover from some errors. The ACM will return a nonzero error, yet the stream header will be properly unprepared. To
+ /// determine whether the stream header was actually unprepared, an application can examine the ACMSTREAMHEADER_STATUSF_PREPARED
+ /// flag. If acmStreamUnprepareHeader returns success, the header will always be unprepared.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/nf-msacm-acmstreamunprepareheader MMRESULT ACMAPI
+ // acmStreamUnprepareHeader( HACMSTREAM has, LPACMSTREAMHEADER pash, DWORD fdwUnprepare );
+ [DllImport(Lib_Msacm32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("msacm.h", MSDNShortId = "NF:msacm.acmStreamUnprepareHeader")]
+ public static extern MMRESULT acmStreamUnprepareHeader(HACMSTREAM has, ref ACMSTREAMHEADER pash, uint fdwUnprepare = 0);
+
+ /// The ACMDRIVERDETAILS structure describes the features of an ACM driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmdriverdetails typedef struct tACMDRIVERDETAILS { DWORD
+ // cbStruct; FOURCC fccType; FOURCC fccComp; WORD wMid; WORD wPid; DWORD vdwACM; DWORD vdwDriver; DWORD fdwSupport; DWORD
+ // cFormatTags; DWORD cFilterTags; HICON hicon; char szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS]; char
+ // szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS]; char szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS]; char
+ // szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS]; char szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS]; } ACMDRIVERDETAILS,
+ // *PACMDRIVERDETAILS, *LPACMDRIVERDETAILS;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMDRIVERDETAILS")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMDRIVERDETAILS
+ {
+ private const int ACMDRIVERDETAILS_SHORTNAME_CHARS = 32;
+ private const int ACMDRIVERDETAILS_LONGNAME_CHARS = 128;
+ private const int ACMDRIVERDETAILS_COPYRIGHT_CHARS = 80;
+ private const int ACMDRIVERDETAILS_LICENSING_CHARS = 128;
+ private const int ACMDRIVERDETAILS_FEATURES_CHARS = 512;
+
+ ///
+ /// Size, in bytes, of the valid information contained in the ACMDRIVERDETAILS structure. An application should
+ /// initialize this member to the size, in bytes, of the desired information. The size specified in this member must be large
+ /// enough to contain the cbStruct member of the ACMDRIVERDETAILS structure. When the acmDriverDetails function
+ /// returns, this member contains the actual size of the information returned. The returned information will never exceed the
+ /// requested size.
+ ///
+ public uint cbStruct;
+
+ /// Type of the driver. For ACM drivers, set this member to ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC.
+ public uint fccType;
+
+ /// Subtype of the driver. This member is currently set to ACMDRIVERDETAILS_FCCCOMP_UNDEFINED (zero).
+ public uint fccComp;
+
+ /// Manufacturer identifier. Manufacturer identifiers are defined in Manufacturer and Product Identifiers.
+ public ushort wMid;
+
+ /// Product identifier. Product identifiers are defined in Manufacturer and Product Identifiers.
+ public ushort wPid;
+
+ ///
+ /// Version of the ACM for which this driver was compiled. The version number is a hexadecimal number in the format 0xAABBCCCC,
+ /// where AA is the major version number, BB is the minor version number, and CCCC is the build number. The version parts
+ /// (major, minor, and build) should be displayed as decimal numbers.
+ ///
+ public uint vdwACM;
+
+ ///
+ /// Version of the driver. The version number is a hexadecimal number in the format 0xAABBCCCC, where AA is the major version
+ /// number, BB is the minor version number, and CCCC is the build number. The version parts (major, minor, and build) should be
+ /// displayed as decimal numbers.
+ ///
+ public uint vdwDriver;
+
+ ///
+ /// Support flags for the driver. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags. For example, if a driver supports compression from
+ /// WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag. For example, if a driver supports
+ /// resampling of WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_DISABLED
+ ///
+ /// Driver has been disabled. This flag is set by the ACM for a driver when it has been disabled for any of a number of reasons.
+ /// Disabled drivers cannot be opened and can be used only under very limited circumstances.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both through a waveform-audio device. An application should use the acmMetrics
+ /// function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indexes to get the
+ /// waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_LOCAL
+ /// The driver has been installed locally with respect to the current task.
+ ///
+ ///
+ ///
+ public ACMDRIVERDETAILS_SUPPORTF fdwSupport;
+
+ /// Number of unique format tags supported by this driver.
+ public uint cFormatTags;
+
+ /// Number of unique filter tags supported by this driver.
+ public uint cFilterTags;
+
+ ///
+ /// Handle to a custom icon for this driver. An application can use this icon for referencing the driver visually. This member
+ /// can be NULL.
+ ///
+ public HICON hicon;
+
+ ///
+ /// Null-terminated string that describes the name of the driver. This string is intended to be displayed in small spaces.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMDRIVERDETAILS_SHORTNAME_CHARS)]
+ public string szShortName;
+
+ ///
+ /// Null-terminated string that describes the full name of the driver. This string is intended to be displayed in large
+ /// (descriptive) spaces.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMDRIVERDETAILS_LONGNAME_CHARS)]
+ public string szLongName;
+
+ /// Null-terminated string that provides copyright information for the driver.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMDRIVERDETAILS_COPYRIGHT_CHARS)]
+ public string szCopyright;
+
+ /// Null-terminated string that provides special licensing information for the driver.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMDRIVERDETAILS_LICENSING_CHARS)]
+ public string szLicensing;
+
+ /// Null-terminated string that provides special feature information for the driver.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMDRIVERDETAILS_FEATURES_CHARS)]
+ public string szFeatures;
+ }
+
+ ///
+ /// The ACMFILTERCHOOSE structure contains information the ACM uses to initialize the system-defined waveform-audio filter
+ /// selection dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmfilterchoose typedef struct tACMFILTERCHOOSE { DWORD
+ // cbStruct; DWORD fdwStyle; HWND hwndOwner; LPWAVEFILTER pwfltr; DWORD cbwfltr; LPCSTR pszTitle; char
+ // szFilterTag[ACMFILTERTAGDETAILS_FILTERTAG_CHARS]; char szFilter[ACMFILTERDETAILS_FILTER_CHARS]; LPSTR pszName; DWORD cchName;
+ // DWORD fdwEnum; LPWAVEFILTER pwfltrEnum; HINSTANCE hInstance; LPCSTR pszTemplateName; LPARAM lCustData; ACMFILTERCHOOSEHOOKPROC
+ // pfnHook; } ACMFILTERCHOOSE, *PACMFILTERCHOOSE, *LPACMFILTERCHOOSE;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFILTERCHOOSE")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFILTERCHOOSE
+ {
+ ///
+ /// Size, in bytes, of the ACMFILTERCHOOSE structure. This member must be initialized before an application calls the
+ /// acmFilterChoose function. The size specified in this member must be large enough to contain the base ACMFILTERCHOOSE structure.
+ ///
+ public uint cbStruct;
+
+ ///
+ ///
+ /// Optional style flags for the acmFilterChoose function. This member must be initialized to a valid combination of the
+ /// following flags before an application calls the acmFilterChoose function. The following values are defined:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_CONTEXTHELP
+ ///
+ /// Context-sensitive help will be available in the dialog box. To use this feature, an application must register the
+ /// ACMHELPMSGCONTEXTMENU and ACMHELPMSGCONTEXTHELP constants, using the RegisterWindowMessage function. When the user invokes
+ /// help, the registered message will be posted to the owning window. The message will contain the wParam and lParam parameters
+ /// from the original WM_CONTEXTMENU or WM_CONTEXTHELP message.
+ ///
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_ENABLEHOOK
+ ///
+ /// Enables the hook function specified in the pfnHook member. An application can use hook functions for a variety of
+ /// customizations, including answering the MM_ACM_FILTERCHOOSE message.
+ ///
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE
+ /// Causes the ACM to create the dialog box template identified by the hInstance and pszTemplateName members.
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE
+ ///
+ /// The hInstance member identifies a data block that contains a preloaded dialog box template. If this flag is specified, the
+ /// ACM ignores the pszTemplateName member.
+ ///
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT
+ ///
+ /// The buffer pointed to by pwfltr contains a valid WAVEFILTER structure that the dialog box will use as the initial selection.
+ ///
+ ///
+ /// -
+ /// ACMFILTERCHOOSE_STYLEF_SHOWHELP
+ ///
+ /// A help button will appear in the dialog box. To use a custom Help file, an application must register the ACMHELPMSGSTRING
+ /// value with the RegisterWindowMessage function. When the user presses the help button, the registered message is posted to
+ /// the owner.
+ ///
+ ///
+ ///
+ ///
+ public ACMFILTERCHOOSE_STYLEF fdwStyle;
+
+ ///
+ /// Handle to the window that owns the dialog box. This member can be any valid window handle or NULL if the dialog box
+ /// has no owner. This member must be initialized before calling the acmFilterChoose function.
+ ///
+ public HWND hwndOwner;
+
+ ///
+ /// Pointer to a WAVEFILTER structure. If the ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT flag is specified in the fdwStyle
+ /// member, this structure must be initialized to a valid filter. When the acmFilterChoose function returns, this buffer
+ /// contains the selected filter. If the user cancels the dialog box, no changes will be made to this buffer.
+ ///
+ public IntPtr pwfltr;
+
+ ///
+ /// Size, in bytes, of the buffer pointed to by the pwfltr member. The acmFilterChoose function returns
+ /// ACMERR_NOTPOSSIBLE if the buffer is too small to contain the filter information; the ACM also copies the required size into
+ /// this member. An application can use the acmMetrics and acmFilterTagDetails functions to determine the largest size required
+ /// for this buffer.
+ ///
+ public uint cbwfltr;
+
+ ///
+ /// Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the ACM uses the default
+ /// title (that is, "Filter Selection").
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string pszTitle;
+
+ ///
+ /// Buffer containing a null-terminated string describing the filter tag of the filter selection when the ACMFILTERTAGDETAILS
+ /// structure returned by acmFilterTagDetails. If the user cancels the dialog box, this member will contain a null-terminated string.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFILTERTAGDETAILS_FILTERTAG_CHARS)]
+ public string szFilterTag;
+
+ ///
+ /// Buffer containing a null-terminated string describing the filter attributes of the filter selection when the
+ /// ACMFILTERDETAILS structure returned by acmFilterDetails. If the user cancels the dialog box, this member will contain a
+ /// null-terminated string.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFILTERDETAILS_FILTER_CHARS)]
+ public string szFilter;
+
+ ///
+ ///
+ /// Pointer to a string for a user-defined filter name. If this is a non-null-terminated string, the ACM attempts to match the
+ /// name with a previously saved user-defined filter name. If a match is found, the dialog box is initialized to that filter. If
+ /// a match is not found or this member is a null-terminated string, this member is ignored for input. When the acmFilterChoose
+ /// function returns, this buffer contains a null-terminated string describing the user-defined filter. If the filter name is
+ /// untitled (that is, the user has not given a name for the filter), this member will be a null-terminated string on return. If
+ /// the user cancels the dialog box, no changes will be made to this buffer.
+ ///
+ ///
+ /// If the ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT flag is specified by the fdwStyle member, the pszName member
+ /// is ignored as an input member.
+ ///
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string pszName;
+
+ ///
+ /// Size, in characters, of the buffer identified by the pszName member. This buffer should be at least 128 characters
+ /// long. If pszName is NULL, this member is ignored.
+ ///
+ public uint cchName;
+
+ ///
+ ///
+ /// Optional flags for restricting the type of filters listed in the dialog box. These flags are identical to the fdwEnum flags
+ /// for the acmFilterEnum function. If pwfltrEnum is NULL, this member should be zero.
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACM_FILTERENUMF_DWFILTERTAG
+ ///
+ /// The dwFilterTag member of the WAVEFILTER structure pointed to by the pwfltrEnum member is valid. The enumerator will only
+ /// enumerate a filter that conforms to this attribute.
+ ///
+ ///
+ ///
+ ///
+ public ACM_FILTERENUMF fdwEnum;
+
+ ///
+ /// Pointer to a WAVEFILTER structure that will be used to restrict the filters listed in the dialog box. The fdwEnum
+ /// member defines which members of this structure should be used for the enumeration restrictions. The cbStruct member
+ /// of this WAVEFILTER structure must be initialized to the size of the WAVEFILTER structure. If no special
+ /// restrictions are desired, this member can be NULL.
+ ///
+ public IntPtr pwfltrEnum;
+
+ ///
+ /// Handle to a data block that contains a dialog box template specified by the pszTemplateName member. This member is
+ /// used only if the fdwStyle member specifies the ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE or
+ /// ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE flag; otherwise, this member should be NULL on input.
+ ///
+ public HINSTANCE hInstance;
+
+ ///
+ /// Pointer to a null-terminated string that specifies the name of the resource file for the dialog box template that is to be
+ /// substituted for the dialog box template in the ACM. An application can use the MAKEINTRESOURCE macro for numbered dialog box
+ /// resources. This member is used only if the fdwStyle member specifies the ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE flag;
+ /// otherwise, this member should be NULL on input.
+ ///
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string pszTemplateName;
+
+ ///
+ /// Application-defined data that the ACM passes to the hook function identified by the pfnHook member. The system passes
+ /// the data in the lParam parameter of the WM_INITDIALOG message.
+ ///
+ public IntPtr lCustData;
+
+ ///
+ /// Pointer to a callback function that processes messages intended for the dialog box. An application must specify the
+ /// ACMFILTERCHOOSE_STYLEF_ENABLEHOOK flag in the fdwStyle member to enable the hook; otherwise, this member should be
+ /// NULL. The hook function should return FALSE to pass a message to the standard dialog box procedure or
+ /// TRUE to discard the message. The callback function type is acmFilterChooseHookProc.
+ ///
+ public ACMFILTERCHOOSEHOOKPROC pfnHook;
+ }
+
+ /// The ACMFILTERDETAILS structure details a waveform-audio filter for a specific filter tag for an ACM driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmfilterdetails typedef struct tACMFILTERDETAILS { DWORD
+ // cbStruct; DWORD dwFilterIndex; DWORD dwFilterTag; DWORD fdwSupport; LPWAVEFILTER pwfltr; DWORD cbwfltr; char
+ // szFilter[ACMFILTERDETAILS_FILTER_CHARS]; } ACMFILTERDETAILS, *PACMFILTERDETAILS, *LPACMFILTERDETAILS;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFILTERDETAILS")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFILTERDETAILS
+ {
+ ///
+ /// Size, in bytes, of the ACMFILTERDETAILS structure. This member must be initialized before calling the
+ /// acmFilterDetails or acmFilterEnum functions. The size specified in this member must be large enough to contain the base
+ /// ACMFILTERDETAILS structure. When the acmFilterDetails function returns, this member contains the actual size
+ /// of the information returned. The returned information will never exceed the requested size.
+ ///
+ public uint cbStruct;
+
+ ///
+ /// Index of the filter about which details will be retrieved. The index ranges from zero to one less than the number of
+ /// standard filters supported by an ACM driver for a filter tag. The number of standard filters supported by a driver for a
+ /// filter tag is contained in the ACMFILTERTAGDETAILS structure. The dwFilterIndex member is used only when querying
+ /// standard filter details about a driver by index; otherwise, this member should be zero. Also, this member will be set to
+ /// zero by the ACM when an application queries for details on a filter; in other words, this member is used only for input and
+ /// is never returned by the ACM or an ACM driver.
+ ///
+ public uint dwFilterIndex;
+
+ ///
+ /// Waveform-audio filter tag that the ACMFILTERDETAILS structure describes. This member is used as an input for the
+ /// ACM_FILTERDETAILSF_INDEX query flag. For the ACM_FILTERDETAILSF_FORMAT query flag, this member must be initialized to the
+ /// same filter tag as the pwfltr member specifies. If the acmFilterDetails function is successful, this member is always
+ /// returned. This member should be set to WAVE_FILTER_UNKNOWN for all other query flags.
+ ///
+ public uint dwFilterTag;
+
+ ///
+ ///
+ /// Driver-support flags specific to the specified filter. These flags are identical to the ACMDRIVERDETAILS structure, but they
+ /// are specific to the filter that is being queried. This member can be a combination of the following values and identifies
+ /// which operations the driver supports for the filter tag:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags while using the specified filter. For example, if a driver
+ /// supports compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified filter, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified filter. For
+ /// example, if a driver supports resampling of WAVE_FORMAT_PCM with the specified filter, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both with the specified filter through a waveform-audio device. An application
+ /// should use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric
+ /// indexes to retrieve the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ public ACMDRIVERDETAILS_SUPPORTF fdwSupport;
+
+ ///
+ /// Pointer to a WAVEFILTER structure that will receive the filter details. This structure requires no initialization by the
+ /// application unless the ACM_FILTERDETAILSF_FILTER flag is specified with the acmFilterDetails function. In this case, the
+ /// dwFilterTag member of the WAVEFILTER structure must be equal to the dwFilterTag member of the
+ /// ACMFILTERDETAILS structure.
+ ///
+ public IntPtr pwfltr;
+
+ ///
+ /// Size, in bytes, available for pwfltr to receive the filter details. The acmMetrics and acmFilterTagDetails functions
+ /// can be used to determine the maximum size required for any filter available for the specified driver (or for all installed
+ /// ACM drivers).
+ ///
+ public uint cbwfltr;
+
+ ///
+ /// String that describes the filter for the dwFilterTag type. If the acmFilterDetails function is successful, this
+ /// string is always returned.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFILTERDETAILS_FILTER_CHARS)]
+ public string szFilter;
+ }
+
+ /// The ACMFILTERTAGDETAILS structure details a waveform-audio filter tag for an ACM filter driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmfiltertagdetails typedef struct tACMFILTERTAGDETAILS { DWORD
+ // cbStruct; DWORD dwFilterTagIndex; DWORD dwFilterTag; DWORD cbFilterSize; DWORD fdwSupport; DWORD cStandardFilters; char
+ // szFilterTag[ACMFILTERTAGDETAILS_FILTERTAG_CHARS]; } ACMFILTERTAGDETAILS, *PACMFILTERTAGDETAILS, *LPACMFILTERTAGDETAILS;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFILTERTAGDETAILS")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFILTERTAGDETAILS
+ {
+ ///
+ /// Size, in bytes, of the ACMFILTERTAGDETAILS structure. This member must be initialized before an application calls the
+ /// acmFilterTagDetails or acmFilterTagEnum function. The size specified in this member must be large enough to contain the base
+ /// ACMFILTERTAGDETAILS structure. When the acmFilterTagDetails function returns, this member contains the actual
+ /// size of the information returned. The returned information will never exceed the requested size.
+ ///
+ public uint cbStruct;
+
+ ///
+ /// Index of the filter tag to retrieve details for. The index ranges from zero to one less than the number of filter tags
+ /// supported by an ACM driver. The number of filter tags supported by a driver is contained in the ACMDRIVERDETAILS structure.
+ /// The dwFilterTagIndex member is used only when querying filter tag details about a driver by index; otherwise, this
+ /// member should be zero.
+ ///
+ public uint dwFilterTagIndex;
+
+ ///
+ /// Waveform-audio filter tag that the ACMFILTERTAGDETAILS structure describes. This member is used as an input for the
+ /// ACM_FILTERTAGDETAILSF_FILTERTAG and ACM_FILTERTAGDETAILSF_LARGESTSIZE query flags. This member is always returned if the
+ /// acmFilterTagDetails function is successful. This member should be set to WAVE_FILTER_UNKNOWN for all other query flags.
+ ///
+ public uint dwFilterTag;
+
+ ///
+ /// Largest total size, in bytes, of a waveform-audio filter of the dwFilterTag type. For example, this member will be 40
+ /// for WAVE_FILTER_ECHO and 36 for WAVE_FILTER_VOLUME.
+ ///
+ public uint cbFilterSize;
+
+ ///
+ ///
+ /// Driver-support flags specific to the filter tag. These flags are identical to the ACMDRIVERDETAILS structure. This member
+ /// can be a combination of the following values and identifies which operations the driver supports with the filter tag:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags while using the specified filter tag. For example, if a driver
+ /// supports compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified filter tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified filter tag. For
+ /// example, if a driver supports resampling of WAVE_FORMAT_PCM with the specified filter tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both with the specified filter tag through a waveform-audio device. An
+ /// application should use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT
+ /// metric indexes to get the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ public ACMDRIVERDETAILS_SUPPORTF fdwSupport;
+
+ ///
+ /// Number of standard filters of the dwFilterTag type (that is, the combination of all filter characteristics). This
+ /// value cannot specify all filters supported by the driver.
+ ///
+ public uint cStandardFilters;
+
+ ///
+ /// String that describes the dwFilterTag type. This string is always returned if the acmFilterTagDetails function is successful.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFILTERTAGDETAILS_FILTERTAG_CHARS)]
+ public string szFilterTag;
+ }
+
+ ///
+ /// The ACMFORMATCHOOSE structure contains information the ACM uses to initialize the system-defined waveform-audio format
+ /// selection dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmformatchoose typedef struct tACMFORMATCHOOSE { DWORD
+ // cbStruct; DWORD fdwStyle; HWND hwndOwner; LPWAVEFORMATEX pwfx; DWORD cbwfx; LPCSTR pszTitle; char
+ // szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS]; char szFormat[ACMFORMATDETAILS_FORMAT_CHARS]; LPSTR pszName; DWORD cchName;
+ // DWORD fdwEnum; LPWAVEFORMATEX pwfxEnum; HINSTANCE hInstance; LPCSTR pszTemplateName; LPARAM lCustData; ACMFORMATCHOOSEHOOKPROC
+ // pfnHook; } ACMFORMATCHOOSE, *PACMFORMATCHOOSE, *LPACMFORMATCHOOSE;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFORMATCHOOSE")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFORMATCHOOSE
+ {
+ ///
+ /// Size, in bytes, of the ACMFORMATCHOOSE structure. This member must be initialized before an application calls the
+ /// acmFormatChoose function. The size specified in this member must be large enough to contain the base ACMFORMATCHOOSE structure.
+ ///
+ public uint cbStruct;
+
+ ///
+ ///
+ /// Optional style flags for the acmFormatChoose function. This member must be initialized to a valid combination of the
+ /// following flags before an application calls the acmFormatChoose function:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_CONTEXTHELP
+ ///
+ /// Context-sensitive help will be available in the dialog box. To use this feature, an application must register the
+ /// ACMHELPMSGCONTEXTMENU and ACMHELPMSGCONTEXTHELP constants, using the RegisterWindowMessage function. When the user invokes
+ /// help, the registered message will be posted to the owning window. The message will contain the wParam and lParam parameters
+ /// from the original WM_CONTEXTMENU or WM_CONTEXTHELP message.
+ ///
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_ENABLEHOOK
+ ///
+ /// Enables the hook function pointed to by the pfnHook member. An application can use hook functions for a variety of
+ /// customizations, including answering the MM_ACM_FORMATCHOOSE message.
+ ///
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE
+ /// Causes the ACM to create the dialog box template identified by hInstance and pszTemplateName.
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE
+ ///
+ /// The hInstance member identifies a data block that contains a preloaded dialog box template. If this flag is specified, the
+ /// ACM ignores the pszTemplateName member.
+ ///
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT
+ ///
+ /// The buffer pointed to by pwfx contains a valid WAVEFORMATEX structure that the dialog box will use as the initial selection.
+ ///
+ ///
+ /// -
+ /// ACMFORMATCHOOSE_STYLEF_SHOWHELP
+ ///
+ /// A help button will appear in the dialog box. To use a custom Help file, an application must register the ACMHELPMSGSTRING
+ /// constant with the RegisterWindowMessage function. When the user presses the help button, the registered message will be
+ /// posted to the owner.
+ ///
+ ///
+ ///
+ ///
+ public ACMFORMATCHOOSE_STYLEF fdwStyle;
+
+ ///
+ /// Handle to the window that owns the dialog box. This member can be any valid window handle, or NULL if the dialog box
+ /// has no owner. This member must be initialized before calling the acmFormatChoose function.
+ ///
+ public HWND hwndOwner;
+
+ ///
+ /// Pointer to a WAVEFORMATEX structure. If the ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT flag is specified in the fdwStyle
+ /// member, this structure must be initialized to a valid format. When the acmFormatChoose function returns, this buffer
+ /// contains the selected format. If the user cancels the dialog box, no changes will be made to this buffer.
+ ///
+ public IntPtr pwfx;
+
+ ///
+ /// Size, in bytes, of the buffer pointed to by pwfx. If the buffer is too small to contain the format information, the
+ /// acmFormatChoose function returns ACMERR_NOTPOSSIBLE. Also, the ACM copies the required size into this member. An application
+ /// can use the acmMetrics and acmFormatTagDetails functions to determine the largest size required for this buffer.
+ ///
+ public uint cbwfx;
+
+ ///
+ /// Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the ACM uses the default
+ /// title (that is, "Sound Selection").
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string pszTitle;
+
+ ///
+ /// Buffer containing a null-terminated string describing the format tag of the format selection when the ACMFORMATTAGDETAILS
+ /// structure returned by the acmFormatTagDetails function. If the user cancels the dialog box, this member will contain a
+ /// null-terminated string.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFORMATTAGDETAILS_FORMATTAG_CHARS)]
+ public string szFormatTag;
+
+ ///
+ /// Buffer containing a null-terminated string describing the format attributes of the format selection when the
+ /// ACMFORMATDETAILS structure returned by the acmFormatDetails function. If the user cancels the dialog box, this member will
+ /// contain a null-terminated string.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFORMATDETAILS_FORMAT_CHARS)]
+ public string szFormat;
+
+ ///
+ /// Pointer to a string for a user-defined format name. If this is a non-null-terminated string, the ACM will attempt to match
+ /// the name with a previously saved user-defined format name. If a match is found, the dialog box is initialized to that
+ /// format. If a match is not found or this member is a null-terminated string, this member is ignored on input. When the
+ /// acmFormatChoose function returns, this buffer contains a null-terminated string describing the user-defined format. If the
+ /// format name is untitled (that is, the user has not given a name for the format), this member will be a null-terminated
+ /// string on return. If the user cancels the dialog box, no changes will be made to this buffer.
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string pszName;
+
+ ///
+ /// Size, in characters, of the buffer identified by the pszName member. This buffer should be at least 128 characters
+ /// long. If the pszName member is NULL, this member is ignored.
+ ///
+ public uint cchName;
+
+ ///
+ ///
+ /// Optional flags for restricting the type of formats listed in the dialog box. These flags are identical to the fdwEnum flags
+ /// for the acmFormatEnum function. If pwfxEnum is NULL, this member should be zero. The following values are defined:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACM_FORMATENUMF_CONVERT
+ ///
+ /// The WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate only destination
+ /// formats that can be converted from the given pwfxEnum format.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_HARDWARE
+ ///
+ /// The enumerator should enumerate only formats that are supported in hardware by one or more of the installed waveform-audio
+ /// devices. This flag provides a way for an application to choose only formats native to an installed waveform-audio device.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_INPUT
+ /// The enumerator should enumerate only formats that are supported for input (recording).
+ ///
+ /// -
+ /// ACM_FORMATENUMF_NCHANNELS
+ ///
+ /// The nChannels member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate
+ /// only a format that conforms to this attribute.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_NSAMPLESPERSEC
+ ///
+ /// The nSamplesPerSec member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_OUTPUT
+ /// The enumerator should enumerate only formats that are supported for output (playback).
+ ///
+ /// -
+ /// ACM_FORMATENUMF_SUGGEST
+ ///
+ /// The WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will enumerate all suggested
+ /// destination formats for the given pwfxEnum format.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_WBITSPERSAMPLE
+ ///
+ /// The wBitsPerSample member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ///
+ /// -
+ /// ACM_FORMATENUMF_WFORMATTAG
+ ///
+ /// The wFormatTag member of the WAVEFORMATEX structure pointed to by the pwfxEnum member is valid. The enumerator will
+ /// enumerate only a format that conforms to this attribute.
+ ///
+ ///
+ ///
+ ///
+ public ACM_FORMATENUMF fdwEnum;
+
+ ///
+ /// Pointer to a WAVEFORMATEX structure that will be used to restrict the formats listed in the dialog box. The
+ /// fdwEnum member defines the members of the structure pointed to by pwfxEnum that should be used for the
+ /// enumeration restrictions. If no special restrictions are desired, this member can be NULL. For other requirements
+ /// associated with the pwfxEnum member, see the description for the acmFormatEnum function.
+ ///
+ public IntPtr pwfxEnum;
+
+ ///
+ /// Handle to a data block that contains a dialog box template specified by the pszTemplateName member. This member is
+ /// used only if the fdwStyle member specifies the ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE or
+ /// ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE flag; otherwise, this member should be NULL on input.
+ ///
+ public HINSTANCE hInstance;
+
+ ///
+ /// Pointer to a null-terminated string that specifies the name of the resource file for the dialog box template that is to be
+ /// substituted for the dialog box template in the ACM. An application can use the MAKEINTRESOURCE macro for numbered dialog box
+ /// resources. This member is used only if the fdwStyle member specifies the ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE flag;
+ /// otherwise, this member should be NULL on input.
+ ///
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string pszTemplateName;
+
+ ///
+ /// Application-defined data that the ACM passes to the hook function identified by the pfnHook member. The system passes
+ /// the data in the lParam parameter of the WM_INITDIALOG message.
+ ///
+ public IntPtr lCustData;
+
+ ///
+ /// Pointer to a callback function that processes messages intended for the dialog box. An application must specify the
+ /// ACMFORMATCHOOSE_STYLEF_ENABLEHOOK flag in the fdwStyle member to enable the hook; otherwise, this member should be
+ /// NULL. The hook function should return FALSE to pass a message to the standard dialog box procedure or
+ /// TRUE to discard the message. The callback function type is acmFormatChooseHookProc.
+ ///
+ public ACMFORMATCHOOSEHOOKPROC pfnHook;
+ }
+
+ /// The ACMFORMATDETAILS structure details a waveform-audio format for a specific format tag for an ACM driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmformatdetails typedef struct tACMFORMATDETAILS { DWORD
+ // cbStruct; DWORD dwFormatIndex; DWORD dwFormatTag; DWORD fdwSupport; LPWAVEFORMATEX pwfx; DWORD cbwfx; char
+ // szFormat[ACMFORMATDETAILS_FORMAT_CHARS]; } ACMFORMATDETAILS, *PACMFORMATDETAILS, *LPACMFORMATDETAILS;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFORMATDETAILS")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFORMATDETAILS
+ {
+ ///
+ /// Size, in bytes, of the ACMFORMATDETAILS structure. This member must be initialized before an application calls the
+ /// acmFormatDetails or acmFormatEnum function. The size specified by this member must be large enough to contain the base
+ /// ACMFORMATDETAILS structure. When the acmFormatDetails function returns, this member contains the actual size
+ /// of the information returned. The returned information will never exceed the requested size.
+ ///
+ public uint cbStruct;
+
+ ///
+ /// Index of the format to retrieve details for. The index ranges from zero to one less than the number of standard formats
+ /// supported by an ACM driver for a format tag. The number of standard formats supported by a driver for a format tag is
+ /// contained in the ACMFORMATTAGDETAILS structure. The dwFormatIndex member is used only when an application queries
+ /// standard format details about a driver by index; otherwise, this member should be zero. Also, this member will be set to
+ /// zero by the ACM when an application queries for details on a format; in other words, this member is used only for input and
+ /// is never returned by the ACM or an ACM driver.
+ ///
+ public uint dwFormatIndex;
+
+ ///
+ /// Waveform-audio format tag that the ACMFORMATDETAILS structure describes. This member is used for input for the
+ /// ACM_FORMATDETAILSF_INDEX query flag. For the ACM_FORMATDETAILSF_FORMAT query flag, this member must be initialized to the
+ /// same format tag as the pwfx member specifies. If a call to the acmFormatDetails function is successful, this member
+ /// is always returned. This member should be set to WAVE_FORMAT_UNKNOWN for all other query flags.
+ ///
+ public uint dwFormatTag;
+
+ ///
+ ///
+ /// Driver-support flags specific to the specified format. These flags are identical to the ACMDRIVERDETAILS structure. This
+ /// member can be a combination of the following values and indicates which operations the driver supports for the format tag:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified format tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags for the specified format. For example, if a driver supports
+ /// compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM with the specified format, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the same format tag while using the specified format. For
+ /// example, if a driver supports resampling of WAVE_FORMAT_PCM to the specified format, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (which modifies data without changing any format attributes) with the specified format. For
+ /// example, if a driver supports volume or echo operations on WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input and/or output of the specified format through a waveform-audio device. An application should
+ /// use acmMetrics with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric indexes to get the
+ /// waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ public ACMDRIVERDETAILS_SUPPORTF fdwSupport;
+
+ ///
+ /// Pointer to a WAVEFORMATEX structure that will receive the format details. This structure requires no initialization by the
+ /// application unless the ACM_FORMATDETAILSF_FORMAT flag is specified in the acmFormatDetails function. In this case, the
+ /// wFormatTag member of the WAVEFORMATEX structure must be equal to the dwFormatTag of the
+ /// ACMFORMATDETAILS structure.
+ ///
+ public IntPtr pwfx;
+
+ ///
+ /// Size, in bytes, available for pwfx to receive the format details. The acmMetrics and acmFormatTagDetails functions
+ /// can be used to determine the maximum size required for any format available for the specified driver (or for all installed
+ /// ACM drivers).
+ ///
+ public uint cbwfx;
+
+ ///
+ /// String that describes the format for the dwFormatTag type. If the acmFormatDetails function is successful, this
+ /// string is always returned.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFORMATDETAILS_FORMAT_CHARS)]
+ public string szFormat;
+ }
+
+ /// The ACMFORMATTAGDETAILS structure details a waveform-audio format tag for an ACM driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmformattagdetails typedef struct tACMFORMATTAGDETAILS { DWORD
+ // cbStruct; DWORD dwFormatTagIndex; DWORD dwFormatTag; DWORD cbFormatSize; DWORD fdwSupport; DWORD cStandardFormats; char
+ // szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS]; } ACMFORMATTAGDETAILS, *PACMFORMATTAGDETAILS, *LPACMFORMATTAGDETAILS;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMFORMATTAGDETAILS")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct ACMFORMATTAGDETAILS
+ {
+ ///
+ /// Size, in bytes, of the ACMFORMATTAGDETAILS structure. This member must be initialized before an application calls the
+ /// acmFormatTagDetails or acmFormatTagEnum function. The size specified by this member must be large enough to contain the base
+ /// ACMFORMATTAGDETAILS structure. When the acmFormatTagDetails function returns, this member contains the actual
+ /// size of the information returned. The returned information will never exceed the requested size.
+ ///
+ public uint cbStruct;
+
+ ///
+ /// Index of the format tag for which details will be retrieved. The index ranges from zero to one less than the number of
+ /// format tags supported by an ACM driver. The number of format tags supported by a driver is contained in the ACMDRIVERDETAILS
+ /// structure. The dwFormatTagIndex member is used only when querying format tag details on a driver by index; otherwise,
+ /// this member should be zero.
+ ///
+ public uint dwFormatTagIndex;
+
+ ///
+ /// Waveform-audio format tag that the ACMFORMATTAGDETAILS structure describes. This member is used for input for the
+ /// ACM_FORMATTAGDETAILSF_FORMATTAG and ACM_FORMATTAGDETAILSF_LARGESTSIZE query flags. If the acmFormatTagDetails function is
+ /// successful, this member is always returned. This member should be set to WAVE_FORMAT_UNKNOWN for all other query flags.
+ ///
+ public uint dwFormatTag;
+
+ ///
+ /// Largest total size, in bytes, of a waveform-audio format of the dwFormatTag type. For example, this member will be 16
+ /// for WAVE_FORMAT_PCM and 50 for WAVE_FORMAT_ADPCM.
+ ///
+ public uint cbFormatSize;
+
+ ///
+ ///
+ /// Driver-support flags specific to the format tag. These flags are identical to the ACMDRIVERDETAILS structure. This member
+ /// may be some combination of the following values and refer to what operations the driver supports with the format tag:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_ASYNC
+ /// Driver supports asynchronous conversions with the specified format tag.
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CODEC
+ ///
+ /// Driver supports conversion between two different format tags where one of the tags is the specified format tag. For example,
+ /// if a driver supports compression from WAVE_FORMAT_PCM to WAVE_FORMAT_ADPCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_CONVERTER
+ ///
+ /// Driver supports conversion between two different formats of the specified format tag. For example, if a driver supports
+ /// resampling of WAVE_FORMAT_PCM, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_FILTER
+ ///
+ /// Driver supports a filter (modification of the data without changing any of the format attributes). For example, if a driver
+ /// supports volume or echo operations on the specified format tag, this flag is set.
+ ///
+ ///
+ /// -
+ /// ACMDRIVERDETAILS_SUPPORTF_HARDWARE
+ ///
+ /// Driver supports hardware input, output, or both of the specified format tag through a waveform-audio device. An application
+ /// should use the acmMetrics function with the ACM_METRIC_HARDWARE_WAVE_INPUT and ACM_METRIC_HARDWARE_WAVE_OUTPUT metric
+ /// indexes to get the waveform-audio device identifiers associated with the supporting ACM driver.
+ ///
+ ///
+ ///
+ ///
+ public ACMDRIVERDETAILS_SUPPORTF fdwSupport;
+
+ ///
+ /// Number of standard formats of the dwFormatTag type; that is, the combination of all sample rates, bits per sample,
+ /// channels, and so on. This value can specify all formats supported by the driver, but not necessarily.
+ ///
+ public uint cStandardFormats;
+
+ ///
+ /// String that describes the dwFormatTag type. If the acmFormatTagDetails function is successful, this string is always returned.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ACMFORMATTAGDETAILS_FORMATTAG_CHARS)]
+ public string szFormatTag;
+ }
+
+ ///
+ /// The ACMSTREAMHEADER structure defines the header used to identify an ACM conversion source and destination buffer pair
+ /// for a conversion stream.
+ ///
+ ///
+ /// Before an ACMSTREAMHEADER structure can be used for a conversion, it must be prepared by using the acmStreamPrepareHeader
+ /// function. When an application is finished with an ACMSTREAMHEADER structure, it must call the acmStreamUnprepareHeader
+ /// function before freeing the source and destination buffers.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/msacm/ns-msacm-acmstreamheader typedef struct tACMSTREAMHEADER { DWORD
+ // cbStruct; DWORD fdwStatus; DWORD_PTR dwUser; LPBYTE pbSrc; DWORD cbSrcLength; DWORD cbSrcLengthUsed; DWORD_PTR dwSrcUser; LPBYTE
+ // pbDst; DWORD cbDstLength; DWORD cbDstLengthUsed; DWORD_PTR dwDstUser; DWORD dwReservedDriver[_DRVRESERVED]; } ACMSTREAMHEADER,
+ // *PACMSTREAMHEADER, *LPACMSTREAMHEADER;
+ [PInvokeData("msacm.h", MSDNShortId = "NS:msacm.tACMSTREAMHEADER")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)]
+ public struct ACMSTREAMHEADER
+ {
+ ///
+ /// Size, in bytes, of the ACMSTREAMHEADER structure. This member must be initialized before the application calls any
+ /// ACM stream functions using this structure. The size specified in this member must be large enough to contain the base
+ /// ACMSTREAMHEADER structure.
+ ///
+ public uint cbStruct;
+
+ ///
+ ///
+ /// Flags giving information about the conversion buffers. This member must be initialized to zero before the application calls
+ /// the acmStreamPrepareHeader function and should not be modified by the application while the stream header remains prepared.
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ACMSTREAMHEADER_STATUSF_DONE
+ /// Set by the ACM or driver to indicate that it is finished with the conversion and is returning the buffers to the application.
+ ///
+ /// -
+ /// ACMSTREAMHEADER_STATUSF_INQUEUE
+ /// Set by the ACM or driver to indicate that the buffers are queued for conversion.
+ ///
+ /// -
+ /// ACMSTREAMHEADER_STATUSF_PREPARED
+ /// Set by the ACM to indicate that the buffers have been prepared by using the acmStreamPrepareHeader function.
+ ///
+ ///
+ ///
+ public ACMSTREAMHEADER_STATUSF fdwStatus;
+
+ /// User data. This can be any instance data specified by the application.
+ public IntPtr dwUser;
+
+ ///
+ /// Pointer to the source buffer. This pointer must always refer to the same location while the stream header remains prepared.
+ /// If an application needs to change the source location, it must unprepare the header and reprepare it with the alternate location.
+ ///
+ public IntPtr pbSrc;
+
+ ///
+ /// Length, in bytes, of the source buffer pointed to by pbSrc. When the header is prepared, this member must specify the
+ /// maximum size that will be used in the source buffer. Conversions can be performed on source lengths less than or equal to
+ /// the original prepared size. However, this member must be reset to the original size when an application unprepares the header.
+ ///
+ public uint cbSrcLength;
+
+ ///
+ /// Amount of data, in bytes, used for the conversion. This member is not valid until the conversion is complete. This value can
+ /// be less than or equal to cbSrcLength. An application must use the cbSrcLengthUsed member when advancing to the
+ /// next piece of source data for the conversion stream.
+ ///
+ public uint cbSrcLengthUsed;
+
+ /// User data. This can be any instance data specified by the application.
+ public IntPtr dwSrcUser;
+
+ ///
+ /// Pointer to the destination buffer. This pointer must always refer to the same location while the stream header remains
+ /// prepared. If an application needs to change the destination location, it must unprepare the header and reprepare it with the
+ /// alternate location.
+ ///
+ public IntPtr pbDst;
+
+ ///
+ /// Length, in bytes, of the destination buffer pointed to by pbDst. When the header is prepared, this member must
+ /// specify the maximum size that will be used in the destination buffer.
+ ///
+ public uint cbDstLength;
+
+ ///
+ /// Amount of data, in bytes, returned by a conversion. This member is not valid until the conversion is complete. This value
+ /// can be less than or equal to cbDstLength. An application must use the cbDstLengthUsed member when advancing to
+ /// the next destination location for the conversion stream.
+ ///
+ public uint cbDstLengthUsed;
+
+ /// User data. This can be any instance data specified by the application.
+ public IntPtr dwDstUser;
+
+ ///
+ /// Reserved; do not use. This member requires no initialization by the application and should never be modified while the
+ /// header remains prepared.
+ ///
+ // Hack to mimic uint[_DRVRESERVED] where _DRVRESERVED is 10 on 32-bit and 15 on 64-bit
+ private readonly uint dwReservedDriver1;
+ private readonly uint dwReservedDriver2;
+ private readonly IntPtr dwReservedDriver6;
+ private readonly uint dwReservedDriver3;
+ private readonly uint dwReservedDriver4;
+ private readonly IntPtr dwReservedDriver7;
+ private readonly IntPtr dwReservedDriver8;
+ private readonly IntPtr dwReservedDriver9;
+ private readonly IntPtr dwReservedDriver10;
+ private readonly uint dwReservedDriver5;
+ }
+
+ /// Provides a handle to an ACM driver.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HACMDRIVER : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HACMDRIVER(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HACMDRIVER NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HACMDRIVER h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HACMDRIVER(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HACMDRIVER h1, HACMDRIVER h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HACMDRIVER h1, HACMDRIVER h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HACMDRIVER h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to an ACM driver.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HACMDRIVERID : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HACMDRIVERID(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HACMDRIVERID NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HACMDRIVERID h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HACMDRIVERID(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HACMDRIVERID h1, HACMDRIVERID h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HACMDRIVERID h1, HACMDRIVERID h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HACMDRIVERID h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to an ACM object.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HACMOBJ : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HACMOBJ(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HACMOBJ NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HACMOBJ h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HACMOBJ(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HACMOBJ h1, HACMOBJ h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HACMOBJ h1, HACMOBJ h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HACMOBJ h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to an ACM stream.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HACMSTREAM : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HACMSTREAM(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HACMSTREAM NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HACMSTREAM h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HACMSTREAM(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HACMSTREAM h1, HACMSTREAM h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HACMSTREAM h1, HACMSTREAM h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HACMSTREAM h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHACMDRIVER : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ public SafeHACMDRIVER(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHACMDRIVER() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HACMDRIVER(SafeHACMDRIVER h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => acmDriverClose(handle) == MMRESULT.MMSYSERR_NOERROR;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHACMSTREAM : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ ///
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ ///
+ public SafeHACMSTREAM(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHACMSTREAM() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HACMSTREAM(SafeHACMSTREAM h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => acmStreamClose(handle) == MMRESULT.MMSYSERR_NOERROR;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/MmReg.cs b/PInvoke/Multimedia/MmReg.cs
new file mode 100644
index 00000000..c8d0161f
--- /dev/null
+++ b/PInvoke/Multimedia/MmReg.cs
@@ -0,0 +1,928 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the WinMm.dll
+ public static partial class WinMm
+ {
+ /// Format type.
+ [PInvokeData("mmreg.h", MSDNShortId = "NS:mmreg.waveformat_tag")]
+ [Flags]
+ public enum WAVE_FORMAT : ushort
+ {
+ /// Microsoft Corporation
+ WAVE_FORMAT_UNKNOWN = 0x0000,
+
+ /// Waveform-audio data is PCM.
+ WAVE_FORMAT_PCM,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_ADPCM = 0x0002,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_IEEE_FLOAT = 0x0003,
+
+ /// Compaq Computer Corp.
+ WAVE_FORMAT_VSELP = 0x0004,
+
+ /// IBM Corporation
+ WAVE_FORMAT_IBM_CVSD = 0x0005,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_ALAW = 0x0006,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MULAW = 0x0007,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_DTS = 0x0008,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_DRM = 0x0009,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMAVOICE9 = 0x000A,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMAVOICE10 = 0x000B,
+
+ /// OKI
+ WAVE_FORMAT_OKI_ADPCM = 0x0010,
+
+ /// Intel Corporation
+ WAVE_FORMAT_DVI_ADPCM = 0x0011,
+
+ /// Intel Corporation
+ WAVE_FORMAT_IMA_ADPCM = WAVE_FORMAT_DVI_ADPCM,
+
+ /// Videologic
+ WAVE_FORMAT_MEDIASPACE_ADPCM = 0x0012,
+
+ /// Sierra Semiconductor Corp
+ WAVE_FORMAT_SIERRA_ADPCM = 0x0013,
+
+ /// Antex Electronics Corporation
+ WAVE_FORMAT_G723_ADPCM = 0x0014,
+
+ /// DSP Solutions, Inc.
+ WAVE_FORMAT_DIGISTD = 0x0015,
+
+ /// DSP Solutions, Inc.
+ WAVE_FORMAT_DIGIFIX = 0x0016,
+
+ /// Dialogic Corporation
+ WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017,
+
+ /// Media Vision, Inc.
+ WAVE_FORMAT_MEDIAVISION_ADPCM = 0x0018,
+
+ /// Hewlett-Packard Company
+ WAVE_FORMAT_CU_CODEC = 0x0019,
+
+ /// Hewlett-Packard Company
+ WAVE_FORMAT_HP_DYN_VOICE = 0x001A,
+
+ /// Yamaha Corporation of America
+ WAVE_FORMAT_YAMAHA_ADPCM = 0x0020,
+
+ /// Speech Compression
+ WAVE_FORMAT_SONARC = 0x0021,
+
+ /// DSP Group, Inc
+ WAVE_FORMAT_DSPGROUP_TRUESPEECH = 0x0022,
+
+ /// Echo Speech Corporation
+ WAVE_FORMAT_ECHOSC1 = 0x0023,
+
+ /// Virtual Music, Inc.
+ WAVE_FORMAT_AUDIOFILE_AF36 = 0x0024,
+
+ /// Audio Processing Technology
+ WAVE_FORMAT_APTX = 0x0025,
+
+ /// Virtual Music, Inc.
+ WAVE_FORMAT_AUDIOFILE_AF10 = 0x0026,
+
+ /// Aculab plc
+ WAVE_FORMAT_PROSODY_1612 = 0x0027,
+
+ /// Merging Technologies S.A.
+ WAVE_FORMAT_LRC = 0x0028,
+
+ /// Dolby Laboratories
+ WAVE_FORMAT_DOLBY_AC2 = 0x0030,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_GSM610 = 0x0031,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MSNAUDIO = 0x0032,
+
+ /// Antex Electronics Corporation
+ WAVE_FORMAT_ANTEX_ADPCME = 0x0033,
+
+ /// Control Resources Limited
+ WAVE_FORMAT_CONTROL_RES_VQLPC = 0x0034,
+
+ /// DSP Solutions, Inc.
+ WAVE_FORMAT_DIGIREAL = 0x0035,
+
+ /// DSP Solutions, Inc.
+ WAVE_FORMAT_DIGIADPCM = 0x0036,
+
+ /// Control Resources Limited
+ WAVE_FORMAT_CONTROL_RES_CR10 = 0x0037,
+
+ /// Natural MicroSystems
+ WAVE_FORMAT_NMS_VBXADPCM = 0x0038,
+
+ /// Crystal Semiconductor IMA ADPCM
+ WAVE_FORMAT_CS_IMAADPCM = 0x0039,
+
+ /// Echo Speech Corporation
+ WAVE_FORMAT_ECHOSC3 = 0x003A,
+
+ /// Rockwell International
+ WAVE_FORMAT_ROCKWELL_ADPCM = 0x003B,
+
+ /// Rockwell International
+ WAVE_FORMAT_ROCKWELL_DIGITALK = 0x003C,
+
+ /// Xebec Multimedia Solutions Limited
+ WAVE_FORMAT_XEBEC = 0x003D,
+
+ /// Antex Electronics Corporation
+ WAVE_FORMAT_G721_ADPCM = 0x0040,
+
+ /// Antex Electronics Corporation
+ WAVE_FORMAT_G728_CELP = 0x0041,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MSG723 = 0x0042,
+
+ /// Intel Corp.
+ WAVE_FORMAT_INTEL_G723_1 = 0x0043,
+
+ /// Intel Corp.
+ WAVE_FORMAT_INTEL_G729 = 0x0044,
+
+ /// Sharp
+ WAVE_FORMAT_SHARP_G726 = 0x0045,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MPEG = 0x0050,
+
+ /// InSoft, Inc.
+ WAVE_FORMAT_RT24 = 0x0052,
+
+ /// InSoft, Inc.
+ WAVE_FORMAT_PAC = 0x0053,
+
+ /// ISO/MPEG Layer3 Format Tag
+ WAVE_FORMAT_MPEGLAYER3 = 0x0055,
+
+ /// Lucent Technologies
+ WAVE_FORMAT_LUCENT_G723 = 0x0059,
+
+ /// Cirrus Logic
+ WAVE_FORMAT_CIRRUS = 0x0060,
+
+ /// ESS Technology
+ WAVE_FORMAT_ESPCM = 0x0061,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE = 0x0062,
+
+ /// Canopus, co., Ltd.
+ WAVE_FORMAT_CANOPUS_ATRAC = 0x0063,
+
+ /// APICOM
+ WAVE_FORMAT_G726_ADPCM = 0x0064,
+
+ /// APICOM
+ WAVE_FORMAT_G722_ADPCM = 0x0065,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_DSAT = 0x0066,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_DSAT_DISPLAY = 0x0067,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = 0x0069,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_AC8 = 0x0070,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_AC10 = 0x0071,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_AC16 = 0x0072,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_AC20 = 0x0073,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_RT24 = 0x0074,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_RT29 = 0x0075,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_RT29HW = 0x0076,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_VR12 = 0x0077,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_VR18 = 0x0078,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_TQ40 = 0x0079,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_SC3 = 0x007A,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_SC3_1 = 0x007B,
+
+ /// Softsound, Ltd.
+ WAVE_FORMAT_SOFTSOUND = 0x0080,
+
+ /// Voxware Inc
+ WAVE_FORMAT_VOXWARE_TQ60 = 0x0081,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MSRT24 = 0x0082,
+
+ /// AT&T Labs, Inc.
+ WAVE_FORMAT_G729A = 0x0083,
+
+ /// Motion Pixels
+ WAVE_FORMAT_MVI_MVI2 = 0x0084,
+
+ /// DataFusion Systems (Pty) (Ltd)
+ WAVE_FORMAT_DF_G726 = 0x0085,
+
+ /// DataFusion Systems (Pty) (Ltd)
+ WAVE_FORMAT_DF_GSM610 = 0x0086,
+
+ /// Iterated Systems, Inc.
+ WAVE_FORMAT_ISIAUDIO = 0x0088,
+
+ /// OnLive! Technologies, Inc.
+ WAVE_FORMAT_ONLIVE = 0x0089,
+
+ /// Multitude Inc.
+ WAVE_FORMAT_MULTITUDE_FT_SX20 = 0x008A,
+
+ /// Infocom
+ WAVE_FORMAT_INFOCOM_ITS_G721_ADPCM = 0x008B,
+
+ /// Convedia Corp.
+ WAVE_FORMAT_CONVEDIA_G729 = 0x008C,
+
+ /// Congruency Inc.
+ WAVE_FORMAT_CONGRUENCY = 0x008D,
+
+ /// Siemens Business Communications Sys
+ WAVE_FORMAT_SBC24 = 0x0091,
+
+ /// Sonic Foundry
+ WAVE_FORMAT_DOLBY_AC3_SPDIF = 0x0092,
+
+ /// MediaSonic
+ WAVE_FORMAT_MEDIASONIC_G723 = 0x0093,
+
+ /// Aculab plc
+ WAVE_FORMAT_PROSODY_8KBPS = 0x0094,
+
+ /// ZyXEL Communications, Inc.
+ WAVE_FORMAT_ZYXEL_ADPCM = 0x0097,
+
+ /// Philips Speech Processing
+ WAVE_FORMAT_PHILIPS_LPCBB = 0x0098,
+
+ /// Studer Professional Audio AG
+ WAVE_FORMAT_PACKED = 0x0099,
+
+ /// Malden Electronics Ltd.
+ WAVE_FORMAT_MALDEN_PHONYTALK = 0x00A0,
+
+ /// Racal recorders
+ WAVE_FORMAT_RACAL_RECORDER_GSM = 0x00A1,
+
+ /// Racal recorders
+ WAVE_FORMAT_RACAL_RECORDER_G720_A = 0x00A2,
+
+ /// Racal recorders
+ WAVE_FORMAT_RACAL_RECORDER_G723_1 = 0x00A3,
+
+ /// Racal recorders
+ WAVE_FORMAT_RACAL_RECORDER_TETRA_ACELP = 0x00A4,
+
+ /// NEC Corp.
+ WAVE_FORMAT_NEC_AAC = 0x00B0,
+
+ /// For Raw AAC, with format block AudioSpecificConfig() (as defined by MPEG-4), that follows WAVEFORMATEX
+ WAVE_FORMAT_RAW_AAC1 = 0x00FF,
+
+ /// Rhetorex Inc.
+ WAVE_FORMAT_RHETOREX_ADPCM = 0x0100,
+
+ /// BeCubed Software Inc.
+ WAVE_FORMAT_IRAT = 0x0101,
+
+ /// Vivo Software
+ WAVE_FORMAT_VIVO_G723 = 0x0111,
+
+ /// Vivo Software
+ WAVE_FORMAT_VIVO_SIREN = 0x0112,
+
+ /// Philips Speech Processing
+ WAVE_FORMAT_PHILIPS_CELP = 0x0120,
+
+ /// Philips Speech Processing
+ WAVE_FORMAT_PHILIPS_GRUNDIG = 0x0121,
+
+ /// Digital Equipment Corporation
+ WAVE_FORMAT_DIGITAL_G723 = 0x0123,
+
+ /// Sanyo Electric Co., Ltd.
+ WAVE_FORMAT_SANYO_LD_ADPCM = 0x0125,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_ACEPLNET = 0x0130,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_ACELP4800 = 0x0131,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_ACELP8V3 = 0x0132,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_G729 = 0x0133,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_G729A = 0x0134,
+
+ /// Sipro Lab Telecom Inc.
+ WAVE_FORMAT_SIPROLAB_KELVIN = 0x0135,
+
+ /// VoiceAge Corp.
+ WAVE_FORMAT_VOICEAGE_AMR = 0x0136,
+
+ /// Dictaphone Corporation
+ WAVE_FORMAT_G726ADPCM = 0x0140,
+
+ /// Dictaphone Corporation
+ WAVE_FORMAT_DICTAPHONE_CELP68 = 0x0141,
+
+ /// Dictaphone Corporation
+ WAVE_FORMAT_DICTAPHONE_CELP54 = 0x0142,
+
+ /// Qualcomm, Inc.
+ WAVE_FORMAT_QUALCOMM_PUREVOICE = 0x0150,
+
+ /// Qualcomm, Inc.
+ WAVE_FORMAT_QUALCOMM_HALFRATE = 0x0151,
+
+ /// Ring Zero Systems, Inc.
+ WAVE_FORMAT_TUBGSM = 0x0155,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MSAUDIO1 = 0x0160,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMAUDIO2 = 0x0161,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMAUDIO3 = 0x0162,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMAUDIO_LOSSLESS = 0x0163,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_WMASPDIF = 0x0164,
+
+ /// Unisys Corp.
+ WAVE_FORMAT_UNISYS_NAP_ADPCM = 0x0170,
+
+ /// Unisys Corp.
+ WAVE_FORMAT_UNISYS_NAP_ULAW = 0x0171,
+
+ /// Unisys Corp.
+ WAVE_FORMAT_UNISYS_NAP_ALAW = 0x0172,
+
+ /// Unisys Corp.
+ WAVE_FORMAT_UNISYS_NAP_16K = 0x0173,
+
+ /// SyCom Technologies
+ WAVE_FORMAT_SYCOM_ACM_SYC008 = 0x0174,
+
+ /// SyCom Technologies
+ WAVE_FORMAT_SYCOM_ACM_SYC701_G726L = 0x0175,
+
+ /// SyCom Technologies
+ WAVE_FORMAT_SYCOM_ACM_SYC701_CELP54 = 0x0176,
+
+ /// SyCom Technologies
+ WAVE_FORMAT_SYCOM_ACM_SYC701_CELP68 = 0x0177,
+
+ /// Knowledge Adventure, Inc.
+ WAVE_FORMAT_KNOWLEDGE_ADVENTURE_ADPCM = 0x0178,
+
+ /// Fraunhofer IIS
+ WAVE_FORMAT_FRAUNHOFER_IIS_MPEG2_AAC = 0x0180,
+
+ /// Digital Theatre Systems, Inc.
+ WAVE_FORMAT_DTS_DS = 0x0190,
+
+ /// Creative Labs, Inc
+ WAVE_FORMAT_CREATIVE_ADPCM = 0x0200,
+
+ /// Creative Labs, Inc
+ WAVE_FORMAT_CREATIVE_FASTSPEECH8 = 0x0202,
+
+ /// Creative Labs, Inc
+ WAVE_FORMAT_CREATIVE_FASTSPEECH10 = 0x0203,
+
+ /// UHER informatic GmbH
+ WAVE_FORMAT_UHER_ADPCM = 0x0210,
+
+ /// Ulead Systems, Inc.
+ WAVE_FORMAT_ULEAD_DV_AUDIO = 0x0215,
+
+ /// Ulead Systems, Inc.
+ WAVE_FORMAT_ULEAD_DV_AUDIO_1 = 0x0216,
+
+ /// Quarterdeck Corporation
+ WAVE_FORMAT_QUARTERDECK = 0x0220,
+
+ /// I-link Worldwide
+ WAVE_FORMAT_ILINK_VC = 0x0230,
+
+ /// Aureal Semiconductor
+ WAVE_FORMAT_RAW_SPORT = 0x0240,
+
+ /// ESS Technology, Inc.
+ WAVE_FORMAT_ESST_AC3 = 0x0241,
+
+ ///
+ WAVE_FORMAT_GENERIC_PASSTHRU = 0x0249,
+
+ /// Interactive Products, Inc.
+ WAVE_FORMAT_IPI_HSX = 0x0250,
+
+ /// Interactive Products, Inc.
+ WAVE_FORMAT_IPI_RPELP = 0x0251,
+
+ /// Consistent Software
+ WAVE_FORMAT_CS2 = 0x0260,
+
+ /// Sony Corp.
+ WAVE_FORMAT_SONY_SCX = 0x0270,
+
+ /// Sony Corp.
+ WAVE_FORMAT_SONY_SCY = 0x0271,
+
+ /// Sony Corp.
+ WAVE_FORMAT_SONY_ATRAC3 = 0x0272,
+
+ /// Sony Corp.
+ WAVE_FORMAT_SONY_SPC = 0x0273,
+
+ /// Telum Inc.
+ WAVE_FORMAT_TELUM_AUDIO = 0x0280,
+
+ /// Telum Inc.
+ WAVE_FORMAT_TELUM_IA_AUDIO = 0x0281,
+
+ /// Norcom Electronics Corp.
+ WAVE_FORMAT_NORCOM_VOICE_SYSTEMS_ADPCM = 0x0285,
+
+ /// Fujitsu Corp.
+ WAVE_FORMAT_FM_TOWNS_SND = 0x0300,
+
+ /// Micronas Semiconductors, Inc.
+ WAVE_FORMAT_MICRONAS = 0x0350,
+
+ /// Micronas Semiconductors, Inc.
+ WAVE_FORMAT_MICRONAS_CELP833 = 0x0351,
+
+ /// Brooktree Corporation
+ WAVE_FORMAT_BTV_DIGITAL = 0x0400,
+
+ /// Intel Corp.
+ WAVE_FORMAT_INTEL_MUSIC_CODER = 0x0401,
+
+ /// Ligos
+ WAVE_FORMAT_INDEO_AUDIO = 0x0402,
+
+ /// QDesign Corporation
+ WAVE_FORMAT_QDESIGN_MUSIC = 0x0450,
+
+ /// On2 Technologies
+ WAVE_FORMAT_ON2_VP7_AUDIO = 0x0500,
+
+ /// On2 Technologies
+ WAVE_FORMAT_ON2_VP6_AUDIO = 0x0501,
+
+ /// AT&T Labs, Inc.
+ WAVE_FORMAT_VME_VMPCM = 0x0680,
+
+ /// AT&T Labs, Inc.
+ WAVE_FORMAT_TPC = 0x0681,
+
+ /// Clearjump
+ WAVE_FORMAT_LIGHTWAVE_LOSSLESS = 0x08AE,
+
+ /// Ing C. Olivetti & C., S.p.A.
+ WAVE_FORMAT_OLIGSM = 0x1000,
+
+ /// Ing C. Olivetti & C., S.p.A.
+ WAVE_FORMAT_OLIADPCM = 0x1001,
+
+ /// Ing C. Olivetti & C., S.p.A.
+ WAVE_FORMAT_OLICELP = 0x1002,
+
+ /// Ing C. Olivetti & C., S.p.A.
+ WAVE_FORMAT_OLISBC = 0x1003,
+
+ /// Ing C. Olivetti & C., S.p.A.
+ WAVE_FORMAT_OLIOPR = 0x1004,
+
+ /// Lernout & Hauspie
+ WAVE_FORMAT_LH_CODEC = 0x1100,
+
+ /// Lernout & Hauspie
+ WAVE_FORMAT_LH_CODEC_CELP = 0x1101,
+
+ /// Lernout & Hauspie
+ WAVE_FORMAT_LH_CODEC_SBC8 = 0x1102,
+
+ /// Lernout & Hauspie
+ WAVE_FORMAT_LH_CODEC_SBC12 = 0x1103,
+
+ /// Lernout & Hauspie
+ WAVE_FORMAT_LH_CODEC_SBC16 = 0x1104,
+
+ /// Norris Communications, Inc.
+ WAVE_FORMAT_NORRIS = 0x1400,
+
+ /// ISIAudio
+ WAVE_FORMAT_ISIAUDIO_2 = 0x1401,
+
+ /// AT&T Labs, Inc.
+ WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS = 0x1500,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MPEG_ADTS_AAC = 0x1600,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_MPEG_RAW_AAC = 0x1601,
+
+ /// Microsoft Corporation (MPEG-4 Audio Transport Streams (LOAS/LATM)
+ WAVE_FORMAT_MPEG_LOAS = 0x1602,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC = 0x1608,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_NOKIA_MPEG_RAW_AAC = 0x1609,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC = 0x160A,
+
+ /// Microsoft Corporation
+ WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC = 0x160B,
+
+ ///
+ /// Microsoft Corporation (MPEG-2 AAC or MPEG-4 HE-AAC v1/v2 streams with any payload (ADTS, ADIF, LOAS/LATM, RAW). Format block
+ /// includes MP4 AudioSpecificConfig() -- see HEAACWAVEFORMAT below
+ ///
+ WAVE_FORMAT_MPEG_HEAAC = 0x1610,
+
+ /// Voxware Inc.
+ WAVE_FORMAT_VOXWARE_RT24_SPEECH = 0x181C,
+
+ /// Sonic Foundry
+ WAVE_FORMAT_SONICFOUNDRY_LOSSLESS = 0x1971,
+
+ /// Innings Telecom Inc.
+ WAVE_FORMAT_INNINGS_TELECOM_ADPCM = 0x1979,
+
+ /// Lucent Technologies
+ WAVE_FORMAT_LUCENT_SX8300P = 0x1C07,
+
+ /// Lucent Technologies
+ WAVE_FORMAT_LUCENT_SX5363S = 0x1C0C,
+
+ /// CUSeeMe
+ WAVE_FORMAT_CUSEEME = 0x1F03,
+
+ /// NTCSoft
+ WAVE_FORMAT_NTCSOFT_ALF2CM_ACM = 0x1FC4,
+
+ /// FAST Multimedia AG
+ WAVE_FORMAT_DVM = 0x2000,
+
+ ///
+ WAVE_FORMAT_DTS2 = 0x2001,
+
+ ///
+ WAVE_FORMAT_MAKEAVIS = 0x3313,
+
+ /// Divio, Inc.
+ WAVE_FORMAT_DIVIO_MPEG4_AAC = 0x4143,
+
+ /// Nokia
+ WAVE_FORMAT_NOKIA_ADAPTIVE_MULTIRATE = 0x4201,
+
+ /// Divio, Inc.
+ WAVE_FORMAT_DIVIO_G726 = 0x4243,
+
+ /// LEAD Technologies
+ WAVE_FORMAT_LEAD_SPEECH = 0x434C,
+
+ /// LEAD Technologies
+ WAVE_FORMAT_LEAD_VORBIS = 0x564C,
+
+ /// xiph.org
+ WAVE_FORMAT_WAVPACK_AUDIO = 0x5756,
+
+ /// Apple Lossless
+ WAVE_FORMAT_ALAC = 0x6C61,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_1 = 0x674F,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_2 = 0x6750,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_3 = 0x6751,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_1_PLUS = 0x676F,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_2_PLUS = 0x6770,
+
+ /// Ogg Vorbis
+ WAVE_FORMAT_OGG_VORBIS_MODE_3_PLUS = 0x6771,
+
+ /// 3COM Corp.
+ WAVE_FORMAT_3COM_NBX = 0x7000,
+
+ /// Opus
+ WAVE_FORMAT_OPUS = 0x704F,
+
+ ///
+ WAVE_FORMAT_FAAD_AAC = 0x706D,
+
+ /// AMR Narrowband
+ WAVE_FORMAT_AMR_NB = 0x7361,
+
+ /// AMR Wideband
+ WAVE_FORMAT_AMR_WB = 0x7362,
+
+ /// AMR Wideband Plus
+ WAVE_FORMAT_AMR_WP = 0x7363,
+
+ /// GSMA/3GPP
+ WAVE_FORMAT_GSM_AMR_CBR = 0x7A21,
+
+ /// GSMA/3GPP
+ WAVE_FORMAT_GSM_AMR_VBR_SID = 0x7A22,
+
+ /// Comverse Infosys
+ WAVE_FORMAT_COMVERSE_INFOSYS_G723_1 = 0xA100,
+
+ /// Comverse Infosys
+ WAVE_FORMAT_COMVERSE_INFOSYS_AVQSBC = 0xA101,
+
+ /// Comverse Infosys
+ WAVE_FORMAT_COMVERSE_INFOSYS_SBC = 0xA102,
+
+ /// Symbol Technologies
+ WAVE_FORMAT_SYMBOL_G729_A = 0xA103,
+
+ /// VoiceAge Corp.
+ WAVE_FORMAT_VOICEAGE_AMR_WB = 0xA104,
+
+ /// Ingenient Technologies, Inc.
+ WAVE_FORMAT_INGENIENT_G726 = 0xA105,
+
+ /// ISO/MPEG-4
+ WAVE_FORMAT_MPEG4_AAC = 0xA106,
+
+ /// Encore Software
+ WAVE_FORMAT_ENCORE_G726 = 0xA107,
+
+ /// ZOLL Medical Corp.
+ WAVE_FORMAT_ZOLL_ASAO = 0xA108,
+
+ /// xiph.org
+ WAVE_FORMAT_SPEEX_VOICE = 0xA109,
+
+ /// Vianix LLC
+ WAVE_FORMAT_VIANIX_MASC = 0xA10A,
+
+ /// Microsoft
+ WAVE_FORMAT_WM9_SPECTRUM_ANALYZER = 0xA10B,
+
+ /// Microsoft
+ WAVE_FORMAT_WMF_SPECTRUM_ANAYZER = 0xA10C,
+
+ ///
+ WAVE_FORMAT_GSM_610 = 0xA10D,
+
+ ///
+ WAVE_FORMAT_GSM_620 = 0xA10E,
+
+ ///
+ WAVE_FORMAT_GSM_660 = 0xA10F,
+
+ ///
+ WAVE_FORMAT_GSM_690 = 0xA110,
+
+ ///
+ WAVE_FORMAT_GSM_ADAPTIVE_MULTIRATE_WB = 0xA111,
+
+ /// Polycom
+ WAVE_FORMAT_POLYCOM_G722 = 0xA112,
+
+ /// Polycom
+ WAVE_FORMAT_POLYCOM_G728 = 0xA113,
+
+ /// Polycom
+ WAVE_FORMAT_POLYCOM_G729_A = 0xA114,
+
+ /// Polycom
+ WAVE_FORMAT_POLYCOM_SIREN = 0xA115,
+
+ /// Global IP
+ WAVE_FORMAT_GLOBAL_IP_ILBC = 0xA116,
+
+ /// RadioTime
+ WAVE_FORMAT_RADIOTIME_TIME_SHIFT_RADIO = 0xA117,
+
+ /// Nice Systems
+ WAVE_FORMAT_NICE_ACA = 0xA118,
+
+ /// Nice Systems
+ WAVE_FORMAT_NICE_ADPCM = 0xA119,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G721 = 0xA11A,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G726 = 0xA11B,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G722_1 = 0xA11C,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G728 = 0xA11D,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G729 = 0xA11E,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G729_A = 0xA11F,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_G723_1 = 0xA120,
+
+ /// Vocord Telecom
+ WAVE_FORMAT_VOCORD_LBC = 0xA121,
+
+ /// Nice Systems
+ WAVE_FORMAT_NICE_G728 = 0xA122,
+
+ /// France Telecom
+ WAVE_FORMAT_FRACE_TELECOM_G729 = 0xA123,
+
+ /// CODIAN
+ WAVE_FORMAT_CODIAN = 0xA124,
+
+ /// flac.sourceforge.net
+ WAVE_FORMAT_FLAC = 0xF1AC,
+
+ /// Microsoft
+ WAVE_FORMAT_EXTENSIBLE = 0xFFFE,
+
+ ///
+ /// New wave format development should be based on the WAVEFORMATEXTENSIBLE structure. WAVEFORMATEXTENSIBLE allows you to avoid
+ /// having to register a new format tag with Microsoft. However, if you must still define a new format tag, the
+ /// WAVE_FORMAT_DEVELOPMENT format tag can be used during the development phase of a new wave format. Before shipping, you MUST
+ /// acquire an official format tag from Microsoft.
+ ///
+ WAVE_FORMAT_DEVELOPMENT = 0xFFFF,
+ }
+
+ ///
+ /// The PCMWAVEFORMAT structure describes the data format for PCM waveform-audio data. This structure has been superseded by
+ /// the WAVEFORMATEX structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-pcmwaveformat typedef struct pcmwaveformat_tag { WAVEFORMAT wf;
+ // WORD wBitsPerSample; } PCMWAVEFORMAT;
+ [PInvokeData("mmreg.h", MSDNShortId = "NS:mmreg.pcmwaveformat_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PCMWAVEFORMAT
+ {
+ /// A WAVEFORMAT structure containing general information about the format of the data.
+ public WAVEFORMAT wf;
+
+ /// Number of bits per sample.
+ public ushort wBitsPerSample;
+ }
+
+ ///
+ /// The WAVEFILTER structure defines a filter for waveform-audio data. Only filter information common to all waveform-audio
+ /// data filters is included in this structure. For filters that require additional information, this structure is included as the
+ /// first member in another structure along with the additional information.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-wavefilter typedef struct wavefilter_tag { DWORD cbStruct;
+ // DWORD dwFilterTag; DWORD fdwFilter; DWORD dwReserved[5]; } WAVEFILTER;
+ [PInvokeData("mmreg.h", MSDNShortId = "NS:mmreg.wavefilter_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct WAVEFILTER
+ {
+ ///
+ /// Size, in bytes, of the WAVEFILTER structure. The size specified in this member must be large enough to contain the
+ /// base WAVEFILTER structure.
+ ///
+ public uint cbStruct;
+
+ /// Waveform-audio filter type. Filter tags are registered with Microsoft Corporation for various filter algorithms.
+ public uint dwFilterTag;
+
+ ///
+ /// Flags for the dwFilterTag member. The flags defined for this member are universal to all filters. Currently, no flags
+ /// are defined.
+ ///
+ public uint fdwFilter;
+
+ /// Reserved for system use; should not be examined or modified by an application.
+ private readonly uint dwReserved1;
+
+ private readonly uint dwReserved2;
+ private readonly uint dwReserved3;
+ private readonly uint dwReserved4;
+ private readonly uint dwReserved5;
+ }
+
+ ///
+ /// The WAVEFORMAT structure describes the format of waveform-audio data. Only format information common to all
+ /// waveform-audio data formats is included in this structure. This structure has been superseded by the WAVEFORMATEX structure.
+ ///
+ ///
+ /// For formats that require additional information, this structure is included as a member in another structure along with the
+ /// additional information.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformat typedef struct waveformat_tag { WORD wFormatTag;
+ // WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; } WAVEFORMAT;
+ [PInvokeData("mmreg.h", MSDNShortId = "NS:mmreg.waveformat_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct WAVEFORMAT
+ {
+ ///
+ /// Format type. The following type is defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// WAVE_FORMAT_PCM
+ /// Waveform-audio data is PCM.
+ ///
+ ///
+ ///
+ public WAVE_FORMAT wFormatTag;
+
+ /// Number of channels in the waveform-audio data. Mono data uses one channel and stereo data uses two channels.
+ public ushort nChannels;
+
+ /// Sample rate, in samples per second.
+ public uint nSamplesPerSec;
+
+ ///
+ /// Required average data transfer rate, in bytes per second. For example, 16-bit stereo at 44.1 kHz has an average data rate of
+ /// 176,400 bytes per second (2 channels — 2 bytes per sample per channel — 44,100 samples per second).
+ ///
+ public uint nAvgBytesPerSec;
+
+ ///
+ /// Block alignment, in bytes. The block alignment is the minimum atomic unit of data. For PCM data, the block alignment is the
+ /// number of bytes used by a single sample, including data for both channels if the data is stereo. For example, the block
+ /// alignment for 16-bit stereo PCM is 4 bytes (2 channels — 2 bytes per sample).
+ ///
+ public ushort nBlockAlign;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/MmSystem.cs b/PInvoke/Multimedia/MmSystem.cs
new file mode 100644
index 00000000..0548f293
--- /dev/null
+++ b/PInvoke/Multimedia/MmSystem.cs
@@ -0,0 +1,575 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the WinMm.dll
+ public static partial class WinMm
+ {
+ ///
+ /// The DRVCALLBACK function is the callback function used with the waveform-audio input device. This function is a
+ /// placeholder for the application-defined function name. The address of this function can be specified in the callback-address
+ /// parameter of the waveInOpen function.
+ ///
+ /// Handle to the waveform-audio device associated with the callback function.
+ ///
+ /// Waveform-audio input message. It can be one of the following messages.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// WIM_CLOSE
+ /// Sent when the device is closed using the waveInClose function.
+ ///
+ /// -
+ /// WIM_DATA
+ /// Sent when the device driver is finished with a data block sent using the waveInAddBuffer function.
+ ///
+ /// -
+ /// WIM_OPEN
+ /// Sent when the device is opened using the waveInOpen function.
+ ///
+ ///
+ ///
+ /// User instance data specified with waveInOpen.
+ /// Message parameter.
+ /// Message parameter.
+ /// This function does not return a value.
+ ///
+ /// Applications should not call any system-defined functions from inside a callback function, except for
+ /// EnterCriticalSection, LeaveCriticalSection, midiOutLongMsg, midiOutShortMsg,
+ /// OutputDebugString, PostMessage, PostThreadMessage, SetEvent, timeGetSystemTime,
+ /// timeGetTime, timeKillEvent, and timeSetEvent. Calling other wave functions will cause deadlock.
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/dd743849(v=vs.85) void CALLBACK waveInProc( HWAVEIN hwi, UINT uMsg, DWORD_PTR
+ // dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate void DRVCALLBACK(IntPtr hdrvr, uint uMsg, IntPtr dwUser, IntPtr dwParam1, IntPtr dwParam2);
+
+ ///
+ /// Flags used with waveOutOpen(), waveInOpen(), midiInOpen(), and midiOutOpen() to specify the type of the dwCallback parameter.
+ ///
+ [PInvokeData("mmsyscom.h", MSDNShortId = "NF:mmeapi.waveInOpen")]
+ [Flags]
+ public enum CALLBACK_FLAGS : uint
+ {
+ /// No callback mechanism. This is the default setting.
+ CALLBACK_NULL = 0x00000000,
+
+ /// The dwCallback parameter is a window handle.
+ CALLBACK_WINDOW = 0x00010000,
+
+ /// The dwCallback parameter is a task handle.
+ CALLBACK_TASK = 0x00020000,
+
+ /// The dwCallback parameter is a callback procedure address.
+ CALLBACK_FUNCTION = 0x00030000,
+
+ /// The dwCallback parameter is a thread identifier.
+ CALLBACK_THREAD = CALLBACK_TASK,
+
+ /// The dwCallback parameter is an event handle.
+ CALLBACK_EVENT = 0x00050000,
+ }
+
+ /// Multimedia function result codes.
+ [PInvokeData("mmsyscon.h")]
+ public enum MMRESULT
+ {
+ /// no error
+ MMSYSERR_NOERROR = 0,
+
+ /// unspecified error
+ MMSYSERR_ERROR = MMSYSERR_BASE + 1,
+
+ /// Specified device identifier is out of range.
+ MMSYSERR_BADDEVICEID = MMSYSERR_BASE + 2,
+
+ /// driver failed enable
+ MMSYSERR_NOTENABLED = MMSYSERR_BASE + 3,
+
+ /// Specified resource is already allocated.
+ MMSYSERR_ALLOCATED = MMSYSERR_BASE + 4,
+
+ /// Specified device handle is invalid.
+ MMSYSERR_INVALHANDLE = MMSYSERR_BASE + 5,
+
+ /// No device driver is present.
+ MMSYSERR_NODRIVER = MMSYSERR_BASE + 6,
+
+ /// Unable to allocate or lock memory.
+ MMSYSERR_NOMEM = MMSYSERR_BASE + 7,
+
+ /// function isn't supported
+ MMSYSERR_NOTSUPPORTED = MMSYSERR_BASE + 8,
+
+ /// Specified error number is out of range.
+ MMSYSERR_BADERRNUM = MMSYSERR_BASE + 9,
+
+ /// invalid flag passed
+ MMSYSERR_INVALFLAG = MMSYSERR_BASE + 10,
+
+ /// invalid parameter passed
+ MMSYSERR_INVALPARAM = MMSYSERR_BASE + 11,
+
+ /// handle being used simultaneously on another thread (eg callback)
+ MMSYSERR_HANDLEBUSY = MMSYSERR_BASE + 12,
+
+ /// specified alias not found
+ MMSYSERR_INVALIDALIAS = MMSYSERR_BASE + 13,
+
+ /// bad registry database
+ MMSYSERR_BADDB = MMSYSERR_BASE + 14,
+
+ /// registry key not found
+ MMSYSERR_KEYNOTFOUND = MMSYSERR_BASE + 15,
+
+ /// registry read error
+ MMSYSERR_READERROR = MMSYSERR_BASE + 16,
+
+ /// registry write error
+ MMSYSERR_WRITEERROR = MMSYSERR_BASE + 17,
+
+ /// registry delete error
+ MMSYSERR_DELETEERROR = MMSYSERR_BASE + 18,
+
+ /// registry value not found
+ MMSYSERR_VALNOTFOUND = MMSYSERR_BASE + 19,
+
+ /// driver does not call DriverCallback
+ MMSYSERR_NODRIVERCB = MMSYSERR_BASE + 20,
+
+ /// more data to be returned
+ MMSYSERR_MOREDATA = MMSYSERR_BASE + 21,
+
+ /// Attempted to open with an unsupported waveform-audio format.
+ WAVERR_BADFORMAT = WAVERR_BASE + 0,
+
+ /// There are still buffers in the queue.
+ WAVERR_STILLPLAYING = WAVERR_BASE + 1,
+
+ /// The buffer pointed to by the pwh parameter hasn't been prepared.
+ WAVERR_UNPREPARED = WAVERR_BASE + 2,
+
+ /// device is synchronous
+ WAVERR_SYNC = WAVERR_BASE + 3,
+
+ /// last error in range
+ WAVERR_LASTERROR = WAVERR_BASE + 3,
+ }
+
+ /// Time format.
+ [PInvokeData("Mmsystem.h")]
+ public enum MMTIME_TYPE
+ {
+ /// time in milliseconds
+ TIME_MS = 0x0001,
+
+ /// number of wave samples
+ TIME_SAMPLES = 0x0002,
+
+ /// current byte offset
+ TIME_BYTES = 0x0004,
+
+ /// SMPTE time
+ TIME_SMPTE = 0x0008,
+
+ /// MIDI time
+ TIME_MIDI = 0x0010,
+
+ /// Ticks within MIDI stream
+ TIME_TICKS = 0x0020,
+ }
+
+ /// Flags for playing the sound.
+ [PInvokeData("Mmsystem.h")]
+ [Flags]
+ public enum SND : uint
+ {
+ ///
+ /// The sound is played synchronously, and PlaySound returns after the sound event completes. This is the default behavior.
+ ///
+ SND_SYNC = 0x0000,
+
+ ///
+ /// The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an
+ /// asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
+ ///
+ SND_ASYNC = 0x0001,
+
+ ///
+ /// No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
+ ///
+ SND_NODEFAULT = 0x0002,
+
+ /// The pszSound parameter points to a sound loaded in memory. For more information, see Playing WAVE Resources.
+ SND_MEMORY = 0x0004,
+
+ ///
+ /// The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. If this flag is set, you
+ /// must also set the SND_ASYNC flag.
+ ///
+ SND_LOOP = 0x0008,
+
+ ///
+ /// The specified sound event will yield to another sound event that is already playing in the same process. If a sound cannot
+ /// be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns
+ /// FALSE without playing the requested sound. If this flag is not specified, PlaySound attempts to stop any sound that is
+ /// currently playing in the same process. Sounds played in other processes are not affected.
+ ///
+ SND_NOSTOP = 0x0010,
+
+ ///
+ /// Not supported. Note Previous versions of the documentation implied incorrectly that this flag is supported. The function
+ /// ignores this flag.
+ ///
+ SND_NOWAIT = 0x00002000,
+
+ ///
+ /// The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
+ ///
+ SND_ALIAS = 0x00010000,
+
+ /// The pszSound parameter is a predefined identifier for a system-event alias. See Remarks.
+ SND_ALIAS_ID = 0x00110000,
+
+ ///
+ /// The pszSound parameter is a file name. If the file cannot be found, the function plays the default sound unless the
+ /// SND_NODEFAULT flag is set.
+ ///
+ SND_FILENAME = 0x00020000,
+
+ ///
+ /// The pszSound parameter is a resource identifier; hmod must identify the instance that contains the resource. For more
+ /// information, see Playing WAVE Resources.
+ ///
+ SND_RESOURCE = 0x00040004,
+
+ /// Not supported.
+ SND_PURGE = 0x0040,
+
+ ///
+ /// The pszSound parameter is an application-specific alias in the registry. You can combine this flag with the SND_ALIAS or
+ /// SND_ALIAS_ID flag to specify an application-defined sound alias.
+ ///
+ SND_APPLICATION = 0x0080,
+
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the function triggers a SoundSentry event when the sound is
+ /// played. SoundSentry is an accessibility feature that causes the computer to display a visual cue when a sound is played. If
+ /// the user did not enable SoundSentry, the visual cue is not displayed.
+ ///
+ SND_SENTRY = 0x00080000,
+
+ /// Treat this as a "ring" from a communications app - don't duck me
+ SND_RING = 0x00100000,
+
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the sound is assigned to the audio session for system
+ /// notification sounds. The system volume-control program (SndVol) displays a volume slider that controls system notification
+ /// sounds. Setting this flag puts the sound under the control of that volume slider If this flag is not set, the sound is
+ /// assigned to the default audio session for the application's process. For more information, see the documentation for the
+ /// Core Audio APIs.
+ ///
+ SND_SYSTEM = 0x00200000,
+ }
+
+ /// Makes a four character code.
+ /// The first character.
+ /// The second character.
+ /// The third character.
+ /// The fourth character.
+ /// The character code.
+ public static uint MAKEFOURCC(char ch0, char ch1, char ch2, char ch3) => (byte)ch0 | ((uint)(byte)ch1 << 8) |
+ ((uint)(byte)ch2 << 16) | ((uint)(byte)ch3 << 24);
+
+ ///
+ /// The PlaySound function plays a sound specified by the given file name, resource, or system event. (A system event may be
+ /// associated with a sound in the registry or in the WIN.INI file.)
+ ///
+ ///
+ ///
+ /// A string that specifies the sound to play. The maximum length, including the null terminator, is 256 characters. If this
+ /// parameter is NULL, any currently playing waveform sound is stopped.
+ ///
+ ///
+ /// Three flags in fdwSound ( SND_ALIAS, SND_FILENAME, and SND_RESOURCE) determine whether the name is
+ /// interpreted as an alias for a system event, a file name, or a resource identifier. If none of these flags are specified,
+ /// PlaySound searches the registry or the WIN.INI file for an association with the specified sound name. If an association
+ /// is found, the sound event is played. If no association is found in the registry, the name is interpreted as a file name.
+ ///
+ ///
+ ///
+ /// Handle to the executable file that contains the resource to be loaded. This parameter must be NULL unless
+ /// SND_RESOURCE is specified in fdwSound.
+ ///
+ ///
+ /// Flags for playing the sound. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// SND_APPLICATION
+ ///
+ /// The pszSound parameter is an application-specific alias in the registry. You can combine this flag with the SND_ALIAS or
+ /// SND_ALIAS_ID flag to specify an application-defined sound alias.
+ ///
+ ///
+ /// -
+ /// SND_ALIAS
+ ///
+ /// The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
+ ///
+ ///
+ /// -
+ /// SND_ALIAS_ID
+ /// The pszSound parameter is a predefined identifier for a system-event alias. See Remarks.
+ ///
+ /// -
+ /// SND_ASYNC
+ ///
+ /// The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously
+ /// played waveform sound, call PlaySound with pszSound set to NULL.
+ ///
+ ///
+ /// -
+ /// SND_FILENAME
+ ///
+ /// The pszSound parameter is a file name. If the file cannot be found, the function plays the default sound unless the
+ /// SND_NODEFAULT flag is set.
+ ///
+ ///
+ /// -
+ /// SND_LOOP
+ ///
+ /// The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. If this flag is set, you
+ /// must also set the SND_ASYNC flag.
+ ///
+ ///
+ /// -
+ /// SND_MEMORY
+ /// The pszSound parameter points to a sound loaded in memory. For more information, see Playing WAVE Resources.
+ ///
+ /// -
+ /// SND_NODEFAULT
+ /// No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
+ ///
+ /// -
+ /// SND_NOSTOP
+ ///
+ /// The specified sound event will yield to another sound event that is already playing in the same process. If a sound cannot be
+ /// played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE
+ /// without playing the requested sound. If this flag is not specified, PlaySound attempts to stop any sound that is currently
+ /// playing in the same process. Sounds played in other processes are not affected.
+ ///
+ ///
+ /// -
+ /// SND_NOWAIT
+ ///
+ /// Not supported. Note Previous versions of the documentation implied incorrectly that this flag is supported. The function ignores
+ /// this flag.
+ ///
+ ///
+ /// -
+ /// SND_PURGE
+ /// Not supported.
+ ///
+ /// -
+ /// SND_RESOURCE
+ ///
+ /// The pszSound parameter is a resource identifier; hmod must identify the instance that contains the resource. For more
+ /// information, see Playing WAVE Resources.
+ ///
+ ///
+ /// -
+ /// SND_SENTRY
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the function triggers a SoundSentry event when the sound is played.
+ /// SoundSentry is an accessibility feature that causes the computer to display a visual cue when a sound is played. If the user did
+ /// not enable SoundSentry, the visual cue is not displayed.
+ ///
+ ///
+ /// -
+ /// SND_SYNC
+ /// The sound is played synchronously, and PlaySound returns after the sound event completes. This is the default behavior.
+ ///
+ /// -
+ /// SND_SYSTEM
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the sound is assigned to the audio session for system notification
+ /// sounds. The system volume-control program (SndVol) displays a volume slider that controls system notification sounds. Setting
+ /// this flag puts the sound under the control of that volume slider If this flag is not set, the sound is assigned to the default
+ /// audio session for the application's process. For more information, see the documentation for the Core Audio APIs.
+ ///
+ ///
+ ///
+ ///
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// The sound specified by pszSound must fit into available physical memory and be playable by an installed waveform-audio device driver.
+ ///
+ ///
+ /// PlaySound searches the following directories for sound files: the current directory; the Windows directory; the Windows
+ /// system directory; directories listed in the PATH environment variable; and the list of directories mapped in a network. If the
+ /// function cannot find the specified sound and the SND_NODEFAULT flag is not specified, PlaySound uses the default
+ /// system event sound instead. If the function can find neither the system default entry nor the default sound, it makes no sound
+ /// and returns FALSE.
+ ///
+ /// If the SND_ALIAS_ID flag is specified in fdwSound, the pszSound parameter must be one of the following values.
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMASTERISK
+ /// "SystemAsterisk" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMDEFAULT
+ /// "SystemDefault" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMEXCLAMATION
+ /// "SystemExclamation" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMEXIT
+ /// "SystemExit" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMHAND
+ /// "SystemHand" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMQUESTION
+ /// "SystemQuestion" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMSTART
+ /// "SystemStart" event.
+ ///
+ /// -
+ /// SND_ALIAS_SYSTEMWELCOME
+ /// "SystemWelcome" event.
+ ///
+ ///
+ ///
+ /// The SND_ASYNC flag causes PlaySound to return immediately without waiting for the sound to finish playing. If you
+ /// combine the SND_MEMORY and SND_ASYNC flags, the memory buffer that contains the sound must remain valid until the
+ /// sound has completed playing.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions//dd743680(v=vs.85) BOOL PlaySound( LPCTSTR pszSound, HMODULE hmod, DWORD
+ // fdwSound );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Mmsystem.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool PlaySound([In, Optional, MarshalAs(UnmanagedType.LPTStr)] string pszSound, [In, Optional] HINSTANCE hmod, [In, Optional] SND fdwSound);
+
+ ///
+ /// The sndPlaySound function plays a waveform sound specified either by a file name or by an entry in the registry or the
+ /// WIN.INI file. This function offers a subset of the functionality of the PlaySound function; sndPlaySound is being
+ /// maintained for backward compatibility.
+ ///
+ ///
+ /// A string that specifies the sound to play. This parameter can be either an entry in the registry or in WIN.INI that identifies a
+ /// system sound, or it can be the name of a waveform-audio file. (If the function does not find the entry, the parameter is treated
+ /// as a file name.) If this parameter is NULL, any currently playing sound is stopped.
+ ///
+ ///
+ /// Flags for playing the sound. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// SND_ASYNC
+ ///
+ /// The sound is played asynchronously and the function returns immediately after beginning the sound. To terminate an
+ /// asynchronously played sound, call sndPlaySound with lpszSound set to NULL.
+ ///
+ ///
+ /// -
+ /// SND_LOOP
+ ///
+ /// The sound plays repeatedly until sndPlaySound is called again with the lpszSound parameter set to NULL. You must also specify
+ /// the SND_ASYNC flag to loop sounds.
+ ///
+ ///
+ /// -
+ /// SND_MEMORY
+ ///
+ /// The parameter specified by lpszSound points to an image of a waveform sound in memory. The data passed must be trusted by the application.
+ ///
+ ///
+ /// -
+ /// SND_NODEFAULT
+ /// If the sound cannot be found, the function returns silently without playing the default sound.
+ ///
+ /// -
+ /// SND_NOSTOP
+ ///
+ /// If a sound is currently playing in the same process, the function immediately returns FALSE, without playing the requested sound.
+ ///
+ ///
+ /// -
+ /// SND_SENTRY
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the function triggers a SoundSentry event when the sound is played.
+ /// For more information, see PlaySound.
+ ///
+ ///
+ /// -
+ /// SND_SYNC
+ /// The sound is played synchronously and the function does not return until the sound ends.
+ ///
+ /// -
+ /// SND_SYSTEM
+ ///
+ /// Note Requires Windows Vista or later. If this flag is set, the sound is assigned to the audio session for system notification
+ /// sounds. For more information, see PlaySound.
+ ///
+ ///
+ ///
+ ///
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// If the specified sound cannot be found, sndPlaySound plays the system default sound. If there is no system default entry
+ /// in the registry or WIN.INI file, or if the default sound cannot be found, the function makes no sound and returns FALSE.
+ ///
+ ///
+ /// The specified sound must fit in available physical memory and be playable by an installed waveform-audio device driver. If
+ /// sndPlaySound does not find the sound in the current directory, the function searches for it using the standard
+ /// directory-search order.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/previous-versions/dd798676(v=vs.85) BOOL sndPlaySound( LPCTSTR lpszSound, UINT fuSound );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("Mmsystem.h")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool sndPlaySound([In, Optional] string lpszSound, uint fuSound);
+
+ /// Multimedia time.
+ // https://docs.microsoft.com/en-us/previous-versions/dd757347(v=vs.85) typedef struct mmtime_tag { UINT wType; union { DWORD ms;
+ // DWORD sample; DWORD cb; DWORD ticks; struct { BYTE hour; BYTE min; BYTE sec; BYTE frame; BYTE fps; BYTE dummy; BYTE pad[2]; }
+ // smpte; struct { DWORD songptrpos; } midi; } u; } MMTIME, *PMMTIME, *LPMMTIME;
+ [PInvokeData("Mmsystem.h")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct MMTIME
+ {
+ /// Time format.
+ public MMTIME_TYPE wType;
+
+ /// The value.
+ public uint u;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/MmeApi.cs b/PInvoke/Multimedia/MmeApi.cs
new file mode 100644
index 00000000..538780b9
--- /dev/null
+++ b/PInvoke/Multimedia/MmeApi.cs
@@ -0,0 +1,3370 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the WinMm.dll
+ public static partial class WinMm
+ {
+ private const string Lib_Winmm = "WinMm.dll";
+ private const int MMSYSERR_BASE = 0;
+ private const int WAVERR_BASE = 32;
+
+ /// Describes optional functionality supported by the auxiliary audio device.
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.auxcaps_tag")]
+ [Flags]
+ public enum AUX_CAPS : uint
+ {
+ /// Supports volume control.
+ AUXCAPS_VOLUME = 0x0001,
+
+ /// Supports separate left and right volume control.
+ AUXCAPS_LRVOLUME = 0x0002,
+ }
+
+ /// Flags for opening the device.
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInOpen")]
+ [Flags]
+ public enum WAVE_OPEN : uint
+ {
+ /// The function queries the device to determine whether it supports the given format, but it does not open the device.
+ WAVE_FORMAT_QUERY = 0x0001,
+
+ ///
+ WAVE_ALLOWSYNC = 0x0002,
+
+ /// The uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.
+ WAVE_MAPPED = 0x0004,
+
+ /// If this flag is specified, the ACM driver does not perform conversions on the audio data.
+ WAVE_FORMAT_DIRECT = 0x0008,
+
+ ///
+ WAVE_FORMAT_DIRECT_QUERY = WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT,
+
+ ///
+ /// If this flag is specified and the uDeviceID parameter is WAVE_MAPPER, the function opens the default communication device.
+ /// This flag applies only when uDeviceID equals WAVE_MAPPER.
+ ///
+ WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE = 0x0010,
+
+ /// No callback mechanism. This is the default setting.
+ CALLBACK_NULL = 0x00000000,
+
+ /// The dwCallback parameter is a window handle.
+ CALLBACK_WINDOW = 0x00010000,
+
+ /// The dwCallback parameter is a task handle.
+ CALLBACK_TASK = 0x00020000,
+
+ /// The dwCallback parameter is a callback procedure address. See .
+ CALLBACK_FUNCTION = 0x00030000,
+
+ /// The dwCallback parameter is a thread identifier.
+ CALLBACK_THREAD = CALLBACK_TASK,
+
+ /// The dwCallback parameter is an event handle.
+ CALLBACK_EVENT = 0x00050000,
+ }
+
+ /// Optional functionality supported by the device.
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.waveoutcaps_tag")]
+ [Flags]
+ public enum WAVECAPS : uint
+ {
+ /// Supports pitch control.
+ WAVECAPS_PITCH = 0x0001,
+
+ /// Supports playback rate control.
+ WAVECAPS_PLAYBACKRATE = 0x0002,
+
+ /// Supports volume control.
+ WAVECAPS_VOLUME = 0x0004,
+
+ /// Supports separate left and right volume control.
+ WAVECAPS_LRVOLUME = 0x0008,
+
+ /// The driver is synchronous and will block while playing a buffer.
+ WAVECAPS_SYNC = 0x0010,
+
+ /// Returns sample-accurate position information.
+ WAVECAPS_SAMPLEACCURATE = 0x0020,
+ }
+
+ /// Flags for WAVEHDR.
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.wavehdr_tag")]
+ [Flags]
+ public enum WHDR
+ {
+ /// Set by the device driver to indicate that it is finished with the buffer and is returning it to the application.
+ WHDR_DONE = 0x00000001,
+
+ ///
+ /// Set by Windows to indicate that the buffer has been prepared with the waveInPrepareHeader or waveOutPrepareHeader function.
+ ///
+ WHDR_PREPARED = 0x00000002,
+
+ /// This buffer is the first buffer in a loop. This flag is used only with output buffers.
+ WHDR_BEGINLOOP = 0x00000004,
+
+ /// This buffer is the last buffer in a loop. This flag is used only with output buffers.
+ WHDR_ENDLOOP = 0x00000008,
+
+ /// Set by Windows to indicate that the buffer is queued for playback.
+ WHDR_INQUEUE = 0x00000010,
+ }
+
+ /// The auxGetDevCaps function retrieves the capabilities of a given auxiliary output device.
+ ///
+ ///
+ /// Identifier of the auxiliary output device to be queried. Specify a valid device identifier (see the following comments section),
+ /// or use the following constant:
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// AUX_MAPPER
+ /// Auxiliary audio mapper. The function returns an error if no auxiliary audio mapper is installed.
+ ///
+ ///
+ ///
+ /// Pointer to an AUXCAPS structure to be filled with information about the capabilities of the device.
+ /// Size, in bytes, of the AUXCAPS structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ ///
+ ///
+ ///
+ /// The device identifier in uDeviceID varies from zero to one less than the number of devices present. AUX_MAPPER may also be used.
+ /// Use the auxGetNumDevs function to determine the number of auxiliary output devices present in the system.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-auxgetdevcaps MMRESULT auxGetDevCaps( UINT uDeviceID,
+ // LPAUXCAPS pac, UINT cbac );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.auxGetDevCaps")]
+ public static extern MMRESULT auxGetDevCaps(uint uDeviceID, out AUXCAPS pac, uint cbac);
+
+ /// The auxGetNumDevs function retrieves the number of auxiliary output devices present in the system.
+ /// Returns the number of device. A return value of zero means that no devices are present or that an error occurred.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-auxgetnumdevs UINT auxGetNumDevs();
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.auxGetNumDevs")]
+ public static extern uint auxGetNumDevs();
+
+ /// The auxGetVolume function retrieves the current volume setting of the specified auxiliary output device.
+ /// Identifier of the auxiliary output device to be queried.
+ ///
+ ///
+ /// Pointer to a variable to be filled with the current volume setting. The low-order word of this location contains the left
+ /// channel volume setting, and the high-order word contains the right channel setting. A value of 0xFFFF represents full volume,
+ /// and a value of 0x0000 is silence.
+ ///
+ ///
+ /// If a device does not support both left and right volume control, the low-order word of the specified location contains the
+ /// volume level.
+ ///
+ ///
+ /// The full 16-bit setting(s) set with the auxSetVolume function are returned, regardless of whether the device supports the full
+ /// 16 bits of volume-level control.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Not all devices support volume control. To determine whether a device supports volume control, use the AUXCAPS_VOLUME flag to
+ /// test the dwSupport member of the AUXCAPS structure (filled by the auxGetDevCaps function).
+ ///
+ ///
+ /// To determine whether a device supports volume control on both the left and right channels, use the AUXCAPS_LRVOLUME flag to test
+ /// the dwSupport member of the AUXCAPS structure (filled by auxGetDevCaps).
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-auxgetvolume MMRESULT auxGetVolume( UINT uDeviceID, LPDWORD
+ // pdwVolume );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.auxGetVolume")]
+ public static extern MMRESULT auxGetVolume(uint uDeviceID, out uint pdwVolume);
+
+ ///
+ /// The auxOutMessage function sends a message to the given auxiliary output device. This function also performs error
+ /// checking on the device identifier passed as part of the message.
+ ///
+ /// Identifier of the auxiliary output device to receive the message.
+ /// Message to send.
+ /// Message parameter.
+ /// Message parameter.
+ /// Returns the message return value.
+ ///
+ /// The
+ /// DRV_QUERYDEVICEINTERFACE
+ /// message queries for the device-interface name of a waveIn, waveOut, midiIn, midiOut, or mixer device.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam1 is a pointer to a caller-allocated buffer into which the function writes a null-terminated Unicode string containing
+ /// the device-interface name. If the device has no device interface, the string length is zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam2 specifies the buffer size in bytes. This is an input parameter to the function. The caller should specify a size that
+ /// is greater than or equal to the buffer size retrieved by the DRV_QUERYDEVICEINTERFACESIZE message.
+ ///
+ ///
+ /// The DRV_QUERYDEVICEINTERFACE message is supported in Windows Me, and Windows 2000 and later. This message is valid only for the
+ /// waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this message and
+ /// returns the appropriate value without sending the message to the device driver. For general information about system-intercepted
+ /// xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The following two message constants are used together for the purpose of obtaining device interface names:
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACE
+ ///
+ ///
+ ///
+ /// The first message obtains the size in bytes of the buffer needed to hold the string containing the device interface name. The
+ /// second message retrieves the name string in a buffer of the required size.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// message queries for the size of the buffer required to hold the device-interface name.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam1 is a pointer to buffer size. This parameter points to a ULONG variable into which the function writes the required
+ /// buffer size in bytes. The size includes storage space for the name string's terminating null. The size is zero if the device ID
+ /// identifies a device that has no device interface.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The
+ /// system intercepts this message and returns the appropriate value without sending the message to the device driver. For general
+ /// information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// The buffer size retrieved by this message is expressed as a byte count. It specifies the size of the buffer needed to hold the
+ /// null-terminated Unicode string that contains the device-interface name. The caller allocates a buffer of the specified size and
+ /// uses the DRV_QUERYDEVICEINTERFACE message to retrieve the device-interface name string.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVNODE
+ /// message queries for the devnode number assigned to the device by the Plug and Play manager.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam1 is a pointer to a caller-allocated DWORD variable into which the function writes the devnode number. If no devnode is
+ /// assigned to the device, the function sets this variable to zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// In Windows 2000 and later, the message always returns MMSYSERR_NOTSUPPORTED. This message is valid only for the waveInMessage,
+ /// waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this message and returns the
+ /// appropriate value without sending the message to the device driver. For general information about system-intercepted
+ /// xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The
+ /// DRV_QUERYMAPPABLE
+ /// message queries for whether the specified device can be used by a mapper.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam1 is unused. Set this parameter to zero.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, mixerMessage and
+ /// auxOutMessage functions. The system intercepts this message and returns the appropriate value without sending the message
+ /// to the device driver. For general information about system-intercepted xxxMessage functions, see System-Intercepted
+ /// Device Messages.
+ ///
+ ///
+ /// When an application program opens a mapper instead of a specific audio device, the system inserts a mapper between the
+ /// application and the available devices. The mapper selects an appropriate device by mapping the application's requirements to one
+ /// of the available devices. For more information about mappers, see the Microsoft Windows SDK documentation.
+ ///
+ /// The
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// message retrieves the device ID of the preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred voice-communications device. The function writes the value (-1) if no device is available that qualifies
+ /// as a preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined: DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage and waveOutMessage functions. When a caller calls these two functions with the
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET message, the caller must specify the device ID as WAVE_MAPPER, and then cast this value to the
+ /// appropriate handle type. For the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, or mixerMessage
+ /// functions, the caller must cast the device ID to a handle of type HWAVEIN, HWAVEOUT, HMIDIIN, HMIDIOUT, or HMIXER, respectively.
+ /// Note that if the caller supplies a valid handle instead of a device ID for this parameter, the function fails and returns error
+ /// code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred specifically for voice communications, in contrast to the
+ /// DRVM_MAPPER_PREFERRED_GET message, which determines which device is preferred for all other audio functions.
+ ///
+ ///
+ /// For example, the preferred waveOut device for voice communications might be the earpiece in a headset, but the preferred
+ /// waveOut device for all other audio functions might be a set of stereo speakers.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred voice-communications device and do not search for other
+ /// available devices if the preferred device is unavailable. The flag that is output by either the waveInMessage or
+ /// waveOutMessage call applies to the preferred voice-communications device for both the waveIn and waveOut
+ /// APIs, regardless of whether the call is made to waveInMessage or waveOutMessage. For more information, see
+ /// Preferred Voice-Communications Device ID.
+ ///
+ /// The
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// message retrieves the device ID of the preferred audio device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred device. The function writes the value (-1) if no device is available that qualifies as a preferred device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined (for waveInMessage and waveOutMessage calls only): DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage and midiOutMessage functions. When the caller calls these
+ /// functions with the DRVM_MAPPER_PREFERRED_GET message, the caller must first specify the device ID as WAVE_MAPPER (for
+ /// waveInMessage or waveOutMessage) or MIDI_MAPPER (for midiOutMessage), and then cast this value to the
+ /// appropriate handle type. For the waveInMessage, waveOutMessage, or midiOutMessage functions, the caller
+ /// must cast the device ID to a handle type HWAVEIN, HWAVEOUT or HMIDIOUT, respectively. Note that if the caller supplies a valid
+ /// handle instead of a device ID for this parameter, the function fails and returns error code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred for audio functions in general, in contrast to the
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET message, which determines which device is preferred specifically for voice communications.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred device and do not search for other available devices if the
+ /// preferred device is unavailable. Note that the midiOutMessage function does not output this flag--the midiOut API
+ /// always uses only the preferred device. The flag that is output by either the waveInMessage or waveOutMessage call
+ /// applies to the preferred device for both the waveIn and waveOut APIs, regardless of whether the call is made to
+ /// waveInMessage or waveOutMessage.
+ ///
+ ///
+ /// The xxxMessage functions accept this value in place of a valid device handle in order to allow an application to determine the
+ /// default device ID without first having to open a device. For more information, see Accessing the Preferred Device ID.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-auxoutmessage MMRESULT auxOutMessage( UINT uDeviceID, UINT
+ // uMsg, DWORD_PTR dw1, DWORD_PTR dw2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.auxOutMessage")]
+ public static extern MMRESULT auxOutMessage(uint uDeviceID, uint uMsg, IntPtr dw1, IntPtr dw2);
+
+ /// The auxSetVolume function sets the volume of the specified auxiliary output device.
+ ///
+ /// Identifier of the auxiliary output device to be queried. Device identifiers are determined implicitly from the number of devices
+ /// present in the system. Device identifier values range from zero to one less than the number of devices present. Use the
+ /// auxGetNumDevs function to determine the number of auxiliary devices in the system.
+ ///
+ ///
+ ///
+ /// Specifies the new volume setting. The low-order word specifies the left-channel volume setting, and the high-order word
+ /// specifies the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
+ ///
+ ///
+ /// If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and
+ /// the high-order word is ignored.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Not all devices support volume control. To determine whether the device supports volume control, use the AUXCAPS_VOLUME flag to
+ /// test the dwSupport member of the AUXCAPS structure (filled by the auxGetDevCaps function).
+ ///
+ ///
+ /// To determine whether the device supports volume control on both the left and right channels, use the AUXCAPS_LRVOLUME flag to
+ /// test the dwSupport member of the AUXCAPS structure (filled by auxGetDevCaps).
+ ///
+ ///
+ /// Most devices do not support the full 16 bits of volume-level control and will use only the high-order bits of the requested
+ /// volume setting. For example, for a device that supports 4 bits of volume control, requested volume level values of 0x4000,
+ /// 0x4FFF, and 0x43BE will produce the same physical volume setting, 0x4000. The auxGetVolume function will return the full 16-bit
+ /// setting set with auxSetVolume.
+ ///
+ ///
+ /// Volume settings are interpreted logarithmically. This means the perceived volume increase is the same when increasing the volume
+ /// level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-auxsetvolume MMRESULT auxSetVolume( UINT uDeviceID, DWORD
+ // dwVolume );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.auxSetVolume")]
+ public static extern MMRESULT auxSetVolume(uint uDeviceID, uint dwVolume);
+
+ ///
+ /// The waveInAddBuffer function sends an input buffer to the given waveform-audio input device. When the buffer is filled,
+ /// the application is notified.
+ ///
+ /// Handle to the waveform-audio input device.
+ /// Pointer to a WAVEHDR structure that identifies the buffer.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_UNPREPARED
+ /// The buffer pointed to by the pwh parameter hasn't been prepared.
+ ///
+ ///
+ ///
+ ///
+ /// When the buffer is filled, the WHDR_DONE bit is set in the dwFlags member of the WAVEHDR structure.
+ /// The buffer must be prepared with the waveInPrepareHeader function before it is passed to this function.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinaddbuffer MMRESULT waveInAddBuffer( HWAVEIN hwi,
+ // LPWAVEHDR pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInAddBuffer")]
+ public static extern MMRESULT waveInAddBuffer([In] HWAVEIN hwi, ref WAVEHDR pwh, uint cbwh);
+
+ /// The waveInClose function closes the given waveform-audio input device.
+ ///
+ /// Handle to the waveform-audio input device. If the function succeeds, the handle is no longer valid after this call.
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_STILLPLAYING
+ /// There are still buffers in the queue.
+ ///
+ ///
+ ///
+ ///
+ /// If there are input buffers that have been sent with the waveInAddBuffer function and that haven't been returned to the
+ /// application, the close operation will fail. Call the waveInReset function to mark all pending buffers as done.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinclose MMRESULT waveInClose( HWAVEIN hwi );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInClose")]
+ public static extern MMRESULT waveInClose(HWAVEIN hwi);
+
+ /// The waveInGetDevCaps function retrieves the capabilities of a given waveform-audio input device.
+ ///
+ /// Identifier of the waveform-audio output device. It can be either a device identifier or a handle of an open waveform-audio input device.
+ ///
+ /// Pointer to a WAVEINCAPS structure to be filled with information about the capabilities of the device.
+ /// Size, in bytes, of the WAVEINCAPS structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// Use this function to determine the number of waveform-audio input devices present in the system. If the value specified by the
+ /// uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices present. The
+ /// WAVE_MAPPER constant can also be used as a device identifier. Only cbwic bytes (or less) of information is copied to the
+ /// location pointed to by pwic. If cbwic is zero, nothing is copied and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveingetdevcaps MMRESULT waveInGetDevCaps( UINT uDeviceID,
+ // LPWAVEINCAPS pwic, UINT cbwic );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInGetDevCaps")]
+ public static extern MMRESULT waveInGetDevCaps(uint uDeviceID, out WAVEINCAPS pwic, uint cbwic);
+
+ ///
+ /// The waveInGetErrorText function retrieves a textual description of the error identified by the given error number.
+ ///
+ /// Error number.
+ /// Pointer to the buffer to be filled with the textual error description.
+ /// Size, in characters, of the buffer pointed to by pszText.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADERRNUM
+ /// Specified error number is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// If the textual error description is longer than the specified buffer, the description is truncated. The returned error string is
+ /// always null-terminated. If cchText is zero, nothing is copied and the function returns zero. All error descriptions are less
+ /// than MAXERRORLENGTH characters long.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveingeterrortext MMRESULT waveInGetErrorText( MMRESULT
+ // mmrError, LPSTR pszText, UINT cchText );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInGetErrorText")]
+ public static extern MMRESULT waveInGetErrorText(MMRESULT mmrError, [MarshalAs(UnmanagedType.LPStr)] StringBuilder pszText, uint cchText);
+
+ ///
+ /// The waveInGetID function gets the device identifier for the given waveform-audio input device.
+ ///
+ /// This function is supported for backward compatibility. New applications can cast a handle of the device rather than retrieving
+ /// the device identifier.
+ ///
+ ///
+ /// Handle to the waveform-audio input device.
+ /// Pointer to a variable to be filled with the device identifier.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The hwi parameter specifies an invalid handle.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveingetid MMRESULT waveInGetID( HWAVEIN hwi, LPUINT
+ // puDeviceID );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInGetID")]
+ public static extern MMRESULT waveInGetID(HWAVEIN hwi, out uint puDeviceID);
+
+ /// The waveInGetNumDevs function returns the number of waveform-audio input devices present in the system.
+ /// Returns the number of devices. A return value of zero means that no devices are present or that an error occurred.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveingetnumdevs UINT waveInGetNumDevs();
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInGetNumDevs")]
+ public static extern uint waveInGetNumDevs();
+
+ ///
+ /// [ waveInGetPosition is no longer supported for use as of Windows Vista. Instead, use IAudioClock::GetPosition.]
+ /// The waveInGetPosition function retrieves the current input position of the given waveform-audio input device.
+ ///
+ /// Handle to the waveform-audio input device.
+ /// Pointer to an MMTIME structure.
+ /// Size, in bytes, of the MMTIME structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Before calling this function, set the wType member of the MMTIME structure to indicate the time format you want. After
+ /// calling this function, check wType to determine whether the desired time format is supported. If the format is not
+ /// supported, the member will specify an alternative format.
+ ///
+ /// The position is set to zero when the device is opened or reset.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveingetposition MMRESULT waveInGetPosition( HWAVEIN hwi,
+ // LPMMTIME pmmt, UINT cbmmt );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInGetPosition")]
+ public static extern MMRESULT waveInGetPosition(HWAVEIN hwi, ref MMTIME pmmt, uint cbmmt);
+
+ /// The waveInMessage function sends messages to the waveform-audio input device drivers.
+ ///
+ /// Identifier of the waveform device that receives the message. You must cast the device ID to the HWAVEIN handle type. If
+ /// you supply a handle instead of a device ID, the function fails and returns the MMSYSERR_NOSUPPORT error code.
+ ///
+ /// Message to send.
+ /// Message parameter.
+ /// Message parameter.
+ /// Returns the value returned from the driver.
+ ///
+ /// The
+ /// DRV_QUERYDEVICEINTERFACE
+ /// message queries for the device-interface name of a waveIn, waveOut, midiIn, midiOut, or mixer device.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam1 is a pointer to a caller-allocated buffer into which the function writes a null-terminated Unicode string containing
+ /// the device-interface name. If the device has no device interface, the string length is zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam2 specifies the buffer size in bytes. This is an input parameter to the function. The caller should specify a size that
+ /// is greater than or equal to the buffer size retrieved by the DRV_QUERYDEVICEINTERFACESIZE message.
+ ///
+ ///
+ /// The DRV_QUERYDEVICEINTERFACE message is supported in Windows Me, and Windows 2000 and later. This message is valid only for the
+ /// waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this
+ /// message and returns the appropriate value without sending the message to the device driver. For general information about
+ /// system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The following two message constants are used together for the purpose of obtaining device interface names:
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACE
+ ///
+ ///
+ ///
+ /// The first message obtains the size in bytes of the buffer needed to hold the string containing the device interface name. The
+ /// second message retrieves the name string in a buffer of the required size.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// message queries for the size of the buffer required to hold the device-interface name.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam1 is a pointer to buffer size. This parameter points to a ULONG variable into which the function writes the required
+ /// buffer size in bytes. The size includes storage space for the name string's terminating null. The size is zero if the device ID
+ /// identifies a device that has no device interface.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage
+ /// functions. The system intercepts this message and returns the appropriate value without sending the message to the device
+ /// driver. For general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// The buffer size retrieved by this message is expressed as a byte count. It specifies the size of the buffer needed to hold the
+ /// null-terminated Unicode string that contains the device-interface name. The caller allocates a buffer of the specified size and
+ /// uses the DRV_QUERYDEVICEINTERFACE message to retrieve the device-interface name string.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVNODE
+ /// message queries for the devnode number assigned to the device by the Plug and Play manager.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam1 is a pointer to a caller-allocated DWORD variable into which the function writes the devnode number. If no devnode is
+ /// assigned to the device, the function sets this variable to zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// In Windows 2000 and later, the message always returns MMSYSERR_NOTSUPPORTED. This message is valid only for the
+ /// waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this
+ /// message and returns the appropriate value without sending the message to the device driver. For general information about
+ /// system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The
+ /// DRV_QUERYMAPPABLE
+ /// message queries for whether the specified device can be used by a mapper.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam1 is unused. Set this parameter to zero.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, mixerMessage and
+ /// auxOutMessage functions. The system intercepts this message and returns the appropriate value without sending the message to the
+ /// device driver. For general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// When an application program opens a mapper instead of a specific audio device, the system inserts a mapper between the
+ /// application and the available devices. The mapper selects an appropriate device by mapping the application's requirements to one
+ /// of the available devices. For more information about mappers, see the Microsoft Windows SDK documentation.
+ ///
+ /// The
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// message retrieves the device ID of the preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred voice-communications device. The function writes the value (-1) if no device is available that qualifies
+ /// as a preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined: DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage and waveOutMessage functions. When a caller calls these two functions
+ /// with the DRVM_MAPPER_CONSOLEVOICECOM_GET message, the caller must specify the device ID as WAVE_MAPPER, and then cast this value
+ /// to the appropriate handle type. For the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, or
+ /// mixerMessage functions, the caller must cast the device ID to a handle of type HWAVEIN, HWAVEOUT, HMIDIIN, HMIDIOUT, or HMIXER,
+ /// respectively. Note that if the caller supplies a valid handle instead of a device ID for this parameter, the function fails and
+ /// returns error code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred specifically for voice communications, in contrast to the
+ /// DRVM_MAPPER_PREFERRED_GET message, which determines which device is preferred for all other audio functions.
+ ///
+ ///
+ /// For example, the preferred waveOut device for voice communications might be the earpiece in a headset, but the preferred
+ /// waveOut device for all other audio functions might be a set of stereo speakers.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred voice-communications device and do not search for other
+ /// available devices if the preferred device is unavailable. The flag that is output by either the waveInMessage or
+ /// waveOutMessage call applies to the preferred voice-communications device for both the waveIn and waveOut
+ /// APIs, regardless of whether the call is made to waveInMessage or waveOutMessage. For more information, see
+ /// Preferred Voice-Communications Device ID.
+ ///
+ /// The
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// message retrieves the device ID of the preferred audio device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred device. The function writes the value (-1) if no device is available that qualifies as a preferred device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined (for waveInMessage and waveOutMessage calls only): DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage and midiOutMessage functions. When the caller calls
+ /// these functions with the DRVM_MAPPER_PREFERRED_GET message, the caller must first specify the device ID as WAVE_MAPPER (for
+ /// waveInMessage or waveOutMessage) or MIDI_MAPPER (for midiOutMessage), and then cast this value to the
+ /// appropriate handle type. For the waveInMessage, waveOutMessage, or midiOutMessage functions, the caller
+ /// must cast the device ID to a handle type HWAVEIN, HWAVEOUT or HMIDIOUT, respectively. Note that if the caller supplies a valid
+ /// handle instead of a device ID for this parameter, the function fails and returns error code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred for audio functions in general, in contrast to the
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET message, which determines which device is preferred specifically for voice communications.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred device and do not search for other available devices if the
+ /// preferred device is unavailable. Note that the midiOutMessage function does not output this flag--the midiOut API
+ /// always uses only the preferred device. The flag that is output by either the waveInMessage or waveOutMessage call
+ /// applies to the preferred device for both the waveIn and waveOut APIs, regardless of whether the call is made to
+ /// waveInMessage or waveOutMessage.
+ ///
+ ///
+ /// The xxxMessage functions accept this value in place of a valid device handle in order to allow an application to determine the
+ /// default device ID without first having to open a device. For more information, see Accessing the Preferred Device ID.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinmessage MMRESULT waveInMessage( HWAVEIN hwi, UINT uMsg,
+ // DWORD_PTR dw1, DWORD_PTR dw2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInMessage")]
+ public static extern MMRESULT waveInMessage(HWAVEIN hwi, uint uMsg, IntPtr dw1, IntPtr dw2);
+
+ /// The waveInOpen function opens the given waveform-audio input device for recording.
+ ///
+ /// Pointer to a buffer that receives a handle identifying the open waveform-audio input device. Use this handle to identify the
+ /// device when calling other waveform-audio input functions. This parameter can be NULL if WAVE_FORMAT_QUERY is
+ /// specified for fdwOpen.
+ ///
+ ///
+ ///
+ /// Identifier of the waveform-audio input device to open. It can be either a device identifier or a handle of an open
+ /// waveform-audio input device. You can use the following flag instead of a device identifier.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// WAVE_MAPPER
+ /// The function selects a waveform-audio input device capable of recording in the specified format.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the desired format for recording waveform-audio data. You can free this
+ /// structure immediately after waveInOpen returns.
+ ///
+ ///
+ /// Pointer to a fixed callback function, an event handle, a handle to a window, or the identifier of a thread to be called during
+ /// waveform-audio recording to process messages related to the progress of recording. If no callback function is required, this
+ /// value can be zero. For more information on the callback function, see waveInProc.
+ ///
+ ///
+ /// User-instance data passed to the callback mechanism. This parameter is not used with the window callback mechanism.
+ ///
+ ///
+ /// Flags for opening the device. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// CALLBACK_EVENT
+ /// The dwCallback parameter is an event handle.
+ ///
+ /// -
+ /// CALLBACK_FUNCTION
+ /// The dwCallback parameter is a callback procedure address.
+ ///
+ /// -
+ /// CALLBACK_NULL
+ /// No callback mechanism. This is the default setting.
+ ///
+ /// -
+ /// CALLBACK_THREAD
+ /// The dwCallback parameter is a thread identifier.
+ ///
+ /// -
+ /// CALLBACK_WINDOW
+ /// The dwCallback parameter is a window handle.
+ ///
+ /// -
+ /// WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE
+ ///
+ /// If this flag is specified and the uDeviceID parameter is WAVE_MAPPER, the function opens the default communication device. This
+ /// flag applies only when uDeviceID equals WAVE_MAPPER.
+ ///
+ ///
+ /// -
+ /// WAVE_FORMAT_DIRECT
+ /// If this flag is specified, the ACM driver does not perform conversions on the audio data.
+ ///
+ /// -
+ /// WAVE_FORMAT_QUERY
+ /// The function queries the device to determine whether it supports the given format, but it does not open the device.
+ ///
+ /// -
+ /// WAVE_MAPPED
+ /// The uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_ALLOCATED
+ /// Specified resource is already allocated.
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_BADFORMAT
+ /// Attempted to open with an unsupported waveform-audio format.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Use the waveInGetNumDevs function to determine the number of waveform-audio input devices present on the system. The device
+ /// identifier specified by uDeviceID varies from zero to one less than the number of devices present. The WAVE_MAPPER constant can
+ /// also be used as a device identifier.
+ ///
+ ///
+ /// If you choose to have a window or thread receive callback information, the following messages are sent to the window procedure
+ /// or thread to indicate the progress of waveform-audio input: MM_WIM_OPEN, MM_WIM_CLOSE, and MM_WIM_DATA.
+ ///
+ ///
+ /// If you choose to have a function receive callback information, the following messages are sent to the function to indicate the
+ /// progress of waveform-audio input: WIM_OPEN, WIM_CLOSE, and WIM_DATA.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinopen MMRESULT waveInOpen( LPHWAVEIN phwi, UINT
+ // uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInOpen")]
+ public static extern MMRESULT waveInOpen(out SafeHWAVEIN phwi, uint uDeviceID, in WAVEFORMATEX pwfx, [In, Optional] IntPtr dwCallback, [In, Optional] IntPtr dwInstance, WAVE_OPEN fdwOpen);
+
+ /// The waveInPrepareHeader function prepares a buffer for waveform-audio input.
+ /// Handle to the waveform-audio input device.
+ /// Pointer to a WAVEHDR structure that identifies the buffer to be prepared.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// The lpData, dwBufferLength, and dwFlags members of the WAVEHDR structure must be set before calling
+ /// this function ( dwFlags must be zero).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinprepareheader MMRESULT waveInPrepareHeader( HWAVEIN
+ // hwi, LPWAVEHDR pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInPrepareHeader")]
+ public static extern MMRESULT waveInPrepareHeader(HWAVEIN hwi, ref WAVEHDR pwh, uint cbwh);
+
+ ///
+ /// The waveInReset function stops input on the given waveform-audio input device and resets the current position to zero.
+ /// All pending buffers are marked as done and returned to the application.
+ ///
+ /// Handle to the waveform-audio input device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinreset MMRESULT waveInReset( HWAVEIN hwi );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInReset")]
+ public static extern MMRESULT waveInReset(HWAVEIN hwi);
+
+ /// The waveInStart function starts input on the given waveform-audio input device.
+ /// Handle to the waveform-audio input device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Buffers are returned to the application when full or when the waveInReset function is called (the dwBytesRecorded
+ /// member in the header will contain the length of data). If there are no buffers in the queue, the data is thrown away without
+ /// notifying the application, and input continues.
+ ///
+ /// Calling this function when input is already started has no effect, and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinstart MMRESULT waveInStart( HWAVEIN hwi );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInStart")]
+ public static extern MMRESULT waveInStart(HWAVEIN hwi);
+
+ /// The waveInStop function stops waveform-audio input.
+ /// Handle to the waveform-audio input device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If there are any buffers in the queue, the current buffer will be marked as done (the dwBytesRecorded member in the
+ /// header will contain the length of data), but any empty buffers in the queue will remain there.
+ ///
+ /// Calling this function when input is not started has no effect, and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinstop MMRESULT waveInStop( HWAVEIN hwi );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInStop")]
+ public static extern MMRESULT waveInStop(HWAVEIN hwi);
+
+ ///
+ /// The waveInUnprepareHeader function cleans up the preparation performed by the waveInPrepareHeader function. This function
+ /// must be called after the device driver fills a buffer and returns it to the application. You must call this function before
+ /// freeing the buffer.
+ ///
+ /// Handle to the waveform-audio input device.
+ /// Pointer to a WAVEHDR structure identifying the buffer to be cleaned up.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_STILLPLAYING
+ /// The buffer pointed to by the pwh parameter is still in the queue.
+ ///
+ ///
+ ///
+ ///
+ /// This function complements the waveInPrepareHeader function.
+ ///
+ /// You must call this function before freeing the buffer. After passing a buffer to the device driver with the
+ /// waveInAddBuffer function, you must wait until the driver is finished with the buffer before calling
+ /// waveInUnprepareHeader. Unpreparing a buffer that has not been prepared has no effect, and the function returns zero.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveinunprepareheader MMRESULT waveInUnprepareHeader( HWAVEIN
+ // hwi, LPWAVEHDR pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveInUnprepareHeader")]
+ public static extern MMRESULT waveInUnprepareHeader(HWAVEIN hwi, ref WAVEHDR pwh, uint cbwh);
+
+ ///
+ /// The waveOutBreakLoop function breaks a loop on the given waveform-audio output device and allows playback to continue
+ /// with the next block in the driver list.
+ ///
+ /// Handle to the waveform-audio output device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// The blocks making up the loop are played to the end before the loop is terminated.
+ /// Calling this function when nothing is playing or looping has no effect, and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutbreakloop MMRESULT waveOutBreakLoop( HWAVEOUT hwo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutBreakLoop")]
+ public static extern MMRESULT waveOutBreakLoop(HWAVEOUT hwo);
+
+ /// The waveOutClose function closes the given waveform-audio output device.
+ ///
+ /// Handle to the waveform-audio output device. If the function succeeds, the handle is no longer valid after this call.
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_STILLPLAYING
+ /// There are still buffers in the queue.
+ ///
+ ///
+ ///
+ ///
+ /// The close operation fails if the device is still playing a waveform-audio buffer that was previously sent by calling
+ /// waveOutWrite. Before calling waveOutClose, the application must wait for all buffers to finish playing or call the
+ /// waveOutReset function to terminate playback.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutclose MMRESULT waveOutClose( HWAVEOUT hwo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutClose")]
+ public static extern MMRESULT waveOutClose(HWAVEOUT hwo);
+
+ /// The waveOutGetDevCaps function retrieves the capabilities of a given waveform-audio output device.
+ ///
+ /// Identifier of the waveform-audio output device. It can be either a device identifier or a handle of an open waveform-audio
+ /// output device.
+ ///
+ /// Pointer to a WAVEOUTCAPS structure to be filled with information about the capabilities of the device.
+ /// Size, in bytes, of the WAVEOUTCAPS structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// Use the waveOutGetNumDevs function to determine the number of waveform-audio output devices present in the system. If the
+ /// value specified by the uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices
+ /// present. The WAVE_MAPPER constant can also be used as a device identifier. Only cbwoc bytes (or less) of information is copied
+ /// to the location pointed to by pwoc. If cbwoc is zero, nothing is copied and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetdevcaps MMRESULT waveOutGetDevCaps( UINT uDeviceID,
+ // LPWAVEOUTCAPS pwoc, UINT cbwoc );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetDevCaps")]
+ public static extern MMRESULT waveOutGetDevCaps(uint uDeviceID, out WAVEOUTCAPS pwoc, uint cbwoc);
+
+ ///
+ /// The waveOutGetErrorText function retrieves a textual description of the error identified by the given error number.
+ ///
+ /// Error number.
+ /// Pointer to a buffer to be filled with the textual error description.
+ /// Size, in characters, of the buffer pointed to by pszText.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_BADERRNUM
+ /// Specified error number is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ /// If the textual error description is longer than the specified buffer, the description is truncated. The returned error string is
+ /// always null-terminated. If cchText is zero, nothing is copied and the function returns zero. All error descriptions are less
+ /// than MAXERRORLENGTH characters long.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgeterrortext MMRESULT waveOutGetErrorText( MMRESULT
+ // mmrError, LPSTR pszText, UINT cchText );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetErrorText")]
+ public static extern MMRESULT waveOutGetErrorText(MMRESULT mmrError, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszText, uint cchText);
+
+ ///
+ /// The waveOutGetID function retrieves the device identifier for the given waveform-audio output device.
+ ///
+ /// This function is supported for backward compatibility. New applications can cast a handle of the device rather than retrieving
+ /// the device identifier.
+ ///
+ ///
+ /// Handle to the waveform-audio output device.
+ /// Pointer to a variable to be filled with the device identifier.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// The hwo parameter specifies an invalid handle.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetid MMRESULT waveOutGetID( HWAVEOUT hwo, LPUINT
+ // puDeviceID );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetID")]
+ public static extern MMRESULT waveOutGetID(HWAVEOUT hwo, out uint puDeviceID);
+
+ /// The waveOutGetNumDevs function retrieves the number of waveform-audio output devices present in the system.
+ /// Returns the number of devices. A return value of zero means that no devices are present or that an error occurred.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetnumdevs UINT waveOutGetNumDevs();
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetNumDevs")]
+ public static extern uint waveOutGetNumDevs();
+
+ ///
+ /// The waveOutGetPitch function retrieves the current pitch setting for the specified waveform-audio output device.
+ ///
+ /// Handle to the waveform-audio output device.
+ ///
+ ///
+ /// Pointer to a variable to be filled with the current pitch multiplier setting. The pitch multiplier indicates the current change
+ /// in pitch from the original authored setting. The pitch multiplier must be a positive value.
+ ///
+ ///
+ /// The pitch multiplier is specified as a fixed-point value. The high-order word of the variable contains the signed integer part
+ /// of the number, and the low-order word contains the fractional part. A value of 0x8000 in the low-order word represents one-half,
+ /// and 0x4000 represents one-quarter. For example, the value 0x00010000 specifies a multiplier of 1.0 (no pitch change), and a
+ /// value of 0x000F8000 specifies a multiplier of 15.5.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function isn't supported.
+ ///
+ ///
+ ///
+ ///
+ /// Changing the pitch does not change the playback rate, sample rate, or playback time. Not all devices support pitch changes. To
+ /// determine whether the device supports pitch control, use the WAVECAPS_PITCH flag to test the dwSupport member of the
+ /// WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetpitch MMRESULT waveOutGetPitch( HWAVEOUT hwo,
+ // LPDWORD pdwPitch );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetPitch")]
+ public static extern MMRESULT waveOutGetPitch(HWAVEOUT hwo, out uint pdwPitch);
+
+ ///
+ /// The waveOutGetPlaybackRate function retrieves the current playback rate for the specified waveform-audio output device.
+ ///
+ /// Handle to the waveform-audio output device.
+ ///
+ ///
+ /// Pointer to a variable to be filled with the current playback rate. The playback rate setting is a multiplier indicating the
+ /// current change in playback rate from the original authored setting. The playback rate multiplier must be a positive value.
+ ///
+ ///
+ /// The rate is specified as a fixed-point value. The high-order word of the variable contains the signed integer part of the
+ /// number, and the low-order word contains the fractional part. A value of 0x8000 in the low-order word represents one-half, and
+ /// 0x4000 represents one-quarter. For example, the value 0x00010000 specifies a multiplier of 1.0 (no playback rate change), and a
+ /// value of 0x000F8000 specifies a multiplier of 15.5.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function isn't supported.
+ ///
+ ///
+ ///
+ ///
+ /// Changing the playback rate does not change the sample rate but does change the playback time. Not all devices support playback
+ /// rate changes. To determine whether a device supports playback rate changes, use the WAVECAPS_PLAYBACKRATE flag to test the
+ /// dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetplaybackrate MMRESULT waveOutGetPlaybackRate(
+ // HWAVEOUT hwo, LPDWORD pdwRate );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetPlaybackRate")]
+ public static extern MMRESULT waveOutGetPlaybackRate(HWAVEOUT hwo, out uint pdwRate);
+
+ ///
+ /// The waveOutGetPosition function retrieves the current playback position of the given waveform-audio output device.
+ ///
+ /// Handle to the waveform-audio output device.
+ /// Pointer to an MMTIME structure.
+ /// Size, in bytes, of the MMTIME structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Before calling this function, set the wType member of the MMTIME structure to indicate the time format you want.
+ /// After calling this function, check wType to determine whether the time format is supported. If the format is not
+ /// supported, wType will specify an alternative format.
+ ///
+ /// The position is set to zero when the device is opened or reset.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetposition MMRESULT waveOutGetPosition( HWAVEOUT hwo,
+ // LPMMTIME pmmt, UINT cbmmt );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetPosition")]
+ public static extern MMRESULT waveOutGetPosition(HWAVEOUT hwo, ref MMTIME pmmt, uint cbmmt);
+
+ /// The waveOutGetVolume function retrieves the current volume level of the specified waveform-audio output device.
+ /// Handle to an open waveform-audio output device. This parameter can also be a device identifier.
+ ///
+ ///
+ /// Pointer to a variable to be filled with the current volume setting. The low-order word of this location contains the
+ /// left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full
+ /// volume, and a value of 0x0000 is silence.
+ ///
+ ///
+ /// If a device does not support both left and right volume control, the low-order word of the specified location contains the mono
+ /// volume level.
+ ///
+ ///
+ /// The full 16-bit setting(s) set with the waveOutSetVolume function is returned, regardless of whether the device supports the
+ /// full 16 bits of volume-level control.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function isn't supported.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If a device identifier is used, then the result of the waveOutGetVolume call and the information returned in pdwVolume
+ /// applies to all instances of the device. If a device handle is used, then the result and information returned applies only to the
+ /// instance of the device referenced by the device handle.
+ ///
+ ///
+ /// Not all devices support volume changes. To determine whether the device supports volume control, use the WAVECAPS_VOLUME flag to
+ /// test the dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).
+ ///
+ ///
+ /// To determine whether the device supports left- and right-channel volume control, use the WAVECAPS_LRVOLUME flag to test the
+ /// dwSupport member of the WAVEOUTCAPS structure (filled by waveOutGetDevCaps).
+ ///
+ ///
+ /// Volume settings are interpreted logarithmically. This means the perceived increase in volume is the same when increasing the
+ /// volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutgetvolume MMRESULT waveOutGetVolume( HWAVEOUT hwo,
+ // LPDWORD pdwVolume );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutGetVolume")]
+ public static extern MMRESULT waveOutGetVolume(HWAVEOUT hwo, out uint pdwVolume);
+
+ /// The waveOutMessage function sends messages to the waveform-audio output device drivers.
+ ///
+ /// Identifier of the waveform device that receives the message. You must cast the device ID to the HWAVEOUT handle type. If
+ /// you supply a handle instead of a device ID, the function fails and returns the MMSYSERR_NOSUPPORT error code.
+ ///
+ /// Message to send.
+ /// Message parameter.
+ /// Message parameter.
+ /// Returns the value returned from the driver.
+ ///
+ /// The
+ /// DRV_QUERYDEVICEINTERFACE
+ /// message queries for the device-interface name of a waveIn, waveOut, midiIn, midiOut, or mixer device.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam1 is a pointer to a caller-allocated buffer into which the function writes a null-terminated Unicode string containing
+ /// the device-interface name. If the device has no device interface, the string length is zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACE
+ /// , dwParam2 specifies the buffer size in bytes. This is an input parameter to the function. The caller should specify a size that
+ /// is greater than or equal to the buffer size retrieved by the DRV_QUERYDEVICEINTERFACESIZE message.
+ ///
+ ///
+ /// The DRV_QUERYDEVICEINTERFACE message is supported in Windows Me, and Windows 2000 and later. This message is valid only for the
+ /// waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this
+ /// message and returns the appropriate value without sending the message to the device driver. For general information about
+ /// system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The following two message constants are used together for the purpose of obtaining device interface names:
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ ///
+ /// -
+ /// DRV_QUERYDEVICEINTERFACE
+ ///
+ ///
+ ///
+ /// The first message obtains the size in bytes of the buffer needed to hold the string containing the device interface name. The
+ /// second message retrieves the name string in a buffer of the required size.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// message queries for the size of the buffer required to hold the device-interface name.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam1 is a pointer to buffer size. This parameter points to a ULONG variable into which the function writes the required
+ /// buffer size in bytes. The size includes storage space for the name string's terminating null. The size is zero if the device ID
+ /// identifies a device that has no device interface.
+ ///
+ /// For
+ /// DRV_QUERYDEVICEINTERFACESIZE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage
+ /// functions. The system intercepts this message and returns the appropriate value without sending the message to the device
+ /// driver. For general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// The buffer size retrieved by this message is expressed as a byte count. It specifies the size of the buffer needed to hold the
+ /// null-terminated Unicode string that contains the device-interface name. The caller allocates a buffer of the specified size and
+ /// uses the DRV_QUERYDEVICEINTERFACE message to retrieve the device-interface name string.
+ ///
+ /// For more information, see Obtaining a Device Interface Name.
+ /// The
+ /// DRV_QUERYDEVNODE
+ /// message queries for the devnode number assigned to the device by the Plug and Play manager.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam1 is a pointer to a caller-allocated DWORD variable into which the function writes the devnode number. If no devnode is
+ /// assigned to the device, the function sets this variable to zero.
+ ///
+ /// For
+ /// DRV_QUERYDEVNODE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// In Windows 2000 and later, the message always returns MMSYSERR_NOTSUPPORTED. This message is valid only for the waveInMessage,
+ /// waveOutMessage, midiInMessage, midiOutMessage, and mixerMessage functions. The system intercepts this message and returns
+ /// the appropriate value without sending the message to the device driver. For general information about system-intercepted
+ /// xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ /// The
+ /// DRV_QUERYMAPPABLE
+ /// message queries for whether the specified device can be used by a mapper.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam1 is unused. Set this parameter to zero.
+ ///
+ /// For
+ /// DRV_QUERYMAPPABLE
+ /// , dwParam2 is unused. Set this parameter to zero.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, mixerMessage and
+ /// auxOutMessage functions. The system intercepts this message and returns the appropriate value without sending the message to the
+ /// device driver. For general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// When an application program opens a mapper instead of a specific audio device, the system inserts a mapper between the
+ /// application and the available devices. The mapper selects an appropriate device by mapping the application's requirements to one
+ /// of the available devices. For more information about mappers, see the Microsoft Windows SDK documentation.
+ ///
+ /// The
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// message retrieves the device ID of the preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred voice-communications device. The function writes the value (-1) if no device is available that qualifies
+ /// as a preferred voice-communications device.
+ ///
+ /// For
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined: DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage and waveOutMessage functions. When a caller calls these two functions
+ /// with the DRVM_MAPPER_CONSOLEVOICECOM_GET message, the caller must specify the device ID as WAVE_MAPPER, and then cast this value
+ /// to the appropriate handle type. For the waveInMessage, waveOutMessage, midiInMessage, midiOutMessage, or
+ /// mixerMessage functions, the caller must cast the device ID to a handle of type HWAVEIN, HWAVEOUT, HMIDIIN, HMIDIOUT, or HMIXER,
+ /// respectively. Note that if the caller supplies a valid handle instead of a device ID for this parameter, the function fails and
+ /// returns error code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred specifically for voice communications, in contrast to the
+ /// DRVM_MAPPER_PREFERRED_GET message, which determines which device is preferred for all other audio functions.
+ ///
+ ///
+ /// For example, the preferred waveOut device for voice communications might be the earpiece in a headset, but the preferred
+ /// waveOut device for all other audio functions might be a set of stereo speakers.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred voice-communications device and do not search for other
+ /// available devices if the preferred device is unavailable. The flag that is output by either the waveInMessage or
+ /// waveOutMessage call applies to the preferred voice-communications device for both the waveIn and waveOut
+ /// APIs, regardless of whether the call is made to waveInMessage or waveOutMessage. For more information, see
+ /// Preferred Voice-Communications Device ID.
+ ///
+ /// The
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// message retrieves the device ID of the preferred audio device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam1 is a pointer to device ID. This parameter points to a DWORD variable into which the function writes the device ID of
+ /// the current preferred device. The function writes the value (-1) if no device is available that qualifies as a preferred device.
+ ///
+ /// For
+ /// DRVM_MAPPER_PREFERRED_GET
+ /// , dwParam2 is a pointer to status flags. This parameter points to a DWORD variable into which the function writes the
+ /// device-status flags. Only one flag bit is currently defined (for waveInMessage and waveOutMessage calls only): DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY.
+ ///
+ ///
+ /// This message is valid only for the waveInMessage, waveOutMessage and midiOutMessage functions. When the caller calls
+ /// these functions with the DRVM_MAPPER_PREFERRED_GET message, the caller must first specify the device ID as WAVE_MAPPER (for
+ /// waveInMessage or waveOutMessage) or MIDI_MAPPER (for midiOutMessage), and then cast this value to the
+ /// appropriate handle type. For the waveInMessage, waveOutMessage, or midiOutMessage functions, the caller
+ /// must cast the device ID to a handle type HWAVEIN, HWAVEOUT or HMIDIOUT, respectively. Note that if the caller supplies a valid
+ /// handle instead of a device ID for this parameter, the function fails and returns error code MMSYSERR_NOSUPPORT.
+ ///
+ ///
+ /// The system intercepts this message and returns the appropriate value without sending the message to the device driver. For
+ /// general information about system-intercepted xxxMessage functions, see System-Intercepted Device Messages.
+ ///
+ ///
+ /// This message provides a way to determine which device is preferred for audio functions in general, in contrast to the
+ /// DRVM_MAPPER_CONSOLEVOICECOM_GET message, which determines which device is preferred specifically for voice communications.
+ ///
+ ///
+ /// When the DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY flag bit is set in the DWORD location pointed to by dwParam2, the
+ /// waveIn and waveOut APIs use only the current preferred device and do not search for other available devices if the
+ /// preferred device is unavailable. Note that the midiOutMessage function does not output this flag--the midiOut API
+ /// always uses only the preferred device. The flag that is output by either the waveInMessage or waveOutMessage call
+ /// applies to the preferred device for both the waveIn and waveOut APIs, regardless of whether the call is made to
+ /// waveInMessage or waveOutMessage.
+ ///
+ ///
+ /// The xxxMessage functions accept this value in place of a valid device handle in order to allow an application to determine the
+ /// default device ID without first having to open a device. For more information, see Accessing the Preferred Device ID.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutmessage MMRESULT waveOutMessage( HWAVEOUT hwo, UINT
+ // uMsg, DWORD_PTR dw1, DWORD_PTR dw2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutMessage")]
+ public static extern MMRESULT waveOutMessage(HWAVEOUT hwo, uint uMsg, IntPtr dw1, IntPtr dw2);
+
+ /// The waveOutOpen function opens the given waveform-audio output device for playback.
+ ///
+ /// Pointer to a buffer that receives a handle identifying the open waveform-audio output device. Use the handle to identify the
+ /// device when calling other waveform-audio output functions. This parameter might be NULL if the WAVE_FORMAT_QUERY
+ /// flag is specified for fdwOpen.
+ ///
+ ///
+ ///
+ /// Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open
+ /// waveform-audio input device. You can also use the following flag instead of a device identifier:
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// WAVE_MAPPER
+ /// The function selects a waveform-audio output device capable of playing the given format.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a WAVEFORMATEX structure that identifies the format of the waveform-audio data to be sent to the device. You can free
+ /// this structure immediately after passing it to waveOutOpen.
+ ///
+ ///
+ /// Specifies the callback mechanism. The value must be one of the following:
+ ///
+ /// -
+ /// A pointer to a callback function. For the function signature, see waveOutProc.
+ ///
+ /// -
+ /// A handle to a window.
+ ///
+ /// -
+ /// A thread identifier.
+ ///
+ /// -
+ /// A handle to an event.
+ ///
+ /// -
+ /// The value NULL.
+ ///
+ ///
+ /// The
+ /// fdwOpen
+ /// parameter specifies how the
+ /// dwCallback
+ /// parameter is interpreted. For more information, see Remarks.
+ ///
+ ///
+ /// User-instance data passed to the callback mechanism. This parameter is not used with the window callback mechanism.
+ ///
+ ///
+ /// Flags for opening the device. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// CALLBACK_EVENT
+ /// The dwCallback parameter is an event handle.
+ ///
+ /// -
+ /// CALLBACK_FUNCTION
+ /// The dwCallback parameter is a callback procedure address.
+ ///
+ /// -
+ /// CALLBACK_NULL
+ /// No callback mechanism. This is the default setting.
+ ///
+ /// -
+ /// CALLBACK_THREAD
+ /// The dwCallback parameter is a thread identifier.
+ ///
+ /// -
+ /// CALLBACK_WINDOW
+ /// The dwCallback parameter is a window handle.
+ ///
+ /// -
+ /// WAVE_ALLOWSYNC
+ ///
+ /// If this flag is specified, a synchronous waveform-audio device can be opened. If this flag is not specified while opening a
+ /// synchronous driver, the device will fail to open.
+ ///
+ ///
+ /// -
+ /// WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE
+ ///
+ /// If this flag is specified and the uDeviceID parameter is WAVE_MAPPER, the function opens the default communication device. This
+ /// flag applies only when uDeviceID equals WAVE_MAPPER.
+ ///
+ ///
+ /// -
+ /// WAVE_FORMAT_DIRECT
+ /// If this flag is specified, the ACM driver does not perform conversions on the audio data.
+ ///
+ /// -
+ /// WAVE_FORMAT_QUERY
+ ///
+ /// If this flag is specified, waveOutOpen queries the device to determine if it supports the given format, but the device is not
+ /// actually opened.
+ ///
+ ///
+ /// -
+ /// WAVE_MAPPED
+ /// If this flag is specified, the uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_ALLOCATED
+ /// Specified resource is already allocated.
+ ///
+ /// -
+ /// MMSYSERR_BADDEVICEID
+ /// Specified device identifier is out of range.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_BADFORMAT
+ /// Attempted to open with an unsupported waveform-audio format.
+ ///
+ /// -
+ /// WAVERR_SYNC
+ /// The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Use the waveOutGetNumDevs function to determine the number of waveform-audio output devices present in the system. If the value
+ /// specified by the uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices
+ /// present. The WAVE_MAPPER constant can also be used as a device identifier.
+ ///
+ ///
+ /// The structure pointed to by pwfx can be extended to include type-specific information for certain data formats. For example, for
+ /// PCM data, an extra UINT is added to specify the number of bits per sample. Use the PCMWAVEFORMAT structure in this case.
+ /// For all other waveform-audio formats, use the WAVEFORMATEX structure to specify the length of the additional data.
+ ///
+ ///
+ /// If you choose to have a window or thread receive callback information, the following messages are sent to the window procedure
+ /// function to indicate the progress of waveform-audio output: MM_WOM_OPEN, MM_WOM_CLOSE, and MM_WOM_DONE.
+ ///
+ /// Callback Mechanism
+ /// The dwCallback and fdwOpen parameters specify how the application is notified about the progress of waveform-audio output.
+ ///
+ /// If fdwOpen contains the CALLBACK_FUNCTION flag, dwCallback is a pointer to a callback function. For the function
+ /// signature, see waveOutProc. The uMsg parameter of the callback indicates the progress of the audio output:
+ ///
+ ///
+ /// -
+ /// WOM_OPEN
+ ///
+ /// -
+ /// WOM_CLOSE
+ ///
+ /// -
+ /// WOM_DONE
+ ///
+ ///
+ ///
+ /// If fdwOpen contains the CALLBACK_WINDOW flag, dwCallback is a handle to a window.The window receives the following
+ /// messages, indicating the progress:
+ ///
+ ///
+ /// -
+ /// MM_WOM_OPEN
+ ///
+ /// -
+ /// MM_WOM_CLOSE
+ ///
+ /// -
+ /// MM_WOM_DONE
+ ///
+ ///
+ ///
+ /// If fdwOpen contains the CALLBACK_THREAD flag, dwCallback is a thread identifier. The thread receives the messages listed
+ /// previously for CALLBACK_WINDOW.
+ ///
+ ///
+ /// If fdwOpen contains the CALLBACK_EVENT flag, dwCallback is a handle to an event. The event is signaled whenever the state
+ /// of the waveform buffer changes. The application can use WaitForSingleObject or WaitForMultipleObjects to wait for the event.
+ /// When the event is signaled, you can get the current state of the waveform buffer by checking the dwFlags member of the
+ /// WAVEHDR structure. (See waveOutPrepareHeader.)
+ ///
+ ///
+ /// If fdwOpen contains the CALLBACK_NULL flag, dwCallback must be NULL. In that case, no callback mechanism is used.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutopen MMRESULT waveOutOpen( LPHWAVEOUT phwo, UINT
+ // uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutOpen")]
+ public static extern MMRESULT waveOutOpen(out SafeHWAVEOUT phwo, uint uDeviceID, in WAVEFORMATEX pwfx, [In, Optional] IntPtr dwCallback, [In, Optional] IntPtr dwInstance, [In, Optional] WAVE_OPEN fdwOpen);
+
+ ///
+ /// The waveOutPause function pauses playback on the given waveform-audio output device. The current position is saved. Use
+ /// the waveOutRestart function to resume playback from the current position.
+ ///
+ /// Handle to the waveform-audio output device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Specified device is synchronous and does not support pausing.
+ ///
+ ///
+ ///
+ /// Calling this function when the output is already paused has no effect, and the function returns zero.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutpause MMRESULT waveOutPause( HWAVEOUT hwo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutPause")]
+ public static extern MMRESULT waveOutPause(HWAVEOUT hwo);
+
+ /// The waveOutPrepareHeader function prepares a waveform-audio data block for playback.
+ /// Handle to the waveform-audio output device.
+ /// Pointer to a WAVEHDR structure that identifies the data block to be prepared.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Set the lpData, dwBufferLength, and dwFlags members of the WAVEHDR structure before calling this function.
+ /// Set the dwFlags member to zero.
+ ///
+ ///
+ /// The dwFlags, dwBufferLength, and dwLoops members of the WAVEHDR structure can change between calls to this
+ /// function and the waveOutWrite function. If you change the size specified by dwBufferLength before the call to
+ /// waveOutWrite, the new value must be less than the prepared value.
+ ///
+ /// If the method succeeds, the WHDR_PREPARED flag is set in the dwFlags member of the WAVEHDR structure.
+ /// Preparing a header that has already been prepared has no effect, and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutprepareheader MMRESULT waveOutPrepareHeader( HWAVEOUT
+ // hwo, LPWAVEHDR pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutPrepareHeader")]
+ public static extern MMRESULT waveOutPrepareHeader(HWAVEOUT hwo, ref WAVEHDR pwh, uint cbwh);
+
+ ///
+ /// The waveOutReset function stops playback on the given waveform-audio output device and resets the current position to
+ /// zero. All pending playback buffers are marked as done (WHDR_DONE) and returned to the application.
+ ///
+ /// Handle to the waveform-audio output device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Specified device is synchronous and does not support pausing.
+ ///
+ ///
+ ///
+ ///
+ /// After this function returns, the application can send new playback buffers to the device by calling waveOutWrite, or close the
+ /// device by calling waveOutClose.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutreset MMRESULT waveOutReset( HWAVEOUT hwo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutReset")]
+ public static extern MMRESULT waveOutReset(HWAVEOUT hwo);
+
+ /// The waveOutRestart function resumes playback on a paused waveform-audio output device.
+ /// Handle to the waveform-audio output device.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Specified device is synchronous and does not support pausing.
+ ///
+ ///
+ ///
+ /// Calling this function when the output is not paused has no effect, and the function returns zero.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutrestart MMRESULT waveOutRestart( HWAVEOUT hwo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutRestart")]
+ public static extern MMRESULT waveOutRestart(HWAVEOUT hwo);
+
+ /// The waveOutSetPitch function sets the pitch for the specified waveform-audio output device.
+ /// Handle to the waveform-audio output device.
+ ///
+ ///
+ /// New pitch multiplier setting. This setting indicates the current change in pitch from the original authored setting. The pitch
+ /// multiplier must be a positive value.
+ ///
+ ///
+ /// The pitch multiplier is specified as a fixed-point value. The high-order word contains the signed integer part of the number,
+ /// and the low-order word contains the fractional part. A value of 0x8000 in the low-order word represents one-half, and 0x4000
+ /// represents one-quarter. For example, the value 0x00010000 specifies a multiplier of 1.0 (no pitch change), and a value of
+ /// 0x000F8000 specifies a multiplier of 15.5.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function isn't supported.
+ ///
+ ///
+ ///
+ ///
+ /// Changing the pitch does not change the playback rate or the sample rate, nor does it change the playback time. Not all devices
+ /// support pitch changes. To determine whether the device supports pitch control, use the WAVECAPS_PITCH flag to test the
+ /// dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutsetpitch MMRESULT waveOutSetPitch( HWAVEOUT hwo, DWORD
+ // dwPitch );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutSetPitch")]
+ public static extern MMRESULT waveOutSetPitch(HWAVEOUT hwo, uint dwPitch);
+
+ /// The waveOutSetPlaybackRate function sets the playback rate for the specified waveform-audio output device.
+ /// Handle to the waveform-audio output device.
+ ///
+ ///
+ /// New playback rate setting. This setting is a multiplier indicating the current change in playback rate from the original
+ /// authored setting. The playback rate multiplier must be a positive value.
+ ///
+ ///
+ /// The rate is specified as a fixed-point value. The high-order word contains the signed integer part of the number, and the
+ /// low-order word contains the fractional part. A value of 0x8000 in the low-order word represents one-half, and 0x4000 represents
+ /// one-quarter. For example, the value 0x00010000 specifies a multiplier of 1.0 (no playback rate change), and a value of
+ /// 0x000F8000 specifies a multiplier of 15.5.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function isn't supported.
+ ///
+ ///
+ ///
+ ///
+ /// Changing the playback rate does not change the sample rate but does change the playback time. Not all devices support playback
+ /// rate changes. To determine whether a device supports playback rate changes, use the WAVECAPS_PLAYBACKRATE flag to test the
+ /// dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutsetplaybackrate MMRESULT waveOutSetPlaybackRate(
+ // HWAVEOUT hwo, DWORD dwRate );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutSetPlaybackRate")]
+ public static extern MMRESULT waveOutSetPlaybackRate(HWAVEOUT hwo, uint dwRate);
+
+ /// The waveOutSetVolume function sets the volume level of the specified waveform-audio output device.
+ /// Handle to an open waveform-audio output device. This parameter can also be a device identifier.
+ ///
+ ///
+ /// New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the
+ /// right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
+ ///
+ ///
+ /// If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and
+ /// the high-order word is ignored.
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// MMSYSERR_NOTSUPPORTED
+ /// Function is not supported.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If a device identifier is used, then the result of the waveOutSetVolume call applies to all instances of the device. If a
+ /// device handle is used, then the result applies only to the instance of the device referenced by the device handle.
+ ///
+ ///
+ /// Not all devices support volume changes. To determine whether the device supports volume control, use the WAVECAPS_VOLUME flag to
+ /// test the dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function). To determine whether
+ /// the device supports volume control on both the left and right channels, use the WAVECAPS_LRVOLUME flag.
+ ///
+ ///
+ /// Most devices do not support the full 16 bits of volume-level control and will not use the least-significant bits of the
+ /// requested volume setting. For example, if a device supports 4 bits of volume control, the values 0x4000, 0x4FFF, and 0x43BE will
+ /// all be truncated to 0x4000. The waveOutGetVolume function returns the full 16-bit setting set with waveOutSetVolume.
+ ///
+ ///
+ /// Volume settings are interpreted logarithmically. This means the perceived increase in volume is the same when increasing the
+ /// volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutsetvolume MMRESULT waveOutSetVolume( HWAVEOUT hwo,
+ // DWORD dwVolume );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutSetVolume")]
+ public static extern MMRESULT waveOutSetVolume(HWAVEOUT hwo, uint dwVolume);
+
+ ///
+ /// The waveOutUnprepareHeader function cleans up the preparation performed by the waveOutPrepareHeader function. This
+ /// function must be called after the device driver is finished with a data block. You must call this function before freeing the buffer.
+ ///
+ /// Handle to the waveform-audio output device.
+ /// Pointer to a WAVEHDR structure identifying the data block to be cleaned up.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_STILLPLAYING
+ /// The data block pointed to by the pwh parameter is still in the queue.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function complements waveOutPrepareHeader. You must call this function before freeing the buffer. After passing a
+ /// buffer to the device driver with the waveOutWrite function, you must wait until the driver is finished with the buffer
+ /// before calling waveOutUnprepareHeader.
+ ///
+ /// Unpreparing a buffer that has not been prepared has no effect, and the function returns zero.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutunprepareheader MMRESULT waveOutUnprepareHeader(
+ // HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutUnprepareHeader")]
+ public static extern MMRESULT waveOutUnprepareHeader(HWAVEOUT hwo, ref WAVEHDR pwh, uint cbwh);
+
+ /// The waveOutWrite function sends a data block to the given waveform-audio output device.
+ /// Handle to the waveform-audio output device.
+ /// Pointer to a WAVEHDR structure containing information about the data block.
+ /// Size, in bytes, of the WAVEHDR structure.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMSYSERR_INVALHANDLE
+ /// Specified device handle is invalid.
+ ///
+ /// -
+ /// MMSYSERR_NODRIVER
+ /// No device driver is present.
+ ///
+ /// -
+ /// MMSYSERR_NOMEM
+ /// Unable to allocate or lock memory.
+ ///
+ /// -
+ /// WAVERR_UNPREPARED
+ /// The data block pointed to by the pwh parameter hasn't been prepared.
+ ///
+ ///
+ ///
+ ///
+ /// When the buffer is finished, the WHDR_DONE bit is set in the dwFlags member of the WAVEHDR structure.
+ ///
+ /// The buffer must be prepared with the waveOutPrepareHeader function before it is passed to waveOutWrite. Unless the
+ /// device is paused by calling the waveOutPause function, playback begins when the first data block is sent to the device.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-waveoutwrite MMRESULT waveOutWrite( HWAVEOUT hwo, LPWAVEHDR
+ // pwh, UINT cbwh );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmeapi.h", MSDNShortId = "NF:mmeapi.waveOutWrite")]
+ public static extern MMRESULT waveOutWrite(HWAVEOUT hwo, ref WAVEHDR pwh, uint cbwh);
+
+ /// The AUXCAPS structure describes the capabilities of an auxiliary output device.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-auxcaps typedef struct auxcaps_tag { WORD wMid; WORD wPid;
+ // VERSION vDriverVersion; char szPname[MAXPNAMELEN]; WORD wTechnology; DWORD dwSupport; } AUXCAPS, *PAUXCAPS, *NPAUXCAPS, *LPAUXCAPS;
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.auxcaps_tag")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct AUXCAPS
+ {
+ ///
+ /// Manufacturer identifier for the device driver for the auxiliary audio device. Manufacturer identifiers are defined in
+ /// Manufacturer and Product Identifiers.
+ ///
+ public ushort wMid;
+
+ ///
+ /// Product identifier for the auxiliary audio device. Currently, no product identifiers are defined for auxiliary audio devices.
+ ///
+ public ushort wPid;
+
+ ///
+ /// Version number of the device driver for the auxiliary audio device. The high-order byte is the major version number, and the
+ /// low-order byte is the minor version number.
+ ///
+ public uint vDriverVersion;
+
+ /// Product name in a null-terminated string.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
+ public string szPname;
+
+ ///
+ /// Type of the auxiliary audio output:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AUXCAPS_AUXIN
+ /// Audio output from auxiliary input jacks.
+ ///
+ /// -
+ /// AUXCAPS_CDAUDIO
+ /// Audio output from an internal CD-ROM drive.
+ ///
+ ///
+ ///
+ public ushort wTechnology;
+
+ ///
+ /// Describes optional functionality supported by the auxiliary audio device.
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AUXCAPS_LRVOLUME
+ /// Supports separate left and right volume control.
+ ///
+ /// -
+ /// AUXCAPS_VOLUME
+ /// Supports volume control.
+ ///
+ ///
+ ///
+ /// If a device supports volume changes, the AUXCAPS_VOLUME flag will be set. If a device supports separate volume changes on
+ /// the left and right channels, both AUXCAPS_VOLUME and the AUXCAPS_LRVOLUME will be set.
+ ///
+ ///
+ public AUX_CAPS dwSupport;
+ }
+
+ /// Provides a handle to a waveform-audio input device.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HWAVEIN : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HWAVEIN(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HWAVEIN NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HWAVEIN h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HWAVEIN(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HWAVEIN h1, HWAVEIN h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HWAVEIN h1, HWAVEIN h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HWAVEIN h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to a waveform-audio output device.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HWAVEOUT : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HWAVEOUT(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HWAVEOUT NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HWAVEOUT h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HWAVEOUT(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HWAVEOUT h1, HWAVEOUT h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HWAVEOUT h1, HWAVEOUT h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HWAVEOUT h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ ///
+ ///
+ /// The WAVEFORMATEX structure defines the format of waveform-audio data. Only format information common to all
+ /// waveform-audio data formats is included in this structure. For formats that require additional information, this structure is
+ /// included as the first member in another structure, along with the additional information.
+ ///
+ ///
+ /// Formats that support more than two channels or sample sizes of more than 16 bits can be described in a WAVEFORMATEXTENSIBLE
+ /// structure, which includes the WAVEFORMAT structure.
+ ///
+ ///
+ ///
+ /// An example of a format that uses extra information is the Microsoft Adaptive Delta Pulse Code Modulation (MS-ADPCM) format. The
+ /// wFormatTag for MS-ADPCM is WAVE_FORMAT_ADPCM. The cbSize member will typically be set to 32. The extra information
+ /// stored for WAVE_FORMAT_ADPCM is coefficient pairs required for encoding and decoding the waveform-audio data.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-waveformatex typedef struct tWAVEFORMATEX { WORD wFormatTag;
+ // WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX,
+ // *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.tWAVEFORMATEX")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct WAVEFORMATEX
+ {
+ ///
+ /// Waveform-audio format type. Format tags are registered with Microsoft Corporation for many compression algorithms. A
+ /// complete list of format tags can be found in the Mmreg.h header file. For one- or two-channel PCM data, this value should be
+ /// WAVE_FORMAT_PCM. When this structure is included in a WAVEFORMATEXTENSIBLE structure, this value must be WAVE_FORMAT_EXTENSIBLE.
+ ///
+ public WAVE_FORMAT wFormatTag;
+
+ /// Number of channels in the waveform-audio data. Monaural data uses one channel and stereo data uses two channels.
+ public ushort nChannels;
+
+ ///
+ /// Sample rate, in samples per second (hertz). If wFormatTag is WAVE_FORMAT_PCM, then common values for
+ /// nSamplesPerSec are 8.0 kHz, 11.025 kHz, 22.05 kHz, and 44.1 kHz. For non-PCM formats, this member must be computed
+ /// according to the manufacturer's specification of the format tag.
+ ///
+ public uint nSamplesPerSec;
+
+ ///
+ /// Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM,
+ /// nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign. For non-PCM formats,
+ /// this member must be computed according to the manufacturer's specification of the format tag.
+ ///
+ public uint nAvgBytesPerSec;
+
+ ///
+ ///
+ /// Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If
+ /// wFormatTag is WAVE_FORMAT_PCM or WAVE_FORMAT_EXTENSIBLE, nBlockAlign must be equal to the product of
+ /// nChannels and wBitsPerSample divided by 8 (bits per byte). For non-PCM formats, this member must be computed
+ /// according to the manufacturer's specification of the format tag.
+ ///
+ ///
+ /// Software must process a multiple of nBlockAlign bytes of data at a time. Data written to and read from a device must
+ /// always start at the beginning of a block. For example, it is illegal to start playback of PCM data in the middle of a sample
+ /// (that is, on a non-block-aligned boundary).
+ ///
+ ///
+ public ushort nBlockAlign;
+
+ ///
+ /// Bits per sample for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample
+ /// should be equal to 8 or 16. For non-PCM formats, this member must be set according to the manufacturer's specification of
+ /// the format tag. If wFormatTag is WAVE_FORMAT_EXTENSIBLE, this value can be any integer multiple of 8 and represents
+ /// the container size, not necessarily the sample size; for example, a 20-bit sample size is in a 24-bit container. Some
+ /// compression schemes cannot define a value for wBitsPerSample, so this member can be 0.
+ ///
+ public ushort wBitsPerSample;
+
+ ///
+ /// Size, in bytes, of extra format information appended to the end of the WAVEFORMATEX structure. This information can
+ /// be used by non-PCM formats to store extra attributes for the wFormatTag. If no extra information is required by the
+ /// wFormatTag, this member must be set to 0. For WAVE_FORMAT_PCM formats (and only WAVE_FORMAT_PCM formats), this member
+ /// is ignored. When this structure is included in a WAVEFORMATEXTENSIBLE structure, this value must be at least 22.
+ ///
+ public ushort cbSize;
+ }
+
+ ///
+ /// The WAVEFORMATEXTENSIBLE structure defines the format of waveform-audio data for formats having more than two channels or
+ /// higher sample resolutions than allowed by WAVEFORMATEX. It can also be used to define any format that can be defined by WAVEFORMATEX.
+ ///
+ ///
+ ///
+ /// WAVEFORMATEXTENSIBLE can describe any format that can be described by WAVEFORMATEX, but provides additional support for
+ /// more than two channels, for greater precision in the number of bits per sample, and for new compression schemes.
+ ///
+ ///
+ /// WAVEFORMATEXTENSIBLE can safely be cast to WAVEFORMATEX, because it simply configures the extra bytes specified by WAVEFORMATEX.cbSize.
+ ///
+ ///
+ /// The dwChannelMask member specifies which channels are present in the multichannel stream. The least significant bit
+ /// corresponds with the front left speaker, the next least significant bit corresponds to the front right speaker, and so on. The
+ /// bits, in order of significance, are defined as follows.
+ ///
+ ///
+ ///
+ /// Speaker position
+ /// Flag bit
+ ///
+ /// -
+ /// SPEAKER_FRONT_LEFT
+ /// 0x1
+ ///
+ /// -
+ /// SPEAKER_FRONT_RIGHT
+ /// 0x2
+ ///
+ /// -
+ /// SPEAKER_FRONT_CENTER
+ /// 0x4
+ ///
+ /// -
+ /// SPEAKER_LOW_FREQUENCY
+ /// 0x8
+ ///
+ /// -
+ /// SPEAKER_BACK_LEFT
+ /// 0x10
+ ///
+ /// -
+ /// SPEAKER_BACK_RIGHT
+ /// 0x20
+ ///
+ /// -
+ /// SPEAKER_FRONT_LEFT_OF_CENTER
+ /// 0x40
+ ///
+ /// -
+ /// SPEAKER_FRONT_RIGHT_OF_CENTER
+ /// 0x80
+ ///
+ /// -
+ /// SPEAKER_BACK_CENTER
+ /// 0x100
+ ///
+ /// -
+ /// SPEAKER_SIDE_LEFT
+ /// 0x200
+ ///
+ /// -
+ /// SPEAKER_SIDE_RIGHT
+ /// 0x400
+ ///
+ /// -
+ /// SPEAKER_TOP_CENTER
+ /// 0x800
+ ///
+ /// -
+ /// SPEAKER_TOP_FRONT_LEFT
+ /// 0x1000
+ ///
+ /// -
+ /// SPEAKER_TOP_FRONT_CENTER
+ /// 0x2000
+ ///
+ /// -
+ /// SPEAKER_TOP_FRONT_RIGHT
+ /// 0x4000
+ ///
+ /// -
+ /// SPEAKER_TOP_BACK_LEFT
+ /// 0x8000
+ ///
+ /// -
+ /// SPEAKER_TOP_BACK_CENTER
+ /// 0x10000
+ ///
+ /// -
+ /// SPEAKER_TOP_BACK_RIGHT
+ /// 0x20000
+ ///
+ ///
+ ///
+ /// The channels specified in dwChannelMask must be present in the prescribed order (from least significant bit up). For
+ /// example, if only SPEAKER_FRONT_LEFT and SPEAKER_FRONT_RIGHT are specified, then the samples for the front left speaker must come
+ /// first in the interleaved stream. The number of bits set in dwChannelMask should be the same as the number of channels
+ /// specified in WAVEFORMATEX.nChannels.
+ ///
+ ///
+ /// For backward compatibility, any wave format that can be specified by a stand-alone WAVEFORMATEX structure can also be defined by
+ /// a WAVEFORMATEXTENSIBLE structure. Thus, every wave-format tag in mmreg.h has a corresponding SubFormat GUID. The
+ /// following table shows some typical wave-format tags and their corresponding SubFormat GUIDs. These GUIDs are defined in Ksmedia.h.
+ ///
+ ///
+ ///
+ /// Wave-Format Tag
+ /// SubFormat GUID
+ ///
+ /// -
+ /// WAVE_FORMAT_PCM
+ /// KSDATAFORMAT_SUBTYPE_PCM
+ ///
+ /// -
+ /// WAVE_FORMAT_IEEE_FLOAT
+ /// KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
+ ///
+ /// -
+ /// WAVE_FORMAT_DRM
+ /// KSDATAFORMAT_SUBTYPE_DRM
+ ///
+ /// -
+ /// WAVE_FORMAT_ALAW
+ /// KSDATAFORMAT_SUBTYPE_ALAW
+ ///
+ /// -
+ /// WAVE_FORMAT_MULAW
+ /// KSDATAFORMAT_SUBTYPE_MULAW
+ ///
+ /// -
+ /// WAVE_FORMAT_ADPCM
+ /// KSDATAFORMAT_SUBTYPE_ADPCM
+ ///
+ ///
+ ///
+ /// Because WAVEFORMATEXTENSIBLE is an extended version of WAVEFORMATEX, it can describe additional formats that cannot be
+ /// described by WAVEFORMATEX alone. Vendors are free to define their own SubFormat GUIDs to identify proprietary
+ /// formats for which no wave-format tags exist.
+ ///
+ /// The following structures, for particular extended formats, are defined as WAVEFORMATEXTENSIBLE.
+ ///
+ ///
+ /// Definition
+ /// Value of SubFormat
+ ///
+ /// -
+ /// WAVEFORMATIEEEFLOATEX
+ /// KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
+ ///
+ /// -
+ /// WAVEFORMATPCMEX
+ /// KSDATAFORMAT_SUBTYPE_PCM
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatextensible typedef struct { WAVEFORMATEX Format;
+ // union { WORD wValidBitsPerSample; WORD wSamplesPerBlock; WORD wReserved; } Samples; DWORD dwChannelMask; GUID SubFormat; }
+ // WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
+ [PInvokeData("mmreg.h", MSDNShortId = "NS:mmreg.__unnamed_struct_0")]
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ public struct WAVEFORMATEXTENSIBLE
+ {
+ ///
+ /// WAVEFORMATEX structure that specifies the basic format. The wFormatTag member must be WAVE_FORMAT_EXTENSIBLE. The
+ /// cbSize member must be at least 22.
+ ///
+ public WAVEFORMATEX Format;
+
+ /// A union describing the sample format.
+ public SAMPLES Samples;
+
+ /// Bitmask specifying the assignment of channels in the stream to speaker positions.
+ public uint dwChannelMask;
+
+ ///
+ /// Subformat of the data, such as KSDATAFORMAT_SUBTYPE_PCM. The subformat information is similar to that provided by the tag in
+ /// the WAVEFORMATEX structure's wFormatTag member.
+ ///
+ public Guid SubFormat;
+
+ /// A union describing the sample format.
+ [StructLayout(LayoutKind.Explicit)]
+ public struct SAMPLES
+ {
+ ///
+ /// Number of bits of precision in the signal. Usually equal to WAVEFORMATEX.wBitsPerSample. However,
+ /// wBitsPerSample is the container size and must be a multiple of 8, whereas wValidBitsPerSample can be any
+ /// value not exceeding the container size. For example, if the format uses 20-bit samples, wBitsPerSample must be at
+ /// least 24, but wValidBitsPerSample is 20.
+ ///
+ [FieldOffset(0)]
+ public ushort wValidBitsPerSample;
+
+ ///
+ /// Number of samples contained in one compressed block of audio data. This value is used in buffer estimation. This value
+ /// is used with compressed formats that have a fixed number of samples within each block. This value can be set to 0 if a
+ /// variable number of samples is contained in each block of compressed audio data. In this case, buffer estimation and
+ /// position information needs to be obtained in other ways.
+ ///
+ [FieldOffset(0)]
+ public ushort wSamplesPerBlock;
+
+ /// Reserved for internal use by operating system. Set to 0.
+ [FieldOffset(0)]
+ public ushort wReserved;
+ }
+ }
+
+ /// The WAVEHDR structure defines the header used to identify a waveform-audio buffer.
+ ///
+ ///
+ /// Use the WHDR_BEGINLOOP and WHDR_ENDLOOP flags in the dwFlags member to specify the beginning and ending data blocks for
+ /// looping. To loop on a single block, specify both flags for the same block. Use the dwLoops member in the WAVEHDR
+ /// structure for the first block in the loop to specify the number of times to play the loop.
+ ///
+ ///
+ /// The lpData, dwBufferLength, and dwFlags members must be set before calling the waveInPrepareHeader or
+ /// waveOutPrepareHeader function. (For either function, the dwFlags member must be set to zero.)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-wavehdr typedef struct wavehdr_tag { LPSTR lpData; DWORD
+ // dwBufferLength; DWORD dwBytesRecorded; DWORD_PTR dwUser; DWORD dwFlags; DWORD dwLoops; struct wavehdr_tag *lpNext; DWORD_PTR
+ // reserved; } WAVEHDR, *PWAVEHDR, *NPWAVEHDR, *LPWAVEHDR;
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.wavehdr_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct WAVEHDR
+ {
+ /// Pointer to the waveform buffer.
+ public IntPtr lpData;
+
+ /// Length, in bytes, of the buffer.
+ public uint dwBufferLength;
+
+ /// When the header is used in input, specifies how much data is in the buffer.
+ public uint dwBytesRecorded;
+
+ /// User data.
+ public IntPtr dwUser;
+
+ ///
+ /// A bitwise OR of zero of more flags. The following flags are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// WHDR_BEGINLOOP
+ /// This buffer is the first buffer in a loop. This flag is used only with output buffers.
+ ///
+ /// -
+ /// WHDR_DONE
+ /// Set by the device driver to indicate that it is finished with the buffer and is returning it to the application.
+ ///
+ /// -
+ /// WHDR_ENDLOOP
+ /// This buffer is the last buffer in a loop. This flag is used only with output buffers.
+ ///
+ /// -
+ /// WHDR_INQUEUE
+ /// Set by Windows to indicate that the buffer is queued for playback.
+ ///
+ /// -
+ /// WHDR_PREPARED
+ ///
+ /// Set by Windows to indicate that the buffer has been prepared with the waveInPrepareHeader or waveOutPrepareHeader function.
+ ///
+ ///
+ ///
+ ///
+ public WHDR dwFlags;
+
+ /// Number of times to play the loop. This member is used only with output buffers.
+ public uint dwLoops;
+
+ /// Reserved.
+ public IntPtr lpNext;
+
+ /// Reserved.
+ public IntPtr reserved;
+ }
+
+ /// The WAVEINCAPS structure describes the capabilities of a waveform-audio input device.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-waveincaps typedef struct waveincaps_tag { WORD wMid; WORD
+ // wPid; VERSION vDriverVersion; char szPname[MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; } WAVEINCAPS, *PWAVEINCAPS,
+ // *NPWAVEINCAPS, *LPWAVEINCAPS;
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.waveincaps_tag")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct WAVEINCAPS
+ {
+ ///
+ /// Manufacturer identifier for the device driver for the waveform-audio input device. Manufacturer identifiers are defined in
+ /// Manufacturer and Product Identifiers.
+ ///
+ public ushort wMid;
+
+ ///
+ /// Product identifier for the waveform-audio input device. Product identifiers are defined in Manufacturer and Product Identifiers.
+ ///
+ public ushort wPid;
+
+ ///
+ /// Version number of the device driver for the waveform-audio input device. The high-order byte is the major version number,
+ /// and the low-order byte is the minor version number.
+ ///
+ public uint vDriverVersion;
+
+ /// Product name in a null-terminated string.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
+ public string szPname;
+
+ ///
+ /// Standard formats that are supported. Can be a combination of the following:
+ ///
+ ///
+ /// Format
+ /// Description
+ ///
+ /// -
+ /// WAVE_FORMAT_1M08
+ /// 11.025 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1M16
+ /// 11.025 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1S08
+ /// 11.025 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1S16
+ /// 11.025 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2M08
+ /// 22.05 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2M16
+ /// 22.05 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2S08
+ /// 22.05 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2S16
+ /// 22.05 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4M08
+ /// 44.1 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4M16
+ /// 44.1 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4S08
+ /// 44.1 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4S16
+ /// 44.1 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96M08
+ /// 96 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96M16
+ /// 96 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96S08
+ /// 96 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96S16
+ /// 96 kHz, stereo, 16-bit
+ ///
+ ///
+ ///
+ public uint dwFormats;
+
+ /// Number specifying whether the device supports mono (1) or stereo (2) input.
+ public ushort wChannels;
+ }
+
+ /// The WAVEOUTCAPS structure describes the capabilities of a waveform-audio output device.
+ ///
+ /// If a device supports volume changes, the WAVECAPS_VOLUME flag will be set for the dwSupport member. If a device supports
+ /// separate volume changes on the left and right channels, both the WAVECAPS_VOLUME and the WAVECAPS_LRVOLUME flags will be set for
+ /// this member.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmeapi/ns-mmeapi-waveoutcaps typedef struct waveoutcaps_tag { WORD wMid; WORD
+ // wPid; VERSION vDriverVersion; char szPname[MAXPNAMELEN]; DWORD dwFormats; WORD wChannels; DWORD dwSupport; } WAVEOUTCAPS,
+ // *PWAVEOUTCAPS, *NPWAVEOUTCAPS, *LPWAVEOUTCAPS;
+ [PInvokeData("mmeapi.h", MSDNShortId = "NS:mmeapi.waveoutcaps_tag")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct WAVEOUTCAPS
+ {
+ ///
+ /// Manufacturer identifier for the device driver for the device. Manufacturer identifiers are defined in Manufacturer and
+ /// Product Identifiers.
+ ///
+ public ushort wMid;
+
+ /// Product identifier for the device. Product identifiers are defined in Manufacturer and Product Identifiers.
+ public ushort wPid;
+
+ ///
+ /// Version number of the device driver for the device. The high-order byte is the major version number, and the low-order byte
+ /// is the minor version number.
+ ///
+ public uint vDriverVersion;
+
+ /// Product name in a null-terminated string.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
+ public string szPname;
+
+ ///
+ /// Standard formats that are supported. Can be a combination of the following:
+ ///
+ ///
+ /// Format
+ /// Description
+ ///
+ /// -
+ /// WAVE_FORMAT_1M08
+ /// 11.025 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1M16
+ /// 11.025 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1S08
+ /// 11.025 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_1S16
+ /// 11.025 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2M08
+ /// 22.05 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2M16
+ /// 22.05 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2S08
+ /// 22.05 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_2S16
+ /// 22.05 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4M08
+ /// 44.1 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4M16
+ /// 44.1 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4S08
+ /// 44.1 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_4S16
+ /// 44.1 kHz, stereo, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96M08
+ /// 96 kHz, mono, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96M16
+ /// 96 kHz, mono, 16-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96S08
+ /// 96 kHz, stereo, 8-bit
+ ///
+ /// -
+ /// WAVE_FORMAT_96S16
+ /// 96 kHz, stereo, 16-bit
+ ///
+ ///
+ ///
+ public uint dwFormats;
+
+ /// Number specifying whether the device supports mono (1) or stereo (2) output.
+ public ushort wChannels;
+
+ ///
+ /// Optional functionality supported by the device. The following values are defined:
+ ///
+ ///
+ /// Flag
+ /// Description
+ ///
+ /// -
+ /// WAVECAPS_LRVOLUME
+ /// Supports separate left and right volume control.
+ ///
+ /// -
+ /// WAVECAPS_PITCH
+ /// Supports pitch control.
+ ///
+ /// -
+ /// WAVECAPS_PLAYBACKRATE
+ /// Supports playback rate control.
+ ///
+ /// -
+ /// WAVECAPS_SYNC
+ /// The driver is synchronous and will block while playing a buffer.
+ ///
+ /// -
+ /// WAVECAPS_VOLUME
+ /// Supports volume control.
+ ///
+ /// -
+ /// WAVECAPS_SAMPLEACCURATE
+ /// Returns sample-accurate position information.
+ ///
+ ///
+ ///
+ public WAVECAPS dwSupport;
+ }
+
+ /// The MMTIME structure contains timing information for different types of multimedia data.
+ /// Provides a for that is disposed using .
+ public class SafeHWAVEIN : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ ///
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ ///
+ public SafeHWAVEIN(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHWAVEIN() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HWAVEIN(SafeHWAVEIN h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => waveInClose(handle) == MMRESULT.MMSYSERR_NOERROR;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHWAVEOUT : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ ///
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ ///
+ public SafeHWAVEOUT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHWAVEOUT() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HWAVEOUT(SafeHWAVEOUT h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => waveOutClose(handle) == MMRESULT.MMSYSERR_NOERROR;
+ }
+
+ /*
+ MM_WIM_CLOSE
+ MM_WIM_DATA
+ MM_WIM_OPEN
+ MM_WOM_CLOSE
+ MM_WOM_DONE
+ MM_WOM_OPEN
+ WIM_CLOSE
+ WIM_DATA
+ WIM_OPEN
+ WOM_CLOSE
+ WOM_DONE
+ WOM_OPEN
+
+ MEVT_EVENTPARM
+MEVT_EVENTTYPE
+midiConnect
+midiDisconnect
+midiInAddBuffer
+midiInClose
+midiInGetDevCaps
+midiInGetDevCapsA
+midiInGetDevCapsW
+midiInGetErrorText
+midiInGetErrorTextA
+midiInGetErrorTextW
+midiInGetID
+midiInGetNumDevs
+midiInMessage
+midiInOpen
+midiInPrepareHeader
+midiInReset
+midiInStart
+midiInStop
+midiInUnprepareHeader
+midiOutCacheDrumPatches
+midiOutCachePatches
+midiOutClose
+midiOutGetDevCaps
+midiOutGetDevCapsA
+midiOutGetDevCapsW
+midiOutGetErrorText
+midiOutGetErrorTextA
+midiOutGetErrorTextW
+midiOutGetID
+midiOutGetNumDevs
+midiOutGetVolume
+midiOutLongMsg
+midiOutMessage
+midiOutOpen
+midiOutPrepareHeader
+midiOutReset
+midiOutSetVolume
+midiOutShortMsg
+midiOutUnprepareHeader
+midiStreamClose
+midiStreamOpen
+midiStreamOut
+midiStreamPause
+midiStreamPosition
+midiStreamProperty
+midiStreamRestart
+midiStreamStop
+mixerClose
+mixerGetControlDetails
+mixerGetControlDetailsA
+mixerGetControlDetailsW
+mixerGetDevCaps
+mixerGetDevCapsA
+mixerGetDevCapsW
+mixerGetID
+mixerGetLineControls
+mixerGetLineControlsA
+mixerGetLineControlsW
+mixerGetLineInfo
+mixerGetLineInfoA
+mixerGetLineInfoW
+mixerGetNumDevs
+mixerMessage
+mixerOpen
+mixerSetControlDetails
+*/
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vanara.PInvoke.Multimedia.csproj b/PInvoke/Multimedia/Vanara.PInvoke.Multimedia.csproj
new file mode 100644
index 00000000..25b3eddc
--- /dev/null
+++ b/PInvoke/Multimedia/Vanara.PInvoke.Multimedia.csproj
@@ -0,0 +1,22 @@
+
+
+
+ winmm.dll;msacm32.dll;avifil32.dll
+
+
+ PInvoke API (methods, structures and constants) imported from Windows Multimedia (winmm.dll, msacm32.dll, avifil32.dll).
+ $(AssemblyName)
+ net20;net35;net40;net45;net5.0-windows;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1
+ Vanara.PInvoke.Multimedia
+ $(AssemblyName)
+ pinvoke;vanara;net-extensions;interop;winmm;windows multimedia;wav;waveform;audio;msacm32;avifil32
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.AVI.cs b/PInvoke/Multimedia/Vfw.AVI.cs
new file mode 100644
index 00000000..b2e165a9
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.AVI.cs
@@ -0,0 +1,2619 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the AviFil32.dll
+ public static partial class AviFil32
+ {
+ /// Let the stream handler determine the number of samples to read.
+ public const int AVISTREAMREAD_CONVENIENT = -1;
+
+ private const string Lib_Avifil32 = "avifil32.dll";
+
+ ///
+ /// A callback function (referenced by using lpfnCallback) can display status information and let the user cancel the save operation.
+ ///
+ /// Specifies the percentage of the file saved.
+ ///
+ /// The callback function should return if the operation should continue and if the
+ /// user wishes to abort the save operation.
+ ///
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public delegate bool AVISAVECALLBACK(int nPercent);
+
+ /// Flags used for compression.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_17")]
+ [Flags]
+ public enum AVICOMPRESSF : uint
+ {
+ /// Interleaves this stream every dwInterleaveEvery frames with respect to the first stream.
+ AVICOMPRESSF_INTERLEAVE = 0x00000001,
+
+ /// Compresses this video stream using the data rate specified in dwBytesPerSecond.
+ AVICOMPRESSF_DATARATE = 0x00000002,
+
+ ///
+ /// Saves this video stream with key frames at least every dwKeyFrameEvery frames. By default, every frame will be a key frame.
+ ///
+ AVICOMPRESSF_KEYFRAMES = 0x00000004,
+
+ ///
+ /// Uses the data in this structure to set the default compression values for AVISaveOptions. If an empty structure is passed
+ /// and this flag is not set, some defaults will be chosen.
+ ///
+ AVICOMPRESSF_VALID = 0x00000008,
+ }
+
+ /// Capability flags for .
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw._AVIFILEINFOA")]
+ [Flags]
+ public enum AVIFILECAPS : uint
+ {
+ /// An application can open the AVI file with the read privilege.
+ AVIFILECAPS_CANREAD = 0x00000001,
+
+ /// An application can open the AVI file with the write privilege.
+ AVIFILECAPS_CANWRITE = 0x00000002,
+
+ /// Every frame in the AVI file is a key frame.
+ AVIFILECAPS_ALLKEYFRAMES = 0x00000010,
+
+ /// The AVI file does not use a compression method.
+ AVIFILECAPS_NOCOMPRESSION = 0x00000020,
+ }
+
+ /// Flags for .
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw._AVIFILEINFOA")]
+ [Flags]
+ public enum AVIFILEINFOF : uint
+ {
+ /// The AVI file has an index at the end of the file. For good performance, all AVI files should contain an index.
+ AVIFILEINFO_HASINDEX = 0x00000010,
+
+ ///
+ /// The file index contains the playback order for the chunks in the file. Use the index rather than the physical ordering of
+ /// the chunks when playing back the data. This could be used for creating a list of frames for editing.
+ ///
+ AVIFILEINFO_MUSTUSEINDEX = 0x00000020,
+
+ /// The AVI file is interleaved.
+ AVIFILEINFO_ISINTERLEAVED = 0x00000100,
+
+ ///
+ /// The AVI file is a specially allocated file used for capturing real-time video. Applications should warn the user before
+ /// writing over a file with this flag set because the user probably defragmented this file.
+ ///
+ AVIFILEINFO_WASCAPTUREFILE = 0x00010000,
+
+ ///
+ /// The AVI file contains copyrighted data and software. When this flag is used, software should not permit the data to be duplicated.
+ ///
+ AVIFILEINFO_COPYRIGHTED = 0x00020000,
+ }
+
+ /// Flag associated with this data.
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamWrite")]
+ [Flags]
+ public enum AVIIF : uint
+ {
+ ///
+ AVIIF_LIST = 0x00000001,
+
+ ///
+ AVIIF_TWOCC = 0x00000002,
+
+ /// Indicates this data does not rely on preceding data in the file.
+ AVIIF_KEYFRAME = 0x00000010,
+ }
+
+ /// Applicable flags for the stream.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw._AVISTREAMINFOA")]
+ [Flags]
+ public enum AVISTREAMINFOF : uint
+ {
+ /// Indicates this stream should be rendered when explicitly enabled by the user.
+ AVISTREAMINFO_DISABLED = 0x00000001,
+
+ ///
+ /// Indicates this video stream contains palette changes. This flag warns the playback software that it will need to animate the palette.
+ ///
+ AVISTREAMINFO_FORMATCHANGES = 0x00010000
+ }
+
+ /// Indicates whether the audio stream controls the clock when writing an AVI file.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.tagCaptureParms")]
+ public enum AVSTREAMMASTER
+ {
+ ///
+ /// The audio stream is considered the master stream and the video stream duration is forced to match the audio duration.
+ ///
+ AVSTREAMMASTER_AUDIO = 0,
+
+ /// The durations of audio and video streams can differ.
+ AVSTREAMMASTER_NONE = 1,
+ }
+
+ ///
+ /// Flags that designate the type of frame to locate, the direction in the stream to search, and the type of return information.
+ ///
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamFindSample")]
+ [Flags]
+ public enum FINDF : uint
+ {
+ /// direction
+ FIND_DIR = 0x0000000F,
+
+ ///
+ /// Finds nearest sample, frame, or format change searching forward. The current sample is included in the search. Use this flag
+ /// with the FIND_ANY, FIND_KEY, or FIND_FORMAT flag. This flag supersedes the SEARCH_FORWARD flag.
+ ///
+ FIND_NEXT = 0x00000001,
+
+ ///
+ /// Finds nearest sample, frame, or format change searching backward. The current sample is included in the search. Use this
+ /// flag with the FIND_ANY, FIND_KEY, or FIND_FORMAT flag. This flag supersedes the SEARCH_NEAREST and SEARCH_BACKWARD flags.
+ ///
+ FIND_PREV = 0x00000004,
+
+ ///
+ /// Finds first sample, frame, or format change beginning from the start of the stream. Use this flag with the FIND_ANY,
+ /// FIND_KEY, or FIND_FORMAT flag.
+ ///
+ FIND_FROM_START = 0x00000008,
+
+ /// type mask
+ FIND_TYPE = 0x000000F0,
+
+ /// Finds a key frame. This flag supersedes the SEARCH_KEY flag.
+ FIND_KEY = 0x00000010,
+
+ /// Finds a nonempty frame. This flag supersedes the SEARCH_ANY flag.
+ FIND_ANY = 0x00000020,
+
+ /// Finds a format change.
+ FIND_FORMAT = 0x00000040,
+
+ /// return mask
+ FIND_RET = 0x0000F000,
+
+ /// return logical position
+ FIND_POS = 0x00000000,
+
+ /// return logical size
+ FIND_LENGTH = 0x00001000,
+
+ /// return physical position
+ FIND_OFFSET = 0x00002000,
+
+ /// return physical size
+ FIND_SIZE = 0x00003000,
+
+ /// return physical index position
+ FIND_INDEX = 0x00004000,
+ }
+
+ /// Flags for displaying the Compression Options dialog box.
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveOptions")]
+ [Flags]
+ public enum ICMF_CHOOSE : uint
+ {
+ ///
+ /// Displays a Key Frame Every dialog box for the video options. This is the same flag used in the ICCompressorChoose function.
+ ///
+ ICMF_CHOOSE_KEYFRAME = 0x0001,
+
+ /// Displays a Data Rate dialog box for the video options. This is the same flag used in ICCompressorChoose.
+ ICMF_CHOOSE_DATARATE = 0x0002,
+
+ ///
+ /// Displays a Preview button for the video options. This button previews the compression by using a frame from the stream. This
+ /// is the same flag used in ICCompressorChoose.
+ ///
+ ICMF_CHOOSE_PREVIEW = 0x0004,
+
+ /// Don't only show those that can handle the input format or input data.
+ ICMF_CHOOSE_ALLCOMPRESSORS = 0x0008,
+ }
+
+ ///
+ /// The AVIBuildFilter function builds a filter specification that is subsequently used by the GetOpenFileName or
+ /// GetSaveFileName function.
+ ///
+ /// Pointer to the buffer containing the filter string.
+ /// Size, in characters, of buffer pointed to by lpszFilter.
+ ///
+ /// Flag that indicates whether the filter should include read or write formats. Specify TRUE to include write formats or
+ /// FALSE to include read formats.
+ ///
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_BUFFERTOOSMALL
+ /// The buffer size cbFilter was smaller than the generated filter specification.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// There was not enough memory to complete the read operation.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function accesses the registry for all filter types that the AVIFile library can use to open, read, or write multimedia
+ /// files. It does not search the hard disk for filter DLLs and formats.
+ ///
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVIBuildFilter 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-avibuildfiltera HRESULT AVIBuildFilterA( LPSTR lpszFilter, LONG
+ // cbFilter, BOOL fSaving );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIBuildFilterA")]
+ public static extern HRESULT AVIBuildFilter([Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszFilter, int cbFilter,
+ [MarshalAs(UnmanagedType.Bool)] bool fSaving);
+
+ /// The AVIClearClipboard function removes an AVI file from the clipboard.
+ /// Returns zero if successful or an error otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-aviclearclipboard HRESULT AVIClearClipboard();
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIClearClipboard")]
+ public static extern HRESULT AVIClearClipboard();
+
+ /// The AVIFileAddRef function increments the reference count of an AVI file.
+ /// Handle to an open AVI file.
+ /// Returns the updated reference count for the file interface.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileaddref ULONG AVIFileAddRef( IAVIFile pfile );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileAddRef")]
+ public static extern uint AVIFileAddRef(IAVIFile pfile);
+
+ ///
+ /// The AVIFileCreateStream function creates a new stream in an existing file and creates an interface to the new stream.
+ ///
+ /// Handle to an open AVI file.
+ /// Pointer to the new stream interface.
+ ///
+ /// Pointer to a structure containing information about the new stream, including the stream type and its sample rate.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Unless the file has been opened with write permission, this function returns AVIERR_READONLY.
+ ///
+ ///
+ /// This function starts a reference count for the new stream.
+ /// The argument pfile is a pointer to an IAVIFile interface. The argument ppavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifilecreatestream HRESULT AVIFileCreateStream( IAVIFile pfile,
+ // IAVIStream *ppavi, AVISTREAMINFO *psi );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileCreateStream")]
+ public static extern HRESULT AVIFileCreateStream(IAVIFile pfile, out IAVIStream ppavi, in AVISTREAMINFO psi);
+
+ ///
+ /// The AVIFileEndRecord function marks the end of a record when writing an interleaved file that uses a 1:1 interleave
+ /// factor of video to audio data. (Each frame of video is interspersed with an equivalent amount of audio data.)
+ ///
+ /// Handle to an open AVI file.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// The AVISave function uses this function internally. In general, applications should not need to use this function.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileendrecord HRESULT AVIFileEndRecord( IAVIFile pfile );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileEndRecord")]
+ public static extern HRESULT AVIFileEndRecord(IAVIFile pfile);
+
+ ///
+ /// The AVIFileExit function exits the AVIFile library and decrements the reference count for the library.
+ /// This function supersedes the obsolete AVIStreamExit function.
+ ///
+ /// None
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileexit void AVIFileExit();
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileExit")]
+ public static extern void AVIFileExit();
+
+ ///
+ /// The AVIFileGetStream function returns the address of a stream interface that is associated with a specified AVI file.
+ ///
+ /// Handle to an open AVI file.
+ /// Pointer to the new stream interface.
+ ///
+ ///
+ /// Four-character code indicating the type of stream to open. Zero indicates any stream can be opened. The following definitions
+ /// apply to the data commonly found in AVI streams.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// streamtypeAUDIO
+ /// Indicates an audio stream.
+ ///
+ /// -
+ /// streamtypeMIDI
+ /// Indicates a MIDI stream.
+ ///
+ /// -
+ /// streamtypeTEXT
+ /// Indicates a text stream.
+ ///
+ /// -
+ /// streamtypeVIDEO
+ /// Indicates a video stream.
+ ///
+ ///
+ ///
+ /// Count of the stream type. Identifies which occurrence of the specified stream type to access.
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_NODATA
+ /// The file does not contain a stream corresponding to the values of fccType and lParam.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// Not enough memory.
+ ///
+ ///
+ ///
+ /// The argument pfile is a pointer to an IAVIFile interface. The argument ppavi is a pointer to an IAVIStream interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifilegetstream HRESULT AVIFileGetStream( IAVIFile pfile,
+ // IAVIStream *ppavi, DWORD fccType, LONG lParam );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileGetStream")]
+ public static extern HRESULT AVIFileGetStream(IAVIFile pfile, out IAVIStream ppavi, uint fccType, int lParam);
+
+ /// The AVIFileInfo function obtains information about an AVI file.
+ /// Handle to an open AVI file.
+ ///
+ /// Pointer to the structure used to return file information. Typically, this parameter points to an AVIFILEINFO structure.
+ ///
+ /// Size, in bytes, of the structure.
+ /// Returns zero if successful or an error otherwise.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileinfo HRESULT AVIFileInfo( IAVIFile pfile, LPAVIFILEINFO pfi,
+ // LONG lSize );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileInfo")]
+ public static extern HRESULT AVIFileInfo(IAVIFile pfile, out AVIFILEINFO pfi, int lSize);
+
+ ///
+ /// The AVIFileInit function initializes the AVIFile library.
+ ///
+ /// The AVIFile library maintains a count of the number of times it is initialized, but not the number of times it was released. Use
+ /// the AVIFileExit function to release the AVIFile library and decrement the reference count. Call AVIFileInit before using
+ /// any other AVIFile functions.
+ ///
+ /// This function supersedes the obsolete AVIStreamInit function.
+ ///
+ /// None
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileinit void AVIFileInit();
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileInit")]
+ public static extern void AVIFileInit();
+
+ ///
+ /// The AVIFileOpen function opens an AVI file and returns the address of a file interface used to access it. The AVIFile
+ /// library maintains a count of the number of times a file is opened, but not the number of times it was released. Use the
+ /// AVIFileRelease function to release the file and decrement the count.
+ ///
+ /// Pointer to a buffer that receives the new IAVIFile interface pointer.
+ /// Null-terminated string containing the name of the file to open.
+ ///
+ ///
+ /// Access mode to use when opening the file. The default access mode is OF_READ. The following access modes can be specified with AVIFileOpen.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// OF_CREATE
+ /// Creates a new file. If the file already exists, it is truncated to zero length.
+ ///
+ /// -
+ /// OF_PARSE
+ ///
+ /// Skips time-consuming operations, such as building an index. Set this flag if you want the function to return as quickly as
+ /// possible—for example, if you are going to query the file properties but not read the file.
+ ///
+ ///
+ /// -
+ /// OF_READ
+ /// Opens the file for reading.
+ ///
+ /// -
+ /// OF_READWRITE
+ /// Opens the file for reading and writing.
+ ///
+ /// -
+ /// OF_SHARE_DENY_NONE
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with read or write access. AVIFileOpen fails if another process
+ /// has opened the file in compatibility mode.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_DENY_READ
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with write access. AVIFileOpen fails if another process has
+ /// opened the file in compatibility mode or has read access to it.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_DENY_WRITE
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with read access. AVIFileOpen fails if another process has
+ /// opened the file in compatibility mode or has write access to it.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_EXCLUSIVE
+ /// Opens the file and denies other processes any access to it. AVIFileOpen fails if any other process has opened the file.
+ ///
+ /// -
+ /// OF_WRITE
+ /// Opens the file for writing.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a class identifier of the standard or custom handler you want to use. If the value is NULL, the system chooses
+ /// a handler from the registry based on the file extension or the RIFF type specified in the file.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_BADFORMAT
+ /// The file couldn't be read, indicating a corrupt file or an unrecognized format.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// The file could not be opened because of insufficient memory.
+ ///
+ /// -
+ /// AVIERR_FILEREAD
+ /// A disk error occurred while reading the file.
+ ///
+ /// -
+ /// AVIERR_FILEOPEN
+ /// A disk error occurred while opening the file.
+ ///
+ /// -
+ /// REGDB_E_CLASSNOTREG
+ /// According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileopen HRESULT AVIFileOpen( IAVIFile *ppfile, LPCSTR szFile,
+ // UINT uMode, LPCLSID lpHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileOpen")]
+ public static extern HRESULT AVIFileOpen(out IAVIFile ppfile, [MarshalAs(UnmanagedType.LPTStr)] string szFile,
+ Kernel32.OpenFileAction uMode, in Guid lpHandler);
+
+ ///
+ /// The AVIFileOpen function opens an AVI file and returns the address of a file interface used to access it. The AVIFile
+ /// library maintains a count of the number of times a file is opened, but not the number of times it was released. Use the
+ /// AVIFileRelease function to release the file and decrement the count.
+ ///
+ /// Pointer to a buffer that receives the new IAVIFile interface pointer.
+ /// Null-terminated string containing the name of the file to open.
+ ///
+ ///
+ /// Access mode to use when opening the file. The default access mode is OF_READ. The following access modes can be specified with AVIFileOpen.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// OF_CREATE
+ /// Creates a new file. If the file already exists, it is truncated to zero length.
+ ///
+ /// -
+ /// OF_PARSE
+ ///
+ /// Skips time-consuming operations, such as building an index. Set this flag if you want the function to return as quickly as
+ /// possible—for example, if you are going to query the file properties but not read the file.
+ ///
+ ///
+ /// -
+ /// OF_READ
+ /// Opens the file for reading.
+ ///
+ /// -
+ /// OF_READWRITE
+ /// Opens the file for reading and writing.
+ ///
+ /// -
+ /// OF_SHARE_DENY_NONE
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with read or write access. AVIFileOpen fails if another process
+ /// has opened the file in compatibility mode.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_DENY_READ
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with write access. AVIFileOpen fails if another process has
+ /// opened the file in compatibility mode or has read access to it.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_DENY_WRITE
+ ///
+ /// Opens the file nonexclusively. Other processes can open the file with read access. AVIFileOpen fails if another process has
+ /// opened the file in compatibility mode or has write access to it.
+ ///
+ ///
+ /// -
+ /// OF_SHARE_EXCLUSIVE
+ /// Opens the file and denies other processes any access to it. AVIFileOpen fails if any other process has opened the file.
+ ///
+ /// -
+ /// OF_WRITE
+ /// Opens the file for writing.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a class identifier of the standard or custom handler you want to use. If the value is NULL, the system chooses
+ /// a handler from the registry based on the file extension or the RIFF type specified in the file.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_BADFORMAT
+ /// The file couldn't be read, indicating a corrupt file or an unrecognized format.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// The file could not be opened because of insufficient memory.
+ ///
+ /// -
+ /// AVIERR_FILEREAD
+ /// A disk error occurred while reading the file.
+ ///
+ /// -
+ /// AVIERR_FILEOPEN
+ /// A disk error occurred while opening the file.
+ ///
+ /// -
+ /// REGDB_E_CLASSNOTREG
+ /// According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifileopen HRESULT AVIFileOpen( IAVIFile *ppfile, LPCSTR szFile,
+ // UINT uMode, LPCLSID lpHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileOpen")]
+ public static extern HRESULT AVIFileOpen(out IAVIFile ppfile, [MarshalAs(UnmanagedType.LPTStr)] string szFile,
+ Kernel32.OpenFileAction uMode, [In, Optional] IntPtr lpHandler);
+
+ ///
+ /// The AVIFileReadData function reads optional header data that applies to the entire file, such as author or copyright information.
+ ///
+ /// Handle to an open AVI file.
+ /// RIFF chunk identifier (four-character code) of the data.
+ /// Pointer to the buffer used to return the data read.
+ ///
+ /// Pointer to a location indicating the size of the memory block referenced by lpData. If the data is read successfully, the value
+ /// is changed to indicate the amount of data read.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. The return value AVIERR_NODATA indicates that data with the requested chunk
+ /// identifier does not exist.
+ ///
+ ///
+ /// The optional header information is custom and does not have a set format.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifilereaddata HRESULT AVIFileReadData( IAVIFile pfile, DWORD
+ // ckid, LPVOID lpData, LONG *lpcbData );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileReadData")]
+ public static extern HRESULT AVIFileReadData([In] IAVIFile pfile, uint ckid, [Out] IntPtr lpData, ref int lpcbData);
+
+ ///
+ ///
+ /// The AVIFileRelease function decrements the reference count of an AVI file interface handle and closes the file if the
+ /// count reaches zero.
+ ///
+ /// This function supersedes the obsolete AVIFileClose function.
+ ///
+ /// Handle to an open AVI file.
+ /// Returns the reference count of the file. This return value should be used only for debugging purposes.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifilerelease ULONG AVIFileRelease( IAVIFile pfile );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileRelease")]
+ public static extern uint AVIFileRelease(IAVIFile pfile);
+
+ ///
+ /// The AVIFileWriteData function writes supplementary data (other than normal header, format, and stream data) to the file.
+ ///
+ /// Handle to an open AVI file.
+ /// RIFF chunk identifier (four-character code) of the data.
+ /// Pointer to the buffer used to write the data.
+ /// Size, in bytes, of the memory block referenced by lpData.
+ ///
+ /// Returns zero if successful or an error otherwise. In an application has read-only access to the file, the error code
+ /// AVIERR_READONLY is returned.
+ ///
+ ///
+ /// Use the AVIStreamWriteData function to write data that applies to an individual stream.
+ /// The argument pfile is a pointer to an IAVIFile interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avifilewritedata HRESULT AVIFileWriteData( IAVIFile pfile, DWORD
+ // ckid, LPVOID lpData, LONG cbData );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIFileWriteData")]
+ public static extern HRESULT AVIFileWriteData(IAVIFile pfile, uint ckid, [In] IntPtr lpData, int cbData);
+
+ /// The AVIGetFromClipboard function copies an AVI file from the clipboard.
+ /// Pointer to the location used to return the handle created for the AVI file.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// If the clipboard does not contain an AVI file, AVIGetFromClipboard also can copy data with the CF_DIB or CF_WAVE
+ /// clipboard flags to an AVI file. In this case, the function creates an AVI file with one DIB stream and one waveform-audio
+ /// stream, and fills each stream with the data from the clipboard.
+ ///
+ /// The argument lppf is the address of a pointer to an IAVIFile interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avigetfromclipboard HRESULT AVIGetFromClipboard( IAVIFile *lppf );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIGetFromClipboard")]
+ public static extern HRESULT AVIGetFromClipboard(out IAVIFile lppf);
+
+ ///
+ /// The AVIMakeCompressedStream function creates a compressed stream from an uncompressed stream and a compression filter,
+ /// and returns the address of a pointer to the compressed stream. This function supports audio and video compression.
+ ///
+ /// Pointer to a buffer that receives the compressed stream pointer.
+ /// Pointer to the stream to be compressed.
+ ///
+ /// Pointer to a structure that identifies the type of compression to use and the options to apply. You can specify video
+ /// compression by identifying an appropriate handler in the AVICOMPRESSOPTIONS structure. For audio compression, specify the
+ /// compressed data format.
+ ///
+ /// Pointer to a class identifier used to create the stream.
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_NOCOMPRESSOR
+ /// A suitable compressor cannot be found.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// There is not enough memory to complete the operation.
+ ///
+ /// -
+ /// AVIERR_UNSUPPORTED
+ ///
+ /// Compression is not supported for this type of data. This error might be returned if you try to compress data that is not audio
+ /// or video.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Applications can read from or write to the compressed stream.
+ /// A IAVIStream is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avimakecompressedstream HRESULT AVIMakeCompressedStream( IAVIStream
+ // *ppsCompressed, IAVIStream ppsSource, AVICOMPRESSOPTIONS *lpOptions, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIMakeCompressedStream")]
+ public static extern HRESULT AVIMakeCompressedStream(out IAVIStream ppsCompressed, [In] IAVIStream ppsSource,
+ in AVICOMPRESSOPTIONS lpOptions, in Guid pclsidHandler);
+
+ ///
+ /// The AVIMakeCompressedStream function creates a compressed stream from an uncompressed stream and a compression filter,
+ /// and returns the address of a pointer to the compressed stream. This function supports audio and video compression.
+ ///
+ /// Pointer to a buffer that receives the compressed stream pointer.
+ /// Pointer to the stream to be compressed.
+ ///
+ /// Pointer to a structure that identifies the type of compression to use and the options to apply. You can specify video
+ /// compression by identifying an appropriate handler in the AVICOMPRESSOPTIONS structure. For audio compression, specify the
+ /// compressed data format.
+ ///
+ /// Pointer to a class identifier used to create the stream.
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_NOCOMPRESSOR
+ /// A suitable compressor cannot be found.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// There is not enough memory to complete the operation.
+ ///
+ /// -
+ /// AVIERR_UNSUPPORTED
+ ///
+ /// Compression is not supported for this type of data. This error might be returned if you try to compress data that is not audio
+ /// or video.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Applications can read from or write to the compressed stream.
+ /// A IAVIStream is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avimakecompressedstream HRESULT AVIMakeCompressedStream( IAVIStream
+ // *ppsCompressed, IAVIStream ppsSource, AVICOMPRESSOPTIONS *lpOptions, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIMakeCompressedStream")]
+ public static extern HRESULT AVIMakeCompressedStream(out IAVIStream ppsCompressed, [In] IAVIStream ppsSource,
+ in AVICOMPRESSOPTIONS lpOptions, [In, Optional] IntPtr pclsidHandler);
+
+ /// The AVIMakeFileFromStreams function constructs an AVIFile interface pointer from separate streams.
+ /// Pointer to a buffer that receives the new file interface pointer.
+ /// Count of the number of streams in the array of stream interface pointers referenced by papStreams.
+ /// Pointer to an array of stream interface pointers.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// Use the AVIFileRelease function to close the file.
+ ///
+ /// Other functions can use the AVIFile interface created by this function to copy and edit the streams associated with the
+ /// interface. For example, you can retrieve a specific stream by using AVIFileGetStream with the file interface pointer.
+ ///
+ ///
+ /// The argument pfile is the address of a pointer to an IAVIFile interface. The argument papStreams is the address of a pointer to
+ /// an IAVIStream interface.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avimakefilefromstreams HRESULT AVIMakeFileFromStreams( IAVIFile
+ // *ppfile, int nStreams, IAVIStream *papStreams );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIMakeFileFromStreams")]
+ public static extern HRESULT AVIMakeFileFromStreams(out IAVIFile ppfile, int nStreams,
+ [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 1)] IAVIStream[] papStreams);
+
+ /// The AVIMakeStreamFromClipboard function creates an editable stream from stream data on the clipboard.
+ /// Clipboard flag.
+ /// Handle to stream data on the clipboard.
+ /// Handle to the created stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// When an application finishes using the editable stream, it must release the stream to free the resources associated with it.
+ ///
+ /// The argument ppstream is the address of a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avimakestreamfromclipboard HRESULT AVIMakeStreamFromClipboard( UINT
+ // cfFormat, HANDLE hGlobal, IAVIStream *ppstream );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIMakeStreamFromClipboard")]
+ public static extern HRESULT AVIMakeStreamFromClipboard(uint cfFormat, Kernel32.HGLOBAL hGlobal, ref IAVIStream ppstream);
+
+ /// The AVIPutFileOnClipboard function copies an AVI file to the clipboard.
+ /// Handle to an open AVI file.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// This function also copies data with the CF_DIB, CF_PALETTE, and CF_WAVE clipboard flags onto the clipboard using the first frame
+ /// of the first video stream of the file as a DIB and using the audio stream as CF_WAVE.
+ ///
+ /// The argument pf is a pointer to an IAVIFile interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-aviputfileonclipboard HRESULT AVIPutFileOnClipboard( IAVIFile pf );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIPutFileOnClipboard")]
+ public static extern HRESULT AVIPutFileOnClipboard(IAVIFile pf);
+
+ /// The AVISave function builds a file by combining data streams from other files or from memory.
+ /// Null-terminated string containing the name of the file to save.
+ ///
+ /// Pointer to the file handler used to write the file. The file is created by calling the AVIFileOpen function using this handler.
+ /// If a handler is not specified, a default is selected from the registry based on the file extension.
+ ///
+ /// Pointer to a callback function for the save operation.
+ /// Number of streams saved in the file.
+ ///
+ /// Pointer to an AVI stream. This parameter is paired with lpOptions. The parameter pair can be repeated as a variable number of arguments.
+ ///
+ ///
+ /// Pointer to an application-defined AVICOMPRESSOPTIONS structure containing the compression options for the stream referenced by
+ /// pavi. This parameter is paired with pavi. The parameter pair can be repeated as a variable number of arguments.
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise.
+ ///
+ ///
+ /// This function creates a file, copies stream data into the file, closes the file, and releases the resources used by the new
+ /// file. The last two parameters of this function identify a stream to save in the file and define the compression options of that
+ /// stream. When saving more than one stream in an AVI file, repeat these two stream-specific parameters for each stream in the file.
+ ///
+ ///
+ /// A callback function (referenced by using lpfnCallback) can display status information and let the user cancel the save
+ /// operation. The callback function uses the following format:
+ ///
+ ///
+ /// LONG PASCAL SaveCallback(int nPercent)
+ ///
+ /// The nPercent parameter specifies the percentage of the file saved.
+ ///
+ /// The callback function should return AVIERR_OK if the operation should continue and AVIERR_USERABORT if the user wishes to abort
+ /// the save operation.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVISave 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-avisavea HRESULT AVISaveA( LPCSTR szFile, CLSID *pclsidHandler,
+ // AVISAVECALLBACK lpfnCallback, int nStreams, IAVIStream pfile, LPAVICOMPRESSOPTIONS lpOptions, ... );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveA")]
+ public static extern HRESULT AVISave([MarshalAs(UnmanagedType.LPTStr)] string szFile, [In, Optional] IntPtr pclsidHandler,
+ AVISAVECALLBACK lpfnCallback, int nStreams, IAVIStream pfile, in AVICOMPRESSOPTIONS lpOptions);
+
+ /// The AVISaveOptions function retrieves the save options for a file and returns them in a buffer.
+ /// Handle to the parent window for the Compression Options dialog box.
+ ///
+ /// Flags for displaying the Compression Options dialog box. The following flags are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// ICMF_CHOOSE_KEYFRAME
+ /// Displays a Key Frame Every dialog box for the video options. This is the same flag used in the ICCompressorChoose function.
+ ///
+ /// -
+ /// ICMF_CHOOSE_DATARATE
+ /// Displays a Data Rate dialog box for the video options. This is the same flag used in ICCompressorChoose.
+ ///
+ /// -
+ /// ICMF_CHOOSE_PREVIEW
+ ///
+ /// Displays a Preview button for the video options. This button previews the compression by using a frame from the stream. This is
+ /// the same flag used in ICCompressorChoose.
+ ///
+ ///
+ ///
+ ///
+ /// Number of streams that have their options set by the dialog box.
+ ///
+ /// Pointer to an array of stream interface pointers. The nStreams parameter indicates the number of pointers in the array.
+ ///
+ ///
+ /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. These structures hold the compression options set by the
+ /// dialog box. The nStreams parameter indicates the number of pointers in the array.
+ ///
+ /// Returns TRUE if the user pressed OK, FALSE for CANCEL, or an error otherwise.
+ ///
+ ///
+ /// This function presents a standard Compression Options dialog box using hwnd as the parent window handle. When the user is
+ /// finished selecting the compression options for each stream, the options are returned in the AVICOMPRESSOPTIONS structure in the
+ /// array referenced by plpOptions. The calling application must pass the interface pointers for the streams in the array referenced
+ /// by ppavi.
+ ///
+ /// An application must allocate memory for the AVICOMPRESSOPTIONS structures and the array of pointers to these structures.
+ /// The argument ppavi contains the address of a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avisaveoptions INT_PTR AVISaveOptions( HWND hwnd, UINT uiFlags, int
+ // nStreams, IAVIStream *ppavi, LPAVICOMPRESSOPTIONS *plpOptions );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveOptions")]
+ public static extern IntPtr AVISaveOptions(HWND hwnd, ICMF_CHOOSE uiFlags, int nStreams,
+ [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi,
+ [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] AVICOMPRESSOPTIONS[] plpOptions);
+
+ /// The AVISaveOptionsFree function frees the resources allocated by the AVISaveOptions function.
+ /// Count of the AVICOMPRESSOPTIONS structures referenced in plpOptions.
+ ///
+ /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. These structures hold the compression options set by the
+ /// dialog box. The resources allocated by AVISaveOptions for each of these structures will be freed.
+ ///
+ /// Returns AVIERR_OK.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avisaveoptionsfree HRESULT AVISaveOptionsFree( int nStreams,
+ // LPAVICOMPRESSOPTIONS *plpOptions );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveOptionsFree")]
+ public static extern HRESULT AVISaveOptionsFree(int nStreams, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] AVICOMPRESSOPTIONS[] plpOptions);
+
+ /// The AVISaveV function builds a file by combining data streams from other files or from memory.
+ /// Null-terminated string containing the name of the file to save.
+ ///
+ /// Pointer to the file handler used to write the file. The file is created by calling the AVIFileOpen function using this handler.
+ /// If a handler is not specified, a default is selected from the registry based on the file extension.
+ ///
+ ///
+ /// Pointer to a callback function used to display status information and to let the user cancel the save operation.
+ ///
+ /// Number of streams to save.
+ ///
+ /// Pointer to an array of pointers to the AVISTREAM function structures. The array uses one pointer for each stream.
+ ///
+ ///
+ /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. The array uses one pointer for each stream.
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise.
+ ///
+ ///
+ /// This function is equivalent to the AVISave function except the streams are passed in an array instead of as a variable number of arguments.
+ ///
+ ///
+ /// This function creates a file, copies stream data into the file, closes the file, and releases the resources used by the new
+ /// file. The last two parameters of this function are arrays that identify the streams to save in the file and define the
+ /// compression options of those streams.
+ ///
+ /// An application must allocate memory for the AVICOMPRESSOPTIONS structures and the array of pointers to these structures.
+ /// The argument ppavi contains the address of a pointer to an IAVIStream interface.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVISaveV 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-avisaveva HRESULT AVISaveVA( LPCSTR szFile, CLSID *pclsidHandler,
+ // AVISAVECALLBACK lpfnCallback, int nStreams, IAVIStream *ppavi, LPAVICOMPRESSOPTIONS *plpOptions );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveVA")]
+ public static extern HRESULT AVISaveV([MarshalAs(UnmanagedType.LPTStr)] string szFile, in Guid pclsidHandler, AVISAVECALLBACK lpfnCallback, int nStreams,
+ [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi,
+ [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] AVICOMPRESSOPTIONS[] plpOptions);
+
+ /// The AVISaveV function builds a file by combining data streams from other files or from memory.
+ /// Null-terminated string containing the name of the file to save.
+ ///
+ /// Pointer to the file handler used to write the file. The file is created by calling the AVIFileOpen function using this handler.
+ /// If a handler is not specified, a default is selected from the registry based on the file extension.
+ ///
+ ///
+ /// Pointer to a callback function used to display status information and to let the user cancel the save operation.
+ ///
+ /// Number of streams to save.
+ ///
+ /// Pointer to an array of pointers to the AVISTREAM function structures. The array uses one pointer for each stream.
+ ///
+ ///
+ /// Pointer to an array of pointers to AVICOMPRESSOPTIONS structures. The array uses one pointer for each stream.
+ ///
+ /// Returns AVIERR_OK if successful or an error otherwise.
+ ///
+ ///
+ /// This function is equivalent to the AVISave function except the streams are passed in an array instead of as a variable number of arguments.
+ ///
+ ///
+ /// This function creates a file, copies stream data into the file, closes the file, and releases the resources used by the new
+ /// file. The last two parameters of this function are arrays that identify the streams to save in the file and define the
+ /// compression options of those streams.
+ ///
+ /// An application must allocate memory for the AVICOMPRESSOPTIONS structures and the array of pointers to these structures.
+ /// The argument ppavi contains the address of a pointer to an IAVIStream interface.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVISaveV 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-avisaveva HRESULT AVISaveVA( LPCSTR szFile, CLSID *pclsidHandler,
+ // AVISAVECALLBACK lpfnCallback, int nStreams, IAVIStream *ppavi, LPAVICOMPRESSOPTIONS *plpOptions );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVISaveVA")]
+ public static extern HRESULT AVISaveV([MarshalAs(UnmanagedType.LPTStr)] string szFile, [In, Optional] IntPtr pclsidHandler, AVISAVECALLBACK lpfnCallback, int nStreams,
+ [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi,
+ [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] AVICOMPRESSOPTIONS[] plpOptions);
+
+ /// The AVIStreamAddRef function increments the reference count of an AVI stream.
+ /// Handle to an open AVI stream.
+ /// Returns the current reference count of the stream. This value should be used only for debugging purposes.
+ /// The argument pavi contains a pointer to an IAVIStream interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamaddref ULONG AVIStreamAddRef( IAVIStream pavi );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamAddRef")]
+ public static extern uint AVIStreamAddRef(IAVIStream pavi);
+
+ ///
+ /// The AVIStreamBeginStreaming function specifies the parameters used in streaming and lets a stream handler prepare for streaming.
+ ///
+ /// Pointer to a stream.
+ /// Starting frame for streaming.
+ /// Ending frame for streaming.
+ ///
+ /// Speed at which the file is read relative to its natural speed. Specify 1000 for the normal speed. Values less than 1000 indicate
+ /// a slower-than-normal speed; values greater than 1000 indicate a faster-than-normal speed.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreambeginstreaming HRESULT AVIStreamBeginStreaming( IAVIStream
+ // pavi, LONG lStart, LONG lEnd, LONG lRate );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamBeginStreaming")]
+ public static extern HRESULT AVIStreamBeginStreaming(IAVIStream pavi, int lStart, int lEnd, int lRate);
+
+ /// The AVIStreamCreate function creates a stream not associated with any file.
+ /// Pointer to a buffer that receives the new stream interface.
+ /// Stream-handler specific information.
+ /// Stream-handler specific information.
+ /// Pointer to the class identifier used for the stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// You should not need to call this function. Some functions, such as CreateEditableStream and AVIMakeCompressedStream, use it internally.
+ ///
+ /// The argument ppavi contains the address of a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamcreate HRESULT AVIStreamCreate( IAVIStream *ppavi, LONG
+ // lParam1, LONG lParam2, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamCreate")]
+ public static extern HRESULT AVIStreamCreate(out IAVIStream ppavi, int lParam1, int lParam2, in Guid pclsidHandler);
+
+ /// The AVIStreamCreate function creates a stream not associated with any file.
+ /// Pointer to a buffer that receives the new stream interface.
+ /// Stream-handler specific information.
+ /// Stream-handler specific information.
+ /// Pointer to the class identifier used for the stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// You should not need to call this function. Some functions, such as CreateEditableStream and AVIMakeCompressedStream, use it internally.
+ ///
+ /// The argument ppavi contains the address of a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamcreate HRESULT AVIStreamCreate( IAVIStream *ppavi, LONG
+ // lParam1, LONG lParam2, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamCreate")]
+ public static extern HRESULT AVIStreamCreate(out IAVIStream ppavi, int lParam1, int lParam2, [In, Optional] IntPtr pclsidHandler);
+
+ ///
+ /// The AVIStreamDataSize macro determines the buffer size, in bytes, needed to retrieve optional header data for a specified stream.
+ ///
+ /// Handle to an open stream.
+ /// Four-character code specifying the stream type.
+ /// Address to contain the buffer size for the optional header data.
+ /// None
+ ///
+ /// The AVIStreamDataSize macro is defined as follows:
+ ///
+ /// #define AVIStreamDataSize(pavi, fcc, plSize) \ AVIStreamReadData(pavi, fcc, NULL, plSize)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamdatasize void AVIStreamDataSize( pavi, fcc, plSize );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamDataSize")]
+ public static void AVIStreamDataSize(IAVIStream pavi, uint fcc, out int plSize)
+ {
+ int sz = 0;
+ AVIStreamReadData(pavi, fcc, default, ref sz);
+ plSize = sz;
+ }
+
+ /// The AVIStreamEnd macro calculates the sample associated with the end of a stream.
+ /// Handle to an open stream.
+ /// Returns the number if successful or -1 otherwise.
+ ///
+ ///
+ /// The sample number returned is not a valid sample number for reading data. It represents the end of the file. (The end of the
+ /// file is equal to the start of the file plus its length.)
+ ///
+ /// The AVIStreamEnd macro is defined as follows:
+ ///
+ /// #define AVIStreamEnd(pavi) \ (AVIStreamStart(pavi) + AVIStreamLength(pavi))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamend void AVIStreamEnd( pavi );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamEnd")]
+ public static int AVIStreamEnd(IAVIStream pavi) => AVIStreamStart(pavi) + AVIStreamLength(pavi);
+
+ /// The AVIStreamEndStreaming function ends streaming.
+ /// Pointer to a stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// Many stream implementations ignore this function.
+ /// The argument pavi contains a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamendstreaming HRESULT AVIStreamEndStreaming( IAVIStream
+ // pavi );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamEndStreaming")]
+ public static extern HRESULT AVIStreamEndStreaming(IAVIStream pavi);
+
+ /// The AVIStreamEndTime macro returns the time representing the end of the stream.
+ /// Handle to an open stream.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The AVIStreamEndTime macro is defined as follows:
+ ///
+ /// #define AVIStreamEndTime(pavi) \ AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamendtime void AVIStreamEndTime( pavi );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamEndTime")]
+ public static int AVIStreamEndTime(IAVIStream pavi) => AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi));
+
+ ///
+ ///
+ /// The AVIStreamFindSample function returns the position of a sample (key frame, nonempty frame, or a frame containing a
+ /// format change) relative to the specified position.
+ ///
+ /// This function supersedes the obsolete AVIStreamFindKeyFrame function.
+ ///
+ /// Handle to an open stream.
+ /// Starting frame for the search.
+ ///
+ ///
+ /// Flags that designate the type of frame to locate, the direction in the stream to search, and the type of return information. The
+ /// following flags are defined.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// FIND_ANY
+ /// Finds a nonempty frame. This flag supersedes the SEARCH_ANY flag.
+ ///
+ /// -
+ /// FIND_KEY
+ /// Finds a key frame. This flag supersedes the SEARCH_KEY flag.
+ ///
+ /// -
+ /// FIND_FORMAT
+ /// Finds a format change.
+ ///
+ /// -
+ /// FIND_NEXT
+ ///
+ /// Finds nearest sample, frame, or format change searching forward. The current sample is included in the search. Use this flag
+ /// with the FIND_ANY, FIND_KEY, or FIND_FORMAT flag. This flag supersedes the SEARCH_FORWARD flag.
+ ///
+ ///
+ /// -
+ /// FIND_PREV
+ ///
+ /// Finds nearest sample, frame, or format change searching backward. The current sample is included in the search. Use this flag
+ /// with the FIND_ANY, FIND_KEY, or FIND_FORMAT flag. This flag supersedes the SEARCH_NEAREST and SEARCH_BACKWARD flags.
+ ///
+ ///
+ /// -
+ /// FIND_FROM_START
+ ///
+ /// Finds first sample, frame, or format change beginning from the start of the stream. Use this flag with the FIND_ANY, FIND_KEY,
+ /// or FIND_FORMAT flag.
+ ///
+ ///
+ ///
+ ///
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The FIND_KEY, FIND_ANY, and FIND_FORMAT flags are mutually exclusive, as are the FIND_NEXT and FIND_PREV flags.
+ /// The argument pavi contains a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamfindsample LONG AVIStreamFindSample( IAVIStream pavi, LONG
+ // lPos, LONG lFlags );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamFindSample")]
+ public static extern int AVIStreamFindSample(IAVIStream pavi, int lPos, FINDF lFlags);
+
+ ///
+ /// The AVIStreamFormatSize macro determines the buffer size, in bytes, needed to store format information for a sample in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Position of a sample in the stream.
+ /// Address to contain the buffer size.
+ /// None
+ ///
+ /// The AVIStreamFormatSize macro is defined as follows:
+ ///
+ /// #define AVIStreamFormatSize(pavi, lPos, plSize) \ AVIStreamReadFormat(pavi, lPos, NULL, plSize)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamformatsize void AVIStreamFormatSize( pavi, lPos, plSize );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamFormatSize")]
+ public static void AVIStreamFormatSize(IAVIStream pavi, int lPos, out int plSize)
+ {
+ var sz = 0;
+ AVIStreamReadFormat(pavi, lPos, default, ref sz);
+ plSize = sz;
+ }
+
+ /// The AVIStreamGetFrame function returns the address of a decompressed video frame.
+ /// Pointer to the IGetFrame interface.
+ /// Position, in samples, within the stream of the desired frame.
+ ///
+ /// Returns a pointer to the frame data if successful or NULL otherwise. The frame data is returned as a packed DIB.
+ ///
+ /// The returned frame is valid only until the next call to this function or the AVIStreamGetFrameClose function.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamgetframe LPVOID AVIStreamGetFrame( PGETFRAME pg, LONG lPos );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamGetFrame")]
+ public static extern IntPtr AVIStreamGetFrame([In] IGetFrame pg, int lPos);
+
+ /// The AVIStreamGetFrameClose function releases resources used to decompress video frames.
+ /// Handle returned from the AVIStreamGetFrameOpen function. After calling this function, the handle is invalid.
+ /// Returns zero if successful or an error otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamgetframeclose HRESULT AVIStreamGetFrameClose( PGETFRAME pg );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamGetFrameClose")]
+ public static extern HRESULT AVIStreamGetFrameClose([In] IGetFrame pg);
+
+ /// The AVIStreamGetFrameOpen function prepares to decompress video frames from the specified video stream.
+ /// Pointer to the video stream used as the video source.
+ ///
+ /// Pointer to a structure that defines the desired video format. Specify NULL to use a default format. You can also specify
+ /// AVIGETFRAMEF_BESTDISPLAYFMT to decode the frames to the best format for your display.
+ ///
+ ///
+ ///
+ /// Returns a GetFrame object that can be used with the AVIStreamGetFrame function. If the system cannot find a decompressor
+ /// that can decompress the stream to the given format, or to any RGB format, the function returns NULL.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamgetframeopen PGETFRAME AVIStreamGetFrameOpen( IAVIStream
+ // pavi, LPBITMAPINFOHEADER lpbiWanted );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamGetFrameOpen")]
+ [return: MarshalAs(UnmanagedType.Interface)]
+ public static extern IGetFrame AVIStreamGetFrameOpen(IAVIStream pavi, in Gdi32.BITMAPINFOHEADER lpbiWanted);
+
+ /// The AVIStreamGetFrameOpen function prepares to decompress video frames from the specified video stream.
+ /// Pointer to the video stream used as the video source.
+ ///
+ /// Pointer to a structure that defines the desired video format. Specify NULL to use a default format. You can also specify
+ /// AVIGETFRAMEF_BESTDISPLAYFMT to decode the frames to the best format for your display.
+ ///
+ ///
+ ///
+ /// Returns a GetFrame object that can be used with the AVIStreamGetFrame function. If the system cannot find a decompressor
+ /// that can decompress the stream to the given format, or to any RGB format, the function returns NULL.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamgetframeopen PGETFRAME AVIStreamGetFrameOpen( IAVIStream
+ // pavi, LPBITMAPINFOHEADER lpbiWanted );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamGetFrameOpen")]
+ [return: MarshalAs(UnmanagedType.Interface)]
+ public static extern IGetFrame AVIStreamGetFrameOpen(IAVIStream pavi, [In, Optional] IntPtr lpbiWanted);
+
+ /// The AVIStreamInfo function obtains stream header information.
+ /// Handle to an open stream.
+ /// Pointer to a structure to contain the stream information.
+ /// Size, in bytes, of the structure used for psi.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVISTREAMINFO 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-avistreaminfoa HRESULT AVIStreamInfoA( IAVIStream pavi,
+ // LPAVISTREAMINFOA psi, LONG lSize );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamInfoA")]
+ public static extern HRESULT AVIStreamInfo(IAVIStream pavi, out AVISTREAMINFO psi, int lSize);
+
+ /// The AVIStreamIsKeyFrame macro indicates whether a sample in a specified stream is a key frame.
+ /// Handle to an open stream.
+ /// Position to search in the stream.
+ /// if a sample in a specified stream is a key frame.
+ ///
+ /// The AVIStreamIsKeyFrame macro is defined as follows:
+ ///
+ /// #define AVIStreamIsKeyFrame(pavi, lPos) \ (AVIStreamNearestKeyFrame(pavi, lPos) == 1)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamiskeyframe void AVIStreamIsKeyFrame( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamIsKeyFrame")]
+ public static bool AVIStreamIsKeyFrame(IAVIStream pavi, int lPos) => AVIStreamNearestKeyFrame(pavi, lPos) == 1;
+
+ /// The AVIStreamLength function returns the length of the stream.
+ /// Handle to an open stream.
+ ///
+ /// Returns the stream's length, in samples, if successful or -1 otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamlength LONG AVIStreamLength( IAVIStream pavi );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamLength")]
+ public static extern int AVIStreamLength(IAVIStream pavi);
+
+ /// The AVIStreamLengthTime macro returns the length of a stream in time.
+ /// Handle to an open stream.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The AVIStreamLengthTime macro is defined as follows:
+ ///
+ /// #define AVIStreamLengthTime(pavi) \ AVIStreamSampleToTime(pavi, AVIStreamLength(pavi))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamlengthtime void AVIStreamLengthTime( pavi );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamLengthTime")]
+ public static int AVIStreamLengthTime(IAVIStream pavi) => AVIStreamSampleToTime(pavi, AVIStreamLength(pavi));
+
+ /// The AVIStreamNearestKeyFrame macro locates the key frame at or preceding a specified position in a stream.
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The AVIStreamNearestKeyFrame macro is defined as follows:
+ ///
+ /// #define AVIStreamNearestKeyFrame(pavi, lPos) \ AVIStreamFindSample(pavi, lPos , FIND_PREV | FIND_KEY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnearestkeyframe void AVIStreamNearestKeyFrame( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNearestKeyFrame")]
+ public static int AVIStreamNearestKeyFrame(IAVIStream pavi, int lPos) => AVIStreamFindSample(pavi, lPos, FINDF.FIND_PREV | FINDF.FIND_KEY);
+
+ ///
+ /// The AVIStreamNearestKeyFrameTime macro determines the time corresponding to the beginning of the key frame nearest (at or
+ /// preceding) a specified time in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Starting time, in milliseconds, to search in the stream.
+ /// Returns the converted time if successful or -1 otherwise.
+ ///
+ /// The AVIStreamNearestKeyFrameTime macro is defined as follows:
+ ///
+ /// #define AVIStreamNearestKeyFrameTime(pavi, lTime) \ AVIStreamSampleToTime(pavi, AVIStreamNearestKeyFrame(pavi, AVIStreamTimeToSample(pavi, lTime)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnearestkeyframetime void AVIStreamNearestKeyFrameTime(
+ // pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNearestKeyFrameTime")]
+ public static int AVIStreamNearestKeyFrameTime(IAVIStream pavi, int lTime) => AVIStreamSampleToTime(pavi, AVIStreamNearestKeyFrame(pavi, AVIStreamTimeToSample(pavi, lTime)));
+
+ ///
+ /// The AVIStreamNearestSample macro locates the nearest nonempty sample at or preceding a specified position in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The AVIStreamNearestSample macro is defined as follows:
+ ///
+ /// #define AVIStreamNearestSample(pavi, lPos) \ AVIStreamFindSample(pavi, lPos, FIND_PREV | FIND_ANY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnearestsample void AVIStreamNearestSample( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNearestSample")]
+ public static int AVIStreamNearestSample(IAVIStream pavi, int lPos) => AVIStreamFindSample(pavi, lPos, FINDF.FIND_PREV | FINDF.FIND_ANY);
+
+ ///
+ /// The AVIStreamNearestSampleTime macro determines the time corresponding to the beginning of a sample that is nearest to a
+ /// specified time in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Starting time, in milliseconds, to search in the stream.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The AVIStreamNearestSampleTime macro is defined as follows:
+ ///
+ /// #define AVIStreamNearestSampleTime(pavi, lTime) \ AVIStreamSampleToTime(pavi, AVIStreamNearestSample(pavi, AVIStreamTimeToSample(pavi, lTime)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnearestsampletime void AVIStreamNearestSampleTime( pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNearestSampleTime")]
+ public static int AVIStreamNearestSampleTime(IAVIStream pavi, int lTime) => AVIStreamSampleToTime(pavi, AVIStreamNearestSample(pavi, AVIStreamTimeToSample(pavi, lTime)));
+
+ /// The AVIStreamNextKeyFrame macro locates the next key frame following a specified position in a stream.
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The search performed by this macro does not include the frame at the specified position.
+ /// The AVIStreamNextKeyFrame macro is defined as follows:
+ ///
+ /// #define AVIStreamNextKeyFrame(pavi, lPos) \ AVIStreamFindSample(pavi, lPos + 1, FIND_NEXT | FIND_KEY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnextkeyframe void AVIStreamNextKeyFrame( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNextKeyFrame")]
+ public static int AVIStreamNextKeyFrame(IAVIStream pavi, int lPos) => AVIStreamFindSample(pavi, lPos + 1, FINDF.FIND_NEXT | FINDF.FIND_KEY);
+
+ ///
+ /// The AVIStreamNextKeyFrameTime macro returns the time of the next key frame in the stream, starting at a given time.
+ ///
+ /// Handle to an open stream.
+ /// Position in the stream to begin searching.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The search performed by this macro includes the frame that corresponds to the specified time.
+ /// The AVIStreamNextKeyFrameTime macro is defined as follows:
+ ///
+ /// #define AVIStreamNextKeyFrameTime(pavi, time) \ AVIStreamSampleToTime(pavi, \ AVIStreamNextKeyFrame(pavi, \ AVIStreamTimeToSample(pavi, time)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnextkeyframetime void AVIStreamNextKeyFrameTime( pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNextKeyFrameTime")]
+ public static int AVIStreamNextKeyFrameTime(IAVIStream pavi, int t) => AVIStreamSampleToTime(pavi, AVIStreamNextKeyFrame(pavi, AVIStreamTimeToSample(pavi, t)));
+
+ /// The AVIStreamNextSample macro locates the next nonempty sample from a specified position in a stream.
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The sample position returned does not include the sample specified by lPos.
+ /// The AVIStreamNextSample macro is defined as follows:
+ ///
+ /// #define AVIStreamNextSample(pavi, lPos) \ AVIStreamFindSample(pavi, lPos + 1, FIND_NEXT | FIND_ANY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnextsample void AVIStreamNextSample( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNextSample")]
+ public static int AVIStreamNextSample(IAVIStream pavi, int l) => AVIStreamFindSample(pavi, l + 1, FINDF.FIND_NEXT | FINDF.FIND_ANY);
+
+ ///
+ /// The AVIStreamNextSampleTime macro returns the time that a sample changes to the next sample in the stream. This macro
+ /// finds the next interesting time in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Position information of the sample in the stream.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The AVIStreamNextSampleTime macro is defined as follows:
+ ///
+ /// #define AVIStreamNextSampleTime(pavi, time) \ AVIStreamSampleToTime(pavi, \ AVIStreamNextSample(pavi, \ AVIStreamTimeToSample(pavi, t)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamnextsampletime void AVIStreamNextSampleTime( pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamNextSampleTime")]
+ public static int AVIStreamNextSampleTime(IAVIStream pavi, int t) => AVIStreamSampleToTime(pavi, AVIStreamNextSample(pavi, AVIStreamTimeToSample(pavi, t)));
+
+ /// The AVIStreamOpenFromFile function opens a single stream from a file.
+ /// Pointer to a buffer that receives the new stream handle.
+ /// Null-terminated string containing the name of the file to open.
+ ///
+ ///
+ /// Four-character code indicating the type of stream to be opened. Zero indicates that any stream can be opened. The following
+ /// definitions apply to the data commonly found in AVI streams:
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// streamtypeAUDIO
+ /// Indicates an audio stream.
+ ///
+ /// -
+ /// streamtypeMIDI
+ /// Indicates a MIDI stream.
+ ///
+ /// -
+ /// streamtypeTEXT
+ /// Indicates a text stream.
+ ///
+ /// -
+ /// streamtypeVIDEO
+ /// Indicates a video stream.
+ ///
+ ///
+ ///
+ ///
+ /// Stream of the type specified in fccType to access. This parameter is zero-based; use zero to specify the first occurrence.
+ ///
+ ///
+ /// Access mode to use when opening the file. This function can open only existing streams, so the OF_CREATE mode flag cannot be
+ /// used. For more information about the available flags for the mode parameter, see the OpenFile function.
+ ///
+ ///
+ /// Pointer to a class identifier of the handler you want to use. If the value is NULL, the system chooses one from the
+ /// registry based on the file extension or the file RIFF type.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// This function calls the AVIFileOpen, AVIFileGetStream, and AVIFileRelease functions.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVIStreamOpenFromFile 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-avistreamopenfromfilea HRESULT AVIStreamOpenFromFileA( IAVIStream
+ // *ppavi, LPCSTR szFile, DWORD fccType, LONG lParam, UINT mode, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamOpenFromFileA")]
+ public static extern HRESULT AVIStreamOpenFromFile(out IAVIStream ppavi, [MarshalAs(UnmanagedType.LPTStr)] string szFile, uint fccType,
+ int lParam, Kernel32.OpenFileAction mode, in Guid pclsidHandler);
+
+ /// The AVIStreamOpenFromFile function opens a single stream from a file.
+ /// Pointer to a buffer that receives the new stream handle.
+ /// Null-terminated string containing the name of the file to open.
+ ///
+ ///
+ /// Four-character code indicating the type of stream to be opened. Zero indicates that any stream can be opened. The following
+ /// definitions apply to the data commonly found in AVI streams:
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// streamtypeAUDIO
+ /// Indicates an audio stream.
+ ///
+ /// -
+ /// streamtypeMIDI
+ /// Indicates a MIDI stream.
+ ///
+ /// -
+ /// streamtypeTEXT
+ /// Indicates a text stream.
+ ///
+ /// -
+ /// streamtypeVIDEO
+ /// Indicates a video stream.
+ ///
+ ///
+ ///
+ ///
+ /// Stream of the type specified in fccType to access. This parameter is zero-based; use zero to specify the first occurrence.
+ ///
+ ///
+ /// Access mode to use when opening the file. This function can open only existing streams, so the OF_CREATE mode flag cannot be
+ /// used. For more information about the available flags for the mode parameter, see the OpenFile function.
+ ///
+ ///
+ /// Pointer to a class identifier of the handler you want to use. If the value is NULL, the system chooses one from the
+ /// registry based on the file extension or the file RIFF type.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// This function calls the AVIFileOpen, AVIFileGetStream, and AVIFileRelease functions.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVIStreamOpenFromFile 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-avistreamopenfromfilea HRESULT AVIStreamOpenFromFileA( IAVIStream
+ // *ppavi, LPCSTR szFile, DWORD fccType, LONG lParam, UINT mode, CLSID *pclsidHandler );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamOpenFromFileA")]
+ public static extern HRESULT AVIStreamOpenFromFile(out IAVIStream ppavi, [MarshalAs(UnmanagedType.LPTStr)] string szFile, uint fccType,
+ int lParam, Kernel32.OpenFileAction mode, [In, Optional] IntPtr pclsidHandler);
+
+ /// The AVIStreamPrevKeyFrame macro locates the key frame that precedes a specified position in a stream.
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// Returns the position of the frame found or -1 if the search is unsuccessful.
+ ///
+ /// The search performed by this macro does not include the frame at the specified position.
+ /// The AVIStreamPrevKeyFrame macro is defined as follows:
+ ///
+ /// #define AVIStreamPrevKeyFrame(pavi, lPos) \ AVIStreamFindSample(pavi, lPos - 1, FIND_PREV | FIND_KEY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamprevkeyframe void AVIStreamPrevKeyFrame( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamPrevKeyFrame")]
+ public static int AVIStreamPrevKeyFrame(IAVIStream pavi, int l) => AVIStreamFindSample(pavi, l - 1, FINDF.FIND_PREV | FINDF.FIND_KEY);
+
+ ///
+ /// The AVIStreamPrevKeyFrameTime macro returns the time of the previous key frame in the stream, starting at a given time.
+ ///
+ /// Handle to an open stream.
+ /// Position in the stream to begin searching.
+ /// Returns the converted time if successful or −1 otherwise.
+ ///
+ /// The search performed by this macro includes the frame that corresponds to the specified time.
+ /// The AVIStreamPrevKeyFrameTime macro is defined as follows:
+ ///
+ /// #define AVIStreamPrevKeyFrameTime(pavi, time) \ AVIStreamSampleToTime(pavi, AVIStreamPrevKeyFrame(pavi, AVIStreamTimeToSample(pavi, time)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamprevkeyframetime void AVIStreamPrevKeyFrameTime( pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamPrevKeyFrameTime")]
+ public static int AVIStreamPrevKeyFrameTime(IAVIStream pavi, int t) => AVIStreamSampleToTime(pavi, AVIStreamPrevKeyFrame(pavi, AVIStreamTimeToSample(pavi, t)));
+
+ ///
+ /// The AVIStreamPrevSample macro locates the nearest nonempty sample that precedes a specified position in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Starting position to search in the stream.
+ /// None
+ ///
+ /// The sample position returned does not include the sample specified by lPos.
+ /// The AVIStreamPrevSample macro is defined as follows:
+ ///
+ /// #define AVIStreamPrevSample(pavi, lPos) \ AVIStreamFindSample(pavi, lPos - 1, FIND_PREV | FIND_ANY)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamprevsample void AVIStreamPrevSample( pavi, l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamPrevSample")]
+ public static int AVIStreamPrevSample(IAVIStream pavi, int l) => AVIStreamFindSample(pavi, l - 1, FINDF.FIND_PREV | FINDF.FIND_ANY);
+
+ ///
+ /// The AVIStreamPrevSampleTime macro determines the time of the nearest nonempty sample that precedes a specified time in a stream.
+ ///
+ /// Handle to an open stream.
+ /// Position information of the sample in the stream.
+ /// None
+ ///
+ /// The AVIStreamPrevSampleTime macro is defined as follows:
+ ///
+ /// #define AVIStreamPrevSampleTime(pavi, time) \ AVIStreamSampleToTime(pavi, \ AVIStreamPrevSample(pavi, \ AVIStreamTimeToSample(pavi, t)))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamprevsampletime void AVIStreamPrevSampleTime( pavi, t );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamPrevSampleTime")]
+ public static int AVIStreamPrevSampleTime(IAVIStream pavi, int t) => AVIStreamSampleToTime(pavi, AVIStreamPrevSample(pavi, AVIStreamTimeToSample(pavi, t)));
+
+ /// The AVIStreamRead function reads audio, video or other data from a stream according to the stream type.
+ /// Handle to an open stream.
+ /// First sample to read.
+ ///
+ /// Number of samples to read. You can also specify the value AVISTREAMREAD_CONVENIENT to let the stream handler determine the
+ /// number of samples to read.
+ ///
+ /// Pointer to a buffer to contain the data.
+ /// Size, in bytes, of the buffer pointed to by lpBuffer.
+ ///
+ /// Pointer to a buffer that receives the number of bytes of data written in the buffer referenced by lpBuffer. This value can be NULL.
+ ///
+ ///
+ /// Pointer to a buffer that receives the number of samples written in the buffer referenced by lpBuffer. This value can be NULL.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// AVIERR_BUFFERTOOSMALL
+ /// The buffer size cbBuffer was smaller than a single sample of data.
+ ///
+ /// -
+ /// AVIERR_MEMORY
+ /// There was not enough memory to complete the read operation.
+ ///
+ /// -
+ /// AVIERR_FILEREAD
+ /// A disk error occurred while reading the file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If lpBuffer is NULL, this function does not read any data; it returns information about the size of data that would be read.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamread HRESULT AVIStreamRead( IAVIStream pavi, LONG lStart,
+ // LONG lSamples, LPVOID lpBuffer, LONG cbBuffer, LONG *plBytes, LONG *plSamples );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamRead")]
+ public static extern HRESULT AVIStreamRead(IAVIStream pavi, int lStart, int lSamples, [Out, Optional] IntPtr lpBuffer, int cbBuffer, out int plBytes, out int plSamples);
+
+ /// The AVIStreamReadData function reads optional header data from a stream.
+ /// Handle to an open stream.
+ /// Four-character code identifying the data.
+ /// Pointer to the buffer to contain the optional header data.
+ ///
+ /// Pointer to the location that specifies the buffer size used for lpData. If the read is successful, AVIFile changes this value to
+ /// indicate the amount of data written into the buffer for lpData.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. The return value AVIERR_NODATA indicates the system could not find any data
+ /// with the specified chunk identifier.
+ ///
+ ///
+ ///
+ /// This function retrieves only optional header information from the stream. This information is custom and does not have a set format.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamreaddata HRESULT AVIStreamReadData( IAVIStream pavi, DWORD
+ // fcc, LPVOID lp, LONG *lpcb );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamReadData")]
+ public static extern HRESULT AVIStreamReadData(IAVIStream pavi, uint fcc, [Out, Optional] IntPtr lp, ref int lpcb);
+
+ /// The AVIStreamReadFormat function reads the stream format data.
+ /// Handle to an open stream.
+ /// Position in the stream used to obtain the format data.
+ /// Pointer to a buffer to contain the format data.
+ ///
+ /// Pointer to a location indicating the size of the memory block referenced by lpFormat. On return, the value is changed to
+ /// indicate the amount of data read. If lpFormat is NULL, this parameter can be used to obtain the amount of memory needed
+ /// to return the format.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ ///
+ /// Standard video stream handlers provide format information in a BITMAPINFOHEADER structure. Standard audio stream handlers
+ /// provide format information in a PCMWAVEFORMAT structure. Other data streams can use other structures that describe the stream data.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamreadformat HRESULT AVIStreamReadFormat( IAVIStream pavi,
+ // LONG lPos, LPVOID lpFormat, LONG *lpcbFormat );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamReadFormat")]
+ public static extern HRESULT AVIStreamReadFormat(IAVIStream pavi, int lPos, IntPtr lpFormat, ref int lpcbFormat);
+
+ ///
+ ///
+ /// The AVIStreamRelease function decrements the reference count of an AVI stream interface handle, and closes the stream if
+ /// the count reaches zero.
+ ///
+ /// This function supersedes the obsolete AVIStreamClose function.
+ ///
+ /// Handle to an open stream.
+ ///
+ /// Returns the current reference count of the stream. This value should be used only for debugging purposes.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamrelease ULONG AVIStreamRelease( IAVIStream pavi );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamRelease")]
+ public static extern uint AVIStreamRelease(IAVIStream pavi);
+
+ ///
+ /// The AVIStreamRelease macro determines the size of the buffer needed to store one sample of information from a stream. The size
+ /// corresponds to the sample at the position specified by lPos.
+ ///
+ /// Handle to an open stream.
+ /// Position of a sample in the stream.
+ /// Address to contain the buffer size.
+ /// None
+ ///
+ /// The AVIStreamSampleSize macro is defined as follows:
+ ///
+ /// #define AVIStreamSampleSize(pavi, lPos, plSize) \ AVIStreamRead(pavi, lPos, 1, NULL, 0, plSize, NULL)
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamsamplesize void AVIStreamSampleSize( pavi, lPos, plSize );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamSampleSize")]
+ public static HRESULT AVIStreamSampleSize(IAVIStream pavi, int lPos, out int plSize) => AVIStreamRead(pavi, lPos, 1, default, 0, out plSize, out _);
+
+ ///
+ /// The AVIStreamSampleToSample macro returns the sample in a stream that occurs at the same time as a sample that occurs in
+ /// a second stream.
+ ///
+ /// Handle to an open stream that contains the sample that is returned.
+ /// Handle to a second stream that contains the reference sample.
+ /// Position information of the sample in the stream referenced by pavi2.
+ /// Returns the converted time if successful or -1 otherwise.
+ ///
+ /// The AVIStreamSampleToSample macro is defined as follows:
+ ///
+ /// #define AVIStreamSampleToSample(pavi1, pavi2, lsample) \ AVIStreamTimeToSample(pavi1, AVIStreamSampleToTime \ (pavi2, lsample))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamsampletosample void AVIStreamSampleToSample( pavi1, pavi2,
+ // l );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamSampleToSample")]
+ public static int AVIStreamSampleToSample(IAVIStream pavi1, IAVIStream pavi2, int l) => AVIStreamTimeToSample(pavi1, AVIStreamSampleToTime(pavi2, l));
+
+ /// The AVIStreamSampleToTime function converts a stream position from samples to milliseconds.
+ /// Handle to an open stream.
+ ///
+ /// Position information. A sample can correspond to blocks of audio, a video frame, or other format, depending on the stream type.
+ ///
+ /// Returns the converted time if successful or −1 otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamsampletotime LONG AVIStreamSampleToTime( IAVIStream pavi,
+ // LONG lSample );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamSampleToTime")]
+ public static extern int AVIStreamSampleToTime(IAVIStream pavi, int lSample);
+
+ /// The AVIStreamSetFormat function sets the format of a stream at the specified position.
+ /// Handle to an open stream.
+ /// Position in the stream to receive the format.
+ /// Pointer to a structure containing the new format.
+ /// Size, in bytes, of the block of memory referenced by lpFormat.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// The handler for writing AVI files does not accept format changes. Besides setting the initial format for a stream, only changes
+ /// in the palette of a video stream are allowed in an AVI file. The palette change must occur after any frames already written to
+ /// the AVI file. Other handlers might impose different restrictions.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamsetformat HRESULT AVIStreamSetFormat( IAVIStream pavi,
+ // LONG lPos, LPVOID lpFormat, LONG cbFormat );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamSetFormat")]
+ public static extern HRESULT AVIStreamSetFormat(IAVIStream pavi, int lPos, [In] IntPtr lpFormat, int cbFormat);
+
+ /// The AVIStreamStart function returns the starting sample number for the stream.
+ /// Handle to an open stream.
+ /// Returns the number if successful or -1 otherwise.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamstart LONG AVIStreamStart( IAVIStream pavi );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamStart")]
+ public static extern int AVIStreamStart(IAVIStream pavi);
+
+ /// The AVIStreamStartTime macro returns the starting time of a stream's first sample.
+ /// Handle to an open stream.
+ /// None
+ ///
+ /// The AVIStreamStartTime macro is defined as follows:
+ ///
+ /// #define AVIStreamStartTime(pavi) \ AVIStreamSampleToTime(pavi, AVIStreamStart(pavi))
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamstarttime void AVIStreamStartTime( pavi );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamStartTime")]
+ public static int AVIStreamStartTime(IAVIStream pavi) => AVIStreamSampleToTime(pavi, AVIStreamStart(pavi));
+
+ /// The AVIStreamTimeToSample function converts from milliseconds to samples.
+ /// Handle to an open stream.
+ /// Time, expressed in milliseconds.
+ /// Returns the converted time if successful or -1 otherwise.
+ ///
+ ///
+ /// Samples typically correspond to audio samples or video frames. Other stream types might support different formats than these.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamtimetosample LONG AVIStreamTimeToSample( IAVIStream pavi,
+ // LONG lTime );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamTimeToSample")]
+ public static extern int AVIStreamTimeToSample(IAVIStream pavi, int lTime);
+
+ /// The AVIStreamWrite function writes data to a stream.
+ /// Handle to an open stream.
+ /// First sample to write.
+ /// Number of samples to write.
+ /// Pointer to a buffer containing the data to write.
+ /// Size of the buffer referenced by lpBuffer.
+ ///
+ /// Flag associated with this data. The following flag is defined:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// AVIIF_KEYFRAME
+ /// Indicates this data does not rely on preceding data in the file.
+ ///
+ ///
+ ///
+ /// Pointer to a buffer that receives the number of samples written. This can be set to NULL.
+ /// Pointer to a buffer that receives the number of bytes written. This can be set to NULL.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// The default AVI file handler supports writing only at the end of a stream. The "WAVE" file handler supports writing anywhere.
+ /// This function overwrites existing data, rather than inserting new data.
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamwrite HRESULT AVIStreamWrite( IAVIStream pavi, LONG
+ // lStart, LONG lSamples, LPVOID lpBuffer, LONG cbBuffer, DWORD dwFlags, LONG *plSampWritten, LONG *plBytesWritten );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamWrite")]
+ public static extern HRESULT AVIStreamWrite([In] IAVIStream pavi, int lStart, int lSamples, [In] IntPtr lpBuffer, int cbBuffer, AVIIF dwFlags, out int plSampWritten, out int plBytesWritten);
+
+ /// The AVIStreamWriteData function writes optional header information to the stream.
+ /// Handle to an open stream.
+ /// Four-character code identifying the data.
+ /// Pointer to a buffer containing the data to write.
+ /// Number of bytes of data to write into the stream.
+ ///
+ /// Returns zero if successful or an error otherwise. The return value AVIERR_READONLY indicates the file was opened without write access.
+ ///
+ ///
+ ///
+ /// Use the AVIStreamWrite function to write the multimedia content of the stream. Use AVIFileWriteData to write data that applies
+ /// to an entire file.
+ ///
+ /// The argument pavi is a pointer to an IAVIStream interface.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-avistreamwritedata HRESULT AVIStreamWriteData( IAVIStream pavi,
+ // DWORD fcc, LPVOID lp, LONG cb );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.AVIStreamWriteData")]
+ public static extern HRESULT AVIStreamWriteData(IAVIStream pavi, uint fcc, [In] IntPtr lp, int cb);
+
+ /// Macro to make a TWOCC out of two characters
+ /// The first character.
+ /// The second character.
+ /// A TWOCC value.
+ public static ushort aviTWOCC(char ch0, char ch1) => (ushort)((byte)ch0 | ((byte)ch1 << 8));
+
+ ///
+ /// The CreateEditableStream function creates an editable stream. Use this function before using other stream editing functions.
+ ///
+ /// Pointer to a buffer that receives the new stream handle.
+ ///
+ /// Handle to the stream supplying data for the new stream. Specify NULL to create an empty editable string that you can copy
+ /// and paste data into.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// The stream pointer returned in ppsEditable must be used as the source stream in the other stream editing functions.
+ ///
+ /// Internally, this function creates tables to keep track of changes to a stream. The original stream is never changed by the
+ /// stream editing functions. The stream pointer created by this function can be used in any AVIFile function that accepts stream
+ /// pointers. You can use this function on the same stream multiple times. A copy of a stream is not affected by changes in another copy.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-createeditablestream HRESULT CreateEditableStream( PAVISTREAM
+ // *ppsEditable, PAVISTREAM psSource );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.CreateEditableStream")]
+ public static extern HRESULT CreateEditableStream(out IAVIStream ppsEditable, [In] IAVIStream psSource);
+
+ /// The EditStreamClone function creates a duplicate editable stream.
+ /// Handle to an editable stream that will be copied.
+ /// Pointer to a buffer that receives the new stream handle.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// The editable stream that is being cloned must have been created by the CreateEditableStream function or one of the stream
+ /// editing functions.
+ ///
+ /// The new stream can be treated as any other AVI stream.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-editstreamclone HRESULT EditStreamClone( PAVISTREAM pavi,
+ // PAVISTREAM *ppResult );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamClone")]
+ public static extern HRESULT EditStreamClone([In] IAVIStream pavi, out IAVIStream ppResult);
+
+ /// The EditStreamCopy function copies an editable stream (or a portion of it) into a temporary stream.
+ /// Handle to the stream being copied.
+ /// Starting position within the stream being copied. The starting position is returned.
+ /// Amount of data to copy from the stream referenced by pavi. The length of the copied data is returned.
+ /// Pointer to a buffer that receives the handle created for the new stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// The stream that is copied must be created by the CreateEditableStream function or one of the stream editing functions.
+ /// The temporary stream can be treated as any other AVI stream.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-editstreamcopy HRESULT EditStreamCopy( PAVISTREAM pavi, LONG
+ // *plStart, LONG *plLength, PAVISTREAM *ppResult );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamCopy")]
+ public static extern HRESULT EditStreamCopy([In] IAVIStream pavi, ref int plStart, ref int plLength, out IAVIStream ppResult);
+
+ ///
+ /// The EditStreamCut function deletes all or part of an editable stream and creates a temporary editable stream from the
+ /// deleted portion of the stream.
+ ///
+ /// Handle to the stream being edited.
+ /// Starting position of the data to cut from the stream referenced by pavi.
+ /// Amount of data to cut from the stream referenced by pavi.
+ /// Pointer to the handle created for the new stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// The stream being edited must have been created by the CreateEditableStream function or one of the stream editing functions.
+ ///
+ ///
+ /// The temporary stream is an editable stream and can be treated as any other AVI stream. An application must release the temporary
+ /// stream to free the resources associated with it.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-editstreamcut HRESULT EditStreamCut( PAVISTREAM pavi, LONG
+ // *plStart, LONG *plLength, PAVISTREAM *ppResult );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamCut")]
+ public static extern HRESULT EditStreamCut([In] IAVIStream pavi, ref int plStart, ref int plLength, out IAVIStream ppResult);
+
+ ///
+ /// The EditStreamPaste function copies a stream (or a portion of it) from one stream and pastes it within another stream at
+ /// a specified location.
+ ///
+ /// Handle to an editable stream that will receive the copied stream data.
+ /// Starting position to paste the data within the destination stream (referenced by pavi).
+ /// Pointer to a buffer that receives the amount of data pasted in the stream.
+ /// Handle to a stream supplying the data to paste. This stream does not need to be an editable stream.
+ /// Starting position of the data to copy within the source stream.
+ ///
+ /// Amount of data to copy from the source stream. If lLength is -1, the entire stream referenced by pstream is pasted in the other stream.
+ ///
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// The stream referenced by pavi must have been created by the CreateEditableStream function or one of the stream editing functions.
+ ///
+ ///
+ /// This function inserts data into the specified stream as a continuous block of data. It opens the specified data stream at the
+ /// insertion point, pastes the specified stream segment at the insertion point, and appends the stream segment that trails the
+ /// insertion point to the end of pasted segment.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-editstreampaste HRESULT EditStreamPaste( PAVISTREAM pavi, LONG
+ // *plPos, LONG *plLength, PAVISTREAM pstream, LONG lStart, LONG lEnd );
+ [DllImport(Lib_Avifil32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamPaste")]
+ public static extern HRESULT EditStreamPaste([In] IAVIStream pavi, ref int plPos, ref int plLength, [In] IAVIStream pstream, int lStart, int lEnd);
+
+ /// The EditStreamSetInfo function changes characteristics of an editable stream.
+ /// Handle to an open stream.
+ /// Pointer to an AVISTREAMINFO structure containing new information.
+ /// Size, in bytes, of the structure pointed to by lpInfo.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// You must supply information for the entire AVISTREAMINFO structure, including the members you will not use. You can use the
+ /// AVIStreamInfo function to initialize the structure and then update selected members with your data.
+ ///
+ /// This function does not change the following members:
+ ///
+ /// -
+ /// dwCaps
+ ///
+ /// -
+ /// dwEditCount
+ ///
+ /// -
+ /// dwFlags
+ ///
+ /// -
+ /// dwInitialFrames
+ ///
+ /// -
+ /// dwLength
+ ///
+ /// -
+ /// dwSampleSize
+ ///
+ /// -
+ /// dwSuggestedBufferSize
+ ///
+ /// -
+ /// fccHandler
+ ///
+ /// -
+ /// fccType
+ ///
+ ///
+ /// The function changes the following members:
+ ///
+ /// -
+ /// dwRate
+ ///
+ /// -
+ /// dwQuality
+ ///
+ /// -
+ /// dwScale
+ ///
+ /// -
+ /// dwStart
+ ///
+ /// -
+ /// rcFrame
+ ///
+ /// -
+ /// szName
+ ///
+ /// -
+ /// wLanguage
+ ///
+ /// -
+ /// wPriority
+ ///
+ ///
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines EditStreamSetInfo 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-editstreamsetinfoa HRESULT EditStreamSetInfoA( PAVISTREAM pavi,
+ // LPAVISTREAMINFOA lpInfo, LONG cbInfo );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamSetInfoA")]
+ public static extern HRESULT EditStreamSetInfo([In] IAVIStream pavi, in AVISTREAMINFO lpInfo, int cbInfo);
+
+ /// The EditStreamSetName function assigns a descriptive string to a stream.
+ /// Handle to an open stream.
+ /// Null-terminated string containing the description of the stream.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// This function updates the szName member of the AVISTREAMINFO structure.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines EditStreamSetName 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-editstreamsetnamea HRESULT EditStreamSetNameA( PAVISTREAM pavi,
+ // LPCSTR lpszName );
+ [DllImport(Lib_Avifil32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.EditStreamSetNameA")]
+ public static extern HRESULT EditStreamSetName([In] IAVIStream pavi, [MarshalAs(UnmanagedType.LPTStr)] string lpszName);
+
+ ///
+ /// The AVICOMPRESSOPTIONS structure contains information about a stream and how it is compressed and saved. This structure
+ /// passes data to the AVIMakeCompressedStream function (or the AVISave function, which uses AVIMakeCompressedStream).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-avicompressoptions typedef struct { DWORD fccType; DWORD
+ // fccHandler; DWORD dwKeyFrameEvery; DWORD dwQuality; DWORD dwBytesPerSecond; DWORD dwFlags; LPVOID lpFormat; DWORD cbFormat;
+ // LPVOID lpParms; DWORD cbParms; DWORD dwInterleaveEvery; } AVICOMPRESSOPTIONS, *LPAVICOMPRESSOPTIONS;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_17")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct AVICOMPRESSOPTIONS
+ {
+ ///
+ ///
+ /// Four-character code indicating the stream type. The following constants have been defined for the data commonly found in AVI streams:
+ ///
+ ///
+ ///
+ /// Constant
+ /// Description
+ ///
+ /// -
+ /// streamtypeAUDIO
+ /// Indicates an audio stream.
+ ///
+ /// -
+ /// streamtypeMIDI
+ /// Indicates a MIDI stream.
+ ///
+ /// -
+ /// streamtypeTEXT
+ /// Indicates a text stream.
+ ///
+ /// -
+ /// streamtypeVIDEO
+ /// Indicates a video stream.
+ ///
+ ///
+ ///
+ public uint fccType;
+
+ ///
+ /// Four-character code for the compressor handler that will compress this video stream when it is saved (for example,
+ /// mmioFOURCC ('M','S','V','C')). This member is not used for audio streams.
+ ///
+ public uint fccHandler;
+
+ ///
+ /// Maximum period between video key frames. This member is used only if the AVICOMPRESSF_KEYFRAMES flag is set; otherwise every
+ /// video frame is a key frame.
+ ///
+ public uint dwKeyFrameEvery;
+
+ /// Quality value passed to a video compressor. This member is not used for an audio compressor.
+ public uint dwQuality;
+
+ /// Video compressor data rate. This member is used only if the AVICOMPRESSF_DATARATE flag is set.
+ public uint dwBytesPerSecond;
+
+ ///
+ /// Flags used for compression. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AVICOMPRESSF_DATARATE
+ /// Compresses this video stream using the data rate specified in dwBytesPerSecond.
+ ///
+ /// -
+ /// AVICOMPRESSF_INTERLEAVE
+ /// Interleaves this stream every dwInterleaveEvery frames with respect to the first stream.
+ ///
+ /// -
+ /// AVICOMPRESSF_KEYFRAMES
+ ///
+ /// Saves this video stream with key frames at least every dwKeyFrameEvery frames. By default, every frame will be a key frame.
+ ///
+ ///
+ /// -
+ /// AVICOMPRESSF_VALID
+ ///
+ /// Uses the data in this structure to set the default compression values for AVISaveOptions. If an empty structure is passed
+ /// and this flag is not set, some defaults will be chosen.
+ ///
+ ///
+ ///
+ ///
+ public AVICOMPRESSF dwFlags;
+
+ /// Pointer to a structure defining the data format. For an audio stream, this is an LPWAVEFORMAT structure.
+ public IntPtr lpFormat;
+
+ /// Size, in bytes, of the data referenced by lpFormat.
+ public uint cbFormat;
+
+ /// Video-compressor-specific data; used internally.
+ public IntPtr lpParms;
+
+ /// Size, in bytes, of the data referenced by lpParms
+ public uint cbParms;
+
+ ///
+ /// Interleave factor for interspersing stream data with data from the first stream. Used only if the AVICOMPRESSF_INTERLEAVE
+ /// flag is set.
+ ///
+ public uint dwInterleaveEvery;
+ }
+
+ /// The AVIFILEINFO structure contains global information for an entire AVI file.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVIFILEINFO 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/ns-vfw-avifileinfoa typedef struct _AVIFILEINFOA { DWORD dwMaxBytesPerSec;
+ // DWORD dwFlags; DWORD dwCaps; DWORD dwStreams; DWORD dwSuggestedBufferSize; DWORD dwWidth; DWORD dwHeight; DWORD dwScale; DWORD
+ // dwRate; DWORD dwLength; DWORD dwEditCount; char szFileType[64]; } AVIFILEINFOA, *LPAVIFILEINFOA;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw._AVIFILEINFOA")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct AVIFILEINFO
+ {
+ /// Approximate maximum data rate of the AVI file.
+ public uint dwMaxBytesPerSec;
+
+ ///
+ /// A bitwise OR of zero or more flags. The following flags are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AVIFILEINFO_HASINDEX
+ /// The AVI file has an index at the end of the file. For good performance, all AVI files should contain an index.
+ ///
+ /// -
+ /// AVIFILEINFO_MUSTUSEINDEX
+ ///
+ /// The file index contains the playback order for the chunks in the file. Use the index rather than the physical ordering of
+ /// the chunks when playing back the data. This could be used for creating a list of frames for editing.
+ ///
+ ///
+ /// -
+ /// AVIFILEINFO_ISINTERLEAVED
+ /// The AVI file is interleaved.
+ ///
+ /// -
+ /// AVIFILEINFO_WASCAPTUREFILE
+ ///
+ /// The AVI file is a specially allocated file used for capturing real-time video. Applications should warn the user before
+ /// writing over a file with this flag set because the user probably defragmented this file.
+ ///
+ ///
+ /// -
+ /// AVIFILEINFO_COPYRIGHTED
+ ///
+ /// The AVI file contains copyrighted data and software. When this flag is used, software should not permit the data to be duplicated.
+ ///
+ ///
+ ///
+ ///
+ public AVIFILEINFOF dwFlags;
+
+ ///
+ /// Capability flags. The following flags are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AVIFILECAPS_CANREAD
+ /// An application can open the AVI file with the read privilege.
+ ///
+ /// -
+ /// AVIFILECAPS_CANWRITE
+ /// An application can open the AVI file with the write privilege.
+ ///
+ /// -
+ /// AVIFILECAPS_ALLKEYFRAMES
+ /// Every frame in the AVI file is a key frame.
+ ///
+ /// -
+ /// AVIFILECAPS_NOCOMPRESSION
+ /// The AVI file does not use a compression method.
+ ///
+ ///
+ ///
+ public AVIFILECAPS dwCaps;
+
+ /// Number of streams in the file. For example, a file with audio and video has at least two streams.
+ public uint dwStreams;
+
+ ///
+ ///
+ /// Suggested buffer size, in bytes, for reading the file. Generally, this size should be large enough to contain the largest
+ /// chunk in the file. For an interleaved file, this size should be large enough to read an entire record, not just a chunk.
+ ///
+ ///
+ /// If the buffer size is too small or is set to zero, the playback software will have to reallocate memory during playback,
+ /// reducing performance.
+ ///
+ ///
+ public uint dwSuggestedBufferSize;
+
+ /// Width, in pixels, of the AVI file.
+ public uint dwWidth;
+
+ /// Height, in pixels, of the AVI file.
+ public uint dwHeight;
+
+ ///
+ ///
+ /// Time scale applicable for the entire file. Dividing dwRate by dwScale gives the number of samples per second.
+ ///
+ /// Any stream can define its own time scale to supersede the file time scale.
+ ///
+ public uint dwScale;
+
+ /// Rate in an integer format. To obtain the rate in samples per second, divide this value by the value in dwScale.
+ public uint dwRate;
+
+ /// Length of the AVI file. The units are defined by dwRate and dwScale.
+ public uint dwLength;
+
+ /// Number of streams that have been added to or deleted from the AVI file.
+ public uint dwEditCount;
+
+ /// Null-terminated string containing descriptive information for the file type.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
+ public string szFileType;
+ }
+
+ /// The AVISTREAMINFO structure contains information for a single stream.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines AVISTREAMINFO 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/ns-vfw-avistreaminfoa typedef struct _AVISTREAMINFOA { DWORD fccType;
+ // DWORD fccHandler; DWORD dwFlags; DWORD dwCaps; WORD wPriority; WORD wLanguage; DWORD dwScale; DWORD dwRate; DWORD dwStart; DWORD
+ // dwLength; DWORD dwInitialFrames; DWORD dwSuggestedBufferSize; DWORD dwQuality; DWORD dwSampleSize; RECT rcFrame; DWORD
+ // dwEditCount; DWORD dwFormatChangeCount; char szName[64]; } AVISTREAMINFOA, *LPAVISTREAMINFOA;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw._AVISTREAMINFOA")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public struct AVISTREAMINFO
+ {
+ ///
+ ///
+ /// Four-character code indicating the stream type. The following constants have been defined for the data commonly found in AVI streams:
+ ///
+ ///
+ ///
+ /// Constant
+ /// Description
+ ///
+ /// -
+ /// streamtypeAUDIO
+ /// Indicates an audio stream.
+ ///
+ /// -
+ /// streamtypeMIDI
+ /// Indicates a MIDI stream.
+ ///
+ /// -
+ /// streamtypeTEXT
+ /// Indicates a text stream.
+ ///
+ /// -
+ /// streamtypeVIDEO
+ /// Indicates a video stream.
+ ///
+ ///
+ ///
+ public uint fccType;
+
+ ///
+ /// Four-character code of the compressor handler that will compress this video stream when it is saved (for example, mmioFOURCC
+ /// ('M','S','V','C')). This member is not used for audio streams.
+ ///
+ public uint fccHandler;
+
+ ///
+ ///
+ /// Applicable flags for the stream. The bits in the high-order word of these flags are specific to the type of data contained
+ /// in the stream. The following flags are defined:
+ ///
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// AVISTREAMINFO_DISABLED
+ /// Indicates this stream should be rendered when explicitly enabled by the user.
+ ///
+ /// -
+ /// AVISTREAMINFO_FORMATCHANGES
+ ///
+ /// Indicates this video stream contains palette changes. This flag warns the playback software that it will need to animate the palette.
+ ///
+ ///
+ ///
+ ///
+ public AVISTREAMINFOF dwFlags;
+
+ /// Capability flags; currently unused.
+ public uint dwCaps;
+
+ /// Priority of the stream.
+ public ushort wPriority;
+
+ /// Language of the stream.
+ public ushort wLanguage;
+
+ ///
+ ///
+ /// Time scale applicable for the stream. Dividing dwRate by dwScale gives the playback rate in number of samples
+ /// per second.
+ ///
+ ///
+ /// For video streams, this rate should be the frame rate. For audio streams, this rate should correspond to the audio block
+ /// size (the nBlockAlign member of the WAVEFORMAT or PCMWAVEFORMAT structure), which for PCM (Pulse Code Modulation)
+ /// audio reduces to the sample rate.
+ ///
+ ///
+ public uint dwScale;
+
+ /// Rate in an integer format. To obtain the rate in samples per second, divide this value by the value in dwScale.
+ public uint dwRate;
+
+ ///
+ ///
+ /// Sample number of the first frame of the AVI file. The units are defined by dwRate and dwScale. Normally, this is
+ /// zero, but it can specify a delay time for a stream that does not start concurrently with the file.
+ ///
+ /// The 1.0 release of the AVI tools does not support a nonzero starting time.
+ ///
+ public uint dwStart;
+
+ /// Length of this stream. The units are defined by dwRate and dwScale.
+ public uint dwLength;
+
+ ///
+ /// Audio skew. This member specifies how much to skew the audio data ahead of the video frames in interleaved files. Typically,
+ /// this is about 0.75 seconds.
+ ///
+ public uint dwInitialFrames;
+
+ ///
+ /// Recommended buffer size, in bytes, for the stream. Typically, this member contains a value corresponding to the largest
+ /// chunk in the stream. Using the correct buffer size makes playback more efficient. Use zero if you do not know the correct
+ /// buffer size.
+ ///
+ public uint dwSuggestedBufferSize;
+
+ ///
+ /// Quality indicator of the video data in the stream. Quality is represented as a number between 0 and 10,000. For compressed
+ /// data, this typically represents the value of the quality parameter passed to the compression software. If set to –1, drivers
+ /// use the default quality value.
+ ///
+ public uint dwQuality;
+
+ ///
+ ///
+ /// Size, in bytes, of a single data sample. If the value of this member is zero, the samples can vary in size and each data
+ /// sample (such as a video frame) must be in a separate chunk. A nonzero value indicates that multiple samples of data can be
+ /// grouped into a single chunk within the file.
+ ///
+ ///
+ /// For video streams, this number is typically zero, although it can be nonzero if all video frames are the same size. For
+ /// audio streams, this number should be the same as the nBlockAlign member of the WAVEFORMAT or WAVEFORMATEX structure
+ /// describing the audio.
+ ///
+ ///
+ public uint dwSampleSize;
+
+ ///
+ /// Dimensions of the video destination rectangle. The values represent the coordinates of upper left corner, the height, and
+ /// the width of the rectangle.
+ ///
+ public RECT rcFrame;
+
+ /// Number of times the stream has been edited. The stream handler maintains this count.
+ public uint dwEditCount;
+
+ /// Number of times the stream format has changed. The stream handler maintains this count.
+ public uint dwFormatChangeCount;
+
+ /// Null-terminated string containing a description of the stream.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
+ public string szName;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.IC.cs b/PInvoke/Multimedia/Vfw.IC.cs
new file mode 100644
index 00000000..c111308c
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.IC.cs
@@ -0,0 +1,916 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.Gdi32;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the Msvfw32.dll
+ public static partial class Msvfw32
+ {
+ private const string Lib_Msvfw32 = "msvfw32.dll";
+
+ /// Applicable flags for the function.
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibBegin")]
+ [Flags]
+ public enum DDF : uint
+ {
+ ///
+ /// Last buffered bitmap needs to be redrawn. If drawing fails with this value, a buffered image is not available and a new
+ /// image needs to be specified before the display can be updated.
+ ///
+ DDF_UPDATE = 0x0002,
+
+ /// Use the current DC handle and the palette currently associated with the DC.
+ DDF_SAME_HDC = 0x0004,
+
+ ///
+ /// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDest, dyDest, dxSrc, and dySrc have not
+ /// changed since using DrawDibDraw or DrawDibBegin. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
+ ///
+ DDF_SAME_DRAW = 0x0008,
+
+ ///
+ /// Current image is not drawn, but is decompressed. DDF_UPDATE can be used later to draw the image. This flag supersedes the
+ /// DDF_PREROLL flag.
+ ///
+ DDF_DONTDRAW = 0x0010,
+
+ ///
+ /// Allows palette animation. If this value is present, DrawDib reserves as many entries as possible by setting PC_RESERVED in
+ /// the palPalEntry array entries of the LOGPALETTE structure, and the palette can be animated by using the DrawDibChangePalette
+ /// function. If your application uses the DrawDibBegin function with the DrawDibDraw function, set this value with DrawDibBegin
+ /// rather than DrawDibDraw.
+ ///
+ DDF_ANIMATE = 0x0020,
+
+ ///
+ /// Causes DrawDib to try to use an off-screen buffer so DDF_UPDATE can be used. This disables decompression and drawing
+ /// directly to the screen. If DrawDib is unable to create an off-screen buffer, it will decompress or draw directly to the
+ /// screen. For more information, see the DDF_UPDATE and DDF_DONTDRAW values described for DrawDibDraw.
+ ///
+ DDF_BUFFER = 0x0040,
+
+ ///
+ /// Draws the image by using GDI. Prohibits DrawDib functions from decompressing, stretching, or dithering the image. This
+ /// strips DrawDib of capabilities that differentiate it from the StretchDIBits function.
+ ///
+ DDF_JUSTDRAWIT = 0x0080,
+
+ /// Not supported.
+ DDF_FULLSCREEN = 0x0100,
+
+ ///
+ /// Realizes the palette used for drawing as a background task, leaving the current palette used for the display unchanged.
+ /// (This value is mutually exclusive of DDF_SAME_HDC.)
+ ///
+ DDF_BACKGROUNDPAL = 0x0200,
+
+ /// this is a partial frame update, hint
+ DDF_NOTKEYFRAME = 0x0400,
+
+ /// hurry up please!
+ DDF_HURRYUP = 0x0800,
+
+ ///
+ /// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses DrawDibBegin
+ /// with DrawDibDraw, set this value with DrawDibBegin rather than DrawDibDraw.
+ ///
+ DDF_HALFTONE = 0x1000,
+ }
+
+ /// The DrawDib function changes parameters of a DrawDib DC or initializes a new DrawDib DC.
+ /// Handle to a DrawDib DC.
+ /// Handle to a DC for drawing. This parameter is optional.
+ /// Width, in MM_TEXT client units, of the destination rectangle.
+ /// Height, in MM_TEXT client units, of the destination rectangle.
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure containing the image format. The color table for the DIB follows the image format and
+ /// the biHeight member must be a positive value.
+ ///
+ /// Width, in pixels, of the source rectangle.
+ /// Height, in pixels, of the source rectangle.
+ ///
+ /// Applicable flags for the function. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DDF_ANIMATE
+ ///
+ /// Allows palette animation. If this value is present, DrawDib reserves as many entries as possible by setting PC_RESERVED in the
+ /// palPalEntry array entries of the LOGPALETTE structure, and the palette can be animated by using the DrawDibChangePalette
+ /// function. If your application uses the DrawDibBegin function with the DrawDibDraw function, set this value with DrawDibBegin
+ /// rather than DrawDibDraw.
+ ///
+ ///
+ /// -
+ /// DDF_BACKGROUNDPAL
+ ///
+ /// Realizes the palette used for drawing as a background task, leaving the current palette used for the display unchanged. (This
+ /// value is mutually exclusive of DDF_SAME_HDC.)
+ ///
+ ///
+ /// -
+ /// DDF_BUFFER
+ ///
+ /// Causes DrawDib to try to use an off-screen buffer so DDF_UPDATE can be used. This disables decompression and drawing directly to
+ /// the screen. If DrawDib is unable to create an off-screen buffer, it will decompress or draw directly to the screen. For more
+ /// information, see the DDF_UPDATE and DDF_DONTDRAW values described for DrawDibDraw.
+ ///
+ ///
+ /// -
+ /// DDF_DONTDRAW
+ ///
+ /// Current image is not drawn, but is decompressed. DDF_UPDATE can be used later to draw the image. This flag supersedes the
+ /// DDF_PREROLL flag.
+ ///
+ ///
+ /// -
+ /// DDF_FULLSCREEN
+ /// Not supported.
+ ///
+ /// -
+ /// DDF_HALFTONE
+ ///
+ /// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses DrawDibBegin with
+ /// DrawDibDraw, set this value with DrawDibBegin rather than DrawDibDraw.
+ ///
+ ///
+ /// -
+ /// DDF_JUSTDRAWIT
+ ///
+ /// Draws the image by using GDI. Prohibits DrawDib functions from decompressing, stretching, or dithering the image. This strips
+ /// DrawDib of capabilities that differentiate it from the StretchDIBits function.
+ ///
+ ///
+ /// -
+ /// DDF_SAME_DRAW
+ ///
+ /// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDest, dyDest, dxSrc, and dySrc have not
+ /// changed since using DrawDibDraw or DrawDibBegin. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
+ ///
+ ///
+ /// -
+ /// DDF_SAME_HDC
+ /// Use the current DC handle and the palette currently associated with the DC.
+ ///
+ /// -
+ /// DDF_UPDATE
+ ///
+ /// Last buffered bitmap needs to be redrawn. If drawing fails with this value, a buffered image is not available and a new image
+ /// needs to be specified before the display can be updated.
+ ///
+ ///
+ ///
+ ///
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// This function prepares to draw a DIB specified by lpbi to the DC. The image is stretched to the size specified by dxDest and
+ /// dyDest. If dxDest and dyDest are set to −1, the DIB is drawn to a 1:1 scale without stretching.
+ ///
+ ///
+ /// You can update the flags of a DrawDib DC by reissuing DrawDibBegin, specifying the new flags, and changing at least one
+ /// of the following settings: dxDest, dyDest, lpbi, dxSrc, or dySrc.
+ ///
+ /// If the parameters of DrawDibBegin have not changed, subsequent calls to the function have no effect.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibbegin BOOL VFWAPI DrawDibBegin( HDRAWDIB hdd, HDC hdc, int
+ // dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, int dxSrc, int dySrc, UINT wFlags );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibBegin")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibBegin([In] HDRAWDIB hdd, [In, Optional] HDC hdc, int dxDst, int dyDst, in BITMAPINFOHEADER lpbi, int dxSrc, int dySrc, DDF wFlags);
+
+ /// The DrawDibChangePalette function sets the palette entries used for drawing DIBs.
+ /// Handle to a DrawDib DC.
+ /// Starting palette entry number.
+ /// Number of palette entries.
+ /// Pointer to an array of palette entries.
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// This function changes the physical palette only if the current DrawDib palette is realized by calling the DrawDibRealize function.
+ ///
+ ///
+ /// If the color table is not changed, the next call to the DrawDibDraw function that does not specify DDF_SAME_DRAW calls the
+ /// DrawDibBegin function implicitly.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibchangepalette BOOL VFWAPI DrawDibChangePalette( HDRAWDIB
+ // hdd, int iStart, int iLen, LPPALETTEENTRY lppe );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibChangePalette")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibChangePalette([In] HDRAWDIB hdd, int iStart, int iLen, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[] lppe);
+
+ /// The DrawDibClose function closes a DrawDib DC and frees the resources DrawDib allocated for it.
+ /// Handle to a DrawDib DC.
+ /// Returns TRUE if successful or FALSE otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibclose BOOL VFWAPI DrawDibClose( HDRAWDIB hdd );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibClose")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibClose(HDRAWDIB hdd);
+
+ /// The DrawDibDraw function draws a DIB to the screen.
+ /// Handle to a DrawDib DC.
+ /// Handle to the DC.
+ /// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ /// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ ///
+ /// Width, in MM_TEXT client coordinates, of the destination rectangle. If dxDst is −1, the width of the bitmap is used.
+ ///
+ ///
+ /// Height, in MM_TEXT client coordinates, of the destination rectangle. If dyDst is −1, the height of the bitmap is used.
+ ///
+ ///
+ /// Pointer to the BITMAPINFOHEADER structure containing the image format. The color table for the DIB within
+ /// BITMAPINFOHEADER follows the format and the biHeight member must be a positive value; DrawDibDraw will not
+ /// draw inverted DIBs.
+ ///
+ /// Pointer to the buffer that contains the bitmap bits.
+ ///
+ /// The x-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
+ /// corner of the bitmap.
+ ///
+ ///
+ /// The y-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
+ /// corner of the bitmap.
+ ///
+ /// Width, in pixels, of the source rectangle.
+ /// Height, in pixels, of the source rectangle.
+ ///
+ /// Applicable flags for drawing. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DDF_BACKGROUNDPAL
+ ///
+ /// Realizes the palette used for drawing in the background, leaving the actual palette used for display unchanged. This value is
+ /// valid only if DDF_SAME_HDC is not set.
+ ///
+ ///
+ /// -
+ /// DDF_DONTDRAW
+ /// Current image is decompressed but not drawn. This flag supersedes the DDF_PREROLL flag.
+ ///
+ /// -
+ /// DDF_FULLSCREEN
+ /// Not supported.
+ ///
+ /// -
+ /// DDF_HALFTONE
+ ///
+ /// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses the DrawDibBegin
+ /// function, set this value in DrawDibBegin rather than in DrawDibDraw.
+ ///
+ ///
+ /// -
+ /// DDF_HURRYUP
+ ///
+ /// Data does not have to be drawn (that is, it can be dropped) and DDF_UPDATE will not be used to recall this information. DrawDib
+ /// checks this value only if it is required to build the next frame; otherwise, the value is ignored.This value is usually used to
+ /// synchronize video and audio. When synchronizing data, applications should send the image with this value in case the driver
+ /// needs to buffer the frame to decompress subsequent frames.
+ ///
+ ///
+ /// -
+ /// DDF_NOTKEYFRAME
+ /// DIB data is not a key frame.
+ ///
+ /// -
+ /// DDF_SAME_HDC
+ /// Use the current DC handle and the palette currently associated with the DC.
+ ///
+ /// -
+ /// DDF_SAME_DRAW
+ ///
+ /// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDst, dyDst, dxSrc, and dySrc have not changed
+ /// since using DrawDibDraw or DrawDibBegin. DrawDibDraw typically checks the parameters, and if they have changed, DrawDibBegin
+ /// prepares the DrawDib DC for drawing. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
+ ///
+ ///
+ /// -
+ /// DDF_UPDATE
+ ///
+ /// Last buffered bitmap is to be redrawn. If drawing fails with this value, a buffered image is not available and a new image needs
+ /// to be specified before the display can be updated.
+ ///
+ ///
+ ///
+ ///
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// DDF_DONTDRAW causes DrawDibDraw to decompress but not display an image. A subsequent call to DrawDibDraw
+ /// specifying DDF_UPDATE displays the image.
+ ///
+ ///
+ /// If the DrawDib DC does not have an off-screen buffer specified, specifying DDF_DONTDRAW causes the frame to be drawn to
+ /// the screen immediately. Subsequent calls to DrawDibDraw specifying DDF_UPDATE fail.
+ ///
+ ///
+ /// Although they are set at different times, DDF_UPDATE and DDF_DONTDRAW can be used together to create composite
+ /// images off-screen. When the off-screen image is complete, you can display the image by calling DrawDibDraw.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibdraw BOOL VFWAPI DrawDibDraw( HDRAWDIB hdd, HDC hdc, int
+ // xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT
+ // wFlags );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibDraw")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibDraw([In] HDRAWDIB hdd, [In] HDC hdc, int xDst, int yDst, int dxDst, int dyDst, in BITMAPINFOHEADER lpbi, [In, Optional] IntPtr lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, DDF wFlags);
+
+ /// The DrawDibDraw function draws a DIB to the screen.
+ /// Handle to a DrawDib DC.
+ /// Handle to the DC.
+ /// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ /// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ ///
+ /// Width, in MM_TEXT client coordinates, of the destination rectangle. If dxDst is −1, the width of the bitmap is used.
+ ///
+ ///
+ /// Height, in MM_TEXT client coordinates, of the destination rectangle. If dyDst is −1, the height of the bitmap is used.
+ ///
+ ///
+ /// Pointer to the BITMAPINFOHEADER structure containing the image format. The color table for the DIB within
+ /// BITMAPINFOHEADER follows the format and the biHeight member must be a positive value; DrawDibDraw will not
+ /// draw inverted DIBs.
+ ///
+ /// Pointer to the buffer that contains the bitmap bits.
+ ///
+ /// The x-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
+ /// corner of the bitmap.
+ ///
+ ///
+ /// The y-coordinate, in pixels, of the upper left corner of the source rectangle. The coordinates (0,0) represent the upper left
+ /// corner of the bitmap.
+ ///
+ /// Width, in pixels, of the source rectangle.
+ /// Height, in pixels, of the source rectangle.
+ ///
+ /// Applicable flags for drawing. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DDF_BACKGROUNDPAL
+ ///
+ /// Realizes the palette used for drawing in the background, leaving the actual palette used for display unchanged. This value is
+ /// valid only if DDF_SAME_HDC is not set.
+ ///
+ ///
+ /// -
+ /// DDF_DONTDRAW
+ /// Current image is decompressed but not drawn. This flag supersedes the DDF_PREROLL flag.
+ ///
+ /// -
+ /// DDF_FULLSCREEN
+ /// Not supported.
+ ///
+ /// -
+ /// DDF_HALFTONE
+ ///
+ /// Always dithers the DIB to a standard palette regardless of the palette of the DIB. If your application uses the DrawDibBegin
+ /// function, set this value in DrawDibBegin rather than in DrawDibDraw.
+ ///
+ ///
+ /// -
+ /// DDF_HURRYUP
+ ///
+ /// Data does not have to be drawn (that is, it can be dropped) and DDF_UPDATE will not be used to recall this information. DrawDib
+ /// checks this value only if it is required to build the next frame; otherwise, the value is ignored.This value is usually used to
+ /// synchronize video and audio. When synchronizing data, applications should send the image with this value in case the driver
+ /// needs to buffer the frame to decompress subsequent frames.
+ ///
+ ///
+ /// -
+ /// DDF_NOTKEYFRAME
+ /// DIB data is not a key frame.
+ ///
+ /// -
+ /// DDF_SAME_HDC
+ /// Use the current DC handle and the palette currently associated with the DC.
+ ///
+ /// -
+ /// DDF_SAME_DRAW
+ ///
+ /// Use the current drawing parameters for DrawDibDraw. Use this value only if lpbi, dxDst, dyDst, dxSrc, and dySrc have not changed
+ /// since using DrawDibDraw or DrawDibBegin. DrawDibDraw typically checks the parameters, and if they have changed, DrawDibBegin
+ /// prepares the DrawDib DC for drawing. This flag supersedes the DDF_SAME_DIB and DDF_SAME_SIZE flags.
+ ///
+ ///
+ /// -
+ /// DDF_UPDATE
+ ///
+ /// Last buffered bitmap is to be redrawn. If drawing fails with this value, a buffered image is not available and a new image needs
+ /// to be specified before the display can be updated.
+ ///
+ ///
+ ///
+ ///
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ ///
+ /// DDF_DONTDRAW causes DrawDibDraw to decompress but not display an image. A subsequent call to DrawDibDraw
+ /// specifying DDF_UPDATE displays the image.
+ ///
+ ///
+ /// If the DrawDib DC does not have an off-screen buffer specified, specifying DDF_DONTDRAW causes the frame to be drawn to
+ /// the screen immediately. Subsequent calls to DrawDibDraw specifying DDF_UPDATE fail.
+ ///
+ ///
+ /// Although they are set at different times, DDF_UPDATE and DDF_DONTDRAW can be used together to create composite
+ /// images off-screen. When the off-screen image is complete, you can display the image by calling DrawDibDraw.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibdraw BOOL VFWAPI DrawDibDraw( HDRAWDIB hdd, HDC hdc, int
+ // xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT
+ // wFlags );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibDraw")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibDraw([In] HDRAWDIB hdd, [In] HDC hdc, int xDst, int yDst, int dxDst, int dyDst, [In, Optional] IntPtr lpbi, [In, Optional] IntPtr lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, DDF wFlags);
+
+ ///
+ /// The DrawDibEnd function clears the flags and other settings of a DrawDib DC that are set by the DrawDibBegin or
+ /// DrawDibDraw functions.
+ ///
+ /// Handle to the DrawDib DC to free.
+ /// Returns TRUE if successful or FALSE otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibend BOOL VFWAPI DrawDibEnd( HDRAWDIB hdd );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibEnd")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibEnd([In] HDRAWDIB hdd);
+
+ /// The DrawDibGetBuffer function retrieves the location of the buffer used by DrawDib for decompression.
+ /// Handle to a DrawDib DC.
+ ///
+ /// Pointer to a BITMAPINFO structure. This structure is made up of a BITMAPINFOHEADER structure and a 256-entry table defining the
+ /// colors used by the bitmap.
+ ///
+ /// Size, in bytes, of the BITMAPINFO structure pointed to by lpbi
+ /// Reserved; must be zero.
+ ///
+ /// Returns the address of the buffer or NULL if no buffer is used. if lpbr is not NULL, it is filled with a copy of
+ /// the BITMAPINFO structure describing the buffer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibgetbuffer LPVOID VFWAPI DrawDibGetBuffer( HDRAWDIB hdd,
+ // LPBITMAPINFOHEADER lpbi, DWORD dwSize, DWORD dwFlags );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibGetBuffer")]
+ public static extern IntPtr DrawDibGetBuffer([In] HDRAWDIB hdd, out BITMAPINFOHEADER lpbi, uint dwSize, uint dwFlags = 0);
+
+ /// The DrawDibGetPalette function retrieves the palette used by a DrawDib DC.
+ /// Handle to a DrawDib DC.
+ /// Returns a handle to the palette if successful or NULL otherwise.
+ ///
+ ///
+ /// This function assumes the DrawDib DC contains a valid palette entry, implying that a call to this function must follow calls to
+ /// the DrawDibDraw or DrawDibBegin functions.
+ ///
+ ///
+ /// You should rarely need to call this function because you can realize the correct palette in response to a window message by
+ /// using the DrawDibRealize function.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibgetpalette HPALETTE VFWAPI DrawDibGetPalette( HDRAWDIB hdd );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibGetPalette")]
+ public static extern SafeHPALETTE DrawDibGetPalette([In] HDRAWDIB hdd);
+
+ /// The DrawDibOpen function opens the DrawDib library for use and creates a DrawDib DC for drawing.
+ /// Returns a handle to a DrawDib DC if successful or NULL otherwise.
+ ///
+ /// When drawing multiple DIBs simultaneously, create a DrawDib DC for each of the images that will be simultaneously on-screen.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibopen HDRAWDIB VFWAPI DrawDibOpen();
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibOpen")]
+ public static extern SafeHDRAWDIB DrawDibOpen();
+
+ /// The DrawDibProfileDisplay function determines settings for the display system when using DrawDib functions.
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure that contains bitmap information. You can also specify NULL to verify that the
+ /// profile information is current. If the profile information is not current, DrawDib will rerun the profile tests to obtain a
+ /// current set of information. When you call DrawDibProfileDisplay with this parameter set to NULL, the return value
+ /// is meaningless.
+ ///
+ ///
+ ///
+ /// Returns a value that indicates the fastest drawing and stretching capabilities of the display system. This value can be zero if
+ /// the bitmap format is not supported or one or more of the following values.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PD_CAN_DRAW_DIB
+ /// DrawDib can draw images using this format. Stretching might or might not also be supported.
+ ///
+ /// -
+ /// PD_CAN_STRETCHDIB
+ /// DrawDib can stretch and draw images using this format.
+ ///
+ /// -
+ /// PD_STRETCHDIB_1_1_OK
+ /// StretchDIBits draws unstretched images using this format faster than an alternative method.
+ ///
+ /// -
+ /// PD_STRETCHDIB_1_2_OK
+ /// StretchDIBits draws stretched images (in a 1:2 ratio) using this format faster than an alternative method.
+ ///
+ /// -
+ /// PD_STRETCHDIB_1_N_OK
+ /// StretchDIBits draws stretched images (in a 1:N ratio) using this format faster than an alternative method.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibprofiledisplay LRESULT VFWAPI DrawDibProfileDisplay(
+ // LPBITMAPINFOHEADER lpbi );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibProfileDisplay")]
+ public static extern IntPtr DrawDibProfileDisplay(in BITMAPINFOHEADER lpbi);
+
+ /// The DrawDibRealize function realizes the palette of the DrawDib DC for use with the specified DC.
+ /// Handle to a DrawDib DC.
+ /// Handle to the DC containing the palette.
+ ///
+ /// Background palette flag. If this value is nonzero, the palette is a background palette. If this value is zero and the DC is
+ /// attached to a window, the logical palette becomes the foreground palette when the window has the input focus. (A DC is attached
+ /// to a window when the window class style is CS_OWNDC or when the DC is obtained by using the GetDC function.)
+ ///
+ ///
+ /// Returns the number of entries in the logical palette mapped to different values in the system palette. If an error occurs or no
+ /// colors were updated, it returns zero.
+ ///
+ ///
+ /// To select the palette of the DrawDib DC as a background palette, use the DrawDibDraw function and specify the DDF_BACKGROUNDPAL flag.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibrealize UINT VFWAPI DrawDibRealize( HDRAWDIB hdd, HDC hdc,
+ // BOOL fBackground );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibRealize")]
+ public static extern uint DrawDibRealize([In] HDRAWDIB hdd, [In] HDC hdc, [MarshalAs(UnmanagedType.Bool)] bool fBackground);
+
+ /// The DrawDibSetPalette function sets the palette used for drawing DIBs.
+ /// Handle to a DrawDib DC.
+ /// Handle to the palette. Specify NULL to use the default palette.
+ /// Returns TRUE if successful or FALSE otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibsetpalette BOOL VFWAPI DrawDibSetPalette( HDRAWDIB hdd,
+ // HPALETTE hpal );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibSetPalette")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibSetPalette([In] HDRAWDIB hdd, [In, Optional] HPALETTE hpal);
+
+ /// The DrawDibStart function prepares a DrawDib DC for streaming playback.
+ /// Handle to a DrawDib DC.
+ /// Playback rate, in microseconds per frame.
+ /// Returns TRUE if successful or FALSE otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibstart BOOL VFWAPI DrawDibStart( HDRAWDIB hdd, DWORD rate );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibStart")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibStart([In] HDRAWDIB hdd, uint rate);
+
+ /// The DrawDibStop function frees the resources used by a DrawDib DC for streaming playback.
+ /// Handle to a DrawDib DC.
+ /// Returns TRUE if successful or FALSE otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibstop BOOL VFWAPI DrawDibStop( HDRAWDIB hdd );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibStop")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibStop([In] HDRAWDIB hdd);
+
+ ///
+ /// The DrawDibTime function retrieves timing information about the drawing operation and is used during debug operations.
+ ///
+ /// Handle to a DrawDib DC.
+ /// Pointer to a DRAWDIBTIME structure.
+ /// Returns TRUE if successful or FALSE otherwise.
+ /// This function is present only in the debug version of the Microsoft Windows Software Development Kit (SDK) libraries.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibtime BOOL VFWAPI DrawDibTime( HDRAWDIB hdd, LPDRAWDIBTIME
+ // lpddtime );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibTime")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DrawDibTime([In] HDRAWDIB hdd, out DRAWDIBTIME lpddtime);
+
+ /// The DrawDibUpdate macro draws the last frame in the DrawDib off-screen buffer.
+ /// Handle to a DrawDib DC.
+ /// Handle of the DC.
+ /// The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ /// The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
+ /// Returns TRUE if successful or FALSE otherwise.
+ ///
+ /// The DrawDibUpdate macro is defined as follows:
+ ///
+ /// #define DrawDibUpdate( hdd, hdc, x, y) \ DrawDibDraw( hdd, hdc, x, y, 0, 0, NULL, NULL, 0, 0, \ 0, 0, DDF_UPDATE)
+ ///
+ /// This macro can be used to refresh an image or a portion of an image displayed by your application.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-drawdibupdate void DrawDibUpdate( hdd, hdc, x, y );
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.DrawDibUpdate")]
+ public static bool DrawDibUpdate([In] HDRAWDIB hdd, [In] HDC hdc, int x, int y) => DrawDibDraw(hdd, hdc, x, y, 0, 0, default, default, 0, 0, 0, 0, DDF.DDF_UPDATE);
+
+ ///
+ /// The GetOpenFileNamePreview function selects a file by using the Open dialog box. The dialog box also allows the user to
+ /// preview the currently specified AVI file. This function augments the capability found in the GetOpenFileName function.
+ ///
+ ///
+ /// Pointer to an OPENFILENAME structure used to initialize the dialog box. On return, the structure contains information
+ /// about the user's file selection.
+ ///
+ /// Returns a handle to the selected file.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines GetOpenFileNamePreview 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-getopenfilenamepreviewa BOOL VFWAPI GetOpenFileNamePreviewA(
+ // LPOPENFILENAMEA lpofn );
+ [DllImport(Lib_Msvfw32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.GetOpenFileNamePreviewA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool GetOpenFileNamePreview(ref ComDlg32.OPENFILENAME lpofn);
+
+ ///
+ /// The GetSaveFileNamePreview function selects a file by using the Save As dialog box. The dialog box also allows the user
+ /// to preview the currently specified file. This function augments the capability found in the GetSaveFileName function.
+ ///
+ ///
+ /// Pointer to an OPENFILENAME structure used to initialize the dialog box. On return, the structure contains information
+ /// about the user's file selection.
+ ///
+ /// Returns a handle to the selected file.
+ ///
+ /// Note
+ ///
+ /// The vfw.h header defines GetSaveFileNamePreview 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-getsavefilenamepreviewa BOOL VFWAPI GetSaveFileNamePreviewA(
+ // LPOPENFILENAMEA lpofn );
+ [DllImport(Lib_Msvfw32, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.GetSaveFileNamePreviewA")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool GetSaveFileNamePreview(ref ComDlg32.OPENFILENAME lpofn);
+
+ ///
+ /// The StretchDIB function copies a device independent bitmap from one memory location to another and resizes the image to
+ /// fit the destination rectangle.
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure that describes the destination bitmap.
+ /// Pointer to the memory buffer that will receive the copied pixel bits.
+ /// X coordinate of the destination rectangle's origin.
+ /// Y coordinate of the destination rectangle's origin.
+ /// Width, in pixels, of the destination rectangle.
+ /// Height, in pixels, of the destination rectangle.
+ /// Pointer to a BITMAPINFOHEADER structure that describes the source bitmap.
+ /// Pointer to the source bitmap data.
+ /// X coordinate of the source rectangle's origin.
+ /// Y coordinate of the source rectangle's origin.
+ /// Width, in pixels, of the source rectangle.
+ /// Height, in pixels, of the source rectangle.
+ /// None
+ ///
+ /// The size of the destination buffer must be large enough to accommodate any alignment bytes at the end of each pixel row.
+ ///
+ /// This function does nothing if biSrc and biDst have different values for biBitCount or if the value for biSrc. biBitCount does
+ /// not equal 8, 16, or 24.
+ ///
+ ///
+ /// This function performs no dithering or other smoothing. Pixel values are merely dropped or duplicated on a line-by-line,
+ /// column-by-column basis.
+ ///
+ ///
+ /// This function does not do any special processing based on pixel encoding except for calculating the number of bits per pixel. In
+ /// particular this function will not generate correct results when pixels are encoded in groups of more than 1 pixel, as in the
+ /// case of a YUV format where U and V are decimated and so are not represented equally in each pixel.
+ ///
+ /// Before including Vfw.h, you must add the following line to your code:
+ ///
+ /// #define DRAWDIB_INCLUDE_STRETCHDIB
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-stretchdib void StretchDIB( LPBITMAPINFOHEADER biDst, LPVOID lpDst,
+ // int DstX, int DstY, int DstXE, int DstYE, LPBITMAPINFOHEADER biSrc, LPVOID lpSrc, int SrcX, int SrcY, int SrcXE, int SrcYE );
+ [DllImport(Lib_Msvfw32, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("vfw.h", MSDNShortId = "NF:vfw.StretchDIB")]
+ public static extern void StretchDIB(in BITMAPINFOHEADER biDst, [Out] IntPtr lpDst, int DstX, int DstY, int DstXE, int DstYE, in BITMAPINFOHEADER biSrc, [In] IntPtr lpSrc, int SrcX, int SrcY, int SrcXE, int SrcYE);
+
+ ///
+ /// The DRAWDIBTIME structure contains elapsed timing information for performing a set of DrawDib operations. The DrawDibTime
+ /// function resets the count and the elapsed time value for each operation each time it is called.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-drawdibtime typedef struct { LONG timeCount; LONG timeDraw; LONG
+ // timeDecompress; LONG timeDither; LONG timeStretch; LONG timeBlt; LONG timeSetDIBits; } DRAWDIBTIME, *LPDRAWDIBTIME;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_12")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DRAWDIBTIME
+ {
+ ///
+ /// Number of times the following operations have been performed since DrawDibTime was last called:
+ ///
+ /// -
+ /// Draw a bitmap on the screen.
+ ///
+ /// -
+ /// Decompress a bitmap.
+ ///
+ /// -
+ /// Dither a bitmap.
+ ///
+ /// -
+ /// Stretch a bitmap.
+ ///
+ /// -
+ /// Transfer bitmap data by using the BitBlt function.
+ ///
+ /// -
+ /// Transfer bitmap data by using the SetDIBits function.
+ ///
+ ///
+ ///
+ public int timeCount;
+
+ /// Time to draw bitmaps.
+ public int timeDraw;
+
+ /// Time to decompress bitmaps.
+ public int timeDecompress;
+
+ /// Time to dither bitmaps.
+ public int timeDither;
+
+ /// Time to stretch bitmaps.
+ public int timeStretch;
+
+ /// Time to transfer bitmaps by using the BitBlt function.
+ public int timeBlt;
+
+ /// Time to transfer bitmaps by using the SetDIBits function.
+ public int timeSetDIBits;
+ }
+
+ /// Provides a handle to a DrawDib DC.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HDRAWDIB : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HDRAWDIB(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HDRAWDIB NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HDRAWDIB h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HDRAWDIB(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HDRAWDIB h1, HDRAWDIB h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HDRAWDIB h1, HDRAWDIB h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HDRAWDIB h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHDRAWDIB : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ ///
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ ///
+ public SafeHDRAWDIB(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHDRAWDIB() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HDRAWDIB(SafeHDRAWDIB h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => DrawDibClose(handle);
+ }
+
+ /*
+ ICAbout
+ ICClose
+ ICCompress
+ ICCompressBegin
+ ICCompressEnd
+ ICCompressGetFormat
+ ICCompressGetFormatSize
+ ICCompressGetSize
+ ICCompressorChoose
+ ICCompressorFree
+ ICCompressQuery
+ ICConfigure
+ ICDecompress
+ ICDecompressBegin
+ ICDecompressEnd
+ ICDecompressEx
+ ICDecompressExBegin
+ ICDecompressExEnd
+ ICDecompressExQuery
+ ICDecompressGetFormat
+ ICDecompressGetFormatSize
+ ICDecompressGetPalette
+ ICDecompressOpen
+ ICDecompressQuery
+ ICDecompressSetPalette
+ ICDraw
+ ICDrawBegin
+ ICDrawChangePalette
+ ICDrawEnd
+ ICDrawFlush
+ ICDrawGetTime
+ ICDrawOpen
+ ICDrawQuery
+ ICDrawRealize
+ ICDrawRenderBuffer
+ ICDrawSetTime
+ ICDrawStart
+ ICDrawStartPlay
+ ICDrawStop
+ ICDrawStopPlay
+ ICDrawSuggestFormat
+ ICDrawWindow
+ ICGetBuffersWanted
+ ICGetDefaultKeyFrameRate
+ ICGetDefaultQuality
+ ICGetDisplayFormat
+ ICGetInfo
+ ICGetState
+ ICGetStateSize
+ ICImageCompress
+ ICImageDecompress
+ ICInfo
+ ICInstall
+ ICLocate
+ ICOpen
+ ICOpenFunction
+ ICQueryAbout
+ ICQueryConfigure
+ ICRemove
+ ICSendMessage
+ ICSeqCompressFrame
+ ICSeqCompressFrameEnd
+ ICSeqCompressFrameStart
+ ICSetState
+ ICSetStatusProc
+ */
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.Interfaces.cs b/PInvoke/Multimedia/Vfw.Interfaces.cs
new file mode 100644
index 00000000..f93c4fd6
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.Interfaces.cs
@@ -0,0 +1,464 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.AviFil32;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the AviFil32.dll
+ public static partial class AviFil32
+ {
+ ///
+ /// The IAVIEditStream interface supports manipulating and modifying editable streams. Uses IUnknown::QueryInterface,
+ /// IUnknown::AddRef, IUnknown::Release in addition to the following custom methods:
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nn-vfw-iavieditstream
+ [PInvokeData("vfw.h", MSDNShortId = "NN:vfw.IAVIEditStream")]
+ [ComImport, Guid("00020024-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAVIEditStream
+ {
+ ///
+ /// The Cut method removes a portion of a stream and places it in a temporary stream. Called when an application uses the
+ /// EditStreamCut function.
+ ///
+ /// Pointer to a buffer that receives the starting position of the operation.
+ /// Pointer to a buffer that receives the length, in frames, of the operation.
+ /// Pointer to a buffer that receives a pointer to the interface to the new stream.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavieditstream-cut HRESULT Cut( LONG *plStart, LONG *plLength,
+ // PAVISTREAM *ppResult );
+ IAVIStream Cut(ref int plStart, ref int plLength);
+
+ ///
+ /// The Copy method copies a stream or a portion of it to a temporary stream. Called when an application uses the
+ /// EditStreamCopy function.
+ ///
+ /// Pointer to a buffer that receives the starting position of the operation.
+ /// Pointer to a buffer that receives the length, in frames, of the operation.
+ /// Pointer to a buffer that receives a pointer to the interface to the new stream.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavieditstream-copy HRESULT Copy( LONG *plStart, LONG
+ // *plLength, PAVISTREAM *ppResult );
+ IAVIStream Copy(ref int plStart, ref int plLength);
+
+ ///
+ /// The Paste method copies a stream or a portion of it in another stream. Called when an application uses the
+ /// EditStreamPaste function.
+ ///
+ /// Pointer to a buffer that receives the starting position of the operation.
+ /// Pointer to a buffer that receives the length, in bytes, of the data to paste from the source stream.
+ /// Pointer to the interface to the source stream.
+ /// Starting position of the copy operation within the source stream.
+ /// Ending position of the copy operation within the source stream.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavieditstream-paste HRESULT Paste( LONG *plPos, LONG
+ // *plLength, PAVISTREAM pstream, LONG lStart, LONG lEnd );
+ void Paste(ref int plPos, ref int plLength, [In, Out] IAVIStream pstream, [In] int lStart, [In] int lEnd);
+
+ /// The Clone method duplicates a stream. Called when an application uses the EditStreamClone function.
+ /// Receives a pointer to the interface to the new stream.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavieditstream-clone HRESULT Clone( PAVISTREAM *ppResult );
+ IAVIStream Clone();
+
+ ///
+ /// The SetInfo method changes the characteristics of a stream. Called when an application uses the EditStreamSetInfo function.
+ ///
+ /// Pointer to an AVISTREAMINFO structure containing the new stream characteristics.
+ /// Size, in bytes, of the buffer.
+ /// Returns the HRESULT defined by OLE.
+ ///
+ /// For handlers written in C++, SetInfo has the following syntax:
+ ///
+ /// HRESULT SetInfo(AVISTREAMINFO *lpInfo, LONG cbInfo);
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavieditstream-setinfo HRESULT SetInfo( AVISTREAMINFOW *lpInfo,
+ // LONG cbInfo );
+ void SetInfo(in AVISTREAMINFO lpInfo, [In] int cbInfo);
+ };
+
+ ///
+ /// The IAVIFile interface supports opening and manipulating files and file headers, and creating and obtaining stream
+ /// interfaces. Uses IUnknown::QueryInterface, IUnknown::AddRef, and IUnknown::Release in addition to the following custom methods:
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nn-vfw-iavifile
+ [PInvokeData("vfw.h", MSDNShortId = "NN:vfw.IAVIFile")]
+ [ComImport, Guid("00020020-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAVIFile
+ {
+ ///
+ /// The Info method returns with information about an AVI file. Called when an application uses the AVIFileInfo function.
+ ///
+ /// A pointer to an AVIFILEINFO structure. The method fills the structure with information about the file.
+ /// The size, in bytes, of the buffer specified by pfi.
+ ///
+ ///
+ /// If the buffer allocated is too small for the structure, this method should fail the call by returning AVIERR_BUFFERTOOSMALL.
+ /// Otherwise, it should fill the structure and return its size.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-info HRESULT Info( AVIFILEINFOW *pfi, LONG lSize );
+ void Info(out AVIFILEINFO pfi, [In] int lSize);
+
+ ///
+ /// The GetStream method opens a stream by accessing it in a file. Called when an application uses the AVIFileGetStream function.
+ ///
+ /// Pointer to a buffer that receives a pointer to the interface to a stream.
+ /// Four-character code indicating the type of stream to locate.
+ /// Stream number.
+ ///
+ ///
+ /// It is typically easier to implement this method by creating all of the stream objects in advance by using the IAVIFile::Open
+ /// method. Then, this method accesses the interface to the specified stream.
+ ///
+ ///
+ /// Remember to increment the reference count maintained by the AddRef method for the stream when this method is used.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-getstream HRESULT GetStream( PAVISTREAM *ppStream,
+ // DWORD fccType, LONG lParam );
+ void GetStream(out IAVIStream ppStream, [In] uint fccType, [In] int lParam);
+
+ ///
+ /// The CreateStream method creates a stream for writing. Called when an application uses the AVIFileCreateStream function.
+ ///
+ /// Pointer to a buffer that receives a pointer to the interface to the new stream.
+ /// Pointer to an AVISTREAMINFO structure defining the stream to create.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-createstream HRESULT CreateStream( PAVISTREAM
+ // *ppStream, AVISTREAMINFOW *psi );
+ void CreateStream(out IAVIStream ppStream, in AVISTREAMINFO psi);
+
+ /// The WriteData method writes file headers. Called when an application uses the AVIFileWriteData function.
+ /// A chunk ID.
+ /// A pointer specifying the memory from which the data is written.
+ /// A LONG specifying the number of bytes to write.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-writedata HRESULT WriteData( DWORD ckid, LPVOID
+ // lpData, LONG cbData );
+ void WriteData([In] uint ckid, [In] IntPtr lpData, [In] int cbData);
+
+ /// The ReadData method reads file headers. Called when an application uses the AVIFileReadData function.
+ /// A chunk identfier.
+ /// A pointer specifying the memory into which the data is read.
+ /// A pointer to a LONG specifying the number of bytes read.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-readdata HRESULT ReadData( DWORD ckid, LPVOID lpData,
+ // LONG *lpcbData );
+ void ReadData([In] uint ckid, [Out] IntPtr lpData, ref int lpcbData);
+
+ ///
+ /// The EndRecord method writes the "REC" chunk in a tightly interleaved AVI file (having a one-to-one interleave factor
+ /// of audio to video). Called when an application uses the AVIFileEndRecord function.
+ ///
+ ///
+ /// This file handler method is typically not used.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavifile-endrecord HRESULT EndRecord();
+ void EndRecord();
+
+ /// Deletes the stream.
+ /// Four-character code indicating the type of stream to delete.
+ /// Stream number.
+ void DeleteStream([In] uint fccType, [In] int lParam);
+ }
+
+ ///
+ /// The IAVIStream interface supports creating and manipulating data streams within a file. Uses IUnknown::QueryInterface,
+ /// IUnknown::AddRef, IUnknown::Release in addition to the following custom methods:
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nn-vfw-iavistream
+ [PInvokeData("vfw.h", MSDNShortId = "NN:vfw.IAVIStream")]
+ [ComImport, Guid("00020021-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAVIStream
+ {
+ ///
+ /// The Create method initializes a stream handler that is not associated with any file. Called when an application uses
+ /// the AVIStreamCreate function.
+ ///
+ /// Stream handler-specific data.
+ /// Stream handler-specific data.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-create HRESULT Create( LPARAM lParam1, LPARAM
+ // lParam2 );
+ void Create(IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// The Info method fills and returns an AVISTREAMINFO structure with information about a stream. Called when an
+ /// application uses the AVIStreamInfo function.
+ ///
+ /// Pointer to an AVISTREAMINFO structure to contain stream information.
+ /// Size, in bytes, of the structure specified by psi.
+ ///
+ ///
+ /// If the buffer allocated is too small for the structure, the Info method should fail the call by returning
+ /// AVIERR_BUFFERTOOSMALL. Otherwise, it should fill the structure and return its size.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-info HRESULT Info( AVISTREAMINFOW *psi, LONG lSize );
+ void Info(out AVISTREAMINFO psi, [In] int lSize);
+
+ ///
+ /// The FindSample method obtains the position in a stream of a key frame or a nonempty frame. Called when an application
+ /// uses the AVIStreamFindSample function.
+ ///
+ /// Position of the sample or frame.
+ ///
+ /// Applicable flags. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// FIND_ANY
+ /// Searches for a nonempty frame.
+ ///
+ /// -
+ /// FIND_FORMAT
+ /// Searches for a format change.
+ ///
+ /// -
+ /// FIND_KEY
+ /// Searches for a key frame.
+ ///
+ /// -
+ /// FIND_NEXT
+ /// Searches forward through a stream, beginning with the current frame.
+ ///
+ /// -
+ /// FIND_PREV
+ /// Searches backward through a stream, beginning with the current frame.
+ ///
+ ///
+ ///
+ /// The FIND_ANY, FIND_KEY, and FIND_FORMAT flags are mutually exclusive, as are the FIND_NEXT and FIND_PREV flags. You must
+ /// specify one value from each group.
+ ///
+ ///
+ /// Returns the location of the key frame corresponding to the frame specified by the application.
+ ///
+ /// If key frames are not significant in your custom format, return the position specified for lPos.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-findsample LONG FindSample( LONG lPos, LONG lFlags );
+ [PreserveSig]
+ int FindSample([In] int lPos, [In] FINDF lFlags);
+
+ ///
+ /// The ReadFormat method obtains format information from a stream. Fills and returns a structure with the data in an
+ /// application-defined buffer. If no buffer is supplied, determines the buffer size needed to retrieve the buffer of format
+ /// data. Called when an application uses the AVIStreamReadFormat function.
+ ///
+ /// Position of the sample or frame.
+ ///
+ /// Pointer to the buffer for the format data. Specify NULL to request the required size of the buffer.
+ ///
+ ///
+ /// Pointer to a buffer that receives the size, in bytes, of the buffer specified by lpFormat. When this method is called, the
+ /// contents of this parameter indicates the size of the buffer specified by lpFormat. When this method returns control to the
+ /// application, the contents of this parameter specifies the amount of data read or the required size of the buffer.
+ ///
+ ///
+ ///
+ /// The type of data stored in a stream dictates the format information and the structure that contains the format information.
+ /// A stream handler should return all applicable format information in this structure, including palette information when the
+ /// format uses a palette. A stream handler should not return stream data with the structure.
+ ///
+ ///
+ /// Standard video stream handlers provide format information in a BITMAPINFOHEADER structure. Standard audio stream
+ /// handlers provide format information in a PCMWAVEFORMAT structure. Other data streams can use other structures that
+ /// describe the stream data.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-readformat HRESULT ReadFormat( LONG lPos, LPVOID
+ // lpFormat, LONG *lpcbFormat );
+ void ReadFormat([In] int lPos, [Out, Optional] IntPtr lpFormat, ref int lpcbFormat);
+
+ ///
+ /// The SetFormat method sets format information in a stream. Called when an application uses the AVIStreamSetFormat function.
+ ///
+ /// Pointer to the interface to a stream.
+ /// Pointer to the buffer for the format data.
+ /// Address containing the size, in bytes, of the buffer specified by lpFormat.
+ ///
+ ///
+ /// Standard video stream handlers provide format information in a BITMAPINFOHEADER structure. Standard audio stream
+ /// handlers provide format information in a PCMWAVEFORMAT structure. Other data streams can use other structures that
+ /// describe the stream data.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-setformat HRESULT SetFormat( LONG lPos, LPVOID
+ // lpFormat, LONG cbFormat );
+ void SetFormat([In] int lPos, [In] IntPtr lpFormat, [In] int cbFormat);
+
+ ///
+ /// The Read method reads data from a stream and copies it to an application-defined buffer. If no buffer is supplied, it
+ /// determines the buffer size needed to retrieve the next buffer of data. Called when an application uses the AVIStreamRead function.
+ ///
+ /// Starting sample or frame number to read.
+ /// Number of samples to read.
+ ///
+ /// Pointer to the application-defined buffer to contain the stream data. You can also specify NULL to request the
+ /// required size of the buffer. Many applications precede each read operation with a query for the buffer size to see how large
+ /// a buffer is needed.
+ ///
+ /// Size, in bytes, of the buffer specified by lpBuffer.
+ /// Pointer to a buffer that receives the number of bytes read.
+ /// Pointer to a buffer that receives the number of samples read.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-read HRESULT Read( LONG lStart, LONG lSamples,
+ // LPVOID lpBuffer, LONG cbBuffer, LONG *plBytes, LONG *plSamples );
+ void Read([In] int lStart, [In] int lSamples, [Out, Optional] IntPtr lpBuffer, [In] int cbBuffer, out int plBytes, out int plSamples);
+
+ /// The Write method writes data to a stream. Called when an application uses the AVIStreamWrite function.
+ /// Starting sample or frame number to write.
+ /// Number of samples to write.
+ /// Pointer to the buffer for the data.
+ /// Size, in bytes, of the buffer specified by lpBuffer.
+ ///
+ /// Applicable flags. The AVIF_KEYFRAME flag is defined and indicates that this frame contains all the information needed for a
+ /// complete image.
+ ///
+ /// Pointer to a buffer used to contain the number of samples written.
+ /// Pointer to a buffer that receives the number of bytes written.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-write HRESULT Write( LONG lStart, LONG lSamples,
+ // LPVOID lpBuffer, LONG cbBuffer, DWORD dwFlags, LONG *plSampWritten, LONG *plBytesWritten );
+ void Write([In] int lStart, [In] int lSamples, [In] IntPtr lpBuffer, [In] int cbBuffer, [In] AVIIF dwFlags, out int plSampWritten, out int plBytesWritten);
+
+ /// The Delete method deletes data from a stream.
+ /// Starting sample or frame number to delete.
+ /// Number of samples to delete.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-delete HRESULT Delete( LONG lStart, LONG lSamples );
+ void Delete([In] int lStart, [In] int lSamples);
+
+ ///
+ /// The ReadData method reads data headers of a stream. Called when an application uses the AVIStreamReadData function.
+ ///
+ /// Four-character code of the stream header to read.
+ /// Pointer to the buffer to contain the header data.
+ ///
+ /// Size, in bytes, of the buffer specified by lpBuffer. When this method returns control to the application, the contents of
+ /// this parameter specifies the amount of data read.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-readdata HRESULT ReadData( DWORD fcc, LPVOID lp,
+ // LONG *lpcb );
+ void ReadData([In] uint fcc, [Out, Optional] IntPtr lp, ref int lpcb);
+
+ ///
+ /// The WriteData method writes headers for a stream. Called when an application uses the AVIStreamWriteData function.
+ ///
+ /// Four-character code of the stream header to write.
+ /// Pointer to the buffer that contains the header data to write.
+ /// Size, in bytes, of the buffer specified by lpBuffer.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistream-writedata HRESULT WriteData( DWORD fcc, LPVOID lp,
+ // LONG cb );
+ void WriteData([In] uint fcc, [In] IntPtr lp, [In] int cb);
+ }
+
+ ///
+ /// The IAVIStreaming interface supports preparing open data streams for playback in streaming operations. Uses
+ /// IUnknown::QueryInterface, IUnknown::AddRef, IUnknown::Release in addition to the following custom methods:
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nn-vfw-iavistreaming
+ [PInvokeData("vfw.h", MSDNShortId = "NN:vfw.IAVIStreaming")]
+ [ComImport, Guid("00020022-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAVIStreaming
+ {
+ ///
+ /// The Begin method prepares for the streaming operation. Called when an application uses the AVIStreamBeginStreaming function.
+ ///
+ /// Starting frame for streaming.
+ /// Ending frame for streaming.
+ ///
+ /// Speed at which the file is read relative to its normal playback rate. Normal speed is 1000. Larger values indicate faster
+ /// speeds; smaller values indicate slower speeds.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistreaming-begin HRESULT Begin( LONG lStart, LONG lEnd, LONG
+ // lRate );
+ void Begin([In] int lStart, [In] int lEnd, [In] int lRate);
+
+ ///
+ /// The End method ends the streaming operation. Called when an application uses the AVIStreamEndStreaming function.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-iavistreaming-end HRESULT End();
+ void End();
+ };
+
+ //[ComImport, Guid("00020025-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ //public interface IAVIPersistFile : System.Runtime.InteropServices.ComTypes.IPersistFile
+ //{
+ // new void GetClassID(out Guid pClassID);
+ // new int IsDirty();
+ // new void Load(string pszFileName, int dwMode);
+ // new void Save(string pszFileName, bool fRemember);
+ // new void SaveCompleted(string pszFileName);
+ // new void GetCurFile(out string ppszFileName);
+ // void Reserved1();
+ //}
+ ///
+ /// The IGetFrame interface supports extracting, decompressing, and displaying individual frames from an open stream. Uses
+ /// IUnknown::QueryInterface, IUnknown::AddRef, IUnknown::Release in addition to the following custom methods:
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nn-vfw-igetframe
+ [PInvokeData("vfw.h", MSDNShortId = "NN:vfw.IGetFrame")]
+ [ComImport, Guid("00020023-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IGetFrame
+ {
+ ///
+ /// The GetFrame method retrieves a decompressed copy of a frame from a stream. Called when an application uses the
+ /// AVIStreamGetFrame function.
+ ///
+ /// Frame to copy and decompress.
+ /// Returns the address of the decompressed frame data.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-igetframe-getframe LPVOID GetFrame( LONG lPos );
+ [PreserveSig]
+ IntPtr GetFrame([In] int lPos);
+
+ ///
+ /// The Begin method prepares to extract and decompress copies of frames from a stream. Called when an application uses
+ /// the AVIStreamGetFrameOpen function.
+ ///
+ /// Starting frame for extracting and decompressing.
+ /// Ending frame for extracting and decompressing.
+ ///
+ /// Speed at which the file is read relative to its normal playback rate. Normal speed is 1000. Larger values indicate faster
+ /// speeds; smaller values indicate slower speeds.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-igetframe-begin HRESULT Begin( LONG lStart, LONG lEnd, LONG
+ // lRate );
+ void Begin([In] int lStart, [In] int lEnd, [In] int lRate);
+
+ ///
+ /// The End method ends frame extraction and decompression. Called when an application uses the AVIStreamGetFrameClose function.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-igetframe-end HRESULT End();
+ void End();
+
+ ///
+ /// The SetFormat method sets the decompressed image format of the frames being extracted and optionally provides a
+ /// buffer for the decompression operation.
+ ///
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure defining the decompressed image format. You can also specify NULL or the value
+ /// ((LPBITMAPINFOHEADER) 1)
+ /// for this parameter. NULL causes the decompressor to choose a format that is appropriate for editing (normally a
+ /// 24-bit image depth format). The value
+ /// ((LPBITMAPINFOHEADER) 1)
+ /// causes the decompressor to choose a format appropriate for the current display mode.
+ ///
+ ///
+ /// Pointer to a buffer to contain the decompressed image data. Specify NULL to have this method allocate a buffer.
+ ///
+ ///
+ /// The x-coordinate of the destination rectangle within the DIB specified by lpbi. This parameter is used when lpBits is not NULL.
+ ///
+ ///
+ /// The y-coordinate of the destination rectangle within the DIB specified by lpbi. This parameter is used when lpBits is not NULL.
+ ///
+ /// Width of the destination rectangle. This parameter is used when lpBits is not NULL.
+ /// Height of the destination rectangle. This parameter is used when lpBits is not NULL.
+ ///
+ ///
+ /// The x, y, dx, and dy parameters identify the portion of the bitmap specified by lpbi and lpBits that receives the
+ /// decompressed image.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/nf-vfw-igetframe-setformat HRESULT SetFormat( LPBITMAPINFOHEADER lpbi,
+ // LPVOID lpBits, int x, int y, int dx, int dy );
+ void SetFormat(in Gdi32.BITMAPINFOHEADER lpbi, [In, Optional] IntPtr lpBits, [In] int x, [In] int y, [In] int dx, [In] int dy);
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.MCI.cs b/PInvoke/Multimedia/Vfw.MCI.cs
new file mode 100644
index 00000000..8f3a3153
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.MCI.cs
@@ -0,0 +1,331 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.WinMm;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the Vfw32.dll
+ public static partial class Vfw32
+ {
+ /*
+ CAPCONTROLCALLBACK
+ CAPERRORCALLBACKA
+ CAPERRORCALLBACKW
+ CAPSTATUSCALLBACKA
+ CAPSTATUSCALLBACKW
+ CAPVIDEOCALLBACK
+ CAPWAVECALLBACK
+ CAPYIELDCALLBACK
+
+ IAVIEditStream
+ IAVIFile
+ IAVIStream
+ IAVIStreaming
+ IGetFrame
+
+ AVIBuildFilterA
+ AVIBuildFilterW
+ AVIClearClipboard
+ AVIFileAddRef
+ AVIFileCreateStream
+ AVIFileCreateStreamA
+ AVIFileCreateStreamW
+ AVIFileEndRecord
+ AVIFileExit
+ AVIFileGetStream
+ AVIFileInfo
+ AVIFileInfoA
+ AVIFileInfoW
+ AVIFileInit
+ AVIFileOpen
+ AVIFileOpenA
+ AVIFileOpenW
+ AVIFileReadData
+ AVIFileRelease
+ AVIFileWriteData
+ AVIGetFromClipboard
+ AVIMakeCompressedStream
+ AVIMakeFileFromStreams
+ AVIMakeStreamFromClipboard
+ AVIPutFileOnClipboard
+ AVISaveA
+ AVISaveOptions
+ AVISaveOptionsFree
+ AVISaveVA
+ AVISaveVW
+ AVISaveW
+ AVIStreamAddRef
+ AVIStreamBeginStreaming
+ AVIStreamCreate
+ AVIStreamDataSize
+ AVIStreamEnd
+ AVIStreamEndStreaming
+ AVIStreamEndTime
+ AVIStreamFindSample
+ AVIStreamFormatSize
+ AVIStreamGetFrame
+ AVIStreamGetFrameClose
+ AVIStreamGetFrameOpen
+ AVIStreamInfoA
+ AVIStreamInfoW
+ AVIStreamIsKeyFrame
+ AVIStreamLength
+ AVIStreamLengthTime
+ AVIStreamNearestKeyFrame
+ AVIStreamNearestKeyFrameTime
+ AVIStreamNearestSample
+ AVIStreamNearestSampleTime
+ AVIStreamNextKeyFrame
+ AVIStreamNextKeyFrameTime
+ AVIStreamNextSample
+ AVIStreamNextSampleTime
+ AVIStreamOpenFromFileA
+ AVIStreamOpenFromFileW
+ AVIStreamPrevKeyFrame
+ AVIStreamPrevKeyFrameTime
+ AVIStreamPrevSample
+ AVIStreamPrevSampleTime
+ AVIStreamRead
+ AVIStreamReadData
+ AVIStreamReadFormat
+ AVIStreamRelease
+ AVIStreamSampleSize
+ AVIStreamSampleToSample
+ AVIStreamSampleToTime
+ AVIStreamSetFormat
+ AVIStreamStart
+ AVIStreamStartTime
+ AVIStreamTimeToSample
+ AVIStreamWrite
+ AVIStreamWriteData
+ capCaptureAbort
+ capCaptureGetSetup
+ capCaptureSequence
+ capCaptureSequenceNoFile
+ capCaptureSetSetup
+ capCaptureSingleFrame
+ capCaptureSingleFrameClose
+ capCaptureSingleFrameOpen
+ capCaptureStop
+ capCreateCaptureWindowA
+ capCreateCaptureWindowW
+ capDlgVideoCompression
+ capDlgVideoDisplay
+ capDlgVideoFormat
+ capDlgVideoSource
+ capDriverConnect
+ capDriverDisconnect
+ capDriverGetCaps
+ capDriverGetName
+ capDriverGetVersion
+ capEditCopy
+ capFileAlloc
+ capFileGetCaptureFile
+ capFileSaveAs
+ capFileSaveDIB
+ capFileSetCaptureFile
+ capFileSetInfoChunk
+ capGetAudioFormat
+ capGetAudioFormatSize
+ capGetDriverDescriptionA
+ capGetDriverDescriptionW
+ capGetMCIDeviceName
+ capGetStatus
+ capGetUserData
+ capGetVideoFormat
+ capGetVideoFormatSize
+ capGrabFrame
+ capGrabFrameNoStop
+ capOverlay
+ capPaletteAuto
+ capPaletteManual
+ capPaletteOpen
+ capPalettePaste
+ capPaletteSave
+ capPreview
+ capPreviewRate
+ capPreviewScale
+ capSetAudioFormat
+ capSetCallbackOnCapControl
+ capSetCallbackOnError
+ capSetCallbackOnFrame
+ capSetCallbackOnStatus
+ capSetCallbackOnVideoStream
+ capSetCallbackOnWaveStream
+ capSetCallbackOnYield
+ capSetMCIDeviceName
+ capSetScrollPos
+ capSetUserData
+ capSetVideoFormat
+ CreateEditableStream
+ DrawDibBegin
+ DrawDibChangePalette
+ DrawDibClose
+ DrawDibDraw
+ DrawDibEnd
+ DrawDibGetBuffer
+ DrawDibGetPalette
+ DrawDibOpen
+ DrawDibProfileDisplay
+ DrawDibRealize
+ DrawDibSetPalette
+ DrawDibStart
+ DrawDibStop
+ DrawDibTime
+ DrawDibUpdate
+ EditStreamClone
+ EditStreamCopy
+ EditStreamCut
+ EditStreamPaste
+ EditStreamSetInfoA
+ EditStreamSetInfoW
+ EditStreamSetNameA
+ EditStreamSetNameW
+ GetOpenFileNamePreviewA
+ GetOpenFileNamePreviewW
+ GetSaveFileNamePreviewA
+ GetSaveFileNamePreviewW
+ ICAbout
+ ICClose
+ ICCompress
+ ICCompressBegin
+ ICCompressEnd
+ ICCompressGetFormat
+ ICCompressGetFormatSize
+ ICCompressGetSize
+ ICCompressorChoose
+ ICCompressorFree
+ ICCompressQuery
+ ICConfigure
+ ICDecompress
+ ICDecompressBegin
+ ICDecompressEnd
+ ICDecompressEx
+ ICDecompressExBegin
+ ICDecompressExEnd
+ ICDecompressExQuery
+ ICDecompressGetFormat
+ ICDecompressGetFormatSize
+ ICDecompressGetPalette
+ ICDecompressOpen
+ ICDecompressQuery
+ ICDecompressSetPalette
+ ICDraw
+ ICDrawBegin
+ ICDrawChangePalette
+ ICDrawEnd
+ ICDrawFlush
+ ICDrawGetTime
+ ICDrawOpen
+ ICDrawQuery
+ ICDrawRealize
+ ICDrawRenderBuffer
+ ICDrawSetTime
+ ICDrawStart
+ ICDrawStartPlay
+ ICDrawStop
+ ICDrawStopPlay
+ ICDrawSuggestFormat
+ ICDrawWindow
+ ICGetBuffersWanted
+ ICGetDefaultKeyFrameRate
+ ICGetDefaultQuality
+ ICGetDisplayFormat
+ ICGetInfo
+ ICGetState
+ ICGetStateSize
+ ICImageCompress
+ ICImageDecompress
+ ICInfo
+ ICInstall
+ ICLocate
+ ICOpen
+ ICOpenFunction
+ ICQueryAbout
+ ICQueryConfigure
+ ICRemove
+ ICSendMessage
+ ICSeqCompressFrame
+ ICSeqCompressFrameEnd
+ ICSeqCompressFrameStart
+ ICSetState
+ ICSetStatusProc
+ MCIWndCanConfig
+ MCIWndCanEject
+ MCIWndCanPlay
+ MCIWndCanRecord
+ MCIWndCanSave
+ MCIWndCanWindow
+ MCIWndChangeStyles
+ MCIWndClose
+ MCIWndCreateA
+ MCIWndCreateW
+ MCIWndDestroy
+ MCIWndEject
+ MCIWndEnd
+ MCIWndGetActiveTimer
+ MCIWndGetAlias
+ MCIWndGetDest
+ MCIWndGetDevice
+ MCIWndGetDeviceID
+ MCIWndGetEnd
+ MCIWndGetError
+ MCIWndGetFileName
+ MCIWndGetInactiveTimer
+ MCIWndGetLength
+ MCIWndGetMode
+ MCIWndGetPalette
+ MCIWndGetPosition
+ MCIWndGetPositionString
+ MCIWndGetRepeat
+ MCIWndGetSource
+ MCIWndGetSpeed
+ MCIWndGetStart
+ MCIWndGetStyles
+ MCIWndGetTimeFormat
+ MCIWndGetVolume
+ MCIWndGetZoom
+ MCIWndHome
+ MCIWndNew
+ MCIWndOpen
+ MCIWndOpenDialog
+ MCIWndOpenInterface
+ MCIWndPause
+ MCIWndPlay
+ MCIWndPlayFrom
+ MCIWndPlayFromTo
+ MCIWndPlayReverse
+ MCIWndPlayTo
+ MCIWndPutDest
+ MCIWndPutSource
+ MCIWndRealize
+ MCIWndRecord
+ MCIWndRegisterClass
+ MCIWndResume
+ MCIWndReturnString
+ MCIWndSave
+ MCIWndSaveDialog
+ MCIWndSeek
+ MCIWndSendString
+ MCIWndSetActiveTimer
+ MCIWndSetInactiveTimer
+ MCIWndSetOwner
+ MCIWndSetPalette
+ MCIWndSetRepeat
+ MCIWndSetSpeed
+ MCIWndSetTimeFormat
+ MCIWndSetTimers
+ MCIWndSetVolume
+ MCIWndSetZoom
+ MCIWndStep
+ MCIWndStop
+ MCIWndUseFrames
+ MCIWndUseTime
+ MCIWndValidateMedia
+ mmioFOURCC
+ StretchDIB
+ */
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.cap.cs b/PInvoke/Multimedia/Vfw.cap.cs
new file mode 100644
index 00000000..8f3a3153
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.cap.cs
@@ -0,0 +1,331 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.WinMm;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the Vfw32.dll
+ public static partial class Vfw32
+ {
+ /*
+ CAPCONTROLCALLBACK
+ CAPERRORCALLBACKA
+ CAPERRORCALLBACKW
+ CAPSTATUSCALLBACKA
+ CAPSTATUSCALLBACKW
+ CAPVIDEOCALLBACK
+ CAPWAVECALLBACK
+ CAPYIELDCALLBACK
+
+ IAVIEditStream
+ IAVIFile
+ IAVIStream
+ IAVIStreaming
+ IGetFrame
+
+ AVIBuildFilterA
+ AVIBuildFilterW
+ AVIClearClipboard
+ AVIFileAddRef
+ AVIFileCreateStream
+ AVIFileCreateStreamA
+ AVIFileCreateStreamW
+ AVIFileEndRecord
+ AVIFileExit
+ AVIFileGetStream
+ AVIFileInfo
+ AVIFileInfoA
+ AVIFileInfoW
+ AVIFileInit
+ AVIFileOpen
+ AVIFileOpenA
+ AVIFileOpenW
+ AVIFileReadData
+ AVIFileRelease
+ AVIFileWriteData
+ AVIGetFromClipboard
+ AVIMakeCompressedStream
+ AVIMakeFileFromStreams
+ AVIMakeStreamFromClipboard
+ AVIPutFileOnClipboard
+ AVISaveA
+ AVISaveOptions
+ AVISaveOptionsFree
+ AVISaveVA
+ AVISaveVW
+ AVISaveW
+ AVIStreamAddRef
+ AVIStreamBeginStreaming
+ AVIStreamCreate
+ AVIStreamDataSize
+ AVIStreamEnd
+ AVIStreamEndStreaming
+ AVIStreamEndTime
+ AVIStreamFindSample
+ AVIStreamFormatSize
+ AVIStreamGetFrame
+ AVIStreamGetFrameClose
+ AVIStreamGetFrameOpen
+ AVIStreamInfoA
+ AVIStreamInfoW
+ AVIStreamIsKeyFrame
+ AVIStreamLength
+ AVIStreamLengthTime
+ AVIStreamNearestKeyFrame
+ AVIStreamNearestKeyFrameTime
+ AVIStreamNearestSample
+ AVIStreamNearestSampleTime
+ AVIStreamNextKeyFrame
+ AVIStreamNextKeyFrameTime
+ AVIStreamNextSample
+ AVIStreamNextSampleTime
+ AVIStreamOpenFromFileA
+ AVIStreamOpenFromFileW
+ AVIStreamPrevKeyFrame
+ AVIStreamPrevKeyFrameTime
+ AVIStreamPrevSample
+ AVIStreamPrevSampleTime
+ AVIStreamRead
+ AVIStreamReadData
+ AVIStreamReadFormat
+ AVIStreamRelease
+ AVIStreamSampleSize
+ AVIStreamSampleToSample
+ AVIStreamSampleToTime
+ AVIStreamSetFormat
+ AVIStreamStart
+ AVIStreamStartTime
+ AVIStreamTimeToSample
+ AVIStreamWrite
+ AVIStreamWriteData
+ capCaptureAbort
+ capCaptureGetSetup
+ capCaptureSequence
+ capCaptureSequenceNoFile
+ capCaptureSetSetup
+ capCaptureSingleFrame
+ capCaptureSingleFrameClose
+ capCaptureSingleFrameOpen
+ capCaptureStop
+ capCreateCaptureWindowA
+ capCreateCaptureWindowW
+ capDlgVideoCompression
+ capDlgVideoDisplay
+ capDlgVideoFormat
+ capDlgVideoSource
+ capDriverConnect
+ capDriverDisconnect
+ capDriverGetCaps
+ capDriverGetName
+ capDriverGetVersion
+ capEditCopy
+ capFileAlloc
+ capFileGetCaptureFile
+ capFileSaveAs
+ capFileSaveDIB
+ capFileSetCaptureFile
+ capFileSetInfoChunk
+ capGetAudioFormat
+ capGetAudioFormatSize
+ capGetDriverDescriptionA
+ capGetDriverDescriptionW
+ capGetMCIDeviceName
+ capGetStatus
+ capGetUserData
+ capGetVideoFormat
+ capGetVideoFormatSize
+ capGrabFrame
+ capGrabFrameNoStop
+ capOverlay
+ capPaletteAuto
+ capPaletteManual
+ capPaletteOpen
+ capPalettePaste
+ capPaletteSave
+ capPreview
+ capPreviewRate
+ capPreviewScale
+ capSetAudioFormat
+ capSetCallbackOnCapControl
+ capSetCallbackOnError
+ capSetCallbackOnFrame
+ capSetCallbackOnStatus
+ capSetCallbackOnVideoStream
+ capSetCallbackOnWaveStream
+ capSetCallbackOnYield
+ capSetMCIDeviceName
+ capSetScrollPos
+ capSetUserData
+ capSetVideoFormat
+ CreateEditableStream
+ DrawDibBegin
+ DrawDibChangePalette
+ DrawDibClose
+ DrawDibDraw
+ DrawDibEnd
+ DrawDibGetBuffer
+ DrawDibGetPalette
+ DrawDibOpen
+ DrawDibProfileDisplay
+ DrawDibRealize
+ DrawDibSetPalette
+ DrawDibStart
+ DrawDibStop
+ DrawDibTime
+ DrawDibUpdate
+ EditStreamClone
+ EditStreamCopy
+ EditStreamCut
+ EditStreamPaste
+ EditStreamSetInfoA
+ EditStreamSetInfoW
+ EditStreamSetNameA
+ EditStreamSetNameW
+ GetOpenFileNamePreviewA
+ GetOpenFileNamePreviewW
+ GetSaveFileNamePreviewA
+ GetSaveFileNamePreviewW
+ ICAbout
+ ICClose
+ ICCompress
+ ICCompressBegin
+ ICCompressEnd
+ ICCompressGetFormat
+ ICCompressGetFormatSize
+ ICCompressGetSize
+ ICCompressorChoose
+ ICCompressorFree
+ ICCompressQuery
+ ICConfigure
+ ICDecompress
+ ICDecompressBegin
+ ICDecompressEnd
+ ICDecompressEx
+ ICDecompressExBegin
+ ICDecompressExEnd
+ ICDecompressExQuery
+ ICDecompressGetFormat
+ ICDecompressGetFormatSize
+ ICDecompressGetPalette
+ ICDecompressOpen
+ ICDecompressQuery
+ ICDecompressSetPalette
+ ICDraw
+ ICDrawBegin
+ ICDrawChangePalette
+ ICDrawEnd
+ ICDrawFlush
+ ICDrawGetTime
+ ICDrawOpen
+ ICDrawQuery
+ ICDrawRealize
+ ICDrawRenderBuffer
+ ICDrawSetTime
+ ICDrawStart
+ ICDrawStartPlay
+ ICDrawStop
+ ICDrawStopPlay
+ ICDrawSuggestFormat
+ ICDrawWindow
+ ICGetBuffersWanted
+ ICGetDefaultKeyFrameRate
+ ICGetDefaultQuality
+ ICGetDisplayFormat
+ ICGetInfo
+ ICGetState
+ ICGetStateSize
+ ICImageCompress
+ ICImageDecompress
+ ICInfo
+ ICInstall
+ ICLocate
+ ICOpen
+ ICOpenFunction
+ ICQueryAbout
+ ICQueryConfigure
+ ICRemove
+ ICSendMessage
+ ICSeqCompressFrame
+ ICSeqCompressFrameEnd
+ ICSeqCompressFrameStart
+ ICSetState
+ ICSetStatusProc
+ MCIWndCanConfig
+ MCIWndCanEject
+ MCIWndCanPlay
+ MCIWndCanRecord
+ MCIWndCanSave
+ MCIWndCanWindow
+ MCIWndChangeStyles
+ MCIWndClose
+ MCIWndCreateA
+ MCIWndCreateW
+ MCIWndDestroy
+ MCIWndEject
+ MCIWndEnd
+ MCIWndGetActiveTimer
+ MCIWndGetAlias
+ MCIWndGetDest
+ MCIWndGetDevice
+ MCIWndGetDeviceID
+ MCIWndGetEnd
+ MCIWndGetError
+ MCIWndGetFileName
+ MCIWndGetInactiveTimer
+ MCIWndGetLength
+ MCIWndGetMode
+ MCIWndGetPalette
+ MCIWndGetPosition
+ MCIWndGetPositionString
+ MCIWndGetRepeat
+ MCIWndGetSource
+ MCIWndGetSpeed
+ MCIWndGetStart
+ MCIWndGetStyles
+ MCIWndGetTimeFormat
+ MCIWndGetVolume
+ MCIWndGetZoom
+ MCIWndHome
+ MCIWndNew
+ MCIWndOpen
+ MCIWndOpenDialog
+ MCIWndOpenInterface
+ MCIWndPause
+ MCIWndPlay
+ MCIWndPlayFrom
+ MCIWndPlayFromTo
+ MCIWndPlayReverse
+ MCIWndPlayTo
+ MCIWndPutDest
+ MCIWndPutSource
+ MCIWndRealize
+ MCIWndRecord
+ MCIWndRegisterClass
+ MCIWndResume
+ MCIWndReturnString
+ MCIWndSave
+ MCIWndSaveDialog
+ MCIWndSeek
+ MCIWndSendString
+ MCIWndSetActiveTimer
+ MCIWndSetInactiveTimer
+ MCIWndSetOwner
+ MCIWndSetPalette
+ MCIWndSetRepeat
+ MCIWndSetSpeed
+ MCIWndSetTimeFormat
+ MCIWndSetTimers
+ MCIWndSetVolume
+ MCIWndSetZoom
+ MCIWndStep
+ MCIWndStop
+ MCIWndUseFrames
+ MCIWndUseTime
+ MCIWndValidateMedia
+ mmioFOURCC
+ StretchDIB
+ */
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/Multimedia/Vfw.cs b/PInvoke/Multimedia/Vfw.cs
new file mode 100644
index 00000000..c62ac5bc
--- /dev/null
+++ b/PInvoke/Multimedia/Vfw.cs
@@ -0,0 +1,1666 @@
+#pragma warning disable IDE1006 // Naming Styles
+
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.Gdi32;
+using static Vanara.PInvoke.WinMm;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the AviFil32.dll
+ public static partial class AviFil32
+ {
+ ///
+ public static readonly uint ckidAVIMAINHDR = MAKEFOURCC('a', 'v', 'i', 'h');
+
+ ///
+ public static readonly uint ckidAVINEWINDEX = MAKEFOURCC('i', 'd', 'x', '1');
+
+ ///
+ public static readonly uint ckidAVIPADDING = MAKEFOURCC('J', 'U', 'N', 'K');
+
+ ///
+ public static readonly uint ckidSTREAMFORMAT = MAKEFOURCC('s', 't', 'r', 'f');
+
+ ///
+ public static readonly uint ckidSTREAMHANDLERDATA = MAKEFOURCC('s', 't', 'r', 'd');
+
+ ///
+ public static readonly uint ckidSTREAMHEADER = MAKEFOURCC('s', 't', 'r', 'h');
+
+ ///
+ public static readonly uint ckidSTREAMNAME = MAKEFOURCC('s', 't', 'r', 'n');
+
+ ///
+ public static readonly ushort cktypeDIBbits = aviTWOCC('d', 'b');
+
+ ///
+ public static readonly ushort cktypeDIBcompressed = aviTWOCC('d', 'c');
+
+ ///
+ public static readonly ushort cktypePALchange = aviTWOCC('p', 'c');
+
+ ///
+ public static readonly ushort cktypeWAVEbytes = aviTWOCC('w', 'b');
+
+ ///
+ public static readonly uint formtypeAVI = MAKEFOURCC('A', 'V', 'I', ' ');
+
+ ///
+ public static readonly uint listtypeAVIHEADER = MAKEFOURCC('h', 'd', 'r', 'l');
+
+ ///
+ public static readonly uint listtypeAVIMOVIE = MAKEFOURCC('m', 'o', 'v', 'i');
+
+ ///
+ public static readonly uint listtypeAVIRECORD = MAKEFOURCC('r', 'e', 'c', ' ');
+
+ ///
+ public static readonly uint listtypeSTREAMHEADER = MAKEFOURCC('s', 't', 'r', 'l');
+
+ ///
+ public static readonly uint streamtypeAUDIO = MAKEFOURCC('a', 'u', 'd', 's');
+
+ ///
+ public static readonly uint streamtypeMIDI = MAKEFOURCC('m', 'i', 'd', 's');
+
+ ///
+ public static readonly uint streamtypeTEXT = MAKEFOURCC('t', 'x', 't', 's');
+
+ ///
+ public static readonly uint streamtypeVIDEO = MAKEFOURCC('v', 'i', 'd', 's');
+
+ /// Flags used for compression.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_2")]
+ [Flags]
+ public enum ICCOMPRESSF : uint
+ {
+ /// Input data should be treated as a key frame.
+ ICCOMPRESS_KEYFRAME = 0x00000001
+ }
+
+ /// Applicable flags.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_3")]
+ [Flags]
+ public enum ICCOMPRESSFRAMESF : uint
+ {
+ /// Padding is used with the frame.
+ ICCOMPRESSFRAMES_PADDING = 1
+ }
+
+ /// Applicable flags.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_5")]
+ [Flags]
+ public enum ICDECOMPRESSF : uint
+ {
+ ///
+ /// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
+ /// not draw the image.
+ ///
+ ICDECOMPRESS_HURRYUP = 0x80000000,
+
+ /// Screen is being updated or refreshed.
+ ICDECOMPRESS_UPDATE = 0x40000000,
+
+ /// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
+ ICDECOMPRESS_PREROLL = 0x20000000,
+
+ /// Current frame does not contain data and the decompressed image should be left the same.
+ ICDECOMPRESS_NULLFRAME = 0x10000000,
+
+ /// Current frame is not a key frame.
+ ICDECOMPRESS_NOTKEYFRAME = 0x08000000,
+ }
+
+ /// Flags from the AVI file index.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_8")]
+ [Flags]
+ public enum ICDRAWF : uint
+ {
+ /// Determines if the decompressor can handle the decompression. The driver does not actually decompress the data.
+ ICDRAW_QUERY = 0x00000001,
+
+ /// Draws the decompressed data on the full screen.
+ ICDRAW_FULLSCREEN = 0x00000002,
+
+ /// Draws the decompressed data to a window or a DC.
+ ICDRAW_HDC = 0x00000004,
+
+ /// Application can animate the palette.
+ ICDRAW_ANIMATE = 0x00000008,
+
+ /// Drawing is a continuation of the previous frame.
+ ICDRAW_CONTINUE = 0x00000010,
+
+ /// DC is off-screen.
+ ICDRAW_MEMORYDC = 0x00000020,
+
+ /// Current frame is being updated rather than played.
+ ICDRAW_UPDATING = 0x00000040,
+
+ /// Renders but does not draw the data.
+ ICDRAW_RENDER = 0x00000080,
+
+ /// Buffers this data off-screen; it will need to be updated.
+ ICDRAW_BUFFER = 0x00000100,
+
+ /// Data is buffered and not drawn to the screen. Use this flag for fastest decompression.
+ ICDRAW_HURRYUP = 0x80000000,
+
+ /// Updates the screen based on data previously received. In this case, lpData should be ignored.
+ ICDRAW_UPDATE = 0x40000000,
+
+ ///
+ /// Current frame of video occurs before playback should start. For example, if playback will begin on frame 10, and frame 0 is
+ /// the nearest previous key frame, frames 0 through 9 are sent to the driver with this flag set. The driver needs this data to
+ /// display frame 10 properly.
+ ///
+ ICDRAW_PREROLL = 0x20000000,
+
+ /// Current frame does not contain any data, and the previous frame should be redrawn.
+ ICDRAW_NULLFRAME = 0x10000000,
+
+ /// Current frame is not a key frame.
+ ICDRAW_NOTKEYFRAME = 0x08000000,
+ }
+
+ /// Applicable flags.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_11")]
+ public enum ICMF_COMPVARS
+ {
+ ///
+ /// Data in this structure is valid and has been manually entered. Set this flag before you call any function if you fill this
+ /// structure manually. Do not set this flag if you let ICCompressorChoose initialize this structure.
+ ///
+ ICMF_COMPVARS_VALID = 0x00000001
+ }
+
+ /// Applicable flags indicating why the driver is opened.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_0")]
+ public enum ICMODE
+ {
+ /// Driver is opened to compress data.
+ ICMODE_COMPRESS = 1,
+
+ /// Driver is opened to decompress data.
+ ICMODE_DECOMPRESS = 2,
+
+ ///
+ ICMODE_FASTDECOMPRESS = 3,
+
+ /// Driver is opened for informational purposes, rather than for compression.
+ ICMODE_QUERY = 4,
+
+ ///
+ ICMODE_FASTCOMPRESS = 5,
+
+ /// Device driver is opened to decompress data directly to hardware.
+ ICMODE_DRAW = 8,
+ }
+
+ /// Flags for VIDEOHDR
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.videohdr_tag")]
+ [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,
+ }
+
+ /// Applicable flags.
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_1")]
+ [Flags]
+ public enum VIDCF : uint
+ {
+ /// Driver supports quality values.
+ VIDCF_QUALITY = 0x0001,
+
+ /// Driver supports compressing to a frame size.
+ VIDCF_CRUNCH = 0x0002,
+
+ /// Driver supports inter-frame compression.
+ VIDCF_TEMPORAL = 0x0004,
+
+ ///
+ /// Driver is requesting to compress all frames. For information about compressing all frames, see the ICM_COMPRESS_FRAMES_INFO message.
+ ///
+ VIDCF_COMPRESSFRAMES = 0x0008,
+
+ /// Driver supports drawing.
+ VIDCF_DRAW = 0x0010,
+
+ ///
+ /// Driver can perform temporal compression and maintains its own copy of the current frame. When compressing a stream of frame
+ /// data, the driver doesn't need image data from the previous frame.
+ ///
+ VIDCF_FASTTEMPORALC = 0x0020,
+
+ ///
+ /// Driver can perform temporal decompression and maintains its own copy of the current frame. When decompressing a stream of
+ /// frame data, the driver doesn't need image data from the previous frame.
+ ///
+ VIDCF_FASTTEMPORALD = 0x0080,
+ }
+
+ ///
+ /// 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 AVSTREAMMASTER AVStreamMaster;
+ }
+
+ ///
+ /// The COMPVARS structure describes compressor settings for functions such as ICCompressorChoose, ICSeqCompressFrame, and ICCompressorFree.
+ ///
+ ///
+ /// You can let ICCompressorChoose fill the contents of this structure or you can do it manually. If you manually fill the
+ /// structure, you must provide information for the following members: cbSize, hic, lpbiOut, lKey, and
+ /// lQ. Also, you must set the ICMF_COMPVARS_VALID flag in the dwFlags member.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-compvars typedef struct { LONG cbSize; DWORD dwFlags; HIC hic;
+ // DWORD fccType; DWORD fccHandler; LPBITMAPINFO lpbiIn; LPBITMAPINFO lpbiOut; LPVOID lpBitsOut; LPVOID lpBitsPrev; LONG lFrame;
+ // LONG lKey; LONG lDataRate; LONG lQ; LONG lKeyCount; LPVOID lpState; LONG cbState; } COMPVARS, *PCOMPVARS;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_11")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct COMPVARS
+ {
+ ///
+ /// Size, in bytes, of this structure. This member must be set to validate the structure before calling any function using this structure.
+ ///
+ public int cbSize;
+
+ ///
+ /// Applicable flags. The following value is defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICMF_COMPVARS_VALID
+ ///
+ /// Data in this structure is valid and has been manually entered. Set this flag before you call any function if you fill this
+ /// structure manually. Do not set this flag if you let ICCompressorChoose initialize this structure.
+ ///
+ ///
+ ///
+ ///
+ public ICMF_COMPVARS dwFlags;
+
+ ///
+ /// Handle to the compressor to use. You can open a compressor and obtain a handle of it by using the ICOpen function. You can
+ /// also choose a compressor by using ICCompressorChoose. ICCompressorChoose opens the chosen compressor and returns the
+ /// handle of the compressor in this member. You can close the compressor by using ICCompressorFree.
+ ///
+ public HIC hic;
+
+ /// Type of compressor used. Currently only ICTYPE_VIDEO (VIDC) is supported. This member can be set to zero.
+ public uint fccType;
+
+ ///
+ /// Four-character code of the compressor. Specify NULL to indicate the data is not to be recompressed. Specify "DIB" to
+ /// indicate the data is an uncompressed, full frame. You can use this member to specify which compressor is selected by default
+ /// when the dialog box is displayed.
+ ///
+ public uint fccHandler;
+
+ /// Reserved; do not use.
+ public IntPtr lpbiIn;
+
+ ///
+ /// Pointer to a BITMAPINFO structure containing the image output format. You can specify a specific format to use or you can
+ /// specify NULL to use the default compressor associated with the input format. You can also set the image output format
+ /// by using ICCompressorChoose.
+ ///
+ public IntPtr lpbiOut;
+
+ /// Reserved; do not use.
+ public IntPtr lpBitsOut;
+
+ /// Reserved; do not use.
+ public IntPtr lpBitsPrev;
+
+ /// Reserved; do not use.
+ public int lFrame;
+
+ ///
+ /// Key-frame rate. Specify an integer to indicate the frequency that key frames are to occur in the compressed sequence or zero
+ /// to not use key frames. You can also let ICCompressorChoose set the key-frame rate selected in the dialog box. The
+ /// ICSeqCompressFrameStart function uses the value of this member for making key frames.
+ ///
+ public int lKey;
+
+ ///
+ /// Data rate, in kilobytes per second. ICCompressorChoose copies the selected data rate from the dialog box to this member.
+ ///
+ public int lDataRate;
+
+ ///
+ /// Quality setting. Specify a quality setting of 1 to 10,000 or specify ICQUALITY_DEFAULT to use the default quality
+ /// setting. You can also let ICCompressorChoose set the quality value selected in the dialog box. ICSeqCompressFrameStart uses
+ /// the value of this member as its quality setting.
+ ///
+ public int lQ;
+
+ /// Reserved; do not use.
+ public int lKeyCount;
+
+ /// Reserved; do not use.
+ public IntPtr lpState;
+
+ /// Reserved; do not use.
+ public int cbState;
+ }
+
+ ///
+ /// The DRAWDIBTIME structure contains elapsed timing information for performing a set of DrawDib operations. The DrawDibTime
+ /// function resets the count and the elapsed time value for each operation each time it is called.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-drawdibtime typedef struct { LONG timeCount; LONG timeDraw; LONG
+ // timeDecompress; LONG timeDither; LONG timeStretch; LONG timeBlt; LONG timeSetDIBits; } DRAWDIBTIME, *LPDRAWDIBTIME;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_12")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DRAWDIBTIME
+ {
+ ///
+ /// Number of times the following operations have been performed since DrawDibTime was last called:
+ ///
+ /// -
+ /// Draw a bitmap on the screen.
+ ///
+ /// -
+ /// Decompress a bitmap.
+ ///
+ /// -
+ /// Dither a bitmap.
+ ///
+ /// -
+ /// Stretch a bitmap.
+ ///
+ /// -
+ /// Transfer bitmap data by using the BitBlt function.
+ ///
+ /// -
+ /// Transfer bitmap data by using the SetDIBits function.
+ ///
+ ///
+ ///
+ public int timeCount;
+
+ /// Time to draw bitmaps.
+ public int timeDraw;
+
+ /// Time to decompress bitmaps.
+ public int timeDecompress;
+
+ /// Time to dither bitmaps.
+ public int timeDither;
+
+ /// Time to stretch bitmaps.
+ public int timeStretch;
+
+ /// Time to transfer bitmaps by using the BitBlt function.
+ public int timeBlt;
+
+ /// Time to transfer bitmaps by using the SetDIBits function.
+ public int timeSetDIBits;
+ }
+
+ /// Provides a handle to an image decompressor.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HIC : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HIC(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HIC NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HIC h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HIC(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HIC h1, HIC h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HIC h1, HIC h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HIC h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// The ICCOMPRESS structure contains compression parameters used with the ICM_COMPRESS message.
+ ///
+ /// Drivers that perform temporal compression use data from the previous frame (found in the lpbiPrev and lpPrev
+ /// members) to prune redundant data from the current frame.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-iccompress typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
+ // lpbiOutput; LPVOID lpOutput; LPBITMAPINFOHEADER lpbiInput; LPVOID lpInput; LPDWORD lpckid; LPDWORD lpdwFlags; LONG lFrameNum;
+ // DWORD dwFrameSize; DWORD dwQuality; LPBITMAPINFOHEADER lpbiPrev; LPVOID lpPrev; } ICCOMPRESS;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_2")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICCOMPRESS
+ {
+ ///
+ /// Flags used for compression. The following value is defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICCOMPRESS_KEYFRAME
+ /// Input data should be treated as a key frame.
+ ///
+ ///
+ ///
+ public ICCOMPRESSF dwFlags;
+
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure containing the output (compressed) format. The biSizeImage member must
+ /// contain the size of the compressed data.
+ ///
+ public IntPtr lpbiOutput;
+
+ /// Pointer to the buffer where the driver should write the compressed data.
+ public IntPtr lpOutput;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the input (uncompressed) format.
+ public IntPtr lpbiInput;
+
+ /// Pointer to the buffer containing input data.
+ public IntPtr lpInput;
+
+ ///
+ /// Address to contain the chunk identifier for data in the AVI file. If the value of this member is not NULL, the driver
+ /// should specify a two-character code for the chunk identifier corresponding to the chunk identifier used in the AVI file.
+ ///
+ public uint lpckid;
+
+ ///
+ /// Address to contain flags for the AVI index. If the returned frame is a key frame, the driver should set the
+ /// AVIIF_KEYFRAME flag.
+ ///
+ public uint lpdwFlags;
+
+ /// Number of the frame to compress.
+ public int lFrameNum;
+
+ ///
+ /// Desired maximum size, in bytes, for compressing this frame. The size value is used for compression methods that can make
+ /// tradeoffs between compressed image size and image quality. Specify zero for this member to use the default setting.
+ ///
+ public uint dwFrameSize;
+
+ /// Quality setting.
+ public uint dwQuality;
+
+ ///
+ /// Pointer to a BITMAPINFOHEADER structure containing the format of the previous frame, which is typically the same as the
+ /// input format.
+ ///
+ public IntPtr lpbiPrev;
+
+ /// Pointer to the buffer containing input data of the previous frame.
+ public IntPtr lpPrev;
+ }
+
+ /// The ICCOMPRESSFRAMES structure contains compression parameters used with the ICM_COMPRESS_FRAMES_INFO message.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-iccompressframes typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
+ // lpbiOutput; LPARAM lOutput; LPBITMAPINFOHEADER lpbiInput; LPARAM lInput; LONG lStartFrame; LONG lFrameCount; LONG lQuality; LONG
+ // lDataRate; LONG lKeyRate; DWORD dwRate; DWORD dwScale; DWORD dwOverheadPerFrame; DWORD dwReserved2; LONG( )(LPARAM lInput,LONG
+ // lFrame,LPVOID lpBits,LONG len) *GetData; LONG( )(LPARAM lOutput,LONG lFrame,LPVOID lpBits,LONG len) *PutData; } ICCOMPRESSFRAMES;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_3")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICCOMPRESSFRAMES
+ {
+ ///
+ /// Applicable flags. The following value is defined: ICCOMPRESSFRAMES_PADDING. If this value is used, padding is used
+ /// with the frame.
+ ///
+ public ICCOMPRESSFRAMESF dwFlags;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the output format.
+ public IntPtr lpbiOutput;
+
+ /// Reserved; do not use.
+ public IntPtr lOutput;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the input format.
+ public IntPtr lpbiInput;
+
+ /// Reserved; do not use.
+ public IntPtr lInput;
+
+ /// Number of the first frame to compress.
+ public int lStartFrame;
+
+ /// Number of frames to compress.
+ public int lFrameCount;
+
+ /// Quality setting.
+ public int lQuality;
+
+ /// Maximum data rate, in bytes per second.
+ public int lDataRate;
+
+ /// Maximum number of frames between consecutive key frames.
+ public int lKeyRate;
+
+ ///
+ /// Compression rate in an integer format. To obtain the rate in frames per second, divide this value by the value in dwScale.
+ ///
+ public uint dwRate;
+
+ /// Value used to scale dwRate to frames per second.
+ public uint dwScale;
+
+ /// Reserved; do not use.
+ public uint dwOverheadPerFrame;
+
+ /// Reserved; do not use.
+ public uint dwReserved2;
+ }
+
+ /// The ICDECOMPRESS structure contains decompression parameters used with the ICM_DECOMPRESS message.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdecompress typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
+ // lpbiInput; LPVOID lpInput; LPBITMAPINFOHEADER lpbiOutput; LPVOID lpOutput; DWORD ckid; } ICDECOMPRESS;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_5")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICDECOMPRESS
+ {
+ ///
+ /// Applicable flags. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICDECOMPRESS_HURRYUP
+ ///
+ /// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
+ /// not draw the image.
+ ///
+ ///
+ /// -
+ /// ICDECOMPRESS_NOTKEYFRAME
+ /// Current frame is not a key frame.
+ ///
+ /// -
+ /// ICDECOMPRESS_NULLFRAME
+ /// Current frame does not contain data and the decompressed image should be left the same.
+ ///
+ /// -
+ /// ICDECOMPRESS_PREROLL
+ /// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
+ ///
+ /// -
+ /// ICDECOMPRESS_UPDATE
+ /// Screen is being updated or refreshed.
+ ///
+ ///
+ ///
+ public ICDECOMPRESSF dwFlags;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the input format.
+ public IntPtr lpbiInput;
+
+ /// Pointer to a buffer containing the input data.
+ public IntPtr lpInput;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the output format.
+ public IntPtr lpbiOutput;
+
+ /// Pointer to a buffer where the driver should write the decompressed image.
+ public IntPtr lpOutput;
+
+ /// Chunk identifier from the AVI file.
+ public uint ckid;
+ }
+
+ /// The ICDECOMPRESSEX structure contains decompression parameters used with the ICM_DECOMPRESSEX message
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdecompressex typedef struct { DWORD dwFlags; LPBITMAPINFOHEADER
+ // lpbiSrc; LPVOID lpSrc; LPBITMAPINFOHEADER lpbiDst; LPVOID lpDst; int xDst; int yDst; int dxDst; int dyDst; int xSrc; int ySrc;
+ // int dxSrc; int dySrc; } ICDECOMPRESSEX;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_6")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICDECOMPRESSEX
+ {
+ ///
+ /// Applicable flags. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICDECOMPRESS_HURRYUP
+ ///
+ /// Tries to decompress at a faster rate. When an application uses this flag, the driver should buffer the decompressed data but
+ /// not draw the image.
+ ///
+ ///
+ /// -
+ /// ICDECOMPRESS_NOTKEYFRAME
+ /// Current frame is not a key frame.
+ ///
+ /// -
+ /// ICDECOMPRESS_NULLFRAME
+ /// Current frame does not contain data and the decompressed image should be left the same.
+ ///
+ /// -
+ /// ICDECOMPRESS_PREROLL
+ /// Current frame precedes the point in the movie where playback starts and, therefore, will not be drawn.
+ ///
+ /// -
+ /// ICDECOMPRESS_UPDATE
+ /// Screen is being updated or refreshed.
+ ///
+ ///
+ ///
+ public ICDECOMPRESSF dwFlags;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the input format.
+ public IntPtr lpbiSrc;
+
+ /// Pointer to a buffer containing the input data.
+ public IntPtr lpSrc;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the output format.
+ public IntPtr lpbiDst;
+
+ /// Pointer to a buffer where the driver should write the decompressed image.
+ public IntPtr lpDst;
+
+ /// The x-coordinate of the destination rectangle within the DIB specified by lpbiDst.
+ public int xDst;
+
+ /// The y-coordinate of the destination rectangle within the DIB specified by lpbiDst.
+ public int yDst;
+
+ /// Width of the destination rectangle.
+ public int dxDst;
+
+ /// Height of the destination rectangle.
+ public int dyDst;
+
+ /// The x-coordinate of the source rectangle within the DIB specified by lpbiSrc.
+ public int xSrc;
+
+ /// The y-coordinate of the source rectangle within the DIB specified by lpbiSrc.
+ public int ySrc;
+
+ /// Width of the source rectangle.
+ public int dxSrc;
+
+ /// Height of the source rectangle.
+ public int dySrc;
+ }
+
+ ///
+ /// The ICDRAW structure contains parameters for drawing video data to the screen. This structure is used with the ICM_DRAW message.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdraw typedef struct { DWORD dwFlags; LPVOID lpFormat; LPVOID
+ // lpData; DWORD cbData; LONG lTime; } ICDRAW;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_8")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct ICDRAW
+ {
+ ///
+ /// Flags from the AVI file index. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICDRAW_HURRYUP
+ /// Data is buffered and not drawn to the screen. Use this flag for fastest decompression.
+ ///
+ /// -
+ /// ICDRAW_NOTKEYFRAME
+ /// Current frame is not a key frame.
+ ///
+ /// -
+ /// ICDRAW_NULLFRAME
+ /// Current frame does not contain any data, and the previous frame should be redrawn.
+ ///
+ /// -
+ /// ICDRAW_PREROLL
+ ///
+ /// Current frame of video occurs before playback should start. For example, if playback will begin on frame 10, and frame 0 is
+ /// the nearest previous key frame, frames 0 through 9 are sent to the driver with this flag set. The driver needs this data to
+ /// display frame 10 properly.
+ ///
+ ///
+ /// -
+ /// ICDRAW_UPDATE
+ /// Updates the screen based on data previously received. In this case, lpData should be ignored.
+ ///
+ ///
+ ///
+ public ICDRAWF dwFlags;
+
+ /// Pointer to a structure containing the data format. For video streams, this is a BITMAPINFOHEADER structure.
+ public IntPtr lpFormat;
+
+ /// Pointer to the data to render.
+ public IntPtr lpData;
+
+ /// Number of data bytes to render.
+ public uint cbData;
+
+ /// Time, in samples, when this data should be drawn. For video data this is normally a frame number.
+ public int lTime;
+ }
+
+ /// The ICDRAWBEGIN structure contains decompression parameters used with the ICM_DRAW_BEGIN message.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdrawbegin typedef struct { DWORD dwFlags; HPALETTE hpal; HWND
+ // hwnd; HDC hdc; int xDst; int yDst; int dxDst; int dyDst; LPBITMAPINFOHEADER lpbi; int xSrc; int ySrc; int dxSrc; int dySrc; DWORD
+ // dwRate; DWORD dwScale; } ICDRAWBEGIN;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_7")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICDRAWBEGIN
+ {
+ ///
+ /// Applicable flags. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICDRAW_ANIMATE
+ /// Application can animate the palette.
+ ///
+ /// -
+ /// ICDRAW_BUFFER
+ /// Buffers this data off-screen; it will need to be updated.
+ ///
+ /// -
+ /// ICDRAW_CONTINUE
+ /// Drawing is a continuation of the previous frame.
+ ///
+ /// -
+ /// ICDRAW_FULLSCREEN
+ /// Draws the decompressed data on the full screen.
+ ///
+ /// -
+ /// ICDRAW_HDC
+ /// Draws the decompressed data to a window or a DC.
+ ///
+ /// -
+ /// ICDRAW_MEMORYDC
+ /// DC is off-screen.
+ ///
+ /// -
+ /// ICDRAW_QUERY
+ /// Determines if the decompressor can handle the decompression. The driver does not actually decompress the data.
+ ///
+ /// -
+ /// ICDRAW_RENDER
+ /// Renders but does not draw the data.
+ ///
+ /// -
+ /// ICDRAW_UPDATING
+ /// Current frame is being updated rather than played.
+ ///
+ ///
+ ///
+ public ICDRAWF dwFlags;
+
+ /// Handle to the palette used for drawing.
+ public HPALETTE hpal;
+
+ /// Handle to the window used for drawing.
+ public HWND hwnd;
+
+ /// Handle to the DC used for drawing. Specify NULL to use a DC associated with the specified window.
+ public HDC hdc;
+
+ /// The x-coordinate of the destination rectangle.
+ public int xDst;
+
+ /// The y-coordinate of the destination rectangle.
+ public int yDst;
+
+ /// Width of the destination rectangle.
+ public int dxDst;
+
+ /// Height of the destination rectangle.
+ public int dyDst;
+
+ /// Pointer to a BITMAPINFOHEADER structure containing the input format.
+ public IntPtr lpbi;
+
+ /// The x-coordinate of the source rectangle.
+ public int xSrc;
+
+ /// The y-coordinate of the source rectangle.
+ public int ySrc;
+
+ /// Width of the source rectangle.
+ public int dxSrc;
+
+ /// Height of the source rectangle.
+ public int dySrc;
+
+ ///
+ /// Decompression rate in an integer format. To obtain the rate in frames per second, divide this value by the value in dwScale.
+ ///
+ public uint dwRate;
+
+ /// Value used to scale dwRate to frames per second.
+ public uint dwScale;
+ }
+
+ ///
+ /// The ICDRAWSUGGEST structure contains compression parameters used with the ICM_DRAW_SUGGESTFORMAT message to suggest an
+ /// appropriate input format.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icdrawsuggest typedef struct { LPBITMAPINFOHEADER lpbiIn;
+ // LPBITMAPINFOHEADER lpbiSuggest; int dxSrc; int dySrc; int dxDst; int dyDst; HIC hicDecompressor; } ICDRAWSUGGEST;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_9")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICDRAWSUGGEST
+ {
+ /// Pointer to the structure containing the compressed input format.
+ public IntPtr lpbiIn;
+
+ /// Pointer to a buffer to return a compatible input format for the renderer.
+ public IntPtr lpbiSuggest;
+
+ /// Width of the source rectangle.
+ public int dxSrc;
+
+ /// Height of the source rectangle.
+ public int dySrc;
+
+ /// Width of the destination rectangle.
+ public int dxDst;
+
+ /// Height of the destination rectangle.
+ public int dyDst;
+
+ /// Handle to a decompressor that supports the format of data described in lpbiIn.
+ public HIC hicDecompressor;
+ }
+
+ ///
+ /// The ICINFO structure contains compression parameters supplied by a video compression driver. The driver fills or updates
+ /// the structure when it receives the ICM_GETINFO message.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icinfo typedef struct { DWORD dwSize; DWORD fccType; DWORD
+ // fccHandler; DWORD dwFlags; DWORD dwVersion; DWORD dwVersionICM; WCHAR szName[16]; WCHAR szDescription[128]; WCHAR szDriver[128];
+ // } ICINFO;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_1")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct ICINFO
+ {
+ /// Size, in bytes, of the ICINFO structure.
+ public uint dwSize;
+
+ ///
+ /// Four-character code indicating the type of stream being compressed or decompressed. Specify "VIDC" for video streams.
+ ///
+ public uint fccType;
+
+ /// A four-character code identifying a specific compressor.
+ public uint fccHandler;
+
+ ///
+ /// Applicable flags. Zero or more of the following flags can be set:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// VIDCF_COMPRESSFRAMES
+ ///
+ /// Driver is requesting to compress all frames. For information about compressing all frames, see the ICM_COMPRESS_FRAMES_INFO message.
+ ///
+ ///
+ /// -
+ /// VIDCF_CRUNCH
+ /// Driver supports compressing to a frame size.
+ ///
+ /// -
+ /// VIDCF_DRAW
+ /// Driver supports drawing.
+ ///
+ /// -
+ /// VIDCF_FASTTEMPORALC
+ ///
+ /// Driver can perform temporal compression and maintains its own copy of the current frame. When compressing a stream of frame
+ /// data, the driver doesn't need image data from the previous frame.
+ ///
+ ///
+ /// -
+ /// VIDCF_FASTTEMPORALD
+ ///
+ /// Driver can perform temporal decompression and maintains its own copy of the current frame. When decompressing a stream of
+ /// frame data, the driver doesn't need image data from the previous frame.
+ ///
+ ///
+ /// -
+ /// VIDCF_QUALITY
+ /// Driver supports quality values.
+ ///
+ /// -
+ /// VIDCF_TEMPORAL
+ /// Driver supports inter-frame compression.
+ ///
+ ///
+ ///
+ public VIDCF dwFlags;
+
+ /// Version number of the driver.
+ public uint dwVersion;
+
+ /// Version of VCM supported by the driver. This member should be set to ICVERSION.
+ public uint dwVersionICM;
+
+ ///
+ /// Short version of the compressor name. The name in the null-terminated string should be suitable for use in list boxes.
+ ///
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
+ public string szName;
+
+ /// Long version of the compressor name.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
+ public string szDescription;
+
+ /// Name of the module containing VCM compression driver. Normally, a driver does not need to fill this out.
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
+ public string szDriver;
+ }
+
+ ///
+ /// The ICOPEN structure contains information about the data stream being compressed or decompressed, the version number of
+ /// the driver, and how the driver is used.
+ ///
+ ///
+ /// This structure is passed to video capture drivers when they are opened. This allows a single installable driver to function as
+ /// either an installable compressor or a video capture device. By examining the fccType member of the ICOPEN
+ /// structure, the driver can determine its function. For example, a fccType value of "VIDC" indicates that it is opened as
+ /// an installable video compressor.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icopen typedef struct { DWORD dwSize; DWORD fccType; DWORD
+ // fccHandler; DWORD dwVersion; DWORD dwFlags; LRESULT dwError; LPVOID pV1Reserved; LPVOID pV2Reserved; DWORD dnDevNode; } ICOPEN;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_0")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICOPEN
+ {
+ /// Size, in bytes, of the structure.
+ public uint dwSize;
+
+ ///
+ /// Four-character code indicating the type of stream being compressed or decompressed. Specify "VIDC" for video streams.
+ ///
+ public uint fccType;
+
+ /// Four-character code identifying a specific compressor.
+ public uint fccHandler;
+
+ /// Version of the installable driver interface used to open the driver.
+ public uint dwVersion;
+
+ ///
+ /// Applicable flags indicating why the driver is opened. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// ICMODE_COMPRESS
+ /// Driver is opened to compress data.
+ ///
+ /// -
+ /// ICMODE_DECOMPRESS
+ /// Driver is opened to decompress data.
+ ///
+ /// -
+ /// ICMODE_DRAW
+ /// Device driver is opened to decompress data directly to hardware.
+ ///
+ /// -
+ /// ICMODE_QUERY
+ /// Driver is opened for informational purposes, rather than for compression.
+ ///
+ ///
+ ///
+ public ICMODE dwFlags;
+
+ ///
+ public IntPtr dwError;
+
+ /// Reserved; do not use.
+ public IntPtr pV1Reserved;
+
+ /// Reserved; do not use.
+ public IntPtr pV2Reserved;
+
+ /// Device node for plug and play devices.
+ public uint dnDevNode;
+ }
+
+ /// The ICSETSTATUSPROC structure contains status information used with the ICM_SET_STATUS_PROC message.
+ // https://docs.microsoft.com/en-us/windows/win32/api/vfw/ns-vfw-icsetstatusproc typedef struct { DWORD dwFlags; LPARAM lParam;
+ // LONG( )(LPARAM lParam,UINT message,LONG l) *Status; } ICSETSTATUSPROC;
+ [PInvokeData("vfw.h", MSDNShortId = "NS:vfw.__unnamed_struct_4")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct ICSETSTATUSPROC
+ {
+ /// Reserved; set to zero.
+ public uint dwFlags;
+
+ /// Parameter that contains a constant to pass to the status procedure.
+ public IntPtr lParam;
+ }
+
+ /// 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.
+ private readonly IntPtr dwReserved1;
+ private readonly IntPtr dwReserved2;
+ private readonly IntPtr dwReserved3;
+ private readonly IntPtr dwReserved4;
+ }
+
+ /*
+ CAPCONTROLCALLBACK
+ CAPERRORCALLBACKA
+ CAPERRORCALLBACKW
+ CAPSTATUSCALLBACKA
+ CAPSTATUSCALLBACKW
+ CAPVIDEOCALLBACK
+ CAPWAVECALLBACK
+ CAPYIELDCALLBACK
+
+ capCaptureAbort
+ capCaptureGetSetup
+ capCaptureSequence
+ capCaptureSequenceNoFile
+ capCaptureSetSetup
+ capCaptureSingleFrame
+ capCaptureSingleFrameClose
+ capCaptureSingleFrameOpen
+ capCaptureStop
+ capCreateCaptureWindowA
+ capCreateCaptureWindowW
+ capDlgVideoCompression
+ capDlgVideoDisplay
+ capDlgVideoFormat
+ capDlgVideoSource
+ capDriverConnect
+ capDriverDisconnect
+ capDriverGetCaps
+ capDriverGetName
+ capDriverGetVersion
+ capEditCopy
+ capFileAlloc
+ capFileGetCaptureFile
+ capFileSaveAs
+ capFileSaveDIB
+ capFileSetCaptureFile
+ capFileSetInfoChunk
+ capGetAudioFormat
+ capGetAudioFormatSize
+ capGetDriverDescriptionA
+ capGetDriverDescriptionW
+ capGetMCIDeviceName
+ capGetStatus
+ capGetUserData
+ capGetVideoFormat
+ capGetVideoFormatSize
+ capGrabFrame
+ capGrabFrameNoStop
+ capOverlay
+ capPaletteAuto
+ capPaletteManual
+ capPaletteOpen
+ capPalettePaste
+ capPaletteSave
+ capPreview
+ capPreviewRate
+ capPreviewScale
+ capSetAudioFormat
+ capSetCallbackOnCapControl
+ capSetCallbackOnError
+ capSetCallbackOnFrame
+ capSetCallbackOnStatus
+ capSetCallbackOnVideoStream
+ capSetCallbackOnWaveStream
+ capSetCallbackOnYield
+ capSetMCIDeviceName
+ capSetScrollPos
+ capSetUserData
+ capSetVideoFormat
+ MCIWndCanConfig
+ MCIWndCanEject
+ MCIWndCanPlay
+ MCIWndCanRecord
+ MCIWndCanSave
+ MCIWndCanWindow
+ MCIWndChangeStyles
+ MCIWndClose
+ MCIWndCreateA
+ MCIWndCreateW
+ MCIWndDestroy
+ MCIWndEject
+ MCIWndEnd
+ MCIWndGetActiveTimer
+ MCIWndGetAlias
+ MCIWndGetDest
+ MCIWndGetDevice
+ MCIWndGetDeviceID
+ MCIWndGetEnd
+ MCIWndGetError
+ MCIWndGetFileName
+ MCIWndGetInactiveTimer
+ MCIWndGetLength
+ MCIWndGetMode
+ MCIWndGetPalette
+ MCIWndGetPosition
+ MCIWndGetPositionString
+ MCIWndGetRepeat
+ MCIWndGetSource
+ MCIWndGetSpeed
+ MCIWndGetStart
+ MCIWndGetStyles
+ MCIWndGetTimeFormat
+ MCIWndGetVolume
+ MCIWndGetZoom
+ MCIWndHome
+ MCIWndNew
+ MCIWndOpen
+ MCIWndOpenDialog
+ MCIWndOpenInterface
+ MCIWndPause
+ MCIWndPlay
+ MCIWndPlayFrom
+ MCIWndPlayFromTo
+ MCIWndPlayReverse
+ MCIWndPlayTo
+ MCIWndPutDest
+ MCIWndPutSource
+ MCIWndRealize
+ MCIWndRecord
+ MCIWndRegisterClass
+ MCIWndResume
+ MCIWndReturnString
+ MCIWndSave
+ MCIWndSaveDialog
+ MCIWndSeek
+ MCIWndSendString
+ MCIWndSetActiveTimer
+ MCIWndSetInactiveTimer
+ MCIWndSetOwner
+ MCIWndSetPalette
+ MCIWndSetRepeat
+ MCIWndSetSpeed
+ MCIWndSetTimeFormat
+ MCIWndSetTimers
+ MCIWndSetVolume
+ MCIWndSetZoom
+ MCIWndStep
+ MCIWndStop
+ MCIWndUseFrames
+ MCIWndUseTime
+ MCIWndValidateMedia
+ */
+ }
+}
\ No newline at end of file
diff --git a/Vanara.sln b/Vanara.sln
index 208da09a..d6f1a2d0 100644
--- a/Vanara.sln
+++ b/Vanara.sln
@@ -313,6 +313,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CfgMgr32", "UnitTests\PInvo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.Lz32", "PInvoke\Lz32\Vanara.PInvoke.Lz32.csproj", "{553081F3-A380-44B4-94ED-E8CE510F3E96}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Multimedia", "PInvoke\Multimedia\Vanara.PInvoke.Multimedia.csproj", "{A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1021,6 +1023,12 @@ Global
{553081F3-A380-44B4-94ED-E8CE510F3E96}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
{553081F3-A380-44B4-94ED-E8CE510F3E96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{553081F3-A380-44B4-94ED-E8CE510F3E96}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1158,6 +1166,7 @@ Global
{17DE6265-EE0F-42E5-AE1A-7ACCDD8A45E8} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
{6F4649D2-CB4E-463A-A5DE-CCC3B0DBD07A} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{553081F3-A380-44B4-94ED-E8CE510F3E96} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
+ {A7936B0B-A16B-42A5-A6DA-5D00FA98EEDD} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}