#pragma warning disable IDE1006 // Naming Styles 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] GuidPtr 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] GuidPtr 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 Guid pclsidHandler, AVISAVECALLBACK lpfnCallback, int nStreams, IAVIStream pfile, in AVICOMPRESSOPTIONS lpOptions); /// 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] GuidPtr 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)] IntPtr[] plpOptions); /// 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 unsafe extern IntPtr AVISaveOptions(HWND hwnd, ICMF_CHOOSE uiFlags, int nStreams, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi, [In, Out] 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)] IntPtr[] 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 unsafe extern HRESULT AVISaveOptionsFree(int nStreams, 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)] IntPtr[] 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] GuidPtr pclsidHandler, AVISAVECALLBACK lpfnCallback, int nStreams, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] 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 unsafe extern HRESULT AVISaveV([MarshalAs(UnmanagedType.LPTStr)] string szFile, [In, Optional] Guid* pclsidHandler, AVISAVECALLBACK lpfnCallback, int nStreams, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAVIStream[] ppavi, [In, Out] 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] GuidPtr 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] GuidPtr 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, [In, Optional] 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; } }