quartz/tests: Add some tests for IMediaSeeking on parser filters.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-11-21 15:24:57 -06:00 committed by Alexandre Julliard
parent 9281b542ff
commit 08026a2c66
5 changed files with 611 additions and 1 deletions

View File

@ -25,6 +25,8 @@
#include "wine/strmbase.h"
#include "wine/test.h"
static const GUID testguid = {0xfacade};
static IBaseFilter *create_avi_splitter(void)
{
IBaseFilter *filter = NULL;
@ -1373,6 +1375,210 @@ static void test_unconnected_filter_state(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_seeking(void)
{
LONGLONG time, current, stop, prev_stop, earliest, latest, duration;
const WCHAR *filename = load_resource(L"test.avi");
IBaseFilter *filter = create_avi_splitter();
IFilterGraph2 *graph = connect_input(filter, filename);
IMediaSeeking *seeking;
unsigned int i;
double rate;
GUID format;
HRESULT hr;
DWORD caps;
ULONG ref;
IPin *pin;
BOOL ret;
static const struct
{
const GUID *guid;
HRESULT hr;
}
format_tests[] =
{
{&TIME_FORMAT_MEDIA_TIME, S_OK},
{&TIME_FORMAT_FRAME, S_OK},
{&TIME_FORMAT_BYTE, S_FALSE},
{&TIME_FORMAT_NONE, S_FALSE},
{&TIME_FORMAT_SAMPLE, S_FALSE},
{&TIME_FORMAT_FIELD, S_FALSE},
{&testguid, S_FALSE},
};
IBaseFilter_FindPin(filter, L"Stream 00", &pin);
IPin_QueryInterface(pin, &IID_IMediaSeeking, (void **)&seeking);
hr = IMediaSeeking_GetCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards
| AM_SEEKING_CanSeekBackwards | AM_SEEKING_CanGetStopPos
| AM_SEEKING_CanGetDuration), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(caps == AM_SEEKING_CanSeekAbsolute, "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
caps = 0;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
for (i = 0; i < ARRAY_SIZE(format_tests); ++i)
{
hr = IMediaSeeking_IsFormatSupported(seeking, format_tests[i].guid);
todo_wine_if(i == 1) ok(hr == format_tests[i].hr, "Got hr %#x for format %s.\n",
hr, wine_dbgstr_guid(format_tests[i].guid));
}
hr = IMediaSeeking_QueryPreferredFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_GetTimeFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_FRAME);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_SAMPLE);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_FRAME);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_GetTimeFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(IsEqualGUID(&format, &TIME_FORMAT_FRAME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_FRAME);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
duration = 0;
hr = IMediaSeeking_GetDuration(seeking, &duration);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(duration > 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetStopPosition(seeking, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
hr = IMediaSeeking_GetCurrentPosition(seeking, &current);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, &TIME_FORMAT_MEDIA_TIME, 0x123456789a, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 0x123456789a, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 123, &TIME_FORMAT_FRAME);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(time == 123 * 10000000, "Got time %s.\n", wine_dbgstr_longlong(time));
earliest = latest = 0xdeadbeef;
hr = IMediaSeeking_GetAvailable(seeking, &earliest, &latest);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!earliest, "Got time %s.\n", wine_dbgstr_longlong(earliest));
ok(latest == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(latest));
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(rate == 1.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, 200.0);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(rate == 200.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, -1.0);
todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_GetPreroll(seeking, &time);
todo_wine ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
current = 1500 * 10000;
stop = 3500 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
&stop, AM_SEEKING_AbsolutePositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 1500 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 3500 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
/* Native snaps to the nearest frame. */
ok(current > 0 && current < duration, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop > 0 && stop < duration && stop > current, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 1500 * 10000;
stop = 3500 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
&stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current > 0 && current < duration, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop > 0 && stop < duration && stop > current, "Got time %s.\n", wine_dbgstr_longlong(stop));
hr = IMediaSeeking_GetStopPosition(seeking, &prev_stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
current = 0;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
NULL, AM_SEEKING_NoPositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == prev_stop, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(prev_stop), wine_dbgstr_longlong(stop));
IMediaSeeking_Release(seeking);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(avisplit)
{
IBaseFilter *filter;
@ -1396,6 +1602,7 @@ START_TEST(avisplit)
test_enum_media_types();
test_unconnected_filter_state();
test_connect_pin();
test_seeking();
CoUninitialize();
}

View File

@ -24,6 +24,7 @@
#include "wine/strmbase.h"
#include "wine/test.h"
static const GUID testguid = {0xfacade};
static const GUID MEDIASUBTYPE_mp3 = {0x00000055,0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}};
static IBaseFilter *create_mpeg_splitter(void)
@ -1554,6 +1555,197 @@ static void test_connect_pin(void)
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
static void test_seeking(void)
{
LONGLONG time, current, stop, earliest, latest, duration;
const WCHAR *filename = load_resource(L"test.mp3");
IBaseFilter *filter = create_mpeg_splitter();
IFilterGraph2 *graph = connect_input(filter, filename);
IMediaSeeking *seeking;
unsigned int i;
double rate;
GUID format;
HRESULT hr;
DWORD caps;
ULONG ref;
IPin *pin;
BOOL ret;
static const struct
{
const GUID *guid;
HRESULT hr;
}
format_tests[] =
{
{&TIME_FORMAT_MEDIA_TIME, S_OK},
{&TIME_FORMAT_SAMPLE, S_FALSE},
{&TIME_FORMAT_BYTE, S_FALSE},
{&TIME_FORMAT_NONE, S_FALSE},
{&TIME_FORMAT_FRAME, S_FALSE},
{&TIME_FORMAT_FIELD, S_FALSE},
{&testguid, S_FALSE},
};
IBaseFilter_FindPin(filter, L"Audio", &pin);
IPin_QueryInterface(pin, &IID_IMediaSeeking, (void **)&seeking);
hr = IMediaSeeking_GetCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards
| AM_SEEKING_CanSeekBackwards | AM_SEEKING_CanGetStopPos
| AM_SEEKING_CanGetDuration), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(caps == AM_SEEKING_CanSeekAbsolute, "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
caps = 0;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
for (i = 0; i < ARRAY_SIZE(format_tests); ++i)
{
hr = IMediaSeeking_IsFormatSupported(seeking, format_tests[i].guid);
ok(hr == format_tests[i].hr, "Got hr %#x for format %s.\n",
hr, wine_dbgstr_guid(format_tests[i].guid));
}
hr = IMediaSeeking_QueryPreferredFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_GetTimeFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_SAMPLE);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_FRAME);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
duration = 0;
hr = IMediaSeeking_GetDuration(seeking, &duration);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(duration > 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetStopPosition(seeking, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
hr = IMediaSeeking_GetCurrentPosition(seeking, &current);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, &TIME_FORMAT_MEDIA_TIME, 0x123456789a, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 0x123456789a, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
earliest = latest = 0xdeadbeef;
hr = IMediaSeeking_GetAvailable(seeking, &earliest, &latest);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!earliest, "Got time %s.\n", wine_dbgstr_longlong(earliest));
ok(latest == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(latest));
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(rate == 1.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, 200.0);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(rate == 200.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, -1.0);
todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_GetPreroll(seeking, &time);
todo_wine ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
current = 200 * 10000;
stop = 400 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
&stop, AM_SEEKING_AbsolutePositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 200 * 10000;
stop = 400 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
&stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 100 * 10000;
stop = 200 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
&stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 100 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 50 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
NULL, AM_SEEKING_NoPositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 50 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
IMediaSeeking_Release(seeking);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(mpegsplit)
{
IBaseFilter *filter;
@ -1577,6 +1769,7 @@ START_TEST(mpegsplit)
test_enum_media_types();
test_unconnected_filter_state();
test_connect_pin();
test_seeking();
CoUninitialize();
}

View File

@ -20,7 +20,7 @@
#include "windef.h"
/* ffmpeg -f lavfi -i smptebars -t 1 -r 1 -f avi -vcodec rawvideo -pix_fmt yuv420p -vf scale=32x24 test.avi */
/* ffmpeg -f lavfi -i smptebars -t 5 -r 1 -f avi -vcodec rawvideo -pix_fmt yuv420p -vf scale=32x24 test.avi */
/* @makedep: test.avi */
test.avi RCDATA "test.avi"

Binary file not shown.

View File

@ -23,6 +23,8 @@
#include "mmreg.h"
#include "wine/test.h"
static const GUID testguid = {0xfacade};
static IBaseFilter *create_wave_parser(void)
{
IBaseFilter *filter = NULL;
@ -825,6 +827,213 @@ static void test_unconnected_filter_state(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_seeking(void)
{
LONGLONG time, current, stop, earliest, latest, duration;
const WCHAR *filename = load_resource(L"test.wav");
IBaseFilter *filter = create_wave_parser();
IFilterGraph2 *graph = connect_input(filter, filename);
IMediaSeeking *seeking;
unsigned int i;
double rate;
GUID format;
HRESULT hr;
DWORD caps;
ULONG ref;
IPin *pin;
BOOL ret;
static const struct
{
const GUID *guid;
HRESULT hr;
}
format_tests[] =
{
{&TIME_FORMAT_MEDIA_TIME, S_OK},
{&TIME_FORMAT_SAMPLE, S_OK},
{&TIME_FORMAT_BYTE, S_FALSE},
{&TIME_FORMAT_NONE, S_FALSE},
{&TIME_FORMAT_FRAME, S_FALSE},
{&TIME_FORMAT_FIELD, S_FALSE},
{&testguid, S_FALSE},
};
IBaseFilter_FindPin(filter, L"output", &pin);
IPin_QueryInterface(pin, &IID_IMediaSeeking, (void **)&seeking);
hr = IMediaSeeking_GetCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards
| AM_SEEKING_CanSeekBackwards | AM_SEEKING_CanGetStopPos
| AM_SEEKING_CanGetDuration | AM_SEEKING_CanDoSegments), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(caps == (AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanSeekForwards), "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanSeekAbsolute | AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(caps == AM_SEEKING_CanSeekAbsolute, "Got caps %#x.\n", caps);
caps = AM_SEEKING_CanGetCurrentPos;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
caps = 0;
hr = IMediaSeeking_CheckCapabilities(seeking, &caps);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
ok(!caps, "Got caps %#x.\n", caps);
for (i = 0; i < ARRAY_SIZE(format_tests); ++i)
{
hr = IMediaSeeking_IsFormatSupported(seeking, format_tests[i].guid);
todo_wine_if(i == 1) ok(hr == format_tests[i].hr, "Got hr %#x for format %s.\n",
hr, wine_dbgstr_guid(format_tests[i].guid));
}
hr = IMediaSeeking_QueryPreferredFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_GetTimeFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(IsEqualGUID(&format, &TIME_FORMAT_MEDIA_TIME), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_SAMPLE);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_FRAME);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_SAMPLE);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_GetTimeFormat(seeking, &format);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(IsEqualGUID(&format, &TIME_FORMAT_SAMPLE), "Got format %s.\n", wine_dbgstr_guid(&format));
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaSeeking_IsUsingTimeFormat(seeking, &TIME_FORMAT_SAMPLE);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaSeeking_SetTimeFormat(seeking, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
duration = 0xdeadbeef;
hr = IMediaSeeking_GetDuration(seeking, &duration);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(duration > 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetStopPosition(seeking, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
hr = IMediaSeeking_GetCurrentPosition(seeking, &current);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!current, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(stop));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, &TIME_FORMAT_MEDIA_TIME, 0x123456789a, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 0x123456789a, &TIME_FORMAT_MEDIA_TIME);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time == 0x123456789a, "Got time %s.\n", wine_dbgstr_longlong(time));
time = 0xdeadbeef;
hr = IMediaSeeking_ConvertTimeFormat(seeking, &time, NULL, 441, &TIME_FORMAT_SAMPLE);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(time == 100000, "Got time %s.\n", wine_dbgstr_longlong(time));
earliest = latest = 0xdeadbeef;
hr = IMediaSeeking_GetAvailable(seeking, &earliest, &latest);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!earliest, "Got time %s.\n", wine_dbgstr_longlong(earliest));
ok(latest == duration, "Expected time %s, got %s.\n",
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(latest));
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(rate == 1.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, 200.0);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
rate = 0;
hr = IMediaSeeking_GetRate(seeking, &rate);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(rate == 200.0, "Got rate %.16e.\n", rate);
hr = IMediaSeeking_SetRate(seeking, -1.0);
todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IMediaSeeking_GetPreroll(seeking, &time);
todo_wine ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
current = 200 * 10000;
stop = 400 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
&stop, AM_SEEKING_AbsolutePositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 200 * 10000;
stop = 400 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
&stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 400 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 100 * 10000;
stop = 200 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
&stop, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 100 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 50 * 10000;
hr = IMediaSeeking_SetPositions(seeking, &current, AM_SEEKING_AbsolutePositioning,
NULL, AM_SEEKING_NoPositioning);
ok(hr == S_OK, "Got hr %#x.\n", hr);
stop = current = 0xdeadbeef;
hr = IMediaSeeking_GetPositions(seeking, &current, &stop);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(current == 50 * 10000, "Got time %s.\n", wine_dbgstr_longlong(current));
ok(stop == 200 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
IMediaSeeking_Release(seeking);
IPin_Release(pin);
IFilterGraph2_Release(graph);
ref = IBaseFilter_Release(filter);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ret = DeleteFileW(filename);
ok(ret, "Failed to delete file, error %u.\n", GetLastError());
}
START_TEST(waveparser)
{
IBaseFilter *filter;
@ -847,6 +1056,7 @@ START_TEST(waveparser)
test_media_types();
test_enum_media_types();
test_unconnected_filter_state();
test_seeking();
CoUninitialize();
}