ReactOS 0.4.15-dev-7108-g1cf6ce6
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
12const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
13const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
14#endif
15
16class CPin : public IPin
17{
18public:
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
58
59protected:
64};
65
66
67LPCWSTR 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
90 IN REFIID refiid,
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
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//
121CPin::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
164{
165 return E_UNEXPECTED;
166}
167
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}
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}
212{
213 OutputDebugStringW(L"CPin::ConnectionMediaType NotImplemented\n");
214 return E_NOTIMPL;
215}
219{
220 wcscpy(pInfo->achName, PIN_ID);
221 pInfo->dir = PINDIR_OUTPUT;
222 pInfo->pFilter = m_ParentFilter;
224
225 return S_OK;
226}
230{
231 if (pPinDir)
232 {
233 *pPinDir = PINDIR_OUTPUT;
234 return S_OK;
235 }
236
237 return E_POINTER;
238}
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}
253{
254 OutputDebugStringW(L"CPin::QueryAccept NotImplemented\n");
255 return E_NOTIMPL;
256}
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}
283{
284 OutputDebugStringW(L"CPin::QueryInternalConnections NotImplemented\n");
285 return E_NOTIMPL;
286}
290{
291 OutputDebugStringW(L"CPin::EndOfStream NotImplemented\n");
292 return E_NOTIMPL;
293}
297{
298 OutputDebugStringW(L"CPin::BeginFlush NotImplemented\n");
299 return E_NOTIMPL;
300}
304{
305 OutputDebugStringW(L"CPin::EndFlush NotImplemented\n");
306 return E_NOTIMPL;
307}
311{
312 OutputDebugStringW(L"CPin::NewSegment NotImplemented\n");
313 return E_NOTIMPL;
314}
315
317WINAPI
320 IBaseFilter * ParentFilter,
321 REFIID riid,
322 LPVOID * ppv)
323{
324 CPin * handler = new CPin(ParentFilter);
325
326#ifdef MSDVBNP_TRACE
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}
DWORD Id
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
enum _PinDirection PIN_DIRECTION
@ PINDIR_OUTPUT
Definition: axcore.idl:42
#define CHAR(Char)
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: bufpool.h:45
Definition: pin.cpp:17
IBaseFilter * m_ParentFilter
Definition: pin.cpp:61
HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin)
Definition: pin.cpp:189
HRESULT STDMETHODCALLTYPE Disconnect()
Definition: pin.cpp:170
CPin(IBaseFilter *ParentFilter)
Definition: pin.cpp:70
HRESULT STDMETHODCALLTYPE EndOfStream()
Definition: pin.cpp:289
LONG m_Ref
Definition: pin.cpp:60
HRESULT STDMETHODCALLTYPE EndFlush()
Definition: pin.cpp:303
HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:252
HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
Definition: pin.cpp:310
virtual ~CPin()
Definition: pin.cpp:55
HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin)
Definition: pin.cpp:282
AM_MEDIA_TYPE m_MediaType
Definition: pin.cpp:62
HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id)
Definition: pin.cpp:241
STDMETHODIMP_(ULONG) Release()
Definition: pin.cpp:26
HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:163
IPin * m_Pin
Definition: pin.cpp:63
STDMETHODIMP_(ULONG) AddRef()
Definition: pin.cpp:21
HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir)
Definition: pin.cpp:229
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: pin.cpp:89
HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum)
Definition: pin.cpp:259
static LPCWSTR PIN_ID
Definition: pin.cpp:57
HRESULT STDMETHODCALLTYPE BeginFlush()
Definition: pin.cpp:296
HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:211
HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
Definition: pin.cpp:121
HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo)
Definition: pin.cpp:218
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define swprintf
Definition: precomp.h:40
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
Definition: axcore.idl:92
HRESULT ReceiveConnection([in] IPin *pConnector, [in] const AM_MEDIA_TYPE *pmt)
HRESULT QueryAccept([in] const AM_MEDIA_TYPE *pmt)
ULONG AddRef()
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4536
HRESULT WINAPI CEnumMediaTypes_fnConstructor(ULONG MediaTypeCount, AM_MEDIA_TYPE *MediaTypes, REFIID riid, LPVOID *ppv)
static LPCSTR lpstr
Definition: font.c:51
static LPOLESTR
Definition: stg_prop.c:27
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
const GUID GUID_NULL
Definition: pin.cpp:13
HRESULT WINAPI CPin_fnConstructor(IUnknown *pUnknown, IBaseFilter *ParentFilter, REFIID riid, LPVOID *ppv)
Definition: pin.cpp:318
const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA
Definition: pin.cpp:12
const GUID IID_IPin
Definition: pincontrol.cpp:15
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
@ Output
Definition: arc.h:85
HRESULT hr
Definition: shlfolder.c:183
PIN_DIRECTION dir
Definition: axcore.idl:96
WCHAR achName[MAX_PIN_NAME]
Definition: axcore.idl:97
IBaseFilter * pFilter
Definition: axcore.idl:95
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define VFW_E_NOT_CONNECTED
Definition: vfwmsgs.h:48
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define E_UNEXPECTED
Definition: winerror.h:2456
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185