I am using Windows Media Foundation for creating video playing app.
I have created custom EVR mixer using the IMFTransform
interface and few of the other mandatory Interfaces as mentioned in the below link.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms701624(v=vs.85).aspx
I have created custom mixer as a DLL and also successful registered it.
Then I have added this custom mixer using below code in the EVR:
// Create the video renderer.
hr = MFCreateVideoRendererActivate(hVideoWindow, &pActivate);
// Add custom mixer
hr = pActivate->SetGUID(MF_ACTIVATE_CUSTOM_VIDEO_MIXER_CLSID, CLSID_CMyCustomMixerMFT);
EVR is calling required methods in my custom mixer, but at the end I am getting error MF_E_CANNOT_CREATE_SINK
.
For the custom mixer I am referring to MFT implementation of my mixer, I am referring to mft_grayscale
sample application from Windows media foundation samples. Most of the IMFTransform implementation is copied from this sample.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb970487%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
I am stuck on this error for long and not able to find way out with this issue.
** EDIT **
As per the documentation for the method STDMETHODIMP GetDeviceID(IID *pDeviceID)
If a mixer or presenter uses Direct3D 9, it must return the value IID_IDirect3DDevice9 in pDeviceID.
The EVR's default mixer and presenter both return this value.
If you write a custom mixer or presenter, it can return some other value.
However, the mixer and presenter must use matching device identifiers.
Custom mixer should return this value which matches with presenter. As I am implementing custom mixer in my code I am returning deviceID as IID_IDirect3DDevice9
.
Update
I have only one video stream with Audio and Video in it.
GetStreamLimits
- Input and Output stream limit set to 1
GetStreamIDs
- Input ID 0 and Output ID 0
AddInputStreams
- In my mixer I don't get call to this method
As Suggested I will use MFTrace for debugging.
Here is a possible way to implement a Custom Video Mixer wich works on Windows 7 and Microsoft MediaSession/Evr.
I discovered that dxva2 can be use with two NV12 stream format. Of course, we can't mix streams with alpha, but it works. My graphic driver tells me that the dxva2 substream can handle only AYUV/AI44, but NV12 works too (strangely). NV12 has no alpha, but we can show two videos (and perhaps more) if we don't superimposed them. I also discovered that CLSID_CColorConvertDMO failed to provide AYUV with a MediaSession/Evr and a Custom Video Mixer. The color conversion could be done in the Custom Video Mixer.
I will post code in several times, so be patient. It is hard to format code here. For some parts of the code, you will need common files from MFNode
Some interface simply return E_NOTIMPL, they are just here to check what Evr needs. So i ommited code where E_NOTIMPL is used.
The Custom Video Mixer class :
CustomVideoMixer.cpp :
CustomVideoMixer_Transform.cpp :
Finally, the EvrMediaSession code :
The rest of the code.
CustomVideoMixer_Attributes.cpp :
CustomVideoMixer_Type.cpp :
Dxva2 part :
Dxva2Manager.cpp :
You try inject customized code in form of
Mixer
into the object withIMFMediaSink
interface which is written by Microsoft and you have gotMF_E_CANNOT_CREATE_SINK
- error message which generalize any error into the MediaSink. This error can have hundred reasons. For such situation Microsoft developed a special tool -MFTrace
. It logs calls inner of code which is developed by Microsoft. Also, it is impossible recognize the reason of errors, because you have not presented your code. For example - how many stream limits you set into the methodGetStreamLimits
, or what ID you set into the methodGetStreamIDs
, or how code process call methodAddInputStreams
. OnlyIMFTransform
has 23 methods.You question has so small information that it is impossible recommend something useful.
Regards.