Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_reader.c | 23 +++++++++++++++++++++-- dlls/wmvcore/tests/wmvcore.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 6b5d9629389..970bdac44ab 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -488,8 +488,27 @@ static HRESULT WINAPI stream_props_GetType(IWMMediaProps *iface, GUID *major_typ
static HRESULT WINAPI stream_props_GetMediaType(IWMMediaProps *iface, WM_MEDIA_TYPE *mt, DWORD *size) { - FIXME("iface %p, mt %p, size %p, stub!\n", iface, mt, size); - return E_NOTIMPL; + struct stream_config *config = impl_from_IWMMediaProps(iface); + const DWORD req_size = *size; + AM_MEDIA_TYPE stream_mt; + + TRACE("iface %p, mt %p, size %p.\n", iface, mt, size); + + if (!amt_from_wg_format(&stream_mt, &config->stream->format, true)) + return E_OUTOFMEMORY; + + *size = sizeof(stream_mt) + stream_mt.cbFormat; + if (!mt) + return S_OK; + if (req_size < *size) + return ASF_E_BUFFERTOOSMALL; + + strmbase_dump_media_type(&stream_mt); + + memcpy(mt, &stream_mt, sizeof(*mt)); + memcpy(mt + 1, stream_mt.pbFormat, stream_mt.cbFormat); + mt->pbFormat = (BYTE *)(mt + 1); + return S_OK; }
static HRESULT WINAPI stream_props_SetMediaType(IWMMediaProps *iface, WM_MEDIA_TYPE *mt) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index d6bd331ea91..bca611e4208 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -1125,14 +1125,37 @@ static void check_audio_type(const WM_MEDIA_TYPE *mt) ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "Got tag %#x.\n", wave_format->wFormatTag); }
-static void test_stream_media_props(IWMStreamConfig *config) +static void test_stream_media_props(IWMStreamConfig *config, const GUID *majortype) { + char mt_buffer[2000]; + WM_MEDIA_TYPE *mt = (WM_MEDIA_TYPE *)mt_buffer; IWMMediaProps *props; + DWORD size, ret_size; HRESULT hr;
hr = IWMStreamConfig_QueryInterface(config, &IID_IWMMediaProps, (void **)&props); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ size = 0xdeadbeef; + hr = IWMMediaProps_GetMediaType(props, NULL, &size); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(size != 0xdeadbeef && size >= sizeof(WM_MEDIA_TYPE), "Got size %u.\n", size); + + ret_size = size - 1; + hr = IWMMediaProps_GetMediaType(props, mt, &ret_size); + ok(hr == ASF_E_BUFFERTOOSMALL, "Got hr %#x.\n", hr); + ok(ret_size == size, "Expected size %u, got %u.\n", size, ret_size); + + ret_size = sizeof(mt_buffer); + memset(mt_buffer, 0xcc, sizeof(mt_buffer)); + hr = IWMMediaProps_GetMediaType(props, mt, &ret_size); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_size == size, "Expected size %u, got %u.\n", size, ret_size); + ok(size == sizeof(WM_MEDIA_TYPE) + mt->cbFormat, "Expected size %u, got %u.\n", + sizeof(WM_MEDIA_TYPE) + mt->cbFormat, size); + ok(IsEqualGUID(&mt->majortype, majortype), "Expected major type %s, got %s.\n", + debugstr_guid(majortype), debugstr_guid(&mt->majortype)); + IWMMediaProps_Release(props); }
@@ -1188,7 +1211,7 @@ static void test_sync_reader_types(void) else ok(IsEqualGUID(&majortype, &MEDIATYPE_Audio), "Got major type %s.\n", debugstr_guid(&majortype));
- test_stream_media_props(config); + test_stream_media_props(config, &majortype);
ref = IWMStreamConfig_Release(config); ok(!ref, "Got outstanding refcount %d.\n", ref); @@ -2280,7 +2303,7 @@ static void test_async_reader_types(void) else ok(IsEqualGUID(&majortype, &MEDIATYPE_Audio), "Got major type %s.\n", debugstr_guid(&majortype));
- test_stream_media_props(config); + test_stream_media_props(config, &majortype);
ref = IWMStreamConfig_Release(config); ok(!ref, "Got outstanding refcount %d.\n", ref);