简体   繁体   中英

DirectShow: how to change filter properties?

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.

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.

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

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.

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

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.

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 its 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 ...

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.

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 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 - in native API you create UI with property pages with OleCreatePropertyFrame function. See also Displaying a Filter's Property Pages on this.

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?

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.

2 - have you tried looking into the DeviceName provided by the filters IMoniker? I personally found it quite useful for blacklisting filters, and it seems you can tell a little bit about the device type through its IMoniker::DeviceName . I'm not sure if it's enough information for your needs, but it might be a start.

对于问题一,要“找到”自动插入的交叉过滤器,请使用 ICaptureGraphBuilder2::FindInterface 然后您可以显示其本机属性页“gui popup”(请参阅​​ Roman 的回答)并允许用户使用它来控制它,或者使用正常的crossbar 枚举/选择 API 以编程方式完成。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM