DirectShow filters : Setting the environment

GraphEdit

If you have to work with filters, GraphEdit will become your best friend, or your worst nightmare. This small tool is very handy to visualize and test your filters in a real graph.

However, if it’s your first installation, you may get some error while running graphedit. Particularly if you want to see the properties of a filter or a pin, you may get the following message:

To solve this issue, open a shell, and from the bin folder of the platform sdk, type:

regsvr32 proppage.dll

Your First Project

If you didn’t miss anything until now, your environment should be ready. Now it’s time to create your project. The easiest way is to create a Win32 Dll project.

In the “general” tab, set “Character Set” to MBCS instead of Unicode. (unless you modified the settings of streambase to support Unicode)
Right click on your freshly created project, and go to the “linker” page. In general, modify the extension of your binary from .dll to .ax.


Then, in the “input” section, set the “Additional Dependencies” as

quartz.lib vfw32.lib winmm.lib strmiids.lib gdi32.lib kernel32.lib strmbasd.lib in Debug, and
quartz.lib vfw32.lib winmm.lib strmiids.lib gdi32.lib kernel32.lib strmbase.lib in Release

DLL entry points

Let’s define our entry points. In your main dll source (.cpp), add

#include
#include
#include
#include
#include

#pragma warning(disable:4710) // ‘function’: function not inlined (optimzation)
STDAPI DllRegisterServer() { return AMovieDllRegisterServer2(TRUE); }
STDAPI DllUnregisterServer() { return AMovieDllRegisterServer2(FALSE); }
extern “C” BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}

And ultimately, add a .def file to your project, and fill it with:

LIBRARY "YourFilter.ax"

EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

That’s it. Now you are ready to start real coding. I’ll try to write some info about Writing a source filter, or a render filter later. Keep checking:-)

The samples

There are several samples provided with the Platform SDK. Among those, wavdest is particularly useful. If you followed this tutorial, you should be able to build them, but you may still experience difficulties to register the resulting .ax.

I recommend you to get the project file corresponding to the sample you want to build, and to check “Register the output” in the General tab of the linker’s options. It should help. The projects files are available on this page: http://tmhare.mvps.org/downloads.htm

Leave a Reply

Your email address will not be published. Required fields are marked *