mfplay: Better handle video control method calls when there is no media item set.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f01b028d58
commit
dbe241990f
|
@ -1323,6 +1323,15 @@ static HRESULT WINAPI media_player_SetMute(IMFPMediaPlayer *iface, BOOL mute)
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT media_player_get_display_control(const struct media_player *player,
|
||||
IMFVideoDisplayControl **display_control)
|
||||
{
|
||||
HRESULT hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)display_control);
|
||||
if (SUCCEEDED(hr)) return hr;
|
||||
return hr == MF_E_SHUTDOWN ? hr : MF_E_INVALIDREQUEST;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI media_player_GetNativeVideoSize(IMFPMediaPlayer *iface,
|
||||
SIZE *video, SIZE *arvideo)
|
||||
{
|
||||
|
@ -1332,8 +1341,7 @@ static HRESULT WINAPI media_player_GetNativeVideoSize(IMFPMediaPlayer *iface,
|
|||
|
||||
TRACE("%p, %p, %p.\n", iface, video, arvideo);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, video, arvideo);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1351,8 +1359,7 @@ static HRESULT WINAPI media_player_GetIdealVideoSize(IMFPMediaPlayer *iface,
|
|||
|
||||
TRACE("%p, %p, %p.\n", iface, min_size, max_size);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_GetIdealVideoSize(display_control, min_size, max_size);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1370,8 +1377,7 @@ static HRESULT WINAPI media_player_SetVideoSourceRect(IMFPMediaPlayer *iface,
|
|||
|
||||
TRACE("%p, %p.\n", iface, rect);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, rect, NULL);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1390,8 +1396,7 @@ static HRESULT WINAPI media_player_GetVideoSourceRect(IMFPMediaPlayer *iface,
|
|||
|
||||
TRACE("%p, %p.\n", iface, rect);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_GetVideoPosition(display_control, rect, &dest);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1408,8 +1413,7 @@ static HRESULT WINAPI media_player_SetAspectRatioMode(IMFPMediaPlayer *iface, DW
|
|||
|
||||
TRACE("%p, %u.\n", iface, mode);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, mode);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1427,8 +1431,7 @@ static HRESULT WINAPI media_player_GetAspectRatioMode(IMFPMediaPlayer *iface,
|
|||
|
||||
TRACE("%p, %p.\n", iface, mode);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, mode);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1463,8 +1466,7 @@ static HRESULT WINAPI media_player_SetBorderColor(IMFPMediaPlayer *iface, COLORR
|
|||
|
||||
TRACE("%p, %#x.\n", iface, color);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_SetBorderColor(display_control, color);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
@ -1481,8 +1483,7 @@ static HRESULT WINAPI media_player_GetBorderColor(IMFPMediaPlayer *iface, COLORR
|
|||
|
||||
TRACE("%p, %p.\n", iface, color);
|
||||
|
||||
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE,
|
||||
&IID_IMFVideoDisplayControl, (void **)&display_control)))
|
||||
if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
|
||||
{
|
||||
hr = IMFVideoDisplayControl_GetBorderColor(display_control, color);
|
||||
IMFVideoDisplayControl_Release(display_control);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TESTDLL = mfplay.dll
|
||||
IMPORTS = mfplay uuid mfuuid
|
||||
IMPORTS = mfplay user32 uuid mfuuid
|
||||
|
||||
C_SRCS = \
|
||||
mfplay.c
|
||||
|
|
|
@ -142,13 +142,16 @@ static void test_create_player(void)
|
|||
|
||||
static void test_shutdown(void)
|
||||
{
|
||||
SIZE min_size, max_size;
|
||||
SIZE size, min_size, max_size;
|
||||
MFP_MEDIAPLAYER_STATE state;
|
||||
MFVideoNormalizedRect rect;
|
||||
IMFPMediaPlayer *player;
|
||||
float slowest, fastest;
|
||||
HRESULT hr;
|
||||
MFP_MEDIAPLAYER_STATE state;
|
||||
IMFPMediaItem *item;
|
||||
COLORREF color;
|
||||
HWND window;
|
||||
DWORD mode;
|
||||
HRESULT hr;
|
||||
|
||||
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
@ -180,6 +183,28 @@ static void test_shutdown(void)
|
|||
hr = IMFPMediaPlayer_GetIdealVideoSize(player, &min_size, &max_size);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetVideoSourceRect(player, &rect);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetBorderColor(player, &color);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetAspectRatioMode(player, &mode);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetNativeVideoSize(player, &size, &size);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_SetBorderColor(player, 0);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_SetAspectRatioMode(player, MFVideoARMode_None);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_UpdateVideo(player);
|
||||
todo_wine
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", TRUE, 0, &item);
|
||||
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
|
@ -212,9 +237,64 @@ static void test_media_item(void)
|
|||
IMFPMediaPlayer_Release(player);
|
||||
}
|
||||
|
||||
static void test_video_control(void)
|
||||
{
|
||||
MFVideoNormalizedRect rect;
|
||||
IMFPMediaPlayer *player;
|
||||
COLORREF color;
|
||||
HWND window;
|
||||
DWORD mode;
|
||||
HRESULT hr;
|
||||
SIZE size;
|
||||
|
||||
window = CreateWindowA("static", "mfplay_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
ok(!!window, "Failed to create output window.\n");
|
||||
|
||||
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, window, &player);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
/* No active media item */
|
||||
|
||||
rect.left = rect.top = 0.0f;
|
||||
rect.right = rect.bottom = 1.0f;
|
||||
hr = IMFPMediaPlayer_SetVideoSourceRect(player, &rect);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_SetBorderColor(player, 0);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_SetAspectRatioMode(player, MFVideoARMode_None);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetVideoSourceRect(player, &rect);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetBorderColor(player, &color);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetAspectRatioMode(player, &mode);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetIdealVideoSize(player, &size, &size);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_GetNativeVideoSize(player, &size, &size);
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFPMediaPlayer_UpdateVideo(player);
|
||||
todo_wine
|
||||
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
IMFPMediaPlayer_Release(player);
|
||||
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(mfplay)
|
||||
{
|
||||
test_create_player();
|
||||
test_shutdown();
|
||||
test_media_item();
|
||||
test_video_control();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue