Commit 562d8c33 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

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

parent 7d28e8ec
......@@ -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)),
......
......@@ -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)
......
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