Anton Baskanov : winegstreamer: Implement output media type enumeration in MPEG audio decoder.

Alexandre Julliard julliard at winehq.org
Mon May 2 16:02:11 CDT 2022


Module: wine
Branch: master
Commit: 562d8c338dd975706a7611a1a899ab4a8a3a2911
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=562d8c338dd975706a7611a1a899ab4a8a3a2911

Author: Anton Baskanov <baskanov at gmail.com>
Date:   Mon May  2 19:28:24 2022 +0700

winegstreamer: Implement output media type enumeration in MPEG audio decoder.

Signed-off-by: Anton Baskanov <baskanov at gmail.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/tests/mpegaudio.c         |  2 +-
 dlls/winegstreamer/quartz_transform.c | 47 +++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/dlls/quartz/tests/mpegaudio.c b/dlls/quartz/tests/mpegaudio.c
index 11280971725..19765fe5b2b 100644
--- a/dlls/quartz/tests/mpegaudio.c
+++ b/dlls/quartz/tests/mpegaudio.c
@@ -1059,7 +1059,7 @@ static void test_connect_pin(void)
         init_pcm_mt(&expect_mt, &expect_format, 1, 32000, i ? 8 : 16);
 
         hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL);
-        todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
+        ok(hr == S_OK, "Got hr %#lx.\n", hr);
         if (hr != S_OK)
             break;
         ok(!memcmp(pmt, &expect_mt, offsetof(AM_MEDIA_TYPE, cbFormat)),
diff --git a/dlls/winegstreamer/quartz_transform.c b/dlls/winegstreamer/quartz_transform.c
index 8207d24ca8d..4995177875b 100644
--- a/dlls/winegstreamer/quartz_transform.c
+++ b/dlls/winegstreamer/quartz_transform.c
@@ -36,6 +36,7 @@ struct transform_ops
 {
     HRESULT (*sink_query_accept)(struct transform *filter, const AM_MEDIA_TYPE *mt);
     HRESULT (*source_query_accept)(struct transform *filter, const AM_MEDIA_TYPE *mt);
+    HRESULT (*source_get_media_type)(struct transform *filter, unsigned int index, AM_MEDIA_TYPE *mt);
 };
 
 static inline struct transform *impl_from_strmbase_filter(struct strmbase_filter *iface)
@@ -103,9 +104,17 @@ static HRESULT transform_source_query_accept(struct strmbase_pin *pin, const AM_
     return filter->ops->source_query_accept(filter, mt);
 }
 
+static HRESULT transform_source_get_media_type(struct strmbase_pin *pin, unsigned int index, AM_MEDIA_TYPE *mt)
+{
+    struct transform *filter = impl_from_strmbase_filter(pin->filter);
+
+    return filter->ops->source_get_media_type(filter, index, mt);
+}
+
 static const struct strmbase_source_ops source_ops =
 {
     .base.pin_query_accept = transform_source_query_accept,
+    .base.pin_get_media_type = transform_source_get_media_type,
     .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
     .pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
 };
@@ -189,10 +198,48 @@ static HRESULT mpeg_audio_codec_source_query_accept(struct transform *filter, co
     return S_OK;
 }
 
+static HRESULT mpeg_audio_codec_source_get_media_type(struct transform *filter, unsigned int index, AM_MEDIA_TYPE *mt)
+{
+    const MPEG1WAVEFORMAT *input_format;
+    WAVEFORMATEX *output_format;
+
+    if (!filter->sink.pin.peer)
+        return VFW_S_NO_MORE_ITEMS;
+
+    if (index > 1)
+        return VFW_S_NO_MORE_ITEMS;
+
+    input_format = (const MPEG1WAVEFORMAT *)filter->sink.pin.mt.pbFormat;
+
+    output_format = CoTaskMemAlloc(sizeof(*output_format));
+    if (!output_format)
+        return E_OUTOFMEMORY;
+
+    memset(output_format, 0, sizeof(*output_format));
+    output_format->wFormatTag = WAVE_FORMAT_PCM;
+    output_format->nSamplesPerSec = input_format->wfx.nSamplesPerSec;
+    output_format->nChannels = input_format->wfx.nChannels;
+    output_format->wBitsPerSample = index ? 8 : 16;
+    output_format->nBlockAlign = output_format->nChannels * output_format->wBitsPerSample / 8;
+    output_format->nAvgBytesPerSec = output_format->nBlockAlign * output_format->nSamplesPerSec;
+
+    memset(mt, 0, sizeof(*mt));
+    mt->majortype = MEDIATYPE_Audio;
+    mt->subtype = MEDIASUBTYPE_PCM;
+    mt->bFixedSizeSamples = TRUE;
+    mt->lSampleSize = output_format->nBlockAlign;
+    mt->formattype = FORMAT_WaveFormatEx;
+    mt->cbFormat = sizeof(*output_format);
+    mt->pbFormat = (BYTE *)output_format;
+
+    return S_OK;
+}
+
 static const struct transform_ops mpeg_audio_codec_transform_ops =
 {
     mpeg_audio_codec_sink_query_accept,
     mpeg_audio_codec_source_query_accept,
+    mpeg_audio_codec_source_get_media_type,
 };
 
 HRESULT mpeg_audio_codec_create(IUnknown *outer, IUnknown **out)




More information about the wine-cvs mailing list