mfplat: Consider first type entry when returning major type for stream descriptors.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-11-02 15:27:48 +03:00 committed by Alexandre Julliard
parent 7d26ac0119
commit 74b10b2a4c
2 changed files with 38 additions and 4 deletions

View File

@ -2003,10 +2003,8 @@ static HRESULT WINAPI mediatype_handler_GetMajorType(IMFMediaTypeHandler *iface,
TRACE("%p, %p.\n", iface, type);
EnterCriticalSection(&stream_desc->attributes.cs);
if (stream_desc->current_type)
hr = IMFMediaType_GetGUID(stream_desc->current_type, &MF_MT_MAJOR_TYPE, type);
else
hr = MF_E_ATTRIBUTENOTFOUND;
hr = IMFMediaType_GetGUID(stream_desc->current_type ? stream_desc->current_type :
stream_desc->media_types[0], &MF_MT_MAJOR_TYPE, type);
LeaveCriticalSection(&stream_desc->attributes.cs);
return hr;

View File

@ -3679,6 +3679,42 @@ static void test_stream_descriptor(void)
IMFMediaTypeHandler_Release(type_handler);
IMFStreamDescriptor_Release(stream_desc);
/* Major type is returned for first entry. */
hr = MFCreateMediaType(&media_types[0]);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = MFCreateMediaType(&media_types[1]);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_types[0], &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_types[1], &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = MFCreateStreamDescriptor(0, 2, media_types, &stream_desc);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFStreamDescriptor_GetMediaTypeHandler(stream_desc, &type_handler);
ok(hr == S_OK, "Failed to get type handler, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMajorType(type_handler, &major_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(IsEqualGUID(&major_type, &MFMediaType_Audio), "Unexpected major type %s.\n", wine_dbgstr_guid(&major_type));
hr = IMFMediaType_SetGUID(media_types[0], &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_types[1], &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMajorType(type_handler, &major_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(IsEqualGUID(&major_type, &MFMediaType_Video), "Unexpected major type %s.\n", wine_dbgstr_guid(&major_type));
IMFMediaType_Release(media_types[0]);
IMFMediaType_Release(media_types[1]);
IMFMediaTypeHandler_Release(type_handler);
IMFStreamDescriptor_Release(stream_desc);
}
static void test_MFCalculateImageSize(void)