文章转自 http://blog.csdn.net/bwmwm/article/details/4423067

·        Note   The legacy Video Renderer Filter always uses windowed mode. The VMR-7 and VMR-9 filters use windowed mode by default, but also support windowless mode.

  • Video Renderer Filter 总是使用windowed模式。VMR-7和VMR-9默认使用windowed模式,也支持windowless模式。

In windowed mode, the video renderer creates its own window where it paints the video frames. Unless you specify otherwise, this window is a top-level window with its own borders and title bar.  Most of the time, however, you will attach the video window to an application window, so that the video is integrated into your application UI. This requires the following steps:

在windowed模式中,video renderer创建一个属于自己的窗口,并在这个窗口上绘制视频帧。除非你指定其他的,否则这个窗口是一个拥有边看和标题栏的顶层窗口。不过,绝大多数情况下,你将视频窗口贴到程序窗口上,以至于视频合并到你的应用程序UI上。这样做需要以下步骤:

1.   Query for IVideoWindow.

2.   Set the parent window.

3.   Set new window styles.

4.   Position the video window inside the owner window.

5.   Notify the video window of WM_MOVE messages.

1.   询问IVideoWindow。

2.   设置父窗口

3.   设置新的窗口风格。

4.   把视频窗口放置在程序窗口上。

5.   通知视频窗口WM_MOVE消息。

Query for IVideoWindow

Before starting playback, query the Filter Graph Manager for the IVideoWindowinterface:

回放之前,向Filter Graph Manager询问IVideoWindow接口:

IVideoWindow *pVidWin = NULL;

pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);

Set the Parent Window

To set the parent window, call the IVideoWindow::put_Owner method with a handle to your application window. This method takes a variable of type OAHWND, so cast the handle to this type:

.调用IVideoWindow::put_Owner函数设置父窗口,参数就是父窗口的句柄。函数需要OAHWND类型的参数,所以要把句柄转换成这个类型:

pVidWin->put_Owner((OAHWND)hwnd);

Set New Window Styles

Change the style of the video window by calling the IVideoWindow::put_WindowStyle method:

调用IVideoWindow::put_WindowStyle函数改变视频窗口的风格:

pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);

The WS_CHILD flag sets the window to be a child window, and the WS_CLIPSIBLINGS flag prevents the window from drawing inside the client area of another child window.

WS_CHILD标记设置窗口为一个子窗口。WS_CLIPSIBLINGS标记防止画到其他窗口的客户区域。

Position the Video Window

To set the position of the video relative to the application window's client area, call the IVideoWindow::SetWindowPosition method. This method takes a rectangle that specifies the left edge, top edge, width, and height of the video window. For example, the following code stretches the video window to fit the entire client area of the parent window:

调用IVideoWindow::SetWindowPosition函数设置视频相对于应用程序窗口客户区域的位置。函数的参数代表视频窗口的左边,上边,宽和高。例如下面的代码拉伸视频窗口来适应整个父窗口的客户区域:

RECT rc;

GetClientRect(hwnd,& rc);

pVidWin->SetWindowPosition(0, 0, rc.right, rc.bottom);

To get the native size of the video, call the IBasicVideo::GetVideoSize method on the Filter Graph Manager. You can use that information to scale the video and keep the correct aspect ratio.

在Filter Graph Manager上调用IBasicVideo::GetVideoSize方法获得视频的原始大小。你可以使用这些信息来调整视频以保证正确的高宽比。

Respond to WM_MOVE Messages

For best performance, you should notify the video renderer whenever the window moves while the graph is paused. Call the IVideoWindow::NotifyOwnerMessage method to forward the WM_MOVE message:

为达到最佳效果,在graph暂停期间,只要窗口移动,就要通知video renderer。调用IVideoWindow::NotifyOwnerMessage函数发送WM_MOVE消息:

// (Inside your WindowProc)

case WM_MOVE:

pVidWin->NotifyOwnerMessage((OAHWND)hWnd, msg, wParam, lParam);

break;

If the renderer is using a hardware overlay, this notification causes the renderer to update the overlay position. (The VMR-9 does not use overlays, so you do not need to call this method if you are using the VMR-9.)

如果renderer使用了硬件overlay,这个通知消息就会导致renderer更新overlay的位置。(VMR-9没有使用overlay,所以如果使用VMR-9就不需要调用这个函数。)

Clean Up

Before the application exits, stop the graph and reset the video window's owner to NULL. Otherwise, window messages might be sent to the wrong window, which is likely to cause errors. Also, hide video window, or else you might see a video image flicker on the screen momentarily:

程序退出之前,停止graph并重新设置视频窗口的拥有者为NULL。否则,窗口消息将发送到错误的窗口,有可能产生错误。而且,隐藏视频窗口,否则可能会看到一个视频图像在屏幕上闪烁。

pControl->Stop();

pVidWin->put_Visible(OAFALSE);

pVidWin->put_Owner(NULL);

  • Note   If the parent of the video window is a child of your main application window (in other words, if the video window is a child of a child), you should create the video window using CoCreateInstance and add it to the graph, instead of letting the Filter Graph Manager add the video renderer during Intelligent Connect. This ensures that the video window and your child window are repainted at the same time. Otherwise, the child window may paint over the video window.
  • Note 如果视频窗口的父窗口是程序主窗口的子窗口(换句话说,如果视频窗口是子窗口的子窗口),你应该使用CoCreateInstance创建一个视频窗口,把它加入到graph中,而不是在智能连接的时候由Filter Graph Manager添加video renderer。这可以确保视频窗口和你的子窗口在同一时刻被重绘。否则,子窗口的绘制会覆盖掉视频窗口。

转载于:https://www.cnblogs.com/xuehuzaifei/p/3210402.html

【转】[DirectShow] 033 - Using Windowed Mode相关推荐

  1. [DirectShow] DirectShow的窗口

    DirectShow提供两种窗口模式:Windowed Mode 和 Windowless Mode. Windowed Mode:DS创建一个属于自己的窗口,在自己创建的窗口上显示视频.通过IVid ...

  2. Windows SDK 7.1 (包含directshow)安装配置

    最近一直在做毕业设计的事情,需要利用directshow进行视频开发,但是现在单独的directshow包已经没有了,从directx9.0c开始directshow和directx分开发布,现在的d ...

  3. 用DirectX Audio和DirectShow播放声音和音乐(1)

    音乐就是一系列的音符,这些音符在不同的时间用不同的幅度被播放或者停止.有非常多的指令被用来播放音乐,但是这些指令的操作基本相同,都在使用各种各样不同的音符.在计算机上进行作曲,实际上是存储了很多组音乐 ...

  4. 【转】FFmpeg获取DirectShow设备数据(摄像头,录屏)

    这两天研究了FFmpeg获取DirectShow设备数据的方法,在此简单记录一下以作备忘.本文所述的方法主要是对应Windows平台的. 1.       列设备 ffmpeg -list_devic ...

  5. DirectShow Filter 基础与简单的示例程序

    DirectShow 是一个 Windows 平台上的流媒体框架,提供了高质量的多媒体流采集和回放功能. Filter 实质是一个 COM 组件,所以学习开发 Filter 前你应该对 COM 相关知 ...

  6. DirectX和DirectShow介绍和区别

    1.DirectX是什么 DirectX是微软推出的一套基于Windows系统的多媒体应用程式接口APIs函式.在开发中,DX分为两个部分,一个是运行库,通过DX编译出来的程式必须要有运行库的支持,另 ...

  7. directshow c++ 设置 曝光_DirectShow 接口访问相机参数设置方法

    本文档适用于所有适用 directshow 接口访问相机的程序,例如 MATLAB和 Labview 的 ImaqDx 接口.Halcon 的 Directshow 接口等. MATLAB 中,可以通 ...

  8. 编译DirectShow Samples

    Windows SDK v7.0里包含有DirectShow相关的例子程序,好像是VS2003或VS2005的工程文件.因为没有直接安装Visual Studio开发工具,只是用SDK安装了VC9编译 ...

  9. 菜鸟学Linux 第033篇笔记 bootloader,inittab

    菜鸟学Linux 第033篇笔记 bootloader,inittab Linux 系统自启动流程 PC OS (Linux) POST-->BIOS(Boot Sequence)-->M ...

  10. DirectShow基础编程 最简单的源Filter的编写步骤 (转)

    转自: http://blog.csdn.net/bwmwm/article/details/5463852 1.创建一个空的Dll工程,添加5个空文件分别名为:MyOutputPin.h.MySou ...

最新文章

  1. 185.dubbo 后台管理系统
  2. OpenGL反射和折射
  3. layui下拉框往上显示跟往下显示_牛肉价格持续攀升,潮汕牛肉火锅下月或将调涨了...
  4. CVPR 2019 | 近日新出论文汇总(含视频目标分割、GAN、度量学习、高效语义分割等主题)...
  5. goland sql 脚本运行_Flink 1.9 实战:使用 SQL 读取 Kafka 并写入 MySQL
  6. L2TP-***通用原理取证及在华为防火墙上的实施
  7. MSB3644 找不到 .NETFramework,Version=v4.7 的引用程序集。要解决此问题,请为此框架版本安装......
  8. html的圆角效果,CSS3轻松实现圆角效果
  9. IDEA初学者 常用注解意思
  10. FPGA是什么呢,通透讲解单片机和FPGA的区别
  11. /* global $ xxxx */ eslint注释
  12. spring项目接入flyway(一) 背景、快速入门
  13. 精伦身份证阅读器php_华视CVR-100身份证阅读器BS开发包
  14. 迅雷链接转为普通链接(js实现)
  15. RK3288 开发板 运行android6.0.1 如何通过i2c_detect 侦测i2c 设备
  16. word 保存时 不能保存
  17. 多方安全计算(MPC)发展脉络及应用实践
  18. linux 创建分区 4t,centos对4T硬盘进行分区
  19. gym创建自己的强化学习环境env
  20. skylin TerraExplorer自定义飞行路线如何监听结束事件

热门文章

  1. 华为大数据客户端安装步骤
  2. 一元多项式的相加和相减操作(链表)
  3. quorum-maker中遇到的问题
  4. SIM800C音频设计指南
  5. 留言送书文末 | 20年磨一剑!南京大学周志华教授团队重磅新作出版
  6. 八卦一下 ,拉点流量
  7. python初级练习
  8. python古诗代码案例_一行代码竟然如此逆天?小码王python案例首次对外展现!
  9. 全向轮平台的旋转中心位置计算
  10. c语言生日快乐音乐程序,89S51演奏生日快乐的歌曲c程序