00001
00037 #pragma once
00038
00039 #pragma warning(push) // disable for this header only
00040 #pragma warning(disable:4312)
00041
00042 #include <streams.h>
00043 #pragma warning(pop) // restore original warning level
00044
00045
00046 #include <vector>
00047 #include <string>
00048 #include <map>
00049
00050 #include "MultiIOInputPin.h"
00051 #include "MultiIOOutputPin.h"
00052
00053
00054 class CMultiIOInputPin;
00055 class CMultiIOOutputPin;
00056
00057
00058 using namespace std;
00059
00060
00061 typedef vector<CMultiIOInputPin*> INPUT_PIN_LIST;
00062 typedef vector<CMultiIOOutputPin*> OUTPUT_PIN_LIST;
00063 typedef map<int, CMediaType> MEDIA_TYPE_LIST;
00064
00065 enum RTVC_DIRECTION
00066 {
00067 RTVC_IN,
00068 RTVC_OUT
00069 };
00070
00071 class CMultiIOBaseFilter : public CBaseFilter
00072 {
00073 friend class CMultiIOInputPin;
00074 friend class CMultiIOOutputPin;
00075
00076 public:
00077 CMultiIOBaseFilter(TCHAR *pObjectName, LPUNKNOWN lpUnk, CLSID clsid);
00078 virtual ~CMultiIOBaseFilter(void);
00079
00080 void Initialise();
00083 virtual int GetPinCount();
00085 virtual CBasePin * GetPin(int n);
00087 virtual STDMETHODIMP FindPin(LPCWSTR Id, IPin **ppPin);
00088
00090
00091 virtual HRESULT CheckInputType(const CMediaType *mtIn);
00093 virtual void OnConnect(int nIndex, RTVC_DIRECTION eDirection );
00095 virtual void OnDisconnect(int nIndex);
00097 virtual HRESULT Receive(IMediaSample *pSample, int nIndex ) PURE;
00099 virtual HRESULT InitializeOutputSample(IMediaSample *pSample, IMediaSample **ppOutSample, int nInputIndex, int nOutputIndex);
00100
00102
00105 virtual int InitialNumberOfInputPins();
00107 virtual int InitialNumberOfOutputPins();
00109 virtual bool OnFullCreateMoreInputs();
00111 virtual bool OnFullCreateMoreOutputs();
00113 virtual void InitialiseInputTypes() = 0;
00115 virtual void InitialiseOutputTypes() = 0;
00117
00119
00121 virtual HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pRequestProperties, int m_nIndex)PURE;
00123 virtual HRESULT CheckOutputType(const CMediaType* pMediaType);
00125 virtual HRESULT GetMediaType(int iPosition, CMediaType* pmt, int nOutputPinIndex) PURE;
00127
00131 virtual HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt, int nIndex);
00132
00133
00134 virtual STDMETHODIMP EndOfStream(int nIndex);
00135 virtual STDMETHODIMP BeginFlush(int nIndex);
00136 virtual STDMETHODIMP EndFlush(int nIndex);
00137 virtual STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate, int nIndex);
00138 protected:
00145
00146
00147 void AddInputType(const GUID* pType, const GUID* pSubType, const GUID* pFormat, int nPin = -1);
00150 void AddOutputType(const GUID* pType, const GUID* pSubType, const GUID* pFormat, int nPin = -1);
00151
00153 void CreateInputPin();
00155 void CreateOutputPin();
00156
00158 INPUT_PIN_LIST m_vInputPins;
00160 OUTPUT_PIN_LIST m_vOutputPins;
00162 MEDIA_TYPE_LIST m_mMediaTypes;
00163
00165 CCritSec m_csFilter;
00167 CCritSec m_csReceive;
00168
00169 private:
00170
00171
00172
00173 class CIOMediaType
00174 {
00175 public:
00176 CIOMediaType(const GUID* pInputType, const GUID* pInputSubtype, const GUID* pFormat)
00177 :MediaType(pInputType),
00178 MediaSubtype(pInputSubtype),
00179 Format(pFormat)
00180 {}
00181 const GUID* MediaType;
00182 const GUID* MediaSubtype;
00183 const GUID* Format;
00184 };
00185
00186
00187 typedef vector<CIOMediaType*> MEDIA_TYPE_LIST;
00188 typedef map<int, MEDIA_TYPE_LIST*> MEDIA_TYPE_MAP;
00189 typedef map<int, MEDIA_TYPE_LIST*>::iterator MEDIA_TYPE_MAP_ITERATOR;
00190
00191
00192 void CleanupTypeMap(MEDIA_TYPE_MAP mTypeMap);
00193
00195 void AddMediaType(CIOMediaType* pMediaType, MEDIA_TYPE_LIST& typeList, MEDIA_TYPE_MAP& typeMap, int nPin = -1);
00197 HRESULT FindMediaType(const CMediaType* pmt, MEDIA_TYPE_LIST* pInputTypeList);
00199 HRESULT FindMediaTypeInLists(const CMediaType* pMediaType, MEDIA_TYPE_LIST* typeList, MEDIA_TYPE_MAP& typeMap);
00200
00202 MEDIA_TYPE_LIST m_vInputTypes;
00203 MEDIA_TYPE_LIST m_vOutputTypes;
00205 MEDIA_TYPE_MAP m_mInputTypeMap;
00206 MEDIA_TYPE_MAP m_mOutputTypeMap;
00207
00208 };