Module: wine Branch: master Commit: 2e1fe519e7551f197392b446a153699b8e983ee5 URL: https://gitlab.winehq.org/wine/wine/-/commit/2e1fe519e7551f197392b446a153699...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Nov 18 21:21:46 2023 +0100
mfplat: Implement IMFMediaType_(Get|Free)Representation.
---
dlls/mfplat/mediatype.c | 48 ++++++++++++++++++++++++++++++++-------------- dlls/mfplat/tests/mfplat.c | 14 ++++++-------- 2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 5467241712e..2ba967c6719 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -634,16 +634,30 @@ static HRESULT WINAPI mediatype_IsEqual(IMFMediaType *iface, IMFMediaType *type,
static HRESULT WINAPI mediatype_GetRepresentation(IMFMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &AM_MEDIA_TYPE_REPRESENTATION)) + return MFCreateAMMediaTypeFromMFMediaType(iface, GUID_NULL, (AM_MEDIA_TYPE **)representation); + + if (IsEqualGUID(&guid, &FORMAT_WaveFormatEx) + || IsEqualGUID(&guid, &FORMAT_VideoInfo) + || IsEqualGUID(&guid, &FORMAT_VideoInfo2) + || IsEqualGUID(&guid, &FORMAT_MFVideoFormat)) + return MFCreateAMMediaTypeFromMFMediaType(iface, guid, (AM_MEDIA_TYPE **)representation); + + FIXME("Format %s not implemented!\n", debugstr_guid(&guid)); + return MF_E_UNSUPPORTED_REPRESENTATION; }
static HRESULT WINAPI mediatype_FreeRepresentation(IMFMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + AM_MEDIA_TYPE *am_type = representation;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + + CoTaskMemFree(am_type->pbFormat); + CoTaskMemFree(am_type); + return S_OK; }
static const IMFMediaTypeVtbl mediatypevtbl = @@ -1009,16 +1023,18 @@ static HRESULT WINAPI video_mediatype_IsEqual(IMFVideoMediaType *iface, IMFMedia
static HRESULT WINAPI video_mediatype_GetRepresentation(IMFVideoMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &FORMAT_WaveFormatEx)) + return MF_E_UNSUPPORTED_REPRESENTATION; + + return mediatype_GetRepresentation((IMFMediaType *)iface, guid, representation); }
static HRESULT WINAPI video_mediatype_FreeRepresentation(IMFVideoMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); - - return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + return mediatype_FreeRepresentation((IMFMediaType *)iface, guid, representation); }
static const MFVIDEOFORMAT * WINAPI video_mediatype_GetVideoFormat(IMFVideoMediaType *iface) @@ -1410,16 +1426,20 @@ static HRESULT WINAPI audio_mediatype_IsEqual(IMFAudioMediaType *iface, IMFMedia
static HRESULT WINAPI audio_mediatype_GetRepresentation(IMFAudioMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &FORMAT_VideoInfo) + || IsEqualGUID(&guid, &FORMAT_VideoInfo2) + || IsEqualGUID(&guid, &FORMAT_MFVideoFormat)) + return E_INVALIDARG; + + return mediatype_GetRepresentation((IMFMediaType *)iface, guid, representation); }
static HRESULT WINAPI audio_mediatype_FreeRepresentation(IMFAudioMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); - - return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + return mediatype_FreeRepresentation((IMFMediaType *)iface, guid, representation); }
static const WAVEFORMATEX * WINAPI audio_mediatype_GetAudioFormat(IMFAudioMediaType *iface) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 1565434cc2c..7fab1598181 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7603,27 +7603,26 @@ static void test_IMFMediaType_GetRepresentation(void) ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr);
hr = IMFMediaType_GetRepresentation(media_type, GUID_NULL, (void **)&am_type); - todo_wine ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, FORMAT_VideoInfo, (void **)&am_type); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr != S_OK) goto skip_tests; + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); @@ -7663,7 +7662,6 @@ static void test_IMFMediaType_GetRepresentation(void) hr = IMFMediaType_FreeRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, am_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-skip_tests: IMFMediaType_Release(media_type); }