ba7b31bb131e037e1429aca49b1f61619313a4b7
[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 /*
13 public IQualityControl,
14 public IKsObject,
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 COutputPin(IBaseFilter * ParentFilter, LPCWSTR PinName) : m_Ref(0), m_ParentFilter(ParentFilter), m_PinName(PinName){};
65 virtual ~COutputPin(){};
66
67 protected:
68 LONG m_Ref;
69 IBaseFilter * m_ParentFilter;
70 LPCWSTR m_PinName;
71 };
72
73 HRESULT
74 STDMETHODCALLTYPE
75 COutputPin::QueryInterface(
76 IN REFIID refiid,
77 OUT PVOID* Output)
78 {
79 *Output = NULL;
80 if (IsEqualGUID(refiid, IID_IUnknown) ||
81 IsEqualGUID(refiid, IID_IPin))
82 {
83 *Output = PVOID(this);
84 reinterpret_cast<IUnknown*>(*Output)->AddRef();
85 return NOERROR;
86 }
87
88 WCHAR Buffer[MAX_PATH];
89 LPOLESTR lpstr;
90 StringFromCLSID(refiid, &lpstr);
91 swprintf(Buffer, L"COutputPin::QueryInterface: NoInterface for %s\n", lpstr);
92 OutputDebugStringW(Buffer);
93 CoTaskMemFree(lpstr);
94
95 return E_NOINTERFACE;
96 }
97
98 //-------------------------------------------------------------------
99 // IPin interface
100 //
101 HRESULT
102 STDMETHODCALLTYPE
103 COutputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
104 {
105 OutputDebugStringW(L"COutputPin::Connect called\n");
106 return E_NOTIMPL;
107 }
108
109 HRESULT
110 STDMETHODCALLTYPE
111 COutputPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
112 {
113 OutputDebugStringW(L"COutputPin::ReceiveConnection called\n");
114 return E_NOTIMPL;
115 }
116 HRESULT
117 STDMETHODCALLTYPE
118 COutputPin::Disconnect( void)
119 {
120 OutputDebugStringW(L"COutputPin::Disconnect called\n");
121 return E_NOTIMPL;
122 }
123 HRESULT
124 STDMETHODCALLTYPE
125 COutputPin::ConnectedTo(IPin **pPin)
126 {
127 OutputDebugStringW(L"COutputPin::ConnectedTo called\n");
128 return VFW_E_NOT_CONNECTED;
129 }
130 HRESULT
131 STDMETHODCALLTYPE
132 COutputPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt)
133 {
134 OutputDebugStringW(L"COutputPin::ConnectionMediaType called\n");
135 return E_NOTIMPL;
136 }
137 HRESULT
138 STDMETHODCALLTYPE
139 COutputPin::QueryPinInfo(PIN_INFO *pInfo)
140 {
141 wcscpy(pInfo->achName, m_PinName);
142 pInfo->dir = PINDIR_OUTPUT;
143 pInfo->pFilter = m_ParentFilter;
144 m_ParentFilter->AddRef();
145
146 return S_OK;
147 }
148 HRESULT
149 STDMETHODCALLTYPE
150 COutputPin::QueryDirection(PIN_DIRECTION *pPinDir)
151 {
152 if (pPinDir)
153 {
154 *pPinDir = PINDIR_OUTPUT;
155 return S_OK;
156 }
157
158 return E_POINTER;
159 }
160 HRESULT
161 STDMETHODCALLTYPE
162 COutputPin::QueryId(LPWSTR *Id)
163 {
164 *Id = (LPWSTR)CoTaskMemAlloc((wcslen(m_PinName)+1)*sizeof(WCHAR));
165 if (!*Id)
166 return E_OUTOFMEMORY;
167
168 wcscpy(*Id, m_PinName);
169 return S_OK;
170 }
171 HRESULT
172 STDMETHODCALLTYPE
173 COutputPin::QueryAccept(const AM_MEDIA_TYPE *pmt)
174 {
175 OutputDebugStringW(L"COutputPin::QueryAccept called\n");
176 return E_NOTIMPL;
177 }
178 HRESULT
179 STDMETHODCALLTYPE
180 COutputPin::EnumMediaTypes(IEnumMediaTypes **ppEnum)
181 {
182 OutputDebugStringW(L"COutputPin::EnumMediaTypes called\n");
183 return E_NOTIMPL;
184 }
185 HRESULT
186 STDMETHODCALLTYPE
187 COutputPin::QueryInternalConnections(IPin **apPin, ULONG *nPin)
188 {
189 OutputDebugStringW(L"COutputPin::QueryInternalConnections called\n");
190 return E_NOTIMPL;
191 }
192 HRESULT
193 STDMETHODCALLTYPE
194 COutputPin::EndOfStream( void)
195 {
196 OutputDebugStringW(L"COutputPin::EndOfStream called\n");
197 return E_NOTIMPL;
198 }
199 HRESULT
200 STDMETHODCALLTYPE
201 COutputPin::BeginFlush( void)
202 {
203 OutputDebugStringW(L"COutputPin::BeginFlush called\n");
204 return E_NOTIMPL;
205 }
206 HRESULT
207 STDMETHODCALLTYPE
208 COutputPin::EndFlush( void)
209 {
210 OutputDebugStringW(L"COutputPin::EndFlush called\n");
211 return E_NOTIMPL;
212 }
213 HRESULT
214 STDMETHODCALLTYPE
215 COutputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
216 {
217 OutputDebugStringW(L"COutputPin::NewSegment called\n");
218 return E_NOTIMPL;
219 }
220
221 HRESULT
222 WINAPI
223 COutputPin_Constructor(
224 IBaseFilter * ParentFilter,
225 LPCWSTR PinName,
226 REFIID riid,
227 LPVOID * ppv)
228 {
229 COutputPin * handler = new COutputPin(ParentFilter, PinName);
230
231 if (!handler)
232 return E_OUTOFMEMORY;
233
234 if (FAILED(handler->QueryInterface(riid, ppv)))
235 {
236 /* not supported */
237 delete handler;
238 return E_NOINTERFACE;
239 }
240
241 return S_OK;
242 }