Final Fantasy XIV intro videos require media_object_GetStreamCount and property_bag_Write to return S_OK in order to not get stuck. This could be done in a separate commit but would cause a temporary regression.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 1 - dlls/winegstreamer/Makefile.in | 5 +- dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/main.c | 26 + dlls/winegstreamer/mfplat.c | 28 +- dlls/winegstreamer/quartz_parser.c | 2 +- dlls/winegstreamer/winegstreamer_classes.idl | 6 + dlls/winegstreamer/wma_decoder.c | 553 +++++++++++++++++++ dlls/wmadmod/tests/wmadmod.c | 5 - 9 files changed, 617 insertions(+), 10 deletions(-) create mode 100644 dlls/winegstreamer/wma_decoder.c
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 8ba93656a7d..0bf81e0c878 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5743,7 +5743,6 @@ static void test_wma_decoder(void) &transform, &class_id)) goto failed;
- todo_wine check_interface(transform, &IID_IMediaObject, TRUE);
/* check default media types */ diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in index 062fe57bdbb..1706effbd20 100644 --- a/dlls/winegstreamer/Makefile.in +++ b/dlls/winegstreamer/Makefile.in @@ -2,7 +2,7 @@ EXTRADEFS = -DWINE_NO_LONG_TYPES MODULE = winegstreamer.dll UNIXLIB = winegstreamer.so IMPORTLIB = winegstreamer -IMPORTS = strmbase ole32 +IMPORTS = strmbase ole32 msdmo DELAYIMPORTS = mfplat EXTRAINCL = $(GSTREAMER_CFLAGS) EXTRALIBS = $(GSTREAMER_LIBS) $(PTHREAD_LIBS) @@ -16,7 +16,8 @@ C_SRCS = \ wg_parser.c \ wm_asyncreader.c \ wm_reader.c \ - wm_syncreader.c + wm_syncreader.c \ + wma_decoder.c
IDL_SRCS = \ winegstreamer_classes.idl diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 9e1d67417d4..222bce3b2c7 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -102,6 +102,7 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; +HRESULT wma_decoder_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool wm); bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format); diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index ac9a3201792..260dd208e2f 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -25,7 +25,9 @@ #include "gst_private.h" #include "winternl.h" #include "rpcproxy.h" +#include "dmoreg.h" #include "gst_guids.h" +#include "wmcodecdsp.h"
static unixlib_handle_t unix_handle;
@@ -339,6 +341,7 @@ static struct class_factory avi_splitter_cf = {{&class_factory_vtbl}, avi_splitt static struct class_factory decodebin_parser_cf = {{&class_factory_vtbl}, decodebin_parser_create}; static struct class_factory mpeg_splitter_cf = {{&class_factory_vtbl}, mpeg_splitter_create}; static struct class_factory wave_parser_cf = {{&class_factory_vtbl}, wave_parser_create}; +static struct class_factory wma_decoder_cf = {{&class_factory_vtbl}, wma_decoder_create};
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) { @@ -361,6 +364,8 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) factory = &mpeg_splitter_cf; else if (IsEqualGUID(clsid, &CLSID_WAVEParser)) factory = &wave_parser_cf; + else if (IsEqualGUID(clsid, &CLSID_WMADecMediaObject)) + factory = &wma_decoder_cf; else { FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid)); @@ -522,6 +527,19 @@ static const REGFILTER2 reg_decodebin_parser =
HRESULT WINAPI DllRegisterServer(void) { + DMO_PARTIAL_MEDIATYPE wma_decoder_output[2] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT}, + }; + DMO_PARTIAL_MEDIATYPE wma_decoder_input[4] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_MSAUDIO1}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO2}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO3}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO_LOSSLESS}, + }; + IFilterMapper2 *mapper; HRESULT hr;
@@ -543,6 +561,10 @@ HRESULT WINAPI DllRegisterServer(void)
IFilterMapper2_Release(mapper);
+ if (FAILED(hr = DMORegister(L"WMA Decoder DMO", &CLSID_WMADecMediaObject, &DMOCATEGORY_AUDIO_DECODER, + 0, ARRAY_SIZE(wma_decoder_input), wma_decoder_input, ARRAY_SIZE(wma_decoder_output), wma_decoder_output))) + return hr; + return mfplat_DllRegisterServer(); }
@@ -566,5 +588,9 @@ HRESULT WINAPI DllUnregisterServer(void) IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_WAVEParser);
IFilterMapper2_Release(mapper); + + if (FAILED(hr = DMOUnregister(&CLSID_WMADecMediaObject, &DMOCATEGORY_AUDIO_DECODER))) + return hr; + return S_OK; } diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 5404728ba83..6a58f444204 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -21,6 +21,7 @@
#include "ks.h" #include "ksmedia.h" +#include "wmcodecdsp.h" #include "initguid.h" #include "mfapi.h"
@@ -442,6 +443,20 @@ static const GUID *audio_converter_supported_types[] = &MFAudioFormat_Float, };
+static WCHAR wma_decoderW[] = L"WMAudio Decoder MFT"; +static const GUID *wma_decoder_input_types[] = +{ + &MEDIASUBTYPE_MSAUDIO1, + &MFAudioFormat_WMAudioV8, + &MFAudioFormat_WMAudioV9, + &MFAudioFormat_WMAudio_Lossless, +}; +static const GUID *wma_decoder_output_types[] = +{ + &MFAudioFormat_PCM, + &MFAudioFormat_Float, +}; + static const struct mft { const GUID *clsid; @@ -467,13 +482,24 @@ mfts[] = ARRAY_SIZE(audio_converter_supported_types), audio_converter_supported_types, }, + { + &CLSID_WMADecMediaObject, + &MFT_CATEGORY_AUDIO_DECODER, + wma_decoderW, + MFT_ENUM_FLAG_SYNCMFT, + &MFMediaType_Audio, + ARRAY_SIZE(wma_decoder_input_types), + wma_decoder_input_types, + ARRAY_SIZE(wma_decoder_output_types), + wma_decoder_output_types, + }, };
HRESULT mfplat_DllRegisterServer(void) { unsigned int i, j; HRESULT hr; - MFT_REGISTER_TYPE_INFO input_types[2], output_types[2]; + MFT_REGISTER_TYPE_INFO input_types[4], output_types[2];
for (i = 0; i < ARRAY_SIZE(mfts); i++) { diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 8532fc1af8b..e8d56d54785 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -29,8 +29,8 @@ #include "dvdmedia.h" #include "mmreg.h" #include "ks.h" -#include "initguid.h" #include "wmcodecdsp.h" +#include "initguid.h" #include "ksmedia.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz); diff --git a/dlls/winegstreamer/winegstreamer_classes.idl b/dlls/winegstreamer/winegstreamer_classes.idl index 072ec90eea4..90dc1dc839b 100644 --- a/dlls/winegstreamer/winegstreamer_classes.idl +++ b/dlls/winegstreamer/winegstreamer_classes.idl @@ -67,3 +67,9 @@ coclass GStreamerByteStreamHandler {} uuid(6a170414-aad9-4693-b806-3a0c47c570d6) ] coclass WINEAudioConverter { } + +[ + threading(both), + uuid(2eeb4adf-4578-4d10-bca7-bb955f56320a) +] +coclass CWMADecMediaObject {}; diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c new file mode 100644 index 00000000000..f034c34395e --- /dev/null +++ b/dlls/winegstreamer/wma_decoder.c @@ -0,0 +1,553 @@ +/* WMA Decoder DMO / MF Transform + * + * Copyright 2022 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "gst_private.h" + +#include "mfapi.h" +#include "mferror.h" +#include "mfobjects.h" +#include "mftransform.h" +#include "wmcodecdsp.h" + +#include "wine/debug.h" +#include "wine/heap.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wmadec); + +struct wma_decoder +{ + IUnknown IUnknown_inner; + IMFTransform IMFTransform_iface; + IMediaObject IMediaObject_iface; + IPropertyBag IPropertyBag_iface; + IUnknown *outer; + LONG refcount; +}; + +static inline struct wma_decoder *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IUnknown_inner); +} + +static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown)) + *out = &decoder->IUnknown_inner; + else if (IsEqualGUID(iid, &IID_IMFTransform)) + *out = &decoder->IMFTransform_iface; + else if (IsEqualGUID(iid, &IID_IMediaObject)) + *out = &decoder->IMediaObject_iface; + else if (IsEqualIID(iid, &IID_IPropertyBag)) + *out = &decoder->IPropertyBag_iface; + else + { + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI unknown_AddRef(IUnknown *iface) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + ULONG refcount = InterlockedIncrement(&decoder->refcount); + + TRACE("iface %p increasing refcount to %u.\n", decoder, refcount); + + return refcount; +} + +static ULONG WINAPI unknown_Release(IUnknown *iface) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + ULONG refcount = InterlockedDecrement(&decoder->refcount); + + TRACE("iface %p decreasing refcount to %u.\n", decoder, refcount); + + if (!refcount) + free(decoder); + + return refcount; +} + +static const IUnknownVtbl unknown_vtbl = +{ + unknown_QueryInterface, + unknown_AddRef, + unknown_Release, +}; + +static struct wma_decoder *impl_from_IMFTransform(IMFTransform *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IMFTransform_iface); +} + +static HRESULT WINAPI transform_QueryInterface(IMFTransform *iface, REFIID iid, void **out) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_QueryInterface(decoder->outer, iid, out); +} + +static ULONG WINAPI transform_AddRef(IMFTransform *iface) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_AddRef(decoder->outer); +} + +static ULONG WINAPI transform_Release(IMFTransform *iface) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_Release(decoder->outer); +} + +static HRESULT WINAPI transform_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, + DWORD *input_maximum, DWORD *output_minimum, DWORD *output_maximum) +{ + FIXME("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p stub!\n", + iface, input_minimum, input_maximum, output_minimum, output_maximum); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs) +{ + FIXME("iface %p, inputs %p, outputs %p stub!\n", iface, inputs, outputs); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs, + DWORD output_size, DWORD *outputs) +{ + FIXME("iface %p, input_size %u, inputs %p, output_size %u, outputs %p stub!\n", iface, + input_size, inputs, output_size, outputs); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) +{ + FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) +{ + FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) +{ + FIXME("iface %p, attributes %p stub!\n", iface, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + FIXME("iface %p, id %u, attributes %p stub!\n", iface, id, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + FIXME("iface %p, id %u, attributes %p stub!\n", iface, id, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_DeleteInputStream(IMFTransform *iface, DWORD id) +{ + FIXME("iface %p, id %u stub!\n", iface, id); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids) +{ + FIXME("iface %p, streams %u, ids %p stub!\n", iface, streams, ids); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + FIXME("iface %p, id %u, index %u, type %p stub!\n", iface, id, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + FIXME("iface %p, id %u, index %u, type %p stub!\n", iface, id, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + FIXME("iface %p, id %u, type %p stub!\n", iface, id, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + FIXME("iface %p, id %u, type %p stub!\n", iface, id, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags) +{ + FIXME("iface %p, id %u, flags %p stub!\n", iface, id, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStatus(IMFTransform *iface, DWORD *flags) +{ + FIXME("iface %p, flags %p stub!\n", iface, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper) +{ + FIXME("iface %p, lower %s, upper %s stub!\n", iface, wine_dbgstr_longlong(lower), + wine_dbgstr_longlong(upper)); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event) +{ + FIXME("iface %p, id %u, event %p stub!\n", iface, id, event); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param) +{ + FIXME("iface %p, message %#x, param %p stub!\n", iface, message, (void *)param); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) +{ + FIXME("iface %p, id %u, sample %p, flags %#x stub!\n", iface, id, sample, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, + MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) +{ + FIXME("iface %p, flags %#x, count %u, samples %p, status %p stub!\n", iface, flags, count, samples, status); + return E_NOTIMPL; +} + +static const IMFTransformVtbl transform_vtbl = +{ + transform_QueryInterface, + transform_AddRef, + transform_Release, + transform_GetStreamLimits, + transform_GetStreamCount, + transform_GetStreamIDs, + transform_GetInputStreamInfo, + transform_GetOutputStreamInfo, + transform_GetAttributes, + transform_GetInputStreamAttributes, + transform_GetOutputStreamAttributes, + transform_DeleteInputStream, + transform_AddInputStreams, + transform_GetInputAvailableType, + transform_GetOutputAvailableType, + transform_SetInputType, + transform_SetOutputType, + transform_GetInputCurrentType, + transform_GetOutputCurrentType, + transform_GetInputStatus, + transform_GetOutputStatus, + transform_SetOutputBounds, + transform_ProcessEvent, + transform_ProcessMessage, + transform_ProcessInput, + transform_ProcessOutput, +}; + +static inline struct wma_decoder *impl_from_IMediaObject(IMediaObject *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IMediaObject_iface); +} + +static HRESULT WINAPI media_object_QueryInterface(IMediaObject *iface, REFIID iid, void **obj) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_QueryInterface(decoder->outer, iid, obj); +} + +static ULONG WINAPI media_object_AddRef(IMediaObject *iface) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_AddRef(decoder->outer); +} + +static ULONG WINAPI media_object_Release(IMediaObject *iface) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_Release(decoder->outer); +} + +static HRESULT WINAPI media_object_GetStreamCount(IMediaObject *iface, DWORD *input, DWORD *output) +{ + FIXME("iface %p, input %p, output %p semi-stub!\n", iface, input, output); + *input = *output = 1; + return S_OK; +} + +static HRESULT WINAPI media_object_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index, + DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type_index %u, type %p stub!\n", iface, index, type_index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index, + DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type_index %u, type %p stub!\n", iface, index, type_index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index, + const DMO_MEDIA_TYPE *type, DWORD flags) +{ + FIXME("iface %p, index %u, type %p, flags %#x stub!\n", iface, index, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD index, + const DMO_MEDIA_TYPE *type, DWORD flags) +{ + FIXME("iface %p, index %u, type %p, flags %#x stub!\n", iface, index, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type %p stub!\n", iface, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type %p stub!\n", iface, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, + DWORD *lookahead, DWORD *alignment) +{ + FIXME("iface %p, index %u, size %p, lookahead %p, alignment %p stub!\n", iface, index, size, + lookahead, alignment); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) +{ + FIXME("iface %p, index %u, size %p, alignment %p stub!\n", iface, index, size, alignment); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME *latency) +{ + FIXME("iface %p, index %u, latency %p stub!\n", iface, index, latency); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME latency) +{ + FIXME("iface %p, index %u, latency %s stub!\n", iface, index, wine_dbgstr_longlong(latency)); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Flush(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Discontinuity(IMediaObject *iface, DWORD index) +{ + FIXME("iface %p, index %u stub!\n", iface, index); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_AllocateStreamingResources(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_FreeStreamingResources(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputStatus(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_ProcessInput(IMediaObject *iface, DWORD index, + IMediaBuffer *buffer, DWORD flags, REFERENCE_TIME timestamp, REFERENCE_TIME timelength) +{ + FIXME("iface %p, index %u, buffer %p, flags %#x, timestamp %s, timelength %s stub!\n", iface, + index, buffer, flags, wine_dbgstr_longlong(timestamp), wine_dbgstr_longlong(timelength)); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_ProcessOutput(IMediaObject *iface, DWORD flags, DWORD count, + DMO_OUTPUT_DATA_BUFFER *buffers, DWORD *status) +{ + FIXME("iface %p, flags %#x, count %u, buffers %p, status %p stub!\n", iface, flags, count, buffers, status); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Lock(IMediaObject *iface, LONG lock) +{ + FIXME("iface %p, lock %d stub!\n", iface, lock); + return E_NOTIMPL; +} + +static const IMediaObjectVtbl media_object_vtbl = +{ + media_object_QueryInterface, + media_object_AddRef, + media_object_Release, + media_object_GetStreamCount, + media_object_GetInputStreamInfo, + media_object_GetOutputStreamInfo, + media_object_GetInputType, + media_object_GetOutputType, + media_object_SetInputType, + media_object_SetOutputType, + media_object_GetInputCurrentType, + media_object_GetOutputCurrentType, + media_object_GetInputSizeInfo, + media_object_GetOutputSizeInfo, + media_object_GetInputMaxLatency, + media_object_SetInputMaxLatency, + media_object_Flush, + media_object_Discontinuity, + media_object_AllocateStreamingResources, + media_object_FreeStreamingResources, + media_object_GetInputStatus, + media_object_ProcessInput, + media_object_ProcessOutput, + media_object_Lock, +}; + +static inline struct wma_decoder *impl_from_IPropertyBag(IPropertyBag *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IPropertyBag_iface); +} + +static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_QueryInterface(filter->outer, iid, out); +} + +static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_AddRef(filter->outer); +} + +static ULONG WINAPI property_bag_Release(IPropertyBag *iface) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_Release(filter->outer); +} + +static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value, + IErrorLog *error_log) +{ + FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface, debugstr_w(prop_name), value, error_log); + return E_NOTIMPL; +} + +static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value) +{ + FIXME("iface %p, prop_name %s, value %p stub!\n", iface, debugstr_w(prop_name), value); + return S_OK; +} + +static const IPropertyBagVtbl property_bag_vtbl = +{ + property_bag_QueryInterface, + property_bag_AddRef, + property_bag_Release, + property_bag_Read, + property_bag_Write, +}; + +HRESULT wma_decoder_create(IUnknown *outer, IUnknown **out) +{ + struct wma_decoder *decoder; + + TRACE("outer %p, out %p.\n", outer, out); + + if (!(decoder = calloc(1, sizeof(*decoder)))) + return E_OUTOFMEMORY; + + decoder->IUnknown_inner.lpVtbl = &unknown_vtbl; + decoder->IMFTransform_iface.lpVtbl = &transform_vtbl; + decoder->IMediaObject_iface.lpVtbl = &media_object_vtbl; + decoder->IPropertyBag_iface.lpVtbl = &property_bag_vtbl; + decoder->refcount = 1; + decoder->outer = outer ? outer : &decoder->IUnknown_inner; + + *out = &decoder->IUnknown_inner; + TRACE("Created decoder %p\n", *out); + return S_OK; +} diff --git a/dlls/wmadmod/tests/wmadmod.c b/dlls/wmadmod/tests/wmadmod.c index e95e297eaca..b49b609dac3 100644 --- a/dlls/wmadmod/tests/wmadmod.c +++ b/dlls/wmadmod/tests/wmadmod.c @@ -52,11 +52,8 @@ static void test_DMOGetTypes(void)
hr = DMOGetTypes( &CLSID_CWMADecMediaObject, ARRAY_SIZE(input), &input_count, input, ARRAY_SIZE(output), &output_count, output ); - todo_wine ok( hr == S_OK, "DMOGetTypes returned %#lx\n", hr ); - todo_wine ok( input_count == ARRAY_SIZE(expect_input), "got input_count %lu\n", input_count ); - todo_wine ok( output_count == ARRAY_SIZE(expect_output), "got output_count %lu\n", output_count );
for (i = 0; i < input_count; ++i) @@ -135,9 +132,7 @@ static void test_interfaces(void)
hr = CoCreateInstance( &CLSID_CWMADecMediaObject, &outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unknown ); - todo_wine ok( hr == S_OK, "CoCreateInstance returned %#lx\n", hr ); - if (FAILED(hr)) return; hr = IUnknown_QueryInterface( unknown, &IID_IMFTransform, (void **)&transform ); ok( hr == S_OK, "QueryInterface returned %#lx\n", hr ); hr = IUnknown_QueryInterface( unknown, &IID_IMediaObject, (void **)&media_object );
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 5 --- dlls/winegstreamer/wma_decoder.c | 59 ++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 0bf81e0c878..6755853f995 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5790,22 +5790,18 @@ static void test_wma_decoder(void) hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#x\n", hr); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#x.\n", hr); init_media_type(media_type, input_type_desc, 1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#x.\n", hr); init_media_type(media_type, input_type_desc, 2); for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) { hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#x.\n", hr); init_media_type(media_type, input_type_desc, i + 1); } hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); @@ -5893,7 +5889,6 @@ static void test_wma_decoder(void) hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 4003); ok(hr == S_OK, "SetUINT32 returned %#x\n", hr); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned %#x.\n", hr);
hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index f034c34395e..12ac9cee8c3 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -30,6 +30,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(wmadec);
+static const GUID *wma_decoder_input_types[] = +{ + &MEDIASUBTYPE_MSAUDIO1, + &MFAudioFormat_WMAudioV8, + &MFAudioFormat_WMAudioV9, + &MFAudioFormat_WMAudio_Lossless, +}; + struct wma_decoder { IUnknown IUnknown_inner; @@ -38,6 +46,7 @@ struct wma_decoder IPropertyBag IPropertyBag_iface; IUnknown *outer; LONG refcount; + IMFMediaType *input_type; };
static inline struct wma_decoder *impl_from_IUnknown(IUnknown *iface) @@ -88,7 +97,11 @@ static ULONG WINAPI unknown_Release(IUnknown *iface) TRACE("iface %p decreasing refcount to %u.\n", decoder, refcount);
if (!refcount) + { + if (decoder->input_type) + IMFMediaType_Release(decoder->input_type); free(decoder); + }
return refcount; } @@ -203,8 +216,50 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) { - FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); - return E_NOTIMPL; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + MF_ATTRIBUTE_TYPE item_type; + GUID major, subtype; + HRESULT hr; + ULONG i; + + TRACE("iface %p, id %u, type %p, flags %#x.\n", iface, id, type, flags); + + if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || + FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return hr; + + if (!IsEqualGUID(&major, &MFMediaType_Audio)) + return MF_E_INVALIDMEDIATYPE; + + for (i = 0; i < ARRAY_SIZE(wma_decoder_input_types); ++i) + if (IsEqualGUID(&subtype, wma_decoder_input_types[i])) + break; + if (i == ARRAY_SIZE(wma_decoder_input_types)) + return MF_E_INVALIDMEDIATYPE; + + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_USER_DATA, &item_type)) || + item_type != MF_ATTRIBUTE_BLOB) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + + if (!decoder->input_type && FAILED(hr = MFCreateMediaType(&decoder->input_type))) + return hr; + + if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->input_type))) + { + IMFMediaType_Release(decoder->input_type); + decoder->input_type = NULL; + } + + return hr; }
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 3 -- dlls/winegstreamer/wma_decoder.c | 75 +++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 6755853f995..683de3e5b3e 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5754,7 +5754,6 @@ static void test_wma_decoder(void) todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputAvailableType returned %#x\n", hr);
i = -1; @@ -5825,9 +5824,7 @@ static void test_wma_decoder(void) ok(ret == 0, "Release returned %u\n", ret); winetest_pop_context(); } - todo_wine ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#x\n", hr); - todo_wine ok(i == 2, "%u output media types\n", i);
/* check required output media type attributes */ diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index 12ac9cee8c3..a99df59e8a0 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -37,6 +37,11 @@ static const GUID *wma_decoder_input_types[] = &MFAudioFormat_WMAudioV9, &MFAudioFormat_WMAudio_Lossless, }; +static const GUID *wma_decoder_output_types[] = +{ + &MFAudioFormat_Float, + &MFAudioFormat_PCM, +};
struct wma_decoder { @@ -210,8 +215,74 @@ static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, IMFMediaType **type) { - FIXME("iface %p, id %u, index %u, type %p stub!\n", iface, id, index, type); - return E_NOTIMPL; + UINT32 channel_count, sample_size, sample_rate, block_alignment; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + IMFMediaType *media_type; + const GUID *output_type; + HRESULT hr; + + TRACE("iface %p, id %u, index %u, type %p.\n", iface, id, index, type); + + if (!decoder->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + *type = NULL; + + if (index >= ARRAY_SIZE(wma_decoder_output_types)) + return MF_E_NO_MORE_TYPES; + output_type = wma_decoder_output_types[index]; + + if (FAILED(hr = MFCreateMediaType(&media_type))) + return hr; + + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio))) + goto done; + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, output_type))) + goto done; + + if (IsEqualGUID(output_type, &MFAudioFormat_Float)) + sample_size = 32; + else if (IsEqualGUID(output_type, &MFAudioFormat_PCM)) + sample_size = 16; + else + { + FIXME("Subtype %s not implemented!\n", debugstr_guid(output_type)); + hr = E_NOTIMPL; + goto done; + } + + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) + goto done; + + if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_NUM_CHANNELS, &channel_count))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, channel_count))) + goto done; + + if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &sample_rate))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, sample_rate))) + goto done; + + block_alignment = sample_size * channel_count / 8; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, block_alignment))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, sample_rate * block_alignment))) + goto done; + + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1))) + goto done; + +done: + if (SUCCEEDED(hr)) + IMFMediaType_AddRef((*type = media_type)); + + IMFMediaType_Release(media_type); + return hr; }
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 6 --- dlls/winegstreamer/wma_decoder.c | 77 +++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 683de3e5b3e..96d8b972de7 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5779,7 +5779,6 @@ static void test_wma_decoder(void) ok(hr == S_OK, "MFCreateMediaType returned %#x\n", hr); init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "SetOutputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); @@ -5832,22 +5831,18 @@ static void test_wma_decoder(void) hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#x\n", hr); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, 1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, 2); for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) { hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, i + 1); } hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetOutputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); @@ -5894,7 +5889,6 @@ static void test_wma_decoder(void)
init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index a99df59e8a0..4fae787679d 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -52,6 +52,7 @@ struct wma_decoder IUnknown *outer; LONG refcount; IMFMediaType *input_type; + IMFMediaType *output_type; };
static inline struct wma_decoder *impl_from_IUnknown(IUnknown *iface) @@ -105,6 +106,8 @@ static ULONG WINAPI unknown_Release(IUnknown *iface) { if (decoder->input_type) IMFMediaType_Release(decoder->input_type); + if (decoder->output_type) + IMFMediaType_Release(decoder->output_type); free(decoder); }
@@ -324,6 +327,12 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM if (!decoder->input_type && FAILED(hr = MFCreateMediaType(&decoder->input_type))) return hr;
+ if (decoder->output_type) + { + IMFMediaType_Release(decoder->output_type); + decoder->output_type = NULL; + } + if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->input_type))) { IMFMediaType_Release(decoder->input_type); @@ -335,8 +344,72 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) { - FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); - return E_NOTIMPL; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + MF_ATTRIBUTE_TYPE item_type; + ULONG i, sample_size; + GUID major, subtype; + HRESULT hr; + + TRACE("iface %p, id %u, type %p, flags %#x.\n", iface, id, type, flags); + + if (!decoder->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || + FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return hr; + + if (!IsEqualGUID(&major, &MFMediaType_Audio)) + return MF_E_INVALIDMEDIATYPE; + + for (i = 0; i < ARRAY_SIZE(wma_decoder_output_types); ++i) + if (IsEqualGUID(&subtype, wma_decoder_output_types[i])) + break; + if (i == ARRAY_SIZE(wma_decoder_output_types)) + return MF_E_INVALIDMEDIATYPE; + + if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) + sample_size = 32; + else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) + sample_size = 16; + else + { + FIXME("Subtype %s not implemented!\n", debugstr_guid(&subtype)); + hr = E_NOTIMPL; + return hr; + } + + if (FAILED(IMFMediaType_SetUINT32(decoder->input_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) + return MF_E_INVALIDMEDIATYPE; + + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + + if (!decoder->output_type && FAILED(hr = MFCreateMediaType(&decoder->output_type))) + return hr; + + if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->output_type))) + goto failed; + + return S_OK; + +failed: + IMFMediaType_Release(decoder->output_type); + decoder->output_type = NULL; + return hr; }
static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
On 2/2/22 06:28, Rémi Bernon wrote:
- if (IsEqualGUID(&subtype, &MFAudioFormat_Float))
sample_size = 32;
- else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM))
sample_size = 16;
- else
- {
FIXME("Subtype %s not implemented!\n", debugstr_guid(&subtype));
hr = E_NOTIMPL;
return hr;
- }
This seems a bit redundant :-)
- if (FAILED(IMFMediaType_SetUINT32(decoder->input_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size)))
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
- if (!decoder->output_type && FAILED(hr = MFCreateMediaType(&decoder->output_type)))
return hr;
- if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->output_type)))
goto failed;
This also seems redundant, being the only user of this label.
On 2/2/22 23:14, Zebediah Figura wrote:
On 2/2/22 06:28, Rémi Bernon wrote:
+ if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) + sample_size = 32; + else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) + sample_size = 16; + else + { + FIXME("Subtype %s not implemented!\n", debugstr_guid(&subtype)); + hr = E_NOTIMPL; + return hr; + }
This seems a bit redundant :-)
A bit indeed, though one could add a new element to wma_decoder_output_types and miss this corner case.
+ if (FAILED(IMFMediaType_SetUINT32(decoder->input_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) + return MF_E_INVALIDMEDIATYPE;
+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE;
+ if (!decoder->output_type && FAILED(hr = MFCreateMediaType(&decoder->output_type))) + return hr;
+ if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->output_type))) + goto failed;
This also seems redundant, being the only user of this label.
There's going to be a second failure path later when it will need to create the unixlib object. Although both could probably be combined, it felt nicer to have two separate ifs + goto failed.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 10 ---------- dlls/winegstreamer/wma_decoder.c | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 96d8b972de7..72910769633 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5751,7 +5751,6 @@ static void test_wma_decoder(void) todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputAvailableType returned %#x\n", hr); @@ -5808,7 +5807,6 @@ static void test_wma_decoder(void) todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr);
/* check new output media types */ @@ -5864,13 +5862,10 @@ static void test_wma_decoder(void)
memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == S_OK, "GetOutputStreamInfo returned %#x\n", hr); - todo_wine ok(output_info.dwFlags == 0, "got dwFlags %#x\n", output_info.dwFlags); todo_wine ok(output_info.cbSize == 0, "got cbSize %#x\n", output_info.cbSize); - todo_wine ok(output_info.cbAlignment == 1, "got cbAlignment %#x\n", output_info.cbAlignment);
/* MF_MT_AUDIO_AVG_BYTES_PER_SECOND isn't required by SetInputType, but is needed for the transform to work */ @@ -5884,7 +5879,6 @@ static void test_wma_decoder(void) ok(hr == S_OK, "SetInputType returned %#x.\n", hr);
hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr);
init_media_type(media_type, output_type_desc, -1); @@ -5895,13 +5889,9 @@ static void test_wma_decoder(void)
memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == S_OK, "GetOutputStreamInfo returned %#x\n", hr); - todo_wine ok(output_info.dwFlags == 0, "got dwFlags %#x\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize == sizeof(wma_decoded_data), "got cbSize %#x\n", output_info.cbSize); - todo_wine ok(output_info.cbAlignment == 1, "got cbAlignment %#x\n", output_info.cbAlignment);
ret = IMFTransform_Release(transform); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index 4fae787679d..dbccd659ac0 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -174,8 +174,25 @@ static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id
static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) { - FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); - return E_NOTIMPL; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + UINT32 channel_count, block_alignment; + HRESULT hr; + + TRACE("iface %p, id %u, info %p.\n", iface, id, info); + + if (!decoder->input_type || !decoder->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFMediaType_GetUINT32(decoder->output_type, &MF_MT_AUDIO_NUM_CHANNELS, &channel_count))) + return hr; + if (FAILED(hr = IMFMediaType_GetUINT32(decoder->output_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment))) + return hr; + + info->dwFlags = 0; + info->cbSize = 1024 * block_alignment * channel_count; + info->cbAlignment = 1; + + return S_OK; }
static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 8 -------- dlls/winegstreamer/wma_decoder.c | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 72910769633..ebf42bcad9c 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5748,7 +5748,6 @@ static void test_wma_decoder(void) /* check default media types */
hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr); @@ -5804,7 +5803,6 @@ static void test_wma_decoder(void) ok(ret == 0, "Release returned %u\n", ret);
hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#x\n", hr); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#x\n", hr); @@ -5847,17 +5845,11 @@ static void test_wma_decoder(void)
memset(&input_info, 0xcd, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - todo_wine ok(hr == S_OK, "GetInputStreamInfo returned %#x\n", hr); - todo_wine ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); - todo_wine ok(input_info.dwFlags == 0, "got dwFlags %#x\n", input_info.dwFlags); - todo_wine ok(input_info.cbSize == wma_block_size, "got cbSize %u\n", input_info.cbSize); - todo_wine ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#x\n", input_info.cbMaxLookahead); - todo_wine ok(input_info.cbAlignment == 1, "got cbAlignment %#x\n", input_info.cbAlignment);
memset(&output_info, 0xcd, sizeof(output_info)); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index dbccd659ac0..a6fdbf27724 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -168,8 +168,25 @@ static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_si
static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) { - FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); - return E_NOTIMPL; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + UINT32 block_alignment; + HRESULT hr; + + TRACE("iface %p, id %u, info %p.\n", iface, id, info); + + if (!decoder->input_type || !decoder->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment))) + return hr; + + info->hnsMaxLatency = 0; + info->dwFlags = 0; + info->cbSize = block_alignment; + info->cbMaxLookahead = 0; + info->cbAlignment = 1; + + return S_OK; }
static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com