DirectShow filters : Setting the environment

Creating media player codec is a pain. All the COM based classes and interfaces of DirectShow are not intuitives, there are not enough samples, and the documentation of the whole thing is reduced to the strict minimum. I guess Microsoft planned a lot of good things to replace DirectShow under Vista, and thus, discontinued to maintain it. However, many people are still using XP, and as a professionnal, it is hard to ask your customer to upgrade to vista just because you use a component not supported on XP.

So this tutorial describes what needs to be done if you want to create a filter, regardless of the type of your filter (source, transform or render).

DirectShow

DirectShow was a part of the DirectX SDK, but then moved to the Platform SDK. And sadly, this SDK is not supported anymore by Microsoft. It was designed to work with Visual C++ 6, and needs a little refresh to work with Visual C++ 2005.

So we will see how to make everything ready to build a media player codec. Of course, you need to have a Visual C++ 2005 installed, and the Platform SDK.

Setting the working environment

First of all, let’s compile BaseClasses. BaseClasses is supposed to be a sample project from the PlatformSdk, but I cannot see how we can work on filters without using it. It contains all the base classes you will need to write a filter.

In order to compile it, click on StartMenu > Softwares >Microsoft Platform SDK for Windows Server 2003 SP1 > Open Build Environment Window, and then choose the appropriate environment for your machine. Start with the Debug version.

It will open a shell. Type :
cd samples\Multimedia\DirectShow\BaseClasses
nmake

You may get some errors. In this case, apply the following corrections:

in ctlutil.h, line 278
replace
operator=(LONG); by COARefTime& operator=(LONG);

in wxdebug.cpp, line 564
replace static g_dwLastRefresh = 0; by static int g_dwLastRefresh = 0;

in winutil.cpp line 2104
replace for (Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {
by
for (int Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {

in outputq.cpp line 636
add long iDone = 0;
before for (iDone = 0;iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);

When both the release and the debug version are compiled, move strmbasd.lib and strmbase.lib to the lib folder of the platform sdk home directory.

Now, open visual studio, click on Tools > Options, and add the platform SDK include and library path on the top of any existing path.

Leave a Reply

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