如何调试 c++ DirectShow过滤器
directshow 过滤器有哪些调试工具可用?目前,我有一个项目编译并注册视频源过滤器,然后在 GraphEdit 中设置图形。我在 Visual Studio 2008 中使用 C++。是否可以以任何方式将调试器附加到过滤器,以便设置断点、检查变量等?除此之外,有没有办法将诊断信息记录在我可以实时查看的地方?
What debugging tools are available for directshow filters? Presently, I have a project that compiles and registers a video source filter that I then setup a graph in GraphEdit. I am using c++ in visual studio 2008. Is it possible to get a debugger attached to the filter in any way where I could set break points, inspect variables, etc? Barring that is there a way to log diagnostic information somewhere that I can view in real time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
连接调试器应该没有问题。将 graphedt.exe 设置为过滤器的 Visual Studio 项目中的调试目标,您应该能够在代码中设置断点。如果您在这方面遇到困难,可能是因为某些解码器中的反调试逻辑 - 您必须避免使用它们。
您还可以通过记录交付及其时间戳和延迟来获取有用的调试信息。我发现做到这一点的最好方法是使用直通滤波器。 www.gdcl.co.uk/mobile(win32 和 win mobile)提供了一个类似的示例监视器过滤器,以源代码和二进制形式提供。
G
There should be no problem with attaching a debugger. Set graphedt.exe as the debug target in your filter's Visual Studio project and you should be able to set breakpoints in your code. If you're having difficulty with this, it might be because of the anti-debugging logic in some decoders — you'll have to avoid using those.
You can also get useful debug information by logging the deliveries and their timestamps and latency. The best way I find to do ths is to use a pass-through filter. There is an example monitor filter like this available in source and binary form from www.gdcl.co.uk/mobile (win32 and win mobile).
G
在调试版本中,DirectShow 基类已经包含由注册表项控制的灵活日志记录机制。基类本身使用这种机制来记录它们自己的操作。如果需要,应该可以修改基类,以便在诊断版本构建中可以使用日志记录。
一个简单的示例:
如果“TIMING”类别的日志记录级别设置为 >=1,则会生成以调用函数名称为前缀的日志输出。每个类别的日志记录级别在注册表中的以下项下配置。有一个“GLOBAL”子键用于所有过滤器的最低日志记录级别,还有一个子键用于按过滤器文件名进行额外日志记录。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectShow\Debug
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectShow\Debug(x64 Windows 上的 32 位代码)。
编辑每个过滤器的“LogToFile”键以指定日志记录目标。默认为“调试”(调试器输出),但也可以是“控制台”以记录到控制台窗口,或用于记录到的文件名。也可以添加其他类型的日志记录。
控制台选项对于无需调试器的实时监控特别方便。在我的系统上,如果控制台窗口尚未打开,基类将无法打开控制台窗口,因此我在 wxdebug.cpp 中添加了以下调整,以便在请求控制台输出时无条件打开控制台。
有关详细信息,请参阅 DirectShow 调试输出函数信息。
In a debug build, the DirectShow base classes already include a flexible logging mechanism controlled by registry keys. The base classes themselves use this mechanism to log their own operation. If required it should be possible to modify the base classes so that logging is available in a diagnostic release build.
A simple example:
This produces log output prefixed by the name of the calling function if the logging level for the 'TIMING' category is set to >=1. Logging levels for each category are configured in the registry under the key below. There is a 'GLOBAL' sub-key for the minimum logging level for all filters and sub-keys for extra logging by filter file name.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectShow\Debug
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectShow\Debug (32bit code on x64 Windows).
Edit the 'LogToFile' key for each filter to specify a logging destination. This defaults to 'Debug' (debugger output) but can also be 'Console' to log to a console window, or a file name to log to. Other types of logging could be added too.
The console option is particularly convenient for live monitoring without a debugger. On my system the base classes fail to open a console window if not already open so I added the following tweak in wxdebug.cpp to open a console unconditionally if console output is requested.
See DirectShow Debug Output Functions for further information.
用于分析过滤器之间的数据流的一些工具:
开源图形编辑器 GraphStudioNext 分析器过滤器(和分析器文件编写器)插入到两个感兴趣的过滤器之间时,将向您显示活动的可视日志。您现在需要自己构建它才能获得此功能。
Geraint Davie 的监视器过滤器 会将活动日志文件写入磁盘。
Some tools for analyzing data flow between filters:
Open source graph editor GraphStudioNext analyzer filter (and analyzer file writer) will show you a visual log of activity when inserted between two filters of interest. You'll need to build it yourself to get this feature for now.
Geraint Davie's monitor filter will write a log file of activity to disk.
调试实时应用程序的最佳方法是生成日志文件。如果你想实时查看日志信息,只需创建一个基于客户端服务器套接字的日志记录即可。例如,您的应用程序可以开始侦听端口。外部查看器应用程序(客户端)可以连接到该端口并开始实时接收日志信息。
The best way to debug real time apps is generating log files. If you want to view the log information in real time, just create a client server socket based logging. For example, your app can start listening to a port. An external viewer app (client) could connect to that port and starts receiving the log information in real time.