feat: Migrate to Media Foundation and get aot compatibility#179
feat: Migrate to Media Foundation and get aot compatibility#179OleRoss wants to merge 5 commits into
Conversation
|
@OleRoss Thanks for the PR! I think this is a great proposal. In particular, support for the Media Foundation API has long been identified as an issue. Would it be possible to split these changes into the following two parts?
MF API related: |
|
Hi @kekyo, I read your comments and understand your stance, but personally, I feel the complexity is not worth it in the long run. And if supporting an old TFM makes it difficult to implement substantial performance/DX improvements for new projects, I feel like it's time to drop some. But back to a solution to the actual issue: My issue right now is that my code is using GeneratedComInterface to generate the previously runtime-generated COM interfaces. And I see no way to easily guard this behind a As a solution, I can see that would be to support Media Foundation for >=
MacOS and Linux could just use conditional This would enable a much cleaner separation of concerns. I can also see a world where we use CsWin32 to generate bindings conditionally, depending on whether the source-generated COM wrappers are available. But they officially support |
Out of interest, since I am not regularly developing with older TFMs, why do I need an older SDK? I can compile |
Hi, I needed Native AOT (and trimming) compatibility for my Avalonia project. Unfortunately, this library does not provide AOT-compatible bindings. This is mainly due to
DllImportBoth can be solved, but require compromises:
DllImport,LibraryImportcan be used, which is only available for >=net7.0net8.0and above offer the capability to have source-generated com APIs.Additionally, to make life a bit easier, I decided to use the
Media FoundationAPIs instead ofDirectShow(the DirectShow APIs were already deprecated, and I felt like the COM API was a bit simpler).I only tested the Windows changes so far.
This PR shows how this refactor can be done, and I hope it can be upstreamed at some point. I already know that this will be difficult because of the following limitations:
net8.0and above.I am happy to continue working on this PR if you are interested in such a huge change.
Or, if you want to go a different way, feel free to close the PR/adjust it to your needs.
P.s.
The only way I can see to support all target frameworks is to add the com-generated APIs as a separate CaptureDevice Type (in addition to the existing DirectShow device) and use LibraryImport conditionally.
However, I felt like this was too much trouble to go through.
Fixes #136, #163