Microsoft Windows CE 3.0  

A Sample Transform Filter Declaration

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This sample illustrates a true minimalist filter, which does nothing except demonstrate the least you must implement for a filter. It uses the transform-inplace classes and derives its filter class from the CTransInPlaceFilterclass. Following is the class declaration for the derived filter class CNullNull.

// CNullNull // class CNullNull : public
CTransInPlaceFilter { public: static CUnknown
*CreateInstance(LPUNKNOWN punk, HRESULT *phr); DECLARE_IUNKNOWN;
LPAMOVIESETUP_FILTER GetSetupData() { return &sudNullNull; }
private: // Constructor. Just calls the base class constructor.
CNullNull(TCHAR *tszName, LPUNKNOWN punk, HRESULT *phr) :
CTransInPlaceFilter (tszName, punk, CLSID_NullNull, phr) { } //
Overrides the pure virtual Transform of CTransInPlaceFilter base
lass. // The "real work" of a transform is done by altering
*pSample. // The Null transform leaves it alone. HRESULT
Transform(IMediaSample *pSample){ return NOERROR; } // This filter
accepts any input type. // (It would return S_FALSE for any it did
not accept.) HRESULT CheckInputType(const CMediaType* mtIn) {
return S_OK; } };

This example illustrates the following basic member functions required in the base class.

Function Description
CreateInstance Needed by every filter so that it can be instantiated as a COM object.
GetSetupData Overrides CBaseFilter::GetSetupDataand is used to provide the class with information required to register this particular filter. In this case, it provides the address of a structure defined in the Nullnull.cpp file included in the SDK.
CNullNull Class constructor, which typically just calls the base class constructor.
Transform Overrides CTransInPlaceFilter::Transformand does the main work of CNullNull, which in this case is nothing.
CheckInputType Overrides CTransInPlaceFilter::CheckInputTypeto verify the media type during connection, and in this case accepts any media type offered, since it will simply pass it along to the next filter in line.

Note that, strictly speaking, GetSetupDatais required only if you want your filter to be self-registering. However, since the base classes implement this feature and it is easy to implement, it is a good idea to include this in your base class.



 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.