Commit 5daa21f9 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

mfmediaengine: Implement media_engine_GetSeekable().

parent 4f0a7cd8
......@@ -1899,17 +1899,35 @@ static HRESULT WINAPI media_engine_GetPlayed(IMFMediaEngineEx *iface, IMFMediaTi
static HRESULT WINAPI media_engine_GetSeekable(IMFMediaEngineEx *iface, IMFMediaTimeRange **seekable)
{
struct media_engine *engine = impl_from_IMFMediaEngineEx(iface);
HRESULT hr = E_NOTIMPL;
IMFMediaTimeRange *time_range = NULL;
DWORD flags;
HRESULT hr;
FIXME("(%p, %p): stub.\n", iface, seekable);
TRACE("%p, %p.\n", iface, seekable);
EnterCriticalSection(&engine->cs);
if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
else
{
hr = create_time_range(&time_range);
if (SUCCEEDED(hr) && !isnan(engine->duration) && engine->presentation.source)
{
hr = IMFMediaSource_GetCharacteristics(engine->presentation.source, &flags);
if (SUCCEEDED(hr) && (flags & MFBYTESTREAM_IS_SEEKABLE))
hr = IMFMediaTimeRange_AddRange(time_range, 0.0, engine->duration);
}
}
LeaveCriticalSection(&engine->cs);
if (FAILED(hr) && time_range)
{
IMFMediaTimeRange_Release(time_range);
time_range = NULL;
}
*seekable = time_range;
return hr;
}
......
......@@ -2285,15 +2285,11 @@ static void test_GetSeekable(void)
/* Media engine is not ready */
hr = IMFMediaEngineEx_GetSeekable(media_engine, &time_range);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
count = IMFMediaTimeRange_GetLength(time_range);
ok(!count, "Unexpected count %lu.\n", count);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
}
count = IMFMediaTimeRange_GetLength(time_range);
ok(!count, "Unexpected count %lu.\n", count);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
hr = IMFMediaEngineEx_Play(media_engine);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
......@@ -2307,22 +2303,18 @@ static void test_GetSeekable(void)
/* Media engine is ready */
hr = IMFMediaEngineEx_GetSeekable(media_engine, &time_range);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
count = IMFMediaTimeRange_GetLength(time_range);
ok(count == 1, "Unexpected count %lu.\n", count);
hr = IMFMediaTimeRange_GetStart(time_range, 0, &start);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(start == 0, "Unexpected start %lf.\n", start);
hr = IMFMediaTimeRange_GetEnd(time_range, 0, &end);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
duration = IMFMediaEngineEx_GetDuration(media_engine);
ok(end == duration, "Unexpected end %lf.\n", end);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
}
count = IMFMediaTimeRange_GetLength(time_range);
ok(count == 1, "Unexpected count %lu.\n", count);
hr = IMFMediaTimeRange_GetStart(time_range, 0, &start);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(start == 0, "Unexpected start %lf.\n", start);
hr = IMFMediaTimeRange_GetEnd(time_range, 0, &end);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
duration = IMFMediaEngineEx_GetDuration(media_engine);
ok(end == duration, "Unexpected end %lf.\n", end);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
/* Media engine is shut down */
hr = IMFMediaEngineEx_Shutdown(media_engine);
......@@ -2331,7 +2323,6 @@ static void test_GetSeekable(void)
time_range = (IMFMediaTimeRange *)0xdeadbeef;
hr = IMFMediaEngineEx_GetSeekable(media_engine, &time_range);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(time_range == NULL || broken(time_range == (IMFMediaTimeRange *)0xdeadbeef) /* <= Win10 1507 */,
"Got unexpected pointer.\n");
......@@ -2357,15 +2348,11 @@ static void test_GetSeekable(void)
ok(res == S_OK, "Unexpected res %#lx.\n", res);
hr = IMFMediaEngineEx_GetSeekable(media_engine, &time_range);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
count = IMFMediaTimeRange_GetLength(time_range);
ok(!count, "Unexpected count %lu.\n", count);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
}
count = IMFMediaTimeRange_GetLength(time_range);
ok(!count, "Unexpected count %lu.\n", count);
refcount = IMFMediaTimeRange_Release(time_range);
ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
done:
hr = IMFMediaEngineEx_Shutdown(media_engine);
......
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