From: Derek Lesho dlesho@codeweavers.com
Unfortunately this causes a small regression in mfreadwrite tests. In an ideal world we would implement everything as in Windows, letting the media source just emit a compressed stream and having the stream reader decompress it to whatever the client is asking for. Since currently the source reader is unable to handle compressed streams, it makes sense to have winegstreamer's media source offer both PCM and floating point streams.
The patch is originally by Derek Lesho, with some changes by Giovanni Mascellani.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfreadwrite/tests/mfplat.c | 1 + dlls/winegstreamer/media_source.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 8ea4e5038f6..1967015e865 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -751,6 +751,7 @@ static void test_source_reader(void) IMFMediaType_Release(mediatype);
hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 1, &mediatype); +todo_wine ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
/* Current media type. */ diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index eb5b9e366ec..626e273780b 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -806,6 +806,34 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) goto done; } } + else if (format.major_type == WG_MAJOR_TYPE_AUDIO) + { + /* Expose at least one PCM and one floating point type for the + consumer to pick from. */ + stream_types = malloc( sizeof(IMFMediaType *) * 2 ); + + stream_types[0] = mf_media_type_from_wg_format(&format); + if (stream_types[0]) + { + stream_types[1] = mf_media_type_from_wg_format(&format); + if (stream_types[1]) + { + GUID base_subtype; + IMFMediaType_GetGUID(stream_types[1], &MF_MT_SUBTYPE, &base_subtype); + if (IsEqualGUID(&base_subtype, &MFAudioFormat_Float)) + { + IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 16); + } + else + { + IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_Float); + IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 32); + } + type_count = 2; + } + } + } else { stream_type = mf_media_type_from_wg_format(&format);
On 5/7/21 7:02 PM, Giovanni Mascellani wrote:
- else if (format.major_type == WG_MAJOR_TYPE_AUDIO)
- {
/* Expose at least one PCM and one floating point type for the
consumer to pick from. */
stream_types = malloc( sizeof(IMFMediaType *) * 2 );
stream_types[0] = mf_media_type_from_wg_format(&format);
if (stream_types[0])
{
stream_types[1] = mf_media_type_from_wg_format(&format);
if (stream_types[1])
{
GUID base_subtype;
IMFMediaType_GetGUID(stream_types[1], &MF_MT_SUBTYPE, &base_subtype);
if (IsEqualGUID(&base_subtype, &MFAudioFormat_Float))
{
IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
}
else
{
IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_Float);
IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
}
type_count = 2;
}
}
- }
I was thinking this could be done similar to video section, you can have a list of WG types to add, and let mf_media_type_from_wg_format() do the job.
{ S16LE, F32LE, } types;
for () { if (types[i] == base_type.audio.format) continue; format.audio.format = types[i]; stream_types[type_count++] = mf_media_type_from_wg_format(&format); }
That seems shorter and reuses as much as possible from conversion helpers.
hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 1, &mediatype);
+todo_wine ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
If we're going to add more formats this will never succeed, so either use larger index that will never work in practice, like 100, or remove the test.