How to Change Directshow Filter Properties C++

DirectShow: how to change filter 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.

How can i Programmatically set a Directshow Filters' options?

The interface you're looking for is IAMStreamConfig on the source filter's output pin This lets you specify fps and height and width, etc. Even though the link is for the c++ version, IAMStreamConfig is available in C# as it is listed here.

Dynamically change filter value without Property Page

If you defined a COM interface to access your filter, all you need to do now is to declare the same interface (using the same GUIs) in C#/VB.Net or whatever .net language you are using. Then you can do a type cast of your filter to the new interface. Here is a C# example on how to declare such an interface:

using System.Runtime.InteropServices;

// Declare IMediaControl as a COM interface which
// derives from the IDispatch interface.
[Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface IMediaControl // cannot list any base interfaces here
{
// Note that the members of IUnknown and Interface are NOT
// listed here
//
void Run();

void Pause();

void Stop();

void GetState( [In] int msTimeout, [Out] out int pfs);

void RenderFile(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename);

void AddSourceFilter(
[In, MarshalAs(UnmanagedType.BStr)] string strFilename,
[Out, MarshalAs(UnmanagedType.Interface)] out object ppUnk);

[return : MarshalAs(UnmanagedType.Interface)]
object FilterCollection();

[return : MarshalAs(UnmanagedType.Interface)]
object RegFilterCollection();

void StopWhenReady();
}

EDIT:

About the issue with E_NOINTERFACE during casting, it looks like a threading problem.
1- Creating your filter with Activator is not a good idea, you should always allow your DS graph to create your filters, try using "enumarate filters" instead.
2- Verify that the treading model you are using for your filter is "Both".Read here and here for some more information.



Related Topics



Leave a reply



Submit