On Tue Jun 25 21:06:23 2024 +0000, Nikolay Sivov wrote:
I think another important feature there was to make request on TransferVideoFrame(), and not automatically on ProcessSample(). I could be wrong about that. @besentv mentioned that media with audio+video streams does not start playing unless TransferVideoFrame() is called once, after which audio plays and I don't know what happens to the video. Or maybe requests are initiated by OnVideoStreamTick(), I don't recall now.
That's right, it's `OnVideoStreamTick`. I wrote a number of tests to understand what MFMediaEngine does, but I haven't included them here as they use `IMFMediaEngineExtension` (this is not implemented in Wine, hence I had to write a hack to run them). The tests enabled me to check when samples are requested. My understanding is: - there is a queue of two pending samples, and one sample that is used for presentation - repeated calls to `TransferVideoFrame` will always write the sample currently in use for presentation - if `OnVideoStreamTick` is called and: - the presentation clock has not passed a queued sample PTS, it will return `S_FALSE` and not request a new sample or update the presentation sample - the presentation clock has passed a queued sample PTS, it will return `S_OK`, promote that sample for presentation and request a new sample - the presentation clock has passed both queued sample PTS, it will return `S_OK`, silently drop the first sample, promote the second sample and request a new sample
I also noticed that if the queue is not full on receipt of a new sample (for example, one sample was dropped), another sample is requested automatically. This scenario appears to be the only time MFMediaEngine requests a new sample without being prompted by an user API call.