The engineering quality of most recent Microsoft’s work around Media Foundation is terrible. It surely passes some internal tests to make sure that software items meet requirements of the use cases required for internal products, but published work gives impression that there is noone left to care about API offerings to wide audience.
One new example of this is how H.265/HEVC video encoder implemented by respective Windows Store extension in mfh265enc.dll works.
I have been putting the component into existing code base in order to extend it with reference software video encoding, now in H.265/HEVC format. Hence, the stock software encoder regardless of its performance and qualtiy metrics.
Encoder started giving nonsensical exceptions and errors, in particular rejecting obviously valid input. Sorting out a few things, I started seeing the MFT producing
E_FAIL on the very first video frame it receives.
The suspected problem was (and there were not so many other things left) that output media type was set two times. Both calls were valid, with good arguments and before any payload processing. Second call supplied the same media type, all the same attributes EXACTLY. Both media type setting call were successful. The whole media type setting story did not produce any errors at the stage of handling streaming start messages.
Still the second call apparently ruined internal state because – and there can be no other explanation – of shitty quality of the MFT itself.
The code fragment that discards the second media type setting call at wrapping level gets the MFT back to processing. What can I say…