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 demonstrates 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.
Copy Code | |
---|---|
// 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::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, 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. |