00001
00002
00003
00004
00005 #ifndef __ASYNCRDR_H__
00006 #define __ASYNCRDR_H__
00007
00008 class CAsyncReader;
00009
00010 class CAsyncOutputPin
00011 : public IAsyncReader,
00012 public CBasePin
00013 {
00014 protected:
00015 CAsyncReader* m_pReader;
00016 CAsyncIo * m_pIo;
00017
00018
00019
00020
00021
00022
00023 BOOL m_bQueriedForAsyncReader;
00024
00025 HRESULT InitAllocator(IMemAllocator **ppAlloc);
00026
00027 public:
00028
00029 CAsyncOutputPin(
00030 HRESULT * phr,
00031 CAsyncReader *pReader,
00032 CAsyncIo *pIo,
00033 CCritSec * pLock);
00034
00035 ~CAsyncOutputPin();
00036
00037
00038
00039
00040 DECLARE_IUNKNOWN
00041 STDMETHODIMP NonDelegatingQueryInterface(REFIID, void**);
00042
00043
00044 STDMETHODIMP Connect(
00045 IPin * pReceivePin,
00046 const AM_MEDIA_TYPE *pmt
00047 );
00048
00049
00050
00051
00052
00053 HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
00054
00055
00056 HRESULT CheckMediaType(const CMediaType* pType);
00057
00058
00059 HRESULT CheckConnect(IPin *pPin)
00060 {
00061 m_bQueriedForAsyncReader = FALSE;
00062 return CBasePin::CheckConnect(pPin);
00063 }
00064
00065
00066 HRESULT CompleteConnect(IPin *pReceivePin)
00067 {
00068 if (m_bQueriedForAsyncReader) {
00069 return CBasePin::CompleteConnect(pReceivePin);
00070 } else {
00071 #ifdef VFW_E_NO_TRANSPORT
00072 return VFW_E_NO_TRANSPORT;
00073 #else
00074 return E_FAIL;
00075 #endif
00076 }
00077 }
00078
00079
00080 HRESULT BreakConnect()
00081 {
00082 m_bQueriedForAsyncReader = FALSE;
00083 return CBasePin::BreakConnect();
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 STDMETHODIMP RequestAllocator(
00093 IMemAllocator* pPreferred,
00094 ALLOCATOR_PROPERTIES* pProps,
00095 IMemAllocator ** ppActual);
00096
00097
00098
00099
00100
00101
00102
00103
00104 STDMETHODIMP Request(
00105 IMediaSample* pSample,
00106 DWORD dwUser);
00107
00108
00109
00110
00111
00112
00113 STDMETHODIMP WaitForNext(
00114 DWORD dwTimeout,
00115 IMediaSample** ppSample,
00116 DWORD * pdwUser);
00117
00118
00119
00120
00121
00122 STDMETHODIMP SyncReadAligned(
00123 IMediaSample* pSample);
00124
00125
00126
00127
00128 STDMETHODIMP SyncRead(
00129 LONGLONG llPosition,
00130 LONG lLength,
00131 BYTE* pBuffer);
00132
00133
00134
00135
00136 STDMETHODIMP Length(
00137 LONGLONG* pTotal,
00138 LONGLONG* pAvailable);
00139
00140
00141
00142
00143 STDMETHODIMP BeginFlush(void);
00144 STDMETHODIMP EndFlush(void);
00145
00146 };
00147
00148 class CAsyncReader : public CBaseFilter
00149 {
00150
00151 protected:
00152
00153 CCritSec m_csFilter;
00154
00155
00156 CAsyncIo m_Io;
00157
00158
00159 CAsyncOutputPin m_OutputPin;
00160
00161
00162 CMediaType m_mt;
00163
00164 public:
00165
00166
00167
00168 CAsyncReader(
00169 TCHAR *pName,
00170 LPUNKNOWN pUnk,
00171 CAsyncStream *pStream,
00172 HRESULT *phr);
00173 ~CAsyncReader();
00174
00175
00176 int GetPinCount();
00177 CBasePin *GetPin(int n);
00178
00179
00180 const CMediaType *LoadType() const
00181 {
00182 return &m_mt;
00183 }
00184
00185 virtual HRESULT Connect(
00186 IPin * pReceivePin,
00187 const AM_MEDIA_TYPE *pmt
00188 )
00189 {
00190 return m_OutputPin.CBasePin::Connect(pReceivePin, pmt);
00191 }
00192 };
00193
00194 #endif