Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Network Provider for MPEG2 based networks * FILE: dll/directx/msdvbnp/pin.cpp * PURPOSE: IPin interface * * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org) */#include "precomp.h"
#ifndef _MSC_VERconst GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};#endif
class CPin : public IPin{public: STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
STDMETHODIMP_(ULONG) AddRef() { InterlockedIncrement(&m_Ref); return m_Ref; } STDMETHODIMP_(ULONG) Release() { InterlockedDecrement(&m_Ref); if (!m_Ref) { delete this; return 0; } return m_Ref; }
//IPin methods HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt); HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt); HRESULT STDMETHODCALLTYPE Disconnect(); HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin); HRESULT STDMETHODCALLTYPE EndOfStream(); HRESULT STDMETHODCALLTYPE BeginFlush(); HRESULT STDMETHODCALLTYPE EndFlush(); HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
CPin(IBaseFilter * ParentFilter); virtual ~CPin(){};
static LPCWSTR PIN_ID;
protected: LONG m_Ref; IBaseFilter * m_ParentFilter; AM_MEDIA_TYPE m_MediaType; IPin * m_Pin;};
LPCWSTR CPin::PIN_ID = L"Antenna Out";
CPin::CPin( IBaseFilter * ParentFilter) : m_Ref(0), m_ParentFilter(ParentFilter), m_Pin(0){ m_MediaType.majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; m_MediaType.subtype = MEDIASUBTYPE_None; m_MediaType.formattype = FORMAT_None; m_MediaType.bFixedSizeSamples = true; m_MediaType.bTemporalCompression = false; m_MediaType.lSampleSize = sizeof(CHAR); m_MediaType.pUnk = NULL; m_MediaType.cbFormat = 0; m_MediaType.pbFormat = NULL;}
HRESULTSTDMETHODCALLTYPECPin::QueryInterface( IN REFIID refiid, OUT PVOID* Output){ if (IsEqualGUID(refiid, IID_IUnknown)) { *Output = PVOID(this); reinterpret_cast<IUnknown*>(*Output)->AddRef(); return NOERROR; } if (IsEqualGUID(refiid, IID_IPin)) { *Output = (IPin*)(this); reinterpret_cast<IPin*>(*Output)->AddRef(); return NOERROR; }
WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; StringFromCLSID(refiid, &lpstr); swprintf(Buffer, L"CPin::QueryInterface: NoInterface for %s\n", lpstr); OutputDebugStringW(Buffer); CoTaskMemFree(lpstr);
return E_NOINTERFACE;}
//-------------------------------------------------------------------// IPin interface//HRESULTSTDMETHODCALLTYPECPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt){ HRESULT hr; OutputDebugStringW(L"CPin::Connect called\n");
if (pmt) { hr = pReceivePin->QueryAccept(pmt); if (FAILED(hr)) { OutputDebugStringW(L"CPin::Connect QueryAccept failed\n"); return hr; } } else { // query accept hr = pReceivePin->QueryAccept(&m_MediaType); if (FAILED(hr)) { OutputDebugStringW(L"CPin::Connect QueryAccept pmt default failed\n"); return hr; }
pmt = &m_MediaType; }
// receive connection; hr = pReceivePin->ReceiveConnection((IPin*)this, pmt); if (SUCCEEDED(hr)) { // increment reference count pReceivePin->AddRef(); m_Pin = pReceivePin; OutputDebugStringW(L"CPin::Connect success\n"); }
return hr;}
HRESULTSTDMETHODCALLTYPECPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt){ return E_UNEXPECTED;}
HRESULTSTDMETHODCALLTYPECPin::Disconnect( void){#ifdef MSDVBNP_TRACE OutputDebugStringW(L"CPin::Disconnect\n");#endif
if (!m_Pin) { // pin was not connected return S_FALSE; }
m_Pin->Release(); m_Pin = NULL;
return S_OK;}HRESULTSTDMETHODCALLTYPECPin::ConnectedTo(IPin **pPin){#ifdef MSDVBNP_TRACE OutputDebugStringW(L"CPin::ConnectedTo\n");#endif
if (!pPin) return E_POINTER;
if (m_Pin) { // increment reference count m_Pin->AddRef(); *pPin = m_Pin; return S_OK; }
*pPin = NULL; return VFW_E_NOT_CONNECTED;}HRESULTSTDMETHODCALLTYPECPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt){ OutputDebugStringW(L"CPin::ConnectionMediaType NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::QueryPinInfo(PIN_INFO *pInfo){ wcscpy(pInfo->achName, PIN_ID); pInfo->dir = PINDIR_OUTPUT; pInfo->pFilter = m_ParentFilter; m_ParentFilter->AddRef();
return S_OK;}HRESULTSTDMETHODCALLTYPECPin::QueryDirection(PIN_DIRECTION *pPinDir){ if (pPinDir) { *pPinDir = PINDIR_OUTPUT; return S_OK; }
return E_POINTER;}HRESULTSTDMETHODCALLTYPECPin::QueryId(LPWSTR *Id){ *Id = (LPWSTR)CoTaskMemAlloc(sizeof(PIN_ID)); if (!*Id) return E_OUTOFMEMORY;
wcscpy(*Id, PIN_ID); return S_OK;}HRESULTSTDMETHODCALLTYPECPin::QueryAccept(const AM_MEDIA_TYPE *pmt){ OutputDebugStringW(L"CPin::QueryAccept NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::EnumMediaTypes(IEnumMediaTypes **ppEnum){ AM_MEDIA_TYPE *MediaType = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
if (!MediaType) { return E_OUTOFMEMORY; }
MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA; MediaType->subtype = MEDIASUBTYPE_None; MediaType->formattype = FORMAT_None; MediaType->bFixedSizeSamples = true; MediaType->bTemporalCompression = false; MediaType->lSampleSize = sizeof(CHAR); MediaType->pUnk = NULL; MediaType->cbFormat = 0; MediaType->pbFormat = NULL;
return CEnumMediaTypes_fnConstructor(NULL, 1, MediaType, IID_IEnumMediaTypes, (void**)ppEnum);}HRESULTSTDMETHODCALLTYPECPin::QueryInternalConnections(IPin **apPin, ULONG *nPin){ OutputDebugStringW(L"CPin::QueryInternalConnections NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::EndOfStream( void){ OutputDebugStringW(L"CPin::EndOfStream NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::BeginFlush( void){ OutputDebugStringW(L"CPin::BeginFlush NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::EndFlush( void){ OutputDebugStringW(L"CPin::EndFlush NotImplemented\n"); return E_NOTIMPL;}HRESULTSTDMETHODCALLTYPECPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate){ OutputDebugStringW(L"CPin::NewSegment NotImplemented\n"); return E_NOTIMPL;}
HRESULTWINAPICPin_fnConstructor( IUnknown *pUnknown, IBaseFilter * ParentFilter, REFIID riid, LPVOID * ppv){ CPin * handler = new CPin(ParentFilter);
#ifdef MSDVBNP_TRACE WCHAR Buffer[MAX_PATH]; LPOLESTR lpstr; StringFromCLSID(riid, &lpstr); swprintf(Buffer, L"CPin_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown); OutputDebugStringW(Buffer);#endif
if (!handler) return E_OUTOFMEMORY;
if (FAILED(handler->QueryInterface(riid, ppv))) { /* not supported */ delete handler; return E_NOINTERFACE; }
return NOERROR;}