[PATCH v2 0/8] MR10643: amstream: Test and fix QueryAccept on ddraw stream.
This MR adds a number of new tests for the `IPin::QueryAccept` function on the Direct Draw media stream. -- v2: amstream: Use DisplayMode to determine pixel format. amstream/test: Test media types when ddraw is passed to AddMediaStream. amstream: Only accept format passed in SetFormat. amstream/tests: Test AcceptQuery behavior after SetFormat. amstream: Accept additional subtypes in QueryAccept. amstream: Reject negative heights in QueryAccept. amstream/tests: Test negative heights in QueryAccept. amstream/tests: Test QueryAccept when connected. https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 2f01a2b7688..f3c4733f3a7 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3020,11 +3020,12 @@ static void test_media_types(void) .cbSize = 0, }; IAMMultiMediaStream *mmstream = create_ammultimediastream(); + struct testfilter source; IEnumMediaTypes *enummt; IMediaStream *stream; AM_MEDIA_TYPE *pmt; + unsigned int i, j; ULONG ref, count; - unsigned int i; HRESULT hr; IPin *pin; @@ -3047,12 +3048,12 @@ static void test_media_types(void) static const GUID *rejected_subtypes[] = { - &MEDIASUBTYPE_RGB1, - &MEDIASUBTYPE_RGB4, &MEDIASUBTYPE_RGB565, &MEDIASUBTYPE_RGB555, &MEDIASUBTYPE_RGB24, &MEDIASUBTYPE_RGB32, + &MEDIASUBTYPE_RGB1, + &MEDIASUBTYPE_RGB4, &MEDIASUBTYPE_ARGB32, &MEDIASUBTYPE_ARGB1555, &MEDIASUBTYPE_ARGB4444, @@ -3118,12 +3119,31 @@ static void test_media_types(void) ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); pmt->majortype = MEDIATYPE_Video; + testfilter_init(&source); + for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) { pmt->subtype = *rejected_subtypes[i]; hr = IPin_QueryAccept(pin, pmt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, pmt); + ok(hr == (i < 4) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx on ReceiveConnection for subtype %s.\n", hr, + wine_dbgstr_guid(rejected_subtypes[i])); + + if (hr == S_OK) + { + for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) + { + pmt->subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, pmt); + todo_wine_if(j < 4) + ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", + hr, wine_dbgstr_guid(rejected_subtypes[j])); + } + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + } } CoTaskMemFree(pmt); @@ -3177,6 +3197,9 @@ static void test_media_types(void) ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %ld.\n", ref); + + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %ld.\n", ref); } static void test_get_end_of_stream_event_handle(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 43 ++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index f3c4733f3a7..6518f15bfee 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3022,8 +3022,9 @@ static void test_media_types(void) IAMMultiMediaStream *mmstream = create_ammultimediastream(); struct testfilter source; IEnumMediaTypes *enummt; + AM_MEDIA_TYPE *pmt, mt; + VIDEOINFOHEADER *vih; IMediaStream *stream; - AM_MEDIA_TYPE *pmt; unsigned int i, j; ULONG ref, count; HRESULT hr; @@ -3121,13 +3122,29 @@ static void test_media_types(void) testfilter_init(&source); + /* Make a copy of the media type so we can manipulate the VIDEOINFOHEADER */ + CopyMediaType(&mt, pmt); + CoTaskMemFree(pmt); + vih = (VIDEOINFOHEADER *)mt.pbFormat; + + vih->bmiHeader.biHeight = 1; + hr = IPin_QueryAccept(pin, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + /* A negative height is never accepted */ + vih->bmiHeader.biHeight = -1; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) { - pmt->subtype = *rejected_subtypes[i]; - hr = IPin_QueryAccept(pin, pmt); + mt.subtype = *rejected_subtypes[i]; + vih->bmiHeader.biHeight = 1; + hr = IPin_QueryAccept(pin, &mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); - hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, pmt); + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); ok(hr == (i < 4) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx on ReceiveConnection for subtype %s.\n", hr, wine_dbgstr_guid(rejected_subtypes[i])); @@ -3135,18 +3152,30 @@ static void test_media_types(void) { for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) { - pmt->subtype = *rejected_subtypes[j]; - hr = IPin_QueryAccept(pin, pmt); + mt.subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, &mt); todo_wine_if(j < 4) ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", hr, wine_dbgstr_guid(rejected_subtypes[j])); } + + /* A negative height is never accepted */ + vih->bmiHeader.biHeight = -1; + for (j = 0; j < ARRAY_SIZE(rejected_subtypes); ++j) + { + mt.subtype = *rejected_subtypes[j]; + hr = IPin_QueryAccept(pin, &mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx for subtype %s using negative height.\n", + hr, wine_dbgstr_guid(rejected_subtypes[j])); + } + hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); } + } - CoTaskMemFree(pmt); + FreeMediaType(&mt); hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); ok(hr == S_FALSE, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 3 ++- dlls/amstream/tests/amstream.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 846814b8fd4..fb17ff9a9c7 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1280,7 +1280,8 @@ static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *m if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8) - && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) + && ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight >= 0) return S_OK; return VFW_E_TYPE_NOT_ACCEPTED; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 6518f15bfee..22bc00c1168 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3134,7 +3134,6 @@ static void test_media_types(void) /* A negative height is never accepted */ vih->bmiHeader.biHeight = -1; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 21 +++++++++++++++++---- dlls/amstream/tests/amstream.c | 1 - 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index fb17ff9a9c7..f33656aa130 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1276,12 +1276,25 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id) static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) { + struct ddraw_stream *stream = impl_from_IPin(iface); + TRACE("iface %p, mt %p.\n", iface, mt); - if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) - && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8) - && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) - && ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight >= 0) + if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Video) + || !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) + || ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight < 0) + return VFW_E_TYPE_NOT_ACCEPTED; + + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)) + return S_OK; + + if (!stream->peer) + return VFW_E_TYPE_NOT_ACCEPTED; + + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB555) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB565) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB24) + || IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB32)) return S_OK; return VFW_E_TYPE_NOT_ACCEPTED; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 22bc00c1168..f21d3ad87d7 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3153,7 +3153,6 @@ static void test_media_types(void) { mt.subtype = *rejected_subtypes[j]; hr = IPin_QueryAccept(pin, &mt); - todo_wine_if(j < 4) ok(hr == (j < 4 ? S_OK : VFW_E_TYPE_NOT_ACCEPTED), "Got hr %#lx for subtype %s whilst connected.\n", hr, wine_dbgstr_guid(rejected_subtypes[j])); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index f21d3ad87d7..33e47f609bc 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4207,11 +4207,27 @@ static void test_ddrawstream_receive_connection(void) hr = IDirectDrawMediaStream_SetFormat(ddraw_stream, &rgb555_format, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr); + /* After SetFormat is called, only this format is accepted by QueryAccept ... */ + mt = rgb555_mt; + mt.pbFormat = (BYTE *)&video_info; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt = rgb8_mt; + mt.pbFormat = (BYTE *)&video_info; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb565_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb555_mt); ok(hr == S_OK, "Got hr %#lx.\n", hr); + /* .. even when connected (where all supported types were previously accepted) */ + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 48 +++++++++++++++++++--------------- dlls/amstream/tests/amstream.c | 3 --- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index f33656aa130..49257554d90 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -553,6 +553,22 @@ static unsigned int align(unsigned int n, unsigned int alignment) return (n + alignment - 1) & ~(alignment - 1); } +static void subtype_from_pf(GUID *subtype, const DDPIXELFORMAT *pf) +{ + if (pf->dwRGBBitCount == 16 && pf->dwRBitMask == 0x7c00) + *subtype = MEDIASUBTYPE_RGB555; + else if (pf->dwRGBBitCount == 16 && pf->dwRBitMask == 0xf800) + *subtype = MEDIASUBTYPE_RGB565; + else if (pf->dwRGBBitCount == 24) + *subtype = MEDIASUBTYPE_RGB24; + else if (pf->dwRGBBitCount == 32) + *subtype = MEDIASUBTYPE_RGB32; + else if (pf->dwRGBBitCount == 8 && (pf->dwFlags & DDPF_PALETTEINDEXED8)) + *subtype = MEDIASUBTYPE_RGB8; + else + FIXME("Unknown flags %#lx, bit count %lu.\n", pf->dwFlags, pf->dwRGBBitCount); +} + static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, unsigned int pitch) { VIDEOINFO *videoinfo = CoTaskMemAlloc(sizeof(VIDEOINFO)); @@ -577,38 +593,20 @@ static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, uns mt->lSampleSize = videoinfo->bmiHeader.biSizeImage; mt->bFixedSizeSamples = TRUE; - if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0x7c00) - { - mt->subtype = MEDIASUBTYPE_RGB555; - } - else if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0xf800) + subtype_from_pf(&mt->subtype, &format->ddpfPixelFormat); + + if (format->ddpfPixelFormat.dwRGBBitCount == 16 && format->ddpfPixelFormat.dwRBitMask == 0xf800) { - mt->subtype = MEDIASUBTYPE_RGB565; - videoinfo = (VIDEOINFO *)mt->pbFormat; videoinfo->bmiHeader.biCompression = BI_BITFIELDS; videoinfo->dwBitMasks[iRED] = 0xf800; videoinfo->dwBitMasks[iGREEN] = 0x07e0; videoinfo->dwBitMasks[iBLUE] = 0x001f; } - else if (format->ddpfPixelFormat.dwRGBBitCount == 24) - { - mt->subtype = MEDIASUBTYPE_RGB24; - } - else if (format->ddpfPixelFormat.dwRGBBitCount == 32) - { - mt->subtype = MEDIASUBTYPE_RGB32; - } else if (format->ddpfPixelFormat.dwRGBBitCount == 8 && (format->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)) { - mt->subtype = MEDIASUBTYPE_RGB8; videoinfo->bmiHeader.biClrUsed = 256; /* FIXME: Translate the palette. */ } - else - { - FIXME("Unknown flags %#lx, bit count %lu.\n", - format->ddpfPixelFormat.dwFlags, format->ddpfPixelFormat.dwRGBBitCount); - } } static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, @@ -1277,6 +1275,7 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id) static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) { struct ddraw_stream *stream = impl_from_IPin(iface); + GUID subtype; TRACE("iface %p, mt %p.\n", iface, mt); @@ -1285,6 +1284,13 @@ static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *m || ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader.biHeight < 0) return VFW_E_TYPE_NOT_ACCEPTED; + if (stream->format.flags & DDSD_PIXELFORMAT) + { + subtype_from_pf(&subtype, &stream->format.pf); + + return IsEqualGUID(&mt->subtype, &subtype) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED; + } + if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)) return S_OK; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 33e47f609bc..5c74fd3cad6 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4211,13 +4211,11 @@ static void test_ddrawstream_receive_connection(void) mt = rgb555_mt; mt.pbFormat = (BYTE *)&video_info; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); mt = rgb8_mt; mt.pbFormat = (BYTE *)&video_info; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &rgb565_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); @@ -4226,7 +4224,6 @@ static void test_ddrawstream_receive_connection(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); /* .. even when connected (where all supported types were previously accepted) */ hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/tests/amstream.c | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 5c74fd3cad6..ef482f6cd0a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3020,13 +3020,19 @@ static void test_media_types(void) .cbSize = 0, }; IAMMultiMediaStream *mmstream = create_ammultimediastream(); + DDSURFACEDESC current = { .dwSize = sizeof(current) }; + DDSURFACEDESC desired = { .dwSize = sizeof(desired) }; + IDirectDrawMediaStream *ddraw_stream; + IDirectDrawPalette *palette; struct testfilter source; IEnumMediaTypes *enummt; AM_MEDIA_TYPE *pmt, mt; VIDEOINFOHEADER *vih; IMediaStream *stream; + IDirectDraw *ddraw; unsigned int i, j; ULONG ref, count; + DWORD flags; HRESULT hr; IPin *pin; @@ -3227,6 +3233,74 @@ static void test_media_types(void) ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); ok(!ref, "Got outstanding refcount %ld.\n", ref); + + /* Test media types when ddraw is passed to AddMediaStream */ + mmstream = create_ammultimediastream(); + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)ddraw, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirectDrawMediaStream_GetFormat(ddraw_stream, ¤t, &palette, &desired, &flags); + ok(hr == 0x80040403, "Got hr %#lx.\n", hr); + + memset(&mt, 0, sizeof(mt)); + mt.majortype = MEDIATYPE_Video; + mt.subtype = MEDIASUBTYPE_RGB32; + mt.bFixedSizeSamples = TRUE; + mt.lSampleSize = 40000; + mt.formattype = FORMAT_VideoInfo; + mt.cbFormat = sizeof(req_vih); + mt.pbFormat = (BYTE*) &req_vih; + + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB8; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB32; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + testfilter_init(&source); + + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IPin_QueryAccept(pin, &mt); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + mt.subtype = MEDIASUBTYPE_RGB8; + hr = IPin_QueryAccept(pin, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + hr = IPin_Disconnect(pin); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); + todo_wine + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); + + IPin_Release(pin); + IDirectDrawMediaStream_Release(ddraw_stream); + IMediaStream_Release(stream); + IDirectDraw_Release(ddraw); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %ld.\n", ref); + + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %ld.\n", ref); } static void test_get_end_of_stream_event_handle(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
From: Brendan McGrath <bmcgrath@codeweavers.com> --- dlls/amstream/ddrawstream.c | 43 ++++++++++++++++++++++++---------- dlls/amstream/tests/amstream.c | 7 +----- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 49257554d90..4887927315e 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -97,6 +97,8 @@ struct ddraw_sample static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDrawSurface *surface, const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample); +static HRESULT WINAPI ddrawstream_check_pixel_format(const DDSURFACEDESC *format); + static void remove_queued_update(struct ddraw_sample *sample) { sample->pending = false; @@ -326,6 +328,7 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn REFMSPID purpose_id, const STREAM_TYPE stream_type) { struct ddraw_stream *stream = impl_from_IAMMediaStream(iface); + DDSURFACEDESC desc = { .dwSize = sizeof(desc) }; HRESULT hr; TRACE("stream %p, source_object %p, flags %lx, purpose_id %s, stream_type %u.\n", stream, source_object, flags, @@ -348,6 +351,14 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn && FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw, (void **)&stream->ddraw))) FIXME("Stream object doesn't implement IDirectDraw interface, hr %#lx.\n", hr); + if (stream->ddraw + && SUCCEEDED(IDirectDraw_GetDisplayMode(stream->ddraw, &desc)) + && SUCCEEDED(ddrawstream_check_pixel_format(&desc))) + { + stream->format.flags |= DDSD_PIXELFORMAT; + stream->format.pf = desc.ddpfPixelFormat; + } + if (!source_object) { if (FAILED(hr = DirectDrawCreate(NULL, &stream->ddraw, NULL))) @@ -609,19 +620,8 @@ static void set_mt_from_desc(AM_MEDIA_TYPE *mt, const DDSURFACEDESC *format, uns } } -static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, - const DDSURFACEDESC *format, IDirectDrawPalette *palette) +static HRESULT WINAPI ddrawstream_check_pixel_format(const DDSURFACEDESC *format) { - struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); - struct format old_format; - IPin *old_peer; - HRESULT hr; - - TRACE("stream %p, format %p, palette %p.\n", stream, format, palette); - - if (palette) - FIXME("Setting palette is not yet supported.\n"); - if (!format) return E_POINTER; @@ -717,6 +717,25 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr } } + return S_OK; +} + +static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStream *iface, + const DDSURFACEDESC *format, IDirectDrawPalette *palette) +{ + struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); + struct format old_format; + IPin *old_peer; + HRESULT hr; + + TRACE("stream %p, format %p, palette %p.\n", stream, format, palette); + + if (palette) + FIXME("Setting palette is not yet supported.\n"); + + if (FAILED(hr = ddrawstream_check_pixel_format(format))) + return hr; + EnterCriticalSection(&stream->cs); old_format = stream->format; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index ef482f6cd0a..41168352d84 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3246,7 +3246,7 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirectDrawMediaStream_GetFormat(ddraw_stream, ¤t, &palette, &desired, &flags); - ok(hr == 0x80040403, "Got hr %#lx.\n", hr); + ok(hr == MS_E_NOSTREAM, "Got hr %#lx.\n", hr); memset(&mt, 0, sizeof(mt)); mt.majortype = MEDIATYPE_Video; @@ -3258,17 +3258,14 @@ static void test_media_types(void) mt.pbFormat = (BYTE*) &req_vih; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); mt.subtype = MEDIASUBTYPE_RGB8; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); mt.subtype = MEDIASUBTYPE_RGB32; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); testfilter_init(&source); @@ -3281,14 +3278,12 @@ static void test_media_types(void) mt.subtype = MEDIASUBTYPE_RGB8; hr = IPin_QueryAccept(pin, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); hr = IPin_Disconnect(pin); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt); - todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); IPin_Release(pin); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
Why test ReceiveConnection() on only these subtypes? If the others return VFW_E_TYPE_NOT_ACCEPTED, we should validate that in the test and then skip the rest of the new tests.
OK, fair point. I've changed that.
This would be more convincing if you also test a height of 1 is accepted. There's other reasons for -1 to be potentially invalid: it doesn't match the height returned from EnumMediaTypes(); it's not aligned; it doesn't match biSizeImage or lSampleSize.
Again, fair call. And again I've changed that.
Are we sure only setting the subtype is enough? Probably everything else needs to match, too.
It seems to be. The tests already test different heights and widths and they pass.
This could use a GetFormat() test.
I've added one, but it just returns `MS_E_NOSTREAM`.
The name ddraw_validate_format() seems odd
OK, yeah you're right. I've changed it to `ddrawstream_check_pixel_format`.
I don't think we need to bother checking if the format we get from GetDisplayMode() has DDSD_PIXELFORMAT set.
OK, I wasn't sure myself so I included it just in case. Now removed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10643#note_136024
v2: - Test `ReceiveConnection` on all rejected types - Test height values of both positive and negative 1 (to isolate the failure to the negative value) - Add a `GetFormat` test when providing `ddraw` to `AddMediaStream` - Rename `ddraw_validate_format` to `ddrawstream_check_pixel_format` to better reflect its purpose - Remove check for DDSD_PIXELFORMAT flag on from format returned by GetDisplayMode() -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10643#note_136025
This merge request was approved by Elizabeth Figura. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10643
participants (3)
-
Brendan McGrath -
Brendan McGrath (@redmcg) -
Elizabeth Figura (@zfigura)