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
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
;
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
);
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
);
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
);
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
);
85 HRESULT WINAPI
BaseControlVideoImpl_get_AvgTimePerFrame(IBasicVideo
*iface
, REFTIME
*pAvgTimePerFrame
)
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
;
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
;
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
;
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
;
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
;
156 HRESULT WINAPI
BaseControlVideoImpl_put_SourceLeft(IBasicVideo
*iface
, LONG SourceLeft
)
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
);
169 HRESULT WINAPI
BaseControlVideoImpl_get_SourceLeft(IBasicVideo
*iface
, LONG
*pSourceLeft
)
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
;
181 HRESULT WINAPI
BaseControlVideoImpl_put_SourceWidth(IBasicVideo
*iface
, LONG SourceWidth
)
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
);
194 HRESULT WINAPI
BaseControlVideoImpl_get_SourceWidth(IBasicVideo
*iface
, LONG
*pSourceWidth
)
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
;
206 HRESULT WINAPI
BaseControlVideoImpl_put_SourceTop(IBasicVideo
*iface
, LONG SourceTop
)
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
);
219 HRESULT WINAPI
BaseControlVideoImpl_get_SourceTop(IBasicVideo
*iface
, LONG
*pSourceTop
)
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
;
231 HRESULT WINAPI
BaseControlVideoImpl_put_SourceHeight(IBasicVideo
*iface
, LONG SourceHeight
)
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
);
244 HRESULT WINAPI
BaseControlVideoImpl_get_SourceHeight(IBasicVideo
*iface
, LONG
*pSourceHeight
)
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
;
257 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationLeft(IBasicVideo
*iface
, LONG DestinationLeft
)
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
);
270 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationLeft(IBasicVideo
*iface
, LONG
*pDestinationLeft
)
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
;
282 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationWidth(IBasicVideo
*iface
, LONG DestinationWidth
)
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
);
295 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationWidth(IBasicVideo
*iface
, LONG
*pDestinationWidth
)
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
;
307 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationTop(IBasicVideo
*iface
, LONG DestinationTop
)
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
);
320 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationTop(IBasicVideo
*iface
, LONG
*pDestinationTop
)
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
;
332 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationHeight(IBasicVideo
*iface
, LONG DestinationHeight
)
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
);
345 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationHeight(IBasicVideo
*iface
, LONG
*pDestinationHeight
)
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
;
357 HRESULT WINAPI
BaseControlVideoImpl_SetSourcePosition(IBasicVideo
*iface
, LONG Left
, LONG Top
, LONG Width
, LONG Height
)
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
);
372 HRESULT WINAPI
BaseControlVideoImpl_GetSourcePosition(IBasicVideo
*iface
, LONG
*pLeft
, LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
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
;
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
)
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
;
405 DestRect
.right
= Left
+ Width
;
406 DestRect
.bottom
= Top
+ Height
;
407 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
412 HRESULT WINAPI
BaseControlVideoImpl_GetDestinationPosition(IBasicVideo
*iface
, LONG
*pLeft
, LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
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
;
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
;
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
);
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
);