Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mp3dmod/mp3dmod.c | 6 ++++-- dlls/mp3dmod/tests/mp3dmod.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index c9da2b8a354..1f3b0126b8e 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -136,9 +136,11 @@ static ULONG WINAPI MediaObject_Release(IMediaObject *iface)
static HRESULT WINAPI MediaObject_GetStreamCount(IMediaObject *iface, DWORD *input, DWORD *output) { - FIXME("(%p)->(%p, %p) stub!\n", iface, input, output); + TRACE("iface %p, input %p, output %p.\n", iface, input, output);
- return E_NOTIMPL; + *input = *output = 1; + + return S_OK; }
static HRESULT WINAPI MediaObject_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 75fd0e2c407..33cc6f3754d 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -286,6 +286,24 @@ static void test_aggregation(void) ok(hr == E_NOINTERFACE, "got %#x\n", hr); }
+static void test_stream_info(void) +{ + DWORD input_count, output_count, flags; + IMediaObject *dmo; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_CMP3DecMediaObject, NULL, CLSCTX_INPROC_SERVER, + &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaObject_GetStreamCount(dmo, &input_count, &output_count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(input_count == 1, "Got input count %u.\n", input_count); + ok(output_count == 1, "Got output count %u.\n", output_count); + + IMediaObject_Release(dmo); +} + START_TEST(mp3dmod) { IMediaObject *dmo; @@ -304,6 +322,7 @@ START_TEST(mp3dmod)
test_convert(); test_aggregation(); + test_stream_info();
CoUninitialize(); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mp3dmod/mp3dmod.c | 6 ++++-- dlls/mp3dmod/tests/mp3dmod.c | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 1f3b0126b8e..8afc128d807 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -145,9 +145,11 @@ static HRESULT WINAPI MediaObject_GetStreamCount(IMediaObject *iface, DWORD *inp
static HRESULT WINAPI MediaObject_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) { - FIXME("(%p)->(%d, %p) stub!\n", iface, index, flags); + TRACE("iface %p, index %u, flags %p.\n", iface, index, flags);
- return E_NOTIMPL; + *flags = 0; + + return S_OK; }
static HRESULT WINAPI MediaObject_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 33cc6f3754d..713623b2448 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -301,6 +301,11 @@ static void test_stream_info(void) ok(input_count == 1, "Got input count %u.\n", input_count); ok(output_count == 1, "Got output count %u.\n", output_count);
+ flags = 0xdeadbeef; + hr = IMediaObject_GetInputStreamInfo(dmo, 0, &flags); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!flags, "Got flags %#x.\n", flags); + IMediaObject_Release(dmo); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mp3dmod/mp3dmod.c | 6 ++++-- dlls/mp3dmod/tests/mp3dmod.c | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 8afc128d807..9e86bcc31d1 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -154,9 +154,11 @@ static HRESULT WINAPI MediaObject_GetInputStreamInfo(IMediaObject *iface, DWORD
static HRESULT WINAPI MediaObject_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) { - FIXME("(%p)->(%d, %p) stub!\n", iface, index, flags); + TRACE("iface %p, index %u, flags %p.\n", iface, index, flags);
- return E_NOTIMPL; + *flags = 0; + + return S_OK; }
static HRESULT WINAPI MediaObject_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index, DMO_MEDIA_TYPE *type) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 713623b2448..211731db9ab 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -306,6 +306,11 @@ static void test_stream_info(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!flags, "Got flags %#x.\n", flags);
+ flags = 0xdeadbeef; + hr = IMediaObject_GetOutputStreamInfo(dmo, 0, &flags); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!flags, "Got flags %#x.\n", flags); + IMediaObject_Release(dmo); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mp3dmod/mp3dmod.c | 14 ++++++++++++-- dlls/mp3dmod/tests/mp3dmod.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 9e86bcc31d1..4df74fc0375 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -163,9 +163,19 @@ static HRESULT WINAPI MediaObject_GetOutputStreamInfo(IMediaObject *iface, DWORD
static HRESULT WINAPI MediaObject_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index, DMO_MEDIA_TYPE *type) { - FIXME("(%p)->(%d, %d, %p) stub!\n", iface, index, type_index, type); + TRACE("iface %p, index %u, type_index %u, type %p.\n", iface, index, type_index, type);
- return E_NOTIMPL; + if (type_index) + return DMO_E_NO_MORE_ITEMS; + + type->majortype = WMMEDIATYPE_Audio; + type->subtype = WMMEDIASUBTYPE_MP3; + type->formattype = GUID_NULL; + type->pUnk = NULL; + type->cbFormat = 0; + type->pbFormat = NULL; + + return S_OK; }
static HRESULT WINAPI MediaObject_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index, DMO_MEDIA_TYPE *type) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 211731db9ab..da785479990 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -314,6 +314,36 @@ static void test_stream_info(void) IMediaObject_Release(dmo); }
+static void test_media_types(void) +{ + DMO_MEDIA_TYPE mt; + IMediaObject *dmo; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_CMP3DecMediaObject, NULL, CLSCTX_INPROC_SERVER, + &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); + hr = IMediaObject_GetInputType(dmo, 0, 0, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio), "Got major type %s.\n", wine_dbgstr_guid(&mt.majortype)); + ok(IsEqualGUID(&mt.subtype, &WMMEDIASUBTYPE_MP3), "Got subtype %s.\n", wine_dbgstr_guid(&mt.subtype)); + ok(mt.bFixedSizeSamples == 0xcccccccc, "Got fixed size %d.\n", mt.bFixedSizeSamples); + ok(mt.bTemporalCompression == 0xcccccccc, "Got temporal compression %d.\n", mt.bTemporalCompression); + ok(mt.lSampleSize == 0xcccccccc, "Got sample size %u.\n", mt.lSampleSize); + ok(IsEqualGUID(&mt.formattype, &GUID_NULL), "Got format type %s.\n", + wine_dbgstr_guid(&mt.formattype)); + ok(!mt.pUnk, "Got pUnk %p.\n", mt.pUnk); + ok(!mt.cbFormat, "Got format size %u.\n", mt.cbFormat); + ok(!mt.pbFormat, "Got format block %p.\n", mt.pbFormat); + + hr = IMediaObject_GetInputType(dmo, 0, 1, &mt); + ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#x.\n", hr); + + IMediaObject_Release(dmo); +} + START_TEST(mp3dmod) { IMediaObject *dmo; @@ -333,6 +363,7 @@ START_TEST(mp3dmod) test_convert(); test_aggregation(); test_stream_info(); + test_media_types();
CoUninitialize(); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/mp3dmod/mp3dmod.c | 36 ++++++++++++++++++++++++--- dlls/mp3dmod/tests/mp3dmod.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 3 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 4df74fc0375..50b6803ff81 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -37,18 +37,23 @@ DEFINE_GUID(WMMEDIATYPE_Audio, 0x73647561,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(WMMEDIASUBTYPE_MP3,0x00000055,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(WMMEDIASUBTYPE_PCM,0x00000001,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); +DEFINE_GUID(WMFORMAT_WaveFormatEx, 0x05589f81,0xc356,0x11ce,0xbf,0x01,0x00,0xaa,0x00,0x55,0x59,0x5a);
WINE_DEFAULT_DEBUG_CHANNEL(mp3dmod);
static HINSTANCE mp3dmod_instance;
-struct mp3_decoder { +struct mp3_decoder +{ IUnknown IUnknown_inner; IMediaObject IMediaObject_iface; IUnknown *outer; LONG ref; mpg123_handle *mh; - DMO_MEDIA_TYPE outtype; + + DMO_MEDIA_TYPE intype, outtype; + BOOL intype_set; + IMediaBuffer *buffer; REFERENCE_TIME timestamp; }; @@ -98,6 +103,8 @@ static ULONG WINAPI Unknown_Release(IUnknown *iface)
if (!refcount) { + if (This->intype_set) + MoFreeMediaType(&This->intype); MoFreeMediaType(&This->outtype); mpg123_delete(This->mh); heap_free(This); @@ -187,7 +194,30 @@ static HRESULT WINAPI MediaObject_GetOutputType(IMediaObject *iface, DWORD index
static HRESULT WINAPI MediaObject_SetInputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { - FIXME("(%p)->(%d, %p, %#x) stub!\n", iface, index, type, flags); + struct mp3_decoder *dmo = impl_from_IMediaObject(iface); + + TRACE("iface %p, index %u, type %p, flags %#x.\n", iface, index, type, flags); + + if (flags & DMO_SET_TYPEF_CLEAR) + { + if (dmo->intype_set) + MoFreeMediaType(&dmo->intype); + dmo->intype_set = FALSE; + return S_OK; + } + + if (!IsEqualGUID(&type->majortype, &WMMEDIATYPE_Audio) + || !IsEqualGUID(&type->subtype, &WMMEDIASUBTYPE_MP3) + || !IsEqualGUID(&type->formattype, &WMFORMAT_WaveFormatEx)) + return DMO_E_TYPE_NOT_ACCEPTED; + + if (!(flags & DMO_SET_TYPEF_TEST_ONLY)) + { + if (dmo->intype_set) + MoFreeMediaType(&dmo->intype); + MoCopyMediaType(&dmo->intype, type); + dmo->intype_set = TRUE; + }
return S_OK; } diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index da785479990..dcf0820afb1 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -316,6 +316,20 @@ static void test_stream_info(void)
static void test_media_types(void) { + MPEGLAYER3WAVEFORMAT mp3fmt = + { + .wfx.nChannels = 2, + .wfx.nSamplesPerSec = 48000, + }; + DMO_MEDIA_TYPE input_mt = + { + .majortype = MEDIATYPE_Audio, + .subtype = WMMEDIASUBTYPE_MP3, + .formattype = FORMAT_WaveFormatEx, + .cbFormat = sizeof(mp3fmt), + .pbFormat = (BYTE *)&mp3fmt, + }; + DMO_MEDIA_TYPE mt; IMediaObject *dmo; HRESULT hr; @@ -341,6 +355,40 @@ static void test_media_types(void) hr = IMediaObject_GetInputType(dmo, 0, 1, &mt); ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#x.\n", hr);
+ hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + input_mt.majortype = GUID_NULL; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.majortype = MEDIATYPE_Stream; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.majortype = MEDIATYPE_Audio; + + input_mt.subtype = GUID_NULL; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.subtype = MEDIASUBTYPE_PCM; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.subtype = WMMEDIASUBTYPE_MP3; + + input_mt.formattype = GUID_NULL; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.formattype = FORMAT_None; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + input_mt.formattype = FORMAT_WaveFormatEx; + + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + mp3fmt.wfx.nChannels = 1; + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMediaObject_Release(dmo); }