sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 638 forks source link

MeidaFoundation VideoPresenter #840

Closed proludio closed 5 years ago

proludio commented 7 years ago

To write a custom presenter for media foundation, you are required to implement the following interfaces

IMFClockStateSink IMFGetService IMFTopologyServiceLookupClient IMFVideoDeviceID IMFVideoPresenter

SharpDx.MediaFoundation has an interface for VideoPresenter. But instead of a method called "GetCurrentMediaType", it has a property called "CurrentMediaType".

It has an interface for IMFClockStateSink.

But, it has a class called "ServiceProvider", which matches "IMFGetService" And, it has a class called "IMFTopologyServiceLookupClient", which matches to "IMFTopologyServiceLookupClient" And, it has a class called "VideoDeviceID", which matches "IMFVideoDeviceID"

But because those are all classes, I cant have my one object inherit from all of them.

Anyone know how to get around this?

Wufflez commented 7 years ago

You may be better just implementing the interfaces using standard C# COM interop. Just be careful with lifetimes of your objects if you pass the native pointers from RCWs over to SharpDX. However, I must say (from experience) that it's far less of a headache to write your custom media foundation components in C++ and keep the managed side client only.

Oh, and if you plan on using your presenter with the EVR, then might have to wrap IMFVideoRenderer too, in order to inject the presenter into the renderer, because if I recall correctly SharpDX doesn't expose the 'InitializeRenderer' method.

xoofx commented 7 years ago

MediaFoundation was impossible to map entirely in .NET, a huge load of work... (It was initially done to just provide MediaEngine working on Windows Phone/Store Apps)...

So I agree with @Wufflez, if you have anything substantial to do with MediaFoundation better do it in a native library.