mf/evr: Set display window to the presenter if it was specified on sink creation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-11-12 13:36:39 +03:00 committed by Alexandre Julliard
parent e272e1a1c3
commit 176ca7b87b
3 changed files with 54 additions and 4 deletions

View File

@ -84,6 +84,7 @@ struct video_renderer
IMFTransform *mixer;
IMFVideoPresenter *presenter;
HWND window;
IUnknown *device_manager;
unsigned int flags;
unsigned int state;
@ -1098,13 +1099,18 @@ static HRESULT video_renderer_create_mixer(IMFAttributes *attributes, IMFTransfo
return CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)out);
}
static HRESULT video_renderer_create_presenter(IMFAttributes *attributes, IMFVideoPresenter **out)
static HRESULT video_renderer_create_presenter(struct video_renderer *renderer, IMFAttributes *attributes,
IMFVideoPresenter **out)
{
unsigned int flags = 0;
IMFActivate *activate;
UINT64 value;
CLSID clsid;
HRESULT hr;
if (attributes && SUCCEEDED(IMFAttributes_GetUINT64(attributes, &MF_ACTIVATE_VIDEO_WINDOW, &value)))
renderer->window = UlongToHandle(value);
if (attributes && SUCCEEDED(IMFAttributes_GetUnknown(attributes, &MF_ACTIVATE_CUSTOM_VIDEO_PRESENTER_ACTIVATE,
&IID_IMFActivate, (void **)&activate)))
{
@ -1193,8 +1199,15 @@ static HRESULT video_renderer_configure_mixer(struct video_renderer *renderer)
static HRESULT video_renderer_configure_presenter(struct video_renderer *renderer)
{
IMFTopologyServiceLookupClient *lookup_client;
IMFVideoDisplayControl *control;
HRESULT hr;
if (SUCCEEDED(IMFVideoPresenter_QueryInterface(renderer->presenter, &IID_IMFVideoDisplayControl, (void **)&control)))
{
IMFVideoDisplayControl_SetVideoWindow(control, renderer->window);
IMFVideoDisplayControl_Release(control);
}
if (SUCCEEDED(hr = IMFVideoPresenter_QueryInterface(renderer->presenter, &IID_IMFTopologyServiceLookupClient,
(void **)&lookup_client)))
{
@ -1270,7 +1283,7 @@ static HRESULT WINAPI video_renderer_InitializeRenderer(IMFVideoRenderer *iface,
if (presenter)
IMFVideoPresenter_AddRef(presenter);
else if (FAILED(hr = video_renderer_create_presenter(NULL, &presenter)))
else if (FAILED(hr = video_renderer_create_presenter(renderer, NULL, &presenter)))
{
WARN("Failed to create default presenter, hr %#x.\n", hr);
IMFTransform_Release(mixer);
@ -2141,7 +2154,7 @@ static HRESULT evr_create_object(IMFAttributes *attributes, void *user_context,
if (FAILED(hr = video_renderer_create_mixer(attributes, &mixer)))
goto failed;
if (FAILED(hr = video_renderer_create_presenter(attributes, &presenter)))
if (FAILED(hr = video_renderer_create_presenter(object, attributes, &presenter)))
goto failed;
if (FAILED(hr = video_renderer_initialize(object, mixer, presenter)))

View File

@ -1,5 +1,5 @@
TESTDLL = mf.dll
IMPORTS = mf mfplat mfuuid ole32
IMPORTS = mf mfplat mfuuid ole32 user32
C_SRCS = \
mf.c

View File

@ -56,6 +56,16 @@ static void _expect_ref(IUnknown* obj, ULONG expected_refcount, int line)
expected_refcount);
}
static HWND create_window(void)
{
RECT r = {0, 0, 640, 480};
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW | WS_VISIBLE, FALSE);
return CreateWindowA("static", "mf_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
}
static WCHAR *load_resource(const WCHAR *name)
{
static WCHAR pathW[MAX_PATH];
@ -3235,6 +3245,7 @@ static void test_evr(void)
IMFMediaSink *sink, *sink2;
IMFAttributes *attributes;
IMFActivate *activate;
HWND window, window2;
DWORD flags, count;
LONG sample_count;
IMFGetService *gs;
@ -3258,6 +3269,32 @@ static void test_evr(void)
hr = MFCreateVideoRendererActivate(NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
/* Window */
window = create_window();
hr = MFCreateVideoRendererActivate(window, &activate);
ok(hr == S_OK, "Failed to create activate object, hr %#x.\n", hr);
hr = IMFActivate_GetUINT64(activate, &MF_ACTIVATE_VIDEO_WINDOW, &value);
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
ok(UlongToHandle(value) == window, "Unexpected value.\n");
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = MFGetService((IUnknown *)sink, &MR_VIDEO_RENDER_SERVICE, &IID_IMFVideoDisplayControl,
(void **)&display_control);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
window2 = NULL;
hr = IMFVideoDisplayControl_GetVideoWindow(display_control, &window2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(window2 == window, "Unexpected window %p.\n", window2);
IMFVideoDisplayControl_Release(display_control);
IMFMediaSink_Release(sink);
IMFActivate_Release(activate);
DestroyWindow(window);
hr = MFCreateVideoRendererActivate(NULL, &activate);
ok(hr == S_OK, "Failed to create activate object, hr %#x.\n", hr);