다음을 통해 공유


A Sample Transform Filter Declaration (Windows CE 5.0)

Send Feedback

This sample illustrates a true minimalist filter, which demonstrates the least you must implement for a filter. It uses the transform-inplace classes and derives its filter class from the CTransInPlaceFilter class.

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.

Member function Description
CreateInstance Needed by every filter so that it can be instantiated as a COM object.
GetSetupData Overrides CBaseFilter::GetSetupData and 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::Transform and does the main work of CNullNull, which in this case is nothing.
CheckInputType Overrides CTransInPlaceFilter::CheckInputType to verify the media type during connection, and in this case accepts any media type offered, because it simply passes it along to the next filter in line.

Note   GetSetupData is only required if you want your filter to be self-registering. However, because the base classes implement this behavior and it is easy to implement, it is good to include this in your base class.

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.