Hi guys,
I am trying to create an image filter for Directshow and want it to be connected automatically in Intelligent Connect mechanism.
The Directshow document say that:
4. If the filter graph contains any filters with unconnected input pins, the Filter Graph Manager tries them next. You can force the Render method to try a particular filter by adding that filter to the graph before calling Render.
I’ve tried to follow above direction but my transform filter is not get connected in the graph (Directshow not call any method of the filter except Stop).
The code to force **Directshow ** try connecting to my transform filter is:
CMyTranformFilter* myFilter = new CMyTranformFilter(NULL, &hr);
hr = g_pGraph->AddFilter(myFilter, L"My Transform filter");
// Render the preview pin on the video capture filter
// Use this instead of g_pGraph->RenderFile
hr = g_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
pSrcFilter, NULL, NULL);
Here is my transform filter:
Not any method below is getting called. Is my understanding is correct? What is the approach to get my filter involve in rendering process?
class CMyTranformFilter : public CTransformFilter
{
public:
CMyTranformFilter(__inout_opt LPUNKNOWN punk, HRESULT* hr) :
CTransformFilter("My Transform filter", punk, CLSID_MYTRANFORMFILTER)
{
}
~CMyTranformFilter() {
}
HRESULT Transform(IMediaSample * pIn, IMediaSample *pOut) {
return E_NOTIMPL;
}
// check if you can support mtIn
HRESULT CheckInputType(const CMediaType* mtIn) {
return E_NOTIMPL;
}
// check if you can support the transform from this input to this output
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut) {
return E_NOTIMPL;
}
// this goes in the factory template table to create new instances
// static CCOMObject * CreateInstance(__inout_opt LPUNKNOWN, HRESULT *);
// call the SetProperties function with appropriate arguments
HRESULT DecideBufferSize(
IMemAllocator * pAllocator,
__inout ALLOCATOR_PROPERTIES *pprop) {
return E_NOTIMPL;
}
// override to suggest OUTPUT pin media types
HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType) {
return E_NOTIMPL;
}
};