Commit dbe24199 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplay: Better handle video control method calls when there is no media item set.

parent f01b028d
...@@ -1323,6 +1323,15 @@ static HRESULT WINAPI media_player_SetMute(IMFPMediaPlayer *iface, BOOL mute) ...@@ -1323,6 +1323,15 @@ static HRESULT WINAPI media_player_SetMute(IMFPMediaPlayer *iface, BOOL mute)
return E_NOTIMPL; 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, static HRESULT WINAPI media_player_GetNativeVideoSize(IMFPMediaPlayer *iface,
SIZE *video, SIZE *arvideo) SIZE *video, SIZE *arvideo)
{ {
...@@ -1332,8 +1341,7 @@ static HRESULT WINAPI media_player_GetNativeVideoSize(IMFPMediaPlayer *iface, ...@@ -1332,8 +1341,7 @@ static HRESULT WINAPI media_player_GetNativeVideoSize(IMFPMediaPlayer *iface,
TRACE("%p, %p, %p.\n", iface, video, arvideo); TRACE("%p, %p, %p.\n", iface, video, arvideo);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, video, arvideo); hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, video, arvideo);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1351,8 +1359,7 @@ static HRESULT WINAPI media_player_GetIdealVideoSize(IMFPMediaPlayer *iface, ...@@ -1351,8 +1359,7 @@ static HRESULT WINAPI media_player_GetIdealVideoSize(IMFPMediaPlayer *iface,
TRACE("%p, %p, %p.\n", iface, min_size, max_size); TRACE("%p, %p, %p.\n", iface, min_size, max_size);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_GetIdealVideoSize(display_control, min_size, max_size); hr = IMFVideoDisplayControl_GetIdealVideoSize(display_control, min_size, max_size);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1370,8 +1377,7 @@ static HRESULT WINAPI media_player_SetVideoSourceRect(IMFPMediaPlayer *iface, ...@@ -1370,8 +1377,7 @@ static HRESULT WINAPI media_player_SetVideoSourceRect(IMFPMediaPlayer *iface,
TRACE("%p, %p.\n", iface, rect); TRACE("%p, %p.\n", iface, rect);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_SetVideoPosition(display_control, rect, NULL); hr = IMFVideoDisplayControl_SetVideoPosition(display_control, rect, NULL);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1390,8 +1396,7 @@ static HRESULT WINAPI media_player_GetVideoSourceRect(IMFPMediaPlayer *iface, ...@@ -1390,8 +1396,7 @@ static HRESULT WINAPI media_player_GetVideoSourceRect(IMFPMediaPlayer *iface,
TRACE("%p, %p.\n", iface, rect); TRACE("%p, %p.\n", iface, rect);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_GetVideoPosition(display_control, rect, &dest); hr = IMFVideoDisplayControl_GetVideoPosition(display_control, rect, &dest);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1408,8 +1413,7 @@ static HRESULT WINAPI media_player_SetAspectRatioMode(IMFPMediaPlayer *iface, DW ...@@ -1408,8 +1413,7 @@ static HRESULT WINAPI media_player_SetAspectRatioMode(IMFPMediaPlayer *iface, DW
TRACE("%p, %u.\n", iface, mode); TRACE("%p, %u.\n", iface, mode);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, mode); hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, mode);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1427,8 +1431,7 @@ static HRESULT WINAPI media_player_GetAspectRatioMode(IMFPMediaPlayer *iface, ...@@ -1427,8 +1431,7 @@ static HRESULT WINAPI media_player_GetAspectRatioMode(IMFPMediaPlayer *iface,
TRACE("%p, %p.\n", iface, mode); TRACE("%p, %p.\n", iface, mode);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, mode); hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, mode);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1463,8 +1466,7 @@ static HRESULT WINAPI media_player_SetBorderColor(IMFPMediaPlayer *iface, COLORR ...@@ -1463,8 +1466,7 @@ static HRESULT WINAPI media_player_SetBorderColor(IMFPMediaPlayer *iface, COLORR
TRACE("%p, %#x.\n", iface, color); TRACE("%p, %#x.\n", iface, color);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_SetBorderColor(display_control, color); hr = IMFVideoDisplayControl_SetBorderColor(display_control, color);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
...@@ -1481,8 +1483,7 @@ static HRESULT WINAPI media_player_GetBorderColor(IMFPMediaPlayer *iface, COLORR ...@@ -1481,8 +1483,7 @@ static HRESULT WINAPI media_player_GetBorderColor(IMFPMediaPlayer *iface, COLORR
TRACE("%p, %p.\n", iface, color); TRACE("%p, %p.\n", iface, color);
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MR_VIDEO_RENDER_SERVICE, if (SUCCEEDED(hr = media_player_get_display_control(player, &display_control)))
&IID_IMFVideoDisplayControl, (void **)&display_control)))
{ {
hr = IMFVideoDisplayControl_GetBorderColor(display_control, color); hr = IMFVideoDisplayControl_GetBorderColor(display_control, color);
IMFVideoDisplayControl_Release(display_control); IMFVideoDisplayControl_Release(display_control);
......
TESTDLL = mfplay.dll TESTDLL = mfplay.dll
IMPORTS = mfplay uuid mfuuid IMPORTS = mfplay user32 uuid mfuuid
C_SRCS = \ C_SRCS = \
mfplay.c mfplay.c
...@@ -142,13 +142,16 @@ static void test_create_player(void) ...@@ -142,13 +142,16 @@ static void test_create_player(void)
static void test_shutdown(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; IMFPMediaPlayer *player;
float slowest, fastest; float slowest, fastest;
HRESULT hr;
MFP_MEDIAPLAYER_STATE state;
IMFPMediaItem *item; IMFPMediaItem *item;
COLORREF color;
HWND window; HWND window;
DWORD mode;
HRESULT hr;
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player); hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
...@@ -180,6 +183,28 @@ static void test_shutdown(void) ...@@ -180,6 +183,28 @@ static void test_shutdown(void)
hr = IMFPMediaPlayer_GetIdealVideoSize(player, &min_size, &max_size); hr = IMFPMediaPlayer_GetIdealVideoSize(player, &min_size, &max_size);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); 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); hr = IMFPMediaPlayer_CreateMediaItemFromURL(player, L"url", TRUE, 0, &item);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
...@@ -212,9 +237,64 @@ static void test_media_item(void) ...@@ -212,9 +237,64 @@ static void test_media_item(void)
IMFPMediaPlayer_Release(player); 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) START_TEST(mfplay)
{ {
test_create_player(); test_create_player();
test_shutdown(); test_shutdown();
test_media_item(); test_media_item();
test_video_control();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment