Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/filter.c | 20 ++++- dlls/amstream/tests/amstream.c | 136 ++++++++++++++++++++++++++++++++- 2 files changed, 152 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/filter.c b/dlls/amstream/filter.c index 5fd5b2afdbc..3c0436a294f 100644 --- a/dlls/amstream/filter.c +++ b/dlls/amstream/filter.c @@ -848,9 +848,25 @@ static HRESULT WINAPI filter_seeking_CheckCapabilities(IMediaSeeking *iface, DWO
static HRESULT WINAPI filter_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) { - FIXME("iface %p, format %s, stub!\n", iface, debugstr_guid(format)); + struct filter *filter = impl_from_IMediaSeeking(iface); + IMediaSeeking *seeking; + HRESULT hr;
- return E_NOTIMPL; + TRACE("filter %p, format %s.\n", filter, debugstr_guid(format)); + + EnterCriticalSection(&filter->cs); + + seeking = get_seeking(filter->seekable_stream); + + LeaveCriticalSection(&filter->cs); + + if (!seeking) + return E_NOTIMPL; + + hr = IMediaSeeking_IsFormatSupported(seeking, format); + IMediaSeeking_Release(seeking); + + return hr; }
static HRESULT WINAPI filter_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index f5014395832..2e5d6bc92be 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -975,12 +975,14 @@ struct testfilter LONGLONG stop_position; const AM_MEDIA_TYPE *preferred_mt; HANDLE wait_state_event; + GUID is_format_supported_format; HRESULT get_duration_hr; HRESULT get_stop_position_hr; HRESULT set_positions_hr; HRESULT init_stream_hr; HRESULT cleanup_stream_hr; HRESULT wait_state_hr; + HRESULT is_format_supported_hr; };
static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface) @@ -1168,8 +1170,11 @@ static HRESULT WINAPI testsource_seeking_CheckCapabilities(IMediaSeeking *iface,
static HRESULT WINAPI testsource_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + struct testfilter *filter = impl_from_IMediaSeeking(iface); + + filter->is_format_supported_format = *format; + + return filter->is_format_supported_hr; }
static HRESULT WINAPI testsource_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) @@ -6926,6 +6931,132 @@ static void test_mediastreamfilter_wait_until(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_mediastreamfilter_is_format_supported(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid1 = {0x88888888, 1}; + static const MSPID mspid2 = {0x88888888, 2}; + static const MSPID mspid3 = {0x88888888, 3}; + struct testfilter source1, source2, source3; + IAMMediaStream *stream1, *stream2, *stream3; + IMediaStreamFilter *filter; + IPin *pin1, *pin2, *pin3; + IMediaSeeking *seeking; + IGraphBuilder *graph; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream1, NULL, 0, &mspid1, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid2, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream3, NULL, 0, &mspid3, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream1, &mspid1, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid2, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream3, &mspid3, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream1, &IID_IPin, (void **)&pin1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream3, &IID_IPin, (void **)&pin3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + testfilter_init(&source1); + testfilter_init(&source2); + testfilter_init(&source3); + source1.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + source2.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + source3.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IGraphBuilder_AddFilter(graph, &source1.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_AddFilter(graph, &source2.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_AddFilter(graph, &source3.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IGraphBuilder_ConnectDirect(graph, &source2.source.pin.IPin_iface, pin2, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_ConnectDirect(graph, &source3.source.pin.IPin_iface, pin3, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IGraphBuilder_ConnectDirect(graph, &source1.source.pin.IPin_iface, pin1, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_QueryInterface(filter, &IID_IMediaSeeking, (void **)&seeking); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + source2.is_format_supported_format = GUID_NULL; + hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME), + "Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format)); + + source2.is_format_supported_hr = E_FAIL; + source2.is_format_supported_format = GUID_NULL; + hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME), + "Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format)); + + source2.is_format_supported_hr = E_NOTIMPL; + source2.is_format_supported_format = GUID_NULL; + hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME), + "Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format)); + + source2.IMediaSeeking_iface.lpVtbl = NULL; + hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IGraphBuilder_Disconnect(graph, pin2); + IGraphBuilder_Disconnect(graph, &source2.source.pin.IPin_iface); + + hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IGraphBuilder_Disconnect(graph, pin1); + IGraphBuilder_Disconnect(graph, &source1.source.pin.IPin_iface); + IGraphBuilder_Disconnect(graph, pin3); + IGraphBuilder_Disconnect(graph, &source3.source.pin.IPin_iface); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaSeeking_Release(seeking); + ref = IMediaStreamFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin1); + ref = IAMMediaStream_Release(stream1); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin2); + ref = IAMMediaStream_Release(stream2); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin3); + ref = IAMMediaStream_Release(stream3); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_ddrawstream_getsetdirectdraw(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8834,6 +8965,7 @@ START_TEST(amstream) test_mediastreamfilter_get_current_stream_time(); test_mediastreamfilter_reference_time_to_stream_time(); test_mediastreamfilter_wait_until(); + test_mediastreamfilter_is_format_supported();
CoUninitialize(); }
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/multimedia.c | 14 ++++-- dlls/amstream/tests/amstream.c | 80 ++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index f927cd106a0..5c04c771535 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -42,6 +42,7 @@ struct multimedia_stream BOOL initialized; STREAM_TYPE type; OAEVENT event; + STREAM_STATE state; };
static inline struct multimedia_stream *impl_from_IAMMultiMediaStream(IAMMultiMediaStream *iface) @@ -136,13 +137,15 @@ static HRESULT WINAPI multimedia_stream_EnumMediaStreams(IAMMultiMediaStream *if return IMediaStreamFilter_EnumMediaStreams(mmstream->filter, index, stream); }
-static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *pCurrentState) +static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *state) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); + struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState); + TRACE("mmstream %p, state %p.\n", mmstream, state);
- return E_NOTIMPL; + *state = mmstream->state; + + return S_OK; }
static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STREAM_STATE new_state) @@ -165,6 +168,9 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR else if (new_state == STREAMSTATE_STOP) hr = IMediaControl_Stop(This->media_control);
+ if (SUCCEEDED(hr)) + This->state = new_state; + return hr; }
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 2e5d6bc92be..cd014ee7f91 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2506,6 +2506,85 @@ static void test_set_state(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_get_state(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaControl *media_control; + struct testfilter source; + IGraphBuilder *graph; + STREAM_STATE state; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaControl, (void **)&media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + testfilter_init(&source); + + hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* Crashes on native. */ + if (0) + { + hr = IAMMultiMediaStream_GetState(mmstream, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_RUN, "Got state %#x.\n", state); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + source.init_stream_hr = E_FAIL; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaControl_Release(media_control); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8904,6 +8983,7 @@ START_TEST(amstream) test_pin_info(); test_initialize(); test_set_state(); + test_get_state(); test_enum_media_types(); test_media_types();
On 11/16/20 9:31 AM, Anton Baskanov wrote:
Signed-off-by: Anton Baskanov baskanov@gmail.com
dlls/amstream/multimedia.c | 14 ++++-- dlls/amstream/tests/amstream.c | 80 ++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index f927cd106a0..5c04c771535 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -42,6 +42,7 @@ struct multimedia_stream BOOL initialized; STREAM_TYPE type; OAEVENT event;
- STREAM_STATE state;
};
static inline struct multimedia_stream *impl_from_IAMMultiMediaStream(IAMMultiMediaStream *iface) @@ -136,13 +137,15 @@ static HRESULT WINAPI multimedia_stream_EnumMediaStreams(IAMMultiMediaStream *if return IMediaStreamFilter_EnumMediaStreams(mmstream->filter, index, stream); }
-static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *pCurrentState) +static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *state) {
- struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
- struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState);
- TRACE("mmstream %p, state %p.\n", mmstream, state);
- return E_NOTIMPL;
- *state = mmstream->state;
- return S_OK;
}
static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STREAM_STATE new_state) @@ -165,6 +168,9 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR else if (new_state == STREAMSTATE_STOP) hr = IMediaControl_Stop(This->media_control);
- if (SUCCEEDED(hr))
This->state = new_state;
- return hr;
}
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 2e5d6bc92be..cd014ee7f91 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2506,6 +2506,85 @@ static void test_set_state(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_get_state(void) +{
- IAMMultiMediaStream *mmstream = create_ammultimediastream();
- IMediaControl *media_control;
- struct testfilter source;
- IGraphBuilder *graph;
- STREAM_STATE state;
- HRESULT hr;
- ULONG ref;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(graph != NULL, "Expected non-NULL graph.\n");
- hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaControl, (void **)&media_control);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- testfilter_init(&source);
- hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- /* Crashes on native. */
- if (0)
- {
hr = IAMMultiMediaStream_GetState(mmstream, NULL);
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
- }
- state = 0xdeadbeef;
- hr = IAMMultiMediaStream_GetState(mmstream, &state);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state);
- hr = IMediaControl_Run(media_control);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- state = 0xdeadbeef;
- hr = IAMMultiMediaStream_GetState(mmstream, &state);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state);
- hr = IMediaControl_Stop(media_control);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- state = 0xdeadbeef;
- hr = IAMMultiMediaStream_GetState(mmstream, &state);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(state == STREAMSTATE_RUN, "Got state %#x.\n", state);
- hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- state = 0xdeadbeef;
- hr = IAMMultiMediaStream_GetState(mmstream, &state);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state);
- source.init_stream_hr = E_FAIL;
- hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
- ok(hr == E_FAIL, "Got hr %#x.\n", hr);
- state = 0xdeadbeef;
- hr = IAMMultiMediaStream_GetState(mmstream, &state);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state);
- ref = IAMMultiMediaStream_Release(mmstream);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IMediaControl_Release(media_control);
- ref = IGraphBuilder_Release(graph);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8904,6 +8983,7 @@ START_TEST(amstream) test_pin_info(); test_initialize(); test_set_state();
- test_get_state(); test_enum_media_types(); test_media_types();
I feel like GetState() and SetState() are so tightly related that it likely makes more sense to test them in the same function.
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 208 ++++++++++++++++----------------- 1 file changed, 104 insertions(+), 104 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index cd014ee7f91..c2331205994 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1305,6 +1305,110 @@ static const IMediaSeekingVtbl testsource_seeking_vtbl = testsource_seeking_GetPreroll, };
+struct advise_time_cookie +{ + LONGLONG base; + LONGLONG offset; + HANDLE event; + HANDLE advise_time_called_event; + BOOL unadvise_called; +}; + +struct testclock +{ + IReferenceClock IReferenceClock_iface; + LONG refcount; + LONGLONG time; + struct advise_time_cookie *advise_time_cookie; + HRESULT get_time_hr; +}; + +static inline struct testclock *impl_from_IReferenceClock(IReferenceClock *iface) +{ + return CONTAINING_RECORD(iface, struct testclock, IReferenceClock_iface); +} + +static HRESULT WINAPI testclock_QueryInterface(IReferenceClock *iface, REFIID iid, void **out) +{ + if (winetest_debug > 1) trace("QueryInterface(%s)\n", wine_dbgstr_guid(iid)); + if (IsEqualGUID(iid, &IID_IReferenceClock) + || IsEqualGUID(iid, &IID_IUnknown)) + { + *out = iface; + IReferenceClock_AddRef(iface); + return S_OK; + } + return E_NOINTERFACE; +} + +static ULONG WINAPI testclock_AddRef(IReferenceClock *iface) +{ + struct testclock *clock = impl_from_IReferenceClock(iface); + return InterlockedIncrement(&clock->refcount); +} + +static ULONG WINAPI testclock_Release(IReferenceClock *iface) +{ + struct testclock *clock = impl_from_IReferenceClock(iface); + return InterlockedDecrement(&clock->refcount); +} + +static HRESULT WINAPI testclock_GetTime(IReferenceClock *iface, REFERENCE_TIME *time) +{ + struct testclock *clock = impl_from_IReferenceClock(iface); + if (SUCCEEDED(clock->get_time_hr)) + *time = clock->time; + return clock->get_time_hr; +} + +static HRESULT WINAPI testclock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) +{ + struct testclock *clock = impl_from_IReferenceClock(iface); + if (clock->advise_time_cookie) + { + clock->advise_time_cookie->base = base; + clock->advise_time_cookie->offset = offset; + clock->advise_time_cookie->event = (HANDLE)event; + SetEvent(clock->advise_time_cookie->advise_time_called_event); + } + else + { + SetEvent((HANDLE)event); + } + *cookie = (DWORD_PTR)clock->advise_time_cookie; + return S_OK; +} + +static HRESULT WINAPI testclock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testclock_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) +{ + if (cookie) + ((struct advise_time_cookie *)cookie)->unadvise_called = TRUE; + return S_OK; +} + +static IReferenceClockVtbl testclock_vtbl = +{ + testclock_QueryInterface, + testclock_AddRef, + testclock_Release, + testclock_GetTime, + testclock_AdviseTime, + testclock_AdvisePeriodic, + testclock_Unadvise, +}; + +static void testclock_init(struct testclock *clock) +{ + memset(clock, 0, sizeof(*clock)); + clock->IReferenceClock_iface.lpVtbl = &testclock_vtbl; +} + #define check_get_stream(a,b,c,d) check_get_stream_(__LINE__,a,b,c,d) static void check_get_stream_(int line, IAMMultiMediaStream *mmstream, IMediaStreamFilter *filter, const GUID *mspid, IMediaStream *expect) @@ -3148,110 +3252,6 @@ out_unknown: IUnknown_Release(unknown); }
-struct advise_time_cookie -{ - LONGLONG base; - LONGLONG offset; - HANDLE event; - HANDLE advise_time_called_event; - BOOL unadvise_called; -}; - -struct testclock -{ - IReferenceClock IReferenceClock_iface; - LONG refcount; - LONGLONG time; - struct advise_time_cookie *advise_time_cookie; - HRESULT get_time_hr; -}; - -static inline struct testclock *impl_from_IReferenceClock(IReferenceClock *iface) -{ - return CONTAINING_RECORD(iface, struct testclock, IReferenceClock_iface); -} - -static HRESULT WINAPI testclock_QueryInterface(IReferenceClock *iface, REFIID iid, void **out) -{ - if (winetest_debug > 1) trace("QueryInterface(%s)\n", wine_dbgstr_guid(iid)); - if (IsEqualGUID(iid, &IID_IReferenceClock) - || IsEqualGUID(iid, &IID_IUnknown)) - { - *out = iface; - IReferenceClock_AddRef(iface); - return S_OK; - } - return E_NOINTERFACE; -} - -static ULONG WINAPI testclock_AddRef(IReferenceClock *iface) -{ - struct testclock *clock = impl_from_IReferenceClock(iface); - return InterlockedIncrement(&clock->refcount); -} - -static ULONG WINAPI testclock_Release(IReferenceClock *iface) -{ - struct testclock *clock = impl_from_IReferenceClock(iface); - return InterlockedDecrement(&clock->refcount); -} - -static HRESULT WINAPI testclock_GetTime(IReferenceClock *iface, REFERENCE_TIME *time) -{ - struct testclock *clock = impl_from_IReferenceClock(iface); - if (SUCCEEDED(clock->get_time_hr)) - *time = clock->time; - return clock->get_time_hr; -} - -static HRESULT WINAPI testclock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie) -{ - struct testclock *clock = impl_from_IReferenceClock(iface); - if (clock->advise_time_cookie) - { - clock->advise_time_cookie->base = base; - clock->advise_time_cookie->offset = offset; - clock->advise_time_cookie->event = (HANDLE)event; - SetEvent(clock->advise_time_cookie->advise_time_called_event); - } - else - { - SetEvent((HANDLE)event); - } - *cookie = (DWORD_PTR)clock->advise_time_cookie; - return S_OK; -} - -static HRESULT WINAPI testclock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI testclock_Unadvise(IReferenceClock *iface, DWORD_PTR cookie) -{ - if (cookie) - ((struct advise_time_cookie *)cookie)->unadvise_called = TRUE; - return S_OK; -} - -static IReferenceClockVtbl testclock_vtbl = -{ - testclock_QueryInterface, - testclock_AddRef, - testclock_Release, - testclock_GetTime, - testclock_AdviseTime, - testclock_AdvisePeriodic, - testclock_Unadvise, -}; - -static void testclock_init(struct testclock *clock) -{ - memset(clock, 0, sizeof(*clock)); - clock->IReferenceClock_iface.lpVtbl = &testclock_vtbl; -} - static void test_audiostream_get_format(void) { static const WAVEFORMATEX pin_format =
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/multimedia.c | 8 ++-- dlls/amstream/tests/amstream.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 5c04c771535..b34634d89d2 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -174,13 +174,13 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR return hr; }
-static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *pCurrentTime) +static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *time) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); + struct multimedia_stream *stream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime); + TRACE("stream %p, time %p.\n", stream, time);
- return E_NOTIMPL; + return IMediaStreamFilter_GetCurrentStreamTime(stream->filter, time); }
static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *duration) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index c2331205994..8a64edbd420 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2689,6 +2689,79 @@ static void test_get_state(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_get_time(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + STREAM_TIME filter_start_time; + IMediaStreamFilter *filter; + IMediaFilter *media_filter; + struct testclock clock; + IGraphBuilder *graph; + STREAM_TIME time; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!filter, "Expected non-null filter.\n"); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&media_filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + testclock_init(&clock); + + /* Crashes on native. */ + if (0) + { + hr = IAMMultiMediaStream_GetTime(mmstream, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time)); + + hr = IMediaFilter_SetSyncSource(media_filter, &clock.IReferenceClock_iface); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + clock.get_time_hr = E_FAIL; + + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time)); + + clock.time = 23456789; + clock.get_time_hr = S_OK; + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &filter_start_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + clock.time = 34567890; + + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(time == 11111101 + filter_start_time, "Got time %s.\n", wine_dbgstr_longlong(time)); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaFilter_Release(media_filter); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IMediaStreamFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8984,6 +9057,7 @@ START_TEST(amstream) test_initialize(); test_set_state(); test_get_state(); + test_get_time(); test_enum_media_types(); test_media_types();
On 11/16/20 9:31 AM, Anton Baskanov wrote:
Signed-off-by: Anton Baskanov baskanov@gmail.com
dlls/amstream/multimedia.c | 8 ++-- dlls/amstream/tests/amstream.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 5c04c771535..b34634d89d2 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -174,13 +174,13 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR return hr; }
-static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *pCurrentTime) +static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *time) {
- struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
- struct multimedia_stream *stream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime);
- TRACE("stream %p, time %p.\n", stream, time);
- return E_NOTIMPL;
- return IMediaStreamFilter_GetCurrentStreamTime(stream->filter, time);
}
static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *duration) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index c2331205994..8a64edbd420 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2689,6 +2689,79 @@ static void test_get_state(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_get_time(void) +{
- IAMMultiMediaStream *mmstream = create_ammultimediastream();
- STREAM_TIME filter_start_time;
- IMediaStreamFilter *filter;
- IMediaFilter *media_filter;
- struct testclock clock;
- IGraphBuilder *graph;
- STREAM_TIME time;
- HRESULT hr;
- ULONG ref;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(!!filter, "Expected non-null filter.\n");
- hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(graph != NULL, "Expected non-NULL graph.\n");
- hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&media_filter);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- testclock_init(&clock);
- /* Crashes on native. */
- if (0)
- {
hr = IAMMultiMediaStream_GetTime(mmstream, NULL);
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
- }
- time = 0xdeadbeefdeadbeef;
- hr = IAMMultiMediaStream_GetTime(mmstream, &time);
- ok(hr == S_FALSE, "Got hr %#x.\n", hr);
- ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time));
- hr = IMediaFilter_SetSyncSource(media_filter, &clock.IReferenceClock_iface);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- clock.get_time_hr = E_FAIL;
- time = 0xdeadbeefdeadbeef;
- hr = IAMMultiMediaStream_GetTime(mmstream, &time);
- ok(hr == S_FALSE, "Got hr %#x.\n", hr);
- ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time));
- clock.time = 23456789;
- clock.get_time_hr = S_OK;
- hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &filter_start_time);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- clock.time = 34567890;
- time = 0xdeadbeefdeadbeef;
- hr = IAMMultiMediaStream_GetTime(mmstream, &time);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(time == 11111101 + filter_start_time, "Got time %s.\n", wine_dbgstr_longlong(time));
- ref = IAMMultiMediaStream_Release(mmstream);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IMediaFilter_Release(media_filter);
- ref = IGraphBuilder_Release(graph);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- ref = IMediaStreamFilter_Release(filter);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8984,6 +9057,7 @@ START_TEST(amstream) test_initialize(); test_set_state(); test_get_state();
- test_get_time(); test_enum_media_types(); test_media_types();
Same here: if the function is identical to IMediaStreamFilter::GetCurrentStreamTime(), it should probably be tested in the same function.
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/ddrawstream.c | 23 ++++++++++++-- dlls/amstream/tests/amstream.c | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 341fd4dff16..d6f07e1b10a 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -717,11 +717,28 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_CreateSample(IDirectDrawMedia }
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetTimePerFrame(IDirectDrawMediaStream *iface, - STREAM_TIME *pFrameTime) + STREAM_TIME *frame_time) { - FIXME("(%p)->(%p) stub!\n", iface, pFrameTime); + struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface);
- return E_NOTIMPL; + TRACE("stream %p, frame_time %p.\n", stream, frame_time); + + if (!frame_time) + return E_POINTER; + + EnterCriticalSection(&stream->cs); + + if (!stream->peer) + { + LeaveCriticalSection(&stream->cs); + return MS_E_NOSTREAM; + } + + *frame_time = ((VIDEOINFO *)stream->mt.pbFormat)->AvgTimePerFrame; + + LeaveCriticalSection(&stream->cs); + + return S_OK; }
static const struct IDirectDrawMediaStreamVtbl ddraw_IDirectDrawMediaStream_Vtbl = diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 8a64edbd420..abba7c4044b 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5780,6 +5780,63 @@ static void test_ddrawstream_new_segment(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_ddrawstream_get_time_per_frame(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IDirectDrawMediaStream *ddraw_stream; + struct testfilter source; + STREAM_TIME frame_time; + IGraphBuilder *graph; + IMediaStream *stream; + VIDEOINFO video_info; + AM_MEDIA_TYPE mt; + HRESULT hr; + ULONG ref; + IPin *pin; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + testfilter_init(&source); + hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_GetTimePerFrame(ddraw_stream, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IDirectDrawMediaStream_GetTimePerFrame(ddraw_stream, &frame_time); + ok(hr == MS_E_NOSTREAM, "Got hr %#x.\n", hr); + + video_info = rgb32_video_info; + video_info.AvgTimePerFrame = 12345678; + mt = rgb32_mt; + mt.pbFormat = (BYTE *)&video_info; + hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + frame_time = 0xdeadbeefdeadbeef; + hr = IDirectDrawMediaStream_GetTimePerFrame(ddraw_stream, &frame_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(frame_time == 12345678, "Got frame time %s.\n", wine_dbgstr_longlong(frame_time)); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin); + IDirectDrawMediaStream_Release(ddraw_stream); + ref = IMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void check_ammediastream_join_am_multi_media_stream(const CLSID *clsid) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -9098,6 +9155,7 @@ START_TEST(amstream) test_ddrawstream_receive(); test_ddrawstream_begin_flush_end_flush(); test_ddrawstream_new_segment(); + test_ddrawstream_get_time_per_frame();
test_ddrawstreamsample_get_media_stream(); test_ddrawstreamsample_update();
Signed-off-by: Zebediah Figura z.figura12@gmail.com
On 11/16/20 9:31 AM, Anton Baskanov wrote:
Signed-off-by: Anton Baskanov baskanov@gmail.com
dlls/amstream/filter.c | 20 ++++- dlls/amstream/tests/amstream.c | 136 ++++++++++++++++++++++++++++++++- 2 files changed, 152 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/filter.c b/dlls/amstream/filter.c index 5fd5b2afdbc..3c0436a294f 100644 --- a/dlls/amstream/filter.c +++ b/dlls/amstream/filter.c @@ -848,9 +848,25 @@ static HRESULT WINAPI filter_seeking_CheckCapabilities(IMediaSeeking *iface, DWO
static HRESULT WINAPI filter_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) {
- FIXME("iface %p, format %s, stub!\n", iface, debugstr_guid(format));
- struct filter *filter = impl_from_IMediaSeeking(iface);
- IMediaSeeking *seeking;
- HRESULT hr;
- return E_NOTIMPL;
- TRACE("filter %p, format %s.\n", filter, debugstr_guid(format));
- EnterCriticalSection(&filter->cs);
- seeking = get_seeking(filter->seekable_stream);
- LeaveCriticalSection(&filter->cs);
- if (!seeking)
return E_NOTIMPL;
- hr = IMediaSeeking_IsFormatSupported(seeking, format);
- IMediaSeeking_Release(seeking);
- return hr;
}
static HRESULT WINAPI filter_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index f5014395832..2e5d6bc92be 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -975,12 +975,14 @@ struct testfilter LONGLONG stop_position; const AM_MEDIA_TYPE *preferred_mt; HANDLE wait_state_event;
- GUID is_format_supported_format; HRESULT get_duration_hr; HRESULT get_stop_position_hr; HRESULT set_positions_hr; HRESULT init_stream_hr; HRESULT cleanup_stream_hr; HRESULT wait_state_hr;
- HRESULT is_format_supported_hr;
};
static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface) @@ -1168,8 +1170,11 @@ static HRESULT WINAPI testsource_seeking_CheckCapabilities(IMediaSeeking *iface,
static HRESULT WINAPI testsource_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) {
- ok(0, "Unexpected call.\n");
- return E_NOTIMPL;
- struct testfilter *filter = impl_from_IMediaSeeking(iface);
- filter->is_format_supported_format = *format;
I do appreciate the attention to detail, but maybe this is a little redundant. The difference in HRESULT already proves that this function is being called. [Plus, you only call this with TIME_FORMAT_MEDIA_TIME anyway, so you could just hard-code it here with an ok() message instead.]
- return filter->is_format_supported_hr;
}
static HRESULT WINAPI testsource_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) @@ -6926,6 +6931,132 @@ static void test_mediastreamfilter_wait_until(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_mediastreamfilter_is_format_supported(void) +{
- IAMMultiMediaStream *mmstream = create_ammultimediastream();
- static const MSPID mspid1 = {0x88888888, 1};
- static const MSPID mspid2 = {0x88888888, 2};
- static const MSPID mspid3 = {0x88888888, 3};
- struct testfilter source1, source2, source3;
- IAMMediaStream *stream1, *stream2, *stream3;
- IMediaStreamFilter *filter;
- IPin *pin1, *pin2, *pin3;
- IMediaSeeking *seeking;
- IGraphBuilder *graph;
- HRESULT hr;
- ULONG ref;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream1);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream3);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_Initialize(stream1, NULL, 0, &mspid1, STREAMTYPE_READ);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid2, STREAMTYPE_READ);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_Initialize(stream3, NULL, 0, &mspid3, STREAMTYPE_READ);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream1, &mspid1, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid2, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream3, &mspid3, 0, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_QueryInterface(stream1, &IID_IPin, (void **)&pin1);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMediaStream_QueryInterface(stream3, &IID_IPin, (void **)&pin3);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(graph != NULL, "Expected non-NULL graph.\n");
- testfilter_init(&source1);
- testfilter_init(&source2);
- testfilter_init(&source3);
- source1.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl;
- source2.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl;
- source3.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl;
- hr = IGraphBuilder_AddFilter(graph, &source1.filter.IBaseFilter_iface, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_AddFilter(graph, &source2.filter.IBaseFilter_iface, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_AddFilter(graph, &source3.filter.IBaseFilter_iface, NULL);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source2.source.pin.IPin_iface, pin2, &audio_mt);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source3.source.pin.IPin_iface, pin3, &audio_mt);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IMediaStreamFilter_SupportSeeking(filter, TRUE);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source1.source.pin.IPin_iface, pin1, &audio_mt);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IMediaStreamFilter_QueryInterface(filter, &IID_IMediaSeeking, (void **)&seeking);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- source2.is_format_supported_format = GUID_NULL;
- hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
- ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME),
"Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format));
- source2.is_format_supported_hr = E_FAIL;
- source2.is_format_supported_format = GUID_NULL;
- hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME);
- ok(hr == E_FAIL, "Got hr %#x.\n", hr);
- ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME),
"Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format));
- source2.is_format_supported_hr = E_NOTIMPL;
- source2.is_format_supported_format = GUID_NULL;
- hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME);
- ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
- ok(IsEqualGUID(&source2.is_format_supported_format, &TIME_FORMAT_MEDIA_TIME),
"Got format %s.\n", wine_dbgstr_guid(&source2.is_format_supported_format));
- source2.IMediaSeeking_iface.lpVtbl = NULL;
- hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME);
- ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin2);
- IGraphBuilder_Disconnect(graph, &source2.source.pin.IPin_iface);
- hr = IMediaSeeking_IsFormatSupported(seeking, &TIME_FORMAT_MEDIA_TIME);
- ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin1);
- IGraphBuilder_Disconnect(graph, &source1.source.pin.IPin_iface);
- IGraphBuilder_Disconnect(graph, pin3);
- IGraphBuilder_Disconnect(graph, &source3.source.pin.IPin_iface);
- ref = IAMMultiMediaStream_Release(mmstream);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- ref = IGraphBuilder_Release(graph);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IMediaSeeking_Release(seeking);
- ref = IMediaStreamFilter_Release(filter);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IPin_Release(pin1);
- ref = IAMMediaStream_Release(stream1);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IPin_Release(pin2);
- ref = IAMMediaStream_Release(stream2);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
- IPin_Release(pin3);
- ref = IAMMediaStream_Release(stream3);
- ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
Self-contained tests are nice, but there's an awful lot of boilerplate here, and I think it wouldn't lose that much to merge this with the GetStopPosition() and GetDuration() tests [and probably also SetPositions()].
static void test_ddrawstream_getsetdirectdraw(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8834,6 +8965,7 @@ START_TEST(amstream) test_mediastreamfilter_get_current_stream_time(); test_mediastreamfilter_reference_time_to_stream_time(); test_mediastreamfilter_wait_until();
test_mediastreamfilter_is_format_supported();
CoUninitialize();
}