summaryrefslogtreecommitdiffstats
path: root/WhisperNet/API/iMediaFoundation.cs
blob: b8d74497d3382e01f512b6e919e8647cde7ec6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using ComLight;
using System.Runtime.InteropServices;
using Whisper.Internal;

namespace Whisper
{
	/// <summary>Exposes a small subset of MS Media Foundation framework.</summary>
	/// <remarks>That framework is a part of Windows OS, since Vista.</remarks>
	/// <seealso href="https://learn.microsoft.com/en-us/windows/win32/medfound/microsoft-media-foundation-sdk" />
	[ComInterface( "fb9763a5-d77d-4b6e-aff8-f494813cebd8", eMarshalDirection.ToManaged ), CustomConventions( typeof( NativeLogger ) )]
	public interface iMediaFoundation: IDisposable
	{
		/// <summary>Decode complete audio file into a new memory buffer.</summary>
		/// <returns>
		/// The method asks MF to resample and convert audio into the suitable type for the Whisper model.<br/>
		/// If the path is a video file, the method will decode the first audio track.
		/// </returns>
		[RetValIndex( 2 )]
		iAudioBuffer loadAudioFile( [MarshalAs( UnmanagedType.LPWStr )] string path, [MarshalAs( UnmanagedType.U1 )] bool stereo = false );

		/// <summary>Create a reader to stream the audio file from disk</summary>
		/// <returns>
		/// The method returns an object which can be used to decode the audio file incrementally.<br/>
		/// For long audio files, this saves both memory (no need for large uncompressed PCM buffer), and time (decode and transcribe run concurrently on different CPU threads).<br/>
		/// If the path is a video file, the implementation will use the first audio track.
		/// </returns>
		[RetValIndex( 2 )]
		iAudioReader openAudioFile( [MarshalAs( UnmanagedType.LPWStr )] string path, [MarshalAs( UnmanagedType.U1 )] bool stereo = false );

		/// <summary>List capture devices</summary>
		void listCaptureDevices( [MarshalAs( UnmanagedType.FunctionPtr )] pfnFoundCaptureDevices pfn, IntPtr pv );

		/// <summary>Open audio capture device</summary>
		[RetValIndex( 2 )]
		iAudioCapture openCaptureDevice( [MarshalAs( UnmanagedType.LPWStr )] string endpoint, [In] ref sCaptureParams captureParams );
	}
}