2 * Copyright 2020 Nikolay Sivov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "evr_classes.h"
27 #include "evr_private.h"
29 #include "wine/debug.h"
30 #include "wine/heap.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(evr
);
34 struct video_presenter
36 IMFVideoPresenter IMFVideoPresenter_iface
;
37 IMFVideoDeviceID IMFVideoDeviceID_iface
;
38 IMFTopologyServiceLookupClient IMFTopologyServiceLookupClient_iface
;
39 IMFVideoDisplayControl IMFVideoDisplayControl_iface
;
40 IMFRateSupport IMFRateSupport_iface
;
41 IUnknown IUnknown_inner
;
46 static struct video_presenter
*impl_from_IUnknown(IUnknown
*iface
)
48 return CONTAINING_RECORD(iface
, struct video_presenter
, IUnknown_inner
);
51 static struct video_presenter
*impl_from_IMFVideoPresenter(IMFVideoPresenter
*iface
)
53 return CONTAINING_RECORD(iface
, struct video_presenter
, IMFVideoPresenter_iface
);
56 static struct video_presenter
*impl_from_IMFVideoDeviceID(IMFVideoDeviceID
*iface
)
58 return CONTAINING_RECORD(iface
, struct video_presenter
, IMFVideoDeviceID_iface
);
61 static struct video_presenter
*impl_from_IMFTopologyServiceLookupClient(IMFTopologyServiceLookupClient
*iface
)
63 return CONTAINING_RECORD(iface
, struct video_presenter
, IMFTopologyServiceLookupClient_iface
);
66 static struct video_presenter
*impl_from_IMFVideoDisplayControl(IMFVideoDisplayControl
*iface
)
68 return CONTAINING_RECORD(iface
, struct video_presenter
, IMFVideoDisplayControl_iface
);
71 static struct video_presenter
*impl_from_IMFRateSupport(IMFRateSupport
*iface
)
73 return CONTAINING_RECORD(iface
, struct video_presenter
, IMFRateSupport_iface
);
76 static HRESULT WINAPI
video_presenter_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **obj
)
78 struct video_presenter
*presenter
= impl_from_IUnknown(iface
);
80 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
82 if (IsEqualIID(riid
, &IID_IUnknown
))
86 else if (IsEqualIID(riid
, &IID_IMFClockStateSink
)
87 || IsEqualIID(riid
, &IID_IMFVideoPresenter
))
89 *obj
= &presenter
->IMFVideoPresenter_iface
;
91 else if (IsEqualIID(riid
, &IID_IMFVideoDeviceID
))
93 *obj
= &presenter
->IMFVideoDeviceID_iface
;
95 else if (IsEqualIID(riid
, &IID_IMFTopologyServiceLookupClient
))
97 *obj
= &presenter
->IMFTopologyServiceLookupClient_iface
;
99 else if (IsEqualIID(riid
, &IID_IMFVideoDisplayControl
))
101 *obj
= &presenter
->IMFVideoDisplayControl_iface
;
103 else if (IsEqualIID(riid
, &IID_IMFRateSupport
))
105 *obj
= &presenter
->IMFRateSupport_iface
;
109 WARN("Unimplemented interface %s.\n", debugstr_guid(riid
));
111 return E_NOINTERFACE
;
114 IUnknown_AddRef((IUnknown
*)*obj
);
118 static ULONG WINAPI
video_presenter_inner_AddRef(IUnknown
*iface
)
120 struct video_presenter
*presenter
= impl_from_IUnknown(iface
);
121 ULONG refcount
= InterlockedIncrement(&presenter
->refcount
);
123 TRACE("%p, refcount %u.\n", iface
, refcount
);
128 static ULONG WINAPI
video_presenter_inner_Release(IUnknown
*iface
)
130 struct video_presenter
*presenter
= impl_from_IUnknown(iface
);
131 ULONG refcount
= InterlockedDecrement(&presenter
->refcount
);
133 TRACE("%p, refcount %u.\n", iface
, refcount
);
137 heap_free(presenter
);
143 static const IUnknownVtbl video_presenter_inner_vtbl
=
145 video_presenter_inner_QueryInterface
,
146 video_presenter_inner_AddRef
,
147 video_presenter_inner_Release
,
150 static HRESULT WINAPI
video_presenter_QueryInterface(IMFVideoPresenter
*iface
, REFIID riid
, void **obj
)
152 struct video_presenter
*presenter
= impl_from_IMFVideoPresenter(iface
);
153 return IUnknown_QueryInterface(presenter
->outer_unk
, riid
, obj
);
156 static ULONG WINAPI
video_presenter_AddRef(IMFVideoPresenter
*iface
)
158 struct video_presenter
*presenter
= impl_from_IMFVideoPresenter(iface
);
159 return IUnknown_AddRef(presenter
->outer_unk
);
162 static ULONG WINAPI
video_presenter_Release(IMFVideoPresenter
*iface
)
164 struct video_presenter
*presenter
= impl_from_IMFVideoPresenter(iface
);
165 return IUnknown_Release(presenter
->outer_unk
);
168 static HRESULT WINAPI
video_presenter_OnClockStart(IMFVideoPresenter
*iface
, MFTIME systime
, LONGLONG offset
)
170 FIXME("%p, %s, %s.\n", iface
, debugstr_time(systime
), wine_dbgstr_longlong(offset
));
175 static HRESULT WINAPI
video_presenter_OnClockStop(IMFVideoPresenter
*iface
, MFTIME systime
)
177 FIXME("%p, %s.\n", iface
, debugstr_time(systime
));
182 static HRESULT WINAPI
video_presenter_OnClockPause(IMFVideoPresenter
*iface
, MFTIME systime
)
184 FIXME("%p, %s.\n", iface
, debugstr_time(systime
));
189 static HRESULT WINAPI
video_presenter_OnClockRestart(IMFVideoPresenter
*iface
, MFTIME systime
)
191 FIXME("%p, %s.\n", iface
, debugstr_time(systime
));
196 static HRESULT WINAPI
video_presenter_OnClockSetRate(IMFVideoPresenter
*iface
, MFTIME systime
, float rate
)
198 FIXME("%p, %s, %f.\n", iface
, debugstr_time(systime
), rate
);
203 static HRESULT WINAPI
video_presenter_ProcessMessage(IMFVideoPresenter
*iface
, MFVP_MESSAGE_TYPE message
, ULONG_PTR param
)
205 FIXME("%p, %d, %lu.\n", iface
, message
, param
);
210 static HRESULT WINAPI
video_presenter_GetCurrentMediaType(IMFVideoPresenter
*iface
, IMFVideoMediaType
**media_type
)
212 FIXME("%p, %p.\n", iface
, media_type
);
217 static const IMFVideoPresenterVtbl video_presenter_vtbl
=
219 video_presenter_QueryInterface
,
220 video_presenter_AddRef
,
221 video_presenter_Release
,
222 video_presenter_OnClockStart
,
223 video_presenter_OnClockStop
,
224 video_presenter_OnClockPause
,
225 video_presenter_OnClockRestart
,
226 video_presenter_OnClockSetRate
,
227 video_presenter_ProcessMessage
,
228 video_presenter_GetCurrentMediaType
,
231 static HRESULT WINAPI
video_presenter_device_id_QueryInterface(IMFVideoDeviceID
*iface
, REFIID riid
, void **obj
)
233 struct video_presenter
*presenter
= impl_from_IMFVideoDeviceID(iface
);
234 return IMFVideoPresenter_QueryInterface(&presenter
->IMFVideoPresenter_iface
, riid
, obj
);
237 static ULONG WINAPI
video_presenter_device_id_AddRef(IMFVideoDeviceID
*iface
)
239 struct video_presenter
*presenter
= impl_from_IMFVideoDeviceID(iface
);
240 return IMFVideoPresenter_AddRef(&presenter
->IMFVideoPresenter_iface
);
243 static ULONG WINAPI
video_presenter_device_id_Release(IMFVideoDeviceID
*iface
)
245 struct video_presenter
*presenter
= impl_from_IMFVideoDeviceID(iface
);
246 return IMFVideoPresenter_Release(&presenter
->IMFVideoPresenter_iface
);
249 static HRESULT WINAPI
video_presenter_device_id_GetDeviceID(IMFVideoDeviceID
*iface
, IID
*device_id
)
251 TRACE("%p, %p.\n", iface
, device_id
);
256 memcpy(device_id
, &IID_IDirect3DDevice9
, sizeof(*device_id
));
261 static const IMFVideoDeviceIDVtbl video_presenter_device_id_vtbl
=
263 video_presenter_device_id_QueryInterface
,
264 video_presenter_device_id_AddRef
,
265 video_presenter_device_id_Release
,
266 video_presenter_device_id_GetDeviceID
,
269 static HRESULT WINAPI
video_presenter_service_client_QueryInterface(IMFTopologyServiceLookupClient
*iface
,
270 REFIID riid
, void **obj
)
272 struct video_presenter
*presenter
= impl_from_IMFTopologyServiceLookupClient(iface
);
273 return IMFVideoPresenter_QueryInterface(&presenter
->IMFVideoPresenter_iface
, riid
, obj
);
276 static ULONG WINAPI
video_presenter_service_client_AddRef(IMFTopologyServiceLookupClient
*iface
)
278 struct video_presenter
*presenter
= impl_from_IMFTopologyServiceLookupClient(iface
);
279 return IMFVideoPresenter_AddRef(&presenter
->IMFVideoPresenter_iface
);
282 static ULONG WINAPI
video_presenter_service_client_Release(IMFTopologyServiceLookupClient
*iface
)
284 struct video_presenter
*presenter
= impl_from_IMFTopologyServiceLookupClient(iface
);
285 return IMFVideoPresenter_Release(&presenter
->IMFVideoPresenter_iface
);
288 static HRESULT WINAPI
video_presenter_service_client_InitServicePointers(IMFTopologyServiceLookupClient
*iface
,
289 IMFTopologyServiceLookup
*service_lookup
)
291 FIXME("%p, %p.\n", iface
, service_lookup
);
296 static HRESULT WINAPI
video_presenter_service_client_ReleaseServicePointers(IMFTopologyServiceLookupClient
*iface
)
298 FIXME("%p.\n", iface
);
303 static const IMFTopologyServiceLookupClientVtbl video_presenter_service_client_vtbl
=
305 video_presenter_service_client_QueryInterface
,
306 video_presenter_service_client_AddRef
,
307 video_presenter_service_client_Release
,
308 video_presenter_service_client_InitServicePointers
,
309 video_presenter_service_client_ReleaseServicePointers
,
312 static HRESULT WINAPI
video_presenter_control_QueryInterface(IMFVideoDisplayControl
*iface
, REFIID riid
, void **obj
)
314 struct video_presenter
*presenter
= impl_from_IMFVideoDisplayControl(iface
);
315 return IMFVideoPresenter_QueryInterface(&presenter
->IMFVideoPresenter_iface
, riid
, obj
);
318 static ULONG WINAPI
video_presenter_control_AddRef(IMFVideoDisplayControl
*iface
)
320 struct video_presenter
*presenter
= impl_from_IMFVideoDisplayControl(iface
);
321 return IMFVideoPresenter_AddRef(&presenter
->IMFVideoPresenter_iface
);
324 static ULONG WINAPI
video_presenter_control_Release(IMFVideoDisplayControl
*iface
)
326 struct video_presenter
*presenter
= impl_from_IMFVideoDisplayControl(iface
);
327 return IMFVideoPresenter_Release(&presenter
->IMFVideoPresenter_iface
);
330 static HRESULT WINAPI
video_presenter_control_GetNativeVideoSize(IMFVideoDisplayControl
*iface
, SIZE
*video_size
,
333 FIXME("%p, %p, %p.\n", iface
, video_size
, aspect_ratio
);
338 static HRESULT WINAPI
video_presenter_control_GetIdealVideoSize(IMFVideoDisplayControl
*iface
, SIZE
*min_size
,
341 FIXME("%p, %p, %p.\n", iface
, min_size
, max_size
);
346 static HRESULT WINAPI
video_presenter_control_SetVideoPosition(IMFVideoDisplayControl
*iface
,
347 const MFVideoNormalizedRect
*source
, const RECT
*dest
)
349 FIXME("%p, %p, %p.\n", iface
, source
, dest
);
354 static HRESULT WINAPI
video_presenter_control_GetVideoPosition(IMFVideoDisplayControl
*iface
, MFVideoNormalizedRect
*source
,
357 FIXME("%p, %p, %p.\n", iface
, source
, dest
);
362 static HRESULT WINAPI
video_presenter_control_SetAspectRatioMode(IMFVideoDisplayControl
*iface
, DWORD mode
)
364 FIXME("%p, %d.\n", iface
, mode
);
369 static HRESULT WINAPI
video_presenter_control_GetAspectRatioMode(IMFVideoDisplayControl
*iface
, DWORD
*mode
)
371 FIXME("%p, %p.\n", iface
, mode
);
376 static HRESULT WINAPI
video_presenter_control_SetVideoWindow(IMFVideoDisplayControl
*iface
, HWND window
)
378 FIXME("%p, %p.\n", iface
, window
);
383 static HRESULT WINAPI
video_presenter_control_GetVideoWindow(IMFVideoDisplayControl
*iface
, HWND
*window
)
385 FIXME("%p, %p.\n", iface
, window
);
390 static HRESULT WINAPI
video_presenter_control_RepaintVideo(IMFVideoDisplayControl
*iface
)
392 FIXME("%p.\n", iface
);
397 static HRESULT WINAPI
video_presenter_control_GetCurrentImage(IMFVideoDisplayControl
*iface
, BITMAPINFOHEADER
*header
,
398 BYTE
**dib
, DWORD
*dib_size
, LONGLONG
*timestamp
)
400 FIXME("%p, %p, %p, %p, %p.\n", iface
, header
, dib
, dib_size
, timestamp
);
405 static const IMFVideoDisplayControlVtbl video_presenter_control_vtbl
=
407 video_presenter_control_QueryInterface
,
408 video_presenter_control_AddRef
,
409 video_presenter_control_Release
,
410 video_presenter_control_GetNativeVideoSize
,
411 video_presenter_control_GetIdealVideoSize
,
412 video_presenter_control_SetVideoPosition
,
413 video_presenter_control_GetVideoPosition
,
414 video_presenter_control_SetAspectRatioMode
,
415 video_presenter_control_GetAspectRatioMode
,
416 video_presenter_control_SetVideoWindow
,
417 video_presenter_control_GetVideoWindow
,
418 video_presenter_control_RepaintVideo
,
419 video_presenter_control_GetCurrentImage
,
422 static HRESULT WINAPI
video_presenter_rate_support_QueryInterface(IMFRateSupport
*iface
, REFIID riid
, void **obj
)
424 struct video_presenter
*presenter
= impl_from_IMFRateSupport(iface
);
425 return IMFVideoPresenter_QueryInterface(&presenter
->IMFVideoPresenter_iface
, riid
, obj
);
428 static ULONG WINAPI
video_presenter_rate_support_AddRef(IMFRateSupport
*iface
)
430 struct video_presenter
*presenter
= impl_from_IMFRateSupport(iface
);
431 return IMFVideoPresenter_AddRef(&presenter
->IMFVideoPresenter_iface
);
434 static ULONG WINAPI
video_presenter_rate_support_Release(IMFRateSupport
*iface
)
436 struct video_presenter
*presenter
= impl_from_IMFRateSupport(iface
);
437 return IMFVideoPresenter_Release(&presenter
->IMFVideoPresenter_iface
);
440 static HRESULT WINAPI
video_presenter_rate_support_GetSlowestRate(IMFRateSupport
*iface
, MFRATE_DIRECTION direction
,
441 BOOL thin
, float *rate
)
443 TRACE("%p, %d, %d, %p.\n", iface
, direction
, thin
, rate
);
450 static HRESULT WINAPI
video_presenter_rate_support_GetFastestRate(IMFRateSupport
*iface
, MFRATE_DIRECTION direction
,
451 BOOL thin
, float *rate
)
456 static HRESULT WINAPI
video_presenter_rate_support_IsRateSupported(IMFRateSupport
*iface
, BOOL thin
, float rate
,
457 float *nearest_supported_rate
)
462 static const IMFRateSupportVtbl video_presenter_rate_support_vtbl
=
464 video_presenter_rate_support_QueryInterface
,
465 video_presenter_rate_support_AddRef
,
466 video_presenter_rate_support_Release
,
467 video_presenter_rate_support_GetSlowestRate
,
468 video_presenter_rate_support_GetFastestRate
,
469 video_presenter_rate_support_IsRateSupported
,
472 HRESULT WINAPI
MFCreateVideoPresenter(IUnknown
*owner
, REFIID riid_device
, REFIID riid
, void **obj
)
474 TRACE("%p, %s, %s, %p.\n", owner
, debugstr_guid(riid_device
), debugstr_guid(riid
), obj
);
478 if (!IsEqualIID(riid_device
, &IID_IDirect3DDevice9
))
481 return CoCreateInstance(&CLSID_MFVideoPresenter9
, owner
, CLSCTX_INPROC_SERVER
, riid
, obj
);
484 HRESULT
evr_presenter_create(IUnknown
*outer
, void **out
)
486 struct video_presenter
*object
;
488 if (!(object
= heap_alloc(sizeof(*object
))))
489 return E_OUTOFMEMORY
;
491 object
->IMFVideoPresenter_iface
.lpVtbl
= &video_presenter_vtbl
;
492 object
->IMFVideoDeviceID_iface
.lpVtbl
= &video_presenter_device_id_vtbl
;
493 object
->IMFTopologyServiceLookupClient_iface
.lpVtbl
= &video_presenter_service_client_vtbl
;
494 object
->IMFVideoDisplayControl_iface
.lpVtbl
= &video_presenter_control_vtbl
;
495 object
->IMFRateSupport_iface
.lpVtbl
= &video_presenter_rate_support_vtbl
;
496 object
->IUnknown_inner
.lpVtbl
= &video_presenter_inner_vtbl
;
497 object
->outer_unk
= outer
? outer
: &object
->IUnknown_inner
;
498 object
->refcount
= 1;
500 *out
= &object
->IUnknown_inner
;