Commit 194e90da authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplay: Enable rate control methods.

parent 9c12ca85
...@@ -1094,16 +1094,44 @@ static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID p ...@@ -1094,16 +1094,44 @@ static HRESULT WINAPI media_player_GetDuration(IMFPMediaPlayer *iface, REFGUID p
static HRESULT WINAPI media_player_SetRate(IMFPMediaPlayer *iface, float rate) static HRESULT WINAPI media_player_SetRate(IMFPMediaPlayer *iface, float rate)
{ {
FIXME("%p, %f.\n", iface, rate); struct media_player *player = impl_from_IMFPMediaPlayer(iface);
IMFRateControl *rate_control;
HRESULT hr;
return E_NOTIMPL; TRACE("%p, %f.\n", iface, rate);
if (rate == 0.0f)
return MF_E_OUT_OF_RANGE;
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl,
(void **)&rate_control)))
{
hr = IMFRateControl_SetRate(rate_control, FALSE, rate);
IMFRateControl_Release(rate_control);
}
return hr;
} }
static HRESULT WINAPI media_player_GetRate(IMFPMediaPlayer *iface, float *rate) static HRESULT WINAPI media_player_GetRate(IMFPMediaPlayer *iface, float *rate)
{ {
FIXME("%p, %p.\n", iface, rate); struct media_player *player = impl_from_IMFPMediaPlayer(iface);
IMFRateControl *rate_control;
HRESULT hr;
return E_NOTIMPL; TRACE("%p, %p.\n", iface, rate);
if (!rate)
return E_POINTER;
if (SUCCEEDED(hr = MFGetService((IUnknown *)player->session, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl,
(void **)&rate_control)))
{
hr = IMFRateControl_GetRate(rate_control, NULL, rate);
IMFRateControl_Release(rate_control);
}
return hr;
} }
static HRESULT WINAPI media_player_GetSupportedRates(IMFPMediaPlayer *iface, BOOL forward, static HRESULT WINAPI media_player_GetSupportedRates(IMFPMediaPlayer *iface, BOOL forward,
...@@ -2080,6 +2108,17 @@ static void media_player_playback_ended(struct media_player *player, HRESULT eve ...@@ -2080,6 +2108,17 @@ static void media_player_playback_ended(struct media_player *player, HRESULT eve
LeaveCriticalSection(&player->cs); LeaveCriticalSection(&player->cs);
} }
static void media_player_rate_changed(struct media_player *player, HRESULT event_status,
float rate, struct media_event **event)
{
EnterCriticalSection(&player->cs);
if (SUCCEEDED(media_event_create(player, MFP_EVENT_TYPE_RATE_SET, event_status, player->item, event)))
(*event)->u.rate_set.flRate = rate;
LeaveCriticalSection(&player->cs);
}
static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallback *iface, static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallback *iface,
IMFAsyncResult *result) IMFAsyncResult *result)
{ {
...@@ -2092,6 +2131,7 @@ static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallba ...@@ -2092,6 +2131,7 @@ static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallba
IMFTopology *topology; IMFTopology *topology;
unsigned int status; unsigned int status;
PROPVARIANT value; PROPVARIANT value;
float rate;
if (FAILED(hr = IMFMediaSession_EndGetEvent(player->session, result, &session_event))) if (FAILED(hr = IMFMediaSession_EndGetEvent(player->session, result, &session_event)))
return S_OK; return S_OK;
...@@ -2146,6 +2186,20 @@ static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallba ...@@ -2146,6 +2186,20 @@ static HRESULT WINAPI media_player_session_events_callback_Invoke(IMFAsyncCallba
break; break;
case MESessionRateChanged:
rate = 0.0f;
if (SUCCEEDED(IMFMediaEvent_GetValue(session_event, &value)))
{
if (value.vt == VT_R4)
rate = value.fltVal;
PropVariantClear(&value);
}
media_player_rate_changed(player, event_status, rate, &event);
break;
case MEBufferingStarted: case MEBufferingStarted:
case MEBufferingStopped: case MEBufferingStopped:
case MEExtendedType: case MEExtendedType:
......
...@@ -171,10 +171,10 @@ static void test_create_player(void) ...@@ -171,10 +171,10 @@ static void test_create_player(void)
static void test_shutdown(void) static void test_shutdown(void)
{ {
SIZE size, min_size, max_size; SIZE size, min_size, max_size;
float slowest, fastest, rate;
MFP_MEDIAPLAYER_STATE state; MFP_MEDIAPLAYER_STATE state;
MFVideoNormalizedRect rect; MFVideoNormalizedRect rect;
IMFPMediaPlayer *player; IMFPMediaPlayer *player;
float slowest, fastest;
IMFPMediaItem *item; IMFPMediaItem *item;
PROPVARIANT propvar; PROPVARIANT propvar;
COLORREF color; COLORREF color;
...@@ -263,6 +263,15 @@ static void test_shutdown(void) ...@@ -263,6 +263,15 @@ static void test_shutdown(void)
hr = IMFPMediaPlayer_GetPosition(player, &MFP_POSITIONTYPE_100NS, &propvar); hr = IMFPMediaPlayer_GetPosition(player, &MFP_POSITIONTYPE_100NS, &propvar);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_SetRate(player, 2.0f);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_GetRate(player, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_GetRate(player, &rate);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_Shutdown(player); hr = IMFPMediaPlayer_Shutdown(player);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
...@@ -548,6 +557,31 @@ static void test_duration(void) ...@@ -548,6 +557,31 @@ static void test_duration(void)
IMFPMediaPlayer_Release(player); IMFPMediaPlayer_Release(player);
} }
static void test_playback_rate(void)
{
IMFPMediaPlayer *player;
float rate;
HRESULT hr;
hr = MFPCreateMediaPlayer(NULL, FALSE, 0, NULL, NULL, &player);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_SetRate(player, 0.0f);
ok(hr == MF_E_OUT_OF_RANGE, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_SetRate(player, 2.0f);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_GetRate(player, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IMFPMediaPlayer_GetRate(player, &rate);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(rate == 1.0f, "Unexpected rate %f.\n", rate);
IMFPMediaPlayer_Release(player);
}
START_TEST(mfplay) START_TEST(mfplay)
{ {
test_create_player(); test_create_player();
...@@ -555,4 +589,5 @@ START_TEST(mfplay) ...@@ -555,4 +589,5 @@ START_TEST(mfplay)
test_media_item(); test_media_item();
test_video_control(); test_video_control();
test_duration(); test_duration();
test_playback_rate();
} }
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