[PATCH] amstream: Accept more media subtypes in AMVideoStream::ReceiveConnection().
Zebediah Figura
zfigura at codeweavers.com
Fri Jul 24 16:55:59 CDT 2020
On 7/24/20 10:50 AM, Gijs Vermeulen wrote:
> Fixes: a7c515fe01c4902a3e7c6b60608a54b77e252b47
> Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
> ---
> dlls/amstream/ddrawstream.c | 26 +++++-----
> dlls/amstream/tests/amstream.c | 93 ++++++++++++++++++++++++++++++++++
> 2 files changed, 107 insertions(+), 12 deletions(-)
>
> diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c
> index 9f74eaf91a..4c94bacf52 100644
> --- a/dlls/amstream/ddrawstream.c
> +++ b/dlls/amstream/ddrawstream.c
> @@ -632,16 +632,6 @@ static HRESULT WINAPI ddraw_sink_Connect(IPin *iface, IPin *peer, const AM_MEDIA
> return E_UNEXPECTED;
> }
>
> -static BOOL check_media_type(const AM_MEDIA_TYPE *mt)
> -{
> - if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video)
> - && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)
> - && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
> - return TRUE;
> -
> - return FALSE;
> -}
> -
> static HRESULT WINAPI ddraw_sink_ReceiveConnection(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
> {
> struct ddraw_stream *stream = impl_from_IPin(iface);
> @@ -657,7 +647,13 @@ static HRESULT WINAPI ddraw_sink_ReceiveConnection(IPin *iface, IPin *peer, cons
> return VFW_E_ALREADY_CONNECTED;
> }
>
> - if (!check_media_type(mt))
> + if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Video)
> + || (!IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)
> + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB24)
> + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB32)
> + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB555)
> + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB565))
> + || !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
> {
> LeaveCriticalSection(&stream->cs);
> return VFW_E_TYPE_NOT_ACCEPTED;
> @@ -788,7 +784,13 @@ static HRESULT WINAPI ddraw_sink_QueryId(IPin *iface, WCHAR **id)
> static HRESULT WINAPI ddraw_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt)
> {
> TRACE("iface %p, mt %p.\n", iface, mt);
> - return check_media_type(mt) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;
> +
> + if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Video)
> + && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)
> + && IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
> + return S_OK;
> +
> + return VFW_E_TYPE_NOT_ACCEPTED;
> }
>
> static HRESULT WINAPI ddraw_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **enum_media_types)
> diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
> index 8adf9db934..8a6dc26f96 100644
> --- a/dlls/amstream/tests/amstream.c
> +++ b/dlls/amstream/tests/amstream.c
> @@ -28,6 +28,7 @@
> #include "initguid.h"
> #include "ksmedia.h"
> #include "dvdmedia.h"
> +#include "wmcodecdsp.h"
> #include "wine/strmbase.h"
>
> static const WAVEFORMATEX audio_format =
> @@ -2330,6 +2331,14 @@ static void test_media_types(void)
> &MEDIASUBTYPE_ARGB32,
> &MEDIASUBTYPE_ARGB1555,
> &MEDIASUBTYPE_ARGB4444,
> + &MEDIASUBTYPE_Avi,
> + &MEDIASUBTYPE_I420,
> + &MEDIASUBTYPE_AYUV,
> + &MEDIASUBTYPE_YV12,
> + &MEDIASUBTYPE_YUY2,
> + &MEDIASUBTYPE_UYVY,
> + &MEDIASUBTYPE_YVYU,
> + &MEDIASUBTYPE_NV12,
> &GUID_NULL,
> };
>
> @@ -3243,6 +3252,89 @@ static void test_audiostream_receive_connection(void)
> ok(!ref, "Got outstanding refcount %d.\n", ref);
> }
>
> +static void test_ddrawstream_receive_connection(void)
> +{
> + static const VIDEOINFOHEADER req_vih;
> + IDirectDrawMediaStream *ddraw_stream;
> + IAMMultiMediaStream *mmstream;
> + struct testfilter source;
> + IMediaStream *stream;
> + AM_MEDIA_TYPE mt;
> + HRESULT hr;
> + ULONG ref;
> + IPin *pin;
> + int i;
> +
> + const AM_MEDIA_TYPE video_mt =
> + {
> + .majortype = MEDIATYPE_Video,
> + .subtype = MEDIASUBTYPE_RGB8,
> + .formattype = FORMAT_VideoInfo,
> + .cbFormat = sizeof(VIDEOINFOHEADER),
> + .pbFormat = (BYTE *)&req_vih,
> + };
> +
> + static const GUID *subtypes[] =
> + {
> + &MEDIASUBTYPE_RGB24,
> + &MEDIASUBTYPE_RGB32,
> + &MEDIASUBTYPE_RGB555,
> + &MEDIASUBTYPE_RGB565,
> + &MEDIASUBTYPE_RGB1,
> + &MEDIASUBTYPE_RGB4,
> + &MEDIASUBTYPE_ARGB32,
> + &MEDIASUBTYPE_ARGB1555,
> + &MEDIASUBTYPE_ARGB4444,
> + &MEDIASUBTYPE_Avi,
> + &MEDIASUBTYPE_I420,
> + &MEDIASUBTYPE_AYUV,
> + &MEDIASUBTYPE_YV12,
> + &MEDIASUBTYPE_YUY2,
> + &MEDIASUBTYPE_UYVY,
> + &MEDIASUBTYPE_YVYU,
> + &MEDIASUBTYPE_NV12,
> + &GUID_NULL,
> + };
> +
> + mmstream = create_ammultimediastream();
> + 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);
> +
> + testfilter_init(&source);
> +
> + mt = video_mt;
> + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt);
> + ok(hr == S_OK, "Got hr %#x.\n", hr);
> + hr = IPin_Disconnect(pin);
> + ok(hr == S_OK, "Got hr %#x.\n", hr);
> +
> + for (i = 0; i < ARRAY_SIZE(subtypes); ++i)
> + {
> + mt = video_mt;
> + mt.subtype = *subtypes[i];
> + hr = IPin_ReceiveConnection(pin, &source.source.pin.IPin_iface, &mt);
> + ok(hr == (i < 4) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
Slight error here: comparison operators bind tighter than the ternary
operator, so the right side needs to be parenthesized.
> + if (hr == S_OK)
> + {
> + hr = IPin_Disconnect(pin);
> + ok(hr == S_OK, "Got hr %#x.\n", hr);
> + }
> + }
> +
> + ref = IAMMultiMediaStream_Release(mmstream);
> + 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);
> + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface);
> + ok(!ref, "Got outstanding refcount %d.\n", ref);
> +}
> +
> static void test_audiostream_set_state(void)
> {
> IAMMultiMediaStream *mmstream = create_ammultimediastream();
> @@ -5238,6 +5330,7 @@ START_TEST(amstream)
>
> test_ddrawstream_initialize();
> test_ddrawstream_getsetdirectdraw();
> + test_ddrawstream_receive_connection();
>
> test_ammediastream_join_am_multi_media_stream();
> test_ammediastream_join_filter();
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200724/a5d7e2a4/attachment-0001.sig>
More information about the wine-devel
mailing list