Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpin.cpp
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Network Provider for MPEG2 based networks 00004 * FILE: dll/directx/msdvbnp/pin.cpp 00005 * PURPOSE: IPin interface 00006 * 00007 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) 00008 */ 00009 #include "precomp.h" 00010 00011 #ifndef _MSC_VER 00012 const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; 00013 const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; 00014 #endif 00015 00016 class CPin : public IPin 00017 { 00018 public: 00019 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); 00020 00021 STDMETHODIMP_(ULONG) AddRef() 00022 { 00023 InterlockedIncrement(&m_Ref); 00024 return m_Ref; 00025 } 00026 STDMETHODIMP_(ULONG) Release() 00027 { 00028 InterlockedDecrement(&m_Ref); 00029 if (!m_Ref) 00030 { 00031 delete this; 00032 return 0; 00033 } 00034 return m_Ref; 00035 } 00036 00037 //IPin methods 00038 HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); 00039 HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); 00040 HRESULT STDMETHODCALLTYPE Disconnect(); 00041 HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); 00042 HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); 00043 HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); 00044 HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); 00045 HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); 00046 HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); 00047 HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); 00048 HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); 00049 HRESULT STDMETHODCALLTYPE EndOfStream(); 00050 HRESULT STDMETHODCALLTYPE BeginFlush(); 00051 HRESULT STDMETHODCALLTYPE EndFlush(); 00052 HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 00053 00054 CPin(IBaseFilter * ParentFilter); 00055 virtual ~CPin(){}; 00056 00057 static LPCWSTR PIN_ID; 00058 00059 protected: 00060 LONG m_Ref; 00061 IBaseFilter * m_ParentFilter; 00062 AM_MEDIA_TYPE m_MediaType; 00063 IPin * m_Pin; 00064 }; 00065 00066 00067 LPCWSTR CPin::PIN_ID = L"Antenna Out"; 00068 00069 00070 CPin::CPin( 00071 IBaseFilter * ParentFilter) : m_Ref(0), 00072 m_ParentFilter(ParentFilter), 00073 m_Pin(0) 00074 { 00075 m_MediaType.majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; 00076 m_MediaType.subtype = MEDIASUBTYPE_None; 00077 m_MediaType.formattype = FORMAT_None; 00078 m_MediaType.bFixedSizeSamples = true; 00079 m_MediaType.bTemporalCompression = false; 00080 m_MediaType.lSampleSize = sizeof(CHAR); 00081 m_MediaType.pUnk = NULL; 00082 m_MediaType.cbFormat = 0; 00083 m_MediaType.pbFormat = NULL; 00084 } 00085 00086 00087 HRESULT 00088 STDMETHODCALLTYPE 00089 CPin::QueryInterface( 00090 IN REFIID refiid, 00091 OUT PVOID* Output) 00092 { 00093 if (IsEqualGUID(refiid, IID_IUnknown)) 00094 { 00095 *Output = PVOID(this); 00096 reinterpret_cast<IUnknown*>(*Output)->AddRef(); 00097 return NOERROR; 00098 } 00099 if (IsEqualGUID(refiid, IID_IPin)) 00100 { 00101 *Output = (IPin*)(this); 00102 reinterpret_cast<IPin*>(*Output)->AddRef(); 00103 return NOERROR; 00104 } 00105 00106 WCHAR Buffer[MAX_PATH]; 00107 LPOLESTR lpstr; 00108 StringFromCLSID(refiid, &lpstr); 00109 swprintf(Buffer, L"CPin::QueryInterface: NoInterface for %s\n", lpstr); 00110 OutputDebugStringW(Buffer); 00111 CoTaskMemFree(lpstr); 00112 00113 return E_NOINTERFACE; 00114 } 00115 00116 //------------------------------------------------------------------- 00117 // IPin interface 00118 // 00119 HRESULT 00120 STDMETHODCALLTYPE 00121 CPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) 00122 { 00123 HRESULT hr; 00124 OutputDebugStringW(L"CPin::Connect called\n"); 00125 00126 if (pmt) 00127 { 00128 hr = pReceivePin->QueryAccept(pmt); 00129 if (FAILED(hr)) 00130 { 00131 OutputDebugStringW(L"CPin::Connect QueryAccept failed\n"); 00132 return hr; 00133 } 00134 } 00135 else 00136 { 00137 // query accept 00138 hr = pReceivePin->QueryAccept(&m_MediaType); 00139 if (FAILED(hr)) 00140 { 00141 OutputDebugStringW(L"CPin::Connect QueryAccept pmt default failed\n"); 00142 return hr; 00143 } 00144 00145 pmt = &m_MediaType; 00146 } 00147 00148 // receive connection; 00149 hr = pReceivePin->ReceiveConnection((IPin*)this, pmt); 00150 if (SUCCEEDED(hr)) 00151 { 00152 // increment reference count 00153 pReceivePin->AddRef(); 00154 m_Pin = pReceivePin; 00155 OutputDebugStringW(L"CPin::Connect success\n"); 00156 } 00157 00158 return hr; 00159 } 00160 00161 HRESULT 00162 STDMETHODCALLTYPE 00163 CPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt) 00164 { 00165 return E_UNEXPECTED; 00166 } 00167 00168 HRESULT 00169 STDMETHODCALLTYPE 00170 CPin::Disconnect( void) 00171 { 00172 #ifdef MSDVBNP_TRACE 00173 OutputDebugStringW(L"CPin::Disconnect\n"); 00174 #endif 00175 00176 if (!m_Pin) 00177 { 00178 // pin was not connected 00179 return S_FALSE; 00180 } 00181 00182 m_Pin->Release(); 00183 m_Pin = NULL; 00184 00185 return S_OK; 00186 } 00187 HRESULT 00188 STDMETHODCALLTYPE 00189 CPin::ConnectedTo(IPin **pPin) 00190 { 00191 #ifdef MSDVBNP_TRACE 00192 OutputDebugStringW(L"CPin::ConnectedTo\n"); 00193 #endif 00194 00195 if (!pPin) 00196 return E_POINTER; 00197 00198 if (m_Pin) 00199 { 00200 // increment reference count 00201 m_Pin->AddRef(); 00202 *pPin = m_Pin; 00203 return S_OK; 00204 } 00205 00206 *pPin = NULL; 00207 return VFW_E_NOT_CONNECTED; 00208 } 00209 HRESULT 00210 STDMETHODCALLTYPE 00211 CPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) 00212 { 00213 OutputDebugStringW(L"CPin::ConnectionMediaType NotImplemented\n"); 00214 return E_NOTIMPL; 00215 } 00216 HRESULT 00217 STDMETHODCALLTYPE 00218 CPin::QueryPinInfo(PIN_INFO *pInfo) 00219 { 00220 wcscpy(pInfo->achName, PIN_ID); 00221 pInfo->dir = PINDIR_OUTPUT; 00222 pInfo->pFilter = m_ParentFilter; 00223 m_ParentFilter->AddRef(); 00224 00225 return S_OK; 00226 } 00227 HRESULT 00228 STDMETHODCALLTYPE 00229 CPin::QueryDirection(PIN_DIRECTION *pPinDir) 00230 { 00231 if (pPinDir) 00232 { 00233 *pPinDir = PINDIR_OUTPUT; 00234 return S_OK; 00235 } 00236 00237 return E_POINTER; 00238 } 00239 HRESULT 00240 STDMETHODCALLTYPE 00241 CPin::QueryId(LPWSTR *Id) 00242 { 00243 *Id = (LPWSTR)CoTaskMemAlloc(sizeof(PIN_ID)); 00244 if (!*Id) 00245 return E_OUTOFMEMORY; 00246 00247 wcscpy(*Id, PIN_ID); 00248 return S_OK; 00249 } 00250 HRESULT 00251 STDMETHODCALLTYPE 00252 CPin::QueryAccept(const AM_MEDIA_TYPE *pmt) 00253 { 00254 OutputDebugStringW(L"CPin::QueryAccept NotImplemented\n"); 00255 return E_NOTIMPL; 00256 } 00257 HRESULT 00258 STDMETHODCALLTYPE 00259 CPin::EnumMediaTypes(IEnumMediaTypes **ppEnum) 00260 { 00261 AM_MEDIA_TYPE *MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); 00262 00263 if (!MediaType) 00264 { 00265 return E_OUTOFMEMORY; 00266 } 00267 00268 MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; 00269 MediaType->subtype = MEDIASUBTYPE_None; 00270 MediaType->formattype = FORMAT_None; 00271 MediaType->bFixedSizeSamples = true; 00272 MediaType->bTemporalCompression = false; 00273 MediaType->lSampleSize = sizeof(CHAR); 00274 MediaType->pUnk = NULL; 00275 MediaType->cbFormat = 0; 00276 MediaType->pbFormat = NULL; 00277 00278 return CEnumMediaTypes_fnConstructor(NULL, 1, MediaType, IID_IEnumMediaTypes, (void**)ppEnum); 00279 } 00280 HRESULT 00281 STDMETHODCALLTYPE 00282 CPin::QueryInternalConnections(IPin **apPin, ULONG *nPin) 00283 { 00284 OutputDebugStringW(L"CPin::QueryInternalConnections NotImplemented\n"); 00285 return E_NOTIMPL; 00286 } 00287 HRESULT 00288 STDMETHODCALLTYPE 00289 CPin::EndOfStream( void) 00290 { 00291 OutputDebugStringW(L"CPin::EndOfStream NotImplemented\n"); 00292 return E_NOTIMPL; 00293 } 00294 HRESULT 00295 STDMETHODCALLTYPE 00296 CPin::BeginFlush( void) 00297 { 00298 OutputDebugStringW(L"CPin::BeginFlush NotImplemented\n"); 00299 return E_NOTIMPL; 00300 } 00301 HRESULT 00302 STDMETHODCALLTYPE 00303 CPin::EndFlush( void) 00304 { 00305 OutputDebugStringW(L"CPin::EndFlush NotImplemented\n"); 00306 return E_NOTIMPL; 00307 } 00308 HRESULT 00309 STDMETHODCALLTYPE 00310 CPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) 00311 { 00312 OutputDebugStringW(L"CPin::NewSegment NotImplemented\n"); 00313 return E_NOTIMPL; 00314 } 00315 00316 HRESULT 00317 WINAPI 00318 CPin_fnConstructor( 00319 IUnknown *pUnknown, 00320 IBaseFilter * ParentFilter, 00321 REFIID riid, 00322 LPVOID * ppv) 00323 { 00324 CPin * handler = new CPin(ParentFilter); 00325 00326 #ifdef MSDVBNP_TRACE 00327 WCHAR Buffer[MAX_PATH]; 00328 LPOLESTR lpstr; 00329 StringFromCLSID(riid, &lpstr); 00330 swprintf(Buffer, L"CPin_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); 00331 OutputDebugStringW(Buffer); 00332 #endif 00333 00334 if (!handler) 00335 return E_OUTOFMEMORY; 00336 00337 if (FAILED(handler->QueryInterface(riid, ppv))) 00338 { 00339 /* not supported */ 00340 delete handler; 00341 return E_NOINTERFACE; 00342 } 00343 00344 return NOERROR; 00345 } Generated on Sun May 27 2012 04:21:53 for ReactOS by
1.7.6.1
|