Modify the Grabber filter to work with Sample Grabber
I modified the grabber Directshow filter in MSDN sample.
This grabber is used in our WMINTF application.
The modification is as follows :
typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged);
the above code is changed as follows :
typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void* pInstanceData);
MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
}
class CSampleGrabber: public IGrabberSample
{
public:
HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :
HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
private:
// Newly added code...
void* m_pInstanceData;
};
SetCallback(SAMPLECALLBACK Callback,void* pInstanceData)
{
m_Callback = Callback;
m_pInstanceData = pInstanceData; //Newly added code
}
within the Grabber filter,
m_Callback( ) fn is called as follows :
HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged); //I modified this code as follows :
HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged,m_pInstanceData);
Afterwards I compiled the Grabber filter.
and copied the following code (Client's)grabber.h as follows:The user class argument is used...
Client must aware of the interface IGrabberSample .
This is done thru the client's grabber.h file.
class CGraph;
typedef HRESULT (CGraph::*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void *pInstanceData);
// We define the interface the app can use to program us
MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetAcceptedMediaType(
const AM_MEDIA_TYPE *pType) = 0;
virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType(
AM_MEDIA_TYPE *pType) = 0;
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
virtual HRESULT STDMETHODCALLTYPE SetDeliveryBuffer(
ALLOCATOR_PROPERTIES props,
BYTE *pBuffer) = 0;
};
This grabber is used in our WMINTF application.
The modification is as follows :
typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged);
the above code is changed as follows :
typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void* pInstanceData);
MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
}
class CSampleGrabber: public IGrabberSample
{
public:
HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :
HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
private:
// Newly added code...
void* m_pInstanceData;
};
SetCallback(SAMPLECALLBACK Callback,void* pInstanceData)
{
m_Callback = Callback;
m_pInstanceData = pInstanceData; //Newly added code
}
within the Grabber filter,
m_Callback( ) fn is called as follows :
HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged); //I modified this code as follows :
HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged,m_pInstanceData);
Afterwards I compiled the Grabber filter.
and copied the following code (Client's)grabber.h as follows:The user class argument is used...
Client must aware of the interface IGrabberSample .
This is done thru the client's grabber.h file.
class CGraph;
typedef HRESULT (CGraph::*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void *pInstanceData);
// We define the interface the app can use to program us
MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetAcceptedMediaType(
const AM_MEDIA_TYPE *pType) = 0;
virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType(
AM_MEDIA_TYPE *pType) = 0;
virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
virtual HRESULT STDMETHODCALLTYPE SetDeliveryBuffer(
ALLOCATOR_PROPERTIES props,
BYTE *pBuffer) = 0;
};
Labels: Directshow
0 Comments:
Post a Comment
<< Home