DirectShow的:如何改变滤波特性?特性、DirectShow

2023-09-04 04:00:27 作者:电玩少年.

我工作的一个应用程序,帮助用户配置自己的电视调谐器卡。基本上,用户选择一个设备,并且应用程序生成一图形文件(.GRF)< /一>作为输出。然而,也有少数的设置,用户应该能够改变。这些设置包括视频标准(PAL,NTSC,SECAM),视频输入(调谐器,复合材料,SVIDEO),依此类推。

I'm working on an application that helps users configure their TV tuner cards. Basically the user selects a device, and the application generates a graph file (.GRF) as output. However, there are a few settings the user should be able to change. These settings include the video standard (PAL, NTSC, SECAM), video input (Tuner, Composite, SVideo), and so on.

在GraphEdit中,这可以通过右键单击所需的过滤器来完成,并选择筛选器属性...。不过,我不知道如何实现在code一样的。

In GraphEdit this can be accomplished by right clicking the desired filter, and select "Filter Properties...". However, I have no clue how to achieve the same in code.

问题1 :在code如何更改的DirectShow过滤器性能

Question 1: How do I change properties of DirectShow filters in code?

由于我使用 ICaptureGraphBuilder2 :: RenderStream 建立我的图,我只是抱着引用源过滤器和渲染器。大多数属性我想是能够改变的被发现在其他滤波器,例如横梁滤波器,它是由RenderStream方法自动添加

Because I use ICaptureGraphBuilder2::RenderStream to build my graph, I'm only holding references to the source filter and renderer. Most of the properties I would like to be able to change are found on other filters, such as the crossbar filter, which is added automatically by the RenderStream method.

问2 :如何获得对其他过滤器在我的图,这样我就可以改变自己的属性。

Question 2: How do I obtain references to other filters in my graph, so I can change their properties?

注:我不会用 FindFilterByName 因为我的应用程序应该与大多数的电视调谐器卡的工作,每卡作为一个不同的名称。的

Note: I won't use FindFilterByName because my application is supposed to work with most of the TV tuner cards, and every card as a different name.

修改:我已经找到一种方法,通过的 EnumFilters 。然后我用 QueryFilterInfo 每个过滤器来查找它的名字。这比使用FindFilterByName不同的,因为我现在可以使用包含找某些词(如交叉开关)。不过,我已经在那里了横梁过滤器被命名为一个例子(... X条),所以我还在寻找一个更通用的方法来做到这一点。我希望我能找到的过滤器通过他们的类 ...

Edit: I have found a way to obtain a reference to these filters by enumerating through EnumFilters. I then use QueryFilterInfo on every filter to find it's name. This is different than using FindFilterByName, because I can now use Contains to find certain words (like "Crossbar"). However, I already have an example where the crossbar filter is named ("... Xbar"), so I'm still looking for a more generic way to do this. I wish I could find filters by their category...

顺便说一句,我目前使用的 DirectShow.Net库,但我相信这些办法应该是相同的,与C ++库。但是,我不完全理解C ++的语法,所以如果您正在计划发布(引用)一个code的例子,这将是一个很大的帮助,如果它是在C#或VB.NET。

By the way, I'm currently using the DirectShow.Net library, but I believe the approach should be the same as with the C++ library. However, I don't fully understand the C++ syntax, so if you are planning to post (a reference to) a code example, it would be a big help if it were in C# or VB.NET.

解决方案:见接受答案的评论。予需要强制转换属性需要改变,以它们各自的接口,它的过滤器。例如,横杆滤波器需要被浇铸到的 IAMCrossbar接口。有了这个接口现在我可以改变这一切横梁相关的属性。

Solution: See the accepted answers comments. I need to cast the filters which properties needs to be changed to their respective interface. For example, the crossbar filter needs to be casted to the IAMCrossbar interface. With this interface I can now change all crossbar related properties.

推荐答案

2 - EnumFilters 是正确的做法。你不应该相信的名字,因为他们完全是为了被开发者友好的能够轻松地在图形过滤器来区分的目的,但他们不答应在全球范围持续性和一致性。这同样适用于引脚名称。

2 - EnumFilters is the correct approach. You should not trust names, because they are solely for the purpose of being developer friendly to be easily able to distinguish between filters in the graph, but they are not promised to be globally persistent and consistent. The same applies to pin names.

1 - 原生API创建UI与属性页用的 OleCreatePropertyFrame 功能。另请参见显示一个过滤器的属性页的这一点。

1 - in native API you create UI with property pages with OleCreatePropertyFrame function. See also Displaying a Filter's Property Pages on this.

我不认为DirectShow.NET有一个包装过它,所以你需要通过P调用这个API /调用是这样的:C# :?如何使用directshow.net显示该对话框

I don't think DirectShow.NET has a wrapper over it, so you need to call this API via P/Invoke like this: C# : How to use directshow.net to show this dialog?

设置为特定的过滤器,并通过专用接口通常暴露,所以没有统一的访问。不过,如果过滤器支持加载从/保存成流,可以保存/以统一的方式恢复设置一次。该方法的GraphEdit节省/负载,.GRF文件。

Settings are filter specific and are typically exposed via private interfaces, so there is no uniform access. Still, if a filter supports loading from/saving into stream, you can save/restore settings at once in a uniform way. The way GraphEdit saves/loads with .GRF files.