mf/evr: Implement IsMediaTypeSupported().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-10-09 13:54:40 +03:00 committed by Alexandre Julliard
parent 24c9d77cee
commit e2bcf44080
2 changed files with 61 additions and 11 deletions

View File

@ -362,12 +362,57 @@ static ULONG WINAPI video_stream_typehandler_Release(IMFMediaTypeHandler *iface)
return IMFStreamSink_Release(&stream->IMFStreamSink_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, static HRESULT WINAPI video_stream_typehandler_IsMediaTypeSupported(IMFMediaTypeHandler *iface,
IMFMediaType *in_type, IMFMediaType **out_type) 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) 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); struct video_stream *stream = impl_from_IMFMediaTypeHandler(iface);
IMFVideoMediaType *video_type; IMFVideoMediaType *video_type;
GUID subtype;
HRESULT hr; HRESULT hr;
TRACE("%p, %p.\n", iface, type); TRACE("%p, %p.\n", iface, type);
@ -405,16 +449,10 @@ static HRESULT WINAPI video_stream_typehandler_SetCurrentMediaType(IMFMediaTypeH
if (!stream->parent) if (!stream->parent)
return MF_E_STREAMSINK_REMOVED; return MF_E_STREAMSINK_REMOVED;
if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) if (FAILED(hr = video_renderer_create_video_type(type, &video_type)))
return hr; return hr;
/* Mixer expects special video media type instance. */ hr = IMFTransform_SetInputType(stream->parent->mixer, stream->id, (IMFMediaType *)video_type, 0);
if (FAILED(hr = MFCreateVideoMediaTypeFromSubtype(&subtype, &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);
IMFVideoMediaType_Release(video_type); IMFVideoMediaType_Release(video_type);
return hr; return hr;

View File

@ -3332,9 +3332,21 @@ static void test_evr(void)
hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480); hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); 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); hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); 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); hr = IMFMediaTypeHandler_SetCurrentMediaType(type_handler, media_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);