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 #include "strmbase_private.h"
23 static inline BaseControlVideo
*impl_from_IBasicVideo(IBasicVideo
*iface
)
25 return CONTAINING_RECORD(iface
, BaseControlVideo
, IBasicVideo_iface
);
28 HRESULT WINAPI
BaseControlVideo_Init(BaseControlVideo
*pControlVideo
, const IBasicVideoVtbl
*lpVtbl
, BaseFilter
*owner
, CRITICAL_SECTION
*lock
, BasePin
* pPin
, const BaseControlVideoFuncTable
* pFuncsTable
)
30 pControlVideo
->IBasicVideo_iface
.lpVtbl
= lpVtbl
;
31 pControlVideo
->pFilter
= owner
;
32 pControlVideo
->pInterfaceLock
= lock
;
33 pControlVideo
->pPin
= pPin
;
34 pControlVideo
->pFuncsTable
= pFuncsTable
;
36 BaseDispatch_Init(&pControlVideo
->baseDispatch
, &IID_IBasicVideo
);
41 HRESULT WINAPI
BaseControlVideo_Destroy(BaseControlVideo
*pControlVideo
)
43 return BaseDispatch_Destroy(&pControlVideo
->baseDispatch
);
46 HRESULT WINAPI
BaseControlVideoImpl_GetTypeInfoCount(IBasicVideo
*iface
, UINT
*pctinfo
)
48 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
50 return BaseDispatchImpl_GetTypeInfoCount(&This
->baseDispatch
, pctinfo
);
53 HRESULT WINAPI
BaseControlVideoImpl_GetTypeInfo(IBasicVideo
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
55 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
57 return BaseDispatchImpl_GetTypeInfo(&This
->baseDispatch
, &IID_NULL
, iTInfo
, lcid
, ppTInfo
);
60 HRESULT WINAPI
BaseControlVideoImpl_GetIDsOfNames(IBasicVideo
*iface
, REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
62 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
64 return BaseDispatchImpl_GetIDsOfNames(&This
->baseDispatch
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
67 HRESULT WINAPI
BaseControlVideoImpl_Invoke(IBasicVideo
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
, UINT
*puArgErr
)
69 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
73 hr
= BaseDispatchImpl_GetTypeInfo(&This
->baseDispatch
, riid
, 1, lcid
, &pTypeInfo
);
76 hr
= ITypeInfo_Invoke(pTypeInfo
, &This
->IBasicVideo_iface
, dispIdMember
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
77 ITypeInfo_Release(pTypeInfo
);
83 HRESULT WINAPI
BaseControlVideoImpl_get_AvgTimePerFrame(IBasicVideo
*iface
, REFTIME
*pAvgTimePerFrame
)
86 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
88 if (!This
->pPin
->pConnectedTo
)
89 return VFW_E_NOT_CONNECTED
;
91 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
93 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
94 *pAvgTimePerFrame
= vih
->AvgTimePerFrame
;
98 HRESULT WINAPI
BaseControlVideoImpl_get_BitRate(IBasicVideo
*iface
, LONG
*pBitRate
)
100 VIDEOINFOHEADER
*vih
;
101 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
103 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
105 if (!This
->pPin
->pConnectedTo
)
106 return VFW_E_NOT_CONNECTED
;
108 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
109 *pBitRate
= vih
->dwBitRate
;
113 HRESULT WINAPI
BaseControlVideoImpl_get_BitErrorRate(IBasicVideo
*iface
, LONG
*pBitErrorRate
)
115 VIDEOINFOHEADER
*vih
;
116 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
118 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
120 if (!This
->pPin
->pConnectedTo
)
121 return VFW_E_NOT_CONNECTED
;
123 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
124 *pBitErrorRate
= vih
->dwBitErrorRate
;
128 HRESULT WINAPI
BaseControlVideoImpl_get_VideoWidth(IBasicVideo
*iface
, LONG
*pVideoWidth
)
130 VIDEOINFOHEADER
*vih
;
131 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
133 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
135 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
136 *pVideoWidth
= vih
->bmiHeader
.biWidth
;
141 HRESULT WINAPI
BaseControlVideoImpl_get_VideoHeight(IBasicVideo
*iface
, LONG
*pVideoHeight
)
143 VIDEOINFOHEADER
*vih
;
144 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
146 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
148 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
149 *pVideoHeight
= abs(vih
->bmiHeader
.biHeight
);
154 HRESULT WINAPI
BaseControlVideoImpl_put_SourceLeft(IBasicVideo
*iface
, LONG SourceLeft
)
157 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
159 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceLeft
);
160 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
161 SourceRect
.left
= SourceLeft
;
162 This
->pFuncsTable
->pfnSetSourceRect(This
, &SourceRect
);
167 HRESULT WINAPI
BaseControlVideoImpl_get_SourceLeft(IBasicVideo
*iface
, LONG
*pSourceLeft
)
170 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
172 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
173 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
174 *pSourceLeft
= SourceRect
.left
;
179 HRESULT WINAPI
BaseControlVideoImpl_put_SourceWidth(IBasicVideo
*iface
, LONG SourceWidth
)
182 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
184 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceWidth
);
185 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
186 SourceRect
.right
= SourceRect
.left
+ SourceWidth
;
187 This
->pFuncsTable
->pfnSetSourceRect(This
, &SourceRect
);
192 HRESULT WINAPI
BaseControlVideoImpl_get_SourceWidth(IBasicVideo
*iface
, LONG
*pSourceWidth
)
195 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
197 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
198 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
199 *pSourceWidth
= SourceRect
.right
- SourceRect
.left
;
204 HRESULT WINAPI
BaseControlVideoImpl_put_SourceTop(IBasicVideo
*iface
, LONG SourceTop
)
207 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
209 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceTop
);
210 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
211 SourceRect
.top
= SourceTop
;
212 This
->pFuncsTable
->pfnSetSourceRect(This
, &SourceRect
);
217 HRESULT WINAPI
BaseControlVideoImpl_get_SourceTop(IBasicVideo
*iface
, LONG
*pSourceTop
)
220 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
222 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
223 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
224 *pSourceTop
= SourceRect
.top
;
229 HRESULT WINAPI
BaseControlVideoImpl_put_SourceHeight(IBasicVideo
*iface
, LONG SourceHeight
)
232 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
234 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceHeight
);
235 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
236 SourceRect
.bottom
= SourceRect
.top
+ SourceHeight
;
237 This
->pFuncsTable
->pfnSetSourceRect(This
, &SourceRect
);
242 HRESULT WINAPI
BaseControlVideoImpl_get_SourceHeight(IBasicVideo
*iface
, LONG
*pSourceHeight
)
245 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
247 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
248 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
250 *pSourceHeight
= SourceRect
.bottom
- SourceRect
.top
;
255 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationLeft(IBasicVideo
*iface
, LONG DestinationLeft
)
258 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
260 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationLeft
);
261 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
262 DestRect
.left
= DestinationLeft
;
263 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
268 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationLeft(IBasicVideo
*iface
, LONG
*pDestinationLeft
)
271 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
273 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
274 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
275 *pDestinationLeft
= DestRect
.left
;
280 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationWidth(IBasicVideo
*iface
, LONG DestinationWidth
)
283 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
285 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationWidth
);
286 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
287 DestRect
.right
= DestRect
.left
+ DestinationWidth
;
288 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
293 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationWidth(IBasicVideo
*iface
, LONG
*pDestinationWidth
)
296 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
298 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
299 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
300 *pDestinationWidth
= DestRect
.right
- DestRect
.left
;
305 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationTop(IBasicVideo
*iface
, LONG DestinationTop
)
308 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
310 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationTop
);
311 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
312 DestRect
.top
= DestinationTop
;
313 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
318 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationTop(IBasicVideo
*iface
, LONG
*pDestinationTop
)
321 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
323 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
324 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
325 *pDestinationTop
= DestRect
.top
;
330 HRESULT WINAPI
BaseControlVideoImpl_put_DestinationHeight(IBasicVideo
*iface
, LONG DestinationHeight
)
333 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
335 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationHeight
);
336 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
337 DestRect
.right
= DestRect
.left
+ DestinationHeight
;
338 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
343 HRESULT WINAPI
BaseControlVideoImpl_get_DestinationHeight(IBasicVideo
*iface
, LONG
*pDestinationHeight
)
346 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
348 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
349 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
350 *pDestinationHeight
= DestRect
.right
- DestRect
.left
;
355 HRESULT WINAPI
BaseControlVideoImpl_SetSourcePosition(IBasicVideo
*iface
, LONG Left
, LONG Top
, LONG Width
, LONG Height
)
358 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
360 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
361 SourceRect
.left
= Left
;
362 SourceRect
.top
= Top
;
363 SourceRect
.right
= Left
+ Width
;
364 SourceRect
.bottom
= Top
+ Height
;
365 This
->pFuncsTable
->pfnSetSourceRect(This
, &SourceRect
);
370 HRESULT WINAPI
BaseControlVideoImpl_GetSourcePosition(IBasicVideo
*iface
, LONG
*pLeft
, LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
373 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
375 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
376 This
->pFuncsTable
->pfnGetSourceRect(This
, &SourceRect
);
378 *pLeft
= SourceRect
.left
;
379 *pTop
= SourceRect
.top
;
380 *pWidth
= SourceRect
.right
- SourceRect
.left
;
381 *pHeight
= SourceRect
.bottom
- SourceRect
.top
;
386 HRESULT WINAPI
BaseControlVideoImpl_SetDefaultSourcePosition(IBasicVideo
*iface
)
388 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
390 TRACE("(%p/%p)->()\n", This
, iface
);
391 return This
->pFuncsTable
->pfnSetDefaultSourceRect(This
);
394 HRESULT WINAPI
BaseControlVideoImpl_SetDestinationPosition(IBasicVideo
*iface
, LONG Left
, LONG Top
, LONG Width
, LONG Height
)
397 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
399 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
401 DestRect
.left
= Left
;
403 DestRect
.right
= Left
+ Width
;
404 DestRect
.bottom
= Top
+ Height
;
405 This
->pFuncsTable
->pfnSetTargetRect(This
, &DestRect
);
410 HRESULT WINAPI
BaseControlVideoImpl_GetDestinationPosition(IBasicVideo
*iface
, LONG
*pLeft
, LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
413 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
415 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
416 This
->pFuncsTable
->pfnGetTargetRect(This
, &DestRect
);
418 *pLeft
= DestRect
.left
;
419 *pTop
= DestRect
.top
;
420 *pWidth
= DestRect
.right
- DestRect
.left
;
421 *pHeight
= DestRect
.bottom
- DestRect
.top
;
426 HRESULT WINAPI
BaseControlVideoImpl_SetDefaultDestinationPosition(IBasicVideo
*iface
)
428 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
430 TRACE("(%p/%p)->()\n", This
, iface
);
431 return This
->pFuncsTable
->pfnSetDefaultTargetRect(This
);
434 HRESULT WINAPI
BaseControlVideoImpl_GetVideoSize(IBasicVideo
*iface
, LONG
*pWidth
, LONG
*pHeight
)
436 VIDEOINFOHEADER
*vih
;
437 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
439 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
441 vih
= This
->pFuncsTable
->pfnGetVideoFormat(This
);
442 *pHeight
= vih
->bmiHeader
.biHeight
;
443 *pWidth
= vih
->bmiHeader
.biWidth
;
448 HRESULT WINAPI
BaseControlVideoImpl_GetVideoPaletteEntries(IBasicVideo
*iface
, LONG StartIndex
, LONG Entries
, LONG
*pRetrieved
, LONG
*pPalette
)
450 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
452 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
456 return VFW_E_NO_PALETTE_AVAILABLE
;
459 HRESULT WINAPI
BaseControlVideoImpl_GetCurrentImage(IBasicVideo
*iface
, LONG
*pBufferSize
, LONG
*pDIBImage
)
461 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
463 return This
->pFuncsTable
->pfnGetStaticImage(This
, pBufferSize
, pDIBImage
);
466 HRESULT WINAPI
BaseControlVideoImpl_IsUsingDefaultSource(IBasicVideo
*iface
)
468 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
470 return This
->pFuncsTable
->pfnIsDefaultSourceRect(This
);
473 HRESULT WINAPI
BaseControlVideoImpl_IsUsingDefaultDestination(IBasicVideo
*iface
)
475 BaseControlVideo
*This
= impl_from_IBasicVideo(iface
);
477 return This
->pFuncsTable
->pfnIsDefaultTargetRect(This
);