Commit b0ecfc96 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Factor the creation of the first stream media type.

parent 82b1cc3c
......@@ -925,6 +925,10 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
wg_parser_stream_get_preferred_format(stream->wg_stream, &format);
if (!(stream_types[0] = mf_media_type_from_wg_format(&format)))
return MF_E_INVALIDMEDIATYPE;
type_count = 1;
if (format.major_type == WG_MAJOR_TYPE_VIDEO)
{
/* Try to prefer YUV formats over RGB ones. Most decoders output in the
......@@ -937,20 +941,9 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
WG_VIDEO_FORMAT_YUY2,
WG_VIDEO_FORMAT_I420,
};
IMFMediaType *base_type = mf_media_type_from_wg_format(&format);
GUID base_subtype;
if (!base_type)
{
hr = MF_E_INVALIDMEDIATYPE;
goto done;
}
IMFMediaType_GetGUID(base_type, &MF_MT_SUBTYPE, &base_subtype);
stream_types[0] = base_type;
type_count = 1;
IMFMediaType_GetGUID(stream_types[0], &MF_MT_SUBTYPE, &base_subtype);
for (i = 0; i < ARRAY_SIZE(video_formats); ++i)
{
......@@ -990,9 +983,6 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
WG_AUDIO_FORMAT_F32LE,
};
if ((stream_types[0] = mf_media_type_from_wg_format(&format)))
type_count = 1;
for (i = 0; i < ARRAY_SIZE(audio_types); i++)
{
struct wg_format new_format;
......@@ -1004,20 +994,9 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
type_count++;
}
}
else
{
if ((stream_types[0] = mf_media_type_from_wg_format(&format)))
type_count = 1;
}
assert(type_count <= ARRAY_SIZE(stream_types));
if (!type_count)
{
ERR("Failed to establish an IMFMediaType from any of the possible stream caps!\n");
return E_FAIL;
}
if (FAILED(hr = MFCreateStreamDescriptor(stream->stream_id, type_count, stream_types, &stream->descriptor)))
goto done;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment