DontPanic DontPanic - 2 months ago 9
C++ Question

DirectShow Sample Filters: How to Use?

I'm trying to write a custom DS rendering filter. I decided to start from a sample filter provided with the SDK, namely "Dump". I can successfully build DUMP.DLL and associated files, but I can't figure out how to use it in my app.

It looks like IFilterMapper2->RegisterFilter might do it, but (IMHO) it's a monstrosity and the doc is minimalist. Also, I see nowhere to specify the DLL as the InProcServer, which I assume would be a requirement.

I also tried regsvr32 DUMP.DLL but I'm not sure if that helps.

I believe the answer must be simple, but I just don't see it. Any help will be greatly appreciated, especially code snipplets (academic discourses are not terribly helpful). Also, the best solution should be straight C++ (no third party packages or .NET stuff).

Thank in advance,

-John

Answer

Filters are not used standalone - they are a part of a pipeline, they communicate with other filters and with Filter Graph Manager.

Filters are indeed registered with IFilterMapper2::RegisterFilter call. Note that as this involves registry write under HKLM the registration has to take place with local administrator's elevated privileges.

In most cases, even though it does not need to happen exactly this way, this registration is a part of generic COM registration, done by regsvr32 or equivalent call. The DLL registration code typically does IFilterMapper2::RegisterFilter for filters it publishes.

In Dump sample, there is a AMovieDllRegisterServer2 call that handles it, with the help of g_Templates in the same file higher.

Once you registered a filter, it can be enumerated by applications. First thing you want to try out is SDK GraphEdit tool or its newer and more powerful open source replacement GraphStudioNext.

Ctrl+ F opens filter list where you can find yours and insert it into filter graph being built interactively. Then connect tpo other filters and run.

See Using GraphEdit on MSDN.

Comments