b29d12ac4b2a8a4b944c86da9c10e7cb5c134d30
[reactos.git] / reactos / dll / directx / ksproxy / output_pin.cpp
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
4 * FILE: dll/directx/ksproxy/input_cpp.cpp
5 * PURPOSE: InputPin of Proxy Filter
6 *
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
8 */
9 #include "precomp.h"
10
11 class COutputPin : public IPin,
12 public IKsObject
13 /*
14 public IQualityControl,
15 public IKsPinEx,
16 public IKsPinPipe,
17 public ISpecifyPropertyPages,
18 public IStreamBuilder,
19 public IKsPropertySet,
20 public IKsPinFactory,
21 public IKsControl,
22 public IKsAggregateControl
23 public IMediaSeeking,
24 public IAMStreamConfig,
25 public IMemAllocatorNotifyCallbackTemp
26 */
27 {
28 public:
29 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
30
31 STDMETHODIMP_(ULONG) AddRef()
32 {
33 InterlockedIncrement(&m_Ref);
34 return m_Ref;
35 }
36 STDMETHODIMP_(ULONG) Release()
37 {
38 InterlockedDecrement(&m_Ref);
39 if (!m_Ref)
40 {
41 delete this;
42 return 0;
43 }
44 return m_Ref;
45 }
46
47 //IPin methods
48 HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);
49 HRESULT STDMETHODCALLTYPE ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt);
50 HRESULT STDMETHODCALLTYPE Disconnect();
51 HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin);
52 HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt);
53 HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo);
54 HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir);
55 HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id);
56 HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt);
57 HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum);
58 HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, ULONG *nPin);
59 HRESULT STDMETHODCALLTYPE EndOfStream();
60 HRESULT STDMETHODCALLTYPE BeginFlush();
61 HRESULT STDMETHODCALLTYPE EndFlush();
62 HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
63
64 //IKsObject methods
65 HANDLE STDMETHODCALLTYPE KsGetObjectHandle();
66
67
68 COutputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){};
69 virtual ~COutputPin(){};
70
71 protected:
72 LONG m_Ref;
73 IBaseFilter * m_ParentFilter;
74 LPCWSTR m_PinName;
75 };
76
77 HRESULT
78 STDMETHODCALLTYPE
79 COutputPin::QueryInterface(
80 IN REFIID refiid,
81 OUT PVOID* Output)
82 {
83 *Output = NULL;
84 if (IsEqualGUID(refiid, IID_IUnknown) ||
85 IsEqualGUID(refiid, IID_IPin))
86 {
87 *Output = PVOID(this);
88 reinterpret_cast<IUnknown*>(*Output)->AddRef();
89 return NOERROR;
90 }
91 else if (IsEqualGUID(refiid, IID_IKsObject))
92 {
93 *Output = (IKsObject*)(this);
94 reinterpret_cast<IKsObject*>(*Output)->AddRef();
95 return NOERROR;
96 }
97
98 WCHAR Buffer[MAX_PATH];
99 LPOLESTR lpstr;
100 StringFromCLSID(refiid, &lpstr);
101 swprintf(Buffer, L"COutputPin::QueryInterface: NoInterface for %s\n", lpstr);
102 OutputDebugStringW(Buffer);
103 CoTaskMemFree(lpstr);
104
105 return E_NOINTERFACE;
106 }
107
108 //-------------------------------------------------------------------
109 // IKsObject
110 //
111 HANDLE
112 STDMETHODCALLTYPE
113 COutputPin::KsGetObjectHandle()
114 {
115 OutputDebugStringW(L"COutputPin::KsGetObjectHandle CALLED\n");
116
117 //FIXME
118 // return pin handle
119 return NULL;
120 }
121
122 //-------------------------------------------------------------------
123 // IPin interface
124 //
125 HRESULT
126 STDMETHODCALLTYPE
127 COutputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
128 {
129 OutputDebugStringW(L"COutputPin::Connect called\n");
130 return E_NOTIMPL;
131 }
132
133 HRESULT
134 STDMETHODCALLTYPE
135 COutputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
136 {
137 OutputDebugStringW(L"COutputPin::ReceiveConnection called\n");
138 return E_NOTIMPL;
139 }
140 HRESULT
141 STDMETHODCALLTYPE
142 COutputPin::Disconnect( void)
143 {
144 OutputDebugStringW(L"COutputPin::Disconnect called\n");
145 return E_NOTIMPL;
146 }
147 HRESULT
148 STDMETHODCALLTYPE
149 COutputPin::ConnectedTo(IPin **pPin)
150 {
151 *pPin = NULL;
152 OutputDebugStringW(L"COutputPin::ConnectedTo called\n");
153 return VFW_E_NOT_CONNECTED;
154 }
155 HRESULT
156 STDMETHODCALLTYPE
157 COutputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt)
158 {
159 OutputDebugStringW(L"COutputPin::ConnectionMediaType called\n");
160 return E_NOTIMPL;
161 }
162 HRESULT
163 STDMETHODCALLTYPE
164 COutputPin::QueryPinInfo(PIN_INFO *pInfo)
165 {
166 wcscpy(pInfo->achName, m_PinName);
167 pInfo->dir = PINDIR_OUTPUT;
168 pInfo->pFilter = m_ParentFilter;
169 m_ParentFilter->AddRef();
170
171 return S_OK;
172 }
173 HRESULT
174 STDMETHODCALLTYPE
175 COutputPin::QueryDirection(PIN_DIRECTION *pPinDir)
176 {
177 if (pPinDir)
178 {
179 *pPinDir = PINDIR_OUTPUT;
180 return S_OK;
181 }
182
183 return E_POINTER;
184 }
185 HRESULT
186 STDMETHODCALLTYPE
187 COutputPin::QueryId(LPWSTR *Id)
188 {
189 *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR));
190 if (!*Id)
191 return E_OUTOFMEMORY;
192
193 wcscpy(*Id, m_PinName);
194 return S_OK;
195 }
196 HRESULT
197 STDMETHODCALLTYPE
198 COutputPin::QueryAccept(const AM_MEDIA_TYPE *pmt)
199 {
200 OutputDebugStringW(L"COutputPin::QueryAccept called\n");
201 return E_NOTIMPL;
202 }
203 HRESULT
204 STDMETHODCALLTYPE
205 COutputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum)
206 {
207 OutputDebugStringW(L"COutputPin::EnumMediaTypes called\n");
208 return E_NOTIMPL;
209 }
210 HRESULT
211 STDMETHODCALLTYPE
212 COutputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin)
213 {
214 OutputDebugStringW(L"COutputPin::QueryInternalConnections called\n");
215 return E_NOTIMPL;
216 }
217 HRESULT
218 STDMETHODCALLTYPE
219 COutputPin::EndOfStream( void)
220 {
221 OutputDebugStringW(L"COutputPin::EndOfStream called\n");
222 return E_NOTIMPL;
223 }
224 HRESULT
225 STDMETHODCALLTYPE
226 COutputPin::BeginFlush( void)
227 {
228 OutputDebugStringW(L"COutputPin::BeginFlush called\n");
229 return E_NOTIMPL;
230 }
231 HRESULT
232 STDMETHODCALLTYPE
233 COutputPin::EndFlush( void)
234 {
235 OutputDebugStringW(L"COutputPin::EndFlush called\n");
236 return E_NOTIMPL;
237 }
238 HRESULT
239 STDMETHODCALLTYPE
240 COutputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
241 {
242 OutputDebugStringW(L"COutputPin::NewSegment called\n");
243 return E_NOTIMPL;
244 }
245
246 HRESULT
247 WINAPI
248 COutputPin_Constructor(
249 IBaseFilter * ParentFilter,
250 LPCWSTR PinName,
251 REFIID riid,
252 LPVOID * ppv)
253 {
254 COutputPin * handler = new COutputPin(ParentFilter, PinName);
255
256 if (!handler)
257 return E_OUTOFMEMORY;
258
259 if (FAILED(handler->QueryInterface(riid, ppv)))
260 {
261 /* not supported */
262 delete handler;
263 return E_NOINTERFACE;
264 }
265
266 return S_OK;
267 }