mfplay: Partially implement GetDuration().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-10-25 13:04:20 +03:00 committed by Alexandre Julliard
parent 4f92399660
commit 9d6fc061c9
2 changed files with 52 additions and 3 deletions

View File

@ -909,11 +909,27 @@ static HRESULT WINAPI media_player_GetPosition(IMFPMediaPlayer *iface, REFGUID p
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *position) static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID postype, PROPVARIANT *duration)
{ {
FIXME("%p, %s, %p.\n", iface, debugstr_guid(postype), position); struct media_player *player = impl_from_IMFPMediaPlayer(iface);
HRESULT hr;
return E_NOTIMPL; TRACE("%p, %s, %p.\n", iface, debugstr_guid(postype), duration);
if (!postype || !duration)
return E_POINTER;
EnterCriticalSection(&player->cs);
if (player->state == MFP_MEDIAPLAYER_STATE_SHUTDOWN)
hr = MF_E_SHUTDOWN;
else if (!player->item)
hr = MF_E_INVALIDREQUEST;
else
/* FIXME: use start/stop markers for resulting duration */
hr = IMFPMediaItem_GetDuration(player->item, postype, duration);
LeaveCriticalSection(&player->cs);
return hr;
} }
static HRESULT WINAPI media_player_SetRate(IMFPMediaPlayer *iface, float rate) static HRESULT WINAPI media_player_SetRate(IMFPMediaPlayer *iface, float rate)

View File

@ -148,6 +148,7 @@ static void test_shutdown(void)
IMFPMediaPlayer *player; IMFPMediaPlayer *player;
float slowest, fastest; float slowest, fastest;
IMFPMediaItem *item; IMFPMediaItem *item;
PROPVARIANT propvar;
COLORREF color; COLORREF color;
HWND window; HWND window;
DWORD mode; DWORD mode;
@ -217,6 +218,15 @@ todo_wine
hr = IMFPMediaPlayer_GetVideoWindow(player, &window); hr = IMFPMediaPlayer_GetVideoWindow(player, &window);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetDuration(player, NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_Shutdown(player); hr = IMFPMediaPlayer_Shutdown(player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@ -345,10 +355,33 @@ todo_wine
DestroyWindow(window); DestroyWindow(window);
} }
static void test_duration(void)
{
IMFPMediaPlayer *player;
PROPVARIANT propvar;
HRESULT hr;
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
/* No media item. */
hr = IMFPMediaPlayer_GetDuration(player, NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFPMediaPlayer_GetDuration(player, &MFP_POSITIONTYPE_100NS, &propvar);
ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
IMFPMediaPlayer_Release(player);
}
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(); test_video_control();
test_duration();
} }