Enumerating Capture Devices (MediaFoundation)
SuRGeoNix opened this issue · 4 comments
SuRGeoNix commented
Just wondering if you have this in your plans. I think it would fits for Vortice purpose.
I mainly interesting for this to enumerate audio/video capture devices.
Update: It seems I can use IMMDeviceEnumerator for at least audio capture devices
amerkoleci commented
Please open a discussion instead of issue:
SuRGeoNix commented
I found out that is possible with the newest Media Foundation API with MFEnumDeviceSources. So, probably not really required to add DirectShow. Sample:
var attrs = MediaFactory.MFCreateAttributes(1);
attrs.Set(CaptureDeviceAttributeKeys.SourceType, CaptureDeviceAttributeKeys.SourceTypeVidcap);
var res = MediaFactory.MFEnumDeviceSources(attrs, out IntPtr vidCapsPtr, out int capsCount);
IntPtr* ptrs = (IntPtr*)vidCapsPtr;
for (int i=0; i<capsCount; i++)
{
var capDevice = new IMFActivate(*ptrs);
System.Diagnostics.Debug.WriteLine(capDevice.Get(CaptureDeviceAttributeKeys.FriendlyName));
capDevice.Release();
ptrs++;
}
amerkoleci commented
b8ec149 added improvements in this scenario. I've added also example that enumerates Audio/Video capture devices:
SuRGeoNix commented
Nice one. Much cleaner now!