Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 233 ++++++++++++++++++++++++++++++++- 1 file changed, 230 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 9cefec12442..2f7854606f4 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1313,6 +1313,208 @@ static const IMediaSeekingVtbl testsource_seeking_vtbl = testsource_seeking_GetPreroll, };
+struct testmediastreamfilter +{ + IMediaStreamFilter IMediaStreamFilter_iface; + LONG refcount; + unsigned int got_end_of_stream; +}; + +static inline struct testmediastreamfilter *impl_from_IMediaStreamFilter(IMediaStreamFilter *iface) +{ + return CONTAINING_RECORD(iface, struct testmediastreamfilter, IMediaStreamFilter_iface); +} + +static HRESULT WINAPI testmediastreamfilter_QueryInterface(IMediaStreamFilter *iface, REFIID iid, void **out) +{ + if (IsEqualGUID(iid, &IID_IUnknown) + || IsEqualGUID(iid, &IID_IPersist) + || IsEqualGUID(iid, &IID_IMediaFilter) + || IsEqualGUID(iid, &IID_IBaseFilter) + || IsEqualGUID(iid, &IID_IMediaStreamFilter)) + { + IMediaStreamFilter_AddRef(iface); + *out = iface; + return S_OK; + } + + ok(0, "Unexpected interface %s.\n", wine_dbgstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI testmediastreamfilter_AddRef(IMediaStreamFilter *iface) +{ + struct testmediastreamfilter *filter = impl_from_IMediaStreamFilter(iface); + return InterlockedIncrement(&filter->refcount); +} + +static ULONG WINAPI testmediastreamfilter_Release(IMediaStreamFilter *iface) +{ + struct testmediastreamfilter *filter = impl_from_IMediaStreamFilter(iface); + return InterlockedDecrement(&filter->refcount); +} + +static HRESULT WINAPI testmediastreamfilter_GetClassID(IMediaStreamFilter *iface, CLSID *clsid) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_Stop(IMediaStreamFilter *iface) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_Pause(IMediaStreamFilter *iface) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_Run(IMediaStreamFilter *iface, REFERENCE_TIME start) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_GetState(IMediaStreamFilter *iface, DWORD timeout, FILTER_STATE *state) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_SetSyncSource(IMediaStreamFilter *iface, IReferenceClock *clock) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_GetSyncSource(IMediaStreamFilter *iface, IReferenceClock **clock) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_EnumPins(IMediaStreamFilter *iface, IEnumPins **enum_pins) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_FindPin(IMediaStreamFilter *iface, const WCHAR *id, IPin **pin) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_QueryFilterInfo(IMediaStreamFilter *iface, FILTER_INFO *pInfo) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_JoinFilterGraph(IMediaStreamFilter *iface, IFilterGraph *graph, const WCHAR *name) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_QueryVendorInfo(IMediaStreamFilter *iface, WCHAR **vendor_info) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_AddMediaStream(IMediaStreamFilter *iface, IAMMediaStream *stream) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_GetMediaStream(IMediaStreamFilter *iface, const MSPID *purpose_id, IMediaStream **stream) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_EnumMediaStreams(IMediaStreamFilter *iface, LONG index, IMediaStream **stream) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_SupportSeeking(IMediaStreamFilter *iface, BOOL renderer) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_ReferenceTimeToStreamTime(IMediaStreamFilter *iface, REFERENCE_TIME *time) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_GetCurrentStreamTime(IMediaStreamFilter *iface, REFERENCE_TIME *time) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_WaitUntil(IMediaStreamFilter *iface, REFERENCE_TIME time) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_Flush(IMediaStreamFilter *iface, BOOL cancel_eos) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testmediastreamfilter_EndOfStream(IMediaStreamFilter *iface) +{ + struct testmediastreamfilter *filter = impl_from_IMediaStreamFilter(iface); + ++filter->got_end_of_stream; + return S_OK; +} + +static IMediaStreamFilterVtbl testmediastreamfilter_vtbl = +{ + testmediastreamfilter_QueryInterface, + testmediastreamfilter_AddRef, + testmediastreamfilter_Release, + testmediastreamfilter_GetClassID, + testmediastreamfilter_Stop, + testmediastreamfilter_Pause, + testmediastreamfilter_Run, + testmediastreamfilter_GetState, + testmediastreamfilter_SetSyncSource, + testmediastreamfilter_GetSyncSource, + testmediastreamfilter_EnumPins, + testmediastreamfilter_FindPin, + testmediastreamfilter_QueryFilterInfo, + testmediastreamfilter_JoinFilterGraph, + testmediastreamfilter_QueryVendorInfo, + testmediastreamfilter_AddMediaStream, + testmediastreamfilter_GetMediaStream, + testmediastreamfilter_EnumMediaStreams, + testmediastreamfilter_SupportSeeking, + testmediastreamfilter_ReferenceTimeToStreamTime, + testmediastreamfilter_GetCurrentStreamTime, + testmediastreamfilter_WaitUntil, + testmediastreamfilter_Flush, + testmediastreamfilter_EndOfStream, +}; + +static void testmediastreamfilter_init(struct testmediastreamfilter *filter) +{ + memset(filter, 0, sizeof(*filter)); + filter->IMediaStreamFilter_iface.lpVtbl = &testmediastreamfilter_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) @@ -6065,9 +6267,11 @@ static void test_ammediastream_set_state(void) check_ammediastream_set_state(&MSPID_PrimaryVideo); }
-static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TYPE *mt) +static void check_ammediastream_end_of_stream(const CLSID *clsid, const MSPID *id, const AM_MEDIA_TYPE *mt) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + struct testmediastreamfilter filter; + IAMMediaStream *am_stream; struct testfilter source; IGraphBuilder *graph; IMediaStream *stream; @@ -6122,12 +6326,35 @@ static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TY IPin_Release(pin); ref = IMediaStream_Release(stream); ok(!ref, "Got outstanding refcount %d.\n", ref); + + testmediastreamfilter_init(&filter); + + hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&am_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(am_stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_JoinFilter(am_stream, &filter.IMediaStreamFilter_iface); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + filter.got_end_of_stream = 0; + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(filter.got_end_of_stream == 1, "Got %d calls to IMediaStreamFilter::EndOfStream().\n", filter.got_end_of_stream); + + hr = IPin_EndOfStream(pin); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + todo_wine ok(filter.got_end_of_stream == 1, "Got %d calls to IMediaStreamFilter::EndOfStream().\n", filter.got_end_of_stream); + + IPin_Release(pin); + ref = IAMMediaStream_Release(am_stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); }
static void test_ammediastream_end_of_stream(void) { - check_ammediastream_end_of_stream(&MSPID_PrimaryAudio, &audio_mt); - check_ammediastream_end_of_stream(&MSPID_PrimaryVideo, &rgb32_mt); + check_ammediastream_end_of_stream(&CLSID_AMAudioStream, &MSPID_PrimaryAudio, &audio_mt); + check_ammediastream_end_of_stream(&CLSID_AMDirectDrawStream, &MSPID_PrimaryVideo, &rgb32_mt); }
void test_mediastreamfilter_get_state(void)