po: Fix some typography issues in the Ukrainian translation.
[wine.git] / dlls / strmbase / video.c
blob3d5a4e36ca13766af5c49c0cf5cc93b425464187
1 /*
2 * Generic Implementation of strmbase video classes
4 * Copyright 2012 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <assert.h>
24 #include "dshow.h"
25 #include "uuids.h"
26 #include "vfwmsgs.h"
27 #include "wine/debug.h"
28 #include "wine/unicode.h"
29 #include "wine/strmbase.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
33 static inline BaseControlVideo *impl_from_IBasicVideo(IBasicVideo *iface)
35 return CONTAINING_RECORD(iface, BaseControlVideo, IBasicVideo_iface);
38 HRESULT WINAPI BaseControlVideo_Init(BaseControlVideo *pControlVideo, const IBasicVideoVtbl *lpVtbl, BaseFilter *owner, CRITICAL_SECTION *lock, BasePin* pPin, const BaseControlVideoFuncTable* pFuncsTable)
40 pControlVideo->IBasicVideo_iface.lpVtbl = lpVtbl;
41 pControlVideo->pFilter = owner;
42 pControlVideo->pInterfaceLock = lock;
43 pControlVideo->pPin = pPin;
44 pControlVideo->pFuncsTable = pFuncsTable;
46 return S_OK;
49 HRESULT WINAPI BaseControlVideoImpl_GetTypeInfoCount(IBasicVideo *iface, UINT*pctinfo)
51 BaseControlVideo *This = impl_from_IBasicVideo(iface);
53 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
55 return S_OK;
58 HRESULT WINAPI BaseControlVideoImpl_GetTypeInfo(IBasicVideo *iface, UINT iTInfo, LCID lcid, ITypeInfo**ppTInfo)
60 BaseControlVideo *This = impl_from_IBasicVideo(iface);
62 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
64 return S_OK;
67 HRESULT WINAPI BaseControlVideoImpl_GetIDsOfNames(IBasicVideo *iface, REFIID riid, LPOLESTR*rgszNames, UINT cNames, LCID lcid, DISPID*rgDispId)
69 BaseControlVideo *This = impl_from_IBasicVideo(iface);
71 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
73 return S_OK;
76 HRESULT WINAPI BaseControlVideoImpl_Invoke(IBasicVideo *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS*pDispParams, VARIANT*pVarResult, EXCEPINFO*pExepInfo, UINT*puArgErr)
78 BaseControlVideo *This = impl_from_IBasicVideo(iface);
80 FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
82 return S_OK;
85 HRESULT WINAPI BaseControlVideoImpl_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame)
87 VIDEOINFOHEADER *vih;
88 BaseControlVideo *This = impl_from_IBasicVideo(iface);
90 if (!This->pPin->pConnectedTo)
91 return VFW_E_NOT_CONNECTED;
93 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
95 vih = This->pFuncsTable->pfnGetVideoFormat(This);
96 *pAvgTimePerFrame = vih->AvgTimePerFrame;
97 return S_OK;
100 HRESULT WINAPI BaseControlVideoImpl_get_BitRate(IBasicVideo *iface, LONG *pBitRate)
102 VIDEOINFOHEADER *vih;
103 BaseControlVideo *This = impl_from_IBasicVideo(iface);
105 TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
107 if (!This->pPin->pConnectedTo)
108 return VFW_E_NOT_CONNECTED;
110 vih = This->pFuncsTable->pfnGetVideoFormat(This);
111 *pBitRate = vih->dwBitRate;
112 return S_OK;
115 HRESULT WINAPI BaseControlVideoImpl_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate)
117 VIDEOINFOHEADER *vih;
118 BaseControlVideo *This = impl_from_IBasicVideo(iface);
120 TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
122 if (!This->pPin->pConnectedTo)
123 return VFW_E_NOT_CONNECTED;
125 vih = This->pFuncsTable->pfnGetVideoFormat(This);
126 *pBitErrorRate = vih->dwBitErrorRate;
127 return S_OK;
130 HRESULT WINAPI BaseControlVideoImpl_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth)
132 VIDEOINFOHEADER *vih;
133 BaseControlVideo *This = impl_from_IBasicVideo(iface);
135 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
137 vih = This->pFuncsTable->pfnGetVideoFormat(This);
138 *pVideoWidth = vih->bmiHeader.biWidth;
140 return S_OK;
143 HRESULT WINAPI BaseControlVideoImpl_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight)
145 VIDEOINFOHEADER *vih;
146 BaseControlVideo *This = impl_from_IBasicVideo(iface);
148 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
150 vih = This->pFuncsTable->pfnGetVideoFormat(This);
151 *pVideoHeight = vih->bmiHeader.biHeight;
153 return S_OK;
156 HRESULT WINAPI BaseControlVideoImpl_put_SourceLeft(IBasicVideo *iface, LONG SourceLeft)
158 RECT SourceRect;
159 BaseControlVideo *This = impl_from_IBasicVideo(iface);
161 TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
162 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
163 SourceRect.left = SourceLeft;
164 This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
166 return S_OK;
169 HRESULT WINAPI BaseControlVideoImpl_get_SourceLeft(IBasicVideo *iface, LONG *pSourceLeft)
171 RECT SourceRect;
172 BaseControlVideo *This = impl_from_IBasicVideo(iface);
174 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
175 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
176 *pSourceLeft = SourceRect.left;
178 return S_OK;
181 HRESULT WINAPI BaseControlVideoImpl_put_SourceWidth(IBasicVideo *iface, LONG SourceWidth)
183 RECT SourceRect;
184 BaseControlVideo *This = impl_from_IBasicVideo(iface);
186 TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
187 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
188 SourceRect.right = SourceRect.left + SourceWidth;
189 This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
191 return S_OK;
194 HRESULT WINAPI BaseControlVideoImpl_get_SourceWidth(IBasicVideo *iface, LONG *pSourceWidth)
196 RECT SourceRect;
197 BaseControlVideo *This = impl_from_IBasicVideo(iface);
199 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
200 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
201 *pSourceWidth = SourceRect.right - SourceRect.left;
203 return S_OK;
206 HRESULT WINAPI BaseControlVideoImpl_put_SourceTop(IBasicVideo *iface, LONG SourceTop)
208 RECT SourceRect;
209 BaseControlVideo *This = impl_from_IBasicVideo(iface);
211 TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
212 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
213 SourceRect.top = SourceTop;
214 This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
216 return S_OK;
219 HRESULT WINAPI BaseControlVideoImpl_get_SourceTop(IBasicVideo *iface, LONG *pSourceTop)
221 RECT SourceRect;
222 BaseControlVideo *This = impl_from_IBasicVideo(iface);
224 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
225 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
226 *pSourceTop = SourceRect.top;
228 return S_OK;
231 HRESULT WINAPI BaseControlVideoImpl_put_SourceHeight(IBasicVideo *iface, LONG SourceHeight)
233 RECT SourceRect;
234 BaseControlVideo *This = impl_from_IBasicVideo(iface);
236 TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
237 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
238 SourceRect.bottom = SourceRect.top + SourceHeight;
239 This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
241 return S_OK;
244 HRESULT WINAPI BaseControlVideoImpl_get_SourceHeight(IBasicVideo *iface, LONG *pSourceHeight)
246 RECT SourceRect;
247 BaseControlVideo *This = impl_from_IBasicVideo(iface);
249 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
250 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
252 *pSourceHeight = SourceRect.bottom - SourceRect.top;
254 return S_OK;
257 HRESULT WINAPI BaseControlVideoImpl_put_DestinationLeft(IBasicVideo *iface, LONG DestinationLeft)
259 RECT DestRect;
260 BaseControlVideo *This = impl_from_IBasicVideo(iface);
262 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
263 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
264 DestRect.left = DestinationLeft;
265 This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
267 return S_OK;
270 HRESULT WINAPI BaseControlVideoImpl_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft)
272 RECT DestRect;
273 BaseControlVideo *This = impl_from_IBasicVideo(iface);
275 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
276 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
277 *pDestinationLeft = DestRect.left;
279 return S_OK;
282 HRESULT WINAPI BaseControlVideoImpl_put_DestinationWidth(IBasicVideo *iface, LONG DestinationWidth)
284 RECT DestRect;
285 BaseControlVideo *This = impl_from_IBasicVideo(iface);
287 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
288 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
289 DestRect.right = DestRect.left + DestinationWidth;
290 This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
292 return S_OK;
295 HRESULT WINAPI BaseControlVideoImpl_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth)
297 RECT DestRect;
298 BaseControlVideo *This = impl_from_IBasicVideo(iface);
300 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
301 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
302 *pDestinationWidth = DestRect.right - DestRect.left;
304 return S_OK;
307 HRESULT WINAPI BaseControlVideoImpl_put_DestinationTop(IBasicVideo *iface, LONG DestinationTop)
309 RECT DestRect;
310 BaseControlVideo *This = impl_from_IBasicVideo(iface);
312 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
313 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
314 DestRect.top = DestinationTop;
315 This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
317 return S_OK;
320 HRESULT WINAPI BaseControlVideoImpl_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop)
322 RECT DestRect;
323 BaseControlVideo *This = impl_from_IBasicVideo(iface);
325 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
326 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
327 *pDestinationTop = DestRect.top;
329 return S_OK;
332 HRESULT WINAPI BaseControlVideoImpl_put_DestinationHeight(IBasicVideo *iface, LONG DestinationHeight)
334 RECT DestRect;
335 BaseControlVideo *This = impl_from_IBasicVideo(iface);
337 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
338 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
339 DestRect.right = DestRect.left + DestinationHeight;
340 This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
342 return S_OK;
345 HRESULT WINAPI BaseControlVideoImpl_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight)
347 RECT DestRect;
348 BaseControlVideo *This = impl_from_IBasicVideo(iface);
350 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
351 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
352 *pDestinationHeight = DestRect.right - DestRect.left;
354 return S_OK;
357 HRESULT WINAPI BaseControlVideoImpl_SetSourcePosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
359 RECT SourceRect;
360 BaseControlVideo *This = impl_from_IBasicVideo(iface);
362 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
363 SourceRect.left = Left;
364 SourceRect.top = Top;
365 SourceRect.right = Left + Width;
366 SourceRect.bottom = Top + Height;
367 This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
369 return S_OK;
372 HRESULT WINAPI BaseControlVideoImpl_GetSourcePosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
374 RECT SourceRect;
375 BaseControlVideo *This = impl_from_IBasicVideo(iface);
377 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
378 This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
380 *pLeft = SourceRect.left;
381 *pTop = SourceRect.top;
382 *pWidth = SourceRect.right - SourceRect.left;
383 *pHeight = SourceRect.bottom - SourceRect.top;
385 return S_OK;
388 HRESULT WINAPI BaseControlVideoImpl_SetDefaultSourcePosition(IBasicVideo *iface)
390 BaseControlVideo *This = impl_from_IBasicVideo(iface);
392 TRACE("(%p/%p)->()\n", This, iface);
393 return This->pFuncsTable->pfnSetDefaultSourceRect(This);
396 HRESULT WINAPI BaseControlVideoImpl_SetDestinationPosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
398 RECT DestRect;
399 BaseControlVideo *This = impl_from_IBasicVideo(iface);
401 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
403 DestRect.left = Left;
404 DestRect.top = Top;
405 DestRect.right = Left + Width;
406 DestRect.bottom = Top + Height;
407 This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
409 return S_OK;
412 HRESULT WINAPI BaseControlVideoImpl_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
414 RECT DestRect;
415 BaseControlVideo *This = impl_from_IBasicVideo(iface);
417 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
418 This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
420 *pLeft = DestRect.left;
421 *pTop = DestRect.top;
422 *pWidth = DestRect.right - DestRect.left;
423 *pHeight = DestRect.bottom - DestRect.top;
425 return S_OK;
428 HRESULT WINAPI BaseControlVideoImpl_SetDefaultDestinationPosition(IBasicVideo *iface)
430 BaseControlVideo *This = impl_from_IBasicVideo(iface);
432 TRACE("(%p/%p)->()\n", This, iface);
433 return This->pFuncsTable->pfnSetDefaultTargetRect(This);
436 HRESULT WINAPI BaseControlVideoImpl_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight)
438 VIDEOINFOHEADER *vih;
439 BaseControlVideo *This = impl_from_IBasicVideo(iface);
441 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
443 vih = This->pFuncsTable->pfnGetVideoFormat(This);
444 *pHeight = vih->bmiHeader.biHeight;
445 *pWidth = vih->bmiHeader.biWidth;
447 return S_OK;
450 HRESULT WINAPI BaseControlVideoImpl_GetVideoPaletteEntries(IBasicVideo *iface, LONG StartIndex, LONG Entries, LONG *pRetrieved, LONG *pPalette)
452 BaseControlVideo *This = impl_from_IBasicVideo(iface);
454 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
456 if (pRetrieved)
457 *pRetrieved = 0;
458 return VFW_E_NO_PALETTE_AVAILABLE;
461 HRESULT WINAPI BaseControlVideoImpl_GetCurrentImage(IBasicVideo *iface, LONG *pBufferSize, LONG *pDIBImage)
463 BaseControlVideo *This = impl_from_IBasicVideo(iface);
465 return This->pFuncsTable->pfnGetStaticImage(This, pBufferSize, pDIBImage);
468 HRESULT WINAPI BaseControlVideoImpl_IsUsingDefaultSource(IBasicVideo *iface)
470 BaseControlVideo *This = impl_from_IBasicVideo(iface);
472 return This->pFuncsTable->pfnIsDefaultSourceRect(This);
475 HRESULT WINAPI BaseControlVideoImpl_IsUsingDefaultDestination(IBasicVideo *iface)
477 BaseControlVideo *This = impl_from_IBasicVideo(iface);
479 return This->pFuncsTable->pfnIsDefaultTargetRect(This);