Nikolay Sivov : mf/evr: Implement IsMediaTypeSupported().
Alexandre Julliard
julliard at winehq.org
Fri Oct 9 16:00:45 CDT 2020
Module: wine
Branch: master
Commit: e2bcf44080070436bfae9888c8e6001d511192e3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e2bcf44080070436bfae9888c8e6001d511192e3
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Oct 9 13:54:40 2020 +0300
mf/evr: Implement IsMediaTypeSupported().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mf/evr.c | 60 ++++++++++++++++++++++++++++++++++++++++++++----------
dlls/mf/tests/mf.c | 12 +++++++++++
2 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/dlls/mf/evr.c b/dlls/mf/evr.c
index 087ac2a88e..c3548170af 100644
--- a/dlls/mf/evr.c
+++ b/dlls/mf/evr.c
@@ -362,12 +362,57 @@ static ULONG WINAPI video_stream_typehandler_Release(IMFMediaTypeHandler *iface)
return IMFStreamSink_Release(&stream->IMFStreamSink_iface);
}
+/* Mixer expects special video media type instance. */
+static HRESULT video_renderer_create_video_type(IMFMediaType *media_type, IMFVideoMediaType **video_type)
+{
+ GUID subtype;
+ HRESULT hr;
+
+ *video_type = NULL;
+
+ if (FAILED(hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &subtype)))
+ return hr;
+
+ if (FAILED(hr = MFCreateVideoMediaTypeFromSubtype(&subtype, video_type)))
+ return hr;
+
+ hr = IMFMediaType_CopyAllItems(media_type, (IMFAttributes *)*video_type);
+ if (FAILED(hr))
+ {
+ IMFVideoMediaType_Release(*video_type);
+ *video_type = NULL;
+ }
+
+ return hr;
+}
+
static HRESULT WINAPI video_stream_typehandler_IsMediaTypeSupported(IMFMediaTypeHandler *iface,
IMFMediaType *in_type, IMFMediaType **out_type)
{
- FIXME("%p, %p, %p.\n", iface, in_type, out_type);
+ struct video_stream *stream = impl_from_IMFMediaTypeHandler(iface);
+ IMFVideoMediaType *video_type;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("%p, %p, %p.\n", iface, in_type, out_type);
+
+ if (!in_type)
+ return E_POINTER;
+
+ if (!stream->parent)
+ return MF_E_INVALIDMEDIATYPE;
+
+ if (FAILED(hr = video_renderer_create_video_type(in_type, &video_type)))
+ return hr;
+
+ if (SUCCEEDED(hr = IMFTransform_SetInputType(stream->parent->mixer, stream->id, (IMFMediaType *)video_type,
+ MFT_SET_TYPE_TEST_ONLY)))
+ {
+ if (out_type) *out_type = NULL;
+ }
+
+ IMFVideoMediaType_Release(video_type);
+
+ return hr;
}
static HRESULT WINAPI video_stream_typehandler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
@@ -394,7 +439,6 @@ static HRESULT WINAPI video_stream_typehandler_SetCurrentMediaType(IMFMediaTypeH
{
struct video_stream *stream = impl_from_IMFMediaTypeHandler(iface);
IMFVideoMediaType *video_type;
- GUID subtype;
HRESULT hr;
TRACE("%p, %p.\n", iface, type);
@@ -405,16 +449,10 @@ static HRESULT WINAPI video_stream_typehandler_SetCurrentMediaType(IMFMediaTypeH
if (!stream->parent)
return MF_E_STREAMSINK_REMOVED;
- if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
- return hr;
-
- /* Mixer expects special video media type instance. */
- if (FAILED(hr = MFCreateVideoMediaTypeFromSubtype(&subtype, &video_type)))
+ if (FAILED(hr = video_renderer_create_video_type(type, &video_type)))
return hr;
- if (SUCCEEDED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)video_type)))
- hr = IMFTransform_SetInputType(stream->parent->mixer, stream->id, (IMFMediaType *)video_type, 0);
-
+ hr = IMFTransform_SetInputType(stream->parent->mixer, stream->id, (IMFMediaType *)video_type, 0);
IMFVideoMediaType_Release(video_type);
return hr;
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index 5ffc191667..351a6e1eda 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -3332,9 +3332,21 @@ static void test_evr(void)
hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFMediaTypeHandler_IsMediaTypeSupported(type_handler, NULL, NULL);
+ ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFMediaTypeHandler_IsMediaTypeSupported(type_handler, media_type, &media_type2);
+ ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
+
hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ media_type2 = (void *)0x1;
+ hr = IMFMediaTypeHandler_IsMediaTypeSupported(type_handler, media_type, &media_type2);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!media_type2, "Unexpected media type %p.\n", media_type2);
+
hr = IMFMediaTypeHandler_SetCurrentMediaType(type_handler, media_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
More information about the wine-cvs
mailing list