在媒体会话暂停时绘画框架 [英] Painting frames while media session is paused

查看:144
本文介绍了在媒体会话暂停时绘画框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Media Foundation框架开发自定义视频播放器。
当前,我可以使用IMFMediaSession播放,暂停,停止或更改播放速率。
我还可以使用IMFSourceReader检索单个框架。

I'm working on a custom video player using the Media Foundation framework. Currently, I can play, pause, stop or change the rate of the playback using an IMFMediaSession. I can also retrieve a single frame using an IMFSourceReader.

我目前能够将框架(IMFSample)渲染到窗口区域(HWND),但是仅在媒体会话停止时。
我的目标是能够在媒体会话暂停时渲染框架。
(=使用源阅读器而不是媒体会话进行帧步进)

I am currently able to render a frame (IMFSample) to a window area (a HWND) but only when the media session is stopped. My goal is to be able to render a frame while the media session is paused. (= doing frame-stepping using a source reader and not the media session)

我正在使用GetDC,CreateBitmap,SelectObject和BitBlt渲染我的帧。
我尝试使用directd3d界面将其填充为纯色(我真的是Direct3d的新手,所以遵循了基础教程),但是没有用。
这是我的工作:使用MR_VIDEO_ACCELERATION_SERVICE检索IDirect3DDeviceManager9,执行OpenDeviceHandle,LockDevice,Clear,Begin / EndScene和Present。

I'm using GetDC, CreateBitmap, SelectObject and BitBlt to render my frame. I tried using directd3d interfaces to fill it with a solid color (I'm really new to direct3d so followed a basic tutorial) but it didn't work. Here is what I did : retrieving an IDirect3DDeviceManager9 with MR_VIDEO_ACCELERATION_SERVICE, doing OpenDeviceHandle, LockDevice, Clear, Begin/EndScene and Present.

这些调用都不会失败,但是我怀疑EVR仍在画最后一帧。
因此,基本上,我希望EVR在需要时停止重新粉刷其框架,当然,我需要重新启用其绘画过程。

None of these calls fail but I suspect the EVR is still painting the last frame. So basically, I want the EVR to stop repainting its frame when I want and of course, I need to re-enable its painting process.

任何想法怎么做 ?
谢谢

Any idea how to do that ? Thanks

推荐答案

我终于使它工作了。
如果您有兴趣,请执行以下操作:

I finally got it working. If you're interested, do the following:


  • 使用MFGetService从媒体会话中检索IMFVideoDisplayControl和IMFVideoMixerBitmap

  • 设置MFVideoAlphaBitmap结构并将其提供给IMFVideoMixerBitmap :: SetAlphaBitmap(在专用的MSDN页面上有一个有效的示例)

  • 调用IMFVideoDisplayControl :: RepaintVideo以更新输出

要隐藏先前的内容,请不要将Alpha设置为不透明。
调用IMFVideoMixerBitmap :: ClearAlphaBitmap以获取先前的内容。

To hide the previous content, don't set the alpha so that it's opaque. Call IMFVideoMixerBitmap::ClearAlphaBitmap to get the previous content back.

然后瞧瞧!

这篇关于在媒体会话暂停时绘画框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆