ReactOS  0.4.13-dev-66-gc714b7f
pin.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Network Provider for MPEG2 based networks
4  * FILE: dll/directx/msdvbnp/pin.cpp
5  * PURPOSE: IPin interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 #ifndef _MSC_VER
12 const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
13 const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
14 #endif
15 
16 class CPin : public IPin
17 {
18 public:
20 
22  {
24  return m_Ref;
25  }
27  {
29  if (!m_Ref)
30  {
31  delete this;
32  return 0;
33  }
34  return m_Ref;
35  }
36 
37  //IPin methods
38  HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);
53 
54  CPin(IBaseFilter * ParentFilter);
55  virtual ~CPin(){};
56 
57  static LPCWSTR PIN_ID;
58 
59 protected:
64 };
65 
66 
67 LPCWSTR CPin::PIN_ID = L"Antenna Out";
68 
69 
71  IBaseFilter * ParentFilter) : m_Ref(0),
72  m_ParentFilter(ParentFilter),
73  m_Pin(0)
74 {
76  m_MediaType.subtype = MEDIASUBTYPE_None;
77  m_MediaType.formattype = FORMAT_None;
78  m_MediaType.bFixedSizeSamples = true;
79  m_MediaType.bTemporalCompression = false;
80  m_MediaType.lSampleSize = sizeof(CHAR);
81  m_MediaType.pUnk = NULL;
82  m_MediaType.cbFormat = 0;
83  m_MediaType.pbFormat = NULL;
84 }
85 
86 
87 HRESULT
90  IN REFIID refiid,
91  OUT PVOID* Output)
92 {
93  if (IsEqualGUID(refiid, IID_IUnknown))
94  {
95  *Output = PVOID(this);
96  reinterpret_cast<IUnknown*>(*Output)->AddRef();
97  return NOERROR;
98  }
99  if (IsEqualGUID(refiid, IID_IPin))
100  {
101  *Output = (IPin*)(this);
102  reinterpret_cast<IPin*>(*Output)->AddRef();
103  return NOERROR;
104  }
105 
107  LPOLESTR lpstr;
108  StringFromCLSID(refiid, &lpstr);
109  swprintf(Buffer, L"CPin::QueryInterface: NoInterface for %s\n", lpstr);
112 
113  return E_NOINTERFACE;
114 }
115 
116 //-------------------------------------------------------------------
117 // IPin interface
118 //
119 HRESULT
121 CPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
122 {
123  HRESULT hr;
124  OutputDebugStringW(L"CPin::Connect called\n");
125 
126  if (pmt)
127  {
128  hr = pReceivePin->QueryAccept(pmt);
129  if (FAILED(hr))
130  {
131  OutputDebugStringW(L"CPin::Connect QueryAccept failed\n");
132  return hr;
133  }
134  }
135  else
136  {
137  // query accept
138  hr = pReceivePin->QueryAccept(&m_MediaType);
139  if (FAILED(hr))
140  {
141  OutputDebugStringW(L"CPin::Connect QueryAccept pmt default failed\n");
142  return hr;
143  }
144 
145  pmt = &m_MediaType;
146  }
147 
148  // receive connection;
149  hr = pReceivePin->ReceiveConnection((IPin*)this, pmt);
150  if (SUCCEEDED(hr))
151  {
152  // increment reference count
153  pReceivePin->AddRef();
154  m_Pin = pReceivePin;
155  OutputDebugStringW(L"CPin::Connect success\n");
156  }
157 
158  return hr;
159 }
160 
161 HRESULT
164 {
165  return E_UNEXPECTED;
166 }
167 
168 HRESULT
171 {
172 #ifdef MSDVBNP_TRACE
173  OutputDebugStringW(L"CPin::Disconnect\n");
174 #endif
175 
176  if (!m_Pin)
177  {
178  // pin was not connected
179  return S_FALSE;
180  }
181 
182  m_Pin->Release();
183  m_Pin = NULL;
184 
185  return S_OK;
186 }
187 HRESULT
190 {
191 #ifdef MSDVBNP_TRACE
192  OutputDebugStringW(L"CPin::ConnectedTo\n");
193 #endif
194 
195  if (!pPin)
196  return E_POINTER;
197 
198  if (m_Pin)
199  {
200  // increment reference count
201  m_Pin->AddRef();
202  *pPin = m_Pin;
203  return S_OK;
204  }
205 
206  *pPin = NULL;
207  return VFW_E_NOT_CONNECTED;
208 }
209 HRESULT
212 {
213  OutputDebugStringW(L"CPin::ConnectionMediaType NotImplemented\n");
214  return E_NOTIMPL;
215 }
216 HRESULT
219 {
220  wcscpy(pInfo->achName, PIN_ID);
221  pInfo->dir = PINDIR_OUTPUT;
222  pInfo->pFilter = m_ParentFilter;
224 
225  return S_OK;
226 }
227 HRESULT
230 {
231  if (pPinDir)
232  {
233  *pPinDir = PINDIR_OUTPUT;
234  return S_OK;
235  }
236 
237  return E_POINTER;
238 }
239 HRESULT
242 {
243  *Id = (LPWSTR)CoTaskMemAlloc(sizeof(PIN_ID));
244  if (!*Id)
245  return E_OUTOFMEMORY;
246 
247  wcscpy(*Id, PIN_ID);
248  return S_OK;
249 }
250 HRESULT
253 {
254  OutputDebugStringW(L"CPin::QueryAccept NotImplemented\n");
255  return E_NOTIMPL;
256 }
257 HRESULT
260 {
262 
263  if (!MediaType)
264  {
265  return E_OUTOFMEMORY;
266  }
267 
268  MediaType->majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA;
269  MediaType->subtype = MEDIASUBTYPE_None;
270  MediaType->formattype = FORMAT_None;
271  MediaType->bFixedSizeSamples = true;
272  MediaType->bTemporalCompression = false;
273  MediaType->lSampleSize = sizeof(CHAR);
274  MediaType->pUnk = NULL;
275  MediaType->cbFormat = 0;
276  MediaType->pbFormat = NULL;
277 
278  return CEnumMediaTypes_fnConstructor(NULL, 1, MediaType, IID_IEnumMediaTypes, (void**)ppEnum);
279 }
280 HRESULT
283 {
284  OutputDebugStringW(L"CPin::QueryInternalConnections NotImplemented\n");
285  return E_NOTIMPL;
286 }
287 HRESULT
290 {
291  OutputDebugStringW(L"CPin::EndOfStream NotImplemented\n");
292  return E_NOTIMPL;
293 }
294 HRESULT
297 {
298  OutputDebugStringW(L"CPin::BeginFlush NotImplemented\n");
299  return E_NOTIMPL;
300 }
301 HRESULT
304 {
305  OutputDebugStringW(L"CPin::EndFlush NotImplemented\n");
306  return E_NOTIMPL;
307 }
308 HRESULT
310 CPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
311 {
312  OutputDebugStringW(L"CPin::NewSegment NotImplemented\n");
313  return E_NOTIMPL;
314 }
315 
316 HRESULT
317 WINAPI
320  IBaseFilter * ParentFilter,
321  REFIID riid,
322  LPVOID * ppv)
323 {
324  CPin * handler = new CPin(ParentFilter);
325 
326 #ifdef MSDVBNP_TRACE
328  LPOLESTR lpstr;
330  swprintf(Buffer, L"CPin_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
332 #endif
333 
334  if (!handler)
335  return E_OUTOFMEMORY;
336 
337  if (FAILED(handler->QueryInterface(riid, ppv)))
338  {
339  /* not supported */
340  delete handler;
341  return E_NOINTERFACE;
342  }
343 
344  return NOERROR;
345 }
HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
Definition: pin.cpp:310
#define IN
Definition: typedefs.h:38
HRESULT STDMETHODCALLTYPE BeginFlush()
Definition: pin.cpp:296
#define REFIID
Definition: guiddef.h:113
HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:121
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HRESULT ReceiveConnection([in] IPin *pConnector, [in] const AM_MEDIA_TYPE *pmt)
#define NOERROR
Definition: winerror.h:2354
static LPCWSTR PIN_ID
Definition: pin.cpp:55
CPin(IBaseFilter *ParentFilter)
Definition: pin.cpp:70
REFIID riid
Definition: precomp.h:44
HRESULT WINAPI CEnumMediaTypes_fnConstructor(ULONG MediaTypeCount, AM_MEDIA_TYPE *MediaTypes, REFIID riid, LPVOID *ppv)
HRESULT QueryAccept([in] const AM_MEDIA_TYPE *pmt)
HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin)
Definition: pin.cpp:282
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin)
Definition: pin.cpp:189
static LPOLESTR
Definition: stg_prop.c:27
DWORD Id
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
IBaseFilter * m_ParentFilter
Definition: pin.cpp:61
HRESULT WINAPI CPin_fnConstructor(IUnknown *pUnknown, IBaseFilter *ParentFilter, REFIID riid, LPVOID *ppv)
Definition: pin.cpp:318
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo)
Definition: pin.cpp:218
IPin * m_Pin
Definition: pin.cpp:63
long LONG
Definition: pedump.c:60
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:252
STDMETHODIMP_(ULONG) AddRef()
Definition: pin.cpp:21
HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:211
Definition: bufpool.h:45
PIN_DIRECTION dir
Definition: axcore.idl:96
const GUID GUID_NULL
Definition: pin.cpp:13
void * PVOID
Definition: retypes.h:9
#define VFW_E_NOT_CONNECTED
Definition: vfwmsgs.h:48
HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:163
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:8
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
HRESULT STDMETHODCALLTYPE EndFlush()
Definition: pin.cpp:303
HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum)
Definition: pin.cpp:259
ULONG AddRef()
HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir)
Definition: pin.cpp:229
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
HRESULT STDMETHODCALLTYPE EndOfStream()
Definition: pin.cpp:289
#define S_OK
Definition: intsafe.h:59
const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA
Definition: pin.cpp:12
virtual ~CPin()
Definition: pin.cpp:55
#define InterlockedIncrement
Definition: armddk.h:53
Definition: pin.cpp:16
STDMETHODIMP_(ULONG) Release()
Definition: pin.cpp:26
Definition: axcore.idl:91
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
enum _PinDirection PIN_DIRECTION
#define E_UNEXPECTED
Definition: winerror.h:2456
#define OUT
Definition: typedefs.h:39
HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id)
Definition: pin.cpp:241
unsigned int ULONG
Definition: retypes.h:1
IBaseFilter * pFilter
Definition: axcore.idl:95
WCHAR achName[MAX_PIN_NAME]
Definition: axcore.idl:97
HRESULT STDMETHODCALLTYPE Disconnect()
Definition: pin.cpp:170
static LPCSTR lpstr
Definition: font.c:51
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
#define CHAR(Char)
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: pin.cpp:89
LONG m_Ref
Definition: pin.cpp:60
const GUID IID_IPin
Definition: pincontrol.cpp:15
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
AM_MEDIA_TYPE m_MediaType
Definition: pin.cpp:62
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2321