00001
00034 #include "MultiIOOutputPin.h"
00035
00036 #include "MultiIOBaseFilter.h"
00037 #include "MultiIOInputPin.h"
00038
00039 CMultiIOOutputPin::CMultiIOOutputPin(CMultiIOBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, LPCWSTR pName, int nIndex)
00040 : CBaseOutputPin(NAME("TM Multi Output Pin"), pFilter, pLock, phr, pName),
00041 m_pFilter(pFilter),
00042 m_nIndex(nIndex),
00043 m_pOutputQueue(NULL)
00044 {
00045 }
00046
00047 CMultiIOOutputPin::~CMultiIOOutputPin(void)
00048 {
00049 }
00050
00051 HRESULT CMultiIOOutputPin::CompleteConnect( IPin *pReceivePin )
00052 {
00053 HRESULT hr = CBaseOutputPin::CompleteConnect(pReceivePin);
00054 if (SUCCEEDED(hr))
00055 {
00056 m_pFilter->OnConnect(m_nIndex, RTVC_OUT);
00057 }
00058 return hr;
00059 }
00060
00061 HRESULT CMultiIOOutputPin::DecideBufferSize( IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pRequestProperties )
00062 {
00063
00064 return m_pFilter->DecideBufferSize(pAlloc, pRequestProperties, m_nIndex);
00065 }
00066
00067 HRESULT CMultiIOOutputPin::CheckMediaType( const CMediaType* pMediaType )
00068 {
00069 return m_pFilter->CheckOutputType(pMediaType);
00070 }
00071
00072 HRESULT CMultiIOOutputPin::GetMediaType( int iPosition, CMediaType* pMediaType )
00073 {
00074 ASSERT(m_pFilter->m_vInputPins.size() > 0);
00075
00076
00077
00078 if (m_pFilter->m_vInputPins[0]->IsConnected())
00079 {
00080 return m_pFilter->GetMediaType(iPosition, pMediaType, m_nIndex);
00081 } else
00082 {
00083 return VFW_S_NO_MORE_ITEMS;
00084 }
00085 }
00086
00087 STDMETHODIMP CMultiIOOutputPin::Notify( IBaseFilter * pSender, Quality q )
00088 {
00089 UNREFERENCED_PARAMETER(q);
00090 UNREFERENCED_PARAMETER(pSender);
00091 return E_NOTIMPL;
00092 }
00093
00094 HRESULT CMultiIOOutputPin::Active()
00095 {
00096 CAutoLock lock_it(m_pLock);
00097 HRESULT hr = NOERROR;
00098
00099
00100 if(m_Connected == NULL)
00101 return NOERROR;
00102
00103
00104 if(m_pOutputQueue == NULL)
00105 {
00106 m_pOutputQueue = new COutputQueue(m_Connected, &hr, TRUE, FALSE);
00107 if(m_pOutputQueue == NULL)
00108 return E_OUTOFMEMORY;
00109
00110
00111 if(FAILED(hr))
00112 {
00113 delete m_pOutputQueue;
00114 m_pOutputQueue = NULL;
00115 return hr;
00116 }
00117 }
00118
00119
00120 CBaseOutputPin::Active();
00121 return NOERROR;
00122
00123 }
00124
00125 HRESULT CMultiIOOutputPin::Inactive()
00126 {
00127 CAutoLock lock_it(m_pLock);
00128
00129
00130 if(m_pOutputQueue)
00131 {
00132 delete m_pOutputQueue;
00133 m_pOutputQueue = NULL;
00134 }
00135
00136 CBaseOutputPin::Inactive();
00137 return NOERROR;
00138
00139 }
00140
00141 HRESULT CMultiIOOutputPin::Deliver(IMediaSample *pMediaSample)
00142 {
00143 CheckPointer(pMediaSample,E_POINTER);
00144
00145
00146 if(m_pOutputQueue == NULL)
00147 return NOERROR;
00148
00149 pMediaSample->AddRef();
00150 return m_pOutputQueue->Receive(pMediaSample);
00151
00152 }
00153
00154
00155
00156
00157 HRESULT CMultiIOOutputPin::DeliverEndOfStream()
00158 {
00159
00160 if(m_pOutputQueue == NULL)
00161 return NOERROR;
00162
00163 m_pOutputQueue->EOS();
00164 return NOERROR;
00165
00166 }
00167
00168
00169
00170
00171
00172 HRESULT CMultiIOOutputPin::DeliverBeginFlush()
00173 {
00174
00175 if(m_pOutputQueue == NULL)
00176 return NOERROR;
00177
00178 m_pOutputQueue->BeginFlush();
00179 return NOERROR;
00180
00181 }
00182
00183
00184
00185
00186
00187 HRESULT CMultiIOOutputPin::DeliverEndFlush()
00188 {
00189
00190 if(m_pOutputQueue == NULL)
00191 return NOERROR;
00192
00193 m_pOutputQueue->EndFlush();
00194 return NOERROR;
00195
00196 }
00197
00198
00199
00200
00201 HRESULT CMultiIOOutputPin::DeliverNewSegment(REFERENCE_TIME tStart,
00202 REFERENCE_TIME tStop,
00203 double dRate)
00204 {
00205
00206 if(m_pOutputQueue == NULL)
00207 return NOERROR;
00208
00209 m_pOutputQueue->NewSegment(tStart, tStop, dRate);
00210 return NOERROR;
00211
00212 }