转载请标明是引用于 http://blog.csdn.net/chenyujing1234
例子代码:
http://www.rayfile.com/zh-cn/files/43c325a3-74b9-11e1-84a4-0015c55db73d/
1、添加CMyOutputStream类.
class CMyOutputStream : public CBaseOutputPin, public IAMStreamConfig, public IKsPropertySet { public: DECLARE_IUNKNOWN STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv); public: // IQualityControl implementations STDMETHODIMP Notify(IBaseFilter * pSender, Quality q); // IAMStreamConfig implementations HRESULT STDMETHODCALLTYPE SetFormat(AM_MEDIA_TYPE *pmt); HRESULT STDMETHODCALLTYPE GetFormat(AM_MEDIA_TYPE **ppmt); HRESULT STDMETHODCALLTYPE GetNumberOfCapabilities(int *piCount, int *piSize); HRESULT STDMETHODCALLTYPE GetStreamCaps(int iIndex, AM_MEDIA_TYPE **pmt, BYTE *pSCC); // IKsPropertySet implementations HRESULT STDMETHODCALLTYPE Set(REFGUID guidPropSet, DWORD dwID, void *pInstanceData, DWORD cbInstanceData, void *pPropData, DWORD cbPropData); HRESULT STDMETHODCALLTYPE Get(REFGUID guidPropSet, DWORD dwPropID, void *pInstanceData,DWORD cbInstanceData, void *pPropData, DWORD cbPropData, DWORD *pcbReturned); HRESULT STDMETHODCALLTYPE QuerySupported(REFGUID guidPropSet, DWORD dwPropID, DWORD *pTypeSupport); // CBaseOutputPin implementations CMyOutputStream(CMyFilter *pParent, CCritSec* pLock, HRESULT *phr, LPCWSTR pPinName); HRESULT DecideBufferSize(IMemAllocator *pIMemAlloc, ALLOCATOR_PROPERTIES *pProperties); HRESULT CheckMediaType(const CMediaType *pMediaType); HRESULT GetMediaType(int iPosition, CMediaType *pmt); HRESULT Active(); HRESULT Inactive(); HRESULT DeliverEndOfStream(); HRESULT DeliverBeginFlush(); HRESULT DeliverEndFlush(); HRESULT Deliver(IMediaSample* pSample); private: CMyFilter *m_pParent; COutputQueue* m_pOutputQ; };
2、在CMyFilter成员中添加CMyOutputStream* m_pOutput;
同时在构造函数中添加对它的初始它.
在CMyFilter::GetPin中return m_pOutput;
3、接下来就可以在CMyFilter中定义自己的业务函数,在函数中可以使用CMyOutputStream进行控制了.