smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

Missing function: MFEnumDeviceSources #22

Closed Steph55 closed 2 years ago

Steph55 commented 2 years ago

Thank you for your great project! However, it seems to be missing an important function of Media Foundations: MFEnumDeviceSources

Is it possible to add it?

It also appears to me that the second parameter of IMFAttributes.GetAllocatorSTring() should be an [out] parameter, unless I don't understand something there...

Thanks!

smourier commented 2 years ago

Hi,

IMFAttributes's GetAllocatedString() is defined as it should as the second parameter is marked as optional. You must allocate it on the heap using Marshal methods.

But you don't need that, you can use the IMFAttributesExtensions class that has all needed helpers.

Steph55 commented 2 years ago

Thank you very much for the missing function, and concerning GetAllocatedString()!

However, I'm not an expert in Marshalling, and I am stuck with the function you have added MFEnumDeviceSources(). How can we use the second parameter in C#, the triple pointer out IntPtr pppSourceActivate? I guess this is the hint I need to understand all the other functions...